Skip to content

A powerful Python tool for extracting password hashes from encrypted PDF files for use with password cracking tools like Hashcat and John the Ripper.

License

Notifications You must be signed in to change notification settings

umar-briamaah/PDF-Hash-Extractor

Repository files navigation

PDF Hash Extractor

A powerful Python tool for extracting password hashes from encrypted PDF files for use with password cracking tools like Hashcat and John the Ripper.

Features

  • Multi-format PDF Support: Handles PDF 1.1-1.3, 1.4-1.6, and 1.7 encryption
  • Multiple Hash Formats: Supports both MD5 (40-char) and SHA-256 (64-char) hashes
  • Robust Extraction: Handles different PDF string formats (parentheses, angle brackets, square brackets)
  • Hash Validation: Validates extracted hashes to ensure correctness
  • Multiple Output Formats: Creates files compatible with Hashcat, John the Ripper, and other tools
  • Comprehensive Debugging: Shows detailed PDF structure analysis
  • Beautiful CLI: Color-coded output with progress indicators

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/PDF-Hash-Extractor.git
cd PDF-Hash-Extractor
  1. Install required dependencies:
pip install PyPDF2

Usage

Basic Usage

python pdf_hash_extractor.py encrypted.pdf

Save Hash to File

python pdf_hash_extractor.py encrypted.pdf -o hash.txt

Examples

# Extract hash and display on screen
python pdf_hash_extractor.py "CASHAPP TRANSFER SAUCE 2025.pdf"

# Extract hash and save to file
python pdf_hash_extractor.py "document.pdf" -o extracted_hash.txt

# Extract hash with custom output filename
python pdf_hash_extractor.py "secure.pdf" --output my_hash.txt

Supported PDF Types

PDF Version Adobe Acrobat Hash Type Hashcat Mode
1.1-1.3 2-4 MD5/SHA-256 + RC4 10400
1.4-1.6 5-8 MD5/SHA-256 + RC4 10500
1.7 9+ MD5/SHA-256 + AES-256 10501

Output Formats

The tool creates multiple output formats:

  • Hashcat Format: $pdf$1*1*40*hash1*hash2
  • John the Ripper Format: Compatible with JtR
  • Clean Format: Simplified hash format

Example Output

╔══════════════════════════════════════════════════════════════╗
║                PDF HASH EXTRACTOR                ║
║                                                                  ║
║  Extract password hashes from PDF files for Hashcat        ║
║                                                                  ║
║  🔓 Extract • 📝 Hash • 🚀 Ready for Hashcat              ║
╚══════════════════════════════════════════════════════════════╝

🔄 Reading PDF file: document.pdf
🔄 Analyzing PDF structure...
ℹ️  Found encryption parameters:
  Owner password (O) - angle brackets: [b'8b0207cafd2d6bbf...']
  User password (U) - angle brackets: [b'0eb75dbfd72cf2b3...']
  Permissions (P): [b'2', b'-4']
  Version (V): [b'5', b'8']
  Revision (R): [b'0', b'7']
🔄 Trying PDF 1.4-1.6 (MD5 + RC4)...
✅ Hash validation passed: Hash format is valid
✅ Hash extracted successfully!
ℹ️  PDF Type: PDF 1.4-1.6 (SHA-256 + RC4)

Extracted Hash:
$pdf$1*1*64*8b0207cafd2d6bbf535bade69e0691848984138f6163360a02f902758e2dfe51*0eb75dbfd72cf2b349d578ab05b5b1490122456a91bae5134273a6db134c87c4

✅ Hash saved to: hash.txt
✅ Hash saved in hashcat format: hash_hashcat.txt
✅ Hash saved in john format: hash_john.txt
✅ Hash saved in clean format: hash_clean.txt

Password Cracking

Once you have the extracted hash, you can use it with password cracking tools:

Hashcat

# Dictionary attack
hashcat -m 10500 -a 0 hash.txt wordlist.txt

# Brute force attack
hashcat -m 10500 -a 3 hash.txt ?a?a?a?a?a?a?a?a

# Mask attack
hashcat -m 10500 -a 3 hash.txt ?d?d?d?d?d?d?d?d

John the Ripper

john --wordlist=wordlist.txt hash.txt

File Structure

PDF-Hash-Extractor/
├── pdf_hash_extractor.py    # Main extraction script
├── extract_hash.bat         # Windows batch file for easy execution
├── crack_pdf.bat           # Password cracking helper script
├── README.md               # This file
└── .gitignore             # Git ignore file

Requirements

  • Python 3.6+
  • PyPDF2 library
  • Password-protected PDF file

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

This tool is for educational and authorized testing purposes only. Only use it on PDF files you own or have explicit permission to test. The authors are not responsible for any misuse of this tool.

Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Include the PDF version and error messages

Changelog

Version 1.0.0

  • Initial release
  • Support for PDF 1.1-1.7 encryption
  • Multiple hash format support
  • Hash validation
  • Multiple output formats
  • Comprehensive debugging output

About

A powerful Python tool for extracting password hashes from encrypted PDF files for use with password cracking tools like Hashcat and John the Ripper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors