From ee7fca82f5a2f1f8a0049c2a29778a85849adec4 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 12 Jun 2021 11:42:19 +0200 Subject: [PATCH] Scrypt Kernels: Re-enable scrypt based kernels to use kernel cache --- docs/changes.txt | 2 ++ src/backend.c | 61 ++++++++++++++++++++++---------------- src/modules/module_08900.c | 7 +---- src/modules/module_09300.c | 7 +---- src/modules/module_15700.c | 7 +---- src/modules/module_22700.c | 7 +---- src/modules/module_25600.c | 25 +++++++++++----- src/modules/module_25800.c | 25 +++++++++++----- 8 files changed, 75 insertions(+), 66 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 084d3033b..074e83110 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -50,6 +50,7 @@ - Performance Monitor: Add -S as a user suggestion to improve cracking performance in specific attack configurations - RAR3-p (Compressed): Fix workaround in unrar library in AES constant table generation to enable multi-threading support - RC4 Kernels: Improved performance by 20%+ for hash-modes Kerberos 5 (etype 23), MS Office (<= 2003) and PDF (<= 1.6) by using new RC4 code +- Scrypt Kernels: Re-enable scrypt based kernels to use kernel cache - Status Screen: Show currently running kernel type (pure, optimized) and generator type (host, device) - UTF8-to-UTF16: Replaced naive UTF8 to UTF16 conversion with true conversion for RAR3, AES Crypt, MultiBit HD (scrypt) and Umbraco HMAC-SHA1 @@ -63,6 +64,7 @@ - Hashrate: Innerloop hashrate prediction requires update because of the new salt_repeats feature and also respect _loop2 kernel runtime - Kernels: Add RC4 cipher to crypto library with optimized shared memory access pattern which will not cause any bank conflicts if -u <= 32 - Kernels: Add standalone true UTF8 to UTF16 converter kernel that runs after amplifier. Use OPTS_TYPE_POST_AMP_UTF16LE from plugin +- Kernel Cache: Add module_jit_build_options() string from modules to kernel cache checksum calculation - Modules: Recategorized HASH_CATEGORY option in various modules - Modules: Added hash categories HASH_CATEGORY_IMS and HASH_CATEGORY_CRYPTOCURRENCY_WALLET - Modules: Changed hash category of Python passlib from HASH_CATEGORY_GENERIC_KDF to HASH_CATEGORY_FRAMEWORK diff --git a/src/backend.c b/src/backend.c index bc3e00c0c..d868645b4 100644 --- a/src/backend.c +++ b/src/backend.c @@ -8676,29 +8676,11 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) #endif /** - * device_name_chksum + * device_name_chksum_amp_mp */ - char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); char *device_name_chksum_amp_mp = (char *) hcmalloc (HCBUFSIZ_TINY); - // The kernel source can depend on some JiT compiler macros which themself depend on the attack_modes. - // ATM this is relevant only for ATTACK_MODE_ASSOCIATION which slightly modifies ATTACK_MODE_STRAIGHT kernels. - - const u32 extra_value = (user_options->attack_mode == ATTACK_MODE_ASSOCIATION) ? ATTACK_MODE_ASSOCIATION : ATTACK_MODE_NONE; - - const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%d-%d-%d-%u-%s-%s-%s-%d-%u-%u", - backend_ctx->comptime, - backend_ctx->cuda_driver_version, - device_param->is_opencl, - device_param->opencl_platform_vendor_id, - device_param->device_name, - device_param->opencl_device_version, - device_param->opencl_driver_version, - device_param->vector_width, - hashconfig->kern_type, - extra_value); - const size_t dnclen_amp_mp = snprintf (device_name_chksum_amp_mp, HCBUFSIZ_TINY, "%d-%d-%d-%u-%s-%s-%s", backend_ctx->comptime, backend_ctx->cuda_driver_version, @@ -8710,12 +8692,6 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) md5_ctx_t md5_ctx; - md5_init (&md5_ctx); - md5_update (&md5_ctx, (u32 *) device_name_chksum, dnclen); - md5_final (&md5_ctx); - - snprintf (device_name_chksum, HCBUFSIZ_TINY, "%08x", md5_ctx.h[0]); - md5_init (&md5_ctx); md5_update (&md5_ctx, (u32 *) device_name_chksum_amp_mp, dnclen_amp_mp); md5_final (&md5_ctx); @@ -8934,6 +8910,38 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: build_options_module '%s'", device_id + 1, build_options_module_buf); #endif + /** + * device_name_chksum + */ + + char *device_name_chksum = (char *) hcmalloc (HCBUFSIZ_TINY); + + // The kernel source can depend on some JiT compiler macros which themself depend on the attack_modes. + // ATM this is relevant only for ATTACK_MODE_ASSOCIATION which slightly modifies ATTACK_MODE_STRAIGHT kernels. + + const u32 extra_value = (user_options->attack_mode == ATTACK_MODE_ASSOCIATION) ? ATTACK_MODE_ASSOCIATION : ATTACK_MODE_NONE; + + const size_t dnclen = snprintf (device_name_chksum, HCBUFSIZ_TINY, "%d-%d-%d-%u-%s-%s-%s-%d-%u-%u-%s", + backend_ctx->comptime, + backend_ctx->cuda_driver_version, + device_param->is_opencl, + device_param->opencl_platform_vendor_id, + device_param->device_name, + device_param->opencl_device_version, + device_param->opencl_driver_version, + device_param->vector_width, + hashconfig->kern_type, + extra_value, + build_options_module_buf); + + md5_ctx_t md5_ctx; + + md5_init (&md5_ctx); + md5_update (&md5_ctx, (u32 *) device_name_chksum, dnclen); + md5_final (&md5_ctx); + + snprintf (device_name_chksum, HCBUFSIZ_TINY, "%08x", md5_ctx.h[0]); + /** * kernel source filename */ @@ -8971,6 +8979,8 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) } hcfree (build_options_module_buf); + + hcfree (device_name_chksum); } /** @@ -9082,7 +9092,6 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) if (hc_clUnloadPlatformCompiler (hashcat_ctx, platform_id) == -1) return -1; } - hcfree (device_name_chksum); hcfree (device_name_chksum_amp_mp); // some algorithm collide too fast, make that impossible diff --git a/src/modules/module_08900.c b/src/modules/module_08900.c index dac69671c..de2a936d6 100644 --- a/src/modules/module_08900.c +++ b/src/modules/module_08900.c @@ -243,11 +243,6 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - bool module_warmup_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return true; @@ -438,7 +433,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; module_ctx->module_kernel_loops_max = module_kernel_loops_max; diff --git a/src/modules/module_09300.c b/src/modules/module_09300.c index 5408f71b8..05dcbc585 100644 --- a/src/modules/module_09300.c +++ b/src/modules/module_09300.c @@ -235,11 +235,6 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - bool module_warmup_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return true; @@ -395,7 +390,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; module_ctx->module_kernel_loops_max = module_kernel_loops_max; diff --git a/src/modules/module_15700.c b/src/modules/module_15700.c index 16b0ceac0..cb2d939ab 100644 --- a/src/modules/module_15700.c +++ b/src/modules/module_15700.c @@ -256,11 +256,6 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - bool module_warmup_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return true; @@ -504,7 +499,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; module_ctx->module_kernel_loops_max = module_kernel_loops_max; diff --git a/src/modules/module_22700.c b/src/modules/module_22700.c index 51409e06c..599144173 100644 --- a/src/modules/module_22700.c +++ b/src/modules/module_22700.c @@ -243,11 +243,6 @@ u64 module_extra_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - bool module_warmup_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return true; @@ -443,7 +438,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; module_ctx->module_kernel_loops_max = module_kernel_loops_max; diff --git a/src/modules/module_25600.c b/src/modules/module_25600.c index 561c04d77..ed48b2476 100644 --- a/src/modules/module_25600.c +++ b/src/modules/module_25600.c @@ -59,6 +59,20 @@ typedef struct bcrypt_tmp } bcrypt_tmp_t; +u32 module_kernel_loops_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_min = 1024; + + return kernel_loops_min; +} + +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1024; + + return kernel_loops_max; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (bcrypt_tmp_t); @@ -66,11 +80,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) { char *jit_build_options = NULL; @@ -321,11 +330,11 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; - module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; + module_ctx->module_kernel_loops_min = module_kernel_loops_min; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; module_ctx->module_kern_type = module_kern_type; diff --git a/src/modules/module_25800.c b/src/modules/module_25800.c index 154e9bc5c..964588174 100644 --- a/src/modules/module_25800.c +++ b/src/modules/module_25800.c @@ -59,6 +59,20 @@ typedef struct bcrypt_tmp } bcrypt_tmp_t; +u32 module_kernel_loops_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_min = 1024; + + return kernel_loops_min; +} + +u32 module_kernel_loops_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 kernel_loops_max = 1024; + + return kernel_loops_max; +} + u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { const u64 tmp_size = (const u64) sizeof (bcrypt_tmp_t); @@ -66,11 +80,6 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c return tmp_size; } -bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) -{ - return true; -} - char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) { char *jit_build_options = NULL; @@ -321,11 +330,11 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hook_salt_size = MODULE_DEFAULT; module_ctx->module_hook_size = MODULE_DEFAULT; module_ctx->module_jit_build_options = module_jit_build_options; - module_ctx->module_jit_cache_disable = module_jit_cache_disable; + module_ctx->module_jit_cache_disable = MODULE_DEFAULT; module_ctx->module_kernel_accel_max = MODULE_DEFAULT; module_ctx->module_kernel_accel_min = MODULE_DEFAULT; - module_ctx->module_kernel_loops_max = MODULE_DEFAULT; - module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; + module_ctx->module_kernel_loops_min = module_kernel_loops_min; module_ctx->module_kernel_threads_max = MODULE_DEFAULT; module_ctx->module_kernel_threads_min = MODULE_DEFAULT; module_ctx->module_kern_type = module_kern_type;