[GH-ISSUE #1014] PRINCE mode segfault #614

Closed
opened 2026-10-14 03:15:26 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @magnumripper on GitHub (Jan 11, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1014

This beats me. Test case:

$ seq 0 9 > testfile
$ ../run/john --prince=testfile -stdout | ../run/pass_gen.pl nt -count=5000000 > prince.nt

This never segfaults:

$ rm -f ../run/john.{pot,log} && ./pp64 <testfile | ../run/john -stdin prince.nt -form:nt -verb=1 
Loaded 5000000 password hashes with no different salts (NT [MD4 128/128 X2 SSE2-16])
Press Ctrl-C to abort, or send SIGUSR1 to john process for status
5000000g 0:00:00:09  535905g/s 535905p/s 535905c/s 1388GC/s 0511581..1811581
Session completed

But this segfaults almost (but not quite) every time:

$ rm -f ../run/john.{pot,log} && ../run/john --prince=testfile prince.nt -form:nt -verb=1 
Loaded 5000000 password hashes with no different salts (NT [MD4 128/128 X2 SSE2-16])
Press 'q' or Ctrl-C to abort, almost any other key for status
Segmentation fault: 11

When it segfaults, it's because salt is NULL

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008
crk_salt_loop () at cracker.c:742
742                     crk_methods.set_salt(salt->salt);
(gdb) bt
#0  crk_salt_loop () at cracker.c:742
#1  0x0000000100269da5 in do_prince_crack (db=0x100ebb0c0, filename=<value temporarily unavailable, due to optimizations>) at prince.c:1148
Previous frame inner to this frame (gdb could not unwind past this frame)
(gdb) print salt
$1 = (struct db_salt *) 0x0

This must be some kind of buffer overrun but I can't see how/why/where it could happen, and ASan does not catch it.

Originally created by @magnumripper on GitHub (Jan 11, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1014 This beats me. Test case: ``` $ seq 0 9 > testfile $ ../run/john --prince=testfile -stdout | ../run/pass_gen.pl nt -count=5000000 > prince.nt ``` This never segfaults: ``` $ rm -f ../run/john.{pot,log} && ./pp64 <testfile | ../run/john -stdin prince.nt -form:nt -verb=1 Loaded 5000000 password hashes with no different salts (NT [MD4 128/128 X2 SSE2-16]) Press Ctrl-C to abort, or send SIGUSR1 to john process for status 5000000g 0:00:00:09 535905g/s 535905p/s 535905c/s 1388GC/s 0511581..1811581 Session completed ``` But this segfaults almost (but not quite) every time: ``` $ rm -f ../run/john.{pot,log} && ../run/john --prince=testfile prince.nt -form:nt -verb=1 Loaded 5000000 password hashes with no different salts (NT [MD4 128/128 X2 SSE2-16]) Press 'q' or Ctrl-C to abort, almost any other key for status Segmentation fault: 11 ``` When it segfaults, it's because salt is NULL ``` Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008 crk_salt_loop () at cracker.c:742 742 crk_methods.set_salt(salt->salt); (gdb) bt #0 crk_salt_loop () at cracker.c:742 #1 0x0000000100269da5 in do_prince_crack (db=0x100ebb0c0, filename=<value temporarily unavailable, due to optimizations>) at prince.c:1148 Previous frame inner to this frame (gdb could not unwind past this frame) (gdb) print salt $1 = (struct db_salt *) 0x0 ``` This must be some kind of buffer overrun but I can't see how/why/where it could happen, and ASan does not catch it.
bsakaguchi 2026-10-14 03:15:26 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (Jan 11, 2015):

BTW here's how to build pp64 with ASan so you are sure to run the exact same version as in JtR:

$ gcc -lgmp -std=c99 -fsanitize=address -O1 -g prince.c -o pp64 -Wall -DOSX

The last -DOSX can also be -DWINDOWS or -DLINUX.

<!-- gh-comment-id:69493116 --> @magnumripper commented on GitHub (Jan 11, 2015): BTW here's how to build pp64 with ASan so you are sure to run the exact same version as in JtR: ``` $ gcc -lgmp -std=c99 -fsanitize=address -O1 -g prince.c -o pp64 -Wall -DOSX ``` The last -DOSX can also be -DWINDOWS or -DLINUX.
Author
Owner

@magnumripper commented on GitHub (Jan 11, 2015):

This must be some kind of buffer overrun but I can't see how/why/where it could happen, and ASan does not catch it.

Another reason could be that we call crk_process_key() even though everything was already cracked. 7223927 fixes such bug and I really thought that was it, but it still segfaults.

<!-- gh-comment-id:69493618 --> @magnumripper commented on GitHub (Jan 11, 2015): > This must be some kind of buffer overrun but I can't see how/why/where it could happen, and ASan does not catch it. Another reason could be that we call crk_process_key() even though everything was already cracked. 7223927 fixes such bug and I really thought that was it, but it still segfaults.
Author
Owner

@magnumripper commented on GitHub (Jan 11, 2015):

LOL, I was right - but there were more levels of loops and we had to break out of them all.

<!-- gh-comment-id:69493851 --> @magnumripper commented on GitHub (Jan 11, 2015): LOL, I was right - but there were more levels of loops and we had to break out of them all.
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#614
No description provided.