Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 98 lines (77 sloc) 2.199 kb
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
1 #!/usr/bin/env ruby
d656e31 HD Moore Mark all libraries as defaulting to 8-bit strings
hmoore-r7 authored
2 # -*- coding: binary -*-
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
3 #
0e72894 Joshua J. Drake more cleanups
jduck authored
4 # $Id$
5 #
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
6 # This user interface allows users to interact with a remote framework
8182f53 typo
kris authored
7 # instance through a XMLRPC socket.
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
8 #
0e72894 Joshua J. Drake more cleanups
jduck authored
9 # $Revision$
10 #
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
11
beb0cc7 HD Moore Patch from Jonathan Steel to fix double-symlinks
hmoore-r7 authored
12 msfbase = __FILE__
13 while File.symlink?(msfbase)
14 msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
15 end
16
bdf8d06 HD Moore Load from the absolute, not relative path
hmoore-r7 authored
17 $:.unshift(File.expand_path(File.join(File.dirname(msfbase), 'lib')))
bfc32f4 Adds fastlib and lib/metasploit.fastlib to the include path
HD Moore authored
18 require 'fastlib'
4bcbdc5 Tod Beardsley Cutting over rails3 to master.
todb authored
19 require 'msfenv'
bfc32f4 Adds fastlib and lib/metasploit.fastlib to the include path
HD Moore authored
20
7d2b2b1 HD Moore Fix up bad line removals
hmoore-r7 authored
21
bfc32f4 Adds fastlib and lib/metasploit.fastlib to the include path
HD Moore authored
22
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
23 $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
24
9278035 Joshua J. Drake performance: parse args before loading everything
jduck authored
25 require 'rex/parser/arguments'
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
26
6dc9be6 comment fix
kris authored
27 # Declare the argument parser for msfrpc
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
28 arguments = Rex::Parser::Arguments.new(
71a01e1 changing host selection option -h to -a to avoid collision with help -h
kris authored
29 "-a" => [ true, "Connect to this IP address" ],
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
30 "-p" => [ true, "Connect to the specified port instead of 55553" ],
31 "-U" => [ true, "Specify the username to access msfrpcd" ],
32 "-P" => [ true, "Specify the password to access msfrpcd" ],
7f758e4 HD Moore Fix up SSL behavior (correctly, this time). Update the msfrpc tools to s...
hmoore-r7 authored
33 "-t" => [ true, "Type of RPC daemon, [XML|Msg]" ],
34 "-S" => [ false, "Disable SSL on the RPC socket" ],
32f9bba whoops, make -h available -- was printing usage but because of an error
kris authored
35 "-h" => [ false, "Help banner" ]
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
36 )
37
0e72894 Joshua J. Drake more cleanups
jduck authored
38 opts = {
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
39 'User' => 'msf',
40 'SSL' => true,
7f758e4 HD Moore Fix up SSL behavior (correctly, this time). Update the msfrpc tools to s...
hmoore-r7 authored
41 'ServerPort' => 55553,
e91a64f HD Moore Remove xmlrpc support in this branch (only msgpack is supported)
hmoore-r7 authored
42 'Type' => 'Msg'
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
43 }
44
45 # Parse command line arguments.
46 arguments.parse(ARGV) { |opt, idx, val|
47 case opt
71a01e1 changing host selection option -h to -a to avoid collision with help -h
kris authored
48 when "-a"
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
49 opts['ServerHost'] = val
50 when "-S"
51 opts['SSL'] = false
52 when "-p"
53 opts['ServerPort'] = val
54 when '-U'
55 opts['User'] = val
56 when '-P'
57 opts['Pass'] = val
58 when "-h"
59 print("\nUsage: #{File.basename(__FILE__)} <options>\n" + arguments.usage)
60 exit
61 end
62 }
63
64
65 if(not opts['ServerHost'])
2faa983 Use [-] instead of [*] for error messages
kris authored
66 $stderr.puts "[-] Error: a server IP must be specified (-a)"
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
67 $stderr.puts arguments.usage
68 exit(0)
69 end
70
71 if(not opts['Pass'])
2faa983 Use [-] instead of [*] for error messages
kris authored
72 $stderr.puts "[-] Error: a password must be specified (-P)"
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
73 $stderr.puts arguments.usage
74 exit(0)
75 end
76
77 $0 = "msfrpc"
78
e91a64f HD Moore Remove xmlrpc support in this branch (only msgpack is supported)
hmoore-r7 authored
79 require 'msf/core/rpc/v10/client'
9278035 Joshua J. Drake performance: parse args before loading everything
jduck authored
80 require 'rex/ui'
81
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
82 rpc = Msf::RPC::Client.new(
83 :host => opts['ServerHost'],
84 :port => opts['ServerPort'],
0e72894 Joshua J. Drake more cleanups
jduck authored
85 :ssl => opts['SSL']
71c5175 HD Moore This patch introduces a really basic RPC service. It is still a long way...
hmoore-r7 authored
86 )
87
88 res = rpc.login(opts['User'], opts['Pass'])
89
90 puts "[*] The 'rpc' object holds the RPC client interface"
91 puts ""
92
93 while(ARGV.shift)
94 end
95
96 Rex::Ui::Text::IrbShell.new(binding).run
7f758e4 HD Moore Fix up SSL behavior (correctly, this time). Update the msfrpc tools to s...
hmoore-r7 authored
97
Something went wrong with that request. Please try again.