Skip to content

Commit 0cbc302

Browse files
committed
Addresses PR feedback
1 parent fd0f1d7 commit 0cbc302

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

lib/msf/core/post/dns/resolve_host.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ module ResolveHost
1313
#
1414
# @param [String] host Hostname
1515
# @return [Array, nil] result[:ips], ips The resolved IPs
16-
def resolve_host(host)
16+
def resolve_host(host, family)
1717
if client.respond_to?(:net) && client.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_NET_RESOLVE_HOST)
18-
result = client.net.resolve.resolve_host(host)
18+
result = client.net.resolve.resolve_host(host, family)
1919
result[:ips]
2020
else
2121
ips = []

modules/post/windows/gather/enum_computers.rb

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ def run
6161
#
6262
# @param [String] host Hostname
6363
# @return [String] ip The resolved IP
64-
def gethost(hostname)
64+
def gethost(hostname, family)
6565
## get IP for host
6666
vprint_status("Looking up IP for #{hostname}")
67-
resolve_host(hostname).join(', ')
67+
resolve_host(hostname, family)
6868
end
6969

7070
def get_domain_computers
@@ -87,6 +87,7 @@ def get_domain_computers
8787
end
8888

8989
def list_computers(domain, hosts)
90+
meterpreter_dns_resolving_errors = []
9091
tbl = Rex::Text::Table.new(
9192
'Header' => 'List of identified Hosts.',
9293
'Indent' => 1,
@@ -98,12 +99,29 @@ def list_computers(domain, hosts)
9899
]
99100
)
100101
hosts.each do |hostname|
101-
hostip = gethost(hostname)
102-
tbl << [domain, hostname, hostip]
102+
begin
103+
hostipv4 = gethost(hostname, AF_INET)
104+
rescue Rex::Post::Meterpreter::RequestError => e
105+
meterpreter_dns_resolving_errors << "IPV4: #{hostname} could not be resolved - #{e}"
106+
end
107+
108+
begin
109+
hostname = "google.com"
110+
hostipv6 = gethost(hostname, AF_INET6)
111+
rescue Rex::Post::Meterpreter::RequestError => e
112+
meterpreter_dns_resolving_errors << "IPV6: #{hostname} could not be resolved - #{e}"
113+
end
114+
115+
hostipv4.each { |ip| tbl << [domain, hostname, ip] } unless hostipv4.nil?
116+
hostipv6.each { |ip| tbl << [domain, hostname, ip] } unless hostipv6.nil?
103117
end
104118

105119
print_line("\n#{tbl}\n")
106120

121+
meterpreter_dns_resolving_errors.each do | error |
122+
print_warning(error)
123+
end
124+
107125
report_note(
108126
host: session,
109127
type: 'domain.hosts',

0 commit comments

Comments
 (0)