diff -urpN j7-rc1/src/dynamic.h j7-rc0/src/dynamic.h --- j7-rc1/src/dynamic.h 2012-08-09 20:46:45.421875000 +0000 +++ j7-rc0/src/dynamic.h 2012-08-09 19:53:39.421875000 +0000 @@ -109,6 +109,7 @@ int dynamic_IS_VALID(int i); int dynamic_real_salt_length(struct fmt_main *pFmt); void dynamic_RESET(struct fmt_main *); void dynamic_DISPLAY_ALL_FORMATS(); +char *RemoveHEX(char *output, char *input); // Function used to 'link' a thin format into dynamic. See PHPS_fmt.c for an example. struct fmt_main *dynamic_THIN_FORMAT_LINK(struct fmt_main *pFmt, char *ciphertext, char *orig_sig, int bInitAlso); diff -urpN j7-rc1/src/dynamic_fmt.c j7-rc0/src/dynamic_fmt.c --- j7-rc1/src/dynamic_fmt.c 2012-08-09 20:46:45.421875000 +0000 +++ j7-rc0/src/dynamic_fmt.c 2012-08-09 19:59:30.234375000 +0000 @@ -788,6 +788,46 @@ static void init(struct fmt_main *pFmt) } } +char *RemoveHEX(char *output, char *input) { + char *cpi = input; + char *cpo = output; + char *cpH = strstr(input, "$HEX$"); + + if (!cpH) { + // should never get here, we have a check performed before this function is called. + strcpy(output, input); + return output; + } + + while (cpi < cpH) + *cpo++ = *cpi++; + + *cpo++ = *cpi; + cpi += 5; + while (*cpi) { + if (*cpi == '0' && cpi[1] == '0') { + strcpy(output, input); + return output; + } + if (atoi16[ARCH_INDEX(*cpi)] != 0x7f && atoi16[ARCH_INDEX(cpi[1])] != 0x7f) { + *cpo++ = atoi16[ARCH_INDEX(*cpi)]*16 + atoi16[ARCH_INDEX(cpi[1])]; + cpi += 2; + } else if (*cpi == '$') { + while (*cpi && strncmp(cpi, "$HEX$", 5)) { + *cpo++ = *cpi++; + } + if (!strncmp(cpi, "$HEX$", 5)) { + *cpo++ = *cpi; + cpi += 5; + } + } else { + strcpy(output, input); + return output; + } + } + *cpo = 0; + return output; +} /********************************************************************************* * This function will add a $dynamic_#$ IF there is not one, and if we have a specific @@ -895,15 +935,21 @@ static char *split(char *ciphertext, int { static char out[1024]; - if (!strncmp(ciphertext, "$dynamic", 8)) + if (!strncmp(ciphertext, "$dynamic", 8)) { + if (strstr(ciphertext, "$HEX$")) + return RemoveHEX(out, ciphertext); return ciphertext; - + } if (!strncmp(ciphertext, "md5_gen(", 8)) { ciphertext += 8; do ++ciphertext; while (*ciphertext != ')') ; ++ciphertext; } - sprintf(out, "%s%s", curdat.dynamic_WHICH_TYPE_SIG, ciphertext); + if (strstr(ciphertext, "$HEX$")) { + char *cp = out + sprintf(out, "%s", curdat.dynamic_WHICH_TYPE_SIG); + RemoveHEX(cp, ciphertext); + } else + sprintf(out, "%s%s", curdat.dynamic_WHICH_TYPE_SIG, ciphertext); return out; } @@ -914,14 +960,21 @@ static char *split_UC(char *ciphertext, static char out[1024]; if (!strncmp(ciphertext, "$dynamic", 8)) { - strcpy(out, ciphertext); + if (strstr(ciphertext, "$HEX$")) + RemoveHEX(out, ciphertext); + else + strcpy(out, ciphertext); } else { if (!strncmp(ciphertext, "md5_gen(", 8)) { ciphertext += 8; do ++ciphertext; while (*ciphertext != ')') ; ++ciphertext; } - sprintf(out, "%s%s", curdat.dynamic_WHICH_TYPE_SIG, ciphertext); + if (strstr(ciphertext, "$HEX$")) { + char *cp = out + sprintf(out, "%s", curdat.dynamic_WHICH_TYPE_SIG); + RemoveHEX(cp, ciphertext); + } else + sprintf(out, "%s%s", curdat.dynamic_WHICH_TYPE_SIG, ciphertext); } ciphertext = strchr(&out[8], '$')+1; while (*ciphertext && *ciphertext != '$') { @@ -6963,6 +7016,7 @@ int dynamic_SETUP(DYNAMIC_Setup *Setup, curdat.dynamic_hdaa_salt = ((Setup->flags&MGF_HDAA_SALT)==MGF_HDAA_SALT) ? 1 : 0; curdat.dynamic_40_byte_sha1 = ((Setup->flags&MGF_SHA1_40_BYTE_FINISH)==MGF_SHA1_40_BYTE_FINISH) ? 1 : 0; + curdat.FldMask = 0; curdat.b2Salts = ((Setup->flags&MGF_SALTED2)==MGF_SALTED2) ? 1 : 0; curdat.dynamic_base16_upcase = ((Setup->flags&MGF_BASE_16_OUTPUT_UPCASE)==MGF_BASE_16_OUTPUT_UPCASE) ? 1 : 0; curdat.FldMask |= ((Setup->flags&MGF_FLD0)==MGF_FLD0) ? MGF_FLD0 : 0; @@ -6978,7 +7032,6 @@ int dynamic_SETUP(DYNAMIC_Setup *Setup, curdat.dynamic_base64_inout = 0; curdat.dynamic_salt_as_hex = 0; - curdat.FldMask = 0; curdat.force_md5_ctx = 0; curdat.nUserName = 0; curdat.nPassCase = 1; @@ -7471,9 +7524,9 @@ static int LoadOneFormat(int idx, struct cp = strchr(label_id, '$'); *cp = 0; - if (!options.format || strncmp(options.format, "dynamic_", 8)) - pFmt->params.label = str_alloc_copy("dynamic"); - else +// if (!options.format || strncmp(options.format, "dynamic_", 8)) +// pFmt->params.label = str_alloc_copy("dynamic"); +// else pFmt->params.label = str_alloc_copy(label_id); strcpy(curdat.dynamic_WHICH_TYPE_SIG, label); diff -urpN j7-rc1/src/loader.c j7-rc0/src/loader.c --- j7-rc1/src/loader.c 2012-08-09 20:46:45.671875000 +0000 +++ j7-rc0/src/loader.c 2012-08-09 20:06:13.359375000 +0000 @@ -32,6 +32,7 @@ #include "john-mpi.h" #endif #include "unicode.h" +#include "dynamic.h" #ifdef HAVE_CRYPT extern struct fmt_main fmt_crypt; @@ -596,21 +597,18 @@ void ldr_load_pw_file(struct db_main *db static void ldr_load_pot_line(struct db_main *db, char *line) { struct fmt_main *format = db->format; - char *ciphertext, *unprepared; + char *ciphertext; void *binary; int hash; struct db_password *current; - char *flds[10]; - int i; - unprepared = ldr_get_field(&line, db->options->field_sep_char); - for (i = 0; i < 10; ++i) - flds[i] = ""; - flds[1] = unprepared; - ciphertext = format->methods.prepare(flds, format); - if (format->methods.valid(ciphertext,format) != 1) return; - - ciphertext = format->methods.split(ciphertext, 0); + ciphertext = ldr_get_field(&line, db->options->field_sep_char); + if (format->methods.valid(ciphertext, format) != 1) { + ciphertext = format->methods.split(ciphertext, 0); + if (format->methods.valid(ciphertext, format) != 1) + return; + } else + ciphertext = format->methods.split(ciphertext, 0); binary = format->methods.binary(ciphertext); hash = db->password_hash_func(binary); @@ -884,10 +882,17 @@ static void ldr_show_pot_line(struct db_ ciphertext = ldr_get_field(&line, db->options->field_sep_char); + if (strstr(ciphertext, "dynamic_") && strstr(ciphertext, "$HEX$")) { + char Tmp[16384]; + RemoveHEX(Tmp, ciphertext); + // tmp will always be 'shorter' or equal length to ciphertext + strcpy(ciphertext, Tmp); + } + if (line) { /* If just one format was forced on the command line, insist on it */ if (!fmt_list->next && - !fmt_list->methods.valid(ciphertext,fmt_list)) + !fmt_list->methods.valid(ciphertext, fmt_list)) return; pos = line;