From ca169a890ca5de4e7fa9db91269f04498f9fc4b2 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 15 Dec 2018 19:46:55 +0100 Subject: [PATCH] Add more global default value functions --- include/interface.h | 42 +- include/modules.h | 14 +- include/types.h | 8 +- modules/m01000.c | 214 +++-- src/interface.c | 1819 ++++++++++++++++++++++--------------------- src/outfile.c | 4 +- 6 files changed, 1111 insertions(+), 990 deletions(-) diff --git a/include/interface.h b/include/interface.h index 0f80735a1..c41838467 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1718,23 +1718,33 @@ u32 hashconfig_forced_kernel_threads (hashcat_ctx_t *hashcat_ctx); u32 hashconfig_get_kernel_threads (hashcat_ctx_t *hashcat_ctx, const hc_device_param_t *device_param); u32 hashconfig_get_kernel_loops (hashcat_ctx_t *hashcat_ctx); int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx); -int hashconfig_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); -int hashconfig_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); -int hashconfig_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); -int hashconfig_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt, void *hook_salt); -const char *hashconfig_benchmark_mask (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 hashconfig_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); -u64 hashconfig_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); -u32 hashconfig_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); -u64 hashconfig_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 hashconfig_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); -u32 hashconfig_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); -u64 hashconfig_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); -u32 hashconfig_benchmark_salt_len (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 hashconfig_benchmark_salt_iter (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 *hashconfig_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); -const char *hashconfig_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); + +u32 default_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); +const char *default_benchmark_mask (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 default_benchmark_salt_len (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 default_benchmark_salt_iter (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 default_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); +u32 default_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); +u32 default_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); +u32 default_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); +u32 default_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); +u64 default_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); +const char *default_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 default_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); +u64 default_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 default_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); +u64 default_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); +u32 default_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); +u64 default_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); +u32 default_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +u32 default_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +u32 default_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +u32 default_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +u32 default_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); +const char *default_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); +const char *default_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); +u64 default_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); void decoder_apply_optimizer (const hashconfig_t *hashconfig, void *data); void decoder_apply_options (const hashconfig_t *hashconfig, void *data); diff --git a/include/modules.h b/include/modules.h index 9ef4d2195..b2612c2ff 100644 --- a/include/modules.h +++ b/include/modules.h @@ -19,18 +19,18 @@ u64 module_hook_size (MAYBE_UNUSED const hashconfig_t *hashco 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); 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); 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); +u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); 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); 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); 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); 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); -u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); -u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); -u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); -u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); -void module_register (module_ctx_t *module_ctx); +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, const char *line_buf, MAYBE_UNUSED const int line_len); +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, char *line_buf, MAYBE_UNUSED const int line_size); -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, const char *line_buf, MAYBE_UNUSED const int line_len); -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, char *line_buf, MAYBE_UNUSED const int line_size); +void module_register (module_ctx_t *module_ctx); #endif // _MODULES_H diff --git a/include/types.h b/include/types.h index 756986573..65c6ad189 100644 --- a/include/types.h +++ b/include/types.h @@ -908,10 +908,10 @@ struct hashconfig // sizes have to be size_t - u64 esalt_size; - u64 hook_salt_size; - u64 tmp_size; - u64 hook_size; + u64 esalt_size; + u64 hook_salt_size; + u64 tmp_size; + u64 hook_size; // password length limit diff --git a/modules/m01000.c b/modules/m01000.c index 32fa58bd9..9bbe8618c 100644 --- a/modules/m01000.c +++ b/modules/m01000.c @@ -11,162 +11,179 @@ #include "inc_hash_constants.h" #include "modules.h" -static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; -static const u32 DGST_POS0 = 0; -static const u32 DGST_POS1 = 3; -static const u32 DGST_POS2 = 2; -static const u32 DGST_POS3 = 1; -static const u32 DGST_SIZE = DGST_SIZE_4_4; -static const char *HASH_NAME = "NTLM"; -static const u32 HASH_TYPE = HASH_TYPE_MD4; -static const u32 KERN_TYPE = 1000; +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +static const char *HASH_NAME = "NTLM"; +static const u32 HASH_TYPE = HASH_TYPE_MD4; +static const u64 KERN_TYPE = 1000; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_PRECOMPUTE_MERKLE + | OPTI_TYPE_MEET_IN_MIDDLE + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_NOT_SALTED + | OPTI_TYPE_RAW_HASH; +static const u32 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14 + | OPTS_TYPE_PT_UTF16LE; +static const char *ST_HASH = "b4b9b02e6f09a9bd760f388b67351e2b"; +static const char *ST_PASS = "hashcat"; + +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 default_attack_exec (hashconfig, user_options, user_options_extra); -void module_register (module_ctx_t *module_ctx) + return ATTACK_EXEC; +} + +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) { - module_ctx->module_attack_exec = module_attack_exec; - module_ctx->module_benchmark_mask = module_benchmark_mask; - module_ctx->module_benchmark_salt_len = module_benchmark_salt_len; - module_ctx->module_benchmark_salt_iter = module_benchmark_salt_iter; - 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_esalt_size = module_esalt_size; - module_ctx->module_hash_decode = module_hash_decode; - module_ctx->module_hash_encode = module_hash_encode; - module_ctx->module_hash_name = module_hash_name; - module_ctx->module_hash_type = module_hash_type; - module_ctx->module_hook_salt_size = module_hook_salt_size; - module_ctx->module_hook_size = module_hook_size; - module_ctx->module_kern_type = module_kern_type; - module_ctx->module_opti_type = module_opti_type; - module_ctx->module_opts_type = module_opts_type; - module_ctx->module_pw_max = module_pw_max; - module_ctx->module_pw_min = module_pw_min; - module_ctx->module_salt_max = module_salt_max; - module_ctx->module_salt_min = module_salt_min; - module_ctx->module_salt_type = module_salt_type; - module_ctx->module_st_hash = module_st_hash; - module_ctx->module_st_pass = module_st_pass; - module_ctx->module_tmp_size = module_tmp_size; + //return default_dgst_size (hashconfig, user_options, user_options_extra); + + return DGST_SIZE; } -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; } -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; } -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) { return HASH_TYPE; } -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; } +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 default_hash_name (hashconfig, user_options, user_options_extra); + return HASH_NAME; +} -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) +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) { - // return hashconfig_st_hash (hashconfig, user_options, user_options_extra); + //return default_hash_type (hashconfig, user_options, user_options_extra); - const char *st_hash = "b4b9b02e6f09a9bd760f388b67351e2b"; + return HASH_TYPE; +} + +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 default_kern_type (hashconfig, user_options, user_options_extra); - return st_hash; + return KERN_TYPE; } -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) +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 hashconfig_st_pass (hashconfig, user_options, user_options_extra); + //return default_st_hash (hashconfig, user_options, user_options_extra); - const char *st_pass = "hashcat"; + return ST_HASH; +} - return st_pass; +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 default_st_pass (hashconfig, user_options, user_options_extra); + + return ST_PASS; } 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 hashconfig_opti_type (hashconfig, user_options, user_options_extra); + //return default_opti_type (hashconfig, user_options, user_options_extra); - const u32 opti_type = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_PRECOMPUTE_INIT - | OPTI_TYPE_PRECOMPUTE_MERKLE - | OPTI_TYPE_MEET_IN_MIDDLE - | OPTI_TYPE_EARLY_SKIP - | OPTI_TYPE_NOT_ITERATED - | OPTI_TYPE_NOT_SALTED - | OPTI_TYPE_RAW_HASH; - - return opti_type; + 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 hashconfig_opts_type (hashconfig, user_options, user_options_extra); + //return default_opts_type (hashconfig, user_options, user_options_extra); - const u32 opts_type = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_PT_ADD80 - | OPTS_TYPE_PT_ADDBITS14 - | OPTS_TYPE_PT_UTF16LE; + return OPTS_TYPE; +} - return opts_type; +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 default_dgst_pos0 (hashconfig, user_options, 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 default_dgst_pos1 (hashconfig, user_options, 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 default_dgst_pos2 (hashconfig, user_options, 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 default_dgst_pos3 (hashconfig, user_options, user_options_extra); + + return DGST_POS3; } 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 hashconfig_salt_type (hashconfig, user_options, user_options_extra); + return default_salt_type (hashconfig, user_options, user_options_extra); } 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 hashconfig_esalt_size (hashconfig, user_options, user_options_extra); + return default_esalt_size (hashconfig, user_options, user_options_extra); } 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) { - return hashconfig_tmp_size (hashconfig, user_options, user_options_extra); + return default_tmp_size (hashconfig, user_options, 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) { - return hashconfig_hook_salt_size (hashconfig, user_options, user_options_extra); + return default_hook_salt_size (hashconfig, user_options, 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) { - return hashconfig_hook_size (hashconfig, user_options, user_options_extra); + return default_hook_size (hashconfig, user_options, user_options_extra); } const char *module_benchmark_mask (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 hashconfig_benchmark_mask (hashconfig, user_options, user_options_extra); + return default_benchmark_mask (hashconfig, user_options, user_options_extra); } u32 module_benchmark_salt_len (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 hashconfig_benchmark_salt_len (hashconfig, user_options, user_options_extra); + return default_benchmark_salt_len (hashconfig, user_options, user_options_extra); } u32 module_benchmark_salt_iter (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 hashconfig_benchmark_salt_iter (hashconfig, user_options, user_options_extra); + return default_benchmark_salt_iter (hashconfig, user_options, user_options_extra); } u32 module_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - return hashconfig_salt_min (hashconfig, user_options, user_options_extra); + return default_salt_min (hashconfig, user_options, user_options_extra); } u32 module_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - return hashconfig_salt_max (hashconfig, user_options, user_options_extra); + return default_salt_max (hashconfig, user_options, user_options_extra); } u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - return hashconfig_pw_min (hashconfig, user_options, user_options_extra); + return default_pw_min (hashconfig, user_options, user_options_extra); } u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - return hashconfig_pw_max (hashconfig, user_options, user_options_extra); + return default_pw_max (hashconfig, user_options, user_options_extra); } 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, const char *line_buf, MAYBE_UNUSED const int line_len) @@ -229,3 +246,34 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE return out_len; } + +void module_register (module_ctx_t *module_ctx) +{ + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_mask = module_benchmark_mask; + module_ctx->module_benchmark_salt_len = module_benchmark_salt_len; + module_ctx->module_benchmark_salt_iter = module_benchmark_salt_iter; + 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_esalt_size = module_esalt_size; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hash_type = module_hash_type; + module_ctx->module_hook_salt_size = module_hook_salt_size; + module_ctx->module_hook_size = module_hook_size; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = module_pw_min; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = module_tmp_size; +} diff --git a/src/interface.c b/src/interface.c index 4ee8e3943..95d413b2d 100644 --- a/src/interface.c +++ b/src/interface.c @@ -29416,528 +29416,184 @@ u32 hashconfig_get_kernel_loops (hashcat_ctx_t *hashcat_ctx) return kernel_loops_fixed; } -int hashconfig_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) { - const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - - // pw_min : algo specific hard min length - - u32 pw_min = PW_MIN; + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + user_options_t *user_options = hashcat_ctx->user_options; - if (optimized_kernel == true) + // truecrypt and veracrypt only + if (((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) + || ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode == 13799))) { - // unused case - } + hashes_t *hashes = hashcat_ctx->hashes; - switch (hashconfig->hash_mode) - { - case 2500: pw_min = 8; break; // WPA-EAPOL-PBKDF2: min RFC - case 2501: pw_min = 64; break; // WPA-EAPOL-PMK: fixed - case 9710: pw_min = 5; break; // RC4-40 fixed - case 9810: pw_min = 5; break; // RC4-40 fixed - case 10410: pw_min = 5; break; // RC4-40 fixed - case 14000: pw_min = 8; break; // DES fixed - case 14100: pw_min = 24; break; // 3DES fixed - case 14900: pw_min = 10; break; // Skip32 fixed - case 15400: pw_min = 32; break; // ChaCha20 fixed - case 16800: pw_min = 8; break; // WPA-PMKID-PBKDF2: min RFC - case 16801: pw_min = 64; break; // WPA-PMKID-PMK: fixed - } + tc_t *tc = (tc_t *) hashes->esalts_buf; - return pw_min; -} + char *optional_param1 = NULL; -int hashconfig_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + if (user_options->truecrypt_keyfiles) optional_param1 = user_options->truecrypt_keyfiles; + if (user_options->veracrypt_keyfiles) optional_param1 = user_options->veracrypt_keyfiles; - // pw_max : some algo suffer from support for long passwords, - // the user need to add -L to enable support for them + if (optional_param1) + { + char *tcvc_keyfiles = optional_param1; - u32 pw_max = PW_MAX; + char *keyfiles = hcstrdup (tcvc_keyfiles); - if (optimized_kernel == true) - { - pw_max = PW_MAX_OLD; + if (keyfiles == NULL) return -1; - if ((hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) || (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE)) - { - pw_max /= 2; - } + char *saveptr = NULL; - #define PW_DICTMAX 31 + char *keyfile = strtok_r (keyfiles, ",", &saveptr); - if ((user_options->rp_files_cnt > 0) || (user_options->rp_gen > 0)) - { - if (user_options->slow_candidates == true) + if (keyfile == NULL) { - pw_max = MIN (pw_max, PW_DICTMAX); + free (keyfiles); + + return -1; } - else + + do { - switch (user_options_extra->attack_kern) + const int rc_crc32 = cpu_crc32 (hashcat_ctx, keyfile, (u8 *) tc->keyfile_buf); + + if (rc_crc32 == -1) { - case ATTACK_KERN_STRAIGHT: pw_max = MIN (pw_max, PW_DICTMAX); - break; - case ATTACK_KERN_COMBI: pw_max = MIN (pw_max, PW_DICTMAX); - break; + free (keyfiles); + + return -1; } - } + + } while ((keyfile = strtok_r ((char *) NULL, ",", &saveptr)) != NULL); + + free (keyfiles); } - else + + // truecrypt and veracrypt boot only + if (hashconfig->opts_type & OPTS_TYPE_KEYBOARD_MAPPING) { - if (user_options->slow_candidates == true) + if (user_options->keyboard_layout_mapping) { - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) - { - pw_max = MIN (pw_max, PW_DICTMAX); - } - else - { - // If we have a NOOP rule then we can process words from wordlists > PW_DICTMAX for slow hashes - } + const bool rc = initialize_keyboard_layout_mapping (hashcat_ctx, user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); + + if (rc == false) return -1; } - else + } + } + + // veracrypt only + if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode == 13799)) + { + if (user_options->veracrypt_pim) + { + // we can access salt directly here because in VC it's always just one salt not many + + hashes_t *hashes = hashcat_ctx->hashes; + + salt_t *salts_buf = hashes->salts_buf; + + salt_t *salt = &salts_buf[0]; + + switch (hashconfig->hash_mode) { - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) - { - switch (user_options_extra->attack_kern) - { - case ATTACK_KERN_STRAIGHT: pw_max = MIN (pw_max, PW_DICTMAX); - break; - case ATTACK_KERN_COMBI: pw_max = MIN (pw_max, PW_DICTMAX); - break; - } - } - else - { - // If we have a NOOP rule then we can process words from wordlists > PW_DICTMAX for slow hashes - } + case 13711: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13712: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13713: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13721: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13722: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13723: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13731: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13732: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13733: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13741: salt->salt_iter = user_options->veracrypt_pim * 2048; + break; + case 13742: salt->salt_iter = user_options->veracrypt_pim * 2048; + break; + case 13743: salt->salt_iter = user_options->veracrypt_pim * 2048; + break; + case 13751: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13752: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13753: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13761: salt->salt_iter = user_options->veracrypt_pim * 2048; + break; + case 13762: salt->salt_iter = user_options->veracrypt_pim * 2048; + break; + case 13763: salt->salt_iter = user_options->veracrypt_pim * 2048; + break; + case 13771: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13772: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; + case 13773: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); + break; } + + salt->salt_iter -= 1; } + } + + return 0; +} + +void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt, void *hook_salt) +{ + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + + if (hashconfig->is_salted == true) + { + salt->salt_len = hashconfig->benchmark_salt_len; + salt->salt_iter = hashconfig->benchmark_salt_iter; + + // special salt handling switch (hashconfig->hash_mode) { - case 500: pw_max = MIN (pw_max, 15); // pure kernel available + case 22: salt->salt_len = 30; break; - case 1600: pw_max = MIN (pw_max, 15); // pure kernel available + case 1500: salt->salt_len = 2; + salt->salt_buf[0] = 388; // pure magic break; - case 1800: pw_max = MIN (pw_max, 16); // pure kernel available + case 1731: salt->salt_len = 4; break; - case 5800: pw_max = MIN (pw_max, 16); // pure kernel available + case 2410: salt->salt_len = 4; break; - case 6300: pw_max = MIN (pw_max, 15); // pure kernel available + case 2500: memcpy (salt->salt_buf, "hashcat.net", 11); break; - case 6900: pw_max = MIN (pw_max, 32); // todo + case 2501: memcpy (salt->salt_buf, "hashcat.net", 11); break; - case 7000: pw_max = MIN (pw_max, 19); // pure kernel available + case 3100: salt->salt_len = 1; break; - case 7400: pw_max = MIN (pw_max, 15); // pure kernel available + case 5800: salt->salt_len = 16; break; - case 10700: pw_max = MIN (pw_max, 16); // pure kernel available + case 6800: salt->salt_len = 32; break; - case 12500: pw_max = MIN (pw_max, 20); // todo + case 8400: salt->salt_len = 40; break; - case 14400: pw_max = MIN (pw_max, 24); // todo + case 8800: salt->salt_len = 16; break; - case 15500: pw_max = MIN (pw_max, 16); // todo + case 8900: salt->salt_len = 16; + salt->scrypt_N = 1024; + salt->scrypt_r = 1; + salt->scrypt_p = 1; break; - } - } - else - { - switch (hashconfig->hash_mode) - { - case 10700: pw_max = 127; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ + case 9100: salt->salt_len = 16; break; - case 16400: pw_max = 64; // HMAC-MD5 and `doveadm pw` are different for password more than 64 bytes - break; - } - } - - // pw_max : all modes listed in the following switch cases are - // the maximum possible password length of the related system - // plus the opencl kernels which eventually allows cracking of passwords of up length PW_MAX for free (no speed drop). - // some modes have a self-set and some have - // underlaying algorithms specific hard maximum password length - // these limits override all previous restrictions, always - - switch (hashconfig->hash_mode) - { - case 112: pw_max = 30; break; // https://www.toadworld.com/platforms/oracle/b/weblog/archive/2013/11/12/oracle-12c-passwords - case 1500: pw_max = 8; break; // Underlaying DES max - case 2100: pw_max = PW_MAX; break; - case 2500: pw_max = 63; break; // WPA-EAPOL-PBKDF2: limits itself to 63 by RFC - case 2501: pw_max = 64; break; // WPA-EAPOL-PMK: fixed length - case 3000: pw_max = 7; break; // LM max - case 3100: pw_max = 30; break; // http://www.red-database-security.de/whitepaper/oracle_passwords.html - case 3200: pw_max = 72; break; // Underlaying Blowfish max - case 5200: pw_max = PW_MAX; break; - case 6211: pw_max = 64; break; // TC limits itself to 64 - case 6212: pw_max = 64; break; // TC limits itself to 64 - case 6213: pw_max = 64; break; // TC limits itself to 64 - case 6221: pw_max = 64; break; // TC limits itself to 64 - case 6222: pw_max = 64; break; // TC limits itself to 64 - case 6223: pw_max = 64; break; // TC limits itself to 64 - case 6231: pw_max = 64; break; // TC limits itself to 64 - case 6232: pw_max = 64; break; // TC limits itself to 64 - case 6233: pw_max = 64; break; // TC limits itself to 64 - case 6241: pw_max = 64; break; // TC limits itself to 64 - case 6242: pw_max = 64; break; // TC limits itself to 64 - case 6243: pw_max = 64; break; // TC limits itself to 64 - case 6400: pw_max = PW_MAX; break; - case 6500: pw_max = PW_MAX; break; - case 6600: pw_max = PW_MAX; break; - case 6700: pw_max = PW_MAX; break; - case 6800: pw_max = PW_MAX; break; - case 7100: pw_max = PW_MAX; break; - case 7200: pw_max = PW_MAX; break; - case 7700: pw_max = 8; break; // https://www.daniel-berlin.de/security/sap-sec/password-hash-algorithms/ - case 7800: pw_max = 40; break; // https://www.daniel-berlin.de/security/sap-sec/password-hash-algorithms/ - case 7900: pw_max = PW_MAX; break; - case 8000: pw_max = 30; break; // http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc31654.1570/html/sag1/CIHIBDBA.htm - case 8200: pw_max = PW_MAX; break; - case 8500: pw_max = 8; break; // Underlaying DES max - case 8600: pw_max = 16; break; // Lotus Notes/Domino 5 limits itself to 16 - case 8700: pw_max = 64; break; // https://www.ibm.com/support/knowledgecenter/en/SSKTWP_8.5.3/com.ibm.notes85.client.doc/fram_limits_of_notes_r.html - case 8800: pw_max = PW_MAX; break; - case 8900: pw_max = PW_MAX; break; - case 9100: pw_max = 64; break; // https://www.ibm.com/support/knowledgecenter/en/SSKTWP_8.5.3/com.ibm.notes85.client.doc/fram_limits_of_notes_r.html - case 9200: pw_max = PW_MAX; break; - case 9300: pw_max = PW_MAX; break; - case 9400: pw_max = PW_MAX; break; - case 9500: pw_max = PW_MAX; break; - case 9600: pw_max = PW_MAX; break; - case 9700: pw_max = 15; break; // https://msdn.microsoft.com/en-us/library/dd772916(v=office.12).aspx - case 9710: pw_max = 5; break; // Underlaying RC4-40 max - case 9720: pw_max = 15; break; // https://msdn.microsoft.com/en-us/library/dd772916(v=office.12).aspx - case 9800: pw_max = 15; break; // https://msdn.microsoft.com/en-us/library/dd772916(v=office.12).aspx - case 9810: pw_max = 5; break; // Underlaying RC4-40 max - case 9820: pw_max = 15; break; // https://msdn.microsoft.com/en-us/library/dd772916(v=office.12).aspx - case 9900: pw_max = 100; break; // RAdmin2 sets w[25] = 0x80 - case 10000: pw_max = PW_MAX; break; - case 10300: pw_max = 40; break; // https://www.daniel-berlin.de/security/sap-sec/password-hash-algorithms/ - case 10400: pw_max = 32; break; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ - case 10410: pw_max = 5; break; // Underlaying RC4-40 max - case 10420: pw_max = 32; break; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ - case 10500: pw_max = 32; break; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ - case 10600: pw_max = 127; break; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ - case 10900: pw_max = PW_MAX; break; - case 11300: pw_max = PW_MAX; break; - case 11600: pw_max = PW_MAX; break; - case 11900: pw_max = PW_MAX; break; - case 12000: pw_max = PW_MAX; break; - case 12001: pw_max = PW_MAX; break; - case 12200: pw_max = PW_MAX; break; - case 12300: pw_max = PW_MAX; break; - case 12400: pw_max = PW_MAX; break; - case 12700: pw_max = PW_MAX; break; - case 12800: pw_max = PW_MAX; break; - case 12900: pw_max = PW_MAX; break; - case 13000: pw_max = PW_MAX; break; - case 13200: pw_max = PW_MAX; break; - case 13400: pw_max = PW_MAX; break; - case 13600: pw_max = PW_MAX; break; - case 13711: pw_max = 64; break; // VC limits itself to 64 - case 13712: pw_max = 64; break; // VC limits itself to 64 - case 13713: pw_max = 64; break; // VC limits itself to 64 - case 13721: pw_max = 64; break; // VC limits itself to 64 - case 13722: pw_max = 64; break; // VC limits itself to 64 - case 13723: pw_max = 64; break; // VC limits itself to 64 - case 13731: pw_max = 64; break; // VC limits itself to 64 - case 13732: pw_max = 64; break; // VC limits itself to 64 - case 13733: pw_max = 64; break; // VC limits itself to 64 - case 13741: pw_max = 64; break; // VC limits itself to 64 - case 13742: pw_max = 64; break; // VC limits itself to 64 - case 13743: pw_max = 64; break; // VC limits itself to 64 - case 13751: pw_max = 64; break; // VC limits itself to 64 - case 13752: pw_max = 64; break; // VC limits itself to 64 - case 13753: pw_max = 64; break; // VC limits itself to 64 - case 13761: pw_max = 64; break; // VC limits itself to 64 - case 13762: pw_max = 64; break; // VC limits itself to 64 - case 13763: pw_max = 64; break; // VC limits itself to 64 - case 13771: pw_max = 64; break; // VC limits itself to 64 - case 13772: pw_max = 64; break; // VC limits itself to 64 - case 13773: pw_max = 64; break; // VC limits itself to 64 - case 14000: pw_max = 8; break; // Underlaying DES fixed - case 14100: pw_max = 24; break; // Underlaying 3DES fixed - case 14611: pw_max = PW_MAX; break; - case 14612: pw_max = PW_MAX; break; - case 14613: pw_max = PW_MAX; break; - case 14621: pw_max = PW_MAX; break; - case 14622: pw_max = PW_MAX; break; - case 14623: pw_max = PW_MAX; break; - case 14631: pw_max = PW_MAX; break; - case 14632: pw_max = PW_MAX; break; - case 14633: pw_max = PW_MAX; break; - case 14641: pw_max = PW_MAX; break; - case 14642: pw_max = PW_MAX; break; - case 14643: pw_max = PW_MAX; break; - case 14700: pw_max = PW_MAX; break; - case 14800: pw_max = PW_MAX; break; - case 14900: pw_max = 10; break; // Underlaying Skip32 fixed - case 15100: pw_max = PW_MAX; break; - case 15300: pw_max = PW_MAX; break; - case 15400: pw_max = 32; break; // Underlaying ChaCha20 fixed - case 15600: pw_max = PW_MAX; break; - case 15700: pw_max = PW_MAX; break; - case 15900: pw_max = PW_MAX; break; - case 16000: pw_max = 8; break; // Underlaying DES max - case 16800: pw_max = 63; break; // WPA-PMKID-PBKDF2: limits itself to 63 by RFC - case 16801: pw_max = 64; break; // WPA-PMKID-PMK: fixed length - case 16900: pw_max = PW_MAX; break; - case 18400: pw_max = PW_MAX; break; - case 18600: pw_max = 51; break; // Bogus SHA-1 in StarOffice code - } - - return pw_max; -} - -int hashconfig_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - - // salt_min : this limit is only interessting for generic hash types that support a salt - - u32 salt_min = SALT_MIN; - - if (optimized_kernel == true) - { - // unused case - } - - if (hashconfig->salt_type == SALT_TYPE_GENERIC) - { - if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) - { - salt_min *= 2; - } - - switch (hashconfig->hash_mode) - { - case 11000: salt_min = 56; break; - case 12600: salt_min = 64; break; - case 15000: salt_min = 64; break; - } - } - - return salt_min; -} - -int hashconfig_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - - // salt_max : this limit is only interessting for generic hash types that support a salt - - u32 salt_max = SALT_MAX; - - if (optimized_kernel == true) - { - salt_max = SALT_MAX_OLD; - - if ((hashconfig->opts_type & OPTS_TYPE_ST_UTF16LE) || (hashconfig->opts_type & OPTS_TYPE_ST_UTF16BE)) - { - salt_max /= 2; - } - } - - if (hashconfig->salt_type == SALT_TYPE_GENERIC) - { - if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) - { - salt_max *= 2; - } - - switch (hashconfig->hash_mode) - { - case 11000: salt_max = 56; break; - case 12600: salt_max = 64; break; - case 15000: salt_max = 64; break; - } - } - - return salt_max; -} - -int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx) -{ - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - user_options_t *user_options = hashcat_ctx->user_options; - - // truecrypt and veracrypt only - if (((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) - || ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode == 13799))) - { - hashes_t *hashes = hashcat_ctx->hashes; - - tc_t *tc = (tc_t *) hashes->esalts_buf; - - char *optional_param1 = NULL; - - if (user_options->truecrypt_keyfiles) optional_param1 = user_options->truecrypt_keyfiles; - if (user_options->veracrypt_keyfiles) optional_param1 = user_options->veracrypt_keyfiles; - - if (optional_param1) - { - char *tcvc_keyfiles = optional_param1; - - char *keyfiles = hcstrdup (tcvc_keyfiles); - - if (keyfiles == NULL) return -1; - - char *saveptr = NULL; - - char *keyfile = strtok_r (keyfiles, ",", &saveptr); - - if (keyfile == NULL) - { - free (keyfiles); - - return -1; - } - - do - { - const int rc_crc32 = cpu_crc32 (hashcat_ctx, keyfile, (u8 *) tc->keyfile_buf); - - if (rc_crc32 == -1) - { - free (keyfiles); - - return -1; - } - - } while ((keyfile = strtok_r ((char *) NULL, ",", &saveptr)) != NULL); - - free (keyfiles); - } - - // truecrypt and veracrypt boot only - if (hashconfig->opts_type & OPTS_TYPE_KEYBOARD_MAPPING) - { - if (user_options->keyboard_layout_mapping) - { - const bool rc = initialize_keyboard_layout_mapping (hashcat_ctx, user_options->keyboard_layout_mapping, tc->keyboard_layout_mapping_buf, &tc->keyboard_layout_mapping_cnt); - - if (rc == false) return -1; - } - } - } - - // veracrypt only - if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode == 13799)) - { - if (user_options->veracrypt_pim) - { - // we can access salt directly here because in VC it's always just one salt not many - - hashes_t *hashes = hashcat_ctx->hashes; - - salt_t *salts_buf = hashes->salts_buf; - - salt_t *salt = &salts_buf[0]; - - switch (hashconfig->hash_mode) - { - case 13711: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13712: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13713: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13721: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13722: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13723: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13731: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13732: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13733: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13741: salt->salt_iter = user_options->veracrypt_pim * 2048; - break; - case 13742: salt->salt_iter = user_options->veracrypt_pim * 2048; - break; - case 13743: salt->salt_iter = user_options->veracrypt_pim * 2048; - break; - case 13751: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13752: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13753: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13761: salt->salt_iter = user_options->veracrypt_pim * 2048; - break; - case 13762: salt->salt_iter = user_options->veracrypt_pim * 2048; - break; - case 13763: salt->salt_iter = user_options->veracrypt_pim * 2048; - break; - case 13771: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13772: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - case 13773: salt->salt_iter = 15000 + (user_options->veracrypt_pim * 1000); - break; - } - - salt->salt_iter -= 1; - } - } - - return 0; -} - -void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt, void *hook_salt) -{ - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - if (hashconfig->is_salted == true) - { - salt->salt_len = hashconfig->benchmark_salt_len; - salt->salt_iter = hashconfig->benchmark_salt_iter; - - // special salt handling - - switch (hashconfig->hash_mode) - { - case 22: salt->salt_len = 30; - break; - case 1500: salt->salt_len = 2; - salt->salt_buf[0] = 388; // pure magic - break; - case 1731: salt->salt_len = 4; - break; - case 2410: salt->salt_len = 4; - break; - case 2500: memcpy (salt->salt_buf, "hashcat.net", 11); - break; - case 2501: memcpy (salt->salt_buf, "hashcat.net", 11); - break; - case 3100: salt->salt_len = 1; - break; - case 5800: salt->salt_len = 16; - break; - case 6800: salt->salt_len = 32; - break; - case 8400: salt->salt_len = 40; - break; - case 8800: salt->salt_len = 16; - break; - case 8900: salt->salt_len = 16; - salt->scrypt_N = 1024; - salt->scrypt_r = 1; - salt->scrypt_p = 1; - break; - case 9100: salt->salt_len = 16; - break; - case 9300: salt->salt_len = 14; - salt->scrypt_N = 16384; - salt->scrypt_r = 1; - salt->scrypt_p = 1; + case 9300: salt->salt_len = 14; + salt->scrypt_N = 16384; + salt->scrypt_r = 1; + salt->scrypt_p = 1; break; case 9400: salt->salt_len = 16; break; @@ -30313,498 +29969,905 @@ void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, vo case 18600: salt->salt_iter = ROUNDS_OPENOFFICE - 1; break; } - */ + */ +} + +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_buf = (u32 *) data; + u64 *digest_buf64 = (u64 *) data; + + if (opti_type & OPTI_TYPE_PRECOMPUTE_PERMUT) + { + u32 tt; + + switch (hash_type) + { + case HASH_TYPE_DES: + FP (digest_buf[1], digest_buf[0], tt); + break; + + case HASH_TYPE_DESCRYPT: + FP (digest_buf[1], digest_buf[0], tt); + break; + + case HASH_TYPE_DESRACF: + digest_buf[0] = rotl32 (digest_buf[0], 29); + digest_buf[1] = rotl32 (digest_buf[1], 29); + + FP (digest_buf[1], digest_buf[0], tt); + break; + + case HASH_TYPE_LM: + FP (digest_buf[1], digest_buf[0], tt); + break; + + case HASH_TYPE_NETNTLM: + digest_buf[0] = rotl32 (digest_buf[0], 29); + digest_buf[1] = rotl32 (digest_buf[1], 29); + digest_buf[2] = rotl32 (digest_buf[2], 29); + digest_buf[3] = rotl32 (digest_buf[3], 29); + + FP (digest_buf[1], digest_buf[0], tt); + FP (digest_buf[3], digest_buf[2], tt); + break; + + case HASH_TYPE_BSDICRYPT: + digest_buf[0] = rotl32 (digest_buf[0], 31); + digest_buf[1] = rotl32 (digest_buf[1], 31); + + FP (digest_buf[1], digest_buf[0], tt); + break; + } + } + + if (opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + switch (hash_type) + { + case HASH_TYPE_MD4: + digest_buf[0] -= MD4M_A; + digest_buf[1] -= MD4M_B; + digest_buf[2] -= MD4M_C; + digest_buf[3] -= MD4M_D; + break; + + case HASH_TYPE_MD5: + digest_buf[0] -= MD5M_A; + digest_buf[1] -= MD5M_B; + digest_buf[2] -= MD5M_C; + digest_buf[3] -= MD5M_D; + break; + + case HASH_TYPE_SHA1: + digest_buf[0] -= SHA1M_A; + digest_buf[1] -= SHA1M_B; + digest_buf[2] -= SHA1M_C; + digest_buf[3] -= SHA1M_D; + digest_buf[4] -= SHA1M_E; + break; + + case HASH_TYPE_SHA224: + digest_buf[0] -= SHA224M_A; + digest_buf[1] -= SHA224M_B; + digest_buf[2] -= SHA224M_C; + digest_buf[3] -= SHA224M_D; + digest_buf[4] -= SHA224M_E; + digest_buf[5] -= SHA224M_F; + digest_buf[6] -= SHA224M_G; + break; + + case HASH_TYPE_SHA256: + digest_buf[0] -= SHA256M_A; + digest_buf[1] -= SHA256M_B; + digest_buf[2] -= SHA256M_C; + digest_buf[3] -= SHA256M_D; + digest_buf[4] -= SHA256M_E; + digest_buf[5] -= SHA256M_F; + digest_buf[6] -= SHA256M_G; + digest_buf[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; + } + } } -u32 hashconfig_benchmark_salt_len (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +void encoder_apply_optimizer (const hashconfig_t *hashconfig, void *data) { - u32 salt_len = 0; + const u32 hash_type = hashconfig->hash_type; + const u32 opti_type = hashconfig->opti_type; - if (hashconfig->is_salted == true) + u32 *digest_buf = (u32 *) data; + u64 *digest_buf64 = (u64 *) data; + + if (opti_type & OPTI_TYPE_PRECOMPUTE_PERMUT) { - salt_len = 8; + u32 tt; + + switch (hash_type) + { + case HASH_TYPE_DES: + FP (digest_buf[1], digest_buf[0], tt); + break; + + case HASH_TYPE_DESCRYPT: + FP (digest_buf[1], digest_buf[0], tt); + break; + + case HASH_TYPE_DESRACF: + digest_buf[0] = rotl32 (digest_buf[0], 29); + digest_buf[1] = rotl32 (digest_buf[1], 29); + + FP (digest_buf[1], digest_buf[0], tt); + break; + + case HASH_TYPE_LM: + FP (digest_buf[1], digest_buf[0], tt); + break; + + case HASH_TYPE_NETNTLM: + digest_buf[0] = rotl32 (digest_buf[0], 29); + digest_buf[1] = rotl32 (digest_buf[1], 29); + digest_buf[2] = rotl32 (digest_buf[2], 29); + digest_buf[3] = rotl32 (digest_buf[3], 29); + + FP (digest_buf[1], digest_buf[0], tt); + FP (digest_buf[3], digest_buf[2], tt); + break; + + case HASH_TYPE_BSDICRYPT: + digest_buf[0] = rotl32 (digest_buf[0], 31); + digest_buf[1] = rotl32 (digest_buf[1], 31); + + FP (digest_buf[1], digest_buf[0], tt); + break; + } } - return salt_len; -} + if (opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + switch (hash_type) + { + case HASH_TYPE_MD4: + digest_buf[0] += MD4M_A; + digest_buf[1] += MD4M_B; + digest_buf[2] += MD4M_C; + digest_buf[3] += MD4M_D; + break; -u32 hashconfig_benchmark_salt_iter (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) -{ - const u32 salt_len = 1; + case HASH_TYPE_MD5: + digest_buf[0] += MD5M_A; + digest_buf[1] += MD5M_B; + digest_buf[2] += MD5M_C; + digest_buf[3] += MD5M_D; + break; - return salt_len; + case HASH_TYPE_SHA1: + digest_buf[0] += SHA1M_A; + digest_buf[1] += SHA1M_B; + digest_buf[2] += SHA1M_C; + digest_buf[3] += SHA1M_D; + digest_buf[4] += SHA1M_E; + break; + + case HASH_TYPE_SHA224: + digest_buf[0] += SHA224M_A; + digest_buf[1] += SHA224M_B; + digest_buf[2] += SHA224M_C; + digest_buf[3] += SHA224M_D; + digest_buf[4] += SHA224M_E; + digest_buf[5] += SHA224M_F; + digest_buf[6] += SHA224M_G; + break; + + case HASH_TYPE_SHA256: + digest_buf[0] += SHA256M_A; + digest_buf[1] += SHA256M_B; + digest_buf[2] += SHA256M_C; + digest_buf[3] += SHA256M_D; + digest_buf[4] += SHA256M_E; + digest_buf[5] += SHA256M_F; + digest_buf[6] += SHA256M_G; + digest_buf[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; + } + } } -u32 hashconfig_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) +void decoder_apply_options (const hashconfig_t *hashconfig, void *data) { - const u32 opti_type = 0; + const u32 hash_type = hashconfig->hash_type; + const u64 opts_type = hashconfig->opts_type; + const u32 dgst_size = hashconfig->dgst_size; - return opti_type; + u32 *digest_buf = (u32 *) data; + u64 *digest_buf64 = (u64 *) data; + + if (opts_type & OPTS_TYPE_STATE_BUFFER_BE) + { + if (dgst_size == DGST_SIZE_4_2) + { + for (int i = 0; i < 2; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_4) + { + for (int i = 0; i < 4; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_5) + { + for (int i = 0; i < 5; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_6) + { + for (int i = 0; i < 6; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_7) + { + for (int i = 0; i < 7; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_8) + { + for (int i = 0; i < 8; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if ((dgst_size == DGST_SIZE_4_16) || (dgst_size == DGST_SIZE_8_8)) // same size, same result :) + { + if (hash_type == HASH_TYPE_WHIRLPOOL) + { + for (int i = 0; i < 16; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (hash_type == HASH_TYPE_SHA384) + { + for (int i = 0; i < 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); + } + else if (hash_type == HASH_TYPE_SHA512) + { + for (int i = 0; i < 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); + } + else if (hash_type == HASH_TYPE_GOST) + { + for (int i = 0; i < 16; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + } + else if (dgst_size == DGST_SIZE_4_64) + { + for (int i = 0; i < 64; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_8_25) + { + for (int i = 0; i < 25; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); + } + } } -u64 hashconfig_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) +void encoder_apply_options (const hashconfig_t *hashconfig, void *data) { - const u64 opts_type = 0; + const u32 hash_type = hashconfig->hash_type; + const u64 opts_type = hashconfig->opts_type; + const u32 dgst_size = hashconfig->dgst_size; - return opts_type; + u32 *digest_buf = (u32 *) data; + u64 *digest_buf64 = (u64 *) data; + + if (opts_type & OPTS_TYPE_STATE_BUFFER_BE) + { + if (dgst_size == DGST_SIZE_4_2) + { + for (int i = 0; i < 2; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_4) + { + for (int i = 0; i < 4; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_5) + { + for (int i = 0; i < 5; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_6) + { + for (int i = 0; i < 6; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_7) + { + for (int i = 0; i < 7; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_4_8) + { + for (int i = 0; i < 8; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if ((dgst_size == DGST_SIZE_4_16) || (dgst_size == DGST_SIZE_8_8)) // same size, same result :) + { + if (hash_type == HASH_TYPE_WHIRLPOOL) + { + for (int i = 0; i < 16; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (hash_type == HASH_TYPE_SHA384) + { + for (int i = 0; i < 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); + } + else if (hash_type == HASH_TYPE_SHA512) + { + for (int i = 0; i < 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); + } + else if (hash_type == HASH_TYPE_GOST) + { + for (int i = 0; i < 16; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + } + else if (dgst_size == DGST_SIZE_4_64) + { + for (int i = 0; i < 64; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + } + else if (dgst_size == DGST_SIZE_8_25) + { + for (int i = 0; i < 25; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); + } + } } -const char *hashconfig_benchmark_mask (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 default_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) { - const char *mask = "?b?b?b?b?b?b?b"; - - /* - switch (hashconfig->hash_mode) - { - case 2500: mask = "?a?a?a?a?a?a?a?a"; - break; - case 2501: mask = "?a?a?a?a?a?a?a?axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; - break; - case 9710: mask = "?b?b?b?b?b"; - break; - case 9810: mask = "?b?b?b?b?b"; - break; - case 10410: mask = "?b?b?b?b?b"; - break; - case 12500: mask = "?b?b?b?b?b"; - break; - case 14000: mask = "?b?b?b?b?b?b?bx"; - break; - case 14100: mask = "?b?b?b?b?b?b?bxxxxxxxxxxxxxxxxx"; - break; - case 14900: mask = "?b?b?b?b?bxxxxx"; - break; - case 16800: mask = "?a?a?a?a?a?a?a?a"; - break; - case 16801: mask = "?a?a?a?a?a?a?a?axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; - break; - default: mask = "?b?b?b?b?b?b?b"; - break; - } - */ + const u32 attack_exec = ATTACK_EXEC_INSIDE_KERNEL; - return mask; + return attack_exec; } -u32 hashconfig_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) +u32 default_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) { - const u32 tmp_size = 4; + const u32 dgst_pos0 = 0; - return tmp_size; + return dgst_pos0; } -u64 hashconfig_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) +u32 default_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) { - const u64 esalt_size = 0; + const u32 dgst_pos1 = 1; - return esalt_size; + return dgst_pos1; } -u32 hashconfig_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) +u32 default_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) { - const u32 salt_type = SALT_TYPE_NONE; + const u32 dgst_pos2 = 2; - return salt_type; + return dgst_pos2; } -u64 hashconfig_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) +u32 default_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) { - const u64 hook_salt_size = 0; + const u32 dgst_pos3 = 3; - return hook_salt_size; + return dgst_pos3; } -u64 hashconfig_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) +u32 default_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) { - const u64 hook_size = 4; + const u32 dgst_size = DGST_SIZE_4_4; - return hook_size; + return dgst_size; } -const char *hashconfig_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) +u32 default_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) { - return ""; + const u32 hash_type = 0; + + return hash_type; } -const char *hashconfig_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) +const char *default_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 ""; + const char *hash_name = ""; + + return hash_name; } -void decoder_apply_optimizer (const hashconfig_t *hashconfig, void *data) +u32 default_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u32 hash_type = hashconfig->hash_type; - const u32 opti_type = hashconfig->opti_type; + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - u32 *digest_buf = (u32 *) data; - u64 *digest_buf64 = (u64 *) data; + // pw_min : algo specific hard min length - if (opti_type & OPTI_TYPE_PRECOMPUTE_PERMUT) + u32 pw_min = PW_MIN; + + if (optimized_kernel == true) { - u32 tt; + // unused case + } - switch (hash_type) - { - case HASH_TYPE_DES: - FP (digest_buf[1], digest_buf[0], tt); - break; + switch (hashconfig->hash_mode) + { + case 2500: pw_min = 8; break; // WPA-EAPOL-PBKDF2: min RFC + case 2501: pw_min = 64; break; // WPA-EAPOL-PMK: fixed + case 9710: pw_min = 5; break; // RC4-40 fixed + case 9810: pw_min = 5; break; // RC4-40 fixed + case 10410: pw_min = 5; break; // RC4-40 fixed + case 14000: pw_min = 8; break; // DES fixed + case 14100: pw_min = 24; break; // 3DES fixed + case 14900: pw_min = 10; break; // Skip32 fixed + case 15400: pw_min = 32; break; // ChaCha20 fixed + case 16800: pw_min = 8; break; // WPA-PMKID-PBKDF2: min RFC + case 16801: pw_min = 64; break; // WPA-PMKID-PMK: fixed + } - case HASH_TYPE_DESCRYPT: - FP (digest_buf[1], digest_buf[0], tt); - break; + return pw_min; +} - case HASH_TYPE_DESRACF: - digest_buf[0] = rotl32 (digest_buf[0], 29); - digest_buf[1] = rotl32 (digest_buf[1], 29); +u32 default_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - FP (digest_buf[1], digest_buf[0], tt); - break; + // pw_max : some algo suffer from support for long passwords, + // the user need to add -L to enable support for them - case HASH_TYPE_LM: - FP (digest_buf[1], digest_buf[0], tt); - break; + u32 pw_max = PW_MAX; - case HASH_TYPE_NETNTLM: - digest_buf[0] = rotl32 (digest_buf[0], 29); - digest_buf[1] = rotl32 (digest_buf[1], 29); - digest_buf[2] = rotl32 (digest_buf[2], 29); - digest_buf[3] = rotl32 (digest_buf[3], 29); + if (optimized_kernel == true) + { + pw_max = PW_MAX_OLD; - FP (digest_buf[1], digest_buf[0], tt); - FP (digest_buf[3], digest_buf[2], tt); - break; + if ((hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) || (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE)) + { + pw_max /= 2; + } - case HASH_TYPE_BSDICRYPT: - digest_buf[0] = rotl32 (digest_buf[0], 31); - digest_buf[1] = rotl32 (digest_buf[1], 31); + #define PW_DICTMAX 31 - FP (digest_buf[1], digest_buf[0], tt); - break; + if ((user_options->rp_files_cnt > 0) || (user_options->rp_gen > 0)) + { + if (user_options->slow_candidates == true) + { + pw_max = MIN (pw_max, PW_DICTMAX); + } + else + { + switch (user_options_extra->attack_kern) + { + case ATTACK_KERN_STRAIGHT: pw_max = MIN (pw_max, PW_DICTMAX); + break; + case ATTACK_KERN_COMBI: pw_max = MIN (pw_max, PW_DICTMAX); + break; + } + } } - } - - if (opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) - { - switch (hash_type) + else { - case HASH_TYPE_MD4: - digest_buf[0] -= MD4M_A; - digest_buf[1] -= MD4M_B; - digest_buf[2] -= MD4M_C; - digest_buf[3] -= MD4M_D; - break; - - case HASH_TYPE_MD5: - digest_buf[0] -= MD5M_A; - digest_buf[1] -= MD5M_B; - digest_buf[2] -= MD5M_C; - digest_buf[3] -= MD5M_D; - break; - - case HASH_TYPE_SHA1: - digest_buf[0] -= SHA1M_A; - digest_buf[1] -= SHA1M_B; - digest_buf[2] -= SHA1M_C; - digest_buf[3] -= SHA1M_D; - digest_buf[4] -= SHA1M_E; - break; - - case HASH_TYPE_SHA224: - digest_buf[0] -= SHA224M_A; - digest_buf[1] -= SHA224M_B; - digest_buf[2] -= SHA224M_C; - digest_buf[3] -= SHA224M_D; - digest_buf[4] -= SHA224M_E; - digest_buf[5] -= SHA224M_F; - digest_buf[6] -= SHA224M_G; - break; - - case HASH_TYPE_SHA256: - digest_buf[0] -= SHA256M_A; - digest_buf[1] -= SHA256M_B; - digest_buf[2] -= SHA256M_C; - digest_buf[3] -= SHA256M_D; - digest_buf[4] -= SHA256M_E; - digest_buf[5] -= SHA256M_F; - digest_buf[6] -= SHA256M_G; - digest_buf[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; + if (user_options->slow_candidates == true) + { + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + { + pw_max = MIN (pw_max, PW_DICTMAX); + } + else + { + // If we have a NOOP rule then we can process words from wordlists > PW_DICTMAX for slow hashes + } + } + else + { + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + { + switch (user_options_extra->attack_kern) + { + case ATTACK_KERN_STRAIGHT: pw_max = MIN (pw_max, PW_DICTMAX); + break; + case ATTACK_KERN_COMBI: pw_max = MIN (pw_max, PW_DICTMAX); + break; + } + } + else + { + // If we have a NOOP rule then we can process words from wordlists > PW_DICTMAX for slow hashes + } + } + } - 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; + switch (hashconfig->hash_mode) + { + case 500: pw_max = MIN (pw_max, 15); // pure kernel available + break; + case 1600: pw_max = MIN (pw_max, 15); // pure kernel available + break; + case 1800: pw_max = MIN (pw_max, 16); // pure kernel available + break; + case 5800: pw_max = MIN (pw_max, 16); // pure kernel available + break; + case 6300: pw_max = MIN (pw_max, 15); // pure kernel available + break; + case 6900: pw_max = MIN (pw_max, 32); // todo + break; + case 7000: pw_max = MIN (pw_max, 19); // pure kernel available + break; + case 7400: pw_max = MIN (pw_max, 15); // pure kernel available + break; + case 10700: pw_max = MIN (pw_max, 16); // pure kernel available + break; + case 12500: pw_max = MIN (pw_max, 20); // todo + break; + case 14400: pw_max = MIN (pw_max, 24); // todo + break; + case 15500: pw_max = MIN (pw_max, 16); // todo + 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_buf = (u32 *) data; - u64 *digest_buf64 = (u64 *) data; - - if (opti_type & OPTI_TYPE_PRECOMPUTE_PERMUT) + else { - u32 tt; - - switch (hash_type) + switch (hashconfig->hash_mode) { - case HASH_TYPE_DES: - FP (digest_buf[1], digest_buf[0], tt); - break; - - case HASH_TYPE_DESCRYPT: - FP (digest_buf[1], digest_buf[0], tt); - break; - - case HASH_TYPE_DESRACF: - digest_buf[0] = rotl32 (digest_buf[0], 29); - digest_buf[1] = rotl32 (digest_buf[1], 29); - - FP (digest_buf[1], digest_buf[0], tt); - break; - - case HASH_TYPE_LM: - FP (digest_buf[1], digest_buf[0], tt); - break; - - case HASH_TYPE_NETNTLM: - digest_buf[0] = rotl32 (digest_buf[0], 29); - digest_buf[1] = rotl32 (digest_buf[1], 29); - digest_buf[2] = rotl32 (digest_buf[2], 29); - digest_buf[3] = rotl32 (digest_buf[3], 29); - - FP (digest_buf[1], digest_buf[0], tt); - FP (digest_buf[3], digest_buf[2], tt); - break; - - case HASH_TYPE_BSDICRYPT: - digest_buf[0] = rotl32 (digest_buf[0], 31); - digest_buf[1] = rotl32 (digest_buf[1], 31); - - FP (digest_buf[1], digest_buf[0], tt); - break; + case 10700: pw_max = 127; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ + break; + case 16400: pw_max = 64; // HMAC-MD5 and `doveadm pw` are different for password more than 64 bytes + break; } } - if (opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) - { - switch (hash_type) - { - case HASH_TYPE_MD4: - digest_buf[0] += MD4M_A; - digest_buf[1] += MD4M_B; - digest_buf[2] += MD4M_C; - digest_buf[3] += MD4M_D; - break; - - case HASH_TYPE_MD5: - digest_buf[0] += MD5M_A; - digest_buf[1] += MD5M_B; - digest_buf[2] += MD5M_C; - digest_buf[3] += MD5M_D; - break; - - case HASH_TYPE_SHA1: - digest_buf[0] += SHA1M_A; - digest_buf[1] += SHA1M_B; - digest_buf[2] += SHA1M_C; - digest_buf[3] += SHA1M_D; - digest_buf[4] += SHA1M_E; - break; - - case HASH_TYPE_SHA224: - digest_buf[0] += SHA224M_A; - digest_buf[1] += SHA224M_B; - digest_buf[2] += SHA224M_C; - digest_buf[3] += SHA224M_D; - digest_buf[4] += SHA224M_E; - digest_buf[5] += SHA224M_F; - digest_buf[6] += SHA224M_G; - break; - - case HASH_TYPE_SHA256: - digest_buf[0] += SHA256M_A; - digest_buf[1] += SHA256M_B; - digest_buf[2] += SHA256M_C; - digest_buf[3] += SHA256M_D; - digest_buf[4] += SHA256M_E; - digest_buf[5] += SHA256M_F; - digest_buf[6] += SHA256M_G; - digest_buf[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; + // pw_max : all modes listed in the following switch cases are + // the maximum possible password length of the related system + // plus the opencl kernels which eventually allows cracking of passwords of up length PW_MAX for free (no speed drop). + // some modes have a self-set and some have + // underlaying algorithms specific hard maximum password length + // these limits override all previous restrictions, always - 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; - } + switch (hashconfig->hash_mode) + { + case 112: pw_max = 30; break; // https://www.toadworld.com/platforms/oracle/b/weblog/archive/2013/11/12/oracle-12c-passwords + case 1500: pw_max = 8; break; // Underlaying DES max + case 2100: pw_max = PW_MAX; break; + case 2500: pw_max = 63; break; // WPA-EAPOL-PBKDF2: limits itself to 63 by RFC + case 2501: pw_max = 64; break; // WPA-EAPOL-PMK: fixed length + case 3000: pw_max = 7; break; // LM max + case 3100: pw_max = 30; break; // http://www.red-database-security.de/whitepaper/oracle_passwords.html + case 3200: pw_max = 72; break; // Underlaying Blowfish max + case 5200: pw_max = PW_MAX; break; + case 6211: pw_max = 64; break; // TC limits itself to 64 + case 6212: pw_max = 64; break; // TC limits itself to 64 + case 6213: pw_max = 64; break; // TC limits itself to 64 + case 6221: pw_max = 64; break; // TC limits itself to 64 + case 6222: pw_max = 64; break; // TC limits itself to 64 + case 6223: pw_max = 64; break; // TC limits itself to 64 + case 6231: pw_max = 64; break; // TC limits itself to 64 + case 6232: pw_max = 64; break; // TC limits itself to 64 + case 6233: pw_max = 64; break; // TC limits itself to 64 + case 6241: pw_max = 64; break; // TC limits itself to 64 + case 6242: pw_max = 64; break; // TC limits itself to 64 + case 6243: pw_max = 64; break; // TC limits itself to 64 + case 6400: pw_max = PW_MAX; break; + case 6500: pw_max = PW_MAX; break; + case 6600: pw_max = PW_MAX; break; + case 6700: pw_max = PW_MAX; break; + case 6800: pw_max = PW_MAX; break; + case 7100: pw_max = PW_MAX; break; + case 7200: pw_max = PW_MAX; break; + case 7700: pw_max = 8; break; // https://www.daniel-berlin.de/security/sap-sec/password-hash-algorithms/ + case 7800: pw_max = 40; break; // https://www.daniel-berlin.de/security/sap-sec/password-hash-algorithms/ + case 7900: pw_max = PW_MAX; break; + case 8000: pw_max = 30; break; // http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc31654.1570/html/sag1/CIHIBDBA.htm + case 8200: pw_max = PW_MAX; break; + case 8500: pw_max = 8; break; // Underlaying DES max + case 8600: pw_max = 16; break; // Lotus Notes/Domino 5 limits itself to 16 + case 8700: pw_max = 64; break; // https://www.ibm.com/support/knowledgecenter/en/SSKTWP_8.5.3/com.ibm.notes85.client.doc/fram_limits_of_notes_r.html + case 8800: pw_max = PW_MAX; break; + case 8900: pw_max = PW_MAX; break; + case 9100: pw_max = 64; break; // https://www.ibm.com/support/knowledgecenter/en/SSKTWP_8.5.3/com.ibm.notes85.client.doc/fram_limits_of_notes_r.html + case 9200: pw_max = PW_MAX; break; + case 9300: pw_max = PW_MAX; break; + case 9400: pw_max = PW_MAX; break; + case 9500: pw_max = PW_MAX; break; + case 9600: pw_max = PW_MAX; break; + case 9700: pw_max = 15; break; // https://msdn.microsoft.com/en-us/library/dd772916(v=office.12).aspx + case 9710: pw_max = 5; break; // Underlaying RC4-40 max + case 9720: pw_max = 15; break; // https://msdn.microsoft.com/en-us/library/dd772916(v=office.12).aspx + case 9800: pw_max = 15; break; // https://msdn.microsoft.com/en-us/library/dd772916(v=office.12).aspx + case 9810: pw_max = 5; break; // Underlaying RC4-40 max + case 9820: pw_max = 15; break; // https://msdn.microsoft.com/en-us/library/dd772916(v=office.12).aspx + case 9900: pw_max = 100; break; // RAdmin2 sets w[25] = 0x80 + case 10000: pw_max = PW_MAX; break; + case 10300: pw_max = 40; break; // https://www.daniel-berlin.de/security/sap-sec/password-hash-algorithms/ + case 10400: pw_max = 32; break; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ + case 10410: pw_max = 5; break; // Underlaying RC4-40 max + case 10420: pw_max = 32; break; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ + case 10500: pw_max = 32; break; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ + case 10600: pw_max = 127; break; // https://www.pdflib.com/knowledge-base/pdf-password-security/encryption/ + case 10900: pw_max = PW_MAX; break; + case 11300: pw_max = PW_MAX; break; + case 11600: pw_max = PW_MAX; break; + case 11900: pw_max = PW_MAX; break; + case 12000: pw_max = PW_MAX; break; + case 12001: pw_max = PW_MAX; break; + case 12200: pw_max = PW_MAX; break; + case 12300: pw_max = PW_MAX; break; + case 12400: pw_max = PW_MAX; break; + case 12700: pw_max = PW_MAX; break; + case 12800: pw_max = PW_MAX; break; + case 12900: pw_max = PW_MAX; break; + case 13000: pw_max = PW_MAX; break; + case 13200: pw_max = PW_MAX; break; + case 13400: pw_max = PW_MAX; break; + case 13600: pw_max = PW_MAX; break; + case 13711: pw_max = 64; break; // VC limits itself to 64 + case 13712: pw_max = 64; break; // VC limits itself to 64 + case 13713: pw_max = 64; break; // VC limits itself to 64 + case 13721: pw_max = 64; break; // VC limits itself to 64 + case 13722: pw_max = 64; break; // VC limits itself to 64 + case 13723: pw_max = 64; break; // VC limits itself to 64 + case 13731: pw_max = 64; break; // VC limits itself to 64 + case 13732: pw_max = 64; break; // VC limits itself to 64 + case 13733: pw_max = 64; break; // VC limits itself to 64 + case 13741: pw_max = 64; break; // VC limits itself to 64 + case 13742: pw_max = 64; break; // VC limits itself to 64 + case 13743: pw_max = 64; break; // VC limits itself to 64 + case 13751: pw_max = 64; break; // VC limits itself to 64 + case 13752: pw_max = 64; break; // VC limits itself to 64 + case 13753: pw_max = 64; break; // VC limits itself to 64 + case 13761: pw_max = 64; break; // VC limits itself to 64 + case 13762: pw_max = 64; break; // VC limits itself to 64 + case 13763: pw_max = 64; break; // VC limits itself to 64 + case 13771: pw_max = 64; break; // VC limits itself to 64 + case 13772: pw_max = 64; break; // VC limits itself to 64 + case 13773: pw_max = 64; break; // VC limits itself to 64 + case 14000: pw_max = 8; break; // Underlaying DES fixed + case 14100: pw_max = 24; break; // Underlaying 3DES fixed + case 14611: pw_max = PW_MAX; break; + case 14612: pw_max = PW_MAX; break; + case 14613: pw_max = PW_MAX; break; + case 14621: pw_max = PW_MAX; break; + case 14622: pw_max = PW_MAX; break; + case 14623: pw_max = PW_MAX; break; + case 14631: pw_max = PW_MAX; break; + case 14632: pw_max = PW_MAX; break; + case 14633: pw_max = PW_MAX; break; + case 14641: pw_max = PW_MAX; break; + case 14642: pw_max = PW_MAX; break; + case 14643: pw_max = PW_MAX; break; + case 14700: pw_max = PW_MAX; break; + case 14800: pw_max = PW_MAX; break; + case 14900: pw_max = 10; break; // Underlaying Skip32 fixed + case 15100: pw_max = PW_MAX; break; + case 15300: pw_max = PW_MAX; break; + case 15400: pw_max = 32; break; // Underlaying ChaCha20 fixed + case 15600: pw_max = PW_MAX; break; + case 15700: pw_max = PW_MAX; break; + case 15900: pw_max = PW_MAX; break; + case 16000: pw_max = 8; break; // Underlaying DES max + case 16800: pw_max = 63; break; // WPA-PMKID-PBKDF2: limits itself to 63 by RFC + case 16801: pw_max = 64; break; // WPA-PMKID-PMK: fixed length + case 16900: pw_max = PW_MAX; break; + case 18400: pw_max = PW_MAX; break; + case 18600: pw_max = 51; break; // Bogus SHA-1 in StarOffice code } + + return pw_max; } -void decoder_apply_options (const hashconfig_t *hashconfig, void *data) +u32 default_salt_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u32 hash_type = hashconfig->hash_type; - const u64 opts_type = hashconfig->opts_type; - const u32 dgst_size = hashconfig->dgst_size; + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - u32 *digest_buf = (u32 *) data; - u64 *digest_buf64 = (u64 *) data; + // salt_min : this limit is only interessting for generic hash types that support a salt - if (opts_type & OPTS_TYPE_STATE_BUFFER_BE) + u32 salt_min = SALT_MIN; + + if (optimized_kernel == true) { - if (dgst_size == DGST_SIZE_4_2) - { - for (int i = 0; i < 2; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_4) - { - for (int i = 0; i < 4; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_5) - { - for (int i = 0; i < 5; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_6) - { - for (int i = 0; i < 6; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_7) - { - for (int i = 0; i < 7; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_8) - { - for (int i = 0; i < 8; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if ((dgst_size == DGST_SIZE_4_16) || (dgst_size == DGST_SIZE_8_8)) // same size, same result :) - { - if (hash_type == HASH_TYPE_WHIRLPOOL) - { - for (int i = 0; i < 16; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (hash_type == HASH_TYPE_SHA384) - { - for (int i = 0; i < 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); - } - else if (hash_type == HASH_TYPE_SHA512) - { - for (int i = 0; i < 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); - } - else if (hash_type == HASH_TYPE_GOST) - { - for (int i = 0; i < 16; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - } - else if (dgst_size == DGST_SIZE_4_64) + // unused case + } + + if (hashconfig->salt_type == SALT_TYPE_GENERIC) + { + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { - for (int i = 0; i < 64; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + salt_min *= 2; } - else if (dgst_size == DGST_SIZE_8_25) + + switch (hashconfig->hash_mode) { - for (int i = 0; i < 25; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); + case 11000: salt_min = 56; break; + case 12600: salt_min = 64; break; + case 15000: salt_min = 64; break; } } + + return salt_min; } -void encoder_apply_options (const hashconfig_t *hashconfig, void *data) +u32 default_salt_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { - const u32 hash_type = hashconfig->hash_type; - const u64 opts_type = hashconfig->opts_type; - const u32 dgst_size = hashconfig->dgst_size; + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - u32 *digest_buf = (u32 *) data; - u64 *digest_buf64 = (u64 *) data; + // salt_max : this limit is only interessting for generic hash types that support a salt - if (opts_type & OPTS_TYPE_STATE_BUFFER_BE) + u32 salt_max = SALT_MAX; + + if (optimized_kernel == true) { - if (dgst_size == DGST_SIZE_4_2) - { - for (int i = 0; i < 2; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_4) - { - for (int i = 0; i < 4; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_5) - { - for (int i = 0; i < 5; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_6) - { - for (int i = 0; i < 6; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_7) - { - for (int i = 0; i < 7; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (dgst_size == DGST_SIZE_4_8) - { - for (int i = 0; i < 8; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if ((dgst_size == DGST_SIZE_4_16) || (dgst_size == DGST_SIZE_8_8)) // same size, same result :) + salt_max = SALT_MAX_OLD; + + if ((hashconfig->opts_type & OPTS_TYPE_ST_UTF16LE) || (hashconfig->opts_type & OPTS_TYPE_ST_UTF16BE)) { - if (hash_type == HASH_TYPE_WHIRLPOOL) - { - for (int i = 0; i < 16; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } - else if (hash_type == HASH_TYPE_SHA384) - { - for (int i = 0; i < 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); - } - else if (hash_type == HASH_TYPE_SHA512) - { - for (int i = 0; i < 8; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); - } - else if (hash_type == HASH_TYPE_GOST) - { - for (int i = 0; i < 16; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); - } + salt_max /= 2; } - else if (dgst_size == DGST_SIZE_4_64) + } + + if (hashconfig->salt_type == SALT_TYPE_GENERIC) + { + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) { - for (int i = 0; i < 64; i++) digest_buf[i] = byte_swap_32 (digest_buf[i]); + salt_max *= 2; } - else if (dgst_size == DGST_SIZE_8_25) + + switch (hashconfig->hash_mode) { - for (int i = 0; i < 25; i++) digest_buf64[i] = byte_swap_64 (digest_buf64[i]); + case 11000: salt_max = 56; break; + case 12600: salt_max = 64; break; + case 15000: salt_max = 64; break; } } + + return salt_max; +} + +u32 default_benchmark_salt_len (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 salt_len = 0; + + if (hashconfig->is_salted == true) + { + salt_len = 8; + } + + return salt_len; +} + +u32 default_benchmark_salt_iter (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const u32 salt_len = 1; + + return salt_len; +} + +u32 default_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) +{ + const u32 opti_type = 0; + + return opti_type; +} + +u64 default_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) +{ + const u64 opts_type = 0; + + return opts_type; +} + +u64 default_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) +{ + const u64 kern_type = 0; + + return kern_type; +} + +const char *default_benchmark_mask (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 *mask = "?b?b?b?b?b?b?b"; + + /* + switch (hashconfig->hash_mode) + { + case 2500: mask = "?a?a?a?a?a?a?a?a"; + break; + case 2501: mask = "?a?a?a?a?a?a?a?axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + break; + case 9710: mask = "?b?b?b?b?b"; + break; + case 9810: mask = "?b?b?b?b?b"; + break; + case 10410: mask = "?b?b?b?b?b"; + break; + case 12500: mask = "?b?b?b?b?b"; + break; + case 14000: mask = "?b?b?b?b?b?b?bx"; + break; + case 14100: mask = "?b?b?b?b?b?b?bxxxxxxxxxxxxxxxxx"; + break; + case 14900: mask = "?b?b?b?b?bxxxxx"; + break; + case 16800: mask = "?a?a?a?a?a?a?a?a"; + break; + case 16801: mask = "?a?a?a?a?a?a?a?axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; + break; + default: mask = "?b?b?b?b?b?b?b"; + break; + } + */ + + return mask; +} + +u64 default_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 = 4; + + return tmp_size; +} + +u64 default_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) +{ + const u64 esalt_size = 0; + + return esalt_size; +} + +u32 default_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) +{ + const u32 salt_type = SALT_TYPE_NONE; + + return salt_type; +} + +u64 default_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) +{ + const u64 hook_salt_size = 0; + + return hook_salt_size; +} + +u64 default_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) +{ + const u64 hook_size = 4; + + return hook_size; +} + +const char *default_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 ""; +} + +const char *default_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 ""; } diff --git a/src/outfile.c b/src/outfile.c index d6a9b386f..11588e55b 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -357,9 +357,9 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl } } - const u32 pw_max = hashconfig_pw_max (hashconfig, user_options, user_options_extra); + const int pw_max = (const int) hashconfig->pw_max; - if (plain_len > (int) hashconfig->pw_max) plain_len = MIN (plain_len, (int) pw_max); + if (plain_len > pw_max) plain_len = MIN (plain_len, pw_max); // truecrypt and veracrypt boot only: // we do some kernel internal substituations, so we need to do that here as well, if it cracks