Reputation: 19
I am trying to scan domain name from ip address. That's why i took a input from file and split that, amd changing the last 3digit with loop . and checking all random ip. But It Shows Nothing. And there is a valid ip with domain.
f = open('ip.txt', 'r')
r = f.readline()
f.close()
ips = r.split(".")
ipc = ips[0] + "." + ips[1] + "." + ips[2] + "."
for i in range(0, 256):
ipm = ipc + str(i)
ip = str('"' + ipm + '"')
try:
socket.gethostbyaddr(ip)
except:
pass
Upvotes: 1
Views: 541
Reputation: 1914
Your indentation here is wrong, try this:
for i in range(0,256):
ipm=ipc+str(i)
ip=str('"'+ipm+'"')
try:
socket.gethostbyaddr(ip)
except:
pass
Edit: I also suspect that you can simply do ip = str(ipm)
, without needing to add the extra double quotes.
Upvotes: 1