mirror of
https://github.com/hashcat/hashcat.git
synced 2025-06-30 20:02:41 +00:00
Move outer loop into separate function
This commit is contained in:
parent
ca48c49575
commit
359762c757
617
src/hashcat.c
617
src/hashcat.c
@ -178,280 +178,20 @@ static void welcome_screen (user_options_t *user_options, const time_t *proc_sta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
static void setup_seeding (const user_options_t *user_options, const time_t proc_start)
|
||||||
{
|
{
|
||||||
/**
|
if (user_options->rp_gen_seed_chgd == true)
|
||||||
* To help users a bit
|
|
||||||
*/
|
|
||||||
|
|
||||||
setup_console ();
|
|
||||||
|
|
||||||
setup_environment_variables ();
|
|
||||||
|
|
||||||
setup_umask ();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Real init
|
|
||||||
*/
|
|
||||||
|
|
||||||
memset (&data, 0, sizeof (hc_global_data_t));
|
|
||||||
|
|
||||||
time_t proc_start;
|
|
||||||
|
|
||||||
time (&proc_start);
|
|
||||||
|
|
||||||
data.proc_start = proc_start;
|
|
||||||
|
|
||||||
time_t prepare_start;
|
|
||||||
|
|
||||||
time (&prepare_start);
|
|
||||||
|
|
||||||
hc_thread_mutex_init (mux_display);
|
|
||||||
hc_thread_mutex_init (mux_hwmon);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* folder
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *install_folder = NULL;
|
|
||||||
char *shared_folder = NULL;
|
|
||||||
|
|
||||||
#if defined (INSTALL_FOLDER)
|
|
||||||
install_folder = INSTALL_FOLDER;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (SHARED_FOLDER)
|
|
||||||
shared_folder = SHARED_FOLDER;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
folder_config_t *folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t));
|
|
||||||
|
|
||||||
folder_config_init (folder_config, install_folder, shared_folder);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* commandline parameters
|
|
||||||
*/
|
|
||||||
|
|
||||||
user_options_t *user_options = (user_options_t *) mymalloc (sizeof (user_options_t));
|
|
||||||
|
|
||||||
data.user_options = user_options;
|
|
||||||
|
|
||||||
user_options_init (user_options, argc, argv);
|
|
||||||
|
|
||||||
const int rc_user_options_parse = user_options_parse (user_options, argc, argv);
|
|
||||||
|
|
||||||
if (rc_user_options_parse == -1) return -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* session
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *eff_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
|
|
||||||
char *new_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
|
|
||||||
|
|
||||||
snprintf (eff_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore", folder_config->session_dir, user_options->session);
|
|
||||||
snprintf (new_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore.new", folder_config->session_dir, user_options->session);
|
|
||||||
|
|
||||||
data.eff_restore_file = eff_restore_file;
|
|
||||||
data.new_restore_file = new_restore_file;
|
|
||||||
|
|
||||||
restore_data_t *rd = init_restore (argc, argv, user_options);
|
|
||||||
|
|
||||||
data.rd = rd;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* restore file
|
|
||||||
*/
|
|
||||||
|
|
||||||
int myargc = argc;
|
|
||||||
char **myargv = argv;
|
|
||||||
|
|
||||||
if (user_options->restore == true)
|
|
||||||
{
|
{
|
||||||
read_restore (eff_restore_file, rd);
|
srand (user_options->rp_gen_seed);
|
||||||
|
|
||||||
if (rd->version < RESTORE_VERSION_MIN)
|
|
||||||
{
|
|
||||||
log_error ("ERROR: Incompatible restore-file version");
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
myargc = rd->argc;
|
|
||||||
myargv = rd->argv;
|
|
||||||
|
|
||||||
#if defined (_POSIX)
|
|
||||||
rd->pid = getpid ();
|
|
||||||
#elif defined (_WIN)
|
|
||||||
rd->pid = GetCurrentProcessId ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
user_options_init (user_options, myargc, myargv);
|
|
||||||
|
|
||||||
const int rc_user_options_parse = user_options_parse (user_options, myargc, myargv);
|
|
||||||
|
|
||||||
if (rc_user_options_parse == -1) return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user_options->version == true)
|
|
||||||
{
|
{
|
||||||
log_info ("%s", VERSION_TAG);
|
srand (proc_start);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (user_options->usage == true)
|
static int outer_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, int myargc, char **myargv, folder_config_t *folder_config, logfile_ctx_t *logfile_ctx, tuning_db_t *tuning_db, induct_ctx_t *induct_ctx, outcheck_ctx_t *outcheck_ctx, opencl_ctx_t *opencl_ctx)
|
||||||
{
|
{
|
||||||
usage_big_print (PROGNAME);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
const int rc_user_options_extra_init = user_options_extra_init (user_options, myargc, myargv, user_options_extra);
|
|
||||||
|
|
||||||
if (rc_user_options_extra_init == -1) return -1;
|
|
||||||
|
|
||||||
const int rc_user_options_sanity = user_options_sanity (user_options, myargc, myargv, user_options_extra);
|
|
||||||
|
|
||||||
if (rc_user_options_sanity == -1) return -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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");
|
|
||||||
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
|
|
||||||
welcome_screen (user_options, &proc_start);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* tuning db
|
|
||||||
*/
|
|
||||||
|
|
||||||
char tuning_db_file[256] = { 0 };
|
|
||||||
|
|
||||||
snprintf (tuning_db_file, sizeof (tuning_db_file) - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE);
|
|
||||||
|
|
||||||
tuning_db_t *tuning_db = tuning_db_init (tuning_db_file);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* induction directory
|
|
||||||
*/
|
|
||||||
|
|
||||||
induct_ctx_t *induct_ctx = (induct_ctx_t *) mymalloc (sizeof (induct_ctx_t));
|
|
||||||
|
|
||||||
data.induct_ctx = induct_ctx;
|
|
||||||
|
|
||||||
const int rc_induct_ctx_init = induct_ctx_init (induct_ctx, user_options, folder_config, proc_start);
|
|
||||||
|
|
||||||
if (rc_induct_ctx_init == -1) return -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* outfile-check directory
|
|
||||||
*/
|
|
||||||
|
|
||||||
outcheck_ctx_t *outcheck_ctx = (outcheck_ctx_t *) mymalloc (sizeof (outcheck_ctx_t));
|
|
||||||
|
|
||||||
data.outcheck_ctx = outcheck_ctx;
|
|
||||||
|
|
||||||
const int rc_outcheck_ctx_init = outcheck_ctx_init (outcheck_ctx, user_options, folder_config);
|
|
||||||
|
|
||||||
if (rc_outcheck_ctx_init == -1) return -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cpu affinity
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (user_options->cpu_affinity)
|
|
||||||
{
|
|
||||||
set_cpu_affinity (user_options->cpu_affinity);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Init OpenCL library loader
|
|
||||||
*/
|
|
||||||
|
|
||||||
opencl_ctx_t *opencl_ctx = (opencl_ctx_t *) mymalloc (sizeof (opencl_ctx_t));
|
|
||||||
|
|
||||||
data.opencl_ctx = opencl_ctx;
|
|
||||||
|
|
||||||
const int rc_opencl_init = opencl_ctx_init (opencl_ctx, user_options);
|
|
||||||
|
|
||||||
if (rc_opencl_init == -1)
|
|
||||||
{
|
|
||||||
log_error ("ERROR: opencl_ctx_init() failed");
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Init OpenCL devices
|
|
||||||
*/
|
|
||||||
|
|
||||||
const int rc_devices_init = opencl_ctx_devices_init (opencl_ctx, user_options);
|
|
||||||
|
|
||||||
if (rc_devices_init == -1)
|
|
||||||
{
|
|
||||||
log_error ("ERROR: opencl_ctx_devices_init() failed");
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* status, monitor and outfile remove threads
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint outer_threads_cnt = 0;
|
|
||||||
|
|
||||||
hc_thread_t *outer_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
|
|
||||||
|
|
||||||
data.shutdown_outer = 0;
|
|
||||||
|
|
||||||
if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false)
|
|
||||||
{
|
|
||||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
|
||||||
{
|
|
||||||
hc_thread_create (outer_threads[outer_threads_cnt], thread_keypress, NULL);
|
|
||||||
|
|
||||||
outer_threads_cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* outer loop
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint algorithm_pos = 0;
|
|
||||||
uint algorithm_max = 1;
|
|
||||||
|
|
||||||
const int *algorithms = DEFAULT_BENCHMARK_ALGORITHMS_BUF;
|
|
||||||
|
|
||||||
if (user_options->benchmark == true && user_options->hash_mode_chgd == false) algorithm_max = DEFAULT_BENCHMARK_ALGORITHMS_CNT;
|
|
||||||
|
|
||||||
for (algorithm_pos = 0; algorithm_pos < algorithm_max; algorithm_pos++)
|
|
||||||
{
|
|
||||||
opencl_ctx->devices_status = STATUS_INIT;
|
opencl_ctx->devices_status = STATUS_INIT;
|
||||||
|
|
||||||
//opencl_ctx->run_main_level1 = true;
|
//opencl_ctx->run_main_level1 = true;
|
||||||
@ -463,8 +203,11 @@ int main (int argc, char **argv)
|
|||||||
/*
|
/*
|
||||||
* We need to reset 'rd' in benchmark mode otherwise when the user hits 'bypass'
|
* We need to reset 'rd' in benchmark mode otherwise when the user hits 'bypass'
|
||||||
* the following algos are skipped entirely
|
* the following algos are skipped entirely
|
||||||
|
* still needed? there's no more bypass in benchmark mode
|
||||||
|
* also there's no signs of special benchmark handling in the branch
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
if (algorithm_pos > 0)
|
if (algorithm_pos > 0)
|
||||||
{
|
{
|
||||||
local_free (rd);
|
local_free (rd);
|
||||||
@ -473,20 +216,15 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
data.rd = rd;
|
data.rd = rd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* update hash_mode in case of multihash benchmark
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (user_options->benchmark == true)
|
/**
|
||||||
{
|
* setup prepare timer
|
||||||
if (user_options->hash_mode_chgd == false)
|
*/
|
||||||
{
|
|
||||||
user_options->hash_mode = algorithms[algorithm_pos];
|
|
||||||
}
|
|
||||||
|
|
||||||
user_options->quiet = true;
|
time_t prepare_start;
|
||||||
}
|
|
||||||
|
time (&prepare_start);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setup variables and buffers depending on hash_mode
|
* setup variables and buffers depending on hash_mode
|
||||||
@ -692,19 +430,6 @@ int main (int argc, char **argv)
|
|||||||
opencl_ctx->force_jit_compilation = 1500;
|
opencl_ctx->force_jit_compilation = 1500;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* prepare seeding for random number generator used from random rules generator
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (user_options->rp_gen_seed_chgd == true)
|
|
||||||
{
|
|
||||||
srand (user_options->rp_gen_seed);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
srand (proc_start);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load rules
|
* load rules
|
||||||
*/
|
*/
|
||||||
@ -2378,6 +2103,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
data.maskcnt = maskcnt;
|
data.maskcnt = maskcnt;
|
||||||
|
|
||||||
|
restore_data_t *rd = data.rd;
|
||||||
|
|
||||||
for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
|
for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
|
||||||
{
|
{
|
||||||
//opencl_ctx->run_main_level1 = true;
|
//opencl_ctx->run_main_level1 = true;
|
||||||
@ -3323,7 +3050,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
data.runtime_start = runtime_start;
|
data.runtime_start = runtime_start;
|
||||||
|
|
||||||
data.prepare_time += runtime_start - prepare_start;
|
data.prepare_time = runtime_start - prepare_start;
|
||||||
|
|
||||||
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
||||||
{
|
{
|
||||||
@ -3490,8 +3217,8 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
if ((opencl_ctx->devices_status == STATUS_EXHAUSTED) || (opencl_ctx->devices_status == STATUS_CRACKED))
|
if ((opencl_ctx->devices_status == STATUS_EXHAUSTED) || (opencl_ctx->devices_status == STATUS_CRACKED))
|
||||||
{
|
{
|
||||||
unlink (eff_restore_file);
|
unlink (data.eff_restore_file);
|
||||||
unlink (new_restore_file);
|
unlink (data.new_restore_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3665,7 +3392,7 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opencl_ctx->run_main_level1 == false) break;
|
if (opencl_ctx->run_main_level1 == false) return -1;
|
||||||
|
|
||||||
// free memory
|
// free memory
|
||||||
|
|
||||||
@ -3708,6 +3435,304 @@ int main (int argc, char **argv)
|
|||||||
global_free (words_progress_done);
|
global_free (words_progress_done);
|
||||||
global_free (words_progress_rejected);
|
global_free (words_progress_rejected);
|
||||||
global_free (words_progress_restored);
|
global_free (words_progress_restored);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* To help users a bit
|
||||||
|
*/
|
||||||
|
|
||||||
|
setup_console ();
|
||||||
|
|
||||||
|
setup_environment_variables ();
|
||||||
|
|
||||||
|
setup_umask ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Real init
|
||||||
|
*/
|
||||||
|
|
||||||
|
memset (&data, 0, sizeof (hc_global_data_t));
|
||||||
|
|
||||||
|
time_t proc_start;
|
||||||
|
|
||||||
|
time (&proc_start);
|
||||||
|
|
||||||
|
data.proc_start = proc_start;
|
||||||
|
|
||||||
|
hc_thread_mutex_init (mux_display);
|
||||||
|
hc_thread_mutex_init (mux_hwmon);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* folder
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *install_folder = NULL;
|
||||||
|
char *shared_folder = NULL;
|
||||||
|
|
||||||
|
#if defined (INSTALL_FOLDER)
|
||||||
|
install_folder = INSTALL_FOLDER;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (SHARED_FOLDER)
|
||||||
|
shared_folder = SHARED_FOLDER;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
folder_config_t *folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t));
|
||||||
|
|
||||||
|
folder_config_init (folder_config, install_folder, shared_folder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* commandline parameters
|
||||||
|
*/
|
||||||
|
|
||||||
|
user_options_t *user_options = (user_options_t *) mymalloc (sizeof (user_options_t));
|
||||||
|
|
||||||
|
data.user_options = user_options;
|
||||||
|
|
||||||
|
user_options_init (user_options, argc, argv);
|
||||||
|
|
||||||
|
const int rc_user_options_parse = user_options_parse (user_options, argc, argv);
|
||||||
|
|
||||||
|
if (rc_user_options_parse == -1) return -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* session
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *eff_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||||
|
char *new_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
|
||||||
|
|
||||||
|
snprintf (eff_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore", folder_config->session_dir, user_options->session);
|
||||||
|
snprintf (new_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore.new", folder_config->session_dir, user_options->session);
|
||||||
|
|
||||||
|
data.eff_restore_file = eff_restore_file;
|
||||||
|
data.new_restore_file = new_restore_file;
|
||||||
|
|
||||||
|
restore_data_t *rd = init_restore (argc, argv, user_options);
|
||||||
|
|
||||||
|
data.rd = rd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* restore file
|
||||||
|
*/
|
||||||
|
|
||||||
|
int myargc = argc;
|
||||||
|
char **myargv = argv;
|
||||||
|
|
||||||
|
if (user_options->restore == true)
|
||||||
|
{
|
||||||
|
read_restore (eff_restore_file, rd);
|
||||||
|
|
||||||
|
if (rd->version < RESTORE_VERSION_MIN)
|
||||||
|
{
|
||||||
|
log_error ("ERROR: Incompatible restore-file version");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
myargc = rd->argc;
|
||||||
|
myargv = rd->argv;
|
||||||
|
|
||||||
|
#if defined (_POSIX)
|
||||||
|
rd->pid = getpid ();
|
||||||
|
#elif defined (_WIN)
|
||||||
|
rd->pid = GetCurrentProcessId ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
user_options_init (user_options, myargc, myargv);
|
||||||
|
|
||||||
|
const int rc_user_options_parse = user_options_parse (user_options, myargc, myargv);
|
||||||
|
|
||||||
|
if (rc_user_options_parse == -1) return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_options->version == true)
|
||||||
|
{
|
||||||
|
log_info ("%s", VERSION_TAG);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user_options->usage == true)
|
||||||
|
{
|
||||||
|
usage_big_print (PROGNAME);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
const int rc_user_options_extra_init = user_options_extra_init (user_options, myargc, myargv, user_options_extra);
|
||||||
|
|
||||||
|
if (rc_user_options_extra_init == -1) return -1;
|
||||||
|
|
||||||
|
const int rc_user_options_sanity = user_options_sanity (user_options, myargc, myargv, user_options_extra);
|
||||||
|
|
||||||
|
if (rc_user_options_sanity == -1) return -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prepare seeding for random number generator, required by logfile and rules generator
|
||||||
|
*/
|
||||||
|
|
||||||
|
setup_seeding (user_options, proc_start);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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");
|
||||||
|
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
|
||||||
|
welcome_screen (user_options, &proc_start);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tuning db
|
||||||
|
*/
|
||||||
|
|
||||||
|
char tuning_db_file[256] = { 0 };
|
||||||
|
|
||||||
|
snprintf (tuning_db_file, sizeof (tuning_db_file) - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE);
|
||||||
|
|
||||||
|
tuning_db_t *tuning_db = tuning_db_init (tuning_db_file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* induction directory
|
||||||
|
*/
|
||||||
|
|
||||||
|
induct_ctx_t *induct_ctx = (induct_ctx_t *) mymalloc (sizeof (induct_ctx_t));
|
||||||
|
|
||||||
|
data.induct_ctx = induct_ctx;
|
||||||
|
|
||||||
|
const int rc_induct_ctx_init = induct_ctx_init (induct_ctx, user_options, folder_config, proc_start);
|
||||||
|
|
||||||
|
if (rc_induct_ctx_init == -1) return -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* outfile-check directory
|
||||||
|
*/
|
||||||
|
|
||||||
|
outcheck_ctx_t *outcheck_ctx = (outcheck_ctx_t *) mymalloc (sizeof (outcheck_ctx_t));
|
||||||
|
|
||||||
|
data.outcheck_ctx = outcheck_ctx;
|
||||||
|
|
||||||
|
const int rc_outcheck_ctx_init = outcheck_ctx_init (outcheck_ctx, user_options, folder_config);
|
||||||
|
|
||||||
|
if (rc_outcheck_ctx_init == -1) return -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cpu affinity
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (user_options->cpu_affinity)
|
||||||
|
{
|
||||||
|
set_cpu_affinity (user_options->cpu_affinity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init OpenCL library loader
|
||||||
|
*/
|
||||||
|
|
||||||
|
opencl_ctx_t *opencl_ctx = (opencl_ctx_t *) mymalloc (sizeof (opencl_ctx_t));
|
||||||
|
|
||||||
|
data.opencl_ctx = opencl_ctx;
|
||||||
|
|
||||||
|
const int rc_opencl_init = opencl_ctx_init (opencl_ctx, user_options);
|
||||||
|
|
||||||
|
if (rc_opencl_init == -1)
|
||||||
|
{
|
||||||
|
log_error ("ERROR: opencl_ctx_init() failed");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init OpenCL devices
|
||||||
|
*/
|
||||||
|
|
||||||
|
const int rc_devices_init = opencl_ctx_devices_init (opencl_ctx, user_options);
|
||||||
|
|
||||||
|
if (rc_devices_init == -1)
|
||||||
|
{
|
||||||
|
log_error ("ERROR: opencl_ctx_devices_init() failed");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* status, monitor and outfile remove threads
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint outer_threads_cnt = 0;
|
||||||
|
|
||||||
|
hc_thread_t *outer_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
|
||||||
|
|
||||||
|
data.shutdown_outer = 0;
|
||||||
|
|
||||||
|
if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false)
|
||||||
|
{
|
||||||
|
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||||
|
{
|
||||||
|
hc_thread_create (outer_threads[outer_threads_cnt], thread_keypress, NULL);
|
||||||
|
|
||||||
|
outer_threads_cnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* outer loop
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (user_options->benchmark == true)
|
||||||
|
{
|
||||||
|
user_options->quiet = true;
|
||||||
|
|
||||||
|
if (user_options->hash_mode_chgd == true)
|
||||||
|
{
|
||||||
|
const int rc = outer_loop (user_options, user_options_extra, myargc, myargv, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, opencl_ctx);
|
||||||
|
|
||||||
|
if (rc == -1) return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int algorithm_pos = 0; algorithm_pos < DEFAULT_BENCHMARK_ALGORITHMS_CNT; algorithm_pos++)
|
||||||
|
{
|
||||||
|
user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos];
|
||||||
|
|
||||||
|
const int rc = outer_loop (user_options, user_options_extra, myargc, myargv, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, opencl_ctx);
|
||||||
|
|
||||||
|
if (rc == -1) return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const int rc = outer_loop (user_options, user_options_extra, myargc, myargv, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, opencl_ctx);
|
||||||
|
|
||||||
|
if (rc == -1) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for outer threads
|
// wait for outer threads
|
||||||
|
Loading…
Reference in New Issue
Block a user