I am currently trying to build a little Networkscan for my home network.
To resolve the hostnames, I want to use this function called within a for loop iterating over a range of IPs. That is doing very well, but I think the gethostbyaddr(tgtHost)
function is very very slow. Is there a way to speed things up or use alternative functions ?
def fn_hostscan(tgtHost):
response = os.system("ping -n 1 " + tgtHost + "> C:\\temp\log.txt")
if response == 0:
try:
tgtName = gethostbyaddr(tgtHost)
print("\n[+] " + tgtHost + " = " + tgtName[0])
except:
dummy = 0
else:
print("\n[-]" + tgtHost + " = None found")