From 75f7172ccad95f7c523f57ccc6d00cdcbc6822a9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 12 Feb 2019 15:30:42 +0100 Subject: [PATCH] Prepare remove of hash_type variable --- include/modules.h | 1 - include/shared.h | 5 - include/tuningdb.h | 2 +- include/types.h | 25 +---- src/interface.c | 96 +---------------- src/modules/module_00000.c | 23 +++-- src/modules/module_00011.c | 23 +++-- src/modules/module_00012.c | 23 +++-- src/modules/module_00021.c | 25 +++-- src/modules/module_00023.c | 25 +++-- src/modules/module_00100.c | 37 +++++-- src/modules/module_00101.c | 37 +++++-- src/modules/module_00112.c | 37 +++++-- src/modules/module_00121.c | 33 +++++- src/modules/module_00124.c | 37 +++++-- src/modules/module_00200.c | 15 +-- src/modules/module_00300.c | 37 +++++-- src/modules/module_00900.c | 23 +++-- src/modules/module_01000.c | 23 +++-- src/modules/module_01100.c | 23 +++-- src/modules/module_01300.c | 45 ++++++-- src/modules/module_01400.c | 49 +++++++-- src/modules/module_01700.c | 48 +++++++-- src/modules/module_04900.c | 21 +++- src/modules/module_10800.c | 47 +++++++-- src/modules/module_18500.c | 37 +++++-- src/modules/module_99999.c | 16 +-- src/outfile.c | 2 +- src/potfile.c | 2 +- src/shared.c | 207 ------------------------------------- src/status.c | 2 +- src/tuningdb.c | 16 +-- 32 files changed, 553 insertions(+), 489 deletions(-) diff --git a/include/modules.h b/include/modules.h index fc6897fda..674ed4a40 100644 --- a/include/modules.h +++ b/include/modules.h @@ -22,7 +22,6 @@ u32 module_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *ha 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); 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); u32 module_hash_mode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); -u32 module_hash_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); bool module_hlfmt_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); u64 module_hook_salt_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); u64 module_hook_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); diff --git a/include/shared.h b/include/shared.h index 8a314424d..070f4c14b 100644 --- a/include/shared.h +++ b/include/shared.h @@ -93,9 +93,4 @@ bool parse_and_store_generic_salt (u8 *out_buf, int *out_len, const u8 *in_buf, int input_tokenizer (const u8 *input_buf, const int input_len, token_t *token); -void decoder_apply_optimizer (const hashconfig_t *hashconfig, void *data); -void decoder_apply_options (const hashconfig_t *hashconfig, void *data); -void encoder_apply_optimizer (const hashconfig_t *hashconfig, void *data); -void encoder_apply_options (const hashconfig_t *hashconfig, void *data); - #endif // _SHARED_H diff --git a/include/tuningdb.h b/include/tuningdb.h index 0d4c81856..60fb60e68 100644 --- a/include/tuningdb.h +++ b/include/tuningdb.h @@ -14,6 +14,6 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx); void tuning_db_destroy (hashcat_ctx_t *hashcat_ctx); -tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_type); +tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_mode); #endif // _TUNINGDB_H diff --git a/include/types.h b/include/types.h index 13a8ce8bb..2f458108e 100644 --- a/include/types.h +++ b/include/types.h @@ -344,7 +344,6 @@ typedef enum opti_type OPTI_TYPE_OPTIMIZED_KERNEL = (1 << 0), OPTI_TYPE_ZERO_BYTE = (1 << 1), OPTI_TYPE_PRECOMPUTE_INIT = (1 << 2), - OPTI_TYPE_PRECOMPUTE_MERKLE = (1 << 3), OPTI_TYPE_MEET_IN_MIDDLE = (1 << 4), OPTI_TYPE_EARLY_SKIP = (1 << 5), OPTI_TYPE_NOT_SALTED = (1 << 6), @@ -411,8 +410,6 @@ typedef enum opts_type OPTS_TYPE_PREFERED_THREAD = (1ULL << 41), // some algorithms (complicated ones with many branches) benefit from this OPTS_TYPE_PT_ADD06 = (1ULL << 42), OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 43), - OPTS_TYPE_STATE_BUFFER_LE = (1ULL << 44), - OPTS_TYPE_STATE_BUFFER_BE = (1ULL << 45), OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 46), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately } opts_type_t; @@ -911,7 +908,6 @@ struct hashconfig char separator; int hash_mode; - u32 hash_type; u32 salt_type; u32 attack_exec; u32 kern_type; @@ -1699,7 +1695,7 @@ typedef struct tuning_db_entry { const char *device_name; int attack_mode; - int hash_type; + int hash_mode; int workload_profile; int vector_width; int kernel_accel; @@ -2289,7 +2285,6 @@ typedef struct module_ctx u32 (*module_hash_category) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); const char *(*module_hash_name) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); int (*module_hash_mode) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); - u32 (*module_hash_type) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); bool (*module_hlfmt_disable) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); u64 (*module_hook_salt_size) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); u64 (*module_hook_size) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); @@ -2413,24 +2408,6 @@ typedef struct token #endif // _TYPES_H -/** - * hash types is relevant for host optimization of raw hashes - * others use GENERIC - */ - -typedef enum hash_type -{ - HASH_TYPE_GENERIC = 1, - HASH_TYPE_MD4 = 2, - HASH_TYPE_MD5 = 3, - HASH_TYPE_SHA1 = 4, - HASH_TYPE_SHA224 = 5, - HASH_TYPE_SHA256 = 6, - HASH_TYPE_SHA384 = 7, - HASH_TYPE_SHA512 = 8, - -} hash_type_t; - /** * hash category is relevant in usage.c (--help screen) */ diff --git a/src/interface.c b/src/interface.c index 980c09111..95f77e6f6 100644 --- a/src/interface.c +++ b/src/interface.c @@ -38,98 +38,10 @@ int ascii_digest (const hashconfig_t *hashconfig, const hashes_t *hashes, const return snprintf (out_buf, out_size, "%s", hashfile); } - //const u32 hash_type = hashconfig->hash_type; - //const u32 hash_mode = hashconfig->hash_mode; - //const u32 salt_type = hashconfig->salt_type; - - //u8 datax[256] = { 0 }; - - //u64 *digest_buf64 = (u64 *) datax; - //u32 *digest_buf = (u32 *) datax; - - char *digests_buf_ptr = (char *) digests_buf; - - //memcpy (digest_buf, digests_buf_ptr + (salts_buf[salt_pos].digests_offset * dgst_size) + (digest_pos * dgst_size), dgst_size); - - char *esalts_buf_ptr = (char *) esalts_buf; - + char *digests_buf_ptr = (char *) digests_buf; + char *esalts_buf_ptr = (char *) esalts_buf; char *hook_salts_buf_ptr = (char *) hook_salts_buf; - //salt_t salt; - - /* - - const bool isSalted = ((hashconfig->salt_type == SALT_TYPE_GENERIC) - | (hashconfig->salt_type == SALT_TYPE_EMBEDDED)); - - if (isSalted == true) - { - memcpy (&salt, &salts_buf[salt_pos], sizeof (salt_t)); - - char *ptr = (char *) salt.salt_buf; - - u32 salt_len = salt.salt_len; - - if (opts_type & OPTS_TYPE_ST_UTF16LE) - { - for (u32 i = 0, j = 0; i < salt_len; i += 1, j += 2) - { - ptr[i] = ptr[j]; - } - - salt_len = salt_len / 2; - } - - if (opts_type & OPTS_TYPE_ST_GENERATE_LE) - { - u32 max = salt.salt_len / 4; - - if (salt_len % 4) max++; - - for (u32 i = 0; i < max; i++) - { - salt.salt_buf[i] = byte_swap_32 (salt.salt_buf[i]); - } - } - - if (opts_type & OPTS_TYPE_ST_HEX) - { - char tmp[64] = { 0 }; - - for (u32 i = 0, j = 0; i < salt_len; i += 1, j += 2) - { - sprintf (tmp + j, "%02x", (unsigned char) ptr[i]); - } - - salt_len = salt_len * 2; - - memcpy (ptr, tmp, salt_len); - } - - u32 memset_size = ((SALT_MAX - (int) salt_len) > 0) ? (SALT_MAX - salt_len) : 0; - - memset (ptr + salt_len, 0, memset_size); - - salt.salt_len = salt_len; - } - else - { - memset (&salt, 0, sizeof (salt_t)); - } - */ - - // - // some modes require special encoding - // - - //u32 out_buf_plain[256] = { 0 }; - //u32 out_buf_salt[256] = { 0 }; - - //char tmp_buf[1024] = { 0 }; - - //char *ptr_plain = (char *) out_buf_plain; - //u8 *ptr_salt = (u8 *) out_buf_salt; - const u32 digest_cur = salts_buf[salt_pos].digests_offset + digest_pos; hashinfo_t *hash_info_ptr = NULL; @@ -305,7 +217,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) CHECK_DEFINED (module_ctx->module_hash_category); CHECK_DEFINED (module_ctx->module_hash_name); CHECK_DEFINED (module_ctx->module_hash_mode); - CHECK_DEFINED (module_ctx->module_hash_type); CHECK_DEFINED (module_ctx->module_hlfmt_disable); CHECK_DEFINED (module_ctx->module_hook_salt_size); CHECK_DEFINED (module_ctx->module_hook_size); @@ -374,7 +285,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) CHECK_MANDATORY (module_ctx->module_hash_encode); CHECK_MANDATORY (module_ctx->module_hash_category); CHECK_MANDATORY (module_ctx->module_hash_name); - CHECK_MANDATORY (module_ctx->module_hash_type); CHECK_MANDATORY (module_ctx->module_kern_type); CHECK_MANDATORY (module_ctx->module_opti_type); CHECK_MANDATORY (module_ctx->module_opts_type); @@ -392,7 +302,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->dgst_size = module_ctx->module_dgst_size (hashconfig, user_options, user_options_extra); hashconfig->hash_category = module_ctx->module_hash_category (hashconfig, user_options, user_options_extra); hashconfig->hash_name = module_ctx->module_hash_name (hashconfig, user_options, user_options_extra); - hashconfig->hash_type = module_ctx->module_hash_type (hashconfig, user_options, user_options_extra); hashconfig->kern_type = module_ctx->module_kern_type (hashconfig, user_options, user_options_extra); hashconfig->opti_type = module_ctx->module_opti_type (hashconfig, user_options, user_options_extra); hashconfig->opts_type = module_ctx->module_opts_type (hashconfig, user_options, user_options_extra); @@ -523,7 +432,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->opts_type &= ~OPTS_TYPE_ST_ADDBITS15; hashconfig->opti_type &= ~OPTI_TYPE_PRECOMPUTE_INIT; - hashconfig->opti_type &= ~OPTI_TYPE_PRECOMPUTE_MERKLE; hashconfig->opti_type &= ~OPTI_TYPE_MEET_IN_MIDDLE; hashconfig->opti_type &= ~OPTI_TYPE_PREPENDED_SALT; hashconfig->opti_type &= ~OPTI_TYPE_APPENDED_SALT; diff --git a/src/modules/module_00000.c b/src/modules/module_00000.c index aa355fc2e..67008b570 100644 --- a/src/modules/module_00000.c +++ b/src/modules/module_00000.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; static const char *HASH_NAME = "MD5"; -static const u32 HASH_TYPE = HASH_TYPE_MD5; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 0; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -76,9 +77,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = hex_to_u32 (hash_pos + 16); digest[3] = hex_to_u32 (hash_pos + 24); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } return (PARSER_OK); } @@ -97,9 +102,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = digest[2]; tmp[3] = digest[3]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00011.c b/src/modules/module_00011.c index f78ec700a..26e7bde62 100644 --- a/src/modules/module_00011.c +++ b/src/modules/module_00011.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; static const char *HASH_NAME = "Joomla < 2.5.18"; -static const u32 HASH_TYPE = HASH_TYPE_MD5; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 10; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -89,9 +90,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = hex_to_u32 (hash_pos + 16); digest[3] = hex_to_u32 (hash_pos + 24); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -117,9 +122,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = digest[2]; tmp[3] = digest[3]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00012.c b/src/modules/module_00012.c index 8de7b75a9..005795b19 100644 --- a/src/modules/module_00012.c +++ b/src/modules/module_00012.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_DATABASE_SERVER; static const char *HASH_NAME = "PostgreSQL"; -static const u32 HASH_TYPE = HASH_TYPE_MD5; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 10; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -80,9 +81,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = hex_to_u32 (hash_pos + 16); digest[3] = hex_to_u32 (hash_pos + 24); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -108,9 +113,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = digest[2]; tmp[3] = digest[3]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00021.c b/src/modules/module_00021.c index 9be21c83d..5e9d776da 100644 --- a/src/modules/module_00021.c +++ b/src/modules/module_00021.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; static const char *HASH_NAME = "osCommerce, xt:Commerce"; -static const u32 HASH_TYPE = HASH_TYPE_MD5; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 20; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -53,7 +54,7 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, 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; - + token_t token; token.token_cnt = 2; @@ -79,9 +80,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = hex_to_u32 (hash_pos + 16); digest[3] = hex_to_u32 (hash_pos + 24); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -107,9 +112,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = digest[2]; tmp[3] = digest[3]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00023.c b/src/modules/module_00023.c index bfde720e8..c0834f0b9 100644 --- a/src/modules/module_00023.c +++ b/src/modules/module_00023.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_PROTOCOL; static const char *HASH_NAME = "Skype"; -static const u32 HASH_TYPE = HASH_TYPE_MD5; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 20; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -80,9 +81,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = hex_to_u32 (hash_pos + 16); digest[3] = hex_to_u32 (hash_pos + 24); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD5M_A; + digest[1] -= MD5M_B; + digest[2] -= MD5M_C; + digest[3] -= MD5M_D; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -90,7 +95,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE const bool parse_rc = parse_and_store_generic_salt ((u8 *) salt->salt_buf, (int *) &salt->salt_len, salt_pos, salt_len, hashconfig); if (parse_rc == false) return (PARSER_SALT_LENGTH); - + /* * add static "salt" part */ @@ -115,9 +120,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = digest[2]; tmp[3] = digest[3]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD5M_A; + tmp[1] += MD5M_B; + tmp[2] += MD5M_C; + tmp[3] += MD5M_D; + } u8 tmp_buf[128]; diff --git a/src/modules/module_00100.c b/src/modules/module_00100.c index 5dc2417a0..0d0ae4225 100644 --- a/src/modules/module_00100.c +++ b/src/modules/module_00100.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; static const char *HASH_NAME = "SHA1"; -static const u32 HASH_TYPE = HASH_TYPE_SHA1; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 100; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -76,9 +77,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = hex_to_u32 (hash_pos + 24); digest[4] = hex_to_u32 (hash_pos + 32); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA1M_A; + digest[1] -= SHA1M_B; + digest[2] -= SHA1M_C; + digest[3] -= SHA1M_D; + digest[4] -= SHA1M_E; + } return (PARSER_OK); } @@ -98,9 +110,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[3] = digest[3]; tmp[4] = digest[4]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA1M_A; + tmp[1] += SHA1M_B; + tmp[2] += SHA1M_C; + tmp[3] += SHA1M_D; + tmp[4] += SHA1M_E; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00101.c b/src/modules/module_00101.c index 872680b72..26b89a34f 100644 --- a/src/modules/module_00101.c +++ b/src/modules/module_00101.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_NETWORK_SERVER; static const char *HASH_NAME = "nsldap, SHA-1(Base64), Netscape LDAP SHA"; -static const u32 HASH_TYPE = HASH_TYPE_SHA1; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 100; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -84,9 +85,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE memcpy (digest, tmp_buf, 20); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA1M_A; + digest[1] -= SHA1M_B; + digest[2] -= SHA1M_C; + digest[3] -= SHA1M_D; + digest[4] -= SHA1M_E; + } return (PARSER_OK); } @@ -106,9 +118,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[3] = digest[3]; tmp[4] = digest[4]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA1M_A; + tmp[1] += SHA1M_B; + tmp[2] += SHA1M_C; + tmp[3] += SHA1M_D; + tmp[4] += SHA1M_E; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); u8 ptr_plain[100] = { 0 }; diff --git a/src/modules/module_00112.c b/src/modules/module_00112.c index 49d68bf23..3524914f2 100644 --- a/src/modules/module_00112.c +++ b/src/modules/module_00112.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_DATABASE_SERVER; static const char *HASH_NAME = "Oracle S: Type (Oracle 11+)"; -static const u32 HASH_TYPE = HASH_TYPE_SHA1; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 110; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -90,9 +91,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = hex_to_u32 (hash_pos + 24); digest[4] = hex_to_u32 (hash_pos + 32); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA1M_A; + digest[1] -= SHA1M_B; + digest[2] -= SHA1M_C; + digest[3] -= SHA1M_D; + digest[4] -= SHA1M_E; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -119,9 +131,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[3] = digest[3]; tmp[4] = digest[4]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA1M_A; + tmp[1] += SHA1M_B; + tmp[2] += SHA1M_C; + tmp[3] += SHA1M_D; + tmp[4] += SHA1M_E; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00121.c b/src/modules/module_00121.c index 7d22c87f8..1204e155f 100644 --- a/src/modules/module_00121.c +++ b/src/modules/module_00121.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; static const char *HASH_NAME = "SMF (Simple Machines Forum) > v1.1"; -static const u32 HASH_TYPE = HASH_TYPE_SHA1; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 120; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -90,9 +91,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = hex_to_u32 (hash_pos + 24); digest[4] = hex_to_u32 (hash_pos + 32); - decoder_apply_options (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA1M_A; + digest[1] -= SHA1M_B; + digest[2] -= SHA1M_C; + digest[3] -= SHA1M_D; + digest[4] -= SHA1M_E; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -119,9 +131,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[3] = digest[3]; tmp[4] = digest[4]; - encoder_apply_optimizer (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA1M_A; + tmp[1] += SHA1M_B; + tmp[2] += SHA1M_C; + tmp[3] += SHA1M_D; + tmp[4] += SHA1M_E; + } - encoder_apply_options (hashconfig, tmp); + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00124.c b/src/modules/module_00124.c index a01adb506..cb1d3bcf8 100644 --- a/src/modules/module_00124.c +++ b/src/modules/module_00124.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE; static const char *HASH_NAME = "Django (SHA-1)"; -static const u32 HASH_TYPE = HASH_TYPE_SHA1; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 120; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -89,9 +90,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = hex_to_u32 (hash_pos + 24); digest[4] = hex_to_u32 (hash_pos + 32); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA1M_A; + digest[1] -= SHA1M_B; + digest[2] -= SHA1M_C; + digest[3] -= SHA1M_D; + digest[4] -= SHA1M_E; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -118,9 +130,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[3] = digest[3]; tmp[4] = digest[4]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA1M_A; + tmp[1] += SHA1M_B; + tmp[2] += SHA1M_C; + tmp[3] += SHA1M_D; + tmp[4] += SHA1M_E; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); char tmp_salt[SALT_MAX]; diff --git a/src/modules/module_00200.c b/src/modules/module_00200.c index d3afdcf8d..efa3822f7 100644 --- a/src/modules/module_00200.c +++ b/src/modules/module_00200.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -66,9 +67,10 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = 0; digest[3] = 0; - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = 0; + digest[3] = 0; return (PARSER_OK); } @@ -87,9 +89,10 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = 0; tmp[3] = 0; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = 0; + tmp[3] = 0; u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00300.c b/src/modules/module_00300.c index 7a444397b..0cdd9c829 100644 --- a/src/modules/module_00300.c +++ b/src/modules/module_00300.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_DATABASE_SERVER; static const char *HASH_NAME = "MySQL4.1/MySQL5"; -static const u32 HASH_TYPE = HASH_TYPE_SHA1; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 300; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -75,9 +76,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = hex_to_u32 (hash_pos + 24); digest[4] = hex_to_u32 (hash_pos + 32); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA1M_A; + digest[1] -= SHA1M_B; + digest[2] -= SHA1M_C; + digest[3] -= SHA1M_D; + digest[4] -= SHA1M_E; + } return (PARSER_OK); } @@ -97,9 +109,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[3] = digest[3]; tmp[4] = digest[4]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA1M_A; + tmp[1] += SHA1M_B; + tmp[2] += SHA1M_C; + tmp[3] += SHA1M_D; + tmp[4] += SHA1M_E; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_00900.c b/src/modules/module_00900.c index 0295dc5f6..54613a2d7 100644 --- a/src/modules/module_00900.c +++ b/src/modules/module_00900.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; static const char *HASH_NAME = "MD4"; -static const u32 HASH_TYPE = HASH_TYPE_MD4; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 900; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -76,9 +77,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = hex_to_u32 (hash_pos + 16); digest[3] = hex_to_u32 (hash_pos + 24); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD4M_A; + digest[1] -= MD4M_B; + digest[2] -= MD4M_C; + digest[3] -= MD4M_D; + } return (PARSER_OK); } @@ -97,9 +102,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = digest[2]; tmp[3] = digest[3]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD4M_A; + tmp[1] += MD4M_B; + tmp[2] += MD4M_C; + tmp[3] += MD4M_D; + } u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_01000.c b/src/modules/module_01000.c index 371c28d89..106d8e270 100644 --- a/src/modules/module_01000.c +++ b/src/modules/module_01000.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; static const char *HASH_NAME = "NTLM"; -static const u32 HASH_TYPE = HASH_TYPE_MD4; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 1000; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -79,9 +80,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = hex_to_u32 (hash_pos + 16); digest[3] = hex_to_u32 (hash_pos + 24); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD4M_A; + digest[1] -= MD4M_B; + digest[2] -= MD4M_C; + digest[3] -= MD4M_D; + } return (PARSER_OK); } @@ -100,9 +105,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = digest[2]; tmp[3] = digest[3]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD4M_A; + tmp[1] += MD4M_B; + tmp[2] += MD4M_C; + tmp[3] += MD4M_D; + } u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_01100.c b/src/modules/module_01100.c index 5928a5352..b0750e23b 100644 --- a/src/modules/module_01100.c +++ b/src/modules/module_01100.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 0; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; static const char *HASH_NAME = "Domain Cached Credentials (DCC), MS Cache"; -static const u32 HASH_TYPE = HASH_TYPE_MD4; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 1100; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -90,9 +91,13 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[2] = hex_to_u32 (hash_pos + 16); digest[3] = hex_to_u32 (hash_pos + 24); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD4M_A; + digest[1] -= MD4M_B; + digest[2] -= MD4M_C; + digest[3] -= MD4M_D; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -118,9 +123,13 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[2] = digest[2]; tmp[3] = digest[3]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD4M_A; + tmp[1] += MD4M_B; + tmp[2] += MD4M_C; + tmp[3] += MD4M_D; + } u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_01300.c b/src/modules/module_01300.c index 2ce3a398c..395b59b3e 100644 --- a/src/modules/module_01300.c +++ b/src/modules/module_01300.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 6; static const u32 DGST_SIZE = DGST_SIZE_4_7; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; static const char *HASH_NAME = "SHA2-224"; -static const u32 HASH_TYPE = HASH_TYPE_SHA224; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 1300; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -78,9 +79,24 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[5] = hex_to_u32 (hash_pos + 40); digest[6] = hex_to_u32 (hash_pos + 48); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA224M_A; + digest[1] -= SHA224M_B; + digest[2] -= SHA224M_C; + digest[3] -= SHA224M_D; + digest[4] -= SHA224M_E; + digest[5] -= SHA224M_F; + digest[6] -= SHA224M_G; + } return (PARSER_OK); } @@ -102,9 +118,24 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[5] = digest[5]; tmp[6] = digest[6]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA224M_A; + tmp[1] += SHA224M_B; + tmp[2] += SHA224M_C; + tmp[3] += SHA224M_D; + tmp[4] += SHA224M_E; + tmp[5] += SHA224M_F; + tmp[6] += SHA224M_G; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); + tmp[5] = byte_swap_32 (tmp[5]); + tmp[6] = byte_swap_32 (tmp[6]); u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_01400.c b/src/modules/module_01400.c index 568b913e1..6e25a341d 100644 --- a/src/modules/module_01400.c +++ b/src/modules/module_01400.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 6; static const u32 DGST_SIZE = DGST_SIZE_4_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; static const char *HASH_NAME = "SHA2-256"; -static const u32 HASH_TYPE = HASH_TYPE_SHA256; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 1400; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -79,9 +80,26 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[6] = hex_to_u32 (hash_pos + 48); digest[7] = hex_to_u32 (hash_pos + 56); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + digest[5] = byte_swap_32 (digest[5]); + digest[6] = byte_swap_32 (digest[6]); + digest[7] = byte_swap_32 (digest[7]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA256M_A; + digest[1] -= SHA256M_B; + digest[2] -= SHA256M_C; + digest[3] -= SHA256M_D; + digest[4] -= SHA256M_E; + digest[5] -= SHA256M_F; + digest[6] -= SHA256M_G; + digest[7] -= SHA256M_H; + } return (PARSER_OK); } @@ -104,9 +122,26 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[6] = digest[6]; tmp[7] = digest[7]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA256M_A; + tmp[1] += SHA256M_B; + tmp[2] += SHA256M_C; + tmp[3] += SHA256M_D; + tmp[4] += SHA256M_E; + tmp[5] += SHA256M_F; + tmp[6] += SHA256M_G; + tmp[7] += SHA256M_H; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); + tmp[5] = byte_swap_32 (tmp[5]); + tmp[6] = byte_swap_32 (tmp[6]); + tmp[7] = byte_swap_32 (tmp[7]); u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_01700.c b/src/modules/module_01700.c index e6962f2e8..a6721062b 100644 --- a/src/modules/module_01700.c +++ b/src/modules/module_01700.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 14; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 7; static const u32 DGST_SIZE = DGST_SIZE_8_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; static const char *HASH_NAME = "SHA2-512"; -static const u32 HASH_TYPE = HASH_TYPE_SHA512; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 1700; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -80,9 +81,26 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[6] = hex_to_u64 (hash_pos + 96); digest[7] = hex_to_u64 (hash_pos + 112); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = byte_swap_64 (digest[6]); + digest[7] = byte_swap_64 (digest[7]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA512M_A; + digest[1] -= SHA512M_B; + digest[2] -= SHA512M_C; + digest[3] -= SHA512M_D; + digest[4] -= SHA512M_E; + digest[5] -= SHA512M_F; + digest[6] -= SHA512M_G; + digest[7] -= SHA512M_H; + } return (PARSER_OK); } @@ -105,9 +123,27 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[6] = digest[6]; tmp[7] = digest[7]; - encoder_apply_optimizer (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA512M_A; + tmp[1] += SHA512M_B; + tmp[2] += SHA512M_C; + tmp[3] += SHA512M_D; + tmp[4] += SHA512M_E; + tmp[5] += SHA512M_F; + tmp[6] += SHA512M_G; + tmp[7] += SHA512M_H; + } + + tmp[0] = byte_swap_64 (tmp[0]); + tmp[1] = byte_swap_64 (tmp[1]); + tmp[2] = byte_swap_64 (tmp[2]); + tmp[3] = byte_swap_64 (tmp[3]); + tmp[4] = byte_swap_64 (tmp[4]); + tmp[5] = byte_swap_64 (tmp[5]); + tmp[6] = byte_swap_64 (tmp[6]); + tmp[7] = byte_swap_64 (tmp[7]); - encoder_apply_options (hashconfig, tmp); u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_04900.c b/src/modules/module_04900.c index d637b430e..ae3fa8a7b 100644 --- a/src/modules/module_04900.c +++ b/src/modules/module_04900.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; static const char *HASH_NAME = "sha1($salt.$pass.$salt)"; -static const u32 HASH_TYPE = HASH_TYPE_SHA1; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 4900; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -90,7 +91,14 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = byte_swap_32 (digest[3]); digest[4] = byte_swap_32 (digest[4]); - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA1M_A; + digest[1] -= SHA1M_B; + digest[2] -= SHA1M_C; + digest[3] -= SHA1M_D; + digest[4] -= SHA1M_E; + } const u8 *salt_pos = token.buf[1]; const int salt_len = token.len[1]; @@ -117,7 +125,14 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[3] = digest[3]; tmp[4] = digest[4]; - encoder_apply_optimizer (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA1M_A; + tmp[1] += SHA1M_B; + tmp[2] += SHA1M_C; + tmp[3] += SHA1M_D; + tmp[4] += SHA1M_E; + } tmp[0] = byte_swap_32 (tmp[0]); tmp[1] = byte_swap_32 (tmp[1]); diff --git a/src/modules/module_10800.c b/src/modules/module_10800.c index eb0723f5a..8cf26adc8 100644 --- a/src/modules/module_10800.c +++ b/src/modules/module_10800.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 6; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 5; static const u32 DGST_SIZE = DGST_SIZE_8_8; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; static const char *HASH_NAME = "SHA2-384"; -static const u32 HASH_TYPE = HASH_TYPE_SHA384; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 10800; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -80,9 +81,26 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[6] = 0; digest[7] = 0; - decoder_apply_options (hashconfig, digest); + digest[0] = byte_swap_64 (digest[0]); + digest[1] = byte_swap_64 (digest[1]); + digest[2] = byte_swap_64 (digest[2]); + digest[3] = byte_swap_64 (digest[3]); + digest[4] = byte_swap_64 (digest[4]); + digest[5] = byte_swap_64 (digest[5]); + digest[6] = 0; + digest[7] = 0; - decoder_apply_optimizer (hashconfig, digest); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA384M_A; + digest[1] -= SHA384M_B; + digest[2] -= SHA384M_C; + digest[3] -= SHA384M_D; + digest[4] -= SHA384M_E; + digest[5] -= SHA384M_F; + digest[6] -= 0; + digest[7] -= 0; + } return (PARSER_OK); } @@ -105,9 +123,26 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[6] = 0; tmp[7] = 0; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA384M_A; + tmp[1] += SHA384M_B; + tmp[2] += SHA384M_C; + tmp[3] += SHA384M_D; + tmp[4] += SHA384M_E; + tmp[5] += SHA384M_F; + tmp[6] += 0; + tmp[7] += 0; + } + + tmp[0] = byte_swap_64 (tmp[0]); + tmp[1] = byte_swap_64 (tmp[1]); + tmp[2] = byte_swap_64 (tmp[2]); + tmp[3] = byte_swap_64 (tmp[3]); + tmp[4] = byte_swap_64 (tmp[4]); + tmp[5] = byte_swap_64 (tmp[5]); + tmp[6] = 0; + tmp[7] = 0; u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_18500.c b/src/modules/module_18500.c index 2561a083c..97f97969e 100644 --- a/src/modules/module_18500.c +++ b/src/modules/module_18500.c @@ -9,6 +9,7 @@ #include "bitops.h" #include "convert.h" #include "shared.h" +#include "inc_hash_constants.h" static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; static const u32 DGST_POS0 = 3; @@ -18,7 +19,7 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH_SALTED; static const char *HASH_NAME = "sha1(md5(md5($pass)))"; -static const u32 HASH_TYPE = HASH_TYPE_SHA1; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 18500; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT @@ -76,9 +77,20 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE digest[3] = hex_to_u32 (hash_pos + 24); digest[4] = hex_to_u32 (hash_pos + 32); - decoder_apply_options (hashconfig, digest); - - decoder_apply_optimizer (hashconfig, digest); + digest[0] = byte_swap_32 (digest[0]); + digest[1] = byte_swap_32 (digest[1]); + digest[2] = byte_swap_32 (digest[2]); + digest[3] = byte_swap_32 (digest[3]); + digest[4] = byte_swap_32 (digest[4]); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= SHA1M_A; + digest[1] -= SHA1M_B; + digest[2] -= SHA1M_C; + digest[3] -= SHA1M_D; + digest[4] -= SHA1M_E; + } return (PARSER_OK); } @@ -98,9 +110,20 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE tmp[3] = digest[3]; tmp[4] = digest[4]; - encoder_apply_optimizer (hashconfig, tmp); - - encoder_apply_options (hashconfig, tmp); + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += SHA1M_A; + tmp[1] += SHA1M_B; + tmp[2] += SHA1M_C; + tmp[3] += SHA1M_D; + tmp[4] += SHA1M_E; + } + + tmp[0] = byte_swap_32 (tmp[0]); + tmp[1] = byte_swap_32 (tmp[1]); + tmp[2] = byte_swap_32 (tmp[2]); + tmp[3] = byte_swap_32 (tmp[3]); + tmp[4] = byte_swap_32 (tmp[4]); u8 *out_buf = (u8 *) line_buf; diff --git a/src/modules/module_99999.c b/src/modules/module_99999.c index 037346923..e922cb41f 100644 --- a/src/modules/module_99999.c +++ b/src/modules/module_99999.c @@ -21,8 +21,8 @@ static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_32; // originally DGST_SIZE_4_; static const u32 HASH_CATEGORY = HASH_CATEGORY_PLAIN; static const char *HASH_NAME = "Plaintext"; -static const u32 HASH_TYPE = HASH_TYPE_MD4; -static const u64 KERN_TYPE = 1000; +static const u32 HASH_TYPE = HASH_TYPE_GENERIC; +static const u64 KERN_TYPE = 900; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE | OPTI_TYPE_PRECOMPUTE_INIT | OPTI_TYPE_PRECOMPUTE_MERKLE @@ -101,15 +101,19 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE md4_64 (w, dgst); - decoder_apply_options (hashconfig, dgst); - - decoder_apply_optimizer (hashconfig, dgst); - digest[0] = dgst[0]; digest[1] = dgst[1]; digest[2] = dgst[2]; digest[3] = dgst[3]; + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD4M_A; + digest[1] -= MD4M_B; + digest[2] -= MD4M_C; + digest[3] -= MD4M_D; + } + return (PARSER_OK); } diff --git a/src/outfile.c b/src/outfile.c index 375ec3c86..8a4da5365 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -475,7 +475,7 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const int ou { if (user_options->outfile_autohex == true) { - const bool always_ascii = (hashconfig->hash_type & OPTS_TYPE_PT_ALWAYS_ASCII) ? true : false; + const bool always_ascii = (hashconfig->opts_type & OPTS_TYPE_PT_ALWAYS_ASCII) ? true : false; convert_to_hex = need_hexify (plain_ptr, plain_len, hashconfig->separator, always_ascii); } diff --git a/src/potfile.c b/src/potfile.c index e9b8379a3..a7d3db540 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -265,7 +265,7 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, cons if (1) { - const bool always_ascii = (hashconfig->hash_type & OPTS_TYPE_PT_ALWAYS_ASCII) ? true : false; + const bool always_ascii = (hashconfig->opts_type & OPTS_TYPE_PT_ALWAYS_ASCII) ? true : false; if ((user_options->outfile_autohex == true) && (need_hexify (plain_ptr, plain_len, hashconfig->separator, always_ascii) == true)) { diff --git a/src/shared.c b/src/shared.c index 09ad14a41..31b8053cd 100644 --- a/src/shared.c +++ b/src/shared.c @@ -921,7 +921,6 @@ const char *stroptitype (const u32 opti_type) case OPTI_TYPE_OPTIMIZED_KERNEL: return OPTI_STR_OPTIMIZED_KERNEL; case OPTI_TYPE_ZERO_BYTE: return OPTI_STR_ZERO_BYTE; case OPTI_TYPE_PRECOMPUTE_INIT: return OPTI_STR_PRECOMPUTE_INIT; - case OPTI_TYPE_PRECOMPUTE_MERKLE: return OPTI_STR_PRECOMPUTE_MERKLE; case OPTI_TYPE_MEET_IN_MIDDLE: return OPTI_STR_MEET_IN_MIDDLE; case OPTI_TYPE_EARLY_SKIP: return OPTI_STR_EARLY_SKIP; case OPTI_TYPE_NOT_SALTED: return OPTI_STR_NOT_SALTED; @@ -1120,212 +1119,6 @@ int input_tokenizer (const u8 *input_buf, const int input_len, token_t *token) return PARSER_OK; } -void decoder_apply_optimizer (const hashconfig_t *hashconfig, void *data) -{ - const u32 hash_type = hashconfig->hash_type; - const u32 opti_type = hashconfig->opti_type; - - u32 *digest_buf32 = (u32 *) data; - u64 *digest_buf64 = (u64 *) data; - - if (opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) - { - switch (hash_type) - { - case HASH_TYPE_MD4: - digest_buf32[0] -= MD4M_A; - digest_buf32[1] -= MD4M_B; - digest_buf32[2] -= MD4M_C; - digest_buf32[3] -= MD4M_D; - break; - - case HASH_TYPE_MD5: - digest_buf32[0] -= MD5M_A; - digest_buf32[1] -= MD5M_B; - digest_buf32[2] -= MD5M_C; - digest_buf32[3] -= MD5M_D; - break; - - case HASH_TYPE_SHA1: - digest_buf32[0] -= SHA1M_A; - digest_buf32[1] -= SHA1M_B; - digest_buf32[2] -= SHA1M_C; - digest_buf32[3] -= SHA1M_D; - digest_buf32[4] -= SHA1M_E; - break; - - case HASH_TYPE_SHA224: - digest_buf32[0] -= SHA224M_A; - digest_buf32[1] -= SHA224M_B; - digest_buf32[2] -= SHA224M_C; - digest_buf32[3] -= SHA224M_D; - digest_buf32[4] -= SHA224M_E; - digest_buf32[5] -= SHA224M_F; - digest_buf32[6] -= SHA224M_G; - break; - - case HASH_TYPE_SHA256: - digest_buf32[0] -= SHA256M_A; - digest_buf32[1] -= SHA256M_B; - digest_buf32[2] -= SHA256M_C; - digest_buf32[3] -= SHA256M_D; - digest_buf32[4] -= SHA256M_E; - digest_buf32[5] -= SHA256M_F; - digest_buf32[6] -= SHA256M_G; - digest_buf32[7] -= SHA256M_H; - break; - - case HASH_TYPE_SHA384: - digest_buf64[0] -= SHA384M_A; - digest_buf64[1] -= SHA384M_B; - digest_buf64[2] -= SHA384M_C; - digest_buf64[3] -= SHA384M_D; - digest_buf64[4] -= SHA384M_E; - digest_buf64[5] -= SHA384M_F; - digest_buf64[6] -= 0; - digest_buf64[7] -= 0; - break; - - case HASH_TYPE_SHA512: - digest_buf64[0] -= SHA512M_A; - digest_buf64[1] -= SHA512M_B; - digest_buf64[2] -= SHA512M_C; - digest_buf64[3] -= SHA512M_D; - digest_buf64[4] -= SHA512M_E; - digest_buf64[5] -= SHA512M_F; - digest_buf64[6] -= SHA512M_G; - digest_buf64[7] -= SHA512M_H; - break; - } - } -} - -void encoder_apply_optimizer (const hashconfig_t *hashconfig, void *data) -{ - const u32 hash_type = hashconfig->hash_type; - const u32 opti_type = hashconfig->opti_type; - - u32 *digest_buf32 = (u32 *) data; - u64 *digest_buf64 = (u64 *) data; - - if (opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) - { - switch (hash_type) - { - case HASH_TYPE_MD4: - digest_buf32[0] += MD4M_A; - digest_buf32[1] += MD4M_B; - digest_buf32[2] += MD4M_C; - digest_buf32[3] += MD4M_D; - break; - - case HASH_TYPE_MD5: - digest_buf32[0] += MD5M_A; - digest_buf32[1] += MD5M_B; - digest_buf32[2] += MD5M_C; - digest_buf32[3] += MD5M_D; - break; - - case HASH_TYPE_SHA1: - digest_buf32[0] += SHA1M_A; - digest_buf32[1] += SHA1M_B; - digest_buf32[2] += SHA1M_C; - digest_buf32[3] += SHA1M_D; - digest_buf32[4] += SHA1M_E; - break; - - case HASH_TYPE_SHA224: - digest_buf32[0] += SHA224M_A; - digest_buf32[1] += SHA224M_B; - digest_buf32[2] += SHA224M_C; - digest_buf32[3] += SHA224M_D; - digest_buf32[4] += SHA224M_E; - digest_buf32[5] += SHA224M_F; - digest_buf32[6] += SHA224M_G; - break; - - case HASH_TYPE_SHA256: - digest_buf32[0] += SHA256M_A; - digest_buf32[1] += SHA256M_B; - digest_buf32[2] += SHA256M_C; - digest_buf32[3] += SHA256M_D; - digest_buf32[4] += SHA256M_E; - digest_buf32[5] += SHA256M_F; - digest_buf32[6] += SHA256M_G; - digest_buf32[7] += SHA256M_H; - break; - - case HASH_TYPE_SHA384: - digest_buf64[0] += SHA384M_A; - digest_buf64[1] += SHA384M_B; - digest_buf64[2] += SHA384M_C; - digest_buf64[3] += SHA384M_D; - digest_buf64[4] += SHA384M_E; - digest_buf64[5] += SHA384M_F; - digest_buf64[6] += 0; - digest_buf64[7] += 0; - break; - - case HASH_TYPE_SHA512: - digest_buf64[0] += SHA512M_A; - digest_buf64[1] += SHA512M_B; - digest_buf64[2] += SHA512M_C; - digest_buf64[3] += SHA512M_D; - digest_buf64[4] += SHA512M_E; - digest_buf64[5] += SHA512M_F; - digest_buf64[6] += SHA512M_G; - digest_buf64[7] += SHA512M_H; - break; - } - } -} - -void decoder_apply_options (const hashconfig_t *hashconfig, void *data) -{ - const u32 opti_type = hashconfig->opti_type; - const u64 opts_type = hashconfig->opts_type; - const u32 dgst_size = hashconfig->dgst_size; - - if (opts_type & OPTS_TYPE_STATE_BUFFER_BE) - { - if (opti_type & OPTI_TYPE_USES_BITS_64) - { - u64 *digest_buf64 = (u64 *) data; - - for (u32 i = 0; i < dgst_size / 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); - } - else - { - u32 *digest_buf32 = (u32 *) data; - - for (u32 i = 0; i < dgst_size / 4; i++) digest_buf32[i] = byte_swap_32 (digest_buf32[i]); - } - } -} - -void encoder_apply_options (const hashconfig_t *hashconfig, void *data) -{ - const u32 opti_type = hashconfig->opti_type; - const u64 opts_type = hashconfig->opts_type; - const u32 dgst_size = hashconfig->dgst_size; - - if (opts_type & OPTS_TYPE_STATE_BUFFER_BE) - { - if (opti_type & OPTI_TYPE_USES_BITS_64) - { - u64 *digest_buf64 = (u64 *) data; - - for (u32 i = 0; i < dgst_size / 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); - } - else - { - u32 *digest_buf32 = (u32 *) data; - - for (u32 i = 0; i < dgst_size / 4; i++) digest_buf32[i] = byte_swap_32 (digest_buf32[i]); - } - } -} - bool parse_and_store_generic_salt (u8 *out_buf, int *out_len, const u8 *in_buf, const int in_len, MAYBE_UNUSED const hashconfig_t *hashconfig) { u32 tmp_u32[(64 * 2) + 1] = { 0 }; diff --git a/src/status.c b/src/status.c index ac0b9b031..d9ba34dea 100644 --- a/src/status.c +++ b/src/status.c @@ -873,7 +873,7 @@ char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const i build_plain ((hashcat_ctx_t *) hashcat_ctx, device_param, &plain1, plain_buf1, &plain_len1); build_plain ((hashcat_ctx_t *) hashcat_ctx, device_param, &plain2, plain_buf2, &plain_len2); - const bool always_ascii = (hashconfig->hash_type & OPTS_TYPE_PT_ALWAYS_ASCII) ? true : false; + const bool always_ascii = (hashconfig->opts_type & OPTS_TYPE_PT_ALWAYS_ASCII) ? true : false; const bool need_hex1 = need_hexify (plain_ptr1, plain_len1, 0, always_ascii); const bool need_hex2 = need_hexify (plain_ptr2, plain_len2, 0, always_ascii); diff --git a/src/tuningdb.c b/src/tuningdb.c index ff0993990..8418c8a9d 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -43,8 +43,8 @@ static int sort_by_tuning_db_entry (const void *v1, const void *v2) if (res2 != 0) return (res2); - const int res3 = t1->hash_type - - t2->hash_type; + const int res3 = t1->hash_mode + - t2->hash_mode; if (res3 != 0) return (res3); @@ -174,13 +174,13 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) char *device_name = token_ptr[0]; int attack_mode = -1; - int hash_type = -1; + int hash_mode = -1; int vector_width = -1; int kernel_accel = -1; int kernel_loops = -1; if (token_ptr[1][0] != '*') attack_mode = (int) strtol (token_ptr[1], NULL, 10); - if (token_ptr[2][0] != '*') hash_type = (int) strtol (token_ptr[2], NULL, 10); + if (token_ptr[2][0] != '*') hash_mode = (int) strtol (token_ptr[2], NULL, 10); if (token_ptr[3][0] != 'N') vector_width = (int) strtol (token_ptr[3], NULL, 10); if (token_ptr[4][0] == 'A') @@ -259,7 +259,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) entry->device_name = hcstrdup (device_name); entry->attack_mode = attack_mode; - entry->hash_type = hash_type; + entry->hash_mode = hash_mode; entry->vector_width = vector_width; entry->kernel_accel = kernel_accel; entry->kernel_loops = kernel_loops; @@ -317,7 +317,7 @@ void tuning_db_destroy (hashcat_ctx_t *hashcat_ctx) memset (tuning_db, 0, sizeof (tuning_db_t)); } -tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_type) +tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *device_name, const cl_device_type device_type, int attack_mode, const int hash_mode) { tuning_db_t *tuning_db = hashcat_ctx->tuning_db; @@ -366,7 +366,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev s.device_name = device_name_nospace; s.attack_mode = attack_mode; - s.hash_type = hash_type; + s.hash_mode = hash_mode; tuning_db_entry_t *entry = NULL; @@ -376,7 +376,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev { s.device_name = (i & 1) ? "*" : device_name_nospace; s.attack_mode = (i & 2) ? -1 : attack_mode; - s.hash_type = (i & 4) ? -1 : hash_type; + s.hash_mode = (i & 4) ? -1 : hash_mode; entry = bsearch (&s, tuning_db->entry_buf, tuning_db->entry_cnt, sizeof (tuning_db_entry_t), sort_by_tuning_db_entry);