[GH-ISSUE #789] pdf2john regression problem #410

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

Originally created by @magnumripper on GitHub (Oct 7, 2014).
Original GitHub issue: https://github.com/openwall/john/issues/789

github.com/magnumripper/JohnTheRipper@292b35c90f (commitcomment-8056201)

Originally created by @magnumripper on GitHub (Oct 7, 2014). Original GitHub issue: https://github.com/openwall/john/issues/789 https://github.com/magnumripper/JohnTheRipper/commit/292b35c90fee0b315f682b140bd360552a5bc381#commitcomment-8056201
bsakaguchi 2026-10-14 03:05:46 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Here's the answer from patch author:

thanks for pointing it, i lurk around but somehow i miss the issue report
...
Anyway, here are 3 trivial patches all OK in all my tests so far :

1) just delete space from searched "tag" value so : "/ID " becomes "/ID" :

    def get_trailer(self):


-        trailer = self.get_data_between(b"trailer", b">>", b"/ID ")
+       trailer = self.get_data_between(b"trailer", b">>", b"/ID")

I initially put the space as foolproof to avoid error on lines such as
/IDwhatever, but didn't find any PDF with such line.

2) double check with " " or "["
    def get_trailer(self):
        trailer = self.get_data_between(b"trailer", b">>", b"/ID ")
+        if(trailer == b""):
+            trailer = self.get_data_between(b"trailer", b">>", b"/ID[")


3) check separator after tag (allows adding other separator, such as '\t') :
    def get_trailer(self):
-        trailer = self.get_data_between(b"trailer", b">>", b"/ID ")
+       trailer = self.get_data_between(b"trailer", b">>", b"/ID")

[...]
    def get_data_between(self, s1, s2, tag):
[...]
            if(inside_first):
                output += ' ' + line
+                tagpos = output.find(tag)
                if(line.find(s2) != -1):
-                   if(tag == b"" or output.find(tag) != -1):
+                   if(tag == b"" or (tagpos != -1 and '
[\t'.find(output[tagpos+len(tag)]) != -1)):
                        break

(the last one uses a dirty trick : "find char after tag in expected
separator list", but works great ;)

I let you choose what's best.
<!-- gh-comment-id:58172163 --> @magnumripper commented on GitHub (Oct 7, 2014): Here's the answer from patch author: ``` thanks for pointing it, i lurk around but somehow i miss the issue report ... Anyway, here are 3 trivial patches all OK in all my tests so far : 1) just delete space from searched "tag" value so : "/ID " becomes "/ID" : def get_trailer(self): - trailer = self.get_data_between(b"trailer", b">>", b"/ID ") + trailer = self.get_data_between(b"trailer", b">>", b"/ID") I initially put the space as foolproof to avoid error on lines such as /IDwhatever, but didn't find any PDF with such line. 2) double check with " " or "[" def get_trailer(self): trailer = self.get_data_between(b"trailer", b">>", b"/ID ") + if(trailer == b""): + trailer = self.get_data_between(b"trailer", b">>", b"/ID[") 3) check separator after tag (allows adding other separator, such as '\t') : def get_trailer(self): - trailer = self.get_data_between(b"trailer", b">>", b"/ID ") + trailer = self.get_data_between(b"trailer", b">>", b"/ID") [...] def get_data_between(self, s1, s2, tag): [...] if(inside_first): output += ' ' + line + tagpos = output.find(tag) if(line.find(s2) != -1): - if(tag == b"" or output.find(tag) != -1): + if(tag == b"" or (tagpos != -1 and ' [\t'.find(output[tagpos+len(tag)]) != -1)): break (the last one uses a dirty trick : "find char after tag in expected separator list", but works great ;) I let you choose what's best. ```
Author
Owner

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

@ShaneQful I'm no good at Python and I didn't manage to apply the above (it's ambiguous, at least the second item). Can you make sense of it?

<!-- gh-comment-id:58172924 --> @magnumripper commented on GitHub (Oct 7, 2014): @ShaneQful I'm no good at Python and I didn't manage to apply the above (it's ambiguous, at least the second item). Can you make sense of it?
Author
Owner

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

Hey @magnumripper I think the patch author's first solution(below) should work fine. It would be good to get a pdf with this issue in the sample non-hashes as they are what I use to make sure nothing has broken once I make a change.

-    trailer = self.get_data_between(b"trailer", b">>", b"/ID ")
+    trailer = self.get_data_between(b"trailer", b">>", b"/ID")
<!-- gh-comment-id:58578088 --> @ShaneQful commented on GitHub (Oct 9, 2014): Hey @magnumripper I think the patch author's first solution(below) should work fine. It would be good to get a pdf with this issue in the sample non-hashes as they are what I use to make sure nothing has broken once I make a change. ``` - trailer = self.get_data_between(b"trailer", b">>", b"/ID ") + trailer = self.get_data_between(b"trailer", b">>", b"/ID") ```
Author
Owner

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

Oh, now I get it... I tried to do all three alternatives and that's why it ended up ambiguous, LOL.

I'll commit the first one then.

<!-- gh-comment-id:58666943 --> @magnumripper commented on GitHub (Oct 10, 2014): Oh, now I get it... I tried to do all three alternatives and that's why it ended up ambiguous, LOL. I'll commit the first one then.
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#410
No description provided.