-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathxmlrpc-web-morerfc.diff
More file actions
172 lines (160 loc) · 4.84 KB
/
xmlrpc-web-morerfc.diff
File metadata and controls
172 lines (160 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Index: plugins/xmlrpc.rb
===================================================================
--- plugins/xmlrpc.rb (revision 7554)
+++ plugins/xmlrpc.rb (working copy)
@@ -45,13 +45,23 @@
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] ]
- self.server = ::Msf::RPC::Service.new(host,port,ssl,cert,ckey)
+ if(type == "Web")
+ print_status("XMLRPC Web URI: #{uri}")
+ self.server = ::Msf::RPC::WebService.new(port,host,uri)
+ elsif(type == "Basic")
+ self.server = ::Msf::RPC::Service.new(host,port,ssl,cert,ckey)
+ else
+ print_status("Invalid server type #{self.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.
Index: msfrpcd
===================================================================
--- msfrpcd (revision 7554)
+++ msfrpcd (working copy)
@@ -21,6 +21,8 @@
"-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]" ],
+ "-u" => [ true, "URI for Web server" ],
"-S" => [ false, "Disable SSL on the XMLRPC socket" ],
"-f" => [ false, "Run the daemon in the foreground" ],
"-h" => [ false, "Help banner" ])
@@ -29,7 +31,8 @@
'RunInForeground' => true,
'SSL' => true,
'ServerHost' => '0.0.0.0',
- 'ServerPort' => 55553
+ 'ServerPort' => 55553,
+ 'ServerType' => 'Basic'
}
foreground = false
@@ -50,6 +53,10 @@
opts['Pass'] = val
when "-f"
foreground = true
+ when "-t"
+ opts['ServerType'] = val
+ when "-u"
+ opts['URI'] = val
when "-h"
print("\nUsage: #{File.basename(__FILE__)} <options>\n" + arguments.usage)
exit
@@ -63,8 +70,10 @@
$0 = "msfrpcd"
-$stderr.puts "[*] XMLRPC starting on #{opts['ServerHost']}:#{opts['ServerPort']} (#{opts['SSL'] ? "SSL" : "NO SSL"})..."
+$stderr.puts "[*] XMLRPC starting on #{opts['ServerHost']}:#{opts['ServerPort']} (#{opts['SSL'] ? "SSL" : "NO SSL"}):#{opts['ServerType']}..."
+$stderr.puts "[*] URI: #{opts['URI']}" if(opts['URI'])
+
# Create an instance of the framework
$framework = Msf::Simple::Framework.create
Index: lib/msf/core/rpc/service.rb
===================================================================
--- lib/msf/core/rpc/service.rb (revision 7554)
+++ lib/msf/core/rpc/service.rb (working copy)
@@ -1,6 +1,8 @@
require "xmlrpc/server"
+require 'rex/service_manager'
require "rex"
+
module Msf
module RPC
class Service < ::XMLRPC::BasicServer
@@ -71,5 +73,69 @@
end
end
+
+class WebService < ::XMLRPC::BasicServer
+
+ attr_accessor :service, :state, :srvhost, :srvport, :uri
+
+
+ def initialize(port, host, uri = "/RPC2")
+ self.srvhost = host
+ self.srvport = port
+ self.uri = uri
+ self.service = nil
+ super()
+ end
+
+ def start
+ self.state = {}
+ self.service = Rex::ServiceManager.start(
+ Rex::Proto::Http::Server,
+ self.srvport ,
+ self.srvhost,
+ {
+ }
+ )
+
+ uopts = {
+ 'Proc' => Proc.new { |cli, req|
+ on_request_uri(cli, req)
+ },
+ 'Path' => self.uri
+ }
+
+ self.service.add_resource(self.uri,uopts)
+ end
+
+ def stop
+ self.state = {}
+ self.service.stop
+ end
+
+ def wait
+ self.service.wait
+ end
+
+ def on_client_close(c)
+ self.state.delete(c)
+ end
+
+ def on_client_connect(c)
+ self.state[c] = ""
+ end
+ def on_request_uri(cli, req)
+ begin
+ res = Rex::Proto::Http::Response.new()
+ res.body = process(req.body)
+ rescue XMLRPC::FaultException => e
+ res = Rex::Proto::Http::Response.new(e.faultCode,e.faultString)
+ rescue
+ res = Rex::Proto::Http::Response.new(404,"An Error Occured")
+ end
+ cli.send_response(res)
+ end
+
end
+
end
+end
Index: lib/msf/core/rpc/module.rb
===================================================================
--- lib/msf/core/rpc/module.rb (revision 7554)
+++ lib/msf/core/rpc/module.rb (working copy)
@@ -125,8 +125,8 @@
def execute(token, mtype, mname, opts)
authenticate(token)
+ mod = _find_module(mtype,mname)
begin
- mod = _find_module(mtype,mname)
case mtype
when 'exploit'
_run_exploit(mod, opts)