1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-07 14:20:59 +00:00

Update dictstat.c function parameters

This commit is contained in:
jsteube 2016-10-06 16:55:17 +02:00
parent 14248d38e3
commit 3f05b7c0a7
4 changed files with 32 additions and 21 deletions

View File

@ -19,11 +19,11 @@
int sort_by_dictstat (const void *s1, const void *s2); int sort_by_dictstat (const void *s1, const void *s2);
void dictstat_init (dictstat_ctx_t *dictstat_ctx, const user_options_t *user_options, const folder_config_t *folder_config); void dictstat_init (hashcat_ctx_t *hashcat_ctx);
void dictstat_destroy (dictstat_ctx_t *dictstat_ctx); void dictstat_destroy (hashcat_ctx_t *hashcat_ctx);
void dictstat_read (dictstat_ctx_t *dictstat_ctx); void dictstat_read (hashcat_ctx_t *hashcat_ctx);
int dictstat_write (dictstat_ctx_t *dictstat_ctx); int dictstat_write (hashcat_ctx_t *hashcat_ctx);
u64 dictstat_find (dictstat_ctx_t *dictstat_ctx, dictstat_t *d); u64 dictstat_find (hashcat_ctx_t *hashcat_ctx, dictstat_t *d);
void dictstat_append (dictstat_ctx_t *dictstat_ctx, dictstat_t *d); void dictstat_append (hashcat_ctx_t *hashcat_ctx, dictstat_t *d);
#endif // _DICTSTAT_H #endif // _DICTSTAT_H

View File

@ -23,8 +23,12 @@ int sort_by_dictstat (const void *s1, const void *s2)
return memcmp (&d1->stat, &d2->stat, sizeof (struct stat)); return memcmp (&d1->stat, &d2->stat, sizeof (struct stat));
} }
void dictstat_init (dictstat_ctx_t *dictstat_ctx, const user_options_t *user_options, const folder_config_t *folder_config) void dictstat_init (hashcat_ctx_t *hashcat_ctx)
{ {
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
folder_config_t *folder_config = hashcat_ctx->folder_config;
user_options_t *user_options = hashcat_ctx->user_options;
dictstat_ctx->enabled = false; dictstat_ctx->enabled = false;
if (user_options->benchmark == true) return; if (user_options->benchmark == true) return;
@ -46,8 +50,10 @@ void dictstat_init (dictstat_ctx_t *dictstat_ctx, const user_options_t *user_opt
snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir); snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir);
} }
void dictstat_destroy (dictstat_ctx_t *dictstat_ctx) void dictstat_destroy (hashcat_ctx_t *hashcat_ctx)
{ {
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
if (dictstat_ctx->enabled == false) return; if (dictstat_ctx->enabled == false) return;
myfree (dictstat_ctx->filename); myfree (dictstat_ctx->filename);
@ -56,8 +62,10 @@ void dictstat_destroy (dictstat_ctx_t *dictstat_ctx)
memset (dictstat_ctx, 0, sizeof (dictstat_ctx_t)); memset (dictstat_ctx, 0, sizeof (dictstat_ctx_t));
} }
void dictstat_read (dictstat_ctx_t *dictstat_ctx) void dictstat_read (hashcat_ctx_t *hashcat_ctx)
{ {
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
if (dictstat_ctx->enabled == false) return; if (dictstat_ctx->enabled == false) return;
FILE *fp = fopen (dictstat_ctx->filename, "rb"); FILE *fp = fopen (dictstat_ctx->filename, "rb");
@ -90,8 +98,10 @@ void dictstat_read (dictstat_ctx_t *dictstat_ctx)
fclose (fp); fclose (fp);
} }
int dictstat_write (dictstat_ctx_t *dictstat_ctx) int dictstat_write (hashcat_ctx_t *hashcat_ctx)
{ {
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
if (dictstat_ctx->enabled == false) return 0; if (dictstat_ctx->enabled == false) return 0;
FILE *fp = fopen (dictstat_ctx->filename, "wb"); FILE *fp = fopen (dictstat_ctx->filename, "wb");
@ -110,8 +120,10 @@ int dictstat_write (dictstat_ctx_t *dictstat_ctx)
return 0; return 0;
} }
u64 dictstat_find (dictstat_ctx_t *dictstat_ctx, dictstat_t *d) u64 dictstat_find (hashcat_ctx_t *hashcat_ctx, dictstat_t *d)
{ {
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
if (dictstat_ctx->enabled == false) return 0; if (dictstat_ctx->enabled == false) return 0;
dictstat_t *d_cache = (dictstat_t *) lfind (d, dictstat_ctx->base, &dictstat_ctx->cnt, sizeof (dictstat_t), sort_by_dictstat); dictstat_t *d_cache = (dictstat_t *) lfind (d, dictstat_ctx->base, &dictstat_ctx->cnt, sizeof (dictstat_t), sort_by_dictstat);
@ -121,8 +133,10 @@ u64 dictstat_find (dictstat_ctx_t *dictstat_ctx, dictstat_t *d)
return d_cache->cnt; return d_cache->cnt;
} }
void dictstat_append (dictstat_ctx_t *dictstat_ctx, dictstat_t *d) void dictstat_append (hashcat_ctx_t *hashcat_ctx, dictstat_t *d)
{ {
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
if (dictstat_ctx->enabled == false) return; if (dictstat_ctx->enabled == false) return;
if (dictstat_ctx->cnt == MAX_DICTSTAT) if (dictstat_ctx->cnt == MAX_DICTSTAT)

View File

@ -1236,8 +1236,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
* main init * main init
*/ */
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
folder_config_t *folder_config = hashcat_ctx->folder_config;
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx; loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
@ -1342,9 +1340,9 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
* dictstat init * dictstat init
*/ */
dictstat_init (dictstat_ctx, user_options, folder_config); dictstat_init (hashcat_ctx);
dictstat_read (dictstat_ctx); dictstat_read (hashcat_ctx);
/** /**
* loopback init * loopback init
@ -1483,7 +1481,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
// final update dictionary cache // final update dictionary cache
dictstat_write (dictstat_ctx); dictstat_write (hashcat_ctx);
// free memory // free memory
@ -1493,7 +1491,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
loopback_destroy (loopback_ctx); loopback_destroy (loopback_ctx);
dictstat_destroy (dictstat_ctx); dictstat_destroy (hashcat_ctx);
potfile_destroy (hashcat_ctx); potfile_destroy (hashcat_ctx);

View File

@ -272,7 +272,6 @@ void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len
u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile) u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
{ {
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
user_options_t *user_options = hashcat_ctx->user_options; user_options_t *user_options = hashcat_ctx->user_options;
@ -306,7 +305,7 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
if (d.stat.st_size == 0) return 0; if (d.stat.st_size == 0) return 0;
const u64 cached_cnt = dictstat_find (dictstat_ctx, &d); const u64 cached_cnt = dictstat_find (hashcat_ctx, &d);
if (run_rule_engine (user_options_extra->rule_len_l, user_options->rule_buf_l) == 0) if (run_rule_engine (user_options_extra->rule_len_l, user_options->rule_buf_l) == 0)
{ {
@ -408,7 +407,7 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
if (user_options->quiet == false) log_info ("Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt); if (user_options->quiet == false) log_info ("Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt);
if (user_options->quiet == false) log_info (""); if (user_options->quiet == false) log_info ("");
dictstat_append (dictstat_ctx, &d); dictstat_append (hashcat_ctx, &d);
//hc_signal (sigHandler_default); //hc_signal (sigHandler_default);