A simple Python script that recovers a forgotten password from an encrypted PDF using a dictionary attack. It tries passwords from a wordlist one by one until it finds the correct one, then saves a clean decrypted copy — all automatically, with no configuration needed.
This tool is intended only for recovering passwords from PDF files you own or have explicit permission to unlock. Using this tool on files you do not own is illegal and unethical. The author takes no responsibility for misuse.
- You place your locked PDF in the same folder as the script.
- The script automatically finds it — no file paths to edit.
- It reads each password from
common_passwords.txt(14 million+ real-world passwords) and tries it against the PDF. - When the correct password is found, it saves a decrypted copy named
unlocked_yourfile.pdfin the same folder. - If no password matches, it tells you the wordlist was exhausted.
- Python 3.7 or higher
- PyPDF2 library
Download from https://www.python.org/downloads/
✅ During installation, check "Add Python to PATH"
Open your terminal (Command Prompt on Windows, Terminal on Mac/Linux) and run:
pip install PyPDF2Make sure all three files are in the same folder:
pdf-crack/
├── pdf_crack_script.py
├── common_passwords.txt
└── your_locked_file.pdf ← place your PDF here
That's it. No editing the script.
Open a terminal in that folder and run:
python pdf_crack_script.pyOn Windows, you can also double-click the script if Python is installed.
The script will show live progress:
==================================================
PDF Password Cracker
==================================================
[*] Target PDF : my_document.pdf
[*] Wordlist : common_passwords.txt
[*] Output will : unlocked_my_document.pdf
--------------------------------------------------
[*] PDF is encrypted. Starting password search...
[*] Tried 1,000 passwords so far...
[*] Tried 2,000 passwords so far...
[+] Password found : sunshine
[+] Saving decrypted copy...
[+] Done! Saved as : unlocked_my_document.pdf
The unlocked file will appear in the same folder as the script.
If the script finds more than one PDF in the folder, it will ask you to choose:
[?] Multiple PDF files found in this folder:
[1] report.pdf
[2] invoice.pdf
Enter the number of the PDF you want to unlock:
| Problem | Solution |
|---|---|
ModuleNotFoundError: No module named 'PyPDF2' |
Run pip install PyPDF2 in your terminal |
[!] Wordlist not found |
Make sure common_passwords.txt is in the same folder as the script |
[!] No PDF file found |
Place your locked PDF in the same folder as the script |
[*] This PDF is not password-protected |
The PDF has no password — nothing to crack |
[-] Password not found in the wordlist |
The password wasn't in the list — it may be too complex or unusual |
common_passwords.txt contains 14+ million real-world passwords from the famous RockYou data leak. It covers the vast majority of weak and common passwords. If your password was something simple (a word, name, number, or common phrase), it's very likely in this list.
If the password is not found, it means the PDF was protected with a strong or unique password, and a larger/specialized wordlist would be needed.
This project is released for personal and educational use only.