metasploit-framework/modules/auxiliary/gather/natpmp_external_address.rb

65 lines
1.7 KiB
Ruby
Raw Normal View History

2013-03-07 23:53:19 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
2013-03-07 23:53:19 +00:00
##
2016-03-08 13:02:44 +00:00
class MetasploitModule < Msf::Auxiliary
2013-08-30 21:28:54 +00:00
include Msf::Auxiliary::Report
include Msf::Exploit::Remote::Udp
include Msf::Auxiliary::UDPScanner
include Msf::Auxiliary::NATPMP
include Rex::Proto::NATPMP
2013-08-30 21:28:54 +00:00
def initialize
super(
'Name' => 'NAT-PMP External Address Scanner',
'Description' => 'Scan NAT devices for their external address using NAT-PMP',
'Author' => 'Jon Hart <jhart[at]spoofed.org>',
'License' => MSF_LICENSE
)
2013-08-30 21:28:54 +00:00
end
def scan_host(ip)
scanner_send(@probe, ip, datastore['RPORT'])
2013-08-30 21:28:54 +00:00
end
def scanner_prescan(batch)
@probe = external_address_request
end
def scanner_process(data, shost, sport)
(ver, op, result, epoch, external_address) = parse_external_address_response(data)
peer = "#{shost}:#{sport}"
if (ver == 0 && op == 128 && result == 0)
print_good("#{peer} -- external address #{external_address}")
# report its external address as alive
if inside_workspace_boundary?(external_address)
report_host(
:host => external_address,
:state => Msf::HostState::Alive
)
end
else
print_error("#{peer} -- unexpected version/opcode/result/address: #{ver}/#{op}/#{result}/#{external_address}")
2013-08-30 21:28:54 +00:00
end
2013-08-30 21:28:54 +00:00
# report the host we scanned as alive
report_host(
:host => shost,
2013-08-30 21:28:54 +00:00
:state => Msf::HostState::Alive
)
2013-08-30 21:28:54 +00:00
# report NAT-PMP as being open
report_service(
:host => shost,
:port => sport,
2013-08-30 21:28:54 +00:00
:proto => 'udp',
:name => 'natpmp',
:state => Msf::ServiceState::Open
)
end
end