Here's my script:
#!/bin/bash
#read password.lst, hash each word, store in variable and check it against our hash
target_hash="14a4b8e7ae966e72a3a2c51633bfabc6"
password_lst=/usr/share/metasploit-framework/data/wordlists/password.lst
while IFS= read -r password
do
hashed_password=printf $password | /usr/bin/md5sum | cut -d " " -f 1
if [ $hashed_password == $target_hash ]
then
printf "==========================\n"
printf "Found Password: $password\n"
printf "==========================\n"
break
else
printf "Password: $password\n"
printf "Target hash: $target_hash\n"
printf "Current Hash: $hashed_password\n"
fi
done < "$password_lst"
The purpose is to hash each word in the file password.lst
, check it against the target_hash
and if it's correct, output the correct password and until the loop gets there, output what hash it's currently working on.
I keep getting errors in lines 10 and 12. Does anyone know what could be wrong and how I can fix it?