Skip to content

Instantly share code, notes, and snippets.

Created March 4, 2017 23:15
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Script to crack a LUKS partition given a fuzzy passphrase pattern
#!/usr/bin/env bash
set -e
# We need to export because xargs runs in a subshell
export the_file=$2
if [ -z "${the_pattern}" ]; then
echo pattern missing
exit 1
if [ -z "${the_file}" ]; then
echo file missing
exit 1
crack_maybe=$(cat <<'EOF'
echo PASS | cryptsetup open --test-passphrase ${the_file}
if [ "$rc" -ne "2" ]; then
echo "return code $rc on input PASS"
exit 255
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