My bash dictionary attack function will select the first word from the dictionary and see if it compares with my hash but then stop, and if it doesn't, it will search the whole dictionary but not actually return the password. When it stops the password is always "1080", no matter what the hash is
I don't understand what's happening, but I've researched quite a lot
dict_attack(){
TARGET_HASH=$1
while read WORD; do
WORD_HASH=$(echo $WORD | sha256sum | awk '{print $1}')
if [ "$WORD_HASH"=="$TARGET_HASH" ]; then
echo "Guessed it!"
echo "Password is : $WORD"
exit
fi
done < /usr/share/dict/linux.words
Here is the call in the rest of the script.
dict_attack $1