From ef33544bfa600c85758e400a1938341d523a4e77 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 23 May 2017 10:07:04 +0200 Subject: [PATCH] Show time spent for dictionary cache building on startup --- docs/changes.txt | 1 + include/types.h | 2 ++ src/main.c | 17 +++++++++++++++++ src/wordlist.c | 9 +++++++++ 4 files changed, 29 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 6353f4c5a..25b20eb40 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -19,6 +19,7 @@ - Rules: Support added for position 'p' in host mode (using -j or -k) - 7-Zip cracking: increased max. data length to 320k and removed AES padding attack to avoid false negatives - Rules: Support added for rejection rule '_N' in host mode +- Dictionary cache: Show time spent for dictionary cache building on startup ## ## Workarounds diff --git a/include/types.h b/include/types.h index 857119323..da3257f87 100644 --- a/include/types.h +++ b/include/types.h @@ -1866,6 +1866,8 @@ typedef struct cache_generate u64 cnt; u64 cnt2; + time_t runtime; + } cache_generate_t; typedef struct hashlist_parse diff --git a/src/main.c b/src/main.c index 10a8dd6c0..a20bfe7fd 100644 --- a/src/main.c +++ b/src/main.c @@ -783,12 +783,29 @@ static void main_wordlist_cache_generate (MAYBE_UNUSED hashcat_ctx_t *hashcat_ct } else { + char *runtime = (char *) malloc (HCBUFSIZ_TINY); + + struct tm *tmp; + + #if defined (_WIN) + tmp = _gmtime64 (&cache_generate->runtime); + #else + struct tm tm; + + tmp = gmtime_r (&cache_generate->runtime, &tm); + #endif + + format_timer_display (tmp, runtime, HCBUFSIZ_TINY); + event_log_info (hashcat_ctx, "Dictionary cache built:"); event_log_info (hashcat_ctx, "* Filename..: %s", cache_generate->dictfile); event_log_info (hashcat_ctx, "* Passwords.: %" PRIu64, cache_generate->cnt2); event_log_info (hashcat_ctx, "* Bytes.....: %" PRId64, cache_generate->comp); event_log_info (hashcat_ctx, "* Keyspace..: %" PRIu64, cache_generate->cnt); + event_log_info (hashcat_ctx, "* Runtime...: %s", runtime); event_log_info (hashcat_ctx, NULL); + + hcfree (runtime); } } diff --git a/src/wordlist.c b/src/wordlist.c index bbb70fc97..f814bad23 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -359,6 +359,10 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 } } + time_t rt_start; + + time (&rt_start); + time_t now = 0; time_t prev = 0; @@ -471,6 +475,10 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 } } + time_t rt_stop; + + time (&rt_stop); + cache_generate_t cache_generate; cache_generate.dictfile = (char *) dictfile; @@ -478,6 +486,7 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64 cache_generate.percent = 100; cache_generate.cnt = cnt; cache_generate.cnt2 = cnt2; + cache_generate.runtime = rt_stop - rt_start; EVENT_DATA (EVENT_WORDLIST_CACHE_GENERATE, &cache_generate, sizeof (cache_generate));