Skip to content

Commit bfde604

Browse files
committed
Introduce a user-controlled timeout for SunRPC stuff
1 parent a9f9a8b commit bfde604

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/msf/core/exploit/sunrpc.rb

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,26 @@ def initialize(info = {})
3838

3939
register_advanced_options(
4040
[
41-
# XXX: Use portmapper to do call - Direct portmap to make the request to the program portmap_req
41+
OptInt.new('TIMEOUT', [true, 'Number of seconds to wait for responses to RPC calls', 5])
42+
# XXX: Use portmapper to do call - Direct portmap to make the request to the program portmap_req
4243
], Msf::Exploit::Remote::SunRPC)
4344

4445
register_options(
4546
[
46-
# XXX: XPORT
47+
# XXX: XPORT
4748
Opt::RHOST,
4849
Opt::RPORT(111),
4950
], Msf::Exploit::Remote::SunRPC
5051
)
5152
end
5253

53-
def sunrpc_create(protocol, program, version)
54+
def sunrpc_create(protocol, program, version, timeout = timeout)
5455
self.rpcobj = Rex::Proto::SunRPC::Client.new(
5556
:rhost => rhost,
5657
:rport => rport.to_i,
5758
:proto => protocol,
5859
:program => program,
60+
:timeout => timeout,
5961
:version => version,
6062
:context => {
6163
'Msf' => framework,
@@ -82,7 +84,7 @@ def sunrpc_create(protocol, program, version)
8284
rpcobj.pport = arr[5]
8385
end
8486

85-
def sunrpc_call(proc, buf, timeout=20)
87+
def sunrpc_call(proc, buf, timeout = timeout)
8688
ret = rpcobj.call(proc, buf, timeout)
8789
raise ::Rex::Proto::SunRPC::RPCError, "#{rhost}:#{rport} - SunRPC - No response to SunRPC call for procedure: #{proc}" unless ret
8890

@@ -157,6 +159,11 @@ def progresolv(number)
157159
return "UNKNOWN-#{number}"
158160
end
159161

162+
# Returns the time that this module will wait for RPC responses, in seconds
163+
def timeout
164+
datastore['TIMEOUT']
165+
end
166+
160167
# Used to track the last SunRPC context
161168
attr_accessor :rpcobj
162169
end

0 commit comments

Comments
 (0)