Skip to content

Instantly share code, notes, and snippets.

@ksaver
Created May 26, 2020 11:00
Show Gist options
  • Save ksaver/8042b389ec455069b7a7bf3933725051 to your computer and use it in GitHub Desktop.
Save ksaver/8042b389ec455069b7a7bf3933725051 to your computer and use it in GitHub Desktop.
Simple bruteforce a sha-1 hash
# created under the alias noobcøder @sololearn
# https://code.sololearn.com/cpZmxS2B8657/#py
import hashlib
import string
import itertools
def bruteforce(hash_string):
charset = string.ascii_lowercase
clearpwd = ''
pwlen = 4
for pwd in itertools.product(
charset, repeat=pwlen):
clearpwd = ''.join(pwd)
hashed = hashlib.sha1(
clearpwd.encode('utf-8')).hexdigest()
if hash_string == hashed:
print("Password Found! [{}]".format(
clearpwd))
return
sha1_hash = "e6fb06210fafc02fd7479ddbed2d042cc3a5155e"
bruteforce(sha1_hash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment