A fast, parallel PDF password cracker written in Python.
Project description
PDF-PyCrack
A not yet blazing fast, parallel PDF password cracker for Python 3.12+.
Table of Contents
Features
- 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.
Installation
Install from PyPI (recommended):
uv pip install pdf-pycrack
For development:
git clone https://github.com/hornikmatej/pdf_pycrack.git
cd pdf_pycrack
uv sync
Quick Start
uv run pdf-pycrack <path_to_pdf>
For all options:
uv run pdf-pycrack --help
Usage
Basic usage:
uv run pdf-pycrack tests/test_pdfs/numbers/100.pdf
Custom charset and length:
uv run pdf-pycrack tests/test_pdfs/letters/ab.pdf --min-len 2 --max-len 2 --charset abcdef
Using as a Python Library
You 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}")
Benchmarking
Measure and compare password cracking speed with the advanced benchmarking tool:
uv run python benchmark/benchmark.py --standard
Custom 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 1000
Results are saved in benchmark/results/ as JSON and CSV. See benchmark/README.md for full details, options, and integration tips.
Testing & Error Handling
Run all tests:
uv run pytest
Tests are marked by category:
numbers,letters,special_chars,mixed
Run a subset:
uv run pytest -m numbers
Error 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.
Contributing
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
License
This project is licensed under the MIT License. See the LICENSE file for details.
Further documentation:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdf_pycrack-0.1.0.tar.gz.
File metadata
- Download URL: pdf_pycrack-0.1.0.tar.gz
- Upload date:
- Size: 25.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dd6dfdb42a2db1bd96c09ad5411325df5c5c7d3d02d061dd897eb7f31fc4006
|
|
| MD5 |
461fe9a0e21cb5d15a80c167f97e0b2a
|
|
| BLAKE2b-256 |
d097e0ef5a7255ecf3abe9d152cefe2d4f56525093c38116250526fc39bc905d
|
Provenance
The following attestation bundles were made for pdf_pycrack-0.1.0.tar.gz:
Publisher:
publish.yml on hornikmatej/pdf_pycrack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdf_pycrack-0.1.0.tar.gz -
Subject digest:
7dd6dfdb42a2db1bd96c09ad5411325df5c5c7d3d02d061dd897eb7f31fc4006 - Sigstore transparency entry: 377105342
- Sigstore integration time:
-
Permalink:
hornikmatej/pdf_pycrack@328207a4089a7d56ad66be26ecbd9bf7b828dc3a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hornikmatej
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@328207a4089a7d56ad66be26ecbd9bf7b828dc3a -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdf_pycrack-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pdf_pycrack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
013488f1e5b32fafe76ba6ed97ba1c9b88b365b298794eb219ae8ec71ccce1fb
|
|
| MD5 |
9424987d3a3c2d68e259fba9fe3f2b64
|
|
| BLAKE2b-256 |
df6bf4992164d4599ec854e20ca252ac2dfc0537f2c3b202d84988a24ad35c71
|
Provenance
The following attestation bundles were made for pdf_pycrack-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on hornikmatej/pdf_pycrack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdf_pycrack-0.1.0-py3-none-any.whl -
Subject digest:
013488f1e5b32fafe76ba6ed97ba1c9b88b365b298794eb219ae8ec71ccce1fb - Sigstore transparency entry: 377105352
- Sigstore integration time:
-
Permalink:
hornikmatej/pdf_pycrack@328207a4089a7d56ad66be26ecbd9bf7b828dc3a -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/hornikmatej
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@328207a4089a7d56ad66be26ecbd9bf7b828dc3a -
Trigger Event:
push
-
Statement type: