Move logfile stuff back to hashcat.c, it's a core feature which should be handled by the library

pull/544/head
jsteube 8 years ago
parent 6d2c58d8df
commit 2a5545d2b7

@ -82,10 +82,6 @@ typedef enum event_identifier
EVENT_LOG_ERROR = 0x00000003,
EVENT_WELCOME_SCREEN = 0x00000011,
EVENT_GOODBYE_SCREEN = 0x00000012,
EVENT_LOGFILE_TOP_INITIALIZE = 0x00000021,
EVENT_LOGFILE_TOP_FINALIZE = 0x00000022,
EVENT_LOGFILE_SUB_INITIALIZE = 0x00000023,
EVENT_LOGFILE_SUB_FINALIZE = 0x00000024,
EVENT_OUTERLOOP_STARTING = 0x00000031,
EVENT_OUTERLOOP_MAINSCREEN = 0x00000032,
EVENT_OUTERLOOP_FINISHED = 0x00000033,
@ -98,7 +94,6 @@ typedef enum event_identifier
EVENT_AUTOTUNE_FINISHED = 0x00000054,
EVENT_CRACKER_STARTING = 0x00000055,
EVENT_CRACKER_FINISHED = 0x00000056,
EVENT_CRACKER_FINAL_STATS = 0x00000057,
EVENT_CRACKER_HASH_CRACKED = 0x00000058,
EVENT_POTFILE_REMOVE_PARSE_PRE = 0x00000061,
EVENT_POTFILE_REMOVE_PARSE_POST = 0x00000062,

@ -146,7 +146,9 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
status_ctx->devices_status = STATUS_INIT;
EVENT (EVENT_LOGFILE_SUB_INITIALIZE);
logfile_generate_subid (hashcat_ctx);
logfile_sub_msg ("START");
status_progress_reset (hashcat_ctx);
@ -315,8 +317,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
status_ctx->devices_status = STATUS_EXHAUSTED;
}
EVENT (EVENT_CRACKER_FINISHED);
// update some timer
time_t runtime_stop;
@ -330,7 +330,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
time (&status_ctx->prepare_start);
EVENT (EVENT_CRACKER_FINAL_STATS);
EVENT (EVENT_CRACKER_FINISHED);
// no more skip and restore from here
@ -339,6 +339,12 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
rd->words_cur = 0;
}
// mark sub logfile
logfile_sub_var_uint ("status-after-work", status_ctx->devices_status);
logfile_sub_msg ("STOP");
// stop loopback recording
if (user_options->loopback == true)
@ -346,8 +352,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
loopback_write_close (hashcat_ctx);
}
EVENT (EVENT_LOGFILE_SUB_FINALIZE);
// New induction folder check
if (induct_ctx->induction_dictionaries_cnt == 0)
@ -847,9 +851,21 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
user_options_extra_init (hashcat_ctx);
// from here all user configuration is pre-processed so we can start logging if we want to
/**
* logfile
*/
const int rc_logfile_init = logfile_init (hashcat_ctx);
if (rc_logfile_init == -1) return -1;
EVENT (EVENT_LOGFILE_TOP_INITIALIZE);
logfile_generate_topid (hashcat_ctx);
logfile_top_msg ("START");
// add all user options to logfile in case we want to debug some user session
user_options_logger (hashcat_ctx);
/**
* cpu affinity
@ -1032,12 +1048,14 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
logfile_top_uint (status_ctx->proc_start);
logfile_top_uint (status_ctx->proc_stop);
EVENT (EVENT_LOGFILE_TOP_FINALIZE);
logfile_top_msg ("STOP");
// free memory
EVENT (EVENT_GOODBYE_SCREEN);
logfile_destroy (hashcat_ctx);
debugfile_destroy (hashcat_ctx);
tuning_db_destroy (hashcat_ctx);

@ -19,7 +19,6 @@
#include "memory.h"
#include "terminal.h"
#include "logfile.h"
#include "thread.h"
#include "status.h"
#include "interface.h"
@ -108,58 +107,6 @@ static int main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_U
return 0;
}
static int main_logfile_top_initialize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
// logfile init
const int rc_logfile_init = logfile_init (hashcat_ctx);
if (rc_logfile_init == -1) return -1;
logfile_generate_topid (hashcat_ctx);
logfile_top_msg ("START");
// add all user options to logfile in case we want to debug some user session
user_options_logger (hashcat_ctx);
return 0;
}
static int main_logfile_top_finalize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
logfile_top_msg ("STOP");
logfile_destroy (hashcat_ctx);
return 0;
}
static int main_logfile_sub_initialize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
logfile_generate_subid (hashcat_ctx);
logfile_sub_msg ("START");
return 0;
}
static int main_logfile_sub_finalize (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
logfile_sub_msg ("STOP");
return 0;
}
static int main_outerloop_starting (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;
@ -240,16 +187,6 @@ static int main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE
}
static int main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
logfile_sub_var_uint ("status-after-work", status_ctx->devices_status);
return 0;
}
static int main_cracker_final_stats (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const hashes_t *hashes = hashcat_ctx->hashes;
const user_options_t *user_options = hashcat_ctx->user_options;
@ -554,16 +491,11 @@ int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size
case EVENT_LOG_ERROR: rc = main_log_error (hashcat_ctx, buf, len); break;
case EVENT_WELCOME_SCREEN: rc = main_welcome_screen (hashcat_ctx, buf, len); break;
case EVENT_GOODBYE_SCREEN: rc = main_goodbye_screen (hashcat_ctx, buf, len); break;
case EVENT_LOGFILE_TOP_INITIALIZE: rc = main_logfile_top_initialize (hashcat_ctx, buf, len); break;
case EVENT_LOGFILE_TOP_FINALIZE: rc = main_logfile_top_finalize (hashcat_ctx, buf, len); break;
case EVENT_LOGFILE_SUB_INITIALIZE: rc = main_logfile_sub_initialize (hashcat_ctx, buf, len); break;
case EVENT_LOGFILE_SUB_FINALIZE: rc = main_logfile_sub_finalize (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_STARTING: rc = main_outerloop_starting (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_FINISHED: rc = main_outerloop_finished (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_MAINSCREEN: rc = main_outerloop_mainscreen (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_STARTING: rc = main_cracker_starting (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_FINISHED: rc = main_cracker_finished (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_FINAL_STATS: rc = main_cracker_final_stats (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_HASH_CRACKED: rc = main_cracker_hash_cracked (hashcat_ctx, buf, len); break;
case EVENT_CALCULATED_WORDS_BASE: rc = main_calculated_words_base (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_REMOVE_PARSE_PRE: rc = main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break;

Loading…
Cancel
Save