pdf2john /Encrypt /Length problem for PDF versions 1.1 - 1.3 #1055
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to the Adobe PDF documentations ( for instance https://wwwimages2.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf ) , the /Length attribute in the encryption dictionary was not available/used for PDF documents with a PDF version number < 1.4.
The documentation says: (Optional; PDF 1.4; only if V is 2 or 3) The length of the encryption key, in bits. The value shall be a multiple of 8, in the range 40 to 128. Default value: 40.
Indeed, for PDF versions < 1.4 /Length afaik does never exist and hence the current code fails, generating something like this:
$pdf$12**... instead of $pdf$1240...
Hashes without a keysize are currently not acceted neither by jtr, nor by oclHashcat.
Example hashes to test (feel free to share/upload/post them): https://mega.co.nz/#!rdxQlTBS!XIfPnQQdtmrUGmBRgrTXN8qM53VFf7OIkt640V_w9Vg
The fix sets a default keysize, which should anyway always be overridden if a newer PDF version format is being used. This ensures that the keysize value (string) is never empty and hence an "invalid" hash (because of the keysize) cannot be generated by pdf2john.py
Greetz from the hashcat crew
phil, atom