A not yet blazing fast, parallel PDF password cracker for Python 3.12+.
- Multi-core Cracking: Utilizes all CPU cores for maximum speed.
- Efficient Memory Usage: Handles large PDFs with minimal RAM.
- Resilient Workers: Worker processes handle errors gracefully; the main process continues.
- Progress Tracking: Real-time progress bar and statistics.
- Customizable: Tune password length, charset, batch size, and more.
- Comprehensive Error Handling: Clear error messages and robust test coverage for all edge cases.
Install from PyPI (recommended):
uv pip install pdf-pycrackFor development:
git clone https://github.com/hornikmatej/pdf_pycrack.git
cd pdf_pycrack
uv syncuv run pdf-pycrack <path_to_pdf>For all options:
uv run pdf-pycrack --helpBasic usage:
uv run pdf-pycrack tests/test_pdfs/numbers/100.pdfCustom charset and length:
uv run pdf-pycrack tests/test_pdfs/letters/ab.pdf --min-len 2 --max-len 2 --charset abcdefYou can also use pdf-pycrack programmatically in your Python code:
from pdf_pycrack import crack_pdf_password, PasswordFound
result = crack_pdf_password(
pdf_path="my_encrypted_file.pdf",
min_len=4,
max_len=6,
charset="0123456789"
)
if isinstance(result, PasswordFound):
print(f"Password found: {result.password}")Measure and compare password cracking speed with the advanced benchmarking tool:
uv run python benchmark/benchmark.py --standardPerformance regression testing:
# Check latest benchmark for performance regression
uv run python benchmark/regression_detector.py
# Check with custom threshold and fail on regression
uv run python benchmark/regression_detector.py --threshold 10.0 --fail-on-regressionCustom runs:
uv run python benchmark/benchmark.py --pdf tests/test_pdfs/letters/ab.pdf --min-len 1 --max-len 2 --charset abcdef
uv run python benchmark/benchmark.py --processes 4 --batch-size 1000Results are saved in benchmark/results/ as JSON and CSV. The system automatically detects performance regressions by comparing against recent baselines. See benchmark/README.md for full details, options, and integration tips.
Run all tests:
uv run pytestTests are marked by category:
numbers,letters,special_chars,mixed
Run a subset:
uv run pytest -m numbersError Handling:
The suite in tests/test_error_handling.py covers:
- File not found, permission denied, directory instead of file
- Corrupted/unencrypted PDFs
- Empty charset, invalid parameters
- Memory errors, worker process failures
All errors are reported with clear messages and suggested actions.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes and add/update tests
- Run all tests and pre-commit hooks:
uv run pre-commit install uv run pre-commit run --all-files uv run pytest
- Open a pull request
This project is licensed under the MIT License. See the LICENSE file for details.
Further documentation: