Advertisement
_s8

Dictionary attack v1

_s8
Dec 28th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. import hashlib
  2. import random
  3.  
  4.  
  5. def dict_attack(pwds):
  6. print("[*] Starting dictionary attack...")
  7. f = open('Dictionary.txt', 'r')
  8. words = f.readlines()
  9. f.close()
  10. cracked = []
  11. for pwd in pwds:
  12. print("[-] Testing for {}...".format(pwd))
  13. for w in words:
  14. word = w.strip('\n')
  15. word = word.strip(' ')
  16. hashed = hashlib.md5(word.encode())
  17. # Uncomment this line if you want it to show everything it tries print("[-] Trying {} as {}...".format(word, hashed.hexdigest()))
  18. if hashed.hexdigest() == pwd:
  19. print("[+] Found {} as {}, updating...".format(pwd, word))
  20. cracked.append(word)
  21. break
  22. print("[-] {}/{} passwords found!".format(len(cracked), len(pwds)))
  23. return cracked
  24.  
  25. def main():
  26. # Write in the passwords list if you want customized passwords
  27. passwords = []
  28. """
  29. If you want randomly generated passwords, uncomment the """'s
  30. f = open('Dictionary.txt', 'r')
  31. words = f.readlines()
  32. f.close()
  33. for b in range(0, 10):
  34. passwords.append(random.choice(words))
  35. passwords[b] = passwords[b].strip('\n')
  36. passwords[b] = passwords[b].strip(' ')
  37. """
  38. hashed_passwords = []
  39. for p in passwords:
  40. hashed_passwords.append(hashlib.md5(p.encode()).hexdigest())
  41. #print(hashed_passwords)
  42. print(dict_attack(hashed_passwords))
  43.  
  44. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement