Pretty Damn Fancy – Java PDF Cracker 

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:

1
2
3
4
5
6
7
8
9
10
11
12
boolean attempt(String password) throws IOException {
 
    try {
        //attempt to open the reader stream
        PdfReader reader = new PdfReader(this.filename, password.getBytes());
        reader.close();
        return true;
    } catch (BadPasswordException e) {
        return false;
    }
 
}

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

1
2
3
4
5
6
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.  http://github.com/seejohnrun/Pretty-Damn-Fancy