Its an infinite loop problem, fellow in the comments set me straight, feel free to take this down if you wish.
I have read some other questions and answers here and tried implementing the suggestions, but to no avail. Because I am not writing proprietary code it is ok for me to post this in its entirety, it not that long, but I hope stack exchange doesn't mind... Also, feel free to use and or modify as you wish.
#!/usr/bin/env python2.7
import sys, random, subprocess, signal
def main(argv=None):
if argv is None:
argv = sys.argv
def signal_handler(signal, frame):
fdHT.close()
fdWL.close()
print '\n'
return 1
signal.signal(signal.SIGINT, signal_handler)
pathToWL = str(sys.argv[1])
pathForHT = str(sys.argv[2])
mId = str(sys.argv[3])
SaltCharSet = str("a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9")
SaltCharSet = SaltCharSet.split(" ")
try:
fdWL = open(pathToWL, 'r')
except:
print "Could not open wordlist file."
return 2
try:
fdHT = open(pathForHT, 'a')
except:
print "Could not open file for hash table"
fdWL.close()
return 3
#We have our wordlist now step through the thing and start generating hashes.
toStop = False
#cursor = 0 #Use the cursor later once this program evolves
#print 'Entering while 1'
while(toStop == False):
try:
ln = str(fdWL.readline())
except:
fdHT.close()
fdWL.close()
return 4
if ln == '':
toStop = True #This should have been an ASSIGNMENT not a test, was ==
ln = ln.strip("\n")
ln = ln.strip("\r")
if len(ln) < 6:
continue
# create random salts
# send ln, id, and salts to hashpipe
salt = []
lenOfSalt = random.randint(6,16)
#print 'Entering while 2'
while(len(salt) < lenOfSalt + 1):
aORn = random.randint(0,1)
if aORn == 0:# Its a letter
uORl = random.randint(0,1)
if uORl == 0:
salt.append(SaltCharSet[(random.randint(0,25))].upper())
elif uORl == 1:
salt.append(SaltCharSet[(random.randint(0,25))].lower())
else:
print "Random Int 'uORl' out of bounds"
fdHT.close()
fdWL.close()
toStop = True
return 5 # I don't know what happened
elif aORn == 1:# Its a number
salt.append(SaltCharSet[(random.randint(26, 35))])
else:
print "Random Int 'aORn' out of bounds"
fdHT.close()
fdWL.close()
toStop = True
return 6 # I don't know what happened
#Generated Salt
salt = "".join(salt)
wholeArg2 = str("$"+mId+"$"+salt)
try:
mHash = str(subprocess.check_output([r"hashpipe", ln, wholeArg2]))
except:
print " error getting hash"
#Clean-up
fdHT.close()
fdWL.close()
toStop = True
return 7
#Generated hash, now write it to the fdHT file
print str(ln+"\t"+mHash)
fdHT.write(str(ln+"\t"+mHash))
#cursor = fdWL.tell()
print 'done with whiles'
fdHT.close()
fdWL.close()
return 0
if __name__ == "__main__":
sys.exit(main())
This script is calls a little C program I wrote to hash a string using GNUs crypt_r() function... It hangs at the end and I have to use ctrl-c to bail... here is some sample output...
zurumba`tico $6$96u6sUy05rM69$1NLxLYXS9tAf05szgV0/GH6pvykOPsuEIlGxOkDOMNEixGiN8oeTG.xxIq/D19YpArMWtD1xJMG9sKWgA9xzK/
zurupeto $6$O2510Y900o02008$BO2OadT8Bvje78C2JhuZ6r/.iJHz.s9UfET8MU93iGy57bbe/qh9/Uj4jSkVSCyknegnkAB2JF7vRgWohkGVI0
zutana $6$Ur2i9m95$E2WqrEnld4aPa1bYAlCNnMEE0nmwxNlfB9ozVc3I6NCKXHqnSyspZrqIq2usqNf2JwlVF1myhqIn26a71Dm510
zutano $6$8x482Lar4qj$LupCZ9t2ImG.nRVH9xHPsyyx9emiImNTRaErxNrtsGyWjeO3XZLzj.F1D3eQOsiurQeQMWeQ3lF5ef.o3iesg.
zuzo`n $6$G9JP2GE$FAoZGGQNNycPfGCHq/Ra4MSQNknATMgHLzk8N9FHDefbZm/Hcx6JdV/sZdbkFHVVkoRjTnoUP9mw6CkE/.4fI.
^C
Where have I gone wrong?