File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 66CS 55N Autumn 2014 with Dan Boneh
77----------------------------------------------------------------------------
88Contains functionality to create a rainbow table and crack a hash for 6-digit lowercase passwords.
9+ ----------------------------------------------------------------------------
10+ With a randomly generated rainbow table of 3 million rows and 1000 chain length,
11+ around 80% of passwords can be cracked, with an average time per password
12+ (including failures) at 3 seconds.
913"""
1014
1115# Use Python 3
@@ -142,10 +146,24 @@ def test(password=""):
142146 for _ in range (6 ):
143147 password += random .choice (string .ascii_lowercase )
144148
145- print ("Cracking password: {0}\n H(password): {1}" .format (password , H (password )))
149+ print ("\n Cracking password: {0}\n H(password): {1}" .format (password , H (password )))
146150
147151 cracked = crack (H (password ))
148152 if cracked :
149153 print ("Success! Password: {0}" .format (cracked ))
154+ return True
150155 else :
151- print ("Unsuccessful :(" )
156+ print ("Unsuccessful :(" )
157+ return False
158+
159+ # Tests random passwords multiple times and prints success rate and average crack time.
160+ def bulk_test (numHashes ):
161+ start = time .time ()
162+ numSuccess = 0
163+
164+ for i in range (numHashes ):
165+ numSuccess += test ()
166+
167+ print ("""\n {0} out of {1} random hashes were successful!\n
168+ Average time per password (including failures): {2} secs.""" \
169+ .format (numSuccess , numHashes , (time .time () - start ) / numHashes ))
You can’t perform that action at this time.
0 commit comments