1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 22:58:30 +00:00

Move event_log_info() out of hashes.c

This commit is contained in:
jsteube 2016-10-23 14:49:40 +02:00
parent 14bd614bfc
commit 1c055a6311
5 changed files with 161 additions and 19 deletions

View File

@ -124,6 +124,15 @@ typedef enum event_identifier
EVENT_MONITOR_STATUS_REFRESH = 0x000000e1,
EVENT_WORDLIST_CACHE_HIT = 0x000000f1,
EVENT_WORDLIST_CACHE_GENERATE = 0x000000f2,
EVENT_HASHLIST_COUNT_LINES_PRE = 0x00000101,
EVENT_HASHLIST_COUNT_LINES_POST = 0x00000102,
EVENT_HASHLIST_PARSE_HASH = 0x00000103,
EVENT_HASHLIST_SORT_HASH_PRE = 0x00000104,
EVENT_HASHLIST_SORT_HASH_POST = 0x00000105,
EVENT_HASHLIST_UNIQUE_HASH_PRE = 0x00000106,
EVENT_HASHLIST_UNIQUE_HASH_POST = 0x00000107,
EVENT_HASHLIST_SORT_SALT_PRE = 0x00000108,
EVENT_HASHLIST_SORT_SALT_POST = 0x00000109,
// there will be much more event types soon
@ -1469,6 +1478,13 @@ typedef struct cache_generate
} cache_generate_t;
typedef struct hashlist_parse
{
u32 hashes_cnt;
u32 hashes_avail;
} hashlist_parse_t;
typedef struct event_ctx
{
char msg_buf[HCBUFSIZ_TINY];

View File

@ -322,8 +322,8 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
if (num_cracked)
{
// display hack (for weak hashes etc, it could be that there is still something to clear on the current line)
event_log_info_nn (hashcat_ctx, "");
// still needed?
//event_log_info_nn (hashcat_ctx, "");
plain_t *cracked = (plain_t *) hccalloc (hashcat_ctx, num_cracked, sizeof (plain_t)); VERIFY_PTR (cracked);
@ -494,10 +494,12 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
return -1;
}
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Counting lines in %s", hashfile);
EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_PRE, hashfile, sizeof (hashfile));
hashes_avail = count_lines (hashcat_ctx, fp);
EVENT_DATA (EVENT_HASHLIST_COUNT_LINES_POST, hashfile, sizeof (hashfile));
rewind (fp);
if (hashes_avail == 0)
@ -807,6 +809,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
time_t prev = 0;
time_t now = 0;
while (!feof (fp))
{
line_num++;
@ -893,8 +898,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
continue;
}
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
hashes_cnt++;
}
else
@ -908,8 +911,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
continue;
}
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
hashes_cnt++;
}
}
@ -924,17 +925,33 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
continue;
}
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
hashes_cnt++;
}
time (&now);
if ((now - prev) == 0) continue;
time (&prev);
hashlist_parse_t hashlist_parse;
hashlist_parse.hashes_cnt = hashes_cnt;
hashlist_parse.hashes_avail = hashes_avail;
EVENT_DATA (EVENT_HASHLIST_PARSE_HASH, &hashlist_parse, sizeof (hashlist_parse));
}
hashlist_parse_t hashlist_parse;
hashlist_parse.hashes_cnt = hashes_cnt;
hashlist_parse.hashes_avail = hashes_avail;
EVENT_DATA (EVENT_HASHLIST_PARSE_HASH, &hashlist_parse, sizeof (hashlist_parse));
hcfree (line_buf);
fclose (fp);
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
}
}
@ -942,7 +959,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if (hashes_cnt)
{
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Sorting Hashes...");
EVENT (EVENT_HASHLIST_SORT_HASH_PRE);
if (hashconfig->is_salted)
{
@ -953,7 +970,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
hc_qsort_r (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt, (void *) hashconfig);
}
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Sorted Hashes...");
EVENT (EVENT_HASHLIST_SORT_HASH_POST);
}
return 0;
@ -972,7 +989,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
* Remove duplicates
*/
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Removing duplicate hashes...");
EVENT (EVENT_HASHLIST_UNIQUE_HASH_PRE);
u32 hashes_cnt_new = 1;
@ -1008,6 +1025,8 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
hashes->hashes_cnt = hashes_cnt;
EVENT (EVENT_HASHLIST_UNIQUE_HASH_POST);
/**
* Now generate all the buffers required for later
*/
@ -1030,7 +1049,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
salts_buf_new = (salt_t *) hccalloc (hashcat_ctx, 1, sizeof (salt_t)); VERIFY_PTR (salts_buf_new);
}
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Structuring salts for cracking task...");
EVENT (EVENT_HASHLIST_SORT_SALT_PRE);
u32 digests_cnt = hashes_cnt;
u32 digests_done = 0;
@ -1147,6 +1166,8 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
}
}
EVENT (EVENT_HASHLIST_SORT_SALT_POST);
hcfree (hashes->digests_buf);
hcfree (hashes->salts_buf);
hcfree (hashes->esalts_buf);

View File

@ -3302,7 +3302,7 @@ void hwmon_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
if ((hm_ADL_Overdrive_State_Set (hashcat_ctx, hwmon_ctx->hm_device[device_id].adl, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) == -1)
{
//event_log_info (hashcat_ctx, "Failed to restore ADL performance state");
//event_log_error (hashcat_ctx, "Failed to restore ADL performance state");
continue;
}

View File

@ -693,7 +693,6 @@ static void main_wordlist_cache_hit (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA
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;
@ -713,6 +712,103 @@ static void main_wordlist_cache_generate (MAYBE_UNUSED hashcat_ctx_t *hashcat_ct
}
}
static void main_hashlist_count_lines_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;
if (user_options->quiet == true) return;
char *hashfile = (char *) buf;
event_log_info_nn (hashcat_ctx, "Counting lines in %s...", hashfile);
}
static void main_hashlist_count_lines_post (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;
char *hashfile = (char *) buf;
event_log_info_nn (hashcat_ctx, "Counted lines in %s...", hashfile);
}
static void main_hashlist_parse_hash (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;
hashlist_parse_t *hashlist_parse = (hashlist_parse_t *) buf;
const u32 hashes_cnt = hashlist_parse->hashes_cnt;
const u32 hashes_avail = hashlist_parse->hashes_avail;
if (hashes_cnt < hashes_avail)
{
event_log_info_nn (hashcat_ctx, "Parsing Hashes: %u/%u (%0.2f%%)...", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
}
else
{
event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, 100);
}
}
static void main_hashlist_sort_hash_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;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Sorting hashes...");
}
static void main_hashlist_sort_hash_post (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_nn (hashcat_ctx, "Sorted hashes...");
}
static void main_hashlist_unique_hash_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;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Removing duplicate hashes...");
}
static void main_hashlist_unique_hash_post (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_nn (hashcat_ctx, "Removed duplicate hashes...");
}
static void main_hashlist_sort_salt_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;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Sorting salts...");
}
static void main_hashlist_sort_salt_post (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_nn (hashcat_ctx, "Sorted salts...");
}
void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
{
switch (id)
@ -750,6 +846,15 @@ void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const siz
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;
case EVENT_HASHLIST_COUNT_LINES_PRE: main_hashlist_count_lines_pre (hashcat_ctx, buf, len); break;
case EVENT_HASHLIST_COUNT_LINES_POST: main_hashlist_count_lines_post (hashcat_ctx, buf, len); break;
case EVENT_HASHLIST_PARSE_HASH: main_hashlist_parse_hash (hashcat_ctx, buf, len); break;
case EVENT_HASHLIST_SORT_HASH_PRE: main_hashlist_sort_hash_pre (hashcat_ctx, buf, len); break;
case EVENT_HASHLIST_SORT_HASH_POST: main_hashlist_sort_hash_post (hashcat_ctx, buf, len); break;
case EVENT_HASHLIST_UNIQUE_HASH_PRE: main_hashlist_unique_hash_pre (hashcat_ctx, buf, len); break;
case EVENT_HASHLIST_UNIQUE_HASH_POST: main_hashlist_unique_hash_post (hashcat_ctx, buf, len); break;
case EVENT_HASHLIST_SORT_SALT_PRE: main_hashlist_sort_salt_pre (hashcat_ctx, buf, len); break;
case EVENT_HASHLIST_SORT_SALT_POST: main_hashlist_sort_salt_post (hashcat_ctx, buf, len); break;
}
}

View File

@ -401,6 +401,8 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
if ((now - prev) == 0) continue;
time (&prev);
double percent = ((double) comp / (double) d.stat.st_size) * 100;
cache_generate_t cache_generate;
@ -412,8 +414,6 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
cache_generate.cnt2 = cnt2;
EVENT_DATA (EVENT_WORDLIST_CACHE_GENERATE, &cache_generate, sizeof (cache_generate));
time (&prev);
}
cache_generate_t cache_generate;