Created
March 4, 2017 23:15
Script to crack a LUKS partition given a fuzzy passphrase pattern
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
#!/usr/bin/env bash | |
set -e | |
the_pattern=$1 | |
# We need to export because xargs runs in a subshell | |
export the_file=$2 | |
if [ -z "${the_pattern}" ]; then | |
echo pattern missing | |
exit 1 | |
fi | |
if [ -z "${the_file}" ]; then | |
echo file missing | |
exit 1 | |
fi | |
crack_maybe=$(cat <<'EOF' | |
echo PASS | cryptsetup open --test-passphrase ${the_file} | |
rc=$? | |
if [ "$rc" -ne "2" ]; then | |
echo "return code $rc on input PASS" | |
exit 255 | |
fi | |
EOF | |
) | |
echo "starting..." | |
stutter ${the_pattern} \ | |
| parallel --ungroup --block-size 1k --progress --pipe --halt now,fail=1 \ | |
" xargs -n 1 -I PASS sh -c '$crack_maybe'" | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment