Advertisement
MGakowski

Bcrypt Hash Matcher

Dec 25th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. import bcrypt
  2. import time
  3. hash_file = raw_input("Name of .txt hash file in this directory? \n")
  4. hf = hash_file + ".txt"
  5. dict_file = raw_input("Name of .txt dictionary file in this directory? \n")
  6. df = dict_file + ".txt"
  7. hash_lines = 0
  8. with open(hf, 'r') as g:
  9. for line in g:
  10. hash_lines += 1
  11. hashes = int(hash_lines)
  12. print(str(hashes) + " Hashes loaded.")
  13. up_to = int(0)
  14. start_time = time.time()
  15. for y in range(0, hash_lines):
  16. g = open(hf)
  17. lines = [line.rstrip() for line in g]
  18. dict_lines = 0
  19. with open(df, 'r') as f:
  20. for line in f:
  21. dict_lines += 1
  22. loop_for = int(dict_lines)
  23. with open(df, 'r') as f:
  24. for x in range(0, loop_for):
  25. cipher = str(lines[up_to])
  26. salt = cipher[:29] # Extract salt
  27. a = f.readline()
  28. passwd = str(a.rstrip('\n'))
  29. hashed = bcrypt.hashpw(passwd, salt)
  30. if str(cipher) == str(hashed):
  31. print(" - Hash match: " + hashed + " : " + passwd)
  32. print("Dictionary exhausted, processing next hash in hashfile.")
  33. up_to += 1
  34. elapsed_time = time.time() - start_time
  35. total_hashes = int(hash_lines*dict_lines)
  36. rate = int(total_hashes/elapsed_time)
  37. print("Completed " + str(total_hashes) + " in " + str(elapsed_time) + " seconds. @ " + str(rate) + "/sec.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement