Advertisement
Mr_hEx

Crack Hash start with $1$ !!

Sep 27th, 2021
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. # it's working on Linux System only !!
  2. # Dis: get salt from hash and use it agin with password to genrate a hash with same salt
  3. # last step compare with hash
  4. # hash e.g. : $1$sm1RceCh$rSd3PygnS/6jlFDfF2J5q. => password is : deadbolt
  5.  
  6. from crypt import *
  7. import sys
  8.  
  9. def crack_password(hash,wordlist):
  10.  
  11. hashed_pwd = hash
  12. lindex = hashed_pwd.rfind('$')
  13. hash_algorithm = hashed_pwd[1:2]
  14. salt = hashed_pwd[3:lindex]
  15. salt_format = "${}${}$".format(hash_algorithm, salt)
  16. Raw_Password = open(wordlist, "r")
  17. for rawPass in Raw_Password:
  18. try:
  19. hashOutPut = crypt(rawPass.split()[0], salt_format)
  20. if hashOutPut == hashed_pwd:
  21. print("[+] Found Pasword : {}".format(rawPass.split()[0]))
  22. break
  23. except:
  24. pass
  25.  
  26.  
  27. if len(sys.argv) !=3:
  28. print("[!] Usage : {} <Hash> <WordListPath>".format(sys.argv[0]))
  29. print("[+] Note : Please don't forget to escape special chars !!")
  30. print("[+] e.g. : {} \"\$1\$sm1RceCh\$rSd3PygnS/6jlFDfF2J5q.\" \"./wordlist/rockyou.txt\"".format(sys.argv[0]))
  31. sys.exit(1)
  32.  
  33.  
  34.  
  35. Hash = sys.argv[1]
  36. WorlListPath = sys.argv[2]
  37. crack_password(Hash,WorlListPath)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement