From e5ff05263e8ecef7d322eda7c633274ab70a9eb5 Mon Sep 17 00:00:00 2001 From: Michael Skelton Date: Tue, 10 Oct 2017 14:02:12 +1000 Subject: [PATCH 1/4] Add exceptions for missing PTR records --- VHostScan.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/VHostScan.py b/VHostScan.py index e36702a..49a4f0e 100644 --- a/VHostScan.py +++ b/VHostScan.py @@ -86,11 +86,17 @@ def main(): print("[>] First hit is set.") if not arguments.no_lookup: - for ip in Resolver().query(arguments.target_hosts, 'A'): - host, aliases, ips = gethostbyaddr(str(ip)) - wordlist.append(str(ip)) - wordlist.append(host) - wordlist.extend(aliases) + try: + print("[+] Resolving DNS for additional wordlist entries") + for ip in Resolver().query(arguments.target_hosts, 'A'): + host, aliases, ips = gethostbyaddr(str(ip)) + wordlist.append(str(ip)) + wordlist.append(host) + wordlist.extend(aliases) + except (dns.resolver.NXDOMAIN): + print("[!] Couldn't find any records (NXDOMAIN)") + except (dns.resolver.NoAnswer): + print("[!] Couldn't find any records (NoAnswer)") scanner_args = vars(arguments) scanner_args.update({ From afe5de5885f9a7b16dbf7f517f2f2361c8e145d3 Mon Sep 17 00:00:00 2001 From: codingo Date: Tue, 10 Oct 2017 14:08:36 +1000 Subject: [PATCH 2/4] Updated version number --- lib/core/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/__version__.py b/lib/core/__version__.py index 27ab71c..38339fd 100644 --- a/lib/core/__version__.py +++ b/lib/core/__version__.py @@ -2,4 +2,4 @@ # |V|H|o|s|t|S|c|a|n| Developed by @codingo_ & @__timk # +-+-+-+-+-+-+-+-+-+ https://github.com/codingo/VHostScan -__version__ = '1.6.2' +__version__ = '1.6.3' From 2b15f1d9250fdb16199316bfc23132633fca1fac Mon Sep 17 00:00:00 2001 From: codingo Date: Tue, 10 Oct 2017 14:36:00 +1000 Subject: [PATCH 3/4] Fix DNS resolver exception handling --- VHostScan.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VHostScan.py b/VHostScan.py index 49a4f0e..5e8bc90 100644 --- a/VHostScan.py +++ b/VHostScan.py @@ -93,9 +93,9 @@ def main(): wordlist.append(str(ip)) wordlist.append(host) wordlist.extend(aliases) - except (dns.resolver.NXDOMAIN): + except (NXDOMAIN): print("[!] Couldn't find any records (NXDOMAIN)") - except (dns.resolver.NoAnswer): + except (NoAnswer): print("[!] Couldn't find any records (NoAnswer)") scanner_args = vars(arguments) From ead2e6efaff73fffefcd42ab6a3f9eb748493126 Mon Sep 17 00:00:00 2001 From: codingo Date: Tue, 10 Oct 2017 14:40:23 +1000 Subject: [PATCH 4/4] Corrected bad import of DNS for exception handling --- VHostScan.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VHostScan.py b/VHostScan.py index 5e8bc90..de9cdce 100644 --- a/VHostScan.py +++ b/VHostScan.py @@ -2,8 +2,8 @@ import os import sys +import dns.resolver from argparse import ArgumentParser -from dns.resolver import Resolver from socket import gethostbyaddr from lib.core.virtual_host_scanner import * from lib.helpers.output_helper import * @@ -88,14 +88,14 @@ def main(): if not arguments.no_lookup: try: print("[+] Resolving DNS for additional wordlist entries") - for ip in Resolver().query(arguments.target_hosts, 'A'): + for ip in dns.resolver.query(arguments.target_hosts, 'A'): host, aliases, ips = gethostbyaddr(str(ip)) wordlist.append(str(ip)) wordlist.append(host) wordlist.extend(aliases) - except (NXDOMAIN): + except (dns.resolver.NXDOMAIN): print("[!] Couldn't find any records (NXDOMAIN)") - except (NoAnswer): + except (dns.resolver.NoAnswer): print("[!] Couldn't find any records (NoAnswer)") scanner_args = vars(arguments)