From 9e440fd6d9de4c80c6af70a9c7894cc75535d103 Mon Sep 17 00:00:00 2001 From: missing0x00 Date: Wed, 19 Jul 2023 22:35:58 -0500 Subject: [PATCH 1/4] Fixed build errors and "Old template?" error for newer versions of Hashcat --- module_code/module_19850.c | 8 ++++++-- opencl_code/m19850_a0-pure.cl | 34 +++++++++++++++++----------------- opencl_code/m19850_a1-pure.cl | 34 +++++++++++++++++----------------- opencl_code/m19850_a3-pure.cl | 33 +++++++++++++++++---------------- 4 files changed, 57 insertions(+), 52 deletions(-) diff --git a/module_code/module_19850.c b/module_code/module_19850.c index b44501d..7bbd2c3 100755 --- a/module_code/module_19850.c +++ b/module_code/module_19850.c @@ -51,7 +51,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE u32 *digest = (u32 *) digest_buf; u32 payload[4]; - token_t token; + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); token.token_cnt = 5; /* 40 byte header @@ -133,6 +135,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; module_ctx->module_benchmark_esalt = MODULE_DEFAULT; module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; @@ -154,6 +157,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_hash_binary_count = MODULE_DEFAULT; module_ctx->module_hash_binary_parse = MODULE_DEFAULT; module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; module_ctx->module_hash_decode = module_hash_decode; @@ -203,4 +207,4 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_tmp_size = MODULE_DEFAULT; module_ctx->module_unstable_warning = MODULE_DEFAULT; module_ctx->module_warmup_disable = MODULE_DEFAULT; -} \ No newline at end of file +} diff --git a/opencl_code/m19850_a0-pure.cl b/opencl_code/m19850_a0-pure.cl index 06af563..1c93022 100755 --- a/opencl_code/m19850_a0-pure.cl +++ b/opencl_code/m19850_a0-pure.cl @@ -4,15 +4,15 @@ */ #ifdef KERNEL_STATIC -#include "inc_vendor.h" -#include "inc_types.h" -#include "inc_platform.cl" -#include "inc_common.cl" -#include "inc_rp.h" -#include "inc_rp.cl" -#include "inc_hash_sha1.cl" -#include "inc_cipher_aes.cl" -#include "inc_scalar.cl" +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) #endif DECLSPEC void crypt_derive_key_password_derivation (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) @@ -139,7 +139,7 @@ KERNEL_FQ void m19850_mxx (KERN_ATTR_RULES()) #endif - if (gid >= gid_max) return; + if (gid >= GID_CNT) return; COPY_PW (pws[gid]); @@ -147,7 +147,7 @@ KERNEL_FQ void m19850_mxx (KERN_ATTR_RULES()) * loop */ - for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { pw_t tmp = PASTE_PW; @@ -196,7 +196,7 @@ KERNEL_FQ void m19850_sxx (KERN_ATTR_RULES()) const u64 lid = get_local_id (0); const u64 lsz = get_local_size (0); - if (gid >= gid_max) return; + if (gid >= GID_CNT) return; /** * aes shared @@ -251,10 +251,10 @@ KERNEL_FQ void m19850_sxx (KERN_ATTR_RULES()) const u32 search[4] = { - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] }; COPY_PW (pws[gid]); @@ -263,7 +263,7 @@ KERNEL_FQ void m19850_sxx (KERN_ATTR_RULES()) * loop */ - for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { pw_t tmp = PASTE_PW; diff --git a/opencl_code/m19850_a1-pure.cl b/opencl_code/m19850_a1-pure.cl index c48209b..be91c4c 100755 --- a/opencl_code/m19850_a1-pure.cl +++ b/opencl_code/m19850_a1-pure.cl @@ -4,15 +4,15 @@ */ #ifdef KERNEL_STATIC -#include "inc_vendor.h" -#include "inc_types.h" -#include "inc_platform.cl" -#include "inc_common.cl" -#include "inc_rp.h" -#include "inc_rp.cl" -#include "inc_hash_sha1.cl" -#include "inc_cipher_aes.cl" -#include "inc_scalar.cl" +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) #endif //CryptDeriveKey is basically sha1hmac if the input is forced to be greater than 64. Based on the code from sha1_hmac_init_vector and ipad from sha1_hmac_init_vector_64. @@ -141,7 +141,7 @@ KERNEL_FQ void m19850_mxx (KERN_ATTR_BASIC()) #endif - if (gid >= gid_max) return; + if (gid >= GID_CNT) return; //First call to sha1_update_global_utf16le_swap for the left hand side password (pws) sha1_ctx_t tmp; @@ -154,7 +154,7 @@ KERNEL_FQ void m19850_mxx (KERN_ATTR_BASIC()) * loop */ - for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { sha1_hmac_ctx_t sha1_hmac_ctx; sha1_ctx_t pwsorig = tmp; //Make a copy of the existing sha1_ctx_t object already calculated for pws, per loop iteration @@ -252,14 +252,14 @@ KERNEL_FQ void m19850_sxx (KERN_ATTR_BASIC()) #endif - if (gid >= gid_max) return; + if (gid >= GID_CNT) return; const u32 search[4] = { - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] }; sha1_ctx_t tmp; @@ -272,7 +272,7 @@ KERNEL_FQ void m19850_sxx (KERN_ATTR_BASIC()) * loop */ - for (u32 il_pos = 0; il_pos < il_cnt; il_pos++) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) { sha1_hmac_ctx_t sha1_hmac_ctx; sha1_ctx_t pwsorig = tmp; diff --git a/opencl_code/m19850_a3-pure.cl b/opencl_code/m19850_a3-pure.cl index 8589c96..8616b96 100755 --- a/opencl_code/m19850_a3-pure.cl +++ b/opencl_code/m19850_a3-pure.cl @@ -6,14 +6,15 @@ #define NEW_SIMD_CODE #ifdef KERNEL_STATIC -#include "inc_vendor.h" -#include "inc_types.h" -#include "inc_platform.cl" -#include "inc_common.cl" -#include "inc_simd.cl" -#include "inc_hash_sha1.cl" -#include "inc_cipher_aes.cl" -#include "inc_scalar.cl" +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) #endif //CryptDeriveKey is basically sha1hmac if the input is forced to be greater than 64. Based on the code from sha1_hmac_init_vector and ipad from sha1_hmac_init_vector_64. @@ -91,7 +92,7 @@ KERNEL_FQ void m19850_mxx (KERN_ATTR_VECTOR ()) const u64 gid = get_global_id (0); const u64 lsz = get_local_size (0); - if (gid >= gid_max) return; + if (gid >= GID_CNT) return; /** * aes shared */ @@ -159,7 +160,7 @@ KERNEL_FQ void m19850_mxx (KERN_ATTR_VECTOR ()) u32x w0l = w[0]; - for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) { const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; @@ -213,7 +214,7 @@ KERNEL_FQ void m19850_sxx (KERN_ATTR_VECTOR ()) const u64 gid = get_global_id (0); const u64 lsz = get_local_size (0); - if (gid >= gid_max) return; + if (gid >= GID_CNT) return; /** * aes shared @@ -269,10 +270,10 @@ KERNEL_FQ void m19850_sxx (KERN_ATTR_VECTOR ()) //The compare_s code macro uses the search array to compare against const u32 search[4] = { - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2], - digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3] + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] }; @@ -292,7 +293,7 @@ KERNEL_FQ void m19850_sxx (KERN_ATTR_VECTOR ()) u32x w0l = w[0]; - for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE) + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) { const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; From 597c1bd4ae7ffe7fa831ed25bd48958095ffa9c3 Mon Sep 17 00:00:00 2001 From: missing0x00 Date: Wed, 19 Jul 2023 22:51:07 -0500 Subject: [PATCH 2/4] Fixed the fix --- opencl_code/m19850_a3-pure.cl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/opencl_code/m19850_a3-pure.cl b/opencl_code/m19850_a3-pure.cl index 8616b96..2701868 100755 --- a/opencl_code/m19850_a3-pure.cl +++ b/opencl_code/m19850_a3-pure.cl @@ -10,8 +10,7 @@ #include M2S(INCLUDE_PATH/inc_types.h) #include M2S(INCLUDE_PATH/inc_platform.cl) #include M2S(INCLUDE_PATH/inc_common.cl) -#include M2S(INCLUDE_PATH/inc_rp.h) -#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_simd.cl) #include M2S(INCLUDE_PATH/inc_hash_sha1.cl) #include M2S(INCLUDE_PATH/inc_cipher_aes.cl) #include M2S(INCLUDE_PATH/inc_scalar.cl) From d9a8efdc6936ef8a99adffbc5afa0ce45e98671f Mon Sep 17 00:00:00 2001 From: blurbdust Date: Wed, 4 Jun 2025 18:13:57 -0500 Subject: [PATCH 3/4] Adding port up to hashcat 6.2.6 and dev from @missing0x00 --- module_code/module_19850.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/module_code/module_19850.c b/module_code/module_19850.c index 7bbd2c3..8fe8192 100755 --- a/module_code/module_19850.c +++ b/module_code/module_19850.c @@ -140,6 +140,8 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; module_ctx->module_benchmark_mask = MODULE_DEFAULT; module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_bridge_name = MODULE_DEFAULT; + module_ctx->module_bridge_type = MODULE_DEFAULT; module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_deprecated_notice = MODULE_DEFAULT; From 6ec09fa5cb1874c8a0ed0536132bdec259d34222 Mon Sep 17 00:00:00 2001 From: blurbdust Date: Wed, 4 Jun 2025 18:25:44 -0500 Subject: [PATCH 4/4] Adding AES-256 version of SCCM module --- module_code/module_19851.c | 211 ++++++++++++++++++ opencl_code/m19851_a0-pure.cl | 368 +++++++++++++++++++++++++++++++ opencl_code/m19851_a3-pure.cl | 401 ++++++++++++++++++++++++++++++++++ 3 files changed, 980 insertions(+) create mode 100755 module_code/module_19851.c create mode 100755 opencl_code/m19851_a0-pure.cl create mode 100644 opencl_code/m19851_a3-pure.cl diff --git a/module_code/module_19851.c b/module_code/module_19851.c new file mode 100755 index 0000000..7c87173 --- /dev/null +++ b/module_code/module_19851.c @@ -0,0 +1,211 @@ +/** + * Author......: Christopher Panayi, MWR CyberSec + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; //Fast Kernel +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 1; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 3; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const u32 HASH_CATEGORY = HASH_CATEGORY_GENERIC_KDF; +static const char *HASH_NAME = "ConfigMgr CryptDeriveKey encrypted media variable file, AES-256"; +static const u64 KERN_TYPE = 19851; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_NOT_SALTED; +static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_HASH_COPY; //This copies the string of the hash to host memory, so that you can just print it out in hash_encode +static const u32 SALT_TYPE = SALT_TYPE_NONE; //No Salt +static const char *ST_PASS = "Password1"; +static const char *ST_HASH = "$sccm$aes256$0000edec14000000ca320000d032000010660000000000003dd6b8bc6cc41f718b07522266e188ce"; + +u32 module_attack_exec (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 ATTACK_EXEC; } +u32 module_dgst_pos0 (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 DGST_POS0; } +u32 module_dgst_pos1 (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 DGST_POS1; } +u32 module_dgst_pos2 (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 DGST_POS2; } +u32 module_dgst_pos3 (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 DGST_POS3; } +u32 module_dgst_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) { return DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +const char *module_st_hash (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 ST_HASH; } +const char *module_st_pass (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 ST_PASS; } + +static const char *SIGNATURE_SCCMAES256 = "$sccm$aes256$"; + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + const u32 aes_bytes = 26128U; //CALG_AES_256 0x00006610 as unsigned int + + u32 *digest = (u32 *) digest_buf; + u32 payload[4]; + hc_token_t token; + + memset (&token, 0, sizeof (hc_token_t)); + token.token_cnt = 5; +/* 40 byte header + * 16 byte - Header bytes (Maybe Magic bytes?) + * 4 byte - ALG_ID bytes (https://docs.microsoft.com/en-us/windows/win32/seccrypto/alg-id) + * 4 byte - Header bytes (Maybe Magic bytes?) + * 16 byte - Payload bytes (Encrypted data) + */ + + token.signatures_cnt = 1; + token.signatures_buf[0] = SIGNATURE_SCCMAES256; + + token.len[0] = 13; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_SIGNATURE; + + token.len[1] = 32; //Header + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + token.len[2] = 8; //ALG_ID + token.attr[2] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + token.len[3] = 8; //Header + token.attr[3] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + token.len[4] = 32; //Encrypted data + token.attr[4] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + setbuf(stdout, NULL); + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + u32 enc_alg_sig[1]; + u8 bytes_sig[token.len[2]]; + u8 bytes_digest[token.len[4]]; + + //Decode hex string to u8 + hex_decode(token.buf[2],token.len[2],bytes_sig); + hex_decode(token.buf[4],token.len[4],bytes_digest); + + //Convert u8 to u32 data types + memcpy(enc_alg_sig, bytes_sig, 4); + memcpy(payload, bytes_digest, 16); + + //Check that ALG_ID == CALG_AES_256 (0x00006610), else the file is not AES encrypted + if(*enc_alg_sig != aes_bytes) + { + return (PARSER_SIGNATURE_UNMATCHED); + } + + //Correct endianess of payload bytes + int i; + for (i = 0; i < 4; i++) + { + payload[i] = byte_swap_32 (payload[i]); + } + + //Store encrypted data as digest for comparison in kernel code + digest[0] = payload[0]; + digest[1] = payload[1]; + digest[2] = payload[2]; + digest[3] = payload[3]; + return (PARSER_OK); +} + +//Idea here is that this module will never really be called with many of these "hashes", so maybe it is worth storing the original hash on the host in this case +int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const int line_len = snprintf (line_buf, line_size, "%s", + hash_info->orighash); + + return line_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_charset = MODULE_DEFAULT; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_bridge_name = MODULE_DEFAULT; + module_ctx->module_bridge_type = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_deprecated_notice = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + module_ctx->module_dgst_pos3 = module_dgst_pos3; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_dictstat_disable = MODULE_DEFAULT; + module_ctx->module_esalt_size = MODULE_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_extra_tmp_size = MODULE_DEFAULT; + module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT; + module_ctx->module_hash_decode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode_potfile = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hashes_count_min = MODULE_DEFAULT; + module_ctx->module_hashes_count_max = MODULE_DEFAULT; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_size = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_init = MODULE_DEFAULT; + module_ctx->module_hook_extra_param_term = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = MODULE_DEFAULT; + 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_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_kern_type_dynamic = MODULE_DEFAULT; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_custom_check = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = MODULE_DEFAULT; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = MODULE_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/opencl_code/m19851_a0-pure.cl b/opencl_code/m19851_a0-pure.cl new file mode 100755 index 0000000..b96aa82 --- /dev/null +++ b/opencl_code/m19851_a0-pure.cl @@ -0,0 +1,368 @@ +/** + * Author......: Christopher Panayi, MWR CyberSec + * License.....: MIT + */ + +#ifdef KERNEL_STATIC +#include M2S(INCLUDE_PATH/inc_vendor.h) +#include M2S(INCLUDE_PATH/inc_types.h) +#include M2S(INCLUDE_PATH/inc_platform.cl) +#include M2S(INCLUDE_PATH/inc_common.cl) +#include M2S(INCLUDE_PATH/inc_rp.h) +#include M2S(INCLUDE_PATH/inc_rp.cl) +#include M2S(INCLUDE_PATH/inc_hash_sha1.cl) +#include M2S(INCLUDE_PATH/inc_cipher_aes.cl) +#include M2S(INCLUDE_PATH/inc_scalar.cl) +#endif + +DECLSPEC void crypt_derive_key_password_derivation (sha1_hmac_ctx_t *ctx, const u32 *w, const int len) +{ + u32 w0[4]; + u32 w1[4]; + u32 w2[4]; + u32 w3[4]; + + sha1_ctx_t tmp; + + sha1_init (&tmp); + + sha1_update_utf16le_swap (&tmp, w, len); + + sha1_final (&tmp); + + w0[0] = tmp.h[0]; + w0[1] = tmp.h[1]; + w0[2] = tmp.h[2]; + w0[3] = tmp.h[3]; + w1[0] = tmp.h[4]; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + u32 t0[4]; + u32 t1[4]; + u32 t2[4]; + u32 t3[4]; + + // ipad + + t0[0] = w0[0] ^ 0x36363636; + t0[1] = w0[1] ^ 0x36363636; + t0[2] = w0[2] ^ 0x36363636; + t0[3] = w0[3] ^ 0x36363636; + t1[0] = w1[0] ^ 0x36363636; + t1[1] = w1[1] ^ 0x36363636; + t1[2] = w1[2] ^ 0x36363636; + t1[3] = w1[3] ^ 0x36363636; + t2[0] = w2[0] ^ 0x36363636; + t2[1] = w2[1] ^ 0x36363636; + t2[2] = w2[2] ^ 0x36363636; + t2[3] = w2[3] ^ 0x36363636; + t3[0] = w3[0] ^ 0x36363636; + t3[1] = w3[1] ^ 0x36363636; + t3[2] = w3[2] ^ 0x36363636; + t3[3] = w3[3] ^ 0x36363636; + + sha1_init (&ctx->ipad); + + sha1_update_64 (&ctx->ipad, t0, t1, t2, t3, 64); + + sha1_final(&ctx->ipad); +} + +DECLSPEC void crypt_derive_key_password_derivation2 (sha1_hmac_ctx_vector_t *ctx, const u32x *w, const int len) +{ + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + sha1_ctx_vector_t tmp; + + sha1_init_vector (&tmp); + + sha1_update_vector_utf16le_swap (&tmp, w, len); + + sha1_final_vector (&tmp); + + w0[0] = tmp.h[0]; + w0[1] = tmp.h[1]; + w0[2] = tmp.h[2]; + w0[3] = tmp.h[3]; + w1[0] = tmp.h[4]; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + u32x t0[4]; + u32x t1[4]; + u32x t2[4]; + u32x t3[4]; + + // ipad + + t0[0] = w0[0] ^ 0x5c5c5c5c; + t0[1] = w0[1] ^ 0x5c5c5c5c; + t0[2] = w0[2] ^ 0x5c5c5c5c; + t0[3] = w0[3] ^ 0x5c5c5c5c; + t1[0] = w1[0] ^ 0x5c5c5c5c; + t1[1] = w1[1] ^ 0x5c5c5c5c; + t1[2] = w1[2] ^ 0x5c5c5c5c; + t1[3] = w1[3] ^ 0x5c5c5c5c; + t2[0] = w2[0] ^ 0x5c5c5c5c; + t2[1] = w2[1] ^ 0x5c5c5c5c; + t2[2] = w2[2] ^ 0x5c5c5c5c; + t2[3] = w2[3] ^ 0x5c5c5c5c; + t3[0] = w3[0] ^ 0x5c5c5c5c; + t3[1] = w3[1] ^ 0x5c5c5c5c; + t3[2] = w3[2] ^ 0x5c5c5c5c; + t3[3] = w3[3] ^ 0x5c5c5c5c; + + sha1_init_vector (&ctx->ipad); + + sha1_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); + + sha1_final_vector (&ctx->ipad); +} + +KERNEL_FQ void m19851_mxx (KERN_ATTR_RULES()) +{ + /** + * base + */ + + const u64 gid = get_global_id (0); + const u64 lid = get_local_id (0); + const u64 lsz = get_local_size (0); + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + if (gid >= GID_CNT) return; + + COPY_PW (pws[gid]); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha1_hmac_ctx_t sha1_hmac_ctx; + crypt_derive_key_password_derivation(&sha1_hmac_ctx, tmp.i,tmp.pw_len); + sha1_hmac_ctx_t sha1_hmac_ctx2; + crypt_derive_key_password_derivation2(&sha1_hmac_ctx2, tmp.i,tmp.pw_len); + + u32 aes_key[8]; + + aes_key[0] = sha1_hmac_ctx.ipad.h[0]; + aes_key[1] = sha1_hmac_ctx.ipad.h[1]; + aes_key[2] = sha1_hmac_ctx.ipad.h[2]; + aes_key[3] = sha1_hmac_ctx.ipad.h[3]; + aes_key[4] = sha1_hmac_ctx.ipad.h[4]; + aes_key[5] = sha1_hmac_ctx2.ipad.h[0]; + aes_key[6] = sha1_hmac_ctx2.ipad.h[1]; + aes_key[7] = sha1_hmac_ctx2.ipad.h[2]; + + u32 aes_cbc_encrypt_xml_ks[60]; + u32 encrypted_block[4]; + + AES256_set_encrypt_key (aes_cbc_encrypt_xml_ks, aes_key, s_te0, s_te1, s_te2, s_te3); + + const u32 enc_blocks [4] = {1006649088U,2013293824U,1811947520U,1979737344U}; // UTF-16LE "= GID_CNT) return; + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + COPY_PW (pws[gid]); + + /** + * loop + */ + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++) + { + pw_t tmp = PASTE_PW; + + tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len); + + sha1_hmac_ctx_t sha1_hmac_ctx; + crypt_derive_key_password_derivation(&sha1_hmac_ctx, tmp.i,tmp.pw_len); + sha1_hmac_ctx_t sha1_hmac_ctx2; + crypt_derive_key_password_derivation2(&sha1_hmac_ctx2, tmp.i,tmp.pw_len); + + u32 aes_key[8]; + + aes_key[0] = sha1_hmac_ctx.ipad.h[0]; + aes_key[1] = sha1_hmac_ctx.ipad.h[1]; + aes_key[2] = sha1_hmac_ctx.ipad.h[2]; + aes_key[3] = sha1_hmac_ctx.ipad.h[3]; + aes_key[4] = sha1_hmac_ctx.ipad.h[4]; + aes_key[5] = sha1_hmac_ctx2.ipad.h[0]; + aes_key[6] = sha1_hmac_ctx2.ipad.h[1]; + aes_key[7] = sha1_hmac_ctx2.ipad.h[2]; + + u32 aes_cbc_encrypt_xml_ks[60]; + u32 encrypted_block[4]; + + AES256_set_encrypt_key (aes_cbc_encrypt_xml_ks, aes_key, s_te0, s_te1, s_te2, s_te3); + + const u32 enc_blocks [4] = {1006649088U,2013293824U,1811947520U,1979737344U}; // UTF-16LE "ipad); + + sha1_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); + + sha1_final_vector (&ctx->ipad); +} + +DECLSPEC void crypt_derive_key_password_derivation_vector2 (sha1_hmac_ctx_vector_t *ctx, const u32x *w, const int len) +{ + u32x w0[4]; + u32x w1[4]; + u32x w2[4]; + u32x w3[4]; + + sha1_ctx_vector_t tmp; + + sha1_init_vector (&tmp); + + sha1_update_vector_utf16le_swap (&tmp, w, len); + + sha1_final_vector (&tmp); + + w0[0] = tmp.h[0]; + w0[1] = tmp.h[1]; + w0[2] = tmp.h[2]; + w0[3] = tmp.h[3]; + w1[0] = tmp.h[4]; + w1[1] = 0; + w1[2] = 0; + w1[3] = 0; + w2[0] = 0; + w2[1] = 0; + w2[2] = 0; + w2[3] = 0; + w3[0] = 0; + w3[1] = 0; + w3[2] = 0; + w3[3] = 0; + + u32x t0[4]; + u32x t1[4]; + u32x t2[4]; + u32x t3[4]; + + // ipad + + t0[0] = w0[0] ^ 0x5c5c5c5c; + t0[1] = w0[1] ^ 0x5c5c5c5c; + t0[2] = w0[2] ^ 0x5c5c5c5c; + t0[3] = w0[3] ^ 0x5c5c5c5c; + t1[0] = w1[0] ^ 0x5c5c5c5c; + t1[1] = w1[1] ^ 0x5c5c5c5c; + t1[2] = w1[2] ^ 0x5c5c5c5c; + t1[3] = w1[3] ^ 0x5c5c5c5c; + t2[0] = w2[0] ^ 0x5c5c5c5c; + t2[1] = w2[1] ^ 0x5c5c5c5c; + t2[2] = w2[2] ^ 0x5c5c5c5c; + t2[3] = w2[3] ^ 0x5c5c5c5c; + t3[0] = w3[0] ^ 0x5c5c5c5c; + t3[1] = w3[1] ^ 0x5c5c5c5c; + t3[2] = w3[2] ^ 0x5c5c5c5c; + t3[3] = w3[3] ^ 0x5c5c5c5c; + + sha1_init_vector (&ctx->ipad); + + sha1_update_vector_64 (&ctx->ipad, t0, t1, t2, t3, 64); + + sha1_final_vector (&ctx->ipad); +} + +KERNEL_FQ void m19851_mxx (KERN_ATTR_VECTOR ()) +{ + /** + * base + */ + + const u64 lid = get_local_id (0); + const u64 gid = get_global_id (0); + const u64 lsz = get_local_size (0); + + if (gid >= GID_CNT) return; + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + //Begin common hashcat vector code + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + //End common hashcat vector code + + sha1_hmac_ctx_vector_t sha1_hmac_ctx_vec; + crypt_derive_key_password_derivation_vector(&sha1_hmac_ctx_vec, w, pw_len); + sha1_hmac_ctx_vector_t sha1_hmac_ctx_vec2; + crypt_derive_key_password_derivation_vector2(&sha1_hmac_ctx_vec2, w, pw_len); + + u32 aes_key[8]; + + aes_key[0] = sha1_hmac_ctx_vec.ipad.h[0].s0; + aes_key[1] = sha1_hmac_ctx_vec.ipad.h[1].s0; + aes_key[2] = sha1_hmac_ctx_vec.ipad.h[2].s0; + aes_key[3] = sha1_hmac_ctx_vec.ipad.h[3].s0; + aes_key[4] = sha1_hmac_ctx_vec.ipad.h[4].s0; + aes_key[5] = sha1_hmac_ctx_vec2.ipad.h[0].s0; + aes_key[6] = sha1_hmac_ctx_vec2.ipad.h[1].s0; + aes_key[7] = sha1_hmac_ctx_vec2.ipad.h[2].s0; + + u32 aes_cbc_encrypt_xml_ks[60]; + u32 encrypted_block[4]; + + AES256_set_encrypt_key (aes_cbc_encrypt_xml_ks, aes_key, s_te0, s_te1, s_te2, s_te3); + + const u32 enc_blocks [4] = {1006649088U,2013293824U,1811947520U,1979737344U}; // UTF-16LE "= GID_CNT) return; + + /** + * aes shared + */ + + #ifdef REAL_SHM + + LOCAL_VK u32 s_td0[256]; + LOCAL_VK u32 s_td1[256]; + LOCAL_VK u32 s_td2[256]; + LOCAL_VK u32 s_td3[256]; + LOCAL_VK u32 s_td4[256]; + + LOCAL_VK u32 s_te0[256]; + LOCAL_VK u32 s_te1[256]; + LOCAL_VK u32 s_te2[256]; + LOCAL_VK u32 s_te3[256]; + LOCAL_VK u32 s_te4[256]; + + for (u32 i = lid; i < 256; i += lsz) + { + s_td0[i] = td0[i]; + s_td1[i] = td1[i]; + s_td2[i] = td2[i]; + s_td3[i] = td3[i]; + s_td4[i] = td4[i]; + + s_te0[i] = te0[i]; + s_te1[i] = te1[i]; + s_te2[i] = te2[i]; + s_te3[i] = te3[i]; + s_te4[i] = te4[i]; + } + + SYNC_THREADS (); + + #else + + CONSTANT_AS u32a *s_td0 = td0; + CONSTANT_AS u32a *s_td1 = td1; + CONSTANT_AS u32a *s_td2 = td2; + CONSTANT_AS u32a *s_td3 = td3; + CONSTANT_AS u32a *s_td4 = td4; + + CONSTANT_AS u32a *s_te0 = te0; + CONSTANT_AS u32a *s_te1 = te1; + CONSTANT_AS u32a *s_te2 = te2; + CONSTANT_AS u32a *s_te3 = te3; + CONSTANT_AS u32a *s_te4 = te4; + + #endif + + //The compare_s code macro uses the search array to compare against + const u32 search[4] = + { + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2], + digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3] + }; + + + //Begin common hashcat vector code. This is shared by all _a3-pure fast kernels + const u32 pw_len = pws[gid].pw_len; + + u32x w[64] = { 0 }; + + for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1) + { + w[idx] = pws[gid].i[idx]; + } + + /** + * loop + */ + + u32x w0l = w[0]; + + for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE) + { + const u32x w0r = words_buf_r[il_pos / VECT_SIZE]; + + const u32x w0 = w0l | w0r; + + w[0] = w0; + + //End common hashcat vector code + + sha1_hmac_ctx_vector_t sha1_hmac_ctx_vec; + crypt_derive_key_password_derivation_vector(&sha1_hmac_ctx_vec, w, pw_len); + sha1_hmac_ctx_vector_t sha1_hmac_ctx_vec2; + crypt_derive_key_password_derivation_vector2(&sha1_hmac_ctx_vec2, w, pw_len); + + u32 aes_key[8]; + + aes_key[0] = sha1_hmac_ctx_vec.ipad.h[0].s0; + aes_key[1] = sha1_hmac_ctx_vec.ipad.h[1].s0; + aes_key[2] = sha1_hmac_ctx_vec.ipad.h[2].s0; + aes_key[3] = sha1_hmac_ctx_vec.ipad.h[3].s0; + aes_key[4] = sha1_hmac_ctx_vec.ipad.h[4].s0; + aes_key[5] = sha1_hmac_ctx_vec2.ipad.h[0].s0; + aes_key[6] = sha1_hmac_ctx_vec2.ipad.h[1].s0; + aes_key[7] = sha1_hmac_ctx_vec2.ipad.h[2].s0; + + u32 aes_cbc_encrypt_xml_ks[60]; + u32 encrypted_block[4]; + + AES256_set_encrypt_key (aes_cbc_encrypt_xml_ks, aes_key, s_te0, s_te1, s_te2, s_te3); + + const u32 enc_blocks [4] = {1006649088U,2013293824U,1811947520U,1979737344U}; // UTF-16LE "