From 39d333d5512c789b8868485982dc1ca25f1e087e Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 6 Oct 2016 21:37:03 +0200 Subject: [PATCH] Add user_options_extra_amplifier() --- include/status.h | 2 -- include/user_options.h | 2 ++ src/hashcat.c | 25 +++++-------------------- src/status.c | 34 ---------------------------------- src/user_options.c | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 56 deletions(-) diff --git a/include/status.h b/include/status.h index 07a2f2c87..2799f5def 100644 --- a/include/status.h +++ b/include/status.h @@ -12,8 +12,6 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries); -u64 status_words_base_calculate (hashcat_ctx_t *hashcat_ctx, const u64 words_cnt); - void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx); void status_display (hashcat_ctx_t *hashcat_ctx); void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx); diff --git a/include/user_options.h b/include/user_options.h index 04ed4bd00..da54d7d49 100644 --- a/include/user_options.h +++ b/include/user_options.h @@ -170,6 +170,8 @@ void user_options_extra_init (hashcat_ctx_t *hashcat_ctx); void user_options_extra_destroy (hashcat_ctx_t *hashcat_ctx); +u64 user_options_extra_amplifier (hashcat_ctx_t *hashcat_ctx); + void user_options_logger (hashcat_ctx_t *hashcat_ctx); #endif // _USER_OPTIONS_H diff --git a/src/hashcat.c b/src/hashcat.c index cc1372f6c..611eaba17 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -296,7 +296,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) // words_base - status_ctx->words_base = status_words_base_calculate (hashcat_ctx, status_ctx->words_cnt); + status_ctx->words_base = status_ctx->words_cnt / user_options_extra_amplifier (hashcat_ctx); if (user_options->keyspace == true) { @@ -314,26 +314,11 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) if (status_ctx->words_cur) { - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) - { - for (u32 i = 0; i < hashes->salts_cnt; i++) - { - status_ctx->words_progress_restored[i] = status_ctx->words_cur * straight_ctx->kernel_rules_cnt; - } - } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) - { - for (u32 i = 0; i < hashes->salts_cnt; i++) - { - status_ctx->words_progress_restored[i] = status_ctx->words_cur * combinator_ctx->combs_cnt; - } - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + const u64 progress_restored = status_ctx->words_cur * user_options_extra_amplifier (hashcat_ctx); + + for (u32 i = 0; i < hashes->salts_cnt; i++) { - for (u32 i = 0; i < hashes->salts_cnt; i++) - { - status_ctx->words_progress_restored[i] = status_ctx->words_cur * mask_ctx->bfs_cnt; - } + status_ctx->words_progress_restored[i] = progress_restored; } } diff --git a/src/status.c b/src/status.c index dec1e7fd0..aed13408d 100644 --- a/src/status.c +++ b/src/status.c @@ -146,40 +146,6 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en return exec_ms_sum / exec_ms_cnt; } -u64 status_words_base_calculate (hashcat_ctx_t *hashcat_ctx, const u64 words_cnt) -{ - const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - - u64 words_base = words_cnt; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) - { - if (straight_ctx->kernel_rules_cnt) - { - words_base /= straight_ctx->kernel_rules_cnt; - } - } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) - { - if (combinator_ctx->combs_cnt) - { - words_base /= combinator_ctx->combs_cnt; - } - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - if (mask_ctx->bfs_cnt) - { - words_base /= mask_ctx->bfs_cnt; - } - } - - return words_base; -} - void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; diff --git a/src/user_options.c b/src/user_options.c index 09da243f2..b97775aef 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1159,6 +1159,38 @@ void user_options_extra_destroy (hashcat_ctx_t *hashcat_ctx) memset (user_options_extra, 0, sizeof (user_options_extra_t)); } +u64 user_options_extra_amplifier (hashcat_ctx_t *hashcat_ctx) +{ + const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + if (straight_ctx->kernel_rules_cnt) + { + return straight_ctx->kernel_rules_cnt; + } + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + if (combinator_ctx->combs_cnt) + { + return combinator_ctx->combs_cnt; + } + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + if (mask_ctx->bfs_cnt) + { + return mask_ctx->bfs_cnt; + } + } + + return 1; +} + void user_options_logger (hashcat_ctx_t *hashcat_ctx) { user_options_t *user_options = hashcat_ctx->user_options;