From 76ce73595472d6d8e44ba16d8e45191925b1d76e Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 22 Apr 2023 16:52:01 +0200 Subject: [PATCH 01/11] Fixed bug in 18400 module_hash_encode --- docs/changes.txt | 1 + src/modules/module_18400.c | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index aa0ef815d..6349c6acb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -51,6 +51,7 @@ - Skip chained generated rules that exceed the maximum number of function calls - Fixed incorrect plaintext check for 25400 and 26610. Increased plaintext check to 32 bytes to prevent false positives. - Fixed bug in --stdout that caused certain rules to malfunction +- Fixed bug in 18400 module_hash_encode - Fixed build failed for 18400 with Apple Metal - Fixed build failed for 18600 with Apple Metal - Fixed display problem of the "Optimizers applied" list for algorithms using OPTI_TYPE_SLOW_HASH_SIMD_INIT2 and/or OPTI_TYPE_SLOW_HASH_SIMD_LOOP2 diff --git a/src/modules/module_18400.c b/src/modules/module_18400.c index 7f681910b..4cd23b671 100644 --- a/src/modules/module_18400.c +++ b/src/modules/module_18400.c @@ -256,15 +256,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // ct - u32 ct_buf[256]; + u8 ct_buf[(256 * 4 * 2) + 1]; - for (int i = 0; i < 256; i++) ct_buf[i] = byte_swap_32 (odf12->encrypted_data[i]); + memset (ct_buf, 0, sizeof (ct_buf)); - u8 ct_buf8[(256 * 4 * 2) + 1]; + const int ct_len = hex_encode ((const u8 *) odf12->encrypted_data, odf12->encrypted_len, ct_buf); - const int ct_len = hex_encode ((const u8 *) ct_buf, odf12->encrypted_len, ct_buf8); - - ct_buf8[ct_len] = 0; + ct_buf[ct_len] = 0; const int out_len = snprintf (line_buf, line_size, "%s*1*1*%u*32*%08x%08x%08x%08x%08x%08x%08x%08x*16*%08x%08x%08x%08x*16*%08x%08x%08x%08x*0*%s", SIGNATURE_ODF, @@ -285,7 +283,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE byte_swap_32 (salt->salt_buf[1]), byte_swap_32 (salt->salt_buf[2]), byte_swap_32 (salt->salt_buf[3]), - (char *) ct_buf8); + (char *) ct_buf); return out_len; } From 756e2e07b1f04af2376edbe7868c91882269787a Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 22 Apr 2023 18:48:46 +0200 Subject: [PATCH 02/11] Fixed bug in 26900 module_hash_encode --- docs/changes.txt | 1 + src/modules/module_26900.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index aa0ef815d..8da7f3d7c 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -51,6 +51,7 @@ - Skip chained generated rules that exceed the maximum number of function calls - Fixed incorrect plaintext check for 25400 and 26610. Increased plaintext check to 32 bytes to prevent false positives. - Fixed bug in --stdout that caused certain rules to malfunction +- Fixed bug in 26900 module_hash_encode - Fixed build failed for 18400 with Apple Metal - Fixed build failed for 18600 with Apple Metal - Fixed display problem of the "Optimizers applied" list for algorithms using OPTI_TYPE_SLOW_HASH_SIMD_INIT2 and/or OPTI_TYPE_SLOW_HASH_SIMD_LOOP2 diff --git a/src/modules/module_26900.c b/src/modules/module_26900.c index 2d724b509..933918c27 100644 --- a/src/modules/module_26900.c +++ b/src/modules/module_26900.c @@ -282,7 +282,19 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE out_len++; - out_len += hex_encode ((u8 *) snmpv3->engineID_buf, snmpv3->engineID_len, out_buf + out_len); + // remove zero padding from snmpv3->engineID_buf + + u8 *engineID_buf_tmp = (u8 *) snmpv3->engineID_buf; + + u32 engineID_len = snmpv3->engineID_len; + + while (engineID_buf_tmp[engineID_len] == 0x00) engineID_len--; + + engineID_len++; + + // append to output + + out_len += hex_encode ((u8 *) snmpv3->engineID_buf, engineID_len, out_buf + out_len); out_buf[out_len] = '$'; From e09d07868b4bcfd3fc4c9c250e0899c31887e168 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 22 Apr 2023 18:57:00 +0200 Subject: [PATCH 03/11] Fixed minimum password length in module of hash-mode 28200 --- docs/changes.txt | 1 + tools/test_modules/m28200.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index aa0ef815d..6c900b064 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -56,6 +56,7 @@ - Fixed display problem of the "Optimizers applied" list for algorithms using OPTI_TYPE_SLOW_HASH_SIMD_INIT2 and/or OPTI_TYPE_SLOW_HASH_SIMD_LOOP2 - Fixed incompatible pointer types (salt1 and salt2 buf) in 31700 a3 kernel - Fixed incompatible pointer types (salt1 and salt2 buf) in 3730 a3 kernel +- Fixed minimum password length in module of hash-mode 28200 - Handle signed/unsigned PDF permission P value for all PDF hash-modes ## diff --git a/tools/test_modules/m28200.pm b/tools/test_modules/m28200.pm index 85bde1ec1..c8ae72830 100644 --- a/tools/test_modules/m28200.pm +++ b/tools/test_modules/m28200.pm @@ -12,7 +12,7 @@ use Crypt::AuthEnc::GCM; use Crypt::ScryptKDF qw (scrypt_raw); use MIME::Base64 qw (decode_base64 encode_base64); -sub module_constraints { [[0, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] } +sub module_constraints { [[4, 256], [64, 64], [-1, -1], [-1, -1], [-1, -1]] } sub module_generate_hash { From 2b818b1d8a4a045bfae0ca6f9eb95ba9b9858037 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Tue, 25 Apr 2023 16:35:58 +0200 Subject: [PATCH 04/11] Fixed build failed for 31700 with Apple Metal --- OpenCL/m31700_a0-pure.cl | 4 ++-- docs/changes.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenCL/m31700_a0-pure.cl b/OpenCL/m31700_a0-pure.cl index d34ff5e99..f56df6f88 100644 --- a/OpenCL/m31700_a0-pure.cl +++ b/OpenCL/m31700_a0-pure.cl @@ -38,7 +38,7 @@ typedef struct md5_double_salt } md5_double_salt_t; -KERNEL_FQ void m31700_mxx (KERN_ATTR_ESALT (md5_double_salt_t)) +KERNEL_FQ void m31700_mxx (KERN_ATTR_RULES_ESALT (md5_double_salt_t)) { /** * modifier @@ -180,7 +180,7 @@ KERNEL_FQ void m31700_mxx (KERN_ATTR_ESALT (md5_double_salt_t)) } } -KERNEL_FQ void m31700_sxx (KERN_ATTR_ESALT (md5_double_salt_t)) +KERNEL_FQ void m31700_sxx (KERN_ATTR_RULES_ESALT (md5_double_salt_t)) { /** * modifier diff --git a/docs/changes.txt b/docs/changes.txt index 9534377b7..987313b88 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -55,6 +55,7 @@ - Fixed bug in input_tokenizer when TOKEN_ATTR_FIXED_LENGTH is used and refactor modules - Fixed build failed for 18400 with Apple Metal - Fixed build failed for 18600 with Apple Metal +- Fixed build failed for 31700 with Apple Metal - Fixed display problem of the "Optimizers applied" list for algorithms using OPTI_TYPE_SLOW_HASH_SIMD_INIT2 and/or OPTI_TYPE_SLOW_HASH_SIMD_LOOP2 - Fixed incompatible pointer types (salt1 and salt2 buf) in 31700 a3 kernel - Fixed incompatible pointer types (salt1 and salt2 buf) in 3730 a3 kernel From f504c692fea039f1a67f69108842db8178ad61f5 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Tue, 25 Apr 2023 17:09:22 +0200 Subject: [PATCH 05/11] Fix 31900 hash parsing error --- src/modules/module_31900.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/modules/module_31900.c b/src/modules/module_31900.c index 96c6840be..291c3d213 100644 --- a/src/modules/module_31900.c +++ b/src/modules/module_31900.c @@ -131,6 +131,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE hc_token_t token; + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 4; token.signatures_cnt = 1; @@ -141,21 +143,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE | TOKEN_ATTR_VERIFY_SIGNATURE; token.sep[1] = '$'; - token.len_min[1] = 24; - token.len_max[1] = 24; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH + token.len[1] = 24; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; token.sep[2] = '$'; - token.len_min[2] = 32; - token.len_max[2] = 32; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH + token.len[2] = 32; + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_HEX; token.sep[3] = '$'; - token.len_min[3] = 24; - token.len_max[3] = 24; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH + token.len[3] = 24; + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH | TOKEN_ATTR_VERIFY_BASE64A; const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); From 5f332995bca867235944f9d043eecdef140563ff Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Tue, 25 Apr 2023 17:17:46 +0200 Subject: [PATCH 06/11] Metal Backend: added workaround to prevent 'Infinite Loop' bug when build kernels --- docs/changes.txt | 1 + src/ext_metal.m | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 9534377b7..47c34f6ff 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -77,6 +77,7 @@ - Unicode: Update UTF-8 to UTF-16 conversion to match RFC 3629 - User Options: Added error message when mixing --username and --show to warn users of exponential delay - MetaMask: update extraction tool to support MetaMask Mobile wallets +- Metal Backend: added workaround to prevent 'Infinite Loop' bug when build kernels * changes v6.2.5 -> v6.2.6 diff --git a/src/ext_metal.m b/src/ext_metal.m index b8428369c..bbfb8dbb7 100644 --- a/src/ext_metal.m +++ b/src/ext_metal.m @@ -681,7 +681,8 @@ int hc_mtlCreateCommandQueue (void *hashcat_ctx, mtl_device_id metal_device, mtl int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_library metal_library, const char *func_name, mtl_function *metal_function, mtl_pipeline *metal_pipeline) { - backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx; + backend_ctx_t *backend_ctx = ((hashcat_ctx_t *) hashcat_ctx)->backend_ctx; + user_options_t *user_options = ((hashcat_ctx_t *) hashcat_ctx)->user_options; MTL_PTR *mtl = (MTL_PTR *) backend_ctx->mtl; @@ -708,7 +709,7 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra return -1; } - NSError *error = nil; + __block NSError *error = nil; NSString *f_name = [NSString stringWithCString: func_name encoding: NSUTF8StringEncoding]; @@ -721,6 +722,9 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra return -1; } + // workaround for MTLCompilerService 'Infinite Loop' bug + + /* mtl_pipeline mtl_pipe = [metal_device newComputePipelineStateWithFunction: mtl_func error: &error]; if (error != nil) @@ -729,6 +733,46 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra return -1; } + */ + + error = nil; + + __block mtl_pipeline mtl_pipe; + + dispatch_group_t group = dispatch_group_create (); + dispatch_queue_t queue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); + + // wait for 60 secs by default or using user-defined runtime if is set + long timeout = (user_options->runtime > 0) ? user_options->runtime : 60; + + dispatch_time_t when = dispatch_time (DISPATCH_TIME_NOW,NSEC_PER_SEC * timeout); + + __block int rc_async_err = 0; + + dispatch_group_async (group, queue, ^(void) + { + mtl_pipe = [metal_device newComputePipelineStateWithFunction: mtl_func error: &error]; + + if (error != nil) + { + event_log_error (hashcat_ctx, "%s(): failed to create '%s' pipeline, %s", __func__, func_name, [[error localizedDescription] UTF8String]); + + rc_async_err = -1; + } + }); + + long rc_queue = dispatch_group_wait (group, when); + + dispatch_release (group); + + if (rc_async_err != 0) return -1; + + if (rc_queue != 0) + { + event_log_error (hashcat_ctx, "%s(): failed to create '%s' pipeline, timeout reached (status %ld)", __func__, func_name, rc_queue); + + return -1; + } if (mtl_pipe == nil) { From 5ac38b381d2177f6efebc98ae1398d74f8f68933 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Wed, 26 Apr 2023 03:11:55 +0200 Subject: [PATCH 07/11] updated default build timeout on Apple Metal to 120 seconds --- src/ext_metal.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ext_metal.m b/src/ext_metal.m index bbfb8dbb7..d4a1b3102 100644 --- a/src/ext_metal.m +++ b/src/ext_metal.m @@ -742,8 +742,8 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra dispatch_group_t group = dispatch_group_create (); dispatch_queue_t queue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - // wait for 60 secs by default or using user-defined runtime if is set - long timeout = (user_options->runtime > 0) ? user_options->runtime : 60; + // wait for 120 secs by default or using user-defined runtime if is set + long timeout = (user_options->runtime > 0) ? user_options->runtime : 120; dispatch_time_t when = dispatch_time (DISPATCH_TIME_NOW,NSEC_PER_SEC * timeout); From c43094267632d19c8caec365e74853a9bcf1769f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?= Date: Thu, 27 Apr 2023 11:35:59 +0200 Subject: [PATCH 08/11] JSON-escape example_hash in hash info --- src/terminal.c | 72 +++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 2de912e0a..d141cdad2 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -634,6 +634,37 @@ void compress_terminal_line_length (char *out_buf, const size_t keep_from_beginn *ptr1 = 0; } +void json_encode (char *text, char *escaped) +{ + /* + * Based on https://www.freeformatter.com/json-escape.html, below these 7 different chars + * are getting escaped before being printed. + */ + + size_t len = strlen (text); + unsigned long i, j; + + for (i = 0, j = 0; i < len; i++, j++) + { + char c = text[i]; + + switch (c) + { + case '\b': c = 'b'; escaped[j] = '\\'; j++; break; + case '\t': c = 't'; escaped[j] = '\\'; j++; break; + case '\n': c = 'n'; escaped[j] = '\\'; j++; break; + case '\f': c = 'f'; escaped[j] = '\\'; j++; break; + case '\r': c = 'r'; escaped[j] = '\\'; j++; break; + case '\\': c = '\\'; escaped[j] = '\\'; j++; break; + case '"': c = '"'; escaped[j] = '\\'; j++; break; + } + + escaped[j] = c; + } + + escaped[j] = 0; +} + void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_options_extra) { if (hashconfig_init (hashcat_ctx) == 0) @@ -692,14 +723,20 @@ void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *us { printf ("\"example_hash_format\": \"%s\", ", "hex-encoded (binary file only)"); } - printf ("\"example_hash\": \"%s\", ", hashconfig->st_hash); } else { printf ("\"example_hash_format\": \"%s\", ", "plain"); - printf ("\"example_hash\": \"%s\", ", hashconfig->st_hash); } + char *example_hash_json_encoded = (char *) hcmalloc (strlen (hashconfig->st_hash) * 2); + + json_encode ((char *)hashconfig->st_hash, example_hash_json_encoded); + + printf ("\"example_hash\": \"%s\", ", example_hash_json_encoded); + + hcfree (example_hash_json_encoded); + if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options_extra->separator, false)) { char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); @@ -1760,37 +1797,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) hcfree (hashcat_status); } -void json_encode (char *text, char *escaped) -{ - /* - * Based on https://www.freeformatter.com/json-escape.html, below these 7 different chars - * are getting escaped before being printed. - */ - - size_t len = strlen (text); - unsigned long i, j; - - for (i = 0, j = 0; i < len; i++, j++) - { - char c = text[i]; - - switch (c) - { - case '\b': c = 'b'; escaped[j] = '\\'; j++; break; - case '\t': c = 't'; escaped[j] = '\\'; j++; break; - case '\n': c = 'n'; escaped[j] = '\\'; j++; break; - case '\f': c = 'f'; escaped[j] = '\\'; j++; break; - case '\r': c = 'r'; escaped[j] = '\\'; j++; break; - case '\\': c = '\\'; escaped[j] = '\\'; j++; break; - case '"': c = '"'; escaped[j] = '\\'; j++; break; - } - - escaped[j] = c; - } - - escaped[j] = 0; -} - void status_display_status_json (hashcat_ctx_t *hashcat_ctx) { const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; From 0176daa03ef1d7c09d6aa56d5cbd61ef1d17637d Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 29 Apr 2023 19:16:17 +0000 Subject: [PATCH 09/11] Fix a bug in self-test section. Hashcat used the salt_repeat value of the first hash not the self-test hash --- src/selftest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/selftest.c b/src/selftest.c index 977c38682..9c80374af 100644 --- a/src/selftest.c +++ b/src/selftest.c @@ -624,7 +624,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param salt_t *salt_buf = &hashes->st_salts_buf[salt_pos]; - const u32 salt_repeats = hashes->salts_buf[salt_pos].salt_repeats; + const u32 salt_repeats = salt_buf->salt_repeats; for (u32 salt_repeat = 0; salt_repeat <= salt_repeats; salt_repeat++) { From e6d1a4c8a252d377b8dc42a8f298861b7fa0ca68 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Mon, 1 May 2023 03:33:35 +0200 Subject: [PATCH 10/11] Added --metal-compiler-runtime option --- include/types.h | 76 ++++++++++++++++++++++++---------------------- src/ext_metal.m | 4 +-- src/usage.c | 1 + src/user_options.c | 16 ++++++++++ 4 files changed, 59 insertions(+), 38 deletions(-) diff --git a/include/types.h b/include/types.h index 9570189cb..c34ae9eb4 100644 --- a/include/types.h +++ b/include/types.h @@ -674,6 +674,7 @@ typedef enum user_options_defaults MARKOV_DISABLE = false, MARKOV_INVERSE = false, MARKOV_THRESHOLD = 0, + METAL_COMPILER_RUNTIME = 120, NONCE_ERROR_CORRECTIONS = 8, BACKEND_IGNORE_CUDA = false, BACKEND_IGNORE_HIP = false, @@ -793,56 +794,57 @@ typedef enum user_options_map IDX_MARKOV_HCSTAT2 = 0xff2d, IDX_MARKOV_INVERSE = 0xff2e, IDX_MARKOV_THRESHOLD = 't', - IDX_NONCE_ERROR_CORRECTIONS = 0xff2f, + IDX_METAL_COMPILER_RUNTIME = 0xff2f, + IDX_NONCE_ERROR_CORRECTIONS = 0xff30, IDX_OPENCL_DEVICE_TYPES = 'D', IDX_OPTIMIZED_KERNEL_ENABLE = 'O', IDX_MULTIPLY_ACCEL_DISABLE = 'M', - IDX_OUTFILE_AUTOHEX_DISABLE = 0xff30, - IDX_OUTFILE_CHECK_DIR = 0xff31, - IDX_OUTFILE_CHECK_TIMER = 0xff32, - IDX_OUTFILE_FORMAT = 0xff33, + IDX_OUTFILE_AUTOHEX_DISABLE = 0xff31, + IDX_OUTFILE_CHECK_DIR = 0xff32, + IDX_OUTFILE_CHECK_TIMER = 0xff33, + IDX_OUTFILE_FORMAT = 0xff34, IDX_OUTFILE = 'o', - IDX_POTFILE_DISABLE = 0xff34, - IDX_POTFILE_PATH = 0xff35, - IDX_PROGRESS_ONLY = 0xff36, - IDX_QUIET = 0xff37, - IDX_REMOVE = 0xff38, - IDX_REMOVE_TIMER = 0xff39, - IDX_RESTORE = 0xff3a, - IDX_RESTORE_DISABLE = 0xff3b, - IDX_RESTORE_FILE_PATH = 0xff3c, + IDX_POTFILE_DISABLE = 0xff35, + IDX_POTFILE_PATH = 0xff36, + IDX_PROGRESS_ONLY = 0xff37, + IDX_QUIET = 0xff38, + IDX_REMOVE = 0xff39, + IDX_REMOVE_TIMER = 0xff3a, + IDX_RESTORE = 0xff3b, + IDX_RESTORE_DISABLE = 0xff3c, + IDX_RESTORE_FILE_PATH = 0xff3d, IDX_RP_FILE = 'r', - IDX_RP_GEN_FUNC_MAX = 0xff3d, - IDX_RP_GEN_FUNC_MIN = 0xff3e, - IDX_RP_GEN_FUNC_SEL = 0xff3f, + IDX_RP_GEN_FUNC_MAX = 0xff3e, + IDX_RP_GEN_FUNC_MIN = 0xff3f, + IDX_RP_GEN_FUNC_SEL = 0xff40, IDX_RP_GEN = 'g', - IDX_RP_GEN_SEED = 0xff40, + IDX_RP_GEN_SEED = 0xff41, IDX_RULE_BUF_L = 'j', IDX_RULE_BUF_R = 'k', - IDX_RUNTIME = 0xff41, - IDX_SCRYPT_TMTO = 0xff42, + IDX_RUNTIME = 0xff42, + IDX_SCRYPT_TMTO = 0xff43, IDX_SEGMENT_SIZE = 'c', - IDX_SELF_TEST_DISABLE = 0xff43, + IDX_SELF_TEST_DISABLE = 0xff44, IDX_SEPARATOR = 'p', - IDX_SESSION = 0xff44, - IDX_SHOW = 0xff45, + IDX_SESSION = 0xff45, + IDX_SHOW = 0xff46, IDX_SKIP = 's', IDX_SLOW_CANDIDATES = 'S', - IDX_SPEED_ONLY = 0xff46, - IDX_SPIN_DAMP = 0xff47, - IDX_STATUS = 0xff48, - IDX_STATUS_JSON = 0xff49, - IDX_STATUS_TIMER = 0xff4a, - IDX_STDOUT_FLAG = 0xff4b, - IDX_STDIN_TIMEOUT_ABORT = 0xff4c, - IDX_TRUECRYPT_KEYFILES = 0xff4d, - IDX_USERNAME = 0xff4e, - IDX_VERACRYPT_KEYFILES = 0xff4f, - IDX_VERACRYPT_PIM_START = 0xff50, - IDX_VERACRYPT_PIM_STOP = 0xff51, + IDX_SPEED_ONLY = 0xff47, + IDX_SPIN_DAMP = 0xff48, + IDX_STATUS = 0xff49, + IDX_STATUS_JSON = 0xff4a, + IDX_STATUS_TIMER = 0xff4b, + IDX_STDOUT_FLAG = 0xff4c, + IDX_STDIN_TIMEOUT_ABORT = 0xff4d, + IDX_TRUECRYPT_KEYFILES = 0xff4e, + IDX_USERNAME = 0xff4f, + IDX_VERACRYPT_KEYFILES = 0xff50, + IDX_VERACRYPT_PIM_START = 0xff51, + IDX_VERACRYPT_PIM_STOP = 0xff52, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', - IDX_WORDLIST_AUTOHEX_DISABLE = 0xff52, + IDX_WORDLIST_AUTOHEX_DISABLE = 0xff53, IDX_WORKLOAD_PROFILE = 'w', } user_options_map_t; @@ -2311,6 +2313,7 @@ typedef struct user_options bool remove_timer_chgd; bool rp_gen_seed_chgd; bool runtime_chgd; + bool metal_compiler_runtime_chgd; bool segment_size_chgd; bool workload_profile_chgd; bool skip_chgd; @@ -2435,6 +2438,7 @@ typedef struct user_options u32 rp_gen_func_min; u32 rp_gen_seed; u32 runtime; + u32 metal_compiler_runtime; u32 scrypt_tmto; u32 segment_size; u32 status_timer; diff --git a/src/ext_metal.m b/src/ext_metal.m index d4a1b3102..a9ab89229 100644 --- a/src/ext_metal.m +++ b/src/ext_metal.m @@ -742,8 +742,8 @@ int hc_mtlCreateKernel (void *hashcat_ctx, mtl_device_id metal_device, mtl_libra dispatch_group_t group = dispatch_group_create (); dispatch_queue_t queue = dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - // wait for 120 secs by default or using user-defined runtime if is set - long timeout = (user_options->runtime > 0) ? user_options->runtime : 120; + // if no user-defined runtime, set to METAL_COMPILER_RUNTIME + long timeout = (user_options->metal_compiler_runtime > 0) ? user_options->metal_compiler_runtime : METAL_COMPILER_RUNTIME; dispatch_time_t when = dispatch_time (DISPATCH_TIME_NOW,NSEC_PER_SEC * timeout); diff --git a/src/usage.c b/src/usage.c index 21f67934a..003a6eea6 100644 --- a/src/usage.c +++ b/src/usage.c @@ -49,6 +49,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --markov-classic | | Enables classic markov-chains, no per-position |", " --markov-inverse | | Enables inverse markov-chains, no per-position |", " -t, --markov-threshold | Num | Threshold X when to stop accepting new markov-chains | -t 50", + " --metal-compiler-runtime | Num | Abort Metal kernel build after X seconds of runtime | --metal-compiler-runtime=180", " --runtime | Num | Abort session after X seconds of runtime | --runtime=10", " --session | Str | Define specific session name | --session=mysession", " --restore | | Restore session from --session |", diff --git a/src/user_options.c b/src/user_options.c index 4198fa3bc..960031f2f 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -94,6 +94,7 @@ static const struct option long_options[] = {"markov-hcstat2", required_argument, NULL, IDX_MARKOV_HCSTAT2}, {"markov-inverse", no_argument, NULL, IDX_MARKOV_INVERSE}, {"markov-threshold", required_argument, NULL, IDX_MARKOV_THRESHOLD}, + {"metal-compiler-runtime", required_argument, NULL, IDX_METAL_COMPILER_RUNTIME}, {"nonce-error-corrections", required_argument, NULL, IDX_NONCE_ERROR_CORRECTIONS}, {"opencl-device-types", required_argument, NULL, IDX_OPENCL_DEVICE_TYPES}, {"optimized-kernel-enable", no_argument, NULL, IDX_OPTIMIZED_KERNEL_ENABLE}, @@ -236,6 +237,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->markov_hcstat2 = NULL; user_options->markov_inverse = MARKOV_INVERSE; user_options->markov_threshold = MARKOV_THRESHOLD; + user_options->metal_compiler_runtime = METAL_COMPILER_RUNTIME; user_options->nonce_error_corrections = NONCE_ERROR_CORRECTIONS; user_options->opencl_device_types = NULL; user_options->optimized_kernel_enable = OPTIMIZED_KERNEL_ENABLE; @@ -330,6 +332,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_STATUS_TIMER: case IDX_HASH_MODE: case IDX_RUNTIME: + case IDX_METAL_COMPILER_RUNTIME: case IDX_ATTACK_MODE: case IDX_RP_GEN: case IDX_RP_GEN_FUNC_MIN: @@ -436,6 +439,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) user_options->hash_mode_chgd = true; break; case IDX_RUNTIME: user_options->runtime = hc_strtoul (optarg, NULL, 10); user_options->runtime_chgd = true; break; + case IDX_METAL_COMPILER_RUNTIME: user_options->metal_compiler_runtime = hc_strtoul (optarg, NULL, 10); + user_options->metal_compiler_runtime_chgd = true; break; case IDX_ATTACK_MODE: user_options->attack_mode = hc_strtoul (optarg, NULL, 10); user_options->attack_mode_chgd = true; break; case IDX_RP_FILE: user_options->rp_files[user_options->rp_files_cnt++] = optarg; break; @@ -732,6 +737,16 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + // --metal-compiler-runtime is really used only on Apple, + // but is useless to expose only on Apple + + if (user_options->metal_compiler_runtime_chgd == true && user_options->metal_compiler_runtime == 0) + { + event_log_error (hashcat_ctx, "Invalid --metal-compiler-runtime value specified (must be > 0)."); + + return -1; + } + if (user_options->limit_chgd == true && user_options->loopback == true) { event_log_error (hashcat_ctx, "Combining --limit with --loopback is not allowed."); @@ -3204,6 +3219,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->markov_disable); logfile_top_uint (user_options->markov_inverse); logfile_top_uint (user_options->markov_threshold); + logfile_top_uint (user_options->metal_compiler_runtime); logfile_top_uint (user_options->multiply_accel_disable); logfile_top_uint (user_options->backend_info); logfile_top_uint (user_options->backend_vector_width); From 2fe2d299bc3f40096c6739a578d5aa17e3a2fd78 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Mon, 1 May 2023 03:44:39 +0200 Subject: [PATCH 11/11] update changes.txt + cleanup --- docs/changes.txt | 1 + src/user_options.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 502feeb5b..4d9bf3438 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -82,6 +82,7 @@ - User Options: Added error message when mixing --username and --show to warn users of exponential delay - MetaMask: update extraction tool to support MetaMask Mobile wallets - Metal Backend: added workaround to prevent 'Infinite Loop' bug when build kernels +- User Options: added --metal-compiler-runtime option * changes v6.2.5 -> v6.2.6 diff --git a/src/user_options.c b/src/user_options.c index 960031f2f..50da0dbd7 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -737,8 +737,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - // --metal-compiler-runtime is really used only on Apple, - // but is useless to expose only on Apple + // --metal-compiler-runtime is really used only on Apple if (user_options->metal_compiler_runtime_chgd == true && user_options->metal_compiler_runtime == 0) {