Skip to content

Commit

Permalink
reversed dns lookup result stored in table
Browse files Browse the repository at this point in the history
  • Loading branch information
Loevenich, Mathis committed Jun 30, 2020
1 parent 0995904 commit b1bce46
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions script/htcompact
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ no_config = False

# Features:
reverse_dns_lookup = False
store_dns_lookups = dict()
summarizer_mode = False
analyser_mode = False
to_csv = False
Expand Down Expand Up @@ -892,11 +893,19 @@ def gethostbyaddr(ip):
:return: resolved domain name, else give back the ip
"""
try:
if ip in list(store_dns_lookups.keys()):
return store_dns_lookups[ip]
# else lookup
reversed_dns = socket.gethostbyaddr(ip)
logging.debug('Lookup sucessful ' + ip + ' resolved as: ' + reversed_dns[0])
# store
store_dns_lookups[ip] = reversed_dns[0]
# return
return reversed_dns[0]
except Exception:
logging.debug('Not able to resolve the IP: '+ip)
# also store
store_dns_lookups[ip] = ip
return ip


Expand Down

0 comments on commit b1bce46

Please sign in to comment.