I needed to pay a bill where the barcode was password protected.
I found https://gist.github.com/dhondta/efe84a92e4dfae3b6c14932c73ab2577 but the Dockerfile was broken becuase it used abbandoned CentOS.
So I converted the Dockerfile to Ubuntu and it worked! Took around 20 seconds to crack 3 number password.
-
Download both files in the same directory:
Dockerfile
andpdf-password-bruteforcer.py
-
Copy your PDF file to the same directory
-
Build docker image with
docker build -t pdftool .
-
Run docker image with a terminal inside it with:
docker run --rm -it pdftool /bin/bash
-
Once you are inside the running container execute:
python3 pdf-password-bruteforcer.py your_pdf_file.pdf
-
By default it will use this regular expression to generate password attempts:
^[0-9a-zA-Z!-_]{1,8}
Which means it will try to use numbers, letters, !, - and _. Between 1 and 8 characters.
But you can specify your own regex like so:
python3 pdf-password-bruteforcer.py -p '[a-z0-9]{5}' your_pdf_file.pdf
This will try only passwords with 5 characters, and it will only try lower case letters and numbers.
Example of it running: