2008-12-02 22:09:34 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Id$
|
|
|
|
#
|
2008-12-02 22:09:34 +00:00
|
|
|
# This user interface allows users to interact with a remote framework
|
2009-01-04 07:55:56 +00:00
|
|
|
# instance through a XMLRPC socket.
|
2008-12-02 22:09:34 +00:00
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Revision$
|
|
|
|
#
|
2008-12-02 22:09:34 +00:00
|
|
|
|
2009-01-30 06:27:10 +00:00
|
|
|
msfbase = __FILE__
|
|
|
|
while File.symlink?(msfbase)
|
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
|
|
end
|
|
|
|
|
2012-02-04 06:32:37 +00:00
|
|
|
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
|
2011-11-21 20:18:57 +00:00
|
|
|
require 'fastlib'
|
|
|
|
|
2011-11-24 05:10:43 +00:00
|
|
|
|
2011-11-21 20:18:57 +00:00
|
|
|
|
2008-12-02 22:09:34 +00:00
|
|
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
|
|
|
|
2010-10-21 05:08:01 +00:00
|
|
|
require 'rex/parser/arguments'
|
2008-12-02 22:09:34 +00:00
|
|
|
|
2008-12-19 23:43:45 +00:00
|
|
|
# Declare the argument parser for msfrpc
|
2008-12-02 22:09:34 +00:00
|
|
|
arguments = Rex::Parser::Arguments.new(
|
2008-12-20 07:31:47 +00:00
|
|
|
"-a" => [ true, "Connect to this IP address" ],
|
2008-12-02 22:09:34 +00:00
|
|
|
"-p" => [ true, "Connect to the specified port instead of 55553" ],
|
|
|
|
"-U" => [ true, "Specify the username to access msfrpcd" ],
|
|
|
|
"-P" => [ true, "Specify the password to access msfrpcd" ],
|
2011-07-29 23:58:05 +00:00
|
|
|
"-t" => [ true, "Type of RPC daemon, [XML|Msg]" ],
|
|
|
|
"-S" => [ false, "Disable SSL on the RPC socket" ],
|
2008-12-22 01:36:56 +00:00
|
|
|
"-h" => [ false, "Help banner" ]
|
2008-12-02 22:09:34 +00:00
|
|
|
)
|
|
|
|
|
2010-05-03 17:13:09 +00:00
|
|
|
opts = {
|
2008-12-02 22:09:34 +00:00
|
|
|
'User' => 'msf',
|
|
|
|
'SSL' => true,
|
2011-07-29 23:58:05 +00:00
|
|
|
'ServerPort' => 55553,
|
2011-12-04 01:50:20 +00:00
|
|
|
'Type' => 'Msg'
|
2008-12-02 22:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Parse command line arguments.
|
|
|
|
arguments.parse(ARGV) { |opt, idx, val|
|
|
|
|
case opt
|
2008-12-20 07:31:47 +00:00
|
|
|
when "-a"
|
2008-12-02 22:09:34 +00:00
|
|
|
opts['ServerHost'] = val
|
|
|
|
when "-S"
|
|
|
|
opts['SSL'] = false
|
|
|
|
when "-p"
|
|
|
|
opts['ServerPort'] = val
|
|
|
|
when '-U'
|
|
|
|
opts['User'] = val
|
|
|
|
when '-P'
|
|
|
|
opts['Pass'] = val
|
|
|
|
when "-h"
|
|
|
|
print("\nUsage: #{File.basename(__FILE__)} <options>\n" + arguments.usage)
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(not opts['ServerHost'])
|
2009-03-11 00:10:27 +00:00
|
|
|
$stderr.puts "[-] Error: a server IP must be specified (-a)"
|
2008-12-02 22:09:34 +00:00
|
|
|
$stderr.puts arguments.usage
|
|
|
|
exit(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
if(not opts['Pass'])
|
2009-03-11 00:10:27 +00:00
|
|
|
$stderr.puts "[-] Error: a password must be specified (-P)"
|
2008-12-02 22:09:34 +00:00
|
|
|
$stderr.puts arguments.usage
|
|
|
|
exit(0)
|
|
|
|
end
|
|
|
|
|
|
|
|
$0 = "msfrpc"
|
|
|
|
|
2011-12-04 01:50:20 +00:00
|
|
|
require 'msf/core/rpc/v10/client'
|
2010-10-21 05:08:01 +00:00
|
|
|
require 'rex/ui'
|
|
|
|
|
2008-12-02 22:09:34 +00:00
|
|
|
rpc = Msf::RPC::Client.new(
|
|
|
|
:host => opts['ServerHost'],
|
|
|
|
:port => opts['ServerPort'],
|
2010-05-03 17:13:09 +00:00
|
|
|
:ssl => opts['SSL']
|
2008-12-02 22:09:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
res = rpc.login(opts['User'], opts['Pass'])
|
|
|
|
|
|
|
|
puts "[*] The 'rpc' object holds the RPC client interface"
|
|
|
|
puts ""
|
|
|
|
|
|
|
|
while(ARGV.shift)
|
|
|
|
end
|
|
|
|
|
|
|
|
Rex::Ui::Text::IrbShell.new(binding).run
|
2011-07-29 23:58:05 +00:00
|
|
|
|