diff --git a/include/logfile.h b/include/logfile.h index c40aea6b5..b286c6e4b 100644 --- a/include/logfile.h +++ b/include/logfile.h @@ -13,16 +13,16 @@ // logfile_append() checks for logfile_disable internally to make it easier from here -#define logfile_top_msg(msg) logfile_append (logfile_ctx, "%s\t%s", logfile_ctx->topid, (msg)); -#define logfile_sub_msg(msg) logfile_append (logfile_ctx, "%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (msg)); -#define logfile_top_var_uint64(var,val) logfile_append (logfile_ctx, "%s\t%s\t%" PRIu64 "", logfile_ctx->topid, (var), (val)); -#define logfile_sub_var_uint64(var,val) logfile_append (logfile_ctx, "%s\t%s\t%s\t%" PRIu64 "", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); -#define logfile_top_var_uint(var,val) logfile_append (logfile_ctx, "%s\t%s\t%u", logfile_ctx->topid, (var), (val)); -#define logfile_sub_var_uint(var,val) logfile_append (logfile_ctx, "%s\t%s\t%s\t%u", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); -#define logfile_top_var_char(var,val) logfile_append (logfile_ctx, "%s\t%s\t%c", logfile_ctx->topid, (var), (val)); -#define logfile_sub_var_char(var,val) logfile_append (logfile_ctx, "%s\t%s\t%s\t%c", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); -#define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append (logfile_ctx, "%s\t%s\t%s", logfile_ctx->topid, (var), (val)); -#define logfile_sub_var_string(var,val) if ((val) != NULL) logfile_append (logfile_ctx, "%s\t%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); +#define logfile_top_msg(msg) logfile_append (hashcat_ctx, "%s\t%s", logfile_ctx->topid, (msg)); +#define logfile_sub_msg(msg) logfile_append (hashcat_ctx, "%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (msg)); +#define logfile_top_var_uint64(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%" PRIu64 "", logfile_ctx->topid, (var), (val)); +#define logfile_sub_var_uint64(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%" PRIu64 "", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); +#define logfile_top_var_uint(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%u", logfile_ctx->topid, (var), (val)); +#define logfile_sub_var_uint(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%u", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); +#define logfile_top_var_char(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%c", logfile_ctx->topid, (var), (val)); +#define logfile_sub_var_char(var,val) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%c", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); +#define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append (hashcat_ctx, "%s\t%s\t%s", logfile_ctx->topid, (var), (val)); +#define logfile_sub_var_string(var,val) if ((val) != NULL) logfile_append (hashcat_ctx, "%s\t%s\t%s\t%s", logfile_ctx->topid, logfile_ctx->subid, (var), (val)); #define logfile_top_uint(var) logfile_top_var_uint (#var, (var)); #define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var)); @@ -33,12 +33,10 @@ #define logfile_top_string(var) logfile_top_var_string (#var, (var)); #define logfile_sub_string(var) logfile_sub_var_string (#var, (var)); -void logfile_generate_topid (logfile_ctx_t *logfile_ctx); -void logfile_generate_subid (logfile_ctx_t *logfile_ctx); - -void logfile_append (const logfile_ctx_t *logfile_ctx, const char *fmt, ...); - -void logfile_init (logfile_ctx_t *logfile_ctx, const user_options_t *user_options, const folder_config_t *folder_config); -void logfile_destroy (logfile_ctx_t *logfile_ctx); +void logfile_generate_topid (hashcat_ctx_t *hashcat_ctx); +void logfile_generate_subid (hashcat_ctx_t *hashcat_ctx); +void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...); +void logfile_init (hashcat_ctx_t *hashcat_ctx); +void logfile_destroy (hashcat_ctx_t *hashcat_ctx); #endif // _LOGFILE_H diff --git a/include/user_options.h b/include/user_options.h index b87c36c29..78ff4560b 100644 --- a/include/user_options.h +++ b/include/user_options.h @@ -170,6 +170,6 @@ void user_options_extra_init (const user_options_t *user_options, user_options_e void user_options_extra_destroy (user_options_extra_t *user_options_extra); -void user_options_logger (const user_options_t *user_options, const logfile_ctx_t *logfile_ctx); +void user_options_logger (hashcat_ctx_t *hashcat_ctx); #endif // _USER_OPTIONS_H diff --git a/src/hashcat.c b/src/hashcat.c index 21b81620e..c686bde62 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -137,7 +137,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) status_ctx->devices_status = STATUS_INIT; - logfile_generate_subid (logfile_ctx); + logfile_generate_subid (hashcat_ctx); logfile_sub_msg ("START"); @@ -1288,13 +1288,13 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold * logfile init */ - logfile_init (logfile_ctx, user_options, folder_config); + logfile_init (hashcat_ctx); - logfile_generate_topid (logfile_ctx); + logfile_generate_topid (hashcat_ctx); logfile_top_msg ("START"); - user_options_logger (user_options, logfile_ctx); + user_options_logger (hashcat_ctx); /** * tuning db @@ -1526,7 +1526,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold logfile_top_msg ("STOP"); - logfile_destroy (logfile_ctx); + logfile_destroy (hashcat_ctx); user_options_destroy (user_options); diff --git a/src/logfile.c b/src/logfile.c index 94a5a3fce..0223589bb 100644 --- a/src/logfile.c +++ b/src/logfile.c @@ -23,8 +23,10 @@ static int logfile_generate_id () return t + n; } -void logfile_generate_topid (logfile_ctx_t *logfile_ctx) +void logfile_generate_topid (hashcat_ctx_t *hashcat_ctx) { + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + if (logfile_ctx->enabled == false) return; const int id = logfile_generate_id (); @@ -32,8 +34,10 @@ void logfile_generate_topid (logfile_ctx_t *logfile_ctx) snprintf (logfile_ctx->topid, 1 + 16, "TOP%08x", id); } -void logfile_generate_subid (logfile_ctx_t *logfile_ctx) +void logfile_generate_subid (hashcat_ctx_t *hashcat_ctx) { + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + if (logfile_ctx->enabled == false) return; const int id = logfile_generate_id (); @@ -41,8 +45,10 @@ void logfile_generate_subid (logfile_ctx_t *logfile_ctx) snprintf (logfile_ctx->subid, 1 + 16, "SUB%08x", id); } -void logfile_append (const logfile_ctx_t *logfile_ctx, const char *fmt, ...) +void logfile_append (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...) { + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + if (logfile_ctx->enabled == false) return; FILE *fp = fopen (logfile_ctx->logfile, "ab"); @@ -62,8 +68,12 @@ void logfile_append (const logfile_ctx_t *logfile_ctx, const char *fmt, ...) fclose (fp); } -void logfile_init (logfile_ctx_t *logfile_ctx, const user_options_t *user_options, const folder_config_t *folder_config) +void logfile_init (hashcat_ctx_t *hashcat_ctx) { + folder_config_t *folder_config = hashcat_ctx->folder_config; + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + if (user_options->logfile_disable == true) return; logfile_ctx->logfile = (char *) mymalloc (HCBUFSIZ_TINY); @@ -76,8 +86,10 @@ void logfile_init (logfile_ctx_t *logfile_ctx, const user_options_t *user_option logfile_ctx->enabled = true; } -void logfile_destroy (logfile_ctx_t *logfile_ctx) +void logfile_destroy (hashcat_ctx_t *hashcat_ctx) { + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + if (logfile_ctx->enabled == false) return; myfree (logfile_ctx->logfile); diff --git a/src/user_options.c b/src/user_options.c index e6e4bac80..9c399eedb 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1144,8 +1144,11 @@ void user_options_extra_destroy (user_options_extra_t *user_options_extra) memset (user_options_extra, 0, sizeof (user_options_extra_t)); } -void user_options_logger (const user_options_t *user_options, const logfile_ctx_t *logfile_ctx) +void user_options_logger (hashcat_ctx_t *hashcat_ctx) { + user_options_t *user_options = hashcat_ctx->user_options; + logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; + logfile_top_uint (user_options->benchmark); logfile_top_uint (user_options->force); logfile_top_uint (user_options->gpu_temp_disable);