mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 01:50:10 +00:00
Move event_log_info() out of wordlist.c
This commit is contained in:
parent
3b014dce28
commit
515107047b
@ -122,6 +122,8 @@ typedef enum event_identifier
|
||||
EVENT_MONITOR_TEMP_ABORT = 0x000000c1,
|
||||
EVENT_MONITOR_RUNTIME_LIMIT = 0x000000d1,
|
||||
EVENT_MONITOR_STATUS_REFRESH = 0x000000e1,
|
||||
EVENT_WORDLIST_CACHE_HIT = 0x000000f1,
|
||||
EVENT_WORDLIST_CACHE_GENERATE = 0x000000f2,
|
||||
|
||||
// there will be much more event types soon
|
||||
|
||||
@ -1444,6 +1446,29 @@ typedef struct hashcat_user
|
||||
|
||||
} hashcat_user_t;
|
||||
|
||||
typedef struct cache_hit
|
||||
{
|
||||
char *dictfile;
|
||||
|
||||
off_t st_size;
|
||||
|
||||
u64 cached_cnt;
|
||||
u64 keyspace;
|
||||
|
||||
} cache_hit_t;
|
||||
|
||||
typedef struct cache_generate
|
||||
{
|
||||
char *dictfile;
|
||||
|
||||
double percent;
|
||||
|
||||
u64 comp;
|
||||
u64 cnt;
|
||||
u64 cnt2;
|
||||
|
||||
} cache_generate_t;
|
||||
|
||||
typedef struct event_ctx
|
||||
{
|
||||
char msg_buf[HCBUFSIZ_TINY];
|
||||
|
34
src/main.c
34
src/main.c
@ -681,6 +681,38 @@ static void main_monitor_status_refresh (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx
|
||||
}
|
||||
}
|
||||
|
||||
static void main_wordlist_cache_hit (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;
|
||||
|
||||
cache_hit_t *cache_hit = (cache_hit_t *) buf;
|
||||
|
||||
event_log_info (hashcat_ctx, "Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", cache_hit->dictfile, cache_hit->st_size, cache_hit->cached_cnt, cache_hit->keyspace);
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
|
||||
|
||||
static void main_wordlist_cache_generate (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;
|
||||
|
||||
cache_generate_t *cache_generate = (cache_generate_t *) buf;
|
||||
|
||||
if (cache_generate->percent < 100)
|
||||
{
|
||||
event_log_info_nn (hashcat_ctx, "Generating dictionary stats for %s: %" PRIu64 " bytes (%.2f%%), %" PRIu64 " words, %" PRIu64 " keyspace", cache_generate->dictfile, cache_generate->comp, cache_generate->percent, cache_generate->cnt2, cache_generate->cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
event_log_info (hashcat_ctx, "Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", cache_generate->dictfile, cache_generate->comp, cache_generate->cnt2, cache_generate->cnt);
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
}
|
||||
|
||||
void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
switch (id)
|
||||
@ -716,6 +748,8 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz
|
||||
case EVENT_MONITOR_TEMP_ABORT: main_monitor_temp_abort (hashcat_ctx, buf, len); break;
|
||||
case EVENT_MONITOR_RUNTIME_LIMIT: main_monitor_runtime_limit (hashcat_ctx, buf, len); break;
|
||||
case EVENT_MONITOR_STATUS_REFRESH: main_monitor_status_refresh (hashcat_ctx, buf, len); break;
|
||||
case EVENT_WORDLIST_CACHE_HIT: main_wordlist_cache_hit (hashcat_ctx, buf, len); break;
|
||||
case EVENT_WORDLIST_CACHE_GENERATE: main_wordlist_cache_generate (hashcat_ctx, buf, len); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,10 +322,14 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
|
||||
keyspace *= combinator_ctx->combs_cnt;
|
||||
}
|
||||
|
||||
if (user_options->quiet == false) event_log_info (hashcat_ctx, "Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, d.stat.st_size, cached_cnt, keyspace);
|
||||
if (user_options->quiet == false) event_log_info (hashcat_ctx, "");
|
||||
cache_hit_t cache_hit;
|
||||
|
||||
//hc_signal (sigHandler_default);
|
||||
cache_hit.dictfile = (char *) dictfile;
|
||||
cache_hit.st_size = d.stat.st_size;
|
||||
cache_hit.cached_cnt = cached_cnt;
|
||||
cache_hit.keyspace = keyspace;
|
||||
|
||||
EVENT_DATA (EVENT_WORDLIST_CACHE_HIT, &cache_hit, sizeof (cache_hit));
|
||||
|
||||
return (keyspace);
|
||||
}
|
||||
@ -397,15 +401,30 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
|
||||
|
||||
if ((now - prev) == 0) continue;
|
||||
|
||||
double percent = (double) comp / (double) d.stat.st_size;
|
||||
double percent = ((double) comp / (double) d.stat.st_size) * 100;
|
||||
|
||||
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Generating dictionary stats for %s: %" PRIu64 " bytes (%.2f%%), %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, percent * 100, cnt2, cnt);
|
||||
cache_generate_t cache_generate;
|
||||
|
||||
cache_generate.dictfile = (char *) dictfile;
|
||||
cache_generate.comp = comp;
|
||||
cache_generate.percent = percent;
|
||||
cache_generate.cnt = cnt;
|
||||
cache_generate.cnt2 = cnt2;
|
||||
|
||||
EVENT_DATA (EVENT_WORDLIST_CACHE_GENERATE, &cache_generate, sizeof (cache_generate));
|
||||
|
||||
time (&prev);
|
||||
}
|
||||
|
||||
if (user_options->quiet == false) event_log_info (hashcat_ctx, "Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt);
|
||||
if (user_options->quiet == false) event_log_info (hashcat_ctx, "");
|
||||
cache_generate_t cache_generate;
|
||||
|
||||
cache_generate.dictfile = (char *) dictfile;
|
||||
cache_generate.comp = comp;
|
||||
cache_generate.percent = 100;
|
||||
cache_generate.cnt = cnt;
|
||||
cache_generate.cnt2 = cnt2;
|
||||
|
||||
EVENT_DATA (EVENT_WORDLIST_CACHE_GENERATE, &cache_generate, sizeof (cache_generate));
|
||||
|
||||
dictstat_append (hashcat_ctx, &d);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user