I would like to manually write out what itertools does in one line so that I can attempt to use multiple strings to work through the function quicker. Right now this function works, I just need to massively speed it up. I am not really even sure if writing out the itertools line would enable me to use multiple threads.
def list ():
charLength = sys.argv[2]
charSet = 'abcdefghijklmnopqrstuvwxyz0123456789'
combo = itertools.combinations_with_replacement(charSet, int(charLength))
for floatingcombo in combo:
floatingcombo = ''.join(floatingcombo)
floatingcombo += "." + sys.argv[3]
try:
floatingIP = socket.gethostbyname(floatingcombo)
msvcrt.printf("%s resolved to --> %s\n", floatingcombo, floatingIP)
except socket.gaierror:
msvcrt.printf("%s does not exist\n", floatingcombo)
return
Your problem is probably IO-bound. You could speed up the lookup by using multiple threads/processes. To avoid threading issues in dns implementation, you could use multiple processes to resolve hosts: