From f9ec232b9bf3eefb326033eb1cbd4dee1abcfe47 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 22 Sep 2016 15:50:49 +0200 Subject: [PATCH] Get rid of attack_kern variable in data. context --- include/autotune.h | 2 +- include/opencl.h | 2 +- include/status.h | 2 +- include/types.h | 1 - src/autotune.c | 13 +++++++------ src/dispatch.c | 10 +++++----- src/hashcat.c | 1 - src/opencl.c | 20 ++++++++++---------- src/status.c | 28 ++++++++++++++-------------- src/wordlist.c | 8 ++++---- 10 files changed, 43 insertions(+), 44 deletions(-) diff --git a/include/autotune.h b/include/autotune.h index 757284a80..b6fa1b41f 100644 --- a/include/autotune.h +++ b/include/autotune.h @@ -6,7 +6,7 @@ #ifndef _AUTOTUNE_H #define _AUTOTUNE_H -int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options); +int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const user_options_extra_t *user_options_extra); void *thread_autotune (void *p); diff --git a/include/opencl.h b/include/opencl.h index 03bb7d930..bda2842d9 100644 --- a/include/opencl.h +++ b/include/opencl.h @@ -81,7 +81,7 @@ int run_kernel_amp (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, c int run_kernel_memset (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cl_mem buf, const uint value, const uint num); int run_kernel_bzero (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cl_mem buf, const size_t size); -int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const uint pws_cnt); +int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const uint pws_cnt); int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const uint pws_cnt); diff --git a/include/status.h b/include/status.h index 7b603430e..fb4de88ee 100644 --- a/include/status.h +++ b/include/status.h @@ -11,7 +11,7 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries); -void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const user_options_t *user_options); +void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra); void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra); void status_benchmark_automate (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig); void status_benchmark (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const user_options_t *user_options); diff --git a/include/types.h b/include/types.h index 48ded0481..dd4442218 100644 --- a/include/types.h +++ b/include/types.h @@ -965,7 +965,6 @@ typedef struct - u32 attack_kern; u32 quiet; u32 force; u32 pw_min; diff --git a/src/autotune.c b/src/autotune.c index ae2e26295..399923282 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -54,7 +54,7 @@ static double try_run (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param return exec_ms_prev; } -int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options) +int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const user_options_extra_t *user_options_extra) { const double target_ms = opencl_ctx->target_ms; @@ -96,7 +96,7 @@ int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon const u32 kernel_power_max = device_param->device_processors * device_param->kernel_threads * kernel_accel_max; - if (data.attack_kern == ATTACK_KERN_BF) + if (user_options_extra->attack_kern == ATTACK_KERN_BF) { run_kernel_memset (opencl_ctx, device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t)); } @@ -317,11 +317,12 @@ void *thread_autotune (void *p) if (device_param->skipped) return NULL; - user_options_t *user_options = data.user_options; - hashconfig_t *hashconfig = data.hashconfig; - opencl_ctx_t *opencl_ctx = data.opencl_ctx; + user_options_t *user_options = data.user_options; + user_options_extra_t *user_options_extra = data.user_options_extra; + hashconfig_t *hashconfig = data.hashconfig; + opencl_ctx_t *opencl_ctx = data.opencl_ctx; - autotune (opencl_ctx, device_param, hashconfig, user_options); + autotune (opencl_ctx, device_param, hashconfig, user_options, user_options_extra); return NULL; } diff --git a/src/dispatch.c b/src/dispatch.c index af38e06e3..e51d0adf0 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -123,7 +123,7 @@ void *thread_calc_stdin (void *p) char *buf = (char *) mymalloc (HCBUFSIZ_LARGE); - const uint attack_kern = data.attack_kern; + const uint attack_kern = user_options_extra->attack_kern; while (opencl_ctx->run_thread_level1 == true) { @@ -208,7 +208,7 @@ void *thread_calc_stdin (void *p) if (pws_cnt) { - run_copy (opencl_ctx, device_param, hashconfig, user_options, pws_cnt); + run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt); run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, pws_cnt); @@ -249,7 +249,7 @@ void *thread_calc (void *p) opencl_ctx_t *opencl_ctx = data.opencl_ctx; const uint attack_mode = user_options->attack_mode; - const uint attack_kern = data.attack_kern; + const uint attack_kern = user_options_extra->attack_kern; if (attack_mode == ATTACK_MODE_BF) { @@ -268,7 +268,7 @@ void *thread_calc (void *p) if (pws_cnt) { - run_copy (opencl_ctx, device_param, hashconfig, user_options, pws_cnt); + run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt); run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, pws_cnt); @@ -460,7 +460,7 @@ void *thread_calc (void *p) if (pws_cnt) { - run_copy (opencl_ctx, device_param, hashconfig, user_options, pws_cnt); + run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt); run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, pws_cnt); diff --git a/src/hashcat.c b/src/hashcat.c index 722d51e73..6e3c07060 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -272,7 +272,6 @@ int main (int argc, char **argv) { data.force = user_options->force; data.quiet = user_options->quiet; - data.attack_kern = user_options_extra->attack_kern; } if (user_options->version) diff --git a/src/opencl.c b/src/opencl.c index 5d20f682c..6842d5ef2 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -865,11 +865,11 @@ int run_kernel_bzero (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, return run_kernel_memset (opencl_ctx, device_param, buf, 0, size); } -int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const uint pws_cnt) +int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const uint pws_cnt) { cl_int CL_err = CL_SUCCESS; - if (data.attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL); @@ -880,7 +880,7 @@ int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon return -1; } } - else if (data.attack_kern == ATTACK_KERN_COMBI) + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { if (user_options->attack_mode == ATTACK_MODE_COMBI) { @@ -945,7 +945,7 @@ int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon return -1; } } - else if (data.attack_kern == ATTACK_KERN_BF) + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) { const u64 off = device_param->words_off; @@ -983,13 +983,13 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash uint highest_pw_len = 0; - if (data.attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { } - else if (data.attack_kern == ATTACK_KERN_COMBI) + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { } - else if (data.attack_kern == ATTACK_KERN_BF) + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) { highest_pw_len = device_param->kernel_params_mp_l_buf32[4] + device_param->kernel_params_mp_l_buf32[5]; @@ -1022,9 +1022,9 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) innerloop_step = device_param->kernel_loops; else innerloop_step = 1; - if (data.attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = data.kernel_rules_cnt; - else if (data.attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = data.combs_cnt; - else if (data.attack_kern == ATTACK_KERN_BF) innerloop_cnt = data.bfs_cnt; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = data.kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = data.combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = data.bfs_cnt; // innerloops diff --git a/src/status.c b/src/status.c index 5c01551fd..d4bd0635f 100644 --- a/src/status.c +++ b/src/status.c @@ -137,7 +137,7 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en return exec_ms_sum / exec_ms_cnt; } -void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const user_options_t *user_options) +void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra) { if (opencl_ctx->devices_status == STATUS_INIT) { @@ -228,18 +228,18 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t * { progress_skip = MIN (user_options->skip, data.words_base) * hashes->salts_cnt; - if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.kernel_rules_cnt; - else if (data.attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt; - else if (data.attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt; } if (user_options->limit) { progress_end = MIN (user_options->limit, data.words_base) * hashes->salts_cnt; - if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.kernel_rules_cnt; - else if (data.attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt; - else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt; } u64 progress_cur_relative_skip = progress_cur - progress_skip; @@ -300,7 +300,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c if (user_options->machine_readable == true) { - status_display_machine_readable (opencl_ctx, hashes, user_options); + status_display_machine_readable (opencl_ctx, hashes, user_options, user_options_extra); return; } @@ -701,18 +701,18 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c { progress_skip = MIN (user_options->skip, data.words_base) * hashes->salts_cnt; - if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.kernel_rules_cnt; - else if (data.attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt; - else if (data.attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt; } if (user_options->limit) { progress_end = MIN (user_options->limit, data.words_base) * hashes->salts_cnt; - if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.kernel_rules_cnt; - else if (data.attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt; - else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt; } u64 progress_cur_relative_skip = progress_cur - progress_skip; diff --git a/src/wordlist.c b/src/wordlist.c index 6fb61c24c..d672cfa4e 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -323,11 +323,11 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u { u64 keyspace = cached_cnt; - if (data.attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { keyspace *= data.kernel_rules_cnt; } - else if (data.attack_kern == ATTACK_KERN_COMBI) + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { keyspace *= data.combs_cnt; } @@ -386,11 +386,11 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u if (len < PW_MAX1) { - if (data.attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { cnt += data.kernel_rules_cnt; } - else if (data.attack_kern == ATTACK_KERN_COMBI) + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { cnt += data.combs_cnt; }