[GH-ISSUE #1357] Markov mode: segfault #854

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

Originally created by @loverszhaokai on GitHub (May 27, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1357

#1. Reproduce

$ ./configure && make -sj8
$ cat test_pw

$apr1$a2Jqm...$grFrwEgiQleDr0zR4Jx1b.

$ ../john test_pw --markov:10:1:3

Using default input encoding: UTF-8
Loaded 1 password hash (md5crypt, crypt(3) $1$ [MD5 256/256 AVX2 8x3])
Will run 8 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
Warning: End = 3 is too large (max = 1)
MKV start (stats=$JOHN/stats, lvl=10 len=12 pwd=0)
Segmentation fault (core dumped)

#2. GDB debug

$ gdb ../john
$ set args test_pw --markov:10:1:3
$ r

Press 'q' or Ctrl-C to abort, almost any other key for status
Warning: End = 3 is too large (max = 1)
MKV start (stats=$JOHN/stats, lvl=10 len=12 pwd=0)

Program received signal SIGSEGV, Segmentation fault.
0x00000000005f109b in show_pwd_r (pwd=pwd@entry=0x7fffffffe6e0, bs=bs@entry=1) at mkv.c:111
111     i = nbparts[pwd->password[pwd->len-1] + pwd->len*256 + pwd->level*256*gmax_len];
(gdb) bt
#0  0x00000000005f109b in show_pwd_r (pwd=pwd@entry=0x7fffffffe6e0, bs=bs@entry=1) at mkv.c:111
#1  0x00000000005f237b in show_pwd (start=<optimized out>) at mkv.c:191
#2  do_markov_crack (db=<optimized out>, mkv_param=<optimized out>) at mkv.c:673
#3  0x00000000005cf8f2 in john_run () at john.c:1434
#4  0x00000000005d0054 in main (argc=3, argv=0x7fffffffe998) at john.c:1709
Originally created by @loverszhaokai on GitHub (May 27, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1357 #1. Reproduce $ ./configure && make -sj8 $ cat test_pw ``` $apr1$a2Jqm...$grFrwEgiQleDr0zR4Jx1b. ``` $ ../john test_pw --markov:10:1:3 ``` C Using default input encoding: UTF-8 Loaded 1 password hash (md5crypt, crypt(3) $1$ [MD5 256/256 AVX2 8x3]) Will run 8 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status Warning: End = 3 is too large (max = 1) MKV start (stats=$JOHN/stats, lvl=10 len=12 pwd=0) Segmentation fault (core dumped) ``` #2. GDB debug $ gdb ../john $ set args test_pw --markov:10:1:3 $ r ``` C Press 'q' or Ctrl-C to abort, almost any other key for status Warning: End = 3 is too large (max = 1) MKV start (stats=$JOHN/stats, lvl=10 len=12 pwd=0) Program received signal SIGSEGV, Segmentation fault. 0x00000000005f109b in show_pwd_r (pwd=pwd@entry=0x7fffffffe6e0, bs=bs@entry=1) at mkv.c:111 111 i = nbparts[pwd->password[pwd->len-1] + pwd->len*256 + pwd->level*256*gmax_len]; (gdb) bt #0 0x00000000005f109b in show_pwd_r (pwd=pwd@entry=0x7fffffffe6e0, bs=bs@entry=1) at mkv.c:111 #1 0x00000000005f237b in show_pwd (start=<optimized out>) at mkv.c:191 #2 do_markov_crack (db=<optimized out>, mkv_param=<optimized out>) at mkv.c:673 #3 0x00000000005cf8f2 in john_run () at john.c:1434 #4 0x00000000005d0054 in main (argc=3, argv=0x7fffffffe998) at john.c:1709 ```
bsakaguchi 2026-10-14 03:26:01 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@magnumripper commented on GitHub (May 27, 2015):

That hash (or format) has nothing to do with it.

$ ../run/john --markov:10:1:3 -stdout=15
Warning: End = 3 is too large (max = 1)
MKV start (stats=$JOHN/stats, lvl=10 len=12 pwd=0)
Segmentation fault: 11
<!-- gh-comment-id:105788898 --> @magnumripper commented on GitHub (May 27, 2015): That hash (or format) has nothing to do with it. ``` $ ../run/john --markov:10:1:3 -stdout=15 Warning: End = 3 is too large (max = 1) MKV start (stats=$JOHN/stats, lvl=10 len=12 pwd=0) Segmentation fault: 11 ```
Author
Owner

@magnumripper commented on GitHub (May 28, 2015):

    if(*mkv_end > mkv_max)
    {
        log_event("! End = "LLd" is too large (max="LLd")", *mkv_end, mkv_max);
        if (john_main_process)
            fprintf(stderr, "Warning: End = "LLd" is too large "
                    "(max = "LLd")\n", *mkv_end, mkv_max);
        *mkv_end = mkv_max;
    }

So mkv_end is reset, but apparently it doesn't help in this case.

<!-- gh-comment-id:106608161 --> @magnumripper commented on GitHub (May 28, 2015): ``` C if(*mkv_end > mkv_max) { log_event("! End = "LLd" is too large (max="LLd")", *mkv_end, mkv_max); if (john_main_process) fprintf(stderr, "Warning: End = "LLd" is too large " "(max = "LLd")\n", *mkv_end, mkv_max); *mkv_end = mkv_max; } ``` So mkv_end is reset, but apparently it doesn't help in this case.
Author
Owner

@jfoug commented on GitHub (Jun 1, 2015):

There are no words in level 10. Here is level 30.

MKV start (stats=$JOHN/stats, lvl=30 len=12 pwd=9)
c
m
s
a
b
p
d
l
8p 0:00:00:00 42.11% (ETA: 14:44:23) 41.88p/s l

The problem is that a level of 255 is returned. Problem (char)-1 but what happens is we offset an array at offset 255 (it is multipled, but level used is 255). This is a pretty easy fix (I think).\

With the syntax used, we are forcing the code to try to build a word, when there is none. HOWEVER, it is a quick check to see if the level is too high.

<!-- gh-comment-id:107682977 --> @jfoug commented on GitHub (Jun 1, 2015): There are no words in level 10. Here is level 30. MKV start (stats=$JOHN/stats, lvl=30 len=12 pwd=9) c m s a b p d l 8p 0:00:00:00 42.11% (ETA: 14:44:23) 41.88p/s l The problem is that a level of 255 is returned. Problem (char)-1 but what happens is we offset an array at offset 255 (it is multipled, but level used is 255). This is a pretty easy fix (I think).\ With the syntax used, we are forcing the code to try to build a word, when there is none. HOWEVER, it is a quick check to see if the level is too high.
Author
Owner

@jfoug commented on GitHub (Jun 1, 2015):

f3d5f9e fixes the problem

<!-- gh-comment-id:107684702 --> @jfoug commented on GitHub (Jun 1, 2015): f3d5f9e fixes the problem
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#854
No description provided.