[GH-ISSUE #1363] External mode: SegFault #859

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

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

Originally assigned to: @loverszhaokai on GitHub.

#1. Analysis

This bug is similar to https://github.com/magnumripper/JohnTheRipper/issues/1358 and https://github.com/magnumripper/JohnTheRipper/issues/1360
But this bug is a little different, at least it does not need --enable-asan
#2. Reproduce

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

$apr1$a2Jqm...$grFrwEgiQleDr0zR4Jx1b.

$ cat local.conf

[List.External:Lanman]
int last;       // Last character position, zero-based
int lastofs;        // Last character position offset into charset[]
int lastid;     // Current character index in the last position
int id[0x7f];       // Current character indices for other positions
int charset[0x7f00];    // Character sets, 0x100 elements for each position

void init()
{
    int A[26], C[26], V[26];
    int length;
    int pos, ofs, i, c;

    i = 0; while (i < 26) { A[i] = C[i] = 1; V[i++] = 0; }
    i = 'a' - 'a'; C[i] = 0; V[i] = 1;
    i = 'e' - 'a'; C[i] = 0; V[i] = 1;
    i = 'i' - 'a'; C[i] = 0; V[i] = 1;
    i = 'o' - 'a'; C[i] = 0; V[i] = 1;
    i = 'u' - 'a'; C[i] = 0; V[i] = 1;
    i = 'q' - 'a'; A[i] = C[i] = 0;
    i = 'x' - 'a'; A[i] = C[i] = 0;
    i = 'y' - 'a'; A[i] = C[i] = 0;

    length = 8;

/* This defines the character sets for different character positions */
    pos = 0;
    while (pos < 6) {
        ofs = pos++ << 8;
        i = 0;
        c = 'a' - 1;
        while (++c <= 'z')
            if (C[c - 'a'])
                charset[ofs + i++] = c;
        charset[ofs + i] = 0;
        ofs = pos++ << 8;
        i = 0;
        c = 'a' - 1;
        while (++c <= 'z')
            if (V[c - 'a'])
                charset[ofs + i++] = c;
        charset[ofs + i] = 0;
        ofs = pos++ << 8;
        i = 0;
        c = 'a' - 1;
        while (++c <= 'z')
            if (A[c - 'a'])
                charset[ofs + i++] = c;
        charset[ofs + i] = 0;
    }
    c = '1';
    while (pos < length) {
        ofs = pos++ << 8;
        i = 0;
        while (c <= '9')
            charset[ofs + i++] = C++;
        charset[ofs + i] = 0;
        c = '0';
    }

    last = length - 1;
    pos = -1;
    while (++pos <= last)
        word[pos] = charset[id[pos] = pos << 8];
    lastid = (lastofs = last << 8) - 1;
    word[pos] = 0;
}

void generate()
{
}

void restore()
{
}

$ ../john test_pw --format=md5crypt --external=lanman --config=local.conf

Segmentation fault

#3. GDB debug

Program received signal SIGSEGV, Segmentation fault.
0x00000000005c15af in c_execute_fast (addr=<optimized out>) at compiler.c:1107
1107        imm = *((sp - 3)->mem += imm);
(gdb) bt
#0  0x00000000005c15af in c_execute_fast (addr=<optimized out>) at compiler.c:1107
#1  0x00000000005c53a2 in ext_init (mode=0x10c712d "lanman", db=<optimized out>) at external.c:190
#2  0x00000000005ccec4 in john_load () at john.c:922
#3  0x00000000005cda86 in john_init (name=0x7fffffffec32 "john", argc=5, argv=0x7fffffffe988) at john.c:1280
#4  0x00000000005ce772 in main (argc=5, argv=0x7fffffffe988) at john.c:1707
Originally created by @loverszhaokai on GitHub (May 27, 2015). Original GitHub issue: https://github.com/openwall/john/issues/1363 Originally assigned to: @loverszhaokai on GitHub. #1. Analysis This bug is similar to https://github.com/magnumripper/JohnTheRipper/issues/1358 and https://github.com/magnumripper/JohnTheRipper/issues/1360 But this bug is a little different, at least it does not need --enable-asan #2. Reproduce $ ./configure && make -sj8 $ cat test_pw ``` $apr1$a2Jqm...$grFrwEgiQleDr0zR4Jx1b. ``` $ cat local.conf ``` C [List.External:Lanman] int last; // Last character position, zero-based int lastofs; // Last character position offset into charset[] int lastid; // Current character index in the last position int id[0x7f]; // Current character indices for other positions int charset[0x7f00]; // Character sets, 0x100 elements for each position void init() { int A[26], C[26], V[26]; int length; int pos, ofs, i, c; i = 0; while (i < 26) { A[i] = C[i] = 1; V[i++] = 0; } i = 'a' - 'a'; C[i] = 0; V[i] = 1; i = 'e' - 'a'; C[i] = 0; V[i] = 1; i = 'i' - 'a'; C[i] = 0; V[i] = 1; i = 'o' - 'a'; C[i] = 0; V[i] = 1; i = 'u' - 'a'; C[i] = 0; V[i] = 1; i = 'q' - 'a'; A[i] = C[i] = 0; i = 'x' - 'a'; A[i] = C[i] = 0; i = 'y' - 'a'; A[i] = C[i] = 0; length = 8; /* This defines the character sets for different character positions */ pos = 0; while (pos < 6) { ofs = pos++ << 8; i = 0; c = 'a' - 1; while (++c <= 'z') if (C[c - 'a']) charset[ofs + i++] = c; charset[ofs + i] = 0; ofs = pos++ << 8; i = 0; c = 'a' - 1; while (++c <= 'z') if (V[c - 'a']) charset[ofs + i++] = c; charset[ofs + i] = 0; ofs = pos++ << 8; i = 0; c = 'a' - 1; while (++c <= 'z') if (A[c - 'a']) charset[ofs + i++] = c; charset[ofs + i] = 0; } c = '1'; while (pos < length) { ofs = pos++ << 8; i = 0; while (c <= '9') charset[ofs + i++] = C++; charset[ofs + i] = 0; c = '0'; } last = length - 1; pos = -1; while (++pos <= last) word[pos] = charset[id[pos] = pos << 8]; lastid = (lastofs = last << 8) - 1; word[pos] = 0; } void generate() { } void restore() { } ``` $ ../john test_pw --format=md5crypt --external=lanman --config=local.conf ``` C Segmentation fault ``` #3. GDB debug ``` C Program received signal SIGSEGV, Segmentation fault. 0x00000000005c15af in c_execute_fast (addr=<optimized out>) at compiler.c:1107 1107 imm = *((sp - 3)->mem += imm); (gdb) bt #0 0x00000000005c15af in c_execute_fast (addr=<optimized out>) at compiler.c:1107 #1 0x00000000005c53a2 in ext_init (mode=0x10c712d "lanman", db=<optimized out>) at external.c:190 #2 0x00000000005ccec4 in john_load () at john.c:922 #3 0x00000000005cda86 in john_init (name=0x7fffffffec32 "john", argc=5, argv=0x7fffffffe988) at john.c:1280 #4 0x00000000005ce772 in main (argc=5, argv=0x7fffffffe988) at john.c:1707 ```
bsakaguchi 2026-10-14 03:26:10 +07:00
Author
Owner

@magnumripper commented on GitHub (Nov 9, 2015):

http://www.openwall.com/lists/john-dev/2015/05/27/4

<!-- gh-comment-id:154888162 --> @magnumripper commented on GitHub (Nov 9, 2015): http://www.openwall.com/lists/john-dev/2015/05/27/4
Author
Owner

@magnumripper commented on GitHub (Nov 9, 2015):

http://www.openwall.com/lists/john-dev/2015/05/30/12

<!-- gh-comment-id:154888841 --> @magnumripper commented on GitHub (Nov 9, 2015): http://www.openwall.com/lists/john-dev/2015/05/30/12
Author
Owner

@magnumripper commented on GitHub (Nov 9, 2015):

http://www.openwall.com/lists/john-dev/2015/06/01/7

<!-- gh-comment-id:154889218 --> @magnumripper commented on GitHub (Nov 9, 2015): http://www.openwall.com/lists/john-dev/2015/06/01/7
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#859
No description provided.