From 574acfab6ab9656d752c94c7195a5741646dad0a Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Oct 2016 22:14:54 +0200 Subject: [PATCH] Move masks_pos from rd* to masks_ctx and dicts_pot from rd* to straight_ctx --- src/dispatch.c | 14 ++++++++---- src/hashcat.c | 60 ++++++++++++++++++++++++++++++++------------------ src/restore.c | 8 +++++-- 3 files changed, 55 insertions(+), 27 deletions(-) diff --git a/src/dispatch.c b/src/dispatch.c index eee6448b3..206ae6481 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -332,9 +332,12 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (user_options->speed_only == true) break; - device_param->words_done = words_fin; + if (status_ctx->run_thread_level2 == true) + { + device_param->words_done = words_fin; - status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + } if (status_ctx->run_thread_level1 == false) break; } @@ -579,9 +582,12 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (user_options->speed_only == true) break; - device_param->words_done = words_fin; + if (status_ctx->run_thread_level2 == true) + { + device_param->words_done = words_fin; - status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + } if (status_ctx->run_thread_level1 == false) break; diff --git a/src/hashcat.c b/src/hashcat.c index c52813a85..3b0fc6e93 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -85,19 +85,22 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->words_off = 0; status_ctx->words_cur = 0; - restore_data_t *rd = restore_ctx->rd; - - if (rd->words_cur) + if (restore_ctx->rd) { - status_ctx->words_off = rd->words_cur; - status_ctx->words_cur = status_ctx->words_off; + restore_data_t *rd = restore_ctx->rd; + + if (rd->words_cur > 0) + { + status_ctx->words_off = rd->words_cur; + status_ctx->words_cur = status_ctx->words_off; - rd->words_cur = 0; + rd->words_cur = 0; - user_options->skip = 0; + user_options->skip = 0; + } } - if (user_options->skip) + if (user_options->skip > 0) { status_ctx->words_off = user_options->skip; status_ctx->words_cur = status_ctx->words_off; @@ -325,14 +328,22 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_INNERLOOP2_STARTING); - restore_data_t *rd = restore_ctx->rd; + if (restore_ctx->rd) + { + restore_data_t *rd = restore_ctx->rd; + + if (rd->dicts_pos > 0) + { + straight_ctx->dicts_pos = rd->dicts_pos; + + rd->dicts_pos = 0; + } + } if (straight_ctx->dicts_cnt) { - for (u32 dicts_pos = rd->dicts_pos; dicts_pos < straight_ctx->dicts_cnt; dicts_pos++) + for (u32 dicts_pos = straight_ctx->dicts_pos; dicts_pos < straight_ctx->dicts_cnt; dicts_pos++) { - rd->dicts_pos = dicts_pos; - straight_ctx->dicts_pos = dicts_pos; const int rc_inner2_loop = inner2_loop (hashcat_ctx); @@ -341,6 +352,8 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->run_main_level3 == false) break; } + + if (straight_ctx->dicts_pos == straight_ctx->dicts_cnt) straight_ctx->dicts_pos = 0; } else { @@ -670,21 +683,24 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) // main call - EVENT (EVENT_INNERLOOP1_STARTING); - - if (mask_ctx->masks_cnt) + if (restore_ctx->rd) { restore_data_t *rd = restore_ctx->rd; - for (u32 masks_pos = rd->masks_pos; masks_pos < mask_ctx->masks_cnt; masks_pos++) + if (rd->masks_pos > 0) { - if (masks_pos > rd->masks_pos) - { - rd->dicts_pos = 0; - } + mask_ctx->masks_pos = rd->masks_pos; + + rd->masks_pos = 0; + } + } - rd->masks_pos = masks_pos; + EVENT (EVENT_INNERLOOP1_STARTING); + if (mask_ctx->masks_cnt) + { + for (u32 masks_pos = mask_ctx->masks_pos; masks_pos < mask_ctx->masks_cnt; masks_pos++) + { mask_ctx->masks_pos = masks_pos; const int rc_inner1_loop = inner1_loop (hashcat_ctx); @@ -693,6 +709,8 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->run_main_level2 == false) break; } + + if (mask_ctx->masks_pos == mask_ctx->masks_cnt) mask_ctx->masks_pos = 0; } else { diff --git a/src/restore.c b/src/restore.c index 412b5fe03..9ab30baed 100644 --- a/src/restore.c +++ b/src/restore.c @@ -221,13 +221,17 @@ static int read_restore (hashcat_ctx_t *hashcat_ctx) static int write_restore (hashcat_ctx_t *hashcat_ctx) { - restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; if (restore_ctx->enabled == false) return 0; restore_data_t *rd = restore_ctx->rd; + rd->masks_pos = mask_ctx->masks_pos; + rd->dicts_pos = straight_ctx->dicts_pos; rd->words_cur = status_ctx->words_cur; char *new_restore_file = restore_ctx->new_restore_file;