The data stored in Password column are MD5 hashes of the act

The data stored in Password column are MD5 hashes of the actual passwords, only accepts all lowercase alphabetic (a to z) characters of length five as passwords (Sample password: tempo). Write a program in Python to crack all the passwords from hashes. You will most likely have to brute-force them. |

Solution

Here we are inputting two files, a file containing hash value of password and another file, wordlist, containing some commonly used passwords in plaintext form.

Program – hash_cracker.py

#Begin hash_cracker.py

import hashlib, sys

m = hashlib.md5()

hashline = \"\"

hash_file = raw_input(\"Enter the hash filename: \")

wordlist = raw_input(\"Enter the wordlist file name: \")

try:

       hashdoc = open(hash_file,\"r\")

except IOError:

       print \"File not exists.\"

       raw_input()

       sys.exit()

else:

       hashline = hashdoc.readline()

       hashline = hashline.replace(\"\ \",\"\")

      

try:

       wordlistfile = open(wordlist,\"r\")

except IOError:

       print \"File not exists.\"

       raw_input()

       sys.exit()

else:

       pass

for wordline in wordlistfile:

       m = hashlib.md5() #flush the buffer

       wordline = wordline.replace(\"\ \",\"\")

       m.update(wordline)

       word_hash = m.hexdigest()

       if word_hash==hashline:

print \"The password corresponding to the hash is \", wordline

              raw_input()

              sys.exit()

print \"The hash does not match word in the wordlist.\"

raw_input()

sys.exit()

#End of the program

 The data stored in Password column are MD5 hashes of the actual passwords, only accepts all lowercase alphabetic (a to z) characters of length five as password
 The data stored in Password column are MD5 hashes of the actual passwords, only accepts all lowercase alphabetic (a to z) characters of length five as password

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site