From 7544adce8f5cee2889ed685de4692d1a8eddd224 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 4 Oct 2016 08:21:03 +0200 Subject: [PATCH] Add mp_css_unicode_expand() --- include/mpsp.h | 3 ++- src/hashcat.c | 17 +---------------- src/mpsp.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/mpsp.h b/include/mpsp.h index a3447dd4b..73924e20b 100644 --- a/include/mpsp.h +++ b/include/mpsp.h @@ -20,9 +20,10 @@ #define INCR_MASKS 1000 +void mp_css_unicode_expand (mask_ctx_t *mask_ctx); void mp_css_to_uniq_tbl (u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]); void mp_cut_at (char *mask, u32 max); -u32 mp_get_length (char *mask); +u32 mp_get_length (char *mask); void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt); cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u32 *css_cnt, const hashconfig_t *hashconfig, const user_options_t *user_options); u64 mp_get_sum (u32 css_cnt, cs_t *css); diff --git a/src/hashcat.c b/src/hashcat.c index 09064d704..13cae463d 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -657,22 +657,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE) { - u32 css_cnt_unicode = mask_ctx->css_cnt * 2; - - cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t)); - - for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2) - { - memcpy (&css_buf_unicode[j + 0], &mask_ctx->css_buf[i], sizeof (cs_t)); - - css_buf_unicode[j + 1].cs_buf[0] = 0; - css_buf_unicode[j + 1].cs_len = 1; - } - - myfree (mask_ctx->css_buf); - - mask_ctx->css_buf = css_buf_unicode; - mask_ctx->css_cnt = css_cnt_unicode; + mp_css_unicode_expand (mask_ctx); } // check if mask is not too large or too small for pw_min/pw_max (*2 if unicode) diff --git a/src/mpsp.c b/src/mpsp.c index d27e7bae9..7adbefebf 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -20,6 +20,26 @@ static const char DEF_MASK[] = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d"; #define MAX_MFS 5 // 4*charset, 1*mask +void mp_css_unicode_expand (mask_ctx_t *mask_ctx) +{ + u32 css_cnt_unicode = mask_ctx->css_cnt * 2; + + cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t)); + + for (u32 i = 0, j = 0; i < mask_ctx->css_cnt; i += 1, j += 2) + { + memcpy (&css_buf_unicode[j + 0], &mask_ctx->css_buf[i], sizeof (cs_t)); + + css_buf_unicode[j + 1].cs_buf[0] = 0; + css_buf_unicode[j + 1].cs_len = 1; + } + + myfree (mask_ctx->css_buf); + + mask_ctx->css_buf = css_buf_unicode; + mask_ctx->css_cnt = css_cnt_unicode; +} + void mp_css_to_uniq_tbl (u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]) { /* generates a lookup table where key is the char itself for fastest possible lookup performance */