Skip to content

Commit

Permalink
Introduce a user-controlled timeout for SunRPC stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
jhart-r7 committed Nov 17, 2014
1 parent 7098d89 commit 151df3a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/msf/core/exploit/sunrpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,26 @@ def initialize(info = {})

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

register_options(
[
# XXX: XPORT
# XXX: XPORT
Opt::RHOST,
Opt::RPORT(111),
], Msf::Exploit::Remote::SunRPC
)
end

def sunrpc_create(protocol, program, version)
def sunrpc_create(protocol, program, version, timeout = timeout)
self.rpcobj = Rex::Proto::SunRPC::Client.new(
:rhost => rhost,
:rport => rport.to_i,
:proto => protocol,
:program => program,
:timeout => timeout,
:version => version,
:context => {
'Msf' => framework,
Expand All @@ -82,7 +84,7 @@ def sunrpc_create(protocol, program, version)
rpcobj.pport = arr[5]
end

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

Expand Down Expand Up @@ -157,6 +159,11 @@ def progresolv(number)
return "UNKNOWN-#{number}"
end

# Returns the time that this module will wait for RPC responses, in seconds
def timeout
datastore['TIMEOUT']
end

# Used to track the last SunRPC context
attr_accessor :rpcobj
end
Expand Down

0 comments on commit 151df3a

Please sign in to comment.