Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #336 from mozilla/add_ptr_lookup
Browse files Browse the repository at this point in the history
Add PTR lookup on IP-only target
  • Loading branch information
Jonathan Claudius committed Mar 16, 2017
2 parents aff90a3 + 6d086a1 commit dc77e3d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/ssh_scan/scan_engine.rb
Expand Up @@ -47,7 +47,7 @@ def scan_target(socket, opts)
client = SSHScan::Client.new(target, port, timeout)
client.connect()
result = client.get_kex_result()
result[:hostname] = ""
result[:hostname] = target.resolve_ptr
return result if result.include?(:error)
end

Expand Down
13 changes: 12 additions & 1 deletion lib/string_ext.rb
Expand Up @@ -55,7 +55,18 @@ def resolve_fqdn_as_ipv4(timeout = 3)
end

def resolve_fqdn
@fqdn ||= TCPSocket.gethostbyname(self)[3]
TCPSocket.gethostbyname(self)[3]
end

def resolve_ptr(timeout = 3)
begin
Timeout::timeout(timeout) {
reversed_dns = Resolv.new.getname(self)
return reversed_dns
}
rescue Timeout::Error
return ""
end
end

def fqdn?
Expand Down

0 comments on commit dc77e3d

Please sign in to comment.