From 779662ea23122ee3129024ec94bdcc405f0a4118 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 9 Nov 2016 02:02:11 +0100 Subject: [PATCH] Fixed a bug when cracking a large salted hashlist: If a word is rejected this produces so high CPU load that cracking process doesn't start --- docs/changes.txt | 1 + src/dispatch.c | 57 ++++++++++++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index c067dc023..d059bb1e6 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -17,6 +17,7 @@ - Status display shows what's the base and modifier keyspace currently in use - Added a workaround for some OpenCL kernel to compile with amd-gpu-pro - Added option --keep-guessing to continue cracking hashes even after they have been cracked (to find collisions) +- Fixed a bug when cracking a large salted hashlist: If a word is rejected this produces so high CPU load that cracking process doesn't start ## ## Algorithms diff --git a/src/dispatch.c b/src/dispatch.c index 1fb7a22c4..857bb39b0 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -154,6 +154,8 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par break; } + u32 words_extra = 0; + u32 words_buffered = 0; while (words_buffered < device_param->kernel_power) @@ -196,14 +198,7 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par { if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) { - hc_thread_mutex_lock (status_ctx->mux_counter); - - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) - { - status_ctx->words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt; - } - - hc_thread_mutex_unlock (status_ctx->mux_counter); + words_extra++; continue; } @@ -220,6 +215,18 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par while (status_ctx->run_thread_level1 == false) break; + if (words_extra > 0) + { + hc_thread_mutex_lock (status_ctx->mux_counter); + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + status_ctx->words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt; + } + + hc_thread_mutex_unlock (status_ctx->mux_counter); + } + // flush const u32 pws_cnt = device_param->pws_cnt; @@ -457,6 +464,8 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) u32 words_extra = -1u; + u32 words_extra_total = 0; + while (words_extra) { const u32 work = get_work (hashcat_ctx, device_param, words_extra); @@ -504,15 +513,6 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { words_extra++; - hc_thread_mutex_lock (status_ctx->mux_counter); - - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) - { - status_ctx->words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt; - } - - hc_thread_mutex_unlock (status_ctx->mux_counter); - continue; } } @@ -525,15 +525,6 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) { words_extra++; - hc_thread_mutex_lock (status_ctx->mux_counter); - - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) - { - status_ctx->words_progress_rejected[salt_pos] += combinator_ctx->combs_cnt; - } - - hc_thread_mutex_unlock (status_ctx->mux_counter); - continue; } } @@ -543,11 +534,25 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) if (status_ctx->run_thread_level1 == false) break; } + words_extra_total += words_extra; + if (status_ctx->run_thread_level1 == false) break; } if (status_ctx->run_thread_level1 == false) break; + if (words_extra_total > 0) + { + hc_thread_mutex_lock (status_ctx->mux_counter); + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt; + } + + hc_thread_mutex_unlock (status_ctx->mux_counter); + } + // // flush //