diff -urpN john-1.7.7-jumbo-5/src/md5_gen_fmt.c john-1.7.7-jumbo-6/src/md5_gen_fmt.c --- john-1.7.7-jumbo-5/src/md5_gen_fmt.c 2011-05-27 18:38:16.000000000 +0000 +++ john-1.7.7-jumbo-6/src/md5_gen_fmt.c 2011-06-06 02:45:14.515625000 +0000 @@ -778,20 +778,21 @@ static void set_salt(void *salt) { if (*cp == '$' && cp[-1] == '$') { - // found an 'additional' salt. - --cp; - *cp = 0; - // re-adjust salt len. - saltlen = cp-cursalt; switch (cp[2]) { case '2': // salt2 + --cp; + *cp = 0; + saltlen = cp-cursalt; strnzcpy(cursalt2, &cp[3], sizeof(cursalt2)); saltlen2 = strlen(cursalt2); break; case 'U': // username + --cp; + *cp = 0; + saltlen = cp-cursalt; strnzcpy(username, &cp[3], sizeof(username)); usernamelen = strlen(username); break; @@ -799,14 +800,19 @@ static void set_salt(void *salt) { // Fld flags int which = cp[3] - '0'; - if (which < 0 || which > 9) - exit(fprintf(stderr, "Error, unknown salt string $%s\n", &cp[1])); - strnzcpy(flds[which], &cp[4], sizeof(flds[0])); - fld_lens[which] = strlen(flds[which]); + if (which >= 0 && which <= 9) { + --cp; + *cp = 0; + saltlen = cp-cursalt; + strnzcpy(flds[which], &cp[4], sizeof(flds[0])); + fld_lens[which] = strlen(flds[which]); + } } break; - default: - exit(fprintf(stderr, "Error, unknown salt string $%s\n", &cp[1])); + + // NOTE this does not allow $$ to be in the salt string. +// default: +// exit(fprintf(stderr, "Error, unknown salt string $%s\n", &cp[1])); } } } @@ -1375,15 +1381,21 @@ static void *salt(char *ciphertext) if (curdat.md5_gen_FIXED_SALT_SIZE==0 && !curdat.bUserName && !curdat.FldMask) return Salt; if (!strncmp(ciphertext, "md5_gen(", 8)) { - if (ciphertext[curdat.md5_gen_SALT_OFFSET] == '$') - strnzcpy(Salt, &ciphertext[curdat.md5_gen_SALT_OFFSET-1], SALT_SIZE); - else + // this code is BROKEN in the case where we have a 'simple' salt, that starts with a '$' + // character. For now, I will simply comment these out, and they shoudl work fine. NOTE, this + // will break complex salts, which do not start with a 'normal' salt. Something like + // $$Uuser will now fail (if that is the entire salt). But at this time, there are no 'canned' + // formats that use that, so this patch will work around the problem, giving me some time to + // address this for the 'complex' salt case, in a later version of md5_gen. +// if (ciphertext[curdat.md5_gen_SALT_OFFSET] == '$') +// strnzcpy(Salt, &ciphertext[curdat.md5_gen_SALT_OFFSET-1], SALT_SIZE); +// else strnzcpy(Salt, &ciphertext[curdat.md5_gen_SALT_OFFSET], SALT_SIZE); } else { - if (ciphertext[curdat.md5_gen_SALT_OFFSET-strlen(curdat.md5_gen_WHICH_TYPE_SIG)] == '$') - strnzcpy(Salt, &ciphertext[curdat.md5_gen_SALT_OFFSET-strlen(curdat.md5_gen_WHICH_TYPE_SIG)-1], SALT_SIZE); - else +// if (ciphertext[curdat.md5_gen_SALT_OFFSET-strlen(curdat.md5_gen_WHICH_TYPE_SIG)] == '$') +// strnzcpy(Salt, &ciphertext[curdat.md5_gen_SALT_OFFSET-strlen(curdat.md5_gen_WHICH_TYPE_SIG)-1], SALT_SIZE); +// else strnzcpy(Salt, &ciphertext[curdat.md5_gen_SALT_OFFSET-strlen(curdat.md5_gen_WHICH_TYPE_SIG)], SALT_SIZE); } if (curdat.md5_gen_salt_as_hex)