How to Recover PDF Passwords with pdfcrack and NVIDIA-Accelerated Hashcat

Forgotten the password to an old PDF? You can try recovering it locally on Linux with pdfcrack.

This guide covers recovery of the password needed to open a PDF. Use it on your own files or files you have permission to recover.

 

IMPORTANT: pdfcrack runs on the CPU and has no built-in CUDA or NVIDIA GPU support. For NVIDIA acceleration, use Hashcat instead.

Start with a small password dictionary

A dictionary is a text file containing one password candidate per line. Start with a short list of passwords you remember using, then try common-password lists. This keeps the first attempt quick and helps check that the setup works before running a larger job.

Download the small SecLists file on Ubuntu:

wget -O common-passwords.txt 'https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10k-most-common.txt'

You can also make a shorter first pass:

head -n 1000 common-passwords.txt > small.txt

This takes the first 1,000 lines. It does not guarantee that they are the best candidates. Extract compressed dictionaries before using them. A larger dictionary takes longer and still cannot recover a password that is absent from the list.

Recover a PDF password with pdfcrack

Install pdfcrack on Ubuntu:

sudo apt update
sudo apt install pdfcrack wget

Replace locked.pdf with your PDF filename:

pdfcrack -f locked.pdf -w small.txt

The -f option selects the PDF and -w selects the dictionary. User-password recovery is the default. If the first list fails, repeat with common-passwords.txt. See the pdfcrack manual for other options.

The project documents support for standard security-handler revisions 2, 3 and 4. Unsupported encryption requires another tool. Installing NVIDIA drivers will not add GPU support to pdfcrack.

Use Hashcat for NVIDIA acceleration

Install Hashcat and the supporting tools:

sudo apt install hashcat git python3
nvidia-smi
hashcat -I

You need a working NVIDIA driver and a compatible CUDA installation. The Hashcat requirements page lists the NVIDIA CUDA Toolkit requirement. Confirm that hashcat -I detects your NVIDIA GPU before continuing. A working nvidia-smi alone does not confirm that Hashcat can use it.

Hashcat needs an extracted password-verification record, rather than the PDF itself. The third-party pdf2hashcat script can prepare it locally:

git clone https://github.com/sighook/pdf2hashcat.git
python3 pdf2hashcat/pdf2hashcat.py locked.pdf > locked.hash
hashcat --identify locked.hash

Select the matching PDF mode using the identification output and Hashcat’s example hashes. The encryption settings determine the mode. The PDF filename or version alone is insufficient.

For example, only if mode 10500 matches your extracted record:

hashcat -m 10500 -a 0 locked.hash common-passwords.txt
hashcat -m 10500 locked.hash --show

Here, -a 0 selects a dictionary attack, while --show displays recovered results. Check the startup output to confirm that the NVIDIA device is being used. Mode 10500 is not suitable for every PDF.

Exhausted means the selected candidates were tried without a match. It does not mean the PDF has no password. GPU acceleration can increase guessing speed, but recovery time depends on the encryption and password. A long random password may remain impractical to recover.

Automatically generate gallery with llgal

LLGAL (llgal) is an tool which can automatically generate gallery on your website. llgal is handy if you want to generate photo album out of photos organized in directories/folders.

Running llgal from the console is easy as typing the llgal command at the root directory of your photos.

llgal --exif --li -L -R --title "Album Name" --sx 960 --sy 720 --tx 250 --ty 150

In Ubuntu, the gallery’s theme is located in “/usr/share/llgal/” directory and my customized theme which supports mobile phone can be downloaded here: llgal.zip (mobile enabled)

llgal Screenshot

Personally, i use llgal to generate cctv tiles automatically on my Ubuntu server from which my TP-LINK NC450 and NC250 IP camera uploads through its FTP functions when it detects movements/motion.

 

Installation

llgal can be installed on Ubuntu by running this command

apt -y install llgal

Alternatively you can compile and install llgal directly from its repository
https://github.com/bgoglin/llgal

crack zip password with cracker-ng

Cracking zip password can be made easy with cracker-ng

Installation

Installation is simple, assuming you use Debian, Ubuntu or any other similar operating system :


$ git clone https://github.com/BoboTiG/cracker-ng.git
$ cd cracker-ng

# For testers and contributors, always work with on the devel branch:
$ git checkout devel

$ make

Cracking

Cracking is relatively simple, assuming you have downloaded the awesome Crackstation’s wordlist dictionary.


$ zipcracker-ng -f targetfile.zip -w crackstation-human-only.txt

Additionally zipcracker-ng can also be used with other brute-forcing cracking tool such as john and

$ john --incremental --stdout | zipcracker-ng -f FILE -

$ crunch 1 8 -f charset.lst lalpha | zipcracker-ng -f FILE -

Screenshot of zipcracker-ng in action

crunch

Download Wordlist for dictionary attack

Crackstation wordlist is one of the most (if not the most) comprehensive wordlist which can be used for the purpose of dictionary -attack on passwords.

The wordlist comes in two flavors:

  1. Full wordlist (GZIP-compressed (level 9). 4.2 GiB compressed. 15 GiB uncompressed)
  2. Human-password only wordlist (GZIP-compressed. 247 MiB compressed. 684 MiB uncompressed)

Personally, I’ve already downloaded the full wordlist via torrent, and tested it against few PDF files (using pdfcrack) and UNIX password cracking (using John), all my test cases were successful. In my opinion, the wordlist is comprehensive for my need.

Since it looked like it took a significant effort to compile this wordlist, I rather advocate those who are interested to donate/buy the wordlist from: https://crackstation.net/buy-crackstation-wordlist-password-cracking-dictionary.htm