[GH-ISSUE #761] pdf2john.py does not extract pdf document with locked printing #396

Closed
opened 2026-10-14 03:05:09 +07:00 by bsakaguchi · 18 comments
Owner

Originally created by @martiGIT on GitHub (Sep 25, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/761

While extracting password from pdf file with locked printing (only), hash is extracted, but cracking results with empty password (I assume that password hash is taken only form file lock, which in fact is empty). No option to extract printing password.

Originally created by @martiGIT on GitHub (Sep 25, 2014). Original GitHub issue: https://github.com/openwall/john/issues/761 While extracting password from pdf file with locked printing (only), hash is extracted, but cracking results with empty password (I assume that password hash is taken only form file lock, which in fact is empty). No option to extract printing password.
bsakaguchi 2026-10-14 03:05:09 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Oct 3, 2014):

Could you by any chance submit a pdf file which has this problem? Obviously we could produce that ourselves but it would likely speed up the handling of this issue.

http://openwall.info/wiki/john/sample-non-hashes?&#PDF would be a good place.

<!-- gh-comment-id:57871661 --> @magnumripper commented on GitHub (Oct 3, 2014): Could you by any chance submit a pdf file which has this problem? Obviously we could produce that ourselves but it would likely speed up the handling of this issue. http://openwall.info/wiki/john/sample-non-hashes?&#PDF would be a good place.
Author
Owner

@kholia commented on GitHub (Oct 4, 2014):

@magnumripper sometimes, I feel like bringing the old pdf2john.pl back again. I am curious how it handles such files.

@martiGIT it would be awesome to have a sample problematic .pdf file.

<!-- gh-comment-id:57896733 --> @kholia commented on GitHub (Oct 4, 2014): @magnumripper sometimes, I feel like bringing the old `pdf2john.pl` back again. I am curious how it handles such files. @martiGIT it would be awesome to have a sample problematic .pdf file.
Author
Owner

@magnumripper commented on GitHub (Oct 4, 2014):

I can't find any pdf2john.pl in history but we had src/pdf2john.c in 96e20a31^

<!-- gh-comment-id:57900138 --> @magnumripper commented on GitHub (Oct 4, 2014): I can't find any pdf2john.pl in history but we had src/pdf2john.c in 96e20a31^
Author
Owner

@kholia commented on GitHub (Oct 4, 2014):

My bad. I was thinking about the https://github.com/kholia/npdf2john project.

<!-- gh-comment-id:57902621 --> @kholia commented on GitHub (Oct 4, 2014): My bad. I was thinking about the https://github.com/kholia/npdf2john project.
Author
Owner

@martiGIT commented on GitHub (Oct 4, 2014):

@magnumripper I does not have upload access to wiki page, so here is a link:
http://m.zyy.pl/f/0956b2311069c11e13972591a13a9667.pdf

<!-- gh-comment-id:57910388 --> @martiGIT commented on GitHub (Oct 4, 2014): @magnumripper I does not have upload access to wiki page, so here is a link: http://m.zyy.pl/f/0956b2311069c11e13972591a13a9667.pdf
Author
Owner

@magnumripper commented on GitHub (Oct 4, 2014):

Thanks. So @kholia could you take a look at this?

<!-- gh-comment-id:57916124 --> @magnumripper commented on GitHub (Oct 4, 2014): Thanks. So @kholia could you take a look at this?
Author
Owner

@magnumripper commented on GitHub (Oct 4, 2014):

Hmm or perhaps @ShaneQful ?

<!-- gh-comment-id:57916392 --> @magnumripper commented on GitHub (Oct 4, 2014): Hmm or perhaps @ShaneQful ?
Author
Owner

@kholia commented on GitHub (Oct 4, 2014):

@martiGIT @magnumripper I can print that .pdf file with no problems (using evince).

https://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt might come in handy while debugging this problem.

<!-- gh-comment-id:57918067 --> @kholia commented on GitHub (Oct 4, 2014): @martiGIT @magnumripper I can print that .pdf file with no problems (using evince). https://www.cs.cmu.edu/~dst/Adobe/Gallery/anon21jul01-pdf-encryption.txt might come in handy while debugging this problem.
Author
Owner

@martiGIT commented on GitHub (Oct 5, 2014):

@kholia @magnumripper right, this "permission" does not work with linux, I know, that if somebody want to print "print secured" document, there is an easy way to cheat it, but acrobat reader still won't permit printing.

<!-- gh-comment-id:57927293 --> @martiGIT commented on GitHub (Oct 5, 2014): @kholia @magnumripper right, this "permission" does not work with linux, I know, that if somebody want to print "print secured" document, there is an easy way to cheat it, but acrobat reader still won't permit printing.
Author
Owner

@ShaneQful commented on GitHub (Oct 5, 2014):

I can have a look at it after work tomorrow, if you'd like ... been meaning to try help out again anyway

<!-- gh-comment-id:57951009 --> @ShaneQful commented on GitHub (Oct 5, 2014): I can have a look at it after work tomorrow, if you'd like ... been meaning to try help out again anyway
Author
Owner

@martiGIT commented on GitHub (Oct 6, 2014):

@kholia great source.

As I marked, print permission is only a flag, which is respected by Adobe Acrobat (also Reader) (and other software as e.g. Finereader). If it is hard to extract this hash, we don't have to reinvent the wheel. The simplest way to remove this flag is to reprint (like print to pdf), or resave this kind of document in software that does not check additional permissions.

<!-- gh-comment-id:57985710 --> @martiGIT commented on GitHub (Oct 6, 2014): @kholia great source. As I marked, print permission is only a flag, which is respected by Adobe Acrobat (also Reader) (and other software as e.g. Finereader). If it is hard to extract this hash, we don't have to reinvent the wheel. The simplest way to remove this flag is to reprint (like print to pdf), or resave this kind of document in software that does not check additional permissions.
Author
Owner

@kholia commented on GitHub (Oct 6, 2014):

@martiGIT @magnumripper The old pdf2john.c had a flag to extract such hashes, IIRC. I haven't looked at it in a while though.

<!-- gh-comment-id:57990258 --> @kholia commented on GitHub (Oct 6, 2014): @martiGIT @magnumripper The old pdf2john.c had a flag to extract such hashes, IIRC. I haven't looked at it in a while though.
Author
Owner

@ShaneQful commented on GitHub (Oct 6, 2014):

No joy yet, although did find an issue with the last commit on this file not testing against the sample non hashes github.com/magnumripper/JohnTheRipper@292b35c90f

<!-- gh-comment-id:58102374 --> @ShaneQful commented on GitHub (Oct 6, 2014): No joy yet, although did find an issue with the last commit on this file not testing against the sample non hashes https://github.com/magnumripper/JohnTheRipper/commit/292b35c90fee0b315f682b140bd360552a5bc381
Author
Owner

@magnumripper commented on GitHub (Oct 7, 2014):

Separate issue for that in #789 just ftr

<!-- gh-comment-id:58132664 --> @magnumripper commented on GitHub (Oct 7, 2014): Separate issue for that in #789 just ftr
Author
Owner

@kholia commented on GitHub (Dec 8, 2014):

I don't think that this issue is important enough to block the release of 1.8.0-jumbo1.

Can we please move this to the next milestone?

<!-- gh-comment-id:66133162 --> @kholia commented on GitHub (Dec 8, 2014): I don't think that this issue is important enough to block the release of `1.8.0-jumbo1`. Can we please move this to the next milestone?
Author
Owner

@ShaneQful commented on GitHub (Feb 21, 2015):

So after having a little look at the issue, the older pdf2john.c could do this but only for really old versions of the pdf spec. In order to do this properly for all versions, the algorithms for generating the owner password have to be implemented. Unfortunately we can't just take these from other open source projects as most don't bother to implent them as it's kinda pointless DRM that only works if you open the pdf in an adobe product.

Essentially the fix is to implement the algorithms for the owner password described here : http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf

And to add a flag in the to say which password you want.

Going to remove myself as assignee as work is a bit hectic at the moment and I don't have the time to work on this, apologies.

<!-- gh-comment-id:75370730 --> @ShaneQful commented on GitHub (Feb 21, 2015): So after having a little look at the issue, the older pdf2john.c could do this but only for really old versions of the pdf spec. In order to do this properly for all versions, the algorithms for generating the owner password have to be implemented. Unfortunately we can't just take these from other open source projects as most don't bother to implent them as it's kinda pointless DRM that only works if you open the pdf in an adobe product. Essentially the fix is to implement the algorithms for the owner password described here : http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf And to add a flag in the to say which password you want. Going to remove myself as assignee as work is a bit hectic at the moment and I don't have the time to work on this, apologies.
Author
Owner

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

@ShaneQful thanks for all the research on this topic!

I agree that it seems to be pretty pointless to implement this, the reporter can simply use "Sumatra PDF reader" to bypass owner password restrictions. Should we just close this ticket?

<!-- gh-comment-id:202517981 --> @kholia commented on GitHub (Mar 28, 2016): @ShaneQful thanks for all the research on this topic! I agree that it seems to be pretty pointless to implement this, the reporter can simply use "Sumatra PDF reader" to bypass owner password restrictions. Should we just close this ticket?
Author
Owner

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

Yeah I think we can close it. I don't think any other pdf viewer other than adobe's even bothers to check the field. If one of the open source pdf viewers start to do this check we can always take their code once it's implemented.

<!-- gh-comment-id:202532635 --> @ShaneQful commented on GitHub (Mar 28, 2016): Yeah I think we can close it. I don't think any other pdf viewer other than adobe's even bothers to check the field. If one of the open source pdf viewers start to do this check we can always take their code once it's implemented.
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#396
No description provided.