From 9e156321ef7b73ebd719cb4f479b08eb85b0302c Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 29 Oct 2016 22:44:01 +0200 Subject: [PATCH] Bring back mask length of mask as number to status screen --- include/mpsp.h | 2 ++ include/status.h | 1 + include/types.h | 3 ++- src/hashcat.c | 1 + src/mpsp.c | 32 ++++++++++++++++---------------- src/status.c | 12 ++++++++++++ src/terminal.c | 12 +++++++----- 7 files changed, 41 insertions(+), 22 deletions(-) diff --git a/include/mpsp.h b/include/mpsp.h index 5840704eb..86f04bf45 100644 --- a/include/mpsp.h +++ b/include/mpsp.h @@ -20,6 +20,8 @@ #define INCR_MASKS 1000 +u32 mp_get_length (char *mask); + void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop); int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx); diff --git a/include/status.h b/include/status.h index 60f8dc16e..2f012bc95 100644 --- a/include/status.h +++ b/include/status.h @@ -26,6 +26,7 @@ int status_get_input_mode (const hashcat_ctx_t *hashcat_ctx) char *status_get_input_base (const hashcat_ctx_t *hashcat_ctx); char *status_get_input_mod (const hashcat_ctx_t *hashcat_ctx); char *status_get_input_charset (const hashcat_ctx_t *hashcat_ctx); +int status_get_input_mask_length (const hashcat_ctx_t *hashcat_ctx); char *status_get_input_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx); char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx); diff --git a/include/types.h b/include/types.h index 433af2abe..aed4e6ab5 100644 --- a/include/types.h +++ b/include/types.h @@ -1568,9 +1568,11 @@ typedef struct { char *hash_target; char *hash_type; + int input_mode; char *input_base; char *input_charset; char *input_mod; + int input_mask_length; char *session; char *status_string; int status_number; @@ -1584,7 +1586,6 @@ typedef struct int digests_cnt; int digests_done; double digests_percent; - int input_mode; int salts_cnt; int salts_done; double salts_percent; diff --git a/src/hashcat.c b/src/hashcat.c index 6e5db2dc9..405b7f69c 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1182,6 +1182,7 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st hashcat_status->hash_type = status_get_hash_type (hashcat_ctx); hashcat_status->input_base = status_get_input_base (hashcat_ctx); hashcat_status->input_charset = status_get_input_charset (hashcat_ctx); + hashcat_status->input_mask_length = status_get_input_mask_length (hashcat_ctx); hashcat_status->input_mode = status_get_input_mode (hashcat_ctx); hashcat_status->input_mod = status_get_input_mod (hashcat_ctx); hashcat_status->msec_paused = status_get_msec_paused (hashcat_ctx); diff --git a/src/mpsp.c b/src/mpsp.c index e810e767a..231cc90df 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -30,22 +30,6 @@ static int sp_comp_val (const void *p1, const void *p2) return b2->val - b1->val; } -static u32 mp_get_length (char *mask) -{ - u32 len = 0; - - u32 mask_len = strlen (mask); - - for (u32 i = 0; i < mask_len; i++) - { - if (mask[i] == '?') i++; - - len++; - } - - return len; -} - static void mp_css_split_cnt (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_orig, u32 css_cnt_lr[2]) { const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; @@ -947,6 +931,22 @@ static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask) return 0; } +u32 mp_get_length (char *mask) +{ + u32 len = 0; + + u32 mask_len = strlen (mask); + + for (u32 i = 0; i < mask_len; i++) + { + if (mask[i] == '?') i++; + + len++; + } + + return len; +} + int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; diff --git a/src/status.c b/src/status.c index a43e01293..b0d4ad177 100644 --- a/src/status.c +++ b/src/status.c @@ -15,6 +15,7 @@ #include "hwmon.h" #include "outfile.h" #include "monitor.h" +#include "mpsp.h" #include "status.h" static const char ST_0000[] = "Initializing"; @@ -524,6 +525,17 @@ char *status_get_input_charset (const hashcat_ctx_t *hashcat_ctx) return NULL; } +int status_get_input_mask_length (const hashcat_ctx_t *hashcat_ctx) +{ + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + + if (mask_ctx == NULL) return -1; + + if (mask_ctx->mask == NULL) return -1; + + return mp_get_length (mask_ctx->mask); +} + char *status_get_input_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id) { const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; diff --git a/src/terminal.c b/src/terminal.c index 8256c5906..5482dbe4d 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -800,19 +800,21 @@ void status_display (hashcat_ctx_t *hashcat_ctx) case INPUT_MODE_MASK: event_log_info (hashcat_ctx, - "Input.Mask.....: %s", - hashcat_status->input_base); + "Input.Mask.....: %s [%d]", + hashcat_status->input_base, + hashcat_status->input_mask_length); break; case INPUT_MODE_MASK_CS: event_log_info (hashcat_ctx, - "Input.Mask.....: %s", - hashcat_status->input_base); + "Input.Mask.....: %s [%d]", + hashcat_status->input_base, + hashcat_status->input_mask_length); event_log_info (hashcat_ctx, - "Input.Charset..: %s", + "Input.Charset..: %s ", hashcat_status->input_charset); break;