mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 01:50:10 +00:00
Rewrote logfile handling from scratch
This commit is contained in:
parent
7d9ff152b0
commit
0a330d4335
@ -19,7 +19,10 @@ int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co
|
||||
|
||||
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, user_options_t *user_options, char *hash_or_file);
|
||||
int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl_ctx_t *opencl_ctx, user_options_t *user_options);
|
||||
int hashes_init_stage3 (hashes_t *hashes, hashconfig_t *hashconfig, user_options_t *user_options);
|
||||
|
||||
void hashes_destroy (hashes_t *hashes);
|
||||
|
||||
void hashes_logger (const hashes_t *hashes, const logfile_ctx_t *logfile_ctx);
|
||||
|
||||
#endif // _HASH_MANAGEMENT_H
|
||||
|
@ -13,29 +13,32 @@
|
||||
|
||||
// logfile_append() checks for logfile_disable internally to make it easier from here
|
||||
|
||||
#define logfile_top_msg(msg) logfile_append (user_options, "%s\t%s", data.topid, (msg));
|
||||
#define logfile_sub_msg(msg) logfile_append (user_options, "%s\t%s\t%s", data.topid, data.subid, (msg));
|
||||
#define logfile_top_var_uint64(var,val) logfile_append (user_options, "%s\t%s\t%" PRIu64 "", data.topid, (var), (val));
|
||||
#define logfile_sub_var_uint64(var,val) logfile_append (user_options, "%s\t%s\t%s\t%" PRIu64 "", data.topid, data.subid, (var), (val));
|
||||
#define logfile_top_var_uint(var,val) logfile_append (user_options, "%s\t%s\t%u", data.topid, (var), (val));
|
||||
#define logfile_sub_var_uint(var,val) logfile_append (user_options, "%s\t%s\t%s\t%u", data.topid, data.subid, (var), (val));
|
||||
#define logfile_top_var_char(var,val) logfile_append (user_options, "%s\t%s\t%c", data.topid, (var), (val));
|
||||
#define logfile_sub_var_char(var,val) logfile_append (user_options, "%s\t%s\t%s\t%c", data.topid, data.subid, (var), (val));
|
||||
#define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append (user_options, "%s\t%s\t%s", data.topid, (var), (val));
|
||||
#define logfile_sub_var_string(var,val) if ((val) != NULL) logfile_append (user_options, "%s\t%s\t%s\t%s", data.topid, data.subid, (var), (val));
|
||||
#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_uint64(var) logfile_top_var_uint64 (#var, (var));
|
||||
#define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
|
||||
#define logfile_top_uint(var) logfile_top_var_uint (#var, (var));
|
||||
#define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var));
|
||||
#define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var));
|
||||
#define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
|
||||
#define logfile_top_char(var) logfile_top_var_char (#var, (var));
|
||||
#define logfile_sub_char(var) logfile_sub_var_char (#var, (var));
|
||||
#define logfile_top_string(var) logfile_top_var_string (#var, (var));
|
||||
#define logfile_sub_string(var) logfile_sub_var_string (#var, (var));
|
||||
|
||||
char *logfile_generate_topid (void);
|
||||
char *logfile_generate_subid (void);
|
||||
void logfile_generate_topid (logfile_ctx_t *logfile_ctx);
|
||||
void logfile_generate_subid (logfile_ctx_t *logfile_ctx);
|
||||
|
||||
void logfile_append (const user_options_t *user_options, const char *fmt, ...);
|
||||
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);
|
||||
|
||||
#endif // _LOGFILE_H
|
||||
|
@ -186,6 +186,16 @@ typedef struct
|
||||
|
||||
} hash_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool enabled;
|
||||
|
||||
char *logfile;
|
||||
char *topid;
|
||||
char *subid;
|
||||
|
||||
} logfile_ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *hashfile;
|
||||
@ -956,14 +966,6 @@ typedef struct
|
||||
void *hm_xnvctrl;
|
||||
hm_attrs_t hm_device[DEVICES_MAX];
|
||||
|
||||
/**
|
||||
* logging
|
||||
*/
|
||||
|
||||
char *logfile;
|
||||
char *topid;
|
||||
char *subid;
|
||||
|
||||
/**
|
||||
* crack-per-time
|
||||
*/
|
||||
@ -1000,6 +1002,7 @@ typedef struct
|
||||
bitmap_ctx_t *bitmap_ctx;
|
||||
induct_ctx_t *induct_ctx;
|
||||
outcheck_ctx_t *outcheck_ctx;
|
||||
logfile_ctx_t *logfile_ctx;
|
||||
|
||||
/**
|
||||
* used for restore
|
||||
|
@ -253,4 +253,6 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
|
||||
|
||||
int user_options_extra_init (user_options_t *user_options, int myargc, char **myargv, user_options_extra_t *user_options_extra);
|
||||
|
||||
void user_options_logger (const user_options_t *user_options, const logfile_ctx_t *logfile_ctx);
|
||||
|
||||
#endif // _USER_OPTIONS_H
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "timer.h"
|
||||
#include "memory.h"
|
||||
#include "logging.h"
|
||||
#include "logfile.h"
|
||||
#include "ext_OpenCL.h"
|
||||
#include "ext_ADL.h"
|
||||
#include "ext_nvapi.h"
|
||||
@ -1450,6 +1451,52 @@ int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hashes_init_stage3 (hashes_t *hashes, hashconfig_t *hashconfig, user_options_t *user_options)
|
||||
{
|
||||
hashconfig_general_defaults (hashconfig, hashes, user_options);
|
||||
|
||||
if (hashes->salts_cnt == 1)
|
||||
hashconfig->opti_type |= OPTI_TYPE_SINGLE_SALT;
|
||||
|
||||
if (hashes->digests_cnt == 1)
|
||||
hashconfig->opti_type |= OPTI_TYPE_SINGLE_HASH;
|
||||
|
||||
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
||||
hashconfig->opti_type |= OPTI_TYPE_NOT_ITERATED;
|
||||
|
||||
if (user_options->attack_mode == ATTACK_MODE_BF)
|
||||
hashconfig->opti_type |= OPTI_TYPE_BRUTE_FORCE;
|
||||
|
||||
if (hashconfig->opti_type & OPTI_TYPE_BRUTE_FORCE)
|
||||
{
|
||||
if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH)
|
||||
{
|
||||
if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT)
|
||||
{
|
||||
if (hashconfig->opts_type & OPTS_TYPE_ST_ADD80)
|
||||
{
|
||||
hashconfig->opts_type &= ~OPTS_TYPE_ST_ADD80;
|
||||
hashconfig->opts_type |= OPTS_TYPE_PT_ADD80;
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_ST_ADDBITS14)
|
||||
{
|
||||
hashconfig->opts_type &= ~OPTS_TYPE_ST_ADDBITS14;
|
||||
hashconfig->opts_type |= OPTS_TYPE_PT_ADDBITS14;
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_ST_ADDBITS15)
|
||||
{
|
||||
hashconfig->opts_type &= ~OPTS_TYPE_ST_ADDBITS15;
|
||||
hashconfig->opts_type |= OPTS_TYPE_PT_ADDBITS15;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hashes_destroy (hashes_t *hashes)
|
||||
{
|
||||
myfree (hashes->digests_buf);
|
||||
@ -1487,3 +1534,15 @@ void hashes_destroy (hashes_t *hashes)
|
||||
|
||||
hashes->hash_info = NULL;
|
||||
}
|
||||
|
||||
void hashes_logger (const hashes_t *hashes, const logfile_ctx_t *logfile_ctx)
|
||||
{
|
||||
logfile_top_string (hashes->hashfile);
|
||||
logfile_top_uint (hashes->hashlist_mode);
|
||||
logfile_top_uint (hashes->hashlist_format);
|
||||
logfile_top_uint (hashes->hashes_cnt);
|
||||
logfile_top_uint (hashes->digests_cnt);
|
||||
logfile_top_uint (hashes->digests_done);
|
||||
logfile_top_uint (hashes->salts_cnt);
|
||||
logfile_top_uint (hashes->salts_done);
|
||||
}
|
||||
|
175
src/hashcat.c
175
src/hashcat.c
@ -307,6 +307,24 @@ int main (int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* logfile init
|
||||
*/
|
||||
|
||||
logfile_ctx_t *logfile_ctx = (logfile_ctx_t *) mymalloc (sizeof (logfile_ctx_t));
|
||||
|
||||
data.logfile_ctx = logfile_ctx;
|
||||
|
||||
logfile_init (logfile_ctx, user_options, folder_config);
|
||||
|
||||
logfile_generate_topid (logfile_ctx);
|
||||
|
||||
logfile_top_msg ("START");
|
||||
|
||||
/**
|
||||
* process user input
|
||||
*/
|
||||
|
||||
user_options_extra_t *user_options_extra = (user_options_extra_t *) mymalloc (sizeof (user_options_extra_t));
|
||||
|
||||
data.user_options_extra = user_options_extra;
|
||||
@ -319,6 +337,8 @@ int main (int argc, char **argv)
|
||||
|
||||
if (rc_user_options_sanity == -1) return -1;
|
||||
|
||||
user_options_logger (user_options, logfile_ctx);
|
||||
|
||||
/**
|
||||
* Inform user things getting started,
|
||||
* - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
|
||||
@ -369,101 +389,6 @@ int main (int argc, char **argv)
|
||||
set_cpu_affinity (user_options->cpu_affinity);
|
||||
}
|
||||
|
||||
/**
|
||||
* logfile init
|
||||
*/
|
||||
|
||||
if (user_options->logfile_disable == false)
|
||||
{
|
||||
char *logfile = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||
|
||||
snprintf (logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", folder_config->session_dir, user_options->session);
|
||||
|
||||
data.logfile = logfile;
|
||||
|
||||
char *topid = logfile_generate_topid ();
|
||||
|
||||
data.topid = topid;
|
||||
}
|
||||
|
||||
logfile_top_msg ("START");
|
||||
|
||||
logfile_top_uint (user_options->attack_mode);
|
||||
logfile_top_uint (user_options->benchmark);
|
||||
logfile_top_uint (user_options->stdout_flag);
|
||||
logfile_top_uint (user_options->bitmap_min);
|
||||
logfile_top_uint (user_options->bitmap_max);
|
||||
logfile_top_uint (user_options->debug_mode);
|
||||
logfile_top_uint (user_options->force);
|
||||
logfile_top_uint (user_options->kernel_accel);
|
||||
logfile_top_uint (user_options->kernel_loops);
|
||||
logfile_top_uint (user_options->nvidia_spin_damp);
|
||||
logfile_top_uint (user_options->hash_mode);
|
||||
logfile_top_uint (user_options->hex_charset);
|
||||
logfile_top_uint (user_options->hex_salt);
|
||||
logfile_top_uint (user_options->hex_wordlist);
|
||||
logfile_top_uint (user_options->increment);
|
||||
logfile_top_uint (user_options->increment_max);
|
||||
logfile_top_uint (user_options->increment_min);
|
||||
logfile_top_uint (user_options->keyspace);
|
||||
logfile_top_uint (user_options->left);
|
||||
logfile_top_uint (user_options->logfile_disable);
|
||||
logfile_top_uint (user_options->loopback);
|
||||
logfile_top_uint (user_options->markov_classic);
|
||||
logfile_top_uint (user_options->markov_disable);
|
||||
logfile_top_uint (user_options->markov_threshold);
|
||||
logfile_top_uint (user_options->outfile_autohex);
|
||||
logfile_top_uint (user_options->outfile_check_timer);
|
||||
logfile_top_uint (user_options->outfile_format);
|
||||
logfile_top_uint (user_options->potfile_disable);
|
||||
logfile_top_string (user_options->potfile_path);
|
||||
logfile_top_uint (user_options->powertune_enable);
|
||||
logfile_top_uint (user_options->scrypt_tmto);
|
||||
logfile_top_uint (user_options->quiet);
|
||||
logfile_top_uint (user_options->remove);
|
||||
logfile_top_uint (user_options->remove_timer);
|
||||
logfile_top_uint (user_options->restore);
|
||||
logfile_top_uint (user_options->restore_disable);
|
||||
logfile_top_uint (user_options->restore_timer);
|
||||
logfile_top_uint (user_options->rp_gen);
|
||||
logfile_top_uint (user_options->rp_gen_func_max);
|
||||
logfile_top_uint (user_options->rp_gen_func_min);
|
||||
logfile_top_uint (user_options->rp_gen_seed);
|
||||
logfile_top_uint (user_options->runtime);
|
||||
logfile_top_uint (user_options->segment_size);
|
||||
logfile_top_uint (user_options->show);
|
||||
logfile_top_uint (user_options->status);
|
||||
logfile_top_uint (user_options->machine_readable);
|
||||
logfile_top_uint (user_options->status_timer);
|
||||
logfile_top_uint (user_options->usage);
|
||||
logfile_top_uint (user_options->username);
|
||||
logfile_top_uint (user_options->version);
|
||||
logfile_top_uint (user_options->weak_hash_threshold);
|
||||
logfile_top_uint (user_options->workload_profile);
|
||||
logfile_top_uint64 (user_options->limit);
|
||||
logfile_top_uint64 (user_options->skip);
|
||||
logfile_top_char (user_options->separator);
|
||||
logfile_top_string (user_options->cpu_affinity);
|
||||
logfile_top_string (user_options->custom_charset_1);
|
||||
logfile_top_string (user_options->custom_charset_2);
|
||||
logfile_top_string (user_options->custom_charset_3);
|
||||
logfile_top_string (user_options->custom_charset_4);
|
||||
logfile_top_string (user_options->debug_file);
|
||||
logfile_top_string (user_options->opencl_devices);
|
||||
logfile_top_string (user_options->opencl_platforms);
|
||||
logfile_top_string (user_options->opencl_device_types);
|
||||
logfile_top_uint (user_options->opencl_vector_width);
|
||||
logfile_top_string (user_options->induction_dir);
|
||||
logfile_top_string (user_options->markov_hcstat);
|
||||
logfile_top_string (user_options->outfile);
|
||||
logfile_top_string (user_options->outfile_check_dir);
|
||||
logfile_top_string (user_options->rule_buf_l);
|
||||
logfile_top_string (user_options->rule_buf_r);
|
||||
logfile_top_string (user_options->session);
|
||||
logfile_top_string (user_options->truecrypt_keyfiles);
|
||||
logfile_top_string (user_options->veracrypt_keyfiles);
|
||||
logfile_top_uint (user_options->veracrypt_pim);
|
||||
|
||||
/**
|
||||
* Init OpenCL library loader
|
||||
*/
|
||||
@ -617,11 +542,6 @@ int main (int argc, char **argv)
|
||||
|
||||
if (rc_hashes_init_stage1 == -1) return -1;
|
||||
|
||||
logfile_top_var_string ("hashfile", hashes->hashfile);
|
||||
|
||||
logfile_top_uint (hashes->hashlist_mode);
|
||||
logfile_top_uint (hashes->hashlist_format);
|
||||
|
||||
if ((user_options->keyspace == false) && (user_options->stdout_flag == false) && (user_options->opencl_info == false))
|
||||
{
|
||||
if (hashes->hashes_cnt == 0)
|
||||
@ -657,59 +577,24 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/**
|
||||
* load hashes, stage 2
|
||||
* load hashes, stage 2, remove duplicates, build base structure
|
||||
*/
|
||||
|
||||
uint hashes_cnt_orig = hashes->hashes_cnt;
|
||||
const u32 hashes_cnt_orig = hashes->hashes_cnt;
|
||||
|
||||
const int rc_hashes_init_stage2 = hashes_init_stage2 (hashes, hashconfig, opencl_ctx, user_options);
|
||||
|
||||
if (rc_hashes_init_stage2 == -1) return -1;
|
||||
|
||||
/**
|
||||
* Automatic Optimizers
|
||||
* load hashes, stage 3, automatic Optimizers
|
||||
*/
|
||||
|
||||
hashconfig_general_defaults (hashconfig, hashes, user_options);
|
||||
const int rc_hashes_init_stage3 = hashes_init_stage3 (hashes, hashconfig, user_options);
|
||||
|
||||
if (hashes->salts_cnt == 1)
|
||||
hashconfig->opti_type |= OPTI_TYPE_SINGLE_SALT;
|
||||
if (rc_hashes_init_stage3 == -1) return -1;
|
||||
|
||||
if (hashes->digests_cnt == 1)
|
||||
hashconfig->opti_type |= OPTI_TYPE_SINGLE_HASH;
|
||||
|
||||
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
||||
hashconfig->opti_type |= OPTI_TYPE_NOT_ITERATED;
|
||||
|
||||
if (user_options->attack_mode == ATTACK_MODE_BF)
|
||||
hashconfig->opti_type |= OPTI_TYPE_BRUTE_FORCE;
|
||||
|
||||
if (hashconfig->opti_type & OPTI_TYPE_BRUTE_FORCE)
|
||||
{
|
||||
if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH)
|
||||
{
|
||||
if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT)
|
||||
{
|
||||
if (hashconfig->opts_type & OPTS_TYPE_ST_ADD80)
|
||||
{
|
||||
hashconfig->opts_type &= ~OPTS_TYPE_ST_ADD80;
|
||||
hashconfig->opts_type |= OPTS_TYPE_PT_ADD80;
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_ST_ADDBITS14)
|
||||
{
|
||||
hashconfig->opts_type &= ~OPTS_TYPE_ST_ADDBITS14;
|
||||
hashconfig->opts_type |= OPTS_TYPE_PT_ADDBITS14;
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_ST_ADDBITS15)
|
||||
{
|
||||
hashconfig->opts_type &= ~OPTS_TYPE_ST_ADDBITS15;
|
||||
hashconfig->opts_type |= OPTS_TYPE_PT_ADDBITS15;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hashes_logger (hashes, logfile_ctx);
|
||||
|
||||
/**
|
||||
* bitmaps
|
||||
@ -2792,9 +2677,7 @@ int main (int argc, char **argv)
|
||||
|
||||
rd->dictpos = dictpos;
|
||||
|
||||
char *subid = logfile_generate_subid ();
|
||||
|
||||
data.subid = subid;
|
||||
logfile_generate_subid (logfile_ctx);
|
||||
|
||||
logfile_sub_msg ("START");
|
||||
|
||||
@ -3536,8 +3419,6 @@ int main (int argc, char **argv)
|
||||
|
||||
logfile_sub_msg ("STOP");
|
||||
|
||||
global_free (subid);
|
||||
|
||||
// finalize task
|
||||
|
||||
if (opencl_ctx->run_main_level3 == false) break;
|
||||
@ -3873,6 +3754,8 @@ int main (int argc, char **argv)
|
||||
|
||||
logfile_top_msg ("STOP");
|
||||
|
||||
logfile_destroy (logfile_ctx);
|
||||
|
||||
if (user_options->quiet == false) log_info_nn ("Started: %s", ctime (&proc_start));
|
||||
if (user_options->quiet == false) log_info_nn ("Stopped: %s", ctime (&proc_stop));
|
||||
|
||||
|
@ -9,55 +9,43 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "interface.h"
|
||||
#include "timer.h"
|
||||
#include "ext_OpenCL.h"
|
||||
#include "ext_ADL.h"
|
||||
#include "ext_nvapi.h"
|
||||
#include "ext_nvml.h"
|
||||
#include "ext_xnvctrl.h"
|
||||
#include "memory.h"
|
||||
#include "rp_cpu.h"
|
||||
#include "mpsp.h"
|
||||
#include "tuningdb.h"
|
||||
#include "thread.h"
|
||||
#include "opencl.h"
|
||||
#include "hwmon.h"
|
||||
#include "restore.h"
|
||||
#include "hash_management.h"
|
||||
#include "outfile.h"
|
||||
#include "potfile.h"
|
||||
#include "debugfile.h"
|
||||
#include "loopback.h"
|
||||
#include "data.h"
|
||||
#include "logfile.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
static FILE *logfile_open (char *logfile)
|
||||
static int logfile_generate_id ()
|
||||
{
|
||||
FILE *fp = fopen (logfile, "ab");
|
||||
const int n = rand ();
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
fp = stdout;
|
||||
}
|
||||
time_t t;
|
||||
|
||||
return fp;
|
||||
time (&t);
|
||||
|
||||
return t + n;
|
||||
}
|
||||
|
||||
static void logfile_close (FILE *fp)
|
||||
void logfile_generate_topid (logfile_ctx_t *logfile_ctx)
|
||||
{
|
||||
if (fp == stdout) return;
|
||||
if (logfile_ctx->enabled == false) return;
|
||||
|
||||
fclose (fp);
|
||||
const int id = logfile_generate_id ();
|
||||
|
||||
snprintf (logfile_ctx->topid, 1 + 16, "TOP%08x", id);
|
||||
}
|
||||
|
||||
void logfile_append (const user_options_t *user_options, const char *fmt, ...)
|
||||
void logfile_generate_subid (logfile_ctx_t *logfile_ctx)
|
||||
{
|
||||
if (user_options->logfile_disable == true) return;
|
||||
if (logfile_ctx->enabled == false) return;
|
||||
|
||||
FILE *fp = logfile_open (data.logfile);
|
||||
const int id = logfile_generate_id ();
|
||||
|
||||
snprintf (logfile_ctx->subid, 1 + 16, "SUB%08x", id);
|
||||
}
|
||||
|
||||
void logfile_append (const logfile_ctx_t *logfile_ctx, const char *fmt, ...)
|
||||
{
|
||||
if (logfile_ctx->enabled == false) return;
|
||||
|
||||
FILE *fp = fopen (logfile_ctx->logfile, "ab");
|
||||
|
||||
va_list ap;
|
||||
|
||||
@ -71,38 +59,30 @@ void logfile_append (const user_options_t *user_options, const char *fmt, ...)
|
||||
|
||||
fflush (fp);
|
||||
|
||||
logfile_close (fp);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
static int logfile_generate_id ()
|
||||
void logfile_init (logfile_ctx_t *logfile_ctx, const user_options_t *user_options, const folder_config_t *folder_config)
|
||||
{
|
||||
const int n = rand ();
|
||||
if (user_options->logfile_disable == true) return;
|
||||
|
||||
time_t t;
|
||||
logfile_ctx->logfile = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||
|
||||
time (&t);
|
||||
snprintf (logfile_ctx->logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", folder_config->session_dir, user_options->session);
|
||||
|
||||
return t + n;
|
||||
logfile_ctx->subid = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||
logfile_ctx->topid = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||
|
||||
logfile_ctx->enabled = true;
|
||||
}
|
||||
|
||||
char *logfile_generate_topid ()
|
||||
void logfile_destroy (logfile_ctx_t *logfile_ctx)
|
||||
{
|
||||
const int id = logfile_generate_id ();
|
||||
if (logfile_ctx->enabled == false) return;
|
||||
|
||||
char *topid = (char *) mymalloc (1 + 16 + 1);
|
||||
myfree (logfile_ctx->logfile);
|
||||
myfree (logfile_ctx->topid);
|
||||
myfree (logfile_ctx->subid);
|
||||
|
||||
snprintf (topid, 1 + 16, "TOP%08x", id);
|
||||
|
||||
return topid;
|
||||
}
|
||||
|
||||
char *logfile_generate_subid ()
|
||||
{
|
||||
const int id = logfile_generate_id ();
|
||||
|
||||
char *subid = (char *) mymalloc (1 + 16 + 1);
|
||||
|
||||
snprintf (subid, 1 + 16, "SUB%08x", id);
|
||||
|
||||
return subid;
|
||||
myfree (logfile_ctx);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "types.h"
|
||||
#include "memory.h"
|
||||
#include "logging.h"
|
||||
#include "logfile.h"
|
||||
#include "interface.h"
|
||||
#include "shared.h"
|
||||
#include "usage.h"
|
||||
@ -872,3 +873,88 @@ int user_options_extra_init (user_options_t *user_options, int myargc, char **my
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void user_options_logger (const user_options_t *user_options, const logfile_ctx_t *logfile_ctx)
|
||||
{
|
||||
logfile_top_uint (user_options->benchmark);
|
||||
logfile_top_uint (user_options->force);
|
||||
logfile_top_uint (user_options->gpu_temp_disable);
|
||||
logfile_top_uint (user_options->hex_charset);
|
||||
logfile_top_uint (user_options->hex_salt);
|
||||
logfile_top_uint (user_options->hex_wordlist);
|
||||
logfile_top_uint (user_options->increment);
|
||||
logfile_top_uint (user_options->keyspace);
|
||||
logfile_top_uint (user_options->left);
|
||||
logfile_top_uint (user_options->logfile_disable);
|
||||
logfile_top_uint (user_options->loopback);
|
||||
logfile_top_uint (user_options->machine_readable);
|
||||
logfile_top_uint (user_options->markov_classic);
|
||||
logfile_top_uint (user_options->markov_disable);
|
||||
logfile_top_uint (user_options->opencl_info);
|
||||
logfile_top_uint (user_options->outfile_autohex);
|
||||
logfile_top_uint (user_options->potfile_disable);
|
||||
logfile_top_uint (user_options->powertune_enable);
|
||||
logfile_top_uint (user_options->quiet);
|
||||
logfile_top_uint (user_options->remove);
|
||||
logfile_top_uint (user_options->restore);
|
||||
logfile_top_uint (user_options->restore_disable);
|
||||
logfile_top_uint (user_options->show);
|
||||
logfile_top_uint (user_options->status);
|
||||
logfile_top_uint (user_options->stdout_flag);
|
||||
logfile_top_uint (user_options->usage);
|
||||
logfile_top_uint (user_options->username);
|
||||
logfile_top_uint (user_options->version);
|
||||
logfile_top_uint (user_options->attack_mode);
|
||||
logfile_top_uint (user_options->bitmap_max);
|
||||
logfile_top_uint (user_options->bitmap_min);
|
||||
logfile_top_uint (user_options->debug_mode);
|
||||
logfile_top_uint (user_options->gpu_temp_abort);
|
||||
logfile_top_uint (user_options->gpu_temp_retain);
|
||||
logfile_top_uint (user_options->hash_mode);
|
||||
logfile_top_uint (user_options->increment_max);
|
||||
logfile_top_uint (user_options->increment_min);
|
||||
logfile_top_uint (user_options->kernel_accel);
|
||||
logfile_top_uint (user_options->kernel_loops);
|
||||
logfile_top_uint (user_options->markov_threshold);
|
||||
logfile_top_uint (user_options->nvidia_spin_damp);
|
||||
logfile_top_uint (user_options->opencl_vector_width);
|
||||
logfile_top_uint (user_options->outfile_check_timer);
|
||||
logfile_top_uint (user_options->outfile_format);
|
||||
logfile_top_uint (user_options->remove_timer);
|
||||
logfile_top_uint (user_options->restore_timer);
|
||||
logfile_top_uint (user_options->rp_files_cnt);
|
||||
logfile_top_uint (user_options->rp_gen);
|
||||
logfile_top_uint (user_options->rp_gen_func_max);
|
||||
logfile_top_uint (user_options->rp_gen_func_min);
|
||||
logfile_top_uint (user_options->rp_gen_seed);
|
||||
logfile_top_uint (user_options->runtime);
|
||||
logfile_top_uint (user_options->scrypt_tmto);
|
||||
logfile_top_uint (user_options->segment_size);
|
||||
logfile_top_uint (user_options->status_timer);
|
||||
logfile_top_uint (user_options->veracrypt_pim);
|
||||
logfile_top_uint (user_options->weak_hash_threshold);
|
||||
logfile_top_uint (user_options->workload_profile);
|
||||
logfile_top_uint64 (user_options->limit);
|
||||
logfile_top_uint64 (user_options->skip);
|
||||
logfile_top_string (user_options->cpu_affinity);
|
||||
logfile_top_string (user_options->custom_charset_1);
|
||||
logfile_top_string (user_options->custom_charset_2);
|
||||
logfile_top_string (user_options->custom_charset_3);
|
||||
logfile_top_string (user_options->custom_charset_4);
|
||||
logfile_top_string (user_options->debug_file);
|
||||
logfile_top_string (user_options->induction_dir);
|
||||
logfile_top_string (user_options->markov_hcstat);
|
||||
logfile_top_string (user_options->opencl_devices);
|
||||
logfile_top_string (user_options->opencl_device_types);
|
||||
logfile_top_string (user_options->opencl_platforms);
|
||||
logfile_top_string (user_options->outfile);
|
||||
logfile_top_string (user_options->outfile_check_dir);
|
||||
logfile_top_string (user_options->potfile_path);
|
||||
logfile_top_string (user_options->rp_files[0]);
|
||||
logfile_top_string (user_options->rule_buf_l);
|
||||
logfile_top_string (user_options->rule_buf_r);
|
||||
logfile_top_char (user_options->separator);
|
||||
logfile_top_string (user_options->session);
|
||||
logfile_top_string (user_options->truecrypt_keyfiles);
|
||||
logfile_top_string (user_options->veracrypt_keyfiles);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user