samedi 20 août 2016

Bash Script IF statement not functioning

I am currently testing a simple dictionary attack using bash scripts. I have encoded my password "Snake" with sha256sum by simply typing the following command:

echo -n Snake | sha256sum

This produced the following:

aaa73ac7721342eac5212f15feb2d5f7631e28222d8b79ffa835def1b81ff620 *-

I then copy pasted the hashed string into the program, but the script is not doing what is intended to do. The script is (Note that I have created a test dictionary text file which only contains 6 lines):

echo "Enter:"
read value

cat dict.txt | while read line1
    do
            atax=$(echo -n "$name" | sha256sum)

            if [[ "$atax" == "$value" ]];
            then
                    echo "Cracked: $line1"
                    exit 1
            fi

    echo "Trying: $line1"

    done

Result:

Trying: Dog
Trying: Cat
Trying: Rabbit
Trying: Hamster
Trying: Goldfish
Trying: Snake

The code should display "Cracked: Snake" and terminate, when it compares the hashed string with the word "Snake". Where am I going wrong?

Aucun commentaire:

Enregistrer un commentaire