-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes improvement to enum_computers module
- Loading branch information
1 parent
4065d01
commit 11eb569
Showing
3 changed files
with
93 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: binary -*- | ||
|
||
module Msf::Post::DNS | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# -*- coding: binary -*- | ||
|
||
module Msf | ||
class Post | ||
module DNS | ||
### | ||
# | ||
# This module resolves session DNS | ||
# | ||
### | ||
module ResolveHost | ||
# Takes the host name and makes use of nsloopup to resolve the IP | ||
# | ||
# @param [String] host Node for the ruby `send` method | ||
# @return [String, nil] ip The resolved IP | ||
def resolve_host(host) | ||
ip = nil | ||
|
||
if client.respond_to?(:net) && client.commands.include?(Rex::Post::Meterpreter::Extensions::Stdapi::COMMAND_ID_STDAPI_NET_RESOLVE_HOST) | ||
result = client.net.resolve.resolve_host(host) | ||
|
||
return if result[:ip].blank? | ||
|
||
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 | ||
end | ||
end | ||
end | ||
|
||
if ip.nil? | ||
print_error("Could not resolve IP for #{host}") | ||
else | ||
ip | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters