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] 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): """