Skip to content

Commit

Permalink
Clean up Ruby style in sunrpc_portmapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jhart-r7 committed Nov 17, 2014
1 parent 47c7df9 commit 91abe6f
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions modules/auxiliary/scanner/misc/sunrpc_portmapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
require 'msf/core'

class Metasploit3 < Msf::Auxiliary

include Msf::Exploit::Remote::SunRPC
include Msf::Auxiliary::Report
include Msf::Auxiliary::Scanner

def initialize
super(
'Name' => 'SunRPC Portmap Program Enumerator',
'Description' => %q{
This module calls the target portmap service and enumerates all
program entries and their running port numbers.
},
'Author' => ['<tebo[at]attackresearch.com>'],
'References' =>
'Name' => 'SunRPC Portmap Program Enumerator',
'Description' => '
This module calls the target portmap service and enumerates all program
entries and their running port numbers.
',
'Author' => ['<tebo[at]attackresearch.com>'],
'References' =>
[
['URL', 'http://www.ietf.org/rfc/rfc1057.txt'],
['URL', 'http://www.ietf.org/rfc/rfc1057.txt']
],
'License' => MSF_LICENSE
)
Expand All @@ -37,29 +36,28 @@ def run_host(ip)
procedure = 4

sunrpc_create('udp', program, progver)
sunrpc_authnull()
sunrpc_authnull
resp = sunrpc_call(procedure, "")

progs = resp[3,1].unpack('C')[0]
progs = resp[3, 1].unpack('C')[0]
maps = []
if (progs == 0x01)
while XDR.decode_int!(resp) == 1 do
map = XDR.decode!(resp, Integer, Integer, Integer, Integer)
maps << map
while XDR.decode_int!(resp) == 1
maps << XDR.decode!(resp, Integer, Integer, Integer, Integer)
end
end
sunrpc_destroy
return if maps.empty?
print_good("#{peer} - Found #{maps.size} programs available")

table = Rex::Ui::Text::Table.new(
'Header' => "SunRPC Programs for #{ip}.",
'Header' => "SunRPC Programs for #{ip}",
'Indent' => 1,
'Columns' => %w(Name Number Version Port Protocol)
)

maps.each do |map|
prog, vers, prot_num, port = map[0,4]
prog, vers, prot_num, port = map[0, 4]
thing = "RPC Program ##{prog} v#{vers} on port #{port} w/ protocol #{prot_num}"
if prot_num == 0x06
proto = 'tcp'
Expand All @@ -73,17 +71,16 @@ def run_host(ip)
resolved = progresolv(prog)
table << [ resolved, prog, vers, port, proto ]
report_service(
:host => ip,
:port => port,
:proto => proto,
:name => resolved,
:info => "Prog: #{prog} Version: #{vers} - via portmapper"
host: ip,
port: port,
proto: proto,
name: resolved,
info: "Prog: #{prog} Version: #{vers} - via portmapper"
)
end

print_good(table.to_s)
rescue ::Rex::Proto::SunRPC::RPCTimeout
end
end

end

0 comments on commit 91abe6f

Please sign in to comment.