Skip to content

Commit

Permalink
Removes Meterpreter logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranleese-r7 committed Oct 3, 2023
1 parent 6fdcc43 commit 87d108a
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions modules/post/windows/gather/enum_computers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def run
list_computers(netbios_domain_name, hostname_list)
end

# Takes the host name and makes use of nsloopup to resolve the IP
# Takes the host name and makes use of nslookup to resolve the IP
#
# @param [String] host Hostname
# @return [String] ip The resolved IP
Expand All @@ -65,24 +65,14 @@ def resolve_host(host)
return host if Rex::Socket.dotted_ip?(host)

ip = []
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
ip << 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)
ip << e
end
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)
ip << e
end
end
end
Expand Down

0 comments on commit 87d108a

Please sign in to comment.