From 84f96c4ddab67517eda38613a3cad10e7fdff423 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 29 Sep 2016 15:19:12 +0200 Subject: [PATCH] Add cpt_ctx_t --- include/cpt.h | 17 ++++++++++++++++ include/hash_management.h | 2 +- include/opencl.h | 2 +- include/status.h | 2 +- include/types.h | 26 ++++++++++++------------- include/weak_hash.h | 2 +- src/Makefile | 2 +- src/cpt.c | 37 +++++++++++++++++++++++++++++++++++ src/dispatch.c | 8 +++++--- src/hash_management.c | 12 ++++++------ src/hashcat.c | 41 ++++++++++++++++++++++++--------------- src/monitor.c | 3 ++- src/opencl.c | 4 ++-- src/status.c | 18 ++++++++--------- src/terminal.c | 3 ++- src/weak_hash.c | 4 ++-- 16 files changed, 125 insertions(+), 58 deletions(-) create mode 100644 include/cpt.h create mode 100644 src/cpt.c diff --git a/include/cpt.h b/include/cpt.h new file mode 100644 index 000000000..7242e9183 --- /dev/null +++ b/include/cpt.h @@ -0,0 +1,17 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifndef _CPT_H +#define _CPT_H + +#include +#include +#include + +int cpt_ctx_init (cpt_ctx_t *cpt_ctx); +void cpt_ctx_destroy (cpt_ctx_t *cpt_ctx); +void cpt_ctx_reset (cpt_ctx_t *cpt_ctx); + +#endif // _CPT_H diff --git a/include/hash_management.h b/include/hash_management.h index 5c08aed69..66f0e2951 100644 --- a/include/hash_management.h +++ b/include/hash_management.h @@ -15,7 +15,7 @@ void save_hash (const user_options_t *user_options, const hashconfig_t *hashconf void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, plain_t *plain); -int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos); +int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, const uint salt_pos); 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); diff --git a/include/opencl.h b/include/opencl.h index 773f96faa..4645a970c 100644 --- a/include/opencl.h +++ b/include/opencl.h @@ -34,7 +34,7 @@ int run_kernel_bzero (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, 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 combinator_ctx_t *combinator_ctx, 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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const outfile_ctx_t *outfile_ctx, const uint pws_cnt); +int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const outfile_ctx_t *outfile_ctx, const uint pws_cnt); int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options); void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx); diff --git a/include/status.h b/include/status.h index ccc3fc888..d9aa8b4df 100644 --- a/include/status.h +++ b/include/status.h @@ -12,7 +12,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 hwmon_ctx_t *hwmon_ctx, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx); -void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx); +void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const cpt_ctx_t *cpt_ctx, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx); 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 b0fba5002..91dcb23ae 100644 --- a/include/types.h +++ b/include/types.h @@ -14,6 +14,9 @@ #include #include +#define CPT_BUF 0x20000 +#define PARAMCNT 64 + #if defined (_WIN) #include #if defined (_BASETSD_H) @@ -475,8 +478,6 @@ typedef struct } comb_t; -#define CPT_BUF 0x20000 - typedef struct { u32 cracked; @@ -506,8 +507,6 @@ typedef struct } wordr_t; -#define PARAMCNT 64 - typedef struct __hc_device_param hc_device_param_t; struct __hc_device_param @@ -1217,6 +1216,15 @@ typedef struct } hwmon_ctx_t; +typedef struct +{ + cpt_t *cpt_buf; + int cpt_pos; + time_t cpt_start; + u64 cpt_total; + +} cpt_ctx_t; + typedef struct { /** @@ -1225,6 +1233,7 @@ typedef struct bitmap_ctx_t *bitmap_ctx; combinator_ctx_t *combinator_ctx; + cpt_ctx_t *cpt_ctx; debugfile_ctx_t *debugfile_ctx; hashconfig_t *hashconfig; hashes_t *hashes; @@ -1250,15 +1259,6 @@ typedef struct bool shutdown_inner; bool shutdown_outer; - /** - * crack-per-time - */ - - cpt_t cpt_buf[CPT_BUF]; - int cpt_pos; - time_t cpt_start; - u64 cpt_total; - /** * status, timer */ diff --git a/include/weak_hash.h b/include/weak_hash.h index f76908f41..f7bcecbac 100644 --- a/include/weak_hash.h +++ b/include/weak_hash.h @@ -6,6 +6,6 @@ #ifndef _WEAK_HASH_H #define _WEAK_HASH_H -void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos); +void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, const uint salt_pos); #endif // _WEAK_HASH_H diff --git a/src/Makefile b/src/Makefile index 8694c3156..9d90de5f9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -163,7 +163,7 @@ LFLAGS_CROSS_WIN := -lpsapi ## Objects ## -OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist +OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o) diff --git a/src/cpt.c b/src/cpt.c new file mode 100644 index 000000000..3f87a955e --- /dev/null +++ b/src/cpt.c @@ -0,0 +1,37 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "memory.h" +#include "logging.h" +#include "cpt.h" + +int cpt_ctx_init (cpt_ctx_t *cpt_ctx) +{ + cpt_ctx->cpt_buf = (cpt_t *) mycalloc (CPT_BUF, sizeof (cpt_t)); + + cpt_ctx->cpt_total = 0; + cpt_ctx->cpt_pos = 0; + cpt_ctx->cpt_start = time (NULL); + + return 0; +} + +void cpt_ctx_destroy (cpt_ctx_t *cpt_ctx) +{ + myfree (cpt_ctx->cpt_buf); + + myfree (cpt_ctx); +} + +void cpt_ctx_reset (cpt_ctx_t *cpt_ctx) +{ + memset (cpt_ctx->cpt_buf, 0, CPT_BUF * sizeof (cpt_t)); + + cpt_ctx->cpt_total = 0; + cpt_ctx->cpt_pos = 0; + cpt_ctx->cpt_start = time (NULL); +} diff --git a/src/dispatch.c b/src/dispatch.c index 1e9b558f2..a66d47410 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -119,6 +119,7 @@ void *thread_calc_stdin (void *p) user_options_extra_t *user_options_extra = data.user_options_extra; hashconfig_t *hashconfig = data.hashconfig; hashes_t *hashes = data.hashes; + cpt_ctx_t *cpt_ctx = data.cpt_ctx; straight_ctx_t *straight_ctx = data.straight_ctx; combinator_ctx_t *combinator_ctx = data.combinator_ctx; mask_ctx_t *mask_ctx = data.mask_ctx; @@ -214,7 +215,7 @@ void *thread_calc_stdin (void *p) { run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt); - run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt); + run_cracker (opencl_ctx, device_param, hashconfig, hashes, cpt_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt); device_param->pws_cnt = 0; @@ -250,6 +251,7 @@ void *thread_calc (void *p) user_options_extra_t *user_options_extra = data.user_options_extra; hashconfig_t *hashconfig = data.hashconfig; hashes_t *hashes = data.hashes; + cpt_ctx_t *cpt_ctx = data.cpt_ctx; straight_ctx_t *straight_ctx = data.straight_ctx; combinator_ctx_t *combinator_ctx = data.combinator_ctx; mask_ctx_t *mask_ctx = data.mask_ctx; @@ -278,7 +280,7 @@ void *thread_calc (void *p) { run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt); - run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt); + run_cracker (opencl_ctx, device_param, hashconfig, hashes, cpt_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt); device_param->pws_cnt = 0; @@ -474,7 +476,7 @@ void *thread_calc (void *p) { run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt); - run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt); + run_cracker (opencl_ctx, device_param, hashconfig, hashes, cpt_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt); device_param->pws_cnt = 0; diff --git a/src/hash_management.c b/src/hash_management.c index 9cabe90b8..bbb517e2d 100644 --- a/src/hash_management.c +++ b/src/hash_management.c @@ -507,7 +507,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons } } -int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos) +int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, const uint salt_pos) { salt_t *salt_buf = &hashes->salts_buf[salt_pos]; @@ -582,14 +582,14 @@ int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co { hc_thread_mutex_lock (mux_display); - data.cpt_buf[data.cpt_pos].timestamp = time (NULL); - data.cpt_buf[data.cpt_pos].cracked = cpt_cracked; + cpt_ctx->cpt_buf[cpt_ctx->cpt_pos].timestamp = time (NULL); + cpt_ctx->cpt_buf[cpt_ctx->cpt_pos].cracked = cpt_cracked; - data.cpt_pos++; + cpt_ctx->cpt_pos++; - data.cpt_total += cpt_cracked; + cpt_ctx->cpt_total += cpt_cracked; - if (data.cpt_pos == CPT_BUF) data.cpt_pos = 0; + if (cpt_ctx->cpt_pos == CPT_BUF) cpt_ctx->cpt_pos = 0; hc_thread_mutex_unlock (mux_display); } diff --git a/src/hashcat.c b/src/hashcat.c index 881cc7c5f..b37c5d620 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -26,6 +26,7 @@ #include "autotune.h" #include "bitmap.h" #include "combinator.h" +#include "cpt.h" #include "debugfile.h" #include "dictstat.h" #include "dispatch.h" @@ -67,7 +68,7 @@ const char *version_tag = VERSION_TAG; // inner2_loop iterates through wordlists, then calls kernel execution -static int inner2_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, logfile_ctx_t *logfile_ctx, induct_ctx_t *induct_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hwmon_ctx_t *hwmon_ctx, hashconfig_t *hashconfig, hashes_t *hashes, wl_data_t *wl_data, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx) +static int inner2_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, logfile_ctx_t *logfile_ctx, induct_ctx_t *induct_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hwmon_ctx_t *hwmon_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, wl_data_t *wl_data, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx) { //opencl_ctx->run_main_level1 = true; //opencl_ctx->run_main_level2 = true; @@ -83,12 +84,6 @@ static int inner2_loop (user_options_t *user_options, user_options_extra_t *user memset (data.words_progress_rejected, 0, hashes->salts_cnt * sizeof (u64)); memset (data.words_progress_restored, 0, hashes->salts_cnt * sizeof (u64)); - memset (data.cpt_buf, 0, CPT_BUF * sizeof (cpt_t)); - - data.cpt_total = 0; - data.cpt_pos = 0; - data.cpt_start = time (NULL); - data.words_cur = 0; restore_data_t *rd = restore_ctx->rd; @@ -111,6 +106,8 @@ static int inner2_loop (user_options_t *user_options, user_options_extra_t *user opencl_session_reset (opencl_ctx); + cpt_ctx_reset (cpt_ctx); + // figure out wordlist based workload if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) @@ -462,7 +459,7 @@ static int inner2_loop (user_options_t *user_options, user_options_extra_t *user if (hashes->digests_saved != hashes->digests_done) log_info (""); - status_display (opencl_ctx, hwmon_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx); + status_display (opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx); log_info (""); } @@ -470,7 +467,7 @@ static int inner2_loop (user_options_t *user_options, user_options_extra_t *user { if (user_options->status == true) { - status_display (opencl_ctx, hwmon_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx); + status_display (opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx); log_info (""); } @@ -487,7 +484,7 @@ static int inner2_loop (user_options_t *user_options, user_options_extra_t *user { for (induct_ctx->induction_dictionaries_pos = 0; induct_ctx->induction_dictionaries_pos < induct_ctx->induction_dictionaries_cnt; induct_ctx->induction_dictionaries_pos++) { - const int rc_inner2_loop = inner2_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, wl_data, straight_ctx, combinator_ctx, mask_ctx); + const int rc_inner2_loop = inner2_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx); if (rc_inner2_loop == -1) return -1; @@ -507,7 +504,7 @@ static int inner2_loop (user_options_t *user_options, user_options_extra_t *user // inner1_loop iterates through masks, then calls inner2_loop -static int inner1_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, logfile_ctx_t *logfile_ctx, induct_ctx_t *induct_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hwmon_ctx_t *hwmon_ctx, hashconfig_t *hashconfig, hashes_t *hashes, wl_data_t *wl_data, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx) +static int inner1_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, logfile_ctx_t *logfile_ctx, induct_ctx_t *induct_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hwmon_ctx_t *hwmon_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, wl_data_t *wl_data, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx) { //opencl_ctx->run_main_level1 = true; //opencl_ctx->run_main_level2 = true; @@ -1162,7 +1159,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user straight_ctx->dicts_pos = dicts_pos; - const int rc_inner2_loop = inner2_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, wl_data, straight_ctx, combinator_ctx, mask_ctx); + const int rc_inner2_loop = inner2_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx); if (rc_inner2_loop == -1) return -1; @@ -1171,7 +1168,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user } else { - const int rc_inner2_loop = inner2_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, wl_data, straight_ctx, combinator_ctx, mask_ctx); + const int rc_inner2_loop = inner2_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx); if (rc_inner2_loop == -1) return -1; } @@ -1326,6 +1323,16 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_ bitmap_ctx_init (bitmap_ctx, user_options, hashconfig, hashes); + /** + * cracks-per-time allocate buffer + */ + + cpt_ctx_t *cpt_ctx = (cpt_ctx_t *) mymalloc (sizeof (cpt_ctx_t)); + + data.cpt_ctx = cpt_ctx; + + cpt_ctx_init (cpt_ctx); + /** * Wordlist allocate buffer */ @@ -1512,7 +1519,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_ for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { - weak_hash_check (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, salt_pos); + weak_hash_check (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, cpt_ctx, salt_pos); } } @@ -1583,7 +1590,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_ mask_ctx->masks_pos = masks_pos; - const int rc_inner1_loop = inner1_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, wl_data, straight_ctx, combinator_ctx, mask_ctx); + const int rc_inner1_loop = inner1_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx); if (rc_inner1_loop == -1) return -1; @@ -1592,7 +1599,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_ } else { - const int rc_inner1_loop = inner1_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, wl_data, straight_ctx, combinator_ctx, mask_ctx); + const int rc_inner1_loop = inner1_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx); if (rc_inner1_loop == -1) return -1; } @@ -1661,6 +1668,8 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_ wl_data_destroy (wl_data); + cpt_ctx_destroy (cpt_ctx); + return 0; } diff --git a/src/monitor.c b/src/monitor.c index e0bf28a85..a7cda14d3 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -44,6 +44,7 @@ void *thread_monitor (void *p) user_options_extra_t *user_options_extra = data.user_options_extra; hashconfig_t *hashconfig = data.hashconfig; hashes_t *hashes = data.hashes; + cpt_ctx_t *cpt_ctx = data.cpt_ctx; straight_ctx_t *straight_ctx = data.straight_ctx; combinator_ctx_t *combinator_ctx = data.combinator_ctx; mask_ctx_t *mask_ctx = data.mask_ctx; @@ -348,7 +349,7 @@ void *thread_monitor (void *p) if (user_options->quiet == false) log_info (""); - status_display (opencl_ctx, hwmon_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx); + status_display (opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx); if (user_options->quiet == false) log_info (""); diff --git a/src/opencl.c b/src/opencl.c index 8b04f7c50..971a7718c 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -1004,7 +1004,7 @@ int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon return 0; } -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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const outfile_ctx_t *outfile_ctx, const uint pws_cnt) +int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const outfile_ctx_t *outfile_ctx, const uint pws_cnt) { char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE); @@ -1291,7 +1291,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash if (user_options->benchmark == false) { - check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, salt_pos); + check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, cpt_ctx, salt_pos); } /** diff --git a/src/status.c b/src/status.c index 5366ab737..762bac610 100644 --- a/src/status.c +++ b/src/status.c @@ -313,7 +313,7 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hwmon_ctx_ fflush (out); } -void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx) +void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const cpt_ctx_t *cpt_ctx, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx) { if (opencl_ctx->devices_status == STATUS_INIT) { @@ -893,8 +893,8 @@ void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, con for (int i = 0; i < CPT_BUF; i++) { - const uint cracked = data.cpt_buf[i].cracked; - const time_t timestamp = data.cpt_buf[i].timestamp; + const uint cracked = cpt_ctx->cpt_buf[i].cracked; + const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp; if ((timestamp + 60) > now) { @@ -914,11 +914,11 @@ void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, con double ms_real = ms_running - ms_paused; - double cpt_avg_min = (double) data.cpt_total / ((ms_real / 1000) / 60); - double cpt_avg_hour = (double) data.cpt_total / ((ms_real / 1000) / 3600); - double cpt_avg_day = (double) data.cpt_total / ((ms_real / 1000) / 86400); + double cpt_avg_min = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 60); + double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 3600); + double cpt_avg_day = (double) cpt_ctx->cpt_total / ((ms_real / 1000) / 86400); - if ((data.cpt_start + 86400) < now) + if ((cpt_ctx->cpt_start + 86400) < now) { log_info ("Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, @@ -928,7 +928,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, con cpt_avg_hour, cpt_avg_day); } - else if ((data.cpt_start + 3600) < now) + else if ((cpt_ctx->cpt_start + 3600) < now) { log_info ("Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, @@ -937,7 +937,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hwmon_ctx_t *hwmon_ctx, con cpt_avg_hour, cpt_avg_day); } - else if ((data.cpt_start + 60) < now) + else if ((cpt_ctx->cpt_start + 60) < now) { log_info ("Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, diff --git a/src/terminal.c b/src/terminal.c index 043d3e403..aad0661d4 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -144,6 +144,7 @@ void *thread_keypress (void *p) user_options_extra_t *user_options_extra = data.user_options_extra; hashconfig_t *hashconfig = data.hashconfig; hashes_t *hashes = data.hashes; + cpt_ctx_t *cpt_ctx = data.cpt_ctx; straight_ctx_t *straight_ctx = data.straight_ctx; combinator_ctx_t *combinator_ctx = data.combinator_ctx; mask_ctx_t *mask_ctx = data.mask_ctx; @@ -178,7 +179,7 @@ void *thread_keypress (void *p) log_info (""); - status_display (opencl_ctx, hwmon_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx); + status_display (opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx); log_info (""); diff --git a/src/weak_hash.c b/src/weak_hash.c index c3b8c70ec..79fc6dad4 100644 --- a/src/weak_hash.c +++ b/src/weak_hash.c @@ -10,7 +10,7 @@ #include "hash_management.h" #include "weak_hash.h" -void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos) +void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, const uint salt_pos) { salt_t *salt_buf = &hashes->salts_buf[salt_pos]; @@ -60,7 +60,7 @@ void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, * result */ - check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, salt_pos); + check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, cpt_ctx, salt_pos); /** * cleanup