Proper method to extract the hash from a PDF file?
Quote:METHOD COMPLETED at post #6.

In order to test the PDF attack feature of OCLHashCat, I am using these sample hashes files:

+ Sample non-hashes (to be) supported by JtR
For example, this one:
And this file from there in:

So I extract it (from Linux shell) by using PDF2John from John the Ripper suite:

$ ./pdf2john test-3-RC4-40-open-testpassword.pdf test-3-RC4-40-open-testpassword.pdf:$pdf$Standard*9a1156c38ab8177598d1608df7d7e340ae639679bd66bc4cda9bc9a4eedeb170*1f300cd939dd5cf0920c787f12d16be22205e55a5bec5c9c6d563ab4fd0770d7*16*c015cff8dbf99345ac91c84a45667784*1*1*0*1*6*40*-4*2*1
$ ./pdf2john test-3-RC4-40-open-testpassword.pdf > test3.txt
n$ cat test3.txt

And now I try to crack it (from PowerShell at Windows 7 SP1):

PS C:\Users\Luis> oclhashcat64 "test3.txt" -m 10400 -a 3 anypassword
oclHashcat v1.33 starting...

WARNING: Hashfile 'test3.txt' in line 1 (test-3-RC4-40-open-testpassword.pdf:$pdf$Standard*9a1156c38ab8177598d1608df7d7e340ae639679bd66bc4cda9bc9a4eedeb170*1f300cd939dd5cf0920c787f12d16be22205e55a5bec5c9c6d563ab4fd0770d7*16*c015cff8dbf99345ac91c84a45667784*1*1*0*1*6*40*-4*2*1): Line-length exception
Parsed Hashes: 1/1 (100.00%)

ERROR: No hashes loaded

Any hash type (10400, 10410, 10420, 10500, 10600, 10700) fail.
If I modify the "test3.pdf" file and remove the "test-3-RC4-40-open-testpassword.pdf:" part, the attacks keep failing.

I think the problem comes, acording to this thread, from the PDF hash file format, that should rather be something like (supposed example for RC4-40 cyphering):


If this is the kind of hash file that must be generated, what is the method to achieve it?

Thanks you.
I think there are 2 problems here:
- your pdf2john must be out of date because mine gives the right format;
- you should remove the first part of the hash (before the ':') and leave ONLY the hash to use it in hashcat.
Well, in fact, the "pdf2john" file included in my distro (The-Distribution-Which-Does-Not-Handle-OpenCL-Well (Kali) Linux v1.0.9) seems to be different, so I downloaded latest John the Ripper Jumbo version from here:

and now the result (same file) is:

$ ../JTR/john-1.8.0-jumbo-1/run/ test-3-RC4-40-open-testpassword.pdf

But I keep having the same Line-length exception, even leaving the hash file like:





Maybe you could give me some idea about where did you get your version?
Mine is 13.376 bytes size.

Thanks you.
download from github ->
and everything will be ok Wink
I just made a video:
Here is the complete procedure (thanks you all who helped, boys):

- Download "" from the suite "John the Ripper":

cp JohnTheRipper-bleeding-jumbo/run/ .

- Run "" file from wherever you want on your .pdf file, leaving only characters between (inside) the ":" :

./ MyPDF.pdf | sed 's/::.*$//' | sed 's/^.*://' > MyPDF-Hash.txt

Note the two "sed" commands, intended to filter the output string. For example, the original:

... would finish as the appropriate (for OCLHashCat):


Or you can do it step by step:

./ MyPDF.pdf > MyPDF-Hash.txt
nano MyPDF-Hash.txt

Windows edition could be (it worked for me, it seems no matter the CR/LF issue with text files):
notepad MyPDF-Hash.txt

... and remove all the stuff outside the ":" (included).

- The file "MyPDF-Hash.txt" is now ready to process with OCLHashCat. Good cracking!

- Works on both Linux shell and CygWin (python required).
- If you do this from Windows but without CygWin (for example, by using another Python interpreter), remember that the "sed" utility included in UnxUtils (for Windows) can not work (as for today, February 2015) with single quotes ('), so use double quotes instead ("):

./ MyPDF.pdf | sed "s/::.*$//" | sed "s/^.*://" > MyPDF-Hash.txt

P.S: Of course, this can be added to the Wiki as a Tutorial or whatever, if Atom considers it OK :-) .
Things were a bit more confusing due to sites like this one whose details about the format for a hash PDF file was incorrect (or so it seems).
Good stuff, I ran into the same issues when benchmarking the new release.
Hi, I found this thread cause I look for an easy way to determine which mode to choose, and how to determine this easy way which pdf is encrypted by which method. As an example, I have bunch of encrypted pdf's:
is it enough to determine the mode, or maybe hash length is also important? Maybe it would be easier to implement this into hashcat to autoguess mode from given hash. Thanks in advance for help
It should be enough to use the right mode.

You can use this as a reference: