What I have is the below script for password guessing. How can I make it parallel by using command parallel? I know that there is no parallel in Cygwin, but I can use this script on Linux machine.

while read -r p; do
    "/cygdrive/c/Program Files/TrueCrypt/TrueCrypt.exe" /a /s /l x /q /v container.tc /p"$p"
    echo "$code $p">>log.txt
    echo "$code $p"
    if [ "$code" -ne 1 ]; then echo "$p" >> found.txt ; echo -e "\\a" ; exit ; fi
done < passwds.txt
echo -e "\\a"
  • And the question is what ? – matzeri Sep 18 '17 at 19:06

I guese your requestion is to rewrite this scirpt using utility parallel in GNU/Linux.

Bulitin command while is read line from file passwds.txt line by line. If your file is large enough, then the totol consuming time will be very long.

Here, I try to use parallel to rewrite it

#!/usr/bin/env bash

    "truecrypt" --non-interactive container.tc /p="$p"
    echo "$code $p">>log.txt
    echo "$code $p"
    if [ "$code" -eq 0 ]; then echo "$p" >> found.txt ; echo -e "\\a" ; exit ; fi

export -f funcPasswdOperation
cat passwds.txt | parallel -k -j 0 funcPasswdOperation
echo -e "\\a"

As I'm not test it, so I'm not guarantee this rewrited scirpt will work. But the usage method is similar.

Be careful of open files error.

| improve this answer | |
  • Great script! It works! But how can I stop the job if it founds the password? exit doesn't seem to work... – pbies Sep 28 '17 at 16:51
  • You could consider setting a global variable, giving it a default value, then check it. If you match the correct password, change the global variable to another value, if you check the global variable has been changed, then set exit. – Gorgon Sep 29 '17 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.