Some more homework, a sha256 cracker in Python.
cat sha256cracker.py
#!/usr/bin/python3
# SHA256 cracker
from pwn import *
import sys
#pass data in from commandline
if len(sys.argv) != 2:
print("Invalid arguments")
print(">> {} <sha256sum>".format(sys.argv[0]))
exit()
wanted_hash = sys.argv[1]
password_file = "shawords.txt"
attempts = 0
with log.progress("Attempting to crack: {}!\n".format(wanted_hash)) as p:
with open(password_file, "r", encoding='latin-1') as password_list:
for password in password_list:
password = password.strip("\n").encode('latin-1')
password_hash = sha256sumhex(password)
p.status("[{}] {} == {}".format(attempts, password.decode('latin-1'), password_hash))
if password_hash == wanted_hash:
p.success("Password Hash found after {} attempts! {} hashes to {}!".format(attempts, password.decode('latin-1'), password_hash))
exit()
attempts += 1
p.failure("Password NOT found !")
Again, this requires pwntools libray.
Make a password fil, with ordinary passwrods, one pr line, adjust the password_file variable, and make a test password you know is in the file, by echoing it through sha256sum, like so.
echo -ne python | sha256sum
That spits out a sha356sum of the test password, so simply run the cracker, like this
python3 shacracker.py loooong-sha256-sum-goes-here
Have fun :)