1

I'm trying to learn some scripting. I have a scenario where I have lost my truecrypt password. I run the script below.

#!/bin/sh
DIRECTORY=/media/truecrypt1
for i in 1 2 password
do
   clear
   echo "Trying $i as a password"
   truecrypt -k "" --protect-hidden=no ITSTUDY $DIRECTORY -p $i
   if [[ -d "${DIRECTORY}" && ! -L "${DIRECTORY}" ]] ; then
       echo "It Worked!"
   fi
done

However if the password is wrong I get

Trying 1 as a password
Incorrect password or not a TrueCrypt volume.
Enter password for /mnt/ITSTUDY:

The only way to get the script to start running again I have to ctrl+c. If I push ctrl+c after each failure eventually the script gets to the correct password. However if I have 1000 possible passwords that is not an option.

How do I get the script to look for the output

Incorrect password or not a TrueCrypt volume.

then send a ctrl+c? or quit? Everything I've tried so far doesn't proceed below the truecrypt -k line until I do the ctrl+c.

cmh
  • 10,612
  • 5
  • 30
  • 40
user610209
  • 111
  • 2
  • it looks like truecrypt is entering an interactive mode to ask for you password (which should be prevented by the empty keyfile flag). Rather than trying to automatically send signals (which is possible) you should look into why the `truecrypt` command is doing this . – cmh Mar 10 '13 at 18:42
  • I tried to answer my own question. Thanks for the above tip. truecrypt --non-interactive was the issue. – user610209 Mar 10 '13 at 18:51

1 Answers1

1

Truecrypt is entering an interactive mode to ask for your password each iteration around the loop, this will block on input so the loop won't continue.

Adding the --non-interactive flag should solve this issue.

cmh
  • 10,612
  • 5
  • 30
  • 40