I have begun my journey on creating password crackers and i’ve been stumped on this problem in regards to the condition of loops, files and indentation scope. I have successfully managed to be able to encrypt the wordlist I have been using and loop it to set it up for comparison with my sha256 password hash file, but I am having trouble getting the password to stop making false positives under an if condition between it’s in comparison with the encrypted for loop. At first I thought it was maybe white space in the wordlist causing the problem but I now don’t think that’s the case. If anyone could possibly analyse my code and give me improvements on functionality, speed and modifications to get this to work it would be much appreciated. I am not that experienced in programming, but I plan on upgrading this tool once I can get it working simply then learn to code it in C for increased speed purposes. I plan on implementing argparse over sys in once I can get the damn thing to work so that it will be much more of a sizeable tool. Thanks to those who can help and if not peace out.
import hashlib
import sys
wordlist_arg = sys.argv[1]
password_hash_arg = sys.argv[2]
def sha256():
with open(wordlist_arg, 'r') as wordlist:
for word in wordlist:
with open(password_hash_arg, 'r') as password:
# encrypt wordlist to compare with password hash
encrypt = hashlib.sha256(word.strip().encode('utf-8')).hexdigest()
# open password hash and use if statement to compare if hash is in wordlist
if password.read().strip() in encrypt:
print("Password Found!")
break
if __name__ == '__main__':
sha256()
5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 < hash.txt = password_hash_arg
10-million-password-list-top-1000000.txt = wordlist_arg
I am trying to implement a password cracking tool that encrypts the wordlist on the fly in a for loop then compares the password hash and returns true if it is in the wordlist. I would also like to implement a feature of being able to see the password cracking attempts so this can become a more impressive tool.
h1dd3nr34p3r is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.