From 1f266fb0f2ecfb4e1b94494f8f9b70acd020faf9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 3 Jan 2017 09:56:40 +0100 Subject: [PATCH] Added new event EVENT_WEAK_HASH_ALL_CRACKED if all hashes have been cracked during weak hash check --- docs/changes.txt | 1 + include/types.h | 1 + src/hashcat.c | 24 ++++++++++++++++++------ src/main.c | 11 +++++++++++ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 94f0308b4..2c0f98a7b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -36,6 +36,7 @@ - Building: Added hashcat32.dll and hashcat64.dll makefile targets for building hashcat windows libraries - Building: Removed access to readlink() on FreeBSD +- Events: Added new event EVENT_WEAK_HASH_ALL_CRACKED if all hashes have been cracked during weak hash check - Hardware management: Switched matching ADL device with OpenCL device by using PCI bus, device and function - Hardware management: Switched matching NvAPI device with OpenCL device by using PCI bus, device and function - Hardware management: Switched matching NVML device with OpenCL device by using PCI bus, device and function diff --git a/include/types.h b/include/types.h index 556d15cf0..2228282ac 100644 --- a/include/types.h +++ b/include/types.h @@ -126,6 +126,7 @@ typedef enum event_identifier EVENT_SET_KERNEL_POWER_FINAL = 0x000000c0, EVENT_WEAK_HASH_POST = 0x000000d0, EVENT_WEAK_HASH_PRE = 0x000000d1, + EVENT_WEAK_HASH_ALL_CRACKED = 0x000000d2, EVENT_WORDLIST_CACHE_GENERATE = 0x000000e0, EVENT_WORDLIST_CACHE_HIT = 0x000000e1, diff --git a/src/hashcat.c b/src/hashcat.c index cd08cfe64..db015c9f6 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -604,6 +604,13 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_OUTERLOOP_MAINSCREEN); + + /** + * Tell user about cracked hashes by potfile + */ + + EVENT (EVENT_POTFILE_NUM_CRACKED); + /** * inform the user */ @@ -653,6 +660,17 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) EVENT (EVENT_WEAK_HASH_POST); } + /** + * maybe all hashes were cracked now (as after potfile checks), we can exit here + */ + + if (status_ctx->devices_status == STATUS_CRACKED) + { + EVENT (EVENT_WEAK_HASH_ALL_CRACKED); + + return 0; + } + /** * status and monitor threads */ @@ -681,12 +699,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) } } - /** - * Tell user about cracked hashes by potfile - */ - - EVENT (EVENT_POTFILE_NUM_CRACKED); - // main call if (restore_ctx->rd) diff --git a/src/main.c b/src/main.c index a4ee26ba9..3c85e96f2 100644 --- a/src/main.c +++ b/src/main.c @@ -515,6 +515,16 @@ static void main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_ event_log_info_nn (hashcat_ctx, "Checked for weak hashes..."); } +static void main_weak_hash_all_cracked (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_info (hashcat_ctx, "INFO: All hashes found during weak hashes check! You can use --show to display them."); + event_log_info (hashcat_ctx, ""); +} + static void main_bitmap_init_pre (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; @@ -889,6 +899,7 @@ static void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, co case EVENT_SET_KERNEL_POWER_FINAL: main_set_kernel_power_final (hashcat_ctx, buf, len); break; case EVENT_WEAK_HASH_POST: main_weak_hash_post (hashcat_ctx, buf, len); break; case EVENT_WEAK_HASH_PRE: main_weak_hash_pre (hashcat_ctx, buf, len); break; + case EVENT_WEAK_HASH_ALL_CRACKED: main_weak_hash_all_cracked (hashcat_ctx, buf, len); break; case EVENT_WORDLIST_CACHE_GENERATE: main_wordlist_cache_generate (hashcat_ctx, buf, len); break; case EVENT_WORDLIST_CACHE_HIT: main_wordlist_cache_hit (hashcat_ctx, buf, len); break; }