Skip to content

Instantly share code, notes, and snippets.

@mkroman
Last active January 10, 2017 17:30
Show Gist options
  • Save mkroman/73f760fa29c532abbc6d760de11cda5b to your computer and use it in GitHub Desktop.
Save mkroman/73f760fa29c532abbc6d760de11cda5b to your computer and use it in GitHub Desktop.
#!/bin/sh
password_file=$1
container_file=$2
if [ $# -ne 2 ]; then
echo "Usage: $0 <password_file> <container_file>"
exit 1
fi
if [ ! -e "${password_file}" ]; then
echo "The password file \`${password_file}' does not exist"
exit 1
fi
if [ ! -e "${container_file}" ]; then
echo "The container file \`${container_file}' does not exist"
exit 1
fi
_num_pws=`wc -l "${password_file}" | cut -f1 -d' '`
echo "Trying to mount the container with ${_num_pws} different passwords."
while read line; do
echo -n "."
echo "${line}" | veracrypt --text --stdin --non-interactive --mount "${container_file}" /media/veracrypt1 >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo
echo "Container was successfully mounted!"
echo "Password: ${line}"
break
fi
done < ${password_file}
echo
echo "Exiting."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment