metasploit-framework/modules/auxiliary/scanner/misc/sunrpc_portmapper.rb

80 lines
2.0 KiB
Ruby
Raw Normal View History

##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
2013-08-30 21:28:54 +00:00
include Msf::Exploit::Remote::SunRPC
include Msf::Auxiliary::Report
include Msf::Auxiliary::Scanner
2013-08-30 21:28:54 +00:00
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' =>
[
['URL', 'http://www.ietf.org/rfc/rfc1057.txt'],
],
'License' => MSF_LICENSE
)
2013-08-30 21:28:54 +00:00
register_options([], self.class)
end
2013-08-30 21:28:54 +00:00
def run_host(ip)
vprint_status "#{ip}:#{rport} - SunRPC - Enumerating programs"
2013-08-30 21:28:54 +00:00
begin
program = 100000
progver = 2
procedure = 4
2013-08-30 21:28:54 +00:00
sunrpc_create('udp', program, progver)
sunrpc_authnull()
resp = sunrpc_call(procedure, "")
2013-08-30 21:28:54 +00:00
progs = resp[3,1].unpack('C')[0]
maps = []
2013-08-30 21:28:54 +00:00
if (progs == 0x01)
print_good("#{ip}:#{rport} - Programs available")
2013-08-30 21:28:54 +00:00
while XDR.decode_int!(resp) == 1 do
map = XDR.decode!(resp, Integer, Integer, Integer, Integer)
maps << map
end
end
sunrpc_destroy
2013-08-30 21:28:54 +00:00
lines = []
maps.each do |map|
prog, vers, prot, port = map[0,4]
prot = if prot == 0x06; "tcp"
elsif prot == 0x11; "udp"
end
lines << "\t#{progresolv(prog)} - #{port}/#{prot}"
2013-08-30 21:28:54 +00:00
report_service(
:host => ip,
:port => port,
:proto => prot,
:name => progresolv(prog),
:info => "Prog: #{prog} Version: #{vers} - via portmapper"
)
end
2013-08-30 21:28:54 +00:00
# So we don't print a line for every program version
lines.uniq.each {|line| print_line(line)}
2013-08-30 21:28:54 +00:00
rescue ::Rex::Proto::SunRPC::RPCTimeout
end
end
end