From 2c8ff7f54cd0348fc7245dd5add7417f3bff8dff Mon Sep 17 00:00:00 2001 From: CMD <80255379+iCMDdev@users.noreply.github.com> Date: Sun, 31 May 2026 12:16:34 +0300 Subject: [PATCH 1/2] Fix permission value calculation in PDF.pm --- run/lib/PDF.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run/lib/PDF.pm b/run/lib/PDF.pm index 70db8d693e7..4a1404fe91b 100644 --- a/run/lib/PDF.pm +++ b/run/lib/PDF.pm @@ -1204,7 +1204,11 @@ sub DecryptInit($$$) $$encrypt{_meta} = 1; } - printf("\$pdf\$%d*%d*%d*%d*%d*%d*", $ver, $rev, $$encrypt{Length} || 40, $$encrypt{P}, $$encrypt{_meta} || 0, length($id)); + # PDF /P is a signed 32-bit integer + my $perm = $$encrypt{P}; + $perm -= 4294967296 if $perm >= 2147483648; + + printf("\$pdf\$%d*%d*%d*%d*%d*%d*", $ver, $rev, $$encrypt{Length} || 40, $perm, $$encrypt{_meta} || 0, length($id)); my $str = $id; $str =~ s/(.)/ sprintf '%02x', ord $1 /seg; printf("%s*", $str); From 09fa63a2f508ea9b3a64350909f94054e524b2d0 Mon Sep 17 00:00:00 2001 From: CMD <80255379+iCMDdev@users.noreply.github.com> Date: Sun, 31 May 2026 12:18:52 +0300 Subject: [PATCH 2/2] Fix permission value calculation in pdf2john.py --- run/pdf2john.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run/pdf2john.py b/run/pdf2john.py index 299714e9946..01b2b72fe29 100755 --- a/run/pdf2john.py +++ b/run/pdf2john.py @@ -73,6 +73,8 @@ def __init__(self, file_name: str, strict: bool = False): self.algorithm: int = self.encrypt_dict.get("/V") self.length: int = self.encrypt_dict.get("/Length", 40) self.permissions: int = self.encrypt_dict["/P"] + if self.permissions >= 2**31: + self.permissions -= 2**32 self.revision: int = self.encrypt_dict["/R"] @property