Nov 1, 2016 05:48 PM
(This post was last modified: Nov 1, 2016 05:48 PM by bhop_alex.)
I'm just getting back into learning python. I wrote a bruteforce hash crack script, it is probably very unoptimized and would like critique/tips on what I could do better. Thanks!
PHP Code
<?php
import hashlib, string, time
def words(chars=string.ascii_letters + string.digits):
yield from chars
for word in words(chars):
for char in chars:
yield word + char
def hashcrack(h):
if len(h) == 32:
startTime = time.clock()
print("Working...")
for word in words('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()-=_+[]\{}|;:\'",./<>?'):
hash = hashlib.md5(word.encode('utf-8')).hexdigest()
if hash == h:
print("Success! The string was {}".format(word))
print("Time taken: {}".format(time.clock()-startTime))
input()
else:
hash = input("Try again, what is the hash?\n")
hashcrack(hash)
hash = input("What is the hash?\n")
hashcrack(hash)


