Remove xmlrpc support in this branch (only msgpack is supported)
This commit is contained in:
@@ -37,7 +37,7 @@ opts = {
|
||||
'User' => 'msf',
|
||||
'SSL' => true,
|
||||
'ServerPort' => 55553,
|
||||
'Type' => 'Xml'
|
||||
'Type' => 'Msg'
|
||||
}
|
||||
|
||||
# Parse command line arguments.
|
||||
@@ -53,8 +53,6 @@ arguments.parse(ARGV) { |opt, idx, val|
|
||||
opts['User'] = val
|
||||
when '-P'
|
||||
opts['Pass'] = val
|
||||
when '-t'
|
||||
opts['Type'] = (val =~ /xml/i) ? 'XML' : 'Msg'
|
||||
when "-h"
|
||||
print("\nUsage: #{File.basename(__FILE__)} <options>\n" + arguments.usage)
|
||||
exit
|
||||
@@ -76,11 +74,7 @@ end
|
||||
|
||||
$0 = "msfrpc"
|
||||
|
||||
if opts['Type'] == 'Msg'
|
||||
require 'msf/core/rpc/v10/client'
|
||||
else
|
||||
require 'msf/core/rpc/client'
|
||||
end
|
||||
require 'msf/core/rpc/v10/client'
|
||||
require 'rex/ui'
|
||||
|
||||
rpc = Msf::RPC::Client.new(
|
||||
|
||||
@@ -28,7 +28,6 @@ arguments = Rex::Parser::Arguments.new(
|
||||
"-p" => [ true, "Bind to this port instead of 55553" ],
|
||||
"-U" => [ true, "Specify the username to access msfrpcd" ],
|
||||
"-P" => [ true, "Specify the password to access msfrpcd" ],
|
||||
"-t" => [ true, "Server type, [Basic|Web|Msg]" ],
|
||||
"-u" => [ true, "URI for Web server" ],
|
||||
"-S" => [ false, "Disable SSL on the RPC socket" ],
|
||||
"-f" => [ false, "Run the daemon in the foreground" ],
|
||||
@@ -40,7 +39,7 @@ opts = {
|
||||
'SSL' => true,
|
||||
'ServerHost' => '0.0.0.0',
|
||||
'ServerPort' => 55553,
|
||||
'ServerType' => 'Basic'
|
||||
'ServerType' => 'Msg'
|
||||
}
|
||||
|
||||
foreground = false
|
||||
@@ -62,8 +61,6 @@ arguments.parse(ARGV) { |opt, idx, val|
|
||||
opts['Pass'] = val
|
||||
when "-f"
|
||||
foreground = true
|
||||
when "-t"
|
||||
opts['ServerType'] = val
|
||||
when "-u"
|
||||
opts['URI'] = val
|
||||
when "-n"
|
||||
@@ -81,8 +78,7 @@ end
|
||||
|
||||
$0 = "msfrpcd"
|
||||
|
||||
rpctype = 'XML'
|
||||
rpctype = 'MSG' if opts['ServerType'].downcase == 'msg'
|
||||
rpctype = 'MSG'
|
||||
|
||||
$stderr.puts "[*] #{rpctype}RPC starting on #{opts['ServerHost']}:#{opts['ServerPort']} (#{opts['SSL'] ? "SSL" : "NO SSL"}):#{opts['ServerType']}..."
|
||||
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
# This plugin provides an msf daemon interface that spawns a listener on a
|
||||
# defined port (default 55553) and gives each connecting client its own
|
||||
# console interface. These consoles all share the same framework instance.
|
||||
# Be aware that the console instance that spawns on the port is entirely
|
||||
# unauthenticated, so realize that you have been warned.
|
||||
#
|
||||
# $Revision$
|
||||
#
|
||||
|
||||
require "msf/core/rpc"
|
||||
require "fileutils"
|
||||
|
||||
module Msf
|
||||
|
||||
###
|
||||
#
|
||||
# This class implements the msfd plugin interface.
|
||||
#
|
||||
###
|
||||
class Plugin::XMLRPC < Msf::Plugin
|
||||
|
||||
#
|
||||
# The default local hostname that the server listens on.
|
||||
#
|
||||
DefaultHost = "127.0.0.1"
|
||||
|
||||
#
|
||||
# The default local port that the server listens on.
|
||||
#
|
||||
DefaultPort = 55553
|
||||
|
||||
#
|
||||
# ServerPort
|
||||
#
|
||||
# The local port to listen on for connections. The default is 55553
|
||||
#
|
||||
def initialize(framework, opts)
|
||||
super
|
||||
|
||||
host = opts['ServerHost'] || DefaultHost
|
||||
port = opts['ServerPort'] || DefaultPort
|
||||
ssl = (opts['SSL'] and opts['SSL'].to_s =~ /^[ty]/i) ? true : false
|
||||
cert = opts['SSLCert']
|
||||
ckey = opts['SSLKey']
|
||||
|
||||
user = opts['User'] || "msf"
|
||||
pass = opts['Pass'] || ::Rex::Text.rand_text_alphanumeric(8)
|
||||
type = opts['ServerType'] || "Basic"
|
||||
uri = opts['URI'] || "/RPC2"
|
||||
|
||||
print_status("XMLRPC Service: #{host}:#{port} #{ssl ? " (SSL)" : ""}")
|
||||
print_status("XMLRPC Username: #{user}")
|
||||
print_status("XMLRPC Password: #{pass}")
|
||||
print_status("XMLRPC Server Type: #{type}")
|
||||
|
||||
@users = [ [user,pass] ]
|
||||
if(type =~ /Web/i)
|
||||
print_status("XMLRPC Web URI: #{uri}")
|
||||
self.server = ::Msf::RPC::WebService.new(port,host,uri)
|
||||
elsif(type =~ /Basic/i)
|
||||
self.server = ::Msf::RPC::Service.new(host,port,ssl,cert,ckey)
|
||||
else
|
||||
print_status("Invalid server type #{type}, please choose Web or Basic")
|
||||
end
|
||||
|
||||
# If the run in foreground flag is not specified, then go ahead and fire
|
||||
# it off in a worker thread.
|
||||
if (opts['RunInForeground'] != true)
|
||||
# Store a handle to the thread so we can kill it during
|
||||
# cleanup when we get unloaded.
|
||||
self.thread = Thread.new {
|
||||
run
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Returns 'xmlrpc'
|
||||
#
|
||||
def name
|
||||
"xmlrpc"
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the plugin description.
|
||||
#
|
||||
def desc
|
||||
"Provides a XMLRPC interface over a listening TCP port."
|
||||
end
|
||||
|
||||
#
|
||||
# The meat of the plugin, sets up handlers for requests
|
||||
#
|
||||
def run
|
||||
|
||||
# Initialize the list of authenticated sessions
|
||||
@tokens = {}
|
||||
|
||||
args = [framework,@tokens,@users]
|
||||
|
||||
# Add handlers for every class
|
||||
self.server.add_handler(::XMLRPC::iPIMethods("auth"),
|
||||
::Msf::RPC::Auth.new(*args)
|
||||
)
|
||||
|
||||
# Note the extra argument for core as compared to the other
|
||||
# handlers. This allows rpc clients access to the plugin so
|
||||
# they can shutdown the server.
|
||||
core_args = args + [self]
|
||||
self.server.add_handler(::XMLRPC::iPIMethods("core"),
|
||||
::Msf::RPC::Core.new(*core_args)
|
||||
)
|
||||
|
||||
self.server.add_handler(::XMLRPC::iPIMethods("session"),
|
||||
::Msf::RPC::Session.new(*args)
|
||||
)
|
||||
|
||||
self.server.add_handler(::XMLRPC::iPIMethods("job"),
|
||||
::Msf::RPC::Job.new(*args)
|
||||
)
|
||||
|
||||
self.server.add_handler(::XMLRPC::iPIMethods("module"),
|
||||
::Msf::RPC::Module.new(*args)
|
||||
)
|
||||
|
||||
self.server.add_handler(::XMLRPC::iPIMethods("console"),
|
||||
::Msf::RPC::Console.new(*args)
|
||||
)
|
||||
|
||||
self.server.add_handler(::XMLRPC::iPIMethods("db"),
|
||||
::Msf::RPC::Db.new(*args)
|
||||
)
|
||||
|
||||
self.server.add_handler(::XMLRPC::iPIMethods("plugin"),
|
||||
::Msf::RPC::Plugin.new(*args)
|
||||
)
|
||||
|
||||
# Set the default/catch-all handler
|
||||
self.server.set_default_handler do |name, *args|
|
||||
raise ::XMLRPC::FaultException.new(-99, "Method #{name} missing or wrong number of parameters!")
|
||||
end
|
||||
|
||||
# Start the actual service
|
||||
self.server.start
|
||||
|
||||
# Wait for the service to complete
|
||||
self.server.wait
|
||||
end
|
||||
|
||||
#
|
||||
# Closes the listener service.
|
||||
#
|
||||
def cleanup
|
||||
self.server.stop if self.server
|
||||
self.thread.kill if self.thread
|
||||
self.server = nil
|
||||
super
|
||||
end
|
||||
|
||||
def stop_rpc
|
||||
print_line
|
||||
print_status("XMLRPC Client requested server stop")
|
||||
# Plugins aren't really meant to be able to unload themselves, so this
|
||||
# is a bit of a corner case. Unloading ourselves ends up killing the
|
||||
# thread that's doing the unloading so we need to fire off the unload
|
||||
# in a seperate one.
|
||||
Thread.new {
|
||||
framework.plugins.unload(self)
|
||||
}
|
||||
nil
|
||||
end
|
||||
|
||||
#
|
||||
# The XMLRPC instance.
|
||||
#
|
||||
attr_accessor :server
|
||||
attr_accessor :thread
|
||||
attr_accessor :users
|
||||
attr_accessor :tokens
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user