From 344ea5b36df88a767434b2bd8baffe74f91ba173 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sun, 4 Nov 2018 10:07:45 +0100 Subject: [PATCH] Memory: Reduced default maximum bitmap size from 24 to 18 and give a notice to use --bitmap-max to restore --- docs/changes.txt | 4 +++- include/types.h | 3 ++- src/bitmap.c | 6 ++++++ src/main.c | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index efb90d599..5499c6f61 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -20,8 +20,10 @@ ## Improvements ## +- Memory: Reduced default maximum bitmap size from 24 to 18 and give a notice to use --bitmap-max to restore - Memory: Limit maximum host memory to allocate depending on bitness -- Tests: Added hash-modes 11700 (Streebog-256) and 11800 (Streebog-512) +- Tests: Added hash-mode 11700 (Streebog-256) +- Tests: Added hash-mode 11800 (Streebog-512) - Tests: Added hash-mode 11850 (HMAC-Streebog-512 (key = $pass), big-endian) ## diff --git a/include/types.h b/include/types.h index d6c279026..b31dae5e4 100644 --- a/include/types.h +++ b/include/types.h @@ -92,6 +92,7 @@ typedef enum event_identifier EVENT_AUTOTUNE_STARTING = 0x00000001, EVENT_BITMAP_INIT_POST = 0x00000010, EVENT_BITMAP_INIT_PRE = 0x00000011, + EVENT_BITMAP_FINAL_OVERFLOW = 0x00000012, EVENT_CALCULATED_WORDS_BASE = 0x00000020, EVENT_CRACKER_FINISHED = 0x00000030, EVENT_CRACKER_HASH_CRACKED = 0x00000031, @@ -534,7 +535,7 @@ typedef enum user_options_defaults ATTACK_MODE = ATTACK_MODE_STRAIGHT, BENCHMARK_ALL = false, BENCHMARK = false, - BITMAP_MAX = 24, + BITMAP_MAX = 18, BITMAP_MIN = 16, #ifdef WITH_BRAIN BRAIN_CLIENT = false, diff --git a/src/bitmap.c b/src/bitmap.c index ac6e62cb9..3a8ec3475 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -7,6 +7,7 @@ #include "types.h" #include "memory.h" #include "bitmap.h" +#include "event.h" static void selftest_to_bitmap (const u32 dgst_shifts, char *digests_buf_ptr, const u32 dgst_pos0, const u32 dgst_pos1, const u32 dgst_pos2, const u32 dgst_pos3, const u32 bitmap_mask, u32 *bitmap_a, u32 *bitmap_b, u32 *bitmap_c, u32 *bitmap_d) { @@ -128,6 +129,11 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) break; } + if (bitmap_bits == bitmap_max) + { + EVENT_DATA (EVENT_BITMAP_FINAL_OVERFLOW, NULL, 0); + } + bitmap_nums = 1u << bitmap_bits; bitmap_mask = bitmap_nums - 1; diff --git a/src/main.c b/src/main.c index c79e17a4e..8923067e2 100644 --- a/src/main.c +++ b/src/main.c @@ -580,6 +580,20 @@ static void main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB event_log_info_nn (hashcat_ctx, "Generated bitmap tables..."); } +static void main_bitmap_final_overflow (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) +{ + const user_options_t *user_options = hashcat_ctx->user_options; + + if (user_options->quiet == true) return; + + event_log_advice (hashcat_ctx, "Bitmap table overflowed at %d bits.", user_options->bitmap_max); + event_log_advice (hashcat_ctx, "This typically happens with too many hashes and reduces your performance."); + event_log_advice (hashcat_ctx, "You can increase the bitmap table size with --bitmap-max, but"); + event_log_advice (hashcat_ctx, "this creates a trade-off between L2-cache and bitmap efficiency."); + event_log_advice (hashcat_ctx, "It is therefore not guaranteed to restore full performance."); + event_log_advice (hashcat_ctx, NULL); +} + static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -954,6 +968,7 @@ static void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, co { case EVENT_BITMAP_INIT_POST: main_bitmap_init_post (hashcat_ctx, buf, len); break; case EVENT_BITMAP_INIT_PRE: main_bitmap_init_pre (hashcat_ctx, buf, len); break; + case EVENT_BITMAP_FINAL_OVERFLOW: main_bitmap_final_overflow (hashcat_ctx, buf, len); break; case EVENT_CALCULATED_WORDS_BASE: main_calculated_words_base (hashcat_ctx, buf, len); break; case EVENT_CRACKER_FINISHED: main_cracker_finished (hashcat_ctx, buf, len); break; case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break;