diff --git a/include/mpsp.h b/include/mpsp.h index 86f04bf45..797f63d09 100644 --- a/include/mpsp.h +++ b/include/mpsp.h @@ -20,7 +20,7 @@ #define INCR_MASKS 1000 -u32 mp_get_length (char *mask); +u32 mp_get_length (const char *mask); void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop); diff --git a/src/interface.c b/src/interface.c index 56dc6441d..2be467720 100644 --- a/src/interface.c +++ b/src/interface.c @@ -19890,6 +19890,11 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->pw_max = PW_MAX; + if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE) + { + hashconfig->pw_max = PW_MAX / 2; + } + switch (hashconfig->hash_mode) { case 125: hashconfig->pw_max = 32; diff --git a/src/mpsp.c b/src/mpsp.c index 2ccbbe4a4..29ce772c7 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -910,11 +910,24 @@ static int mask_append_final (hashcat_ctx_t *hashcat_ctx, const char *mask) static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; user_options_t *user_options = hashcat_ctx->user_options; if (user_options->increment == true) { - for (u32 increment_len = user_options->increment_min; increment_len <= user_options->increment_max; increment_len++) + const u32 mask_length = mp_get_length (mask); + + const u32 pw_min = hashconfig->pw_min; + const u32 pw_max = hashconfig->pw_max; + + u32 increment_min = user_options->increment_min; + u32 increment_max = user_options->increment_max; + + increment_min = MAX (increment_min, pw_min); + increment_max = MIN (increment_max, pw_max); + increment_max = MIN (increment_max, mask_length); + + for (u32 increment_len = increment_min; increment_len <= increment_max; increment_len++) { char *mask_truncated = (char *) hcmalloc (hashcat_ctx, 256); VERIFY_PTR (mask_truncated); @@ -937,7 +950,7 @@ static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) return 0; } -u32 mp_get_length (char *mask) +u32 mp_get_length (const char *mask) { u32 len = 0;