I had to open a PDF, so I spent the morning working on a basic PDF password cracker written in Java. I haven’t encapsulated it in a command line tool yet (and I’m not sure I ever will), but it came out pretty neat.

It started out simple enough:

boolean attempt(String password) throws IOException {
  try {
    //attempt to open the reader stream
    PdfReader reader = new PdfReader(this.filename, password.getBytes());
    return true;
  } catch (BadPasswordException e) {
    return false;

After I had the password, I couldn’t resist the urge to implement:

boolean attempt(String password);
String crackViaWordlistFiles(Collection wordlistFiles);
String crackViaWordlistFile(String wordlistFile);
String crackViaWordlist(Collection words);
String crackViaBruteForce(String alphabet, int length);
String crackViaBruteForce(String alphabet, int lower_length, int upper_length);

The coolest of which, was the code for generating the brute force permutations of @length.

Hopefully someone finds a use for this, and if not, finds a use for my brute force algorithm. Thanks!

Update: This project has been moved to GitHub, expanded, and unit tested.