You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PDF Permissions value is treated as an unsigned integer in PDF2John #5992
However, loading this hash in john or hashcat failed:
$ john --format=pdf pdf.john
Using default input encoding: UTF-8
No password hashes loaded (see FAQ)
So I started to investigate this issue. The PDF seemed fine since I could open it in my PDF viewer and enter the password (which I already knew) to decrypt it.
After analyzing this issue, it seems that the problem was with the /P entry in the PDF encryption dictionary:
/P is a 32-bit permissions value, but it is treated as a signed 32-bit integer, and thus the value 4294967292 is the unsigned representation of -4. Looking at the hash format generated by pdf2john tools, these do not appear to convert this value back to a signed integer, before printing the hash:
Current pdf2john output:
document.pdf:$pdf$2*3*128*4294967292*1*16*[redacted]
Expected output (this hash works):
document.pdf:$pdf$2*3*128*-4*1*16*[redacted]
I think we've already fixed this in John a few years ago:
commit e2bc5ca440beaaadfb78e8091f026fcf10cd610d
Author: magnum <magnumripper@hushmail.com>
Date: Mon Apr 25 10:06:05 2022 +0200
PDF format: Allow P as signed or unsigned int - 32-bit build bugfix
Value can be -2147483648 .. 4294967295. Closes #5114
commit 102106fad96efb4e2311bc320eae1bd4007bd061
Author: magnum <magnumripper@hushmail.com>
Date: Tue Apr 12 09:31:40 2022 +0200
PDF format: Allow unsigned permission value, and/or empty id
Closes #4739
I guess you were using an older version?
That said, I don't mind us also fixing it in the 2john tools, to produce "hashes" usable by older John and maybe hashcat - have you checked what hashcat expects?
You're right, thanks and sorry for not checking that - I was using the one that comes with homebrew, which is john-1.9.0-jumbo-1. And on your website, you're indeed specifying this doesn't include the latest patches - "out of date, with known issues".
I built the latest john and everything works!
have you checked what hashcat expects?
Hashcat expects the same format, excepting the document.pdf: filename prefix -i.e. just $pdf$2*3*128*4294967292*1*16*.... And the latest version also now supports unsigned values like the new john does (I was yet again on an outdated version). So indeed this isn't necessary anymore (unless you want compatibility with older john / hashcat, but the old releases would still include the old pdf2john script). Again, my apologies for not checking my versions!
@iCMDdev Thank you for checking and confirming that everything works with the latest revisions.
@magnumripper Do you think we should merge the script changes anyway? I think we could, but then we'd possibly need some retesting on our samples and with different versions of John and hashcat. Up to you.
@magnumripper Do you think we should merge the script changes anyway? I think we could, but then we'd possibly need some retesting on our samples and with different versions of John and hashcat. Up to you.
I wouldn't mind but I don't think it's necessary. In general, running different version of tool and cracker is not supported att all. But if someone else does the testing, fine with me!
Activity
solardiz commentedon May 31, 2026
I think we've already fixed this in John a few years ago:
I guess you were using an older version?
That said, I don't mind us also fixing it in the 2john tools, to produce "hashes" usable by older John and maybe hashcat - have you checked what hashcat expects?
iCMDdev commentedon May 31, 2026
You're right, thanks and sorry for not checking that - I was using the one that comes with homebrew, which is
john-1.9.0-jumbo-1. And on your website, you're indeed specifying this doesn't include the latest patches - "out of date, with known issues".I built the latest
johnand everything works!Hashcat expects the same format, excepting the
document.pdf:filename prefix -i.e. just$pdf$2*3*128*4294967292*1*16*.... And the latest version also now supports unsigned values like the new john does (I was yet again on an outdated version). So indeed this isn't necessary anymore (unless you want compatibility with older john / hashcat, but the old releases would still include the oldpdf2johnscript). Again, my apologies for not checking my versions!solardiz commentedon Jun 2, 2026
@iCMDdev Thank you for checking and confirming that everything works with the latest revisions.
@magnumripper Do you think we should merge the script changes anyway? I think we could, but then we'd possibly need some retesting on our samples and with different versions of John and hashcat. Up to you.
magnumripper commentedon Jul 3, 2026
I wouldn't mind but I don't think it's necessary. In general, running different version of tool and cracker is not supported att all. But if someone else does the testing, fine with me!