How Can I Generate A Password From Sha3-512 Hash Value?
I am trying to figure out the password for this SHA3-512 hash value: 11af05af85d7656ee0f2e3260760bccdc2af88dee449f682ab2e367003856166edc045c4164a4d543ea4a43d6dd022d3c290866f2d2a7a9
Solution 1:
Your code currently doesn't use the hash to find the password. Instead you currently iterate over your alphabet to match the password that you've also put in.
You need to pass in the hashed password instead of the actual password into your tryPassword
function. Additionally, inside of the function, you need to hash your generated password candidate and compare it to the passed in hash.
Here is the full code. I've changed some variable names to make it clear what they are.
import itertools
import time
import hashlib
from binascii import hexlify
import shutil
import os
pw = input("Enter Password:")
pw = pw.encode('utf-8')
pwHashHex = hashlib.sha3_512(pw).hexdigest()
print(pwHashHex)
# Function to brute force the passworddeftryPassword(pwHashHex):
start = time.time()
# Allowed characters in the password
alphabet = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()_-+=[{]}|:;'\",<.>/?"
attempts = 0for value inrange(1, 800):
# Build up a string to test against, character by characterfor pwCandidate in itertools.product(alphabet, repeat=value):
attempts += 1
pwCandidate = ''.join(pwCandidate)
#if the string we are building matches the password given to us, return from the functionif hashlib.sha3_512(pwCandidate).hexdigest() == pwHashHex:
end = time.time()
distance = end - start
return (pwCandidate, attempts, distance)
pwFound, tries, timeAmount = tryPassword(pwHashHex)
print("The password %s was cracked in %s tries and %s seconds!" % (pwFound, tries, timeAmount))
Post a Comment for "How Can I Generate A Password From Sha3-512 Hash Value?"