[GH-ISSUE #1556] pdf2john.py doesn't extract the owner hash if the user password is null #1019

Closed
opened 2026-10-14 03:31:57 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @akhepcat on GitHub (Jul 13, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1556

Originally assigned to: @kholia on GitHub.

As you can see by this extract from pdfparse, there's no user password. But there is an owner password set. (the actual hash has been munged for safety)

obj 47918 0
Type:
Referencing:

<<
/CF
<<
/StdCF
<<
/AuthEvent /DocOpen
/CFM /AESV2
/Length 16
>>
>>
/Filter /Standard
/Length 128
/O '(\xc5\xff\xafBG<\x02j\x0fv$\xb3>r\x7fL\x9a\xf9\x94IT\xc5\xff\t\xfd7\xbc\xac\xf6\xc1^\xb2)'
/P -1340
/R 4
/StmF /StdCF
/StrF /StdCF
/U '("\x99\xa8v D\xb3\x96\x17\x8d@\x95\x03\xb9\x13Z\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00)'
/V 4

obj 48389 0
Type: /XRef
Referencing: 47918 0 R, 45900 0 R, 45902 0 R
Contains stream

<<
/DecodeParms
<<
/Columns 5
/Predictor 12
>>
/Encrypt 47918 0 R
/Filter /FlateDecode
/ID [<50F143EA493FF43B6045E2060A8519E2><13A4C0BE6360764EAD661371B32F8B80>]
/Info 45900 0 R
/Length 3768
/Root 45902 0 R
/Size 48390
/Type /XRef
/W [1 3 1]


pdf2john.py simply errors out that the file is not encrypted.

Oddly, if I copy the /O password bits into the /U position, it still reports the file as not encrypted.

the pdf-extract-owner.py (as linked elsewhere) take the /O field and format it into plain hex, but I don't know how to munge that into a proper hash format, especially without the /U field info - which I think are both used in the hash line?

Originally created by @akhepcat on GitHub (Jul 13, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1556 Originally assigned to: @kholia on GitHub. As you can see by this extract from pdfparse, there's no user password. But there is an owner password set. (the actual hash has been munged for safety) obj 47918 0 Type: Referencing: << /CF << /StdCF << /AuthEvent /DocOpen /CFM /AESV2 /Length 16 >> >> /Filter /Standard /Length 128 /O '(\xc5\xff\xafBG<\x02j\x0fv$\xb3>r\x7fL\x9a\xf9\x94IT\xc5\xff\t\xfd7\xbc\xac\xf6\xc1^\xb2)' /P -1340 /R 4 /StmF /StdCF /StrF /StdCF /U '("\x99\xa8v D\xb3\x96\x17\x8d@\x95\x03\xb9\x13Z\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00)' /V 4 obj 48389 0 Type: /XRef Referencing: 47918 0 R, 45900 0 R, 45902 0 R Contains stream << /DecodeParms << /Columns 5 /Predictor 12 >> /Encrypt 47918 0 R /Filter /FlateDecode /ID [<50F143EA493FF43B6045E2060A8519E2><13A4C0BE6360764EAD661371B32F8B80>] /Info 45900 0 R /Length 3768 /Root 45902 0 R /Size 48390 /Type /XRef /W [1 3 1] --- pdf2john.py simply errors out that the file is not encrypted. Oddly, if I copy the /O password bits into the /U position, it still reports the file as not encrypted. the pdf-extract-owner.py (as linked elsewhere) take the /O field and format it into plain hex, but I don't know how to munge that into a proper hash format, especially without the /U field info - which I think are both used in the hash line?
bsakaguchi 2026-10-14 03:31:57 +07:00
Author
Owner

@akhepcat commented on GitHub (Jul 13, 2015):

further edit - it SEEMS as if https://github.com/kholia/npdf2john is able to pull the password out.
i've yet to try it in john.

<!-- gh-comment-id:121059298 --> @akhepcat commented on GitHub (Jul 13, 2015): further edit - it SEEMS as if https://github.com/kholia/npdf2john is able to pull the password out. i've yet to try it in john.
Author
Owner

@kholia commented on GitHub (Mar 28, 2016):

Such a sample .pdf file can be found at,

http://www.novapdf.com/uploads/novapdf_en/media_items/pdf-example-encryption.original.pdf

JtR + npdf2john is easily able to crack this owner-password-protected PDF file.

<!-- gh-comment-id:202511986 --> @kholia commented on GitHub (Mar 28, 2016): Such a sample .pdf file can be found at, http://www.novapdf.com/uploads/novapdf_en/media_items/pdf-example-encryption.original.pdf JtR + npdf2john is easily able to crack this owner-password-protected PDF file.
Author
Owner

@kholia commented on GitHub (Mar 28, 2016):

Well, JtR prints a blank password which might not be correct. See https://github.com/magnumripper/JohnTheRipper/issues/761 for details.

<!-- gh-comment-id:202512556 --> @kholia commented on GitHub (Mar 28, 2016): Well, JtR prints a blank password which might not be correct. See https://github.com/magnumripper/JohnTheRipper/issues/761 for details.
Author
Owner

@kholia commented on GitHub (Mar 29, 2016):

#761 is now closed, hence closing this one too.

<!-- gh-comment-id:202711323 --> @kholia commented on GitHub (Mar 29, 2016): #761 is now closed, hence closing this one too.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openwall/john#1019
No description provided.