npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pdf-cracker

v1.0.1

Published

Node.js wrapper for pdfcrack to brute force and dictionary attack PDF passwords

Downloads

20

Readme

PDF Password Cracker (Node.js Wrapper for pdfcrack)

This Node.js project provides a simple interface to pdfcrack, a command-line tool to recover passwords from encrypted PDF files via brute force or dictionary attacks.


Features

  • Brute force attack with configurable password length range and character set
  • Dictionary attack using a wordlist file
  • Resume password cracking from a saved state file
  • Show pdfcrack version info
  • Live output logging during cracking process

Prerequisites

  • Node.js (v12+ recommended)
  • pdfcrack installed and available in your system's PATH

Install pdfcrack on Ubuntu/Debian

sudo apt-get update
sudo apt-get install pdfcrack

Check installation:

pdfcrack -v

Installation

  1. Clone this repository or copy the files to your project directory.

  2. Ensure dependencies are installed (none external needed for this wrapper):

npm install
  1. Place your encrypted PDF file in the project folder or specify the full path in the code.

Usage

Import functions

const {
  crackBruteForce,
  crackDictionary,
  resumeCrack,
  showVersion,
} = require('./index');

Brute force attack example

const charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
const pdfPath = 'test-encrypted.pdf';

(async () => {
  try {
    const password = await crackBruteForce(pdfPath, 1, 8, charset);
    console.log('Password found:', password);
  } catch (e) {
    console.error('Error:', e.message);
  }
})();

Dictionary attack example

const pdfPath = 'test-encrypted.pdf';
const wordlistFile = './wordlist.txt';

(async () => {
  try {
    const password = await crackDictionary(pdfPath, wordlistFile);
    console.log('Password found:', password);
  } catch (e) {
    console.error('Error:', e.message);
  }
})();

Resume cracking from a state file

const stateFile = './statefile.state';

(async () => {
  try {
    const password = await resumeCrack(stateFile);
    console.log('Password found:', password);
  } catch (e) {
    console.error('Error:', e.message);
  }
})();

Show pdfcrack version

(async () => {
  const version = await showVersion();
  console.log('pdfcrack version:', version);
})();

API

crackBruteForce(pdfFilePath, minLength, maxLength, charset)

  • pdfFilePath — Path to the encrypted PDF file
  • minLength — Minimum password length to try
  • maxLength — Maximum password length to try
  • charset — String of characters to use for brute forcing

Returns a Promise that resolves with the found password or rejects if not found.


crackDictionary(pdfFilePath, wordlistFile)

  • pdfFilePath — Path to the encrypted PDF file
  • wordlistFile — Path to the dictionary wordlist file

Returns a Promise that resolves with the found password or rejects if not found.


resumeCrack(stateFile)

  • stateFile — Path to the saved state file to resume cracking

Returns a Promise that resolves with the found password or rejects if not found.


showVersion()

Returns a Promise resolving to the pdfcrack version string.


Notes

  • The project expects pdfcrack to be installed and accessible in your system's PATH.
  • Brute forcing passwords with large max lengths and big charsets can take significant time.
  • Use dictionary attacks with good wordlists when possible for faster cracking.
  • The regex used to detect the found password matches output like: found user-password: 'password'

Test

const {
  crackBruteForce,
  crackDictionary,
  resumeCrack,
  showVersion,
} = require('./index');

const all = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';

(async () => {
  try {
    const pdfPath = 'test-encrypted.pdf'; // update path as needed

    console.log('Running brute force...');
    const password = await crackBruteForce(pdfPath, 1, 8, all);
    console.log('Password found:', password);

    // Uncomment to try dictionary attack:
    // const dictPassword = await crackDictionary(pdfPath, './wordlist.txt');
    // console.log('Dictionary attack found password:', dictPassword);

    // Uncomment to resume cracking from a saved state:
    // const resumedPassword = await resumeCrack('./statefile.state');
    // console.log('Resumed cracking found password:', resumedPassword);

    // Uncomment to show pdfcrack version:
    // const version = await showVersion();
    // console.log('pdfcrack version:', version);

  } catch (e) {
    console.error('Error:', e.message);
  }
})();

License

MIT License © rMi99 or Organization


Acknowledgments

  • pdfcrack — PDF password recovery tool
  • Inspired by CLI usage, wrapped for Node.js convenience