I’m not very experienced with python, but occasionally I write a script. This script generates random ip addresses and tries to connect to them, displaying the addresses that work:
import socket
from random import randint
def randip():
while True:
yield ".".join(str(randint(1, 255)) for i in range(4))
a = []
for address in randip():
try:
s = socket.socket()
s.settimeout(0.3)
s.connect((address, 80))
print address, "WORKS!!!"
a.append(address)
except socket.error:
if len(a) != 5:
continue
else:
print a
raw_input("press enter"
break
0 Responses to “Python: Random IP”