I copied that code to make a THM exercise, I understand it and it does his job that's passing names from a wordlist ($2) to steghide to try to crack the image ($1), and it works, but the problem is that it doesn't show correctly the correct password, it just stops in the word before it, and if you click enter it keeps going, I would like to just stop when it finds it and show me the password, here's the code:
for word in $(cat $2); do
steghide extract -sf $1 -p $word &> /dev/null
if [ $? == 0 ]; then
echo
echo "[!] PWD FOUND - $word [!]"
break
else
echo "NOPE - $word"
fi
done
for ... inwill probably mangle it. See "Why you don't read lines withfor" and BashFAQ #1: "How can I read a file (data stream, variable) line-by-line (and/or field-by-field)?" Also, you have several variable references that really should be double-quoted; shellcheck.net will point them out (along with some other recommendations).steghidedoes that itself.