From 10fc30b57481ca360016689cffb562afcbe3bcfc Mon Sep 17 00:00:00 2001 From: Nick Lauder Date: Mon, 6 Apr 2020 11:06:17 +1200 Subject: [PATCH 1/2] Fixed issues with running out of resources and connection timing out --- enum_tools/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/enum_tools/utils.py b/enum_tools/utils.py index 9a40fe8..e57ec0d 100644 --- a/enum_tools/utils.py +++ b/enum_tools/utils.py @@ -113,7 +113,7 @@ def dns_lookup(nameserver, name): res.query(name) # If no exception is thrown, return the valid name return name - except dns.resolver.NXDOMAIN: + except (dns.resolver.NXDOMAIN, dns.exception.Timeout): return '' def fast_dns_lookup(names, nameserver, callback='', threads=5): @@ -151,6 +151,7 @@ def fast_dns_lookup(names, nameserver, callback='', threads=5): sys.stdout.flush() sys.stdout.write(" {}/{} complete...".format(current, total)) sys.stdout.write('\r') + pool.close() # Clear the status message sys.stdout.write(' \r') From 1116b3835c4cac4ec7aa2883b78d1884519eb3cb Mon Sep 17 00:00:00 2001 From: initstring <26131150+initstring@users.noreply.github.com> Date: Tue, 7 Apr 2020 06:37:14 +1000 Subject: [PATCH 2/2] DNS timeout improvements --- enum_tools/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/enum_tools/utils.py b/enum_tools/utils.py index e57ec0d..b6b3670 100644 --- a/enum_tools/utils.py +++ b/enum_tools/utils.py @@ -107,14 +107,18 @@ def dns_lookup(nameserver, name): by the fast_dns_lookup function. """ res = dns.resolver.Resolver() + res.timeout = 10 res.nameservers = [nameserver] try: res.query(name) # If no exception is thrown, return the valid name return name - except (dns.resolver.NXDOMAIN, dns.exception.Timeout): + except dns.resolver.NXDOMAIN: return '' + except dns.exception.Timeout: + print(" [!] DNS Timeut on {}. Investigate if there are many" + " of these.".format(name)) def fast_dns_lookup(names, nameserver, callback='', threads=5): """