Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion run/lib/PDF.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions run/pdf2john.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down