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

Commit dc77e3d

Browse files
author
Jonathan Claudius
authored
Merge pull request #336 from mozilla/add_ptr_lookup
Add PTR lookup on IP-only target
2 parents aff90a3 + 6d086a1 commit dc77e3d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/ssh_scan/scan_engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def scan_target(socket, opts)
4747
client = SSHScan::Client.new(target, port, timeout)
4848
client.connect()
4949
result = client.get_kex_result()
50-
result[:hostname] = ""
50+
result[:hostname] = target.resolve_ptr
5151
return result if result.include?(:error)
5252
end
5353

lib/string_ext.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,18 @@ def resolve_fqdn_as_ipv4(timeout = 3)
5555
end
5656

5757
def resolve_fqdn
58-
@fqdn ||= TCPSocket.gethostbyname(self)[3]
58+
TCPSocket.gethostbyname(self)[3]
59+
end
60+
61+
def resolve_ptr(timeout = 3)
62+
begin
63+
Timeout::timeout(timeout) {
64+
reversed_dns = Resolv.new.getname(self)
65+
return reversed_dns
66+
}
67+
rescue Timeout::Error
68+
return ""
69+
end
5970
end
6071

6172
def fqdn?

0 commit comments

Comments
 (0)