Skip to content

Commit

Permalink
DNS timeout improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
initstring committed Apr 6, 2020
1 parent 8e2381b commit 1116b38
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion enum_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 1116b38

Please sign in to comment.