Last active
June 2, 2023 05:22
-
-
Save colin-stubbs/93a63528d380d3f4b3054284e6c4aa97 to your computer and use it in GitHub Desktop.
Script to brute force the auth parameters for a veracrypt volume
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -l | |
# | |
# VeraCrypt volume brute forcing script with support for key file based volumes | |
# | |
# NOTE: veracrypt will need to be run with root privileges, either directly as root or via sudo | |
# WARNING: This is a very slow method to brute force access into a volume, you can extract the password hash and use hashcat if you're certain no key file needs to be involved. | |
# | |
if [ $# -ne 2 ] && [ $# -ne 3 ] ; then | |
/bin/echo "Usage $0 <veracrypt-file> <wordlist> [<key-file>]" | |
exit 2 | |
fi | |
# On MacOS you may need to specify VeraCrypt or the full path to the .app executable | |
#dep="/Applications/VeraCrypt.app/Contents/MacOS/VeraCrypt" | |
# Linux should just be this, | |
dep="veracrypt" | |
command -v $dep >/dev/null 2>&1 || { /bin/echo >&2 "Error: $dep not installed. Aborting."; exit 1; } | |
n_total=$( wc -l < $2 | sed -E 's/[\ \t]//g' ) | |
n_tested=0 | |
IFS='' | |
while read -r line; do | |
n_tested=$((n_tested + 1)) | |
/bin/echo -n "[+] Words tested: $n_tested/$n_total (" | |
/bin/echo -n $line | |
/bin/echo ")" | |
if [ "${3}x" != "x" ] ; then | |
${dep} --text --non-interactive --slot=9 --password="$line" --keyfiles="${3}" --filesystem=none "${1}" 1>/dev/null 2>&1 | |
else | |
${dep} --text --non-interactive --slot=9 --password="$line" --filesystem=none "${1}" 1>/dev/null 2>&1 | |
fi | |
if [ $? -eq 0 ] | |
then | |
/bin/echo "" | |
/bin/echo -n "[*] Password found: " | |
/bin/echo $line | |
${dep} --text --non-interactive --slot=9 --dismount | |
exit 0 | |
fi | |
done < $2 | |
/bin/echo "" | |
/bin/echo "[!] Wordlist exhausted, no match found"; exit 3; | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment