Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. import time
  2. import hashlib
  3. import string
  4. import sys
  5.  
  6. global yes
  7. global no
  8. global listPassword
  9. answer = True
  10. yes = {'yes','y', 'ye', ''}
  11. no = {'no','n'}
  12. lowerCase = list(string.ascii_lowercase)
  13. upperCase = list(string.ascii_uppercase)
  14. special = list(string.punctuation)
  15. numbers = list(string.digits)
  16. startTime = time.time()
  17. maxAttempts = 9
  18.  
  19.  
  20. def crack():
  21. global realPassword
  22. realPassword = input("Enter your password:")
  23. password_hash = hashlib.md5(realPassword.encode('utf-8')).hexdigest()
  24. with open(r'C:\Users\Me\Desktop\Password Cracker\dictionary.txt', 'r') as f:
  25. words = list(f)
  26. for word in words:
  27. word_hash = hashlib.md5(word.strip().encode()).hexdigest()
  28. if word_hash == password_hash:
  29. return word
  30. #else:
  31. # print("Your Password has not been cracked")
  32. # choice = input("Your password was not cracked, do you want to try another password?: ")
  33. #if choice in yes:
  34. # attempts += 1
  35. #elif choice in no:
  36. # sys.exit()
  37.  
  38.  
  39.  
  40. def main():
  41. while answer == True:
  42. password = crack()
  43. if password:
  44. print('-Stats-')
  45. print('The password is: {0}'.format(password))
  46. print('time: ' + str((time.time() - startTime)) + ' sec')
  47. else:
  48. print("Your Password has not been cracked")
  49. listPassword = list(realPassword)
  50. lowerCheck = any(i in listPassword for i in lowerCase)
  51. upperCheck = any(i in listPassword for i in upperCase)
  52. specialCheck = any(i in listPassword for i in special)
  53. numbersCheck = any(i in listPassword for i in numbers)
  54. if lowerCheck is False:
  55. print("Your password contains no lower case letters, this makes it a weak password.")
  56. if upperCheck is False:
  57. print("Your password contains no upper case letters, this makes it a weak password.")
  58. if numbersCheck is False:
  59. print("Your password contains no numbers, add some to make it a stronger password")
  60. if special is False:
  61. print("Your password contains no special characters, add some to increase the strength of your pasword.")
  62. choice = input("Do you want to continue").lower()
  63. if choice in yes:
  64. continue
  65. elif choice in no:
  66. break
  67. #password = crack()
  68. #if password:
  69. # print('-Stats-')
  70. # print('The password is: {0}'.format(password))
  71. # print('time: ' + str((time.time() - startTime)) + ' sec')
  72.  
  73. if __name__ == "__main__":
  74. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement