Skip to content

Commit

Permalink
Removes mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranleese-r7 committed Sep 21, 2023
1 parent 461e661 commit 67092d3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 54 deletions.
48 changes: 0 additions & 48 deletions lib/msf/core/post/dns/resolve_host.rb

This file was deleted.

37 changes: 31 additions & 6 deletions modules/post/windows/gather/enum_computers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class MetasploitModule < Msf::Post
include Msf::Post::File
include Msf::Post::Windows::Accounts
include Msf::Post::Windows::Registry
include Msf::Post::DNS::ResolveHost

def initialize(info = {})
super(
Expand Down Expand Up @@ -57,10 +56,36 @@ def run
list_computers(netbios_domain_name, hostname_list)
end

def gethost(hostname)
## get IP for host
vprint_status("Looking up IP for #{hostname}")
resolve_host(hostname)
# Takes the host name and makes use of nsloopup to resolve the IP
#
# @param [String] host Hostname
# @return [String] ip The resolved IP
def resolve_host(host)
vprint_status("Looking up IP for #{host}")
return host if Rex::Socket.dotted_ip?(host)

if client.respond_to?(:net) && client.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_NET_RESOLVE_HOST)
begin
# client.net.resolve.resolve_host returns an exception in the scenario of non-existent host names
result = client.net.resolve.resolve_host(host)
rescue Rex::Post::Meterpreter::RequestError
return 'Not resolvable'
end
return result[:ip]
else
data = cmd_exec("nslookup #{host}")
if data =~ /Name/
# Remove unnecessary data and get the section with the addresses
returned_data = data.split(/Name:/)[1]
# check each element of the array to see if they are IP
returned_data.gsub(/\r\n\t |\r\n|Aliases:|Addresses:|Address:/, ' ').split(' ').each do |e|
if Rex::Socket.dotted_ip?(e)
return e
end
end
end
end
'Not resolvable'
end

def get_domain_computers
Expand Down Expand Up @@ -91,7 +116,7 @@ def list_computers(domain, hosts)
]
)
hosts.each do |hostname|
hostip = gethost(hostname)
hostip = resolve_host(hostname)
tbl << [domain, hostname, hostip]
end

Expand Down

0 comments on commit 67092d3

Please sign in to comment.