Add ipv6 resolution and remove nix

bug/bundler_fix
Meatballs 2013-06-20 22:17:31 +01:00
parent 67791c12a5
commit 6c62463f83
3 changed files with 25 additions and 9 deletions

View File

@ -11,6 +11,14 @@
#
###
##
#
# Net
#
##
AF_INET = 2
AF_INET6 = 23
##
#
# Permissions

View File

@ -33,9 +33,10 @@ class Resolve
self.client = client
end
def resolve_host(hostname)
def resolve_host(hostname, family=AF_INET)
request = Packet.create_request('stdapi_net_resolve_host')
request.add_tlv(TLV_TYPE_HOST_NAME, hostname)
request.add_tlv(TLV_TYPE_ADDR_TYPE, family)
response = client.send_request(request)
@ -45,8 +46,9 @@ class Resolve
return raw_to_host_ip_pair(hostname, raw, type)
end
def resolve_hosts(hostnames)
def resolve_hosts(hostnames, family=AF_INET)
request = Packet.create_request('stdapi_net_resolve_hosts')
request.add_tlv(TLV_TYPE_ADDR_TYPE, family)
hostnames.each do |hostname|
request.add_tlv(TLV_TYPE_HOST_NAME, hostname)
@ -58,7 +60,6 @@ class Resolve
raws = []
types = []
# This is probably neater creating a TLV_GROUP?
response.each(TLV_TYPE_IP) do |raw|
raws << raw
end
@ -86,7 +87,7 @@ class Resolve
if raw.empty?
ip = ""
else
if type == 2
if type == AF_INET
ip = Rex::Socket.addr_ntoa(raw[0..3])
else
ip = Rex::Socket.addr_ntoa(raw[0..16])

View File

@ -12,9 +12,9 @@ class Metasploit3 < Msf::Post
def initialize(info={})
super( update_info( info,
'Name' => 'Multi General Resolve Hosts',
'Name' => 'Windows Resolve Hosts',
'Description' => %q{
Resolves hostnames.
Resolves hostnames to either IPv4 or IPv6 addresses.
},
'License' => MSF_LICENSE,
'Author' => [ 'Ben Campbell <eat_meatballs[at]hotmail.co.uk>' ],
@ -23,19 +23,26 @@ class Metasploit3 < Msf::Post
))
register_options([
OptString.new('HOSTNAMES', [true, 'Comma seperated list of hostnames to resolve.'])
OptString.new('HOSTNAMES', [true, 'Comma seperated list of hostnames to resolve.']),
OptEnum.new('AI_FAMILY', [true, 'Address Family', 'IPv4', ['IPv4', 'IPv6'] ])
], self.class)
end
def run
hosts = datastore['HOSTNAMES'].split(',')
if datastore['FAMILY'] == 'IPv4'
family = AF_INET
else
family = AF_INET6
end
# Clear whitespace
hosts.collect{|x| x.strip!}
print_status("Attempting to resolve '#{hosts.join(', ')}' on #{sysinfo['Computer']}") if not sysinfo.nil?
response = client.net.resolve.resolve_hosts(hosts)
response = client.net.resolve.resolve_hosts(hosts, family)
table = Rex::Ui::Text::Table.new(
'Indent' => 0,