From 74af4eced60bf8d966f22451bda98d05c2a93f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20=C5=A0trom?= Date: Mon, 28 Feb 2022 21:47:59 +0100 Subject: [PATCH] update module version --- OpenCL/m23400-pure.cl | 66 +++++++++++++++++++++++------------- src/modules/module_23400.c | 20 ++++++++--- tools/test_modules/m23400.pm | 4 +-- 3 files changed, 60 insertions(+), 30 deletions(-) diff --git a/OpenCL/m23400-pure.cl b/OpenCL/m23400-pure.cl index 48480ed56..d63d6c4b4 100644 --- a/OpenCL/m23400-pure.cl +++ b/OpenCL/m23400-pure.cl @@ -253,7 +253,7 @@ KERNEL_FQ void m23400_loop (KERN_ATTR_TMPS (bitwarden_tmp_t)) unpackv (tmps, out, gid, 7, out[7]); } -KERNEL_FQ void m23400_comp (KERN_ATTR_TMPS (bitwarden_tmp_t)) +KERNEL_FQ void m23400_comp (KERN_ATTR_TMPS_ESALT (bitwarden_tmp_t, u32)) { /** * base @@ -324,36 +324,54 @@ KERNEL_FQ void m23400_comp (KERN_ATTR_TMPS (bitwarden_tmp_t)) w3[1] = 0; w3[2] = 0; w3[3] = 0; - + sha256_hmac_update_64 (&sha256_hmac_ctx2, w0, w1, w2, w3, 4); sha256_hmac_final (&sha256_hmac_ctx2); - sha256_hmac_ctx_t sha256_hmac_ctx3; + const u32 version = esalt_bufs[DIGESTS_OFFSET_HOST]; + if(version == 2) + { + + sha256_hmac_ctx_t sha256_hmac_ctx3; - u32 buff[16] = {0}; - buff[0] = sha256_hmac_ctx2.opad.h[0]; - buff[1] = sha256_hmac_ctx2.opad.h[1]; - buff[2] = sha256_hmac_ctx2.opad.h[2]; - buff[3] = sha256_hmac_ctx2.opad.h[3]; - buff[4] = sha256_hmac_ctx2.opad.h[4]; - buff[5] = sha256_hmac_ctx2.opad.h[5]; - buff[6] = sha256_hmac_ctx2.opad.h[6]; - buff[7] = sha256_hmac_ctx2.opad.h[7]; + u32 buff[16] = {0}; + buff[0] = sha256_hmac_ctx2.opad.h[0]; + buff[1] = sha256_hmac_ctx2.opad.h[1]; + buff[2] = sha256_hmac_ctx2.opad.h[2]; + buff[3] = sha256_hmac_ctx2.opad.h[3]; + buff[4] = sha256_hmac_ctx2.opad.h[4]; + buff[5] = sha256_hmac_ctx2.opad.h[5]; + buff[6] = sha256_hmac_ctx2.opad.h[6]; + buff[7] = sha256_hmac_ctx2.opad.h[7]; - sha256_hmac_init (&sha256_hmac_ctx3, out, 32); - sha256_hmac_update (&sha256_hmac_ctx3, buff, 32); - sha256_hmac_final (&sha256_hmac_ctx3); - - const u32 r0 = sha256_hmac_ctx2.opad.h[0] ^ sha256_hmac_ctx3.opad.h[0]; - const u32 r1 = sha256_hmac_ctx2.opad.h[1] ^ sha256_hmac_ctx3.opad.h[1]; - const u32 r2 = sha256_hmac_ctx2.opad.h[2] ^ sha256_hmac_ctx3.opad.h[2]; - const u32 r3 = sha256_hmac_ctx2.opad.h[3] ^ sha256_hmac_ctx3.opad.h[3]; + sha256_hmac_init (&sha256_hmac_ctx3, out, 32); + sha256_hmac_update (&sha256_hmac_ctx3, buff, 32); + sha256_hmac_final (&sha256_hmac_ctx3); + + const u32 r0 = sha256_hmac_ctx2.opad.h[0] ^ sha256_hmac_ctx3.opad.h[0]; + const u32 r1 = sha256_hmac_ctx2.opad.h[1] ^ sha256_hmac_ctx3.opad.h[1]; + const u32 r2 = sha256_hmac_ctx2.opad.h[2] ^ sha256_hmac_ctx3.opad.h[2]; + const u32 r3 = sha256_hmac_ctx2.opad.h[3] ^ sha256_hmac_ctx3.opad.h[3]; - #define il_pos 0 + #define il_pos 0 - #ifdef KERNEL_STATIC - #include COMPARE_M - #endif + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif + } + else if (version == 1) + { + const u32 r0 = sha256_hmac_ctx2.opad.h[0]; + const u32 r1 = sha256_hmac_ctx2.opad.h[1]; + const u32 r2 = sha256_hmac_ctx2.opad.h[2]; + const u32 r3 = sha256_hmac_ctx2.opad.h[3]; + + #define il_pos 0 + + #ifdef KERNEL_STATIC + #include COMPARE_M + #endif + } } diff --git a/src/modules/module_23400.c b/src/modules/module_23400.c index 3a69b5d57..d0e14a293 100644 --- a/src/modules/module_23400.c +++ b/src/modules/module_23400.c @@ -24,7 +24,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const char *ST_PASS = "hashcat1"; -static const char *ST_HASH = "$bitwarden$1*100000*bm9yZXBseUBoYXNoY2F0Lm5ldA==*CWCy4KZEEw1W92qB7xfLRNoJpepTMSyr7WJGZ0/Xr8c="; +static const char *ST_HASH = "$bitwarden$2*100000*bm9yZXBseUBoYXNoY2F0Lm5ldA==*CWCy4KZEEw1W92qB7xfLRNoJpepTMSyr7WJGZ0/Xr8c="; 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; } @@ -84,6 +84,11 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY return jit_build_options; } +u64 module_esalt_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 (u64) sizeof(u32); +} + 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 (bitwarden_tmp_t); @@ -104,6 +109,8 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con 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) { u32 *digest = (u32 *) digest_buf; + + u32 *ver = (u32 *) esalt_buf; hc_token_t token; @@ -146,8 +153,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE // version const u8 *version_pos = token.buf[1]; + const u32 version = *version_pos - 0x30; - if (version_pos[0] != '1') return (PARSER_SALT_VALUE); + if (version == 1 || version == 2) + { + *ver = version; + } + else return (PARSER_SALT_VALUE); // iter @@ -230,7 +242,7 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE base64_encode (int_to_base64, (const u8 *) tmp_buf, 32, (u8 *) hash_buf); - const int line_len = snprintf (line_buf, line_size, "%s1*%i*%s*%s", + const int line_len = snprintf (line_buf, line_size, "%s2*%i*%s*%s", SIGNATURE_BITWARDEN, salt->salt_iter + 1, salt_buf, @@ -258,7 +270,7 @@ void module_init (module_ctx_t *module_ctx) 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_esalt_size = module_esalt_size; module_ctx->module_extra_buffer_size = MODULE_DEFAULT; module_ctx->module_extra_tmp_size = MODULE_DEFAULT; module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT; diff --git a/tools/test_modules/m23400.pm b/tools/test_modules/m23400.pm index 4fd327845..d891ae046 100644 --- a/tools/test_modules/m23400.pm +++ b/tools/test_modules/m23400.pm @@ -38,7 +38,7 @@ sub module_generate_hash my $digest1 = $kdf1->PBKDF2 ($email, $word); my $digest2 = $kdf2->PBKDF2 ($word, $digest1); # position of $word switched ! - my $hash = sprintf ("\$bitwarden\$1*%d*%s*%s", $iter, encode_base64 ($email, ""), encode_base64 ($digest2, "")); + my $hash = sprintf ("\$bitwarden\$2*%d*%s*%s", $iter, encode_base64 ($email, ""), encode_base64 ($digest2, "")); return $hash; } @@ -54,7 +54,7 @@ sub module_verify_hash my $hash = substr ($line, 0, $idx); my $word = substr ($line, $idx + 1); - return unless substr ($hash, 0, 12) eq '$bitwarden$1'; + return unless substr ($hash, 0, 12) eq '$bitwarden$2'; my ($type, $iter, $salt_base64, $hash_base64) = split ('\*', $hash);