Skip to content

Instantly share code, notes, and snippets.

@ronoaldo
Created March 4, 2026 15:16
Show Gist options
  • Select an option

  • Save ronoaldo/42db9ef21ecca2896febd3459739bbb6 to your computer and use it in GitHub Desktop.

Select an option

Save ronoaldo/42db9ef21ecca2896febd3459739bbb6 to your computer and use it in GitHub Desktop.
Brute forcing PDF dumb passwords in a few seconds...
#!/usr/bin/env bash
# sudo apt install qpdf first if needed
# adjust range accordingly in lines 9 and 10
INPUT="$1"
printf "Bruteforcing password with numeric 4 digit key:\n"
time for i in $(seq 1 9999); do
pass="$(printf '%04d' $i)"
printf "Trying '%s': " "$pass"
qpdf --decrypt --password="$pass" "$INPUT" "$INPUT.decrypted.pdf" && {
printf "Success!\n"
exit 0
}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment