diff --git a/include/interface.h b/include/interface.h index c90caa2ba..1235aa587 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1696,10 +1696,10 @@ 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 (const hashcat_ctx_t *hashcat_ctx, const bool optimized_kernel); -int hashconfig_pw_max (const hashcat_ctx_t *hashcat_ctx, const bool optimized_kernel); -int hashconfig_salt_min (const hashcat_ctx_t *hashcat_ctx, const bool optimized_kernel); -int hashconfig_salt_max (const hashcat_ctx_t *hashcat_ctx, const bool optimized_kernel); +int hashconfig_pw_min (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); +int hashconfig_pw_max (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); +int hashconfig_salt_min (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); +int hashconfig_salt_max (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); void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt, void *hook_salt); const char *hashconfig_benchmark_mask (hashcat_ctx_t *hashcat_ctx); diff --git a/include/modules.h b/include/modules.h index 8414e3b91..8fcaa6423 100644 --- a/include/modules.h +++ b/include/modules.h @@ -1,48 +1,25 @@ - -#ifndef _MODULES_H -#define _MODULES_H - -typedef struct hashcat_module -{ - const char *(*module_hash_name) (); - u32 (*module_salt_type) (); - u32 (*module_attack_exec) (); - u64 (*module_opts_type) (); - u32 (*module_dgst_size) (); - u32 (*module_opti_type) (); - u32 (*module_dgst_pos0) (); - u32 (*module_dgst_pos1) (); - u32 (*module_dgst_pos2) (); - u32 (*module_dgst_pos3) (); - const char *(*module_st_hash) (); - const char *(*module_st_pass) (); - u32 (*module_pw_min) (const hashcat_ctx_t *); - u32 (*module_pw_max) (const hashcat_ctx_t *); - u32 (*module_salt_min) (const hashcat_ctx_t *); - u32 (*module_salt_max) (const hashcat_ctx_t *); - int (*module_hash_decode) (const hashcat_ctx_t *, const u8 *, const int, hash_t *); - int (*module_hash_encode) (const hashcat_ctx_t *, const void *, const salt_t *, const void *, u8 *, const size_t); - -} hashcat_module_t; - -const char *module_hash_name (); -u32 module_salt_type (); -u32 module_attack_exec (); -u64 module_opts_type (); -u32 module_dgst_size (); -u32 module_opti_type (); -u32 module_dgst_pos0 (); -u32 module_dgst_pos1 (); -u32 module_dgst_pos2 (); -u32 module_dgst_pos3 (); -const char *module_st_hash (); -const char *module_st_pass (); -u32 module_pw_min (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx); -u32 module_pw_max (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx); -u32 module_salt_min (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx); -u32 module_salt_max (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx); -int module_hash_decode (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx, const u8 *input_buf, const int input_len, hash_t *hash_buf); -int module_hash_encode (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *digest, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt, u8 *output_buf, const size_t output_size); -void module_register (hashcat_module_t *hashcat_module); - -#endif // _MODULES_H + +#ifndef _MODULES_H +#define _MODULES_H + +const char *module_hash_name (); +u32 module_salt_type (); +u32 module_attack_exec (); +u64 module_opts_type (); +u32 module_dgst_size (); +u32 module_opti_type (); +u32 module_dgst_pos0 (); +u32 module_dgst_pos1 (); +u32 module_dgst_pos2 (); +u32 module_dgst_pos3 (); +const char *module_st_hash (); +const char *module_st_pass (); +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); +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, const int *line_len); +void 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, int *line_len); +void module_register (module_ctx_t *module_ctx); + +#endif // _MODULES_H diff --git a/include/types.h b/include/types.h index c6d76106d..ed93b954f 100644 --- a/include/types.h +++ b/include/types.h @@ -2194,6 +2194,29 @@ typedef struct event_ctx } event_ctx_t; +typedef struct module_ctx +{ + const char *(*module_hash_name) (); + u32 (*module_salt_type) (); + u32 (*module_attack_exec) (); + u64 (*module_opts_type) (); + u32 (*module_dgst_size) (); + u32 (*module_opti_type) (); + u32 (*module_dgst_pos0) (); + u32 (*module_dgst_pos1) (); + u32 (*module_dgst_pos2) (); + u32 (*module_dgst_pos3) (); + const char *(*module_st_hash) (); + const char *(*module_st_pass) (); + u32 (*module_pw_min) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); + u32 (*module_pw_max) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); + u32 (*module_salt_min) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); + u32 (*module_salt_max) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); + int (*module_hash_decode) (const hashconfig_t *, void *, salt_t *, void *, const char *, const int *); + void (*module_hash_encode) (const hashconfig_t *, const void *, const salt_t *, const void *, char *, int *); + +} module_ctx_t; + typedef struct hashcat_ctx { bitmap_ctx_t *bitmap_ctx; @@ -2211,6 +2234,7 @@ typedef struct hashcat_ctx logfile_ctx_t *logfile_ctx; loopback_ctx_t *loopback_ctx; mask_ctx_t *mask_ctx; + module_ctx_t *module_ctx; opencl_ctx_t *opencl_ctx; outcheck_ctx_t *outcheck_ctx; outfile_ctx_t *outfile_ctx; diff --git a/modules/m01000.c b/modules/m01000.c index c48dea333..3118968e8 100644 --- a/modules/m01000.c +++ b/modules/m01000.c @@ -1,176 +1,163 @@ -/** - * Author......: See docs/credits.txt - * License.....: MIT - */ - -#include "common.h" -#include "types.h" -#include "modules.h" -#include "convert.h" -#include "interface.h" -#include "inc_hash_constants.h" - -static const char *HASH_NAME = "NTLM"; -static const u32 SALT_TYPE = SALT_TYPE_NONE; -static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; -static const u32 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_PT_ADD80 - | OPTS_TYPE_PT_ADDBITS14 - | OPTS_TYPE_PT_UTF16LE; -static const u32 DGST_SIZE = DGST_SIZE_4_4; -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 DGST_POS0 = 0; -static const u32 DGST_POS1 = 3; -static const u32 DGST_POS2 = 2; -static const u32 DGST_POS3 = 1; -static const char *ST_HASH = "b4b9b02e6f09a9bd760f388b67351e2b"; -static const char *ST_PASS = "hashcat"; -static const char *SIGNATURE = NULL; - -const char *module_hash_name () { return HASH_NAME; } -u32 module_salt_type () { return SALT_TYPE; } -u32 module_attack_exec () { return ATTACK_EXEC; } -u64 module_opts_type () { return OPTS_TYPE; } -u32 module_dgst_size () { return DGST_SIZE; } -u32 module_opti_type () { return OPTI_TYPE; } -u32 module_dgst_pos0 () { return DGST_POS0; } -u32 module_dgst_pos1 () { return DGST_POS1; } -u32 module_dgst_pos2 () { return DGST_POS2; } -u32 module_dgst_pos3 () { return DGST_POS3; } -const char *module_st_hash () { return ST_HASH; } -const char *module_st_pass () { return ST_PASS; } - -u32 module_salt_min (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx) -{ - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - - return hashconfig_salt_min (hashcat_ctx, optimized_kernel); -} - -u32 module_salt_max (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx) -{ - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - - return hashconfig_salt_max (hashcat_ctx, optimized_kernel); -} - -u32 module_pw_min (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx) -{ - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - - return hashconfig_pw_min (hashcat_ctx, optimized_kernel); -} - -u32 module_pw_max (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx) -{ - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - - return hashconfig_pw_max (hashcat_ctx, optimized_kernel); -} - -int module_hash_decode (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx, const u8 *input_buf, const int input_len, hash_t *hash_buf) -{ - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - u32 *digest = (u32 *) hash_buf->digest; - - token_t token; - - token.token_cnt = 1; - - token.len_min[0] = 32; - token.len_max[0] = 32; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - const u8 *hash_pos = token.buf[0]; - - digest[0] = hex_to_u32 (hash_pos + 0); - digest[1] = hex_to_u32 (hash_pos + 8); - digest[2] = hex_to_u32 (hash_pos + 16); - digest[3] = hex_to_u32 (hash_pos + 24); - - if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) - { - digest[0] -= MD4M_A; - digest[1] -= MD4M_B; - digest[2] -= MD4M_C; - digest[3] -= MD4M_D; - } - - return (PARSER_OK); -} - -int module_hash_encode (MAYBE_UNUSED const hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *digest, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt, u8 *output_buf, const size_t output_size) -{ - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - - u32 *digest_u32 = (u32 *) digest; - - // we can not change anything in the original buffer, otherwise destroying sorting - // therefore create some local buffer - - u32 digest_buf[4]; - - digest_buf[0] = digest_u32[0]; - digest_buf[1] = digest_u32[1]; - digest_buf[2] = digest_u32[2]; - digest_buf[3] = digest_u32[3]; - - if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) - { - digest_buf[0] += MD4M_A; - digest_buf[1] += MD4M_B; - digest_buf[2] += MD4M_C; - digest_buf[3] += MD4M_D; - } - - const int output_len = snprintf ((char *) output_buf, output_size - 1, "%08x%08x%08x%08x", - digest_buf[0], - digest_buf[1], - digest_buf[2], - digest_buf[3]); - - return output_len; -} - -void module_register (hashcat_module_t *hashcat_module) -{ - hashcat_module->module_hash_name = module_hash_name; - hashcat_module->module_salt_type = module_salt_type; - hashcat_module->module_attack_exec = module_attack_exec; - hashcat_module->module_opts_type = module_opts_type; - hashcat_module->module_dgst_size = module_dgst_size; - hashcat_module->module_opti_type = module_opti_type; - hashcat_module->module_dgst_pos0 = module_dgst_pos0; - hashcat_module->module_dgst_pos1 = module_dgst_pos1; - hashcat_module->module_dgst_pos2 = module_dgst_pos2; - hashcat_module->module_dgst_pos3 = module_dgst_pos3; - hashcat_module->module_st_hash = module_st_hash; - hashcat_module->module_st_pass = module_st_pass; - hashcat_module->module_salt_min = module_salt_min; - hashcat_module->module_salt_max = module_salt_max; - hashcat_module->module_pw_min = module_pw_min; - hashcat_module->module_pw_max = module_pw_max; - hashcat_module->module_hash_decode = module_hash_decode; - hashcat_module->module_hash_encode = module_hash_encode; -} +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "convert.h" +#include "interface.h" +#include "inc_hash_constants.h" + +static const char *HASH_NAME = "NTLM"; +static const u32 SALT_TYPE = SALT_TYPE_NONE; +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14 + | OPTS_TYPE_PT_UTF16LE; +static const u32 DGST_SIZE = DGST_SIZE_4_4; +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 DGST_POS0 = 0; +static const u32 DGST_POS1 = 3; +static const u32 DGST_POS2 = 2; +static const u32 DGST_POS3 = 1; +static const char *ST_HASH = "b4b9b02e6f09a9bd760f388b67351e2b"; +static const char *ST_PASS = "hashcat"; + +const char *module_hash_name () { return HASH_NAME; } +u32 module_salt_type () { return SALT_TYPE; } +u32 module_attack_exec () { return ATTACK_EXEC; } +u64 module_opts_type () { return OPTS_TYPE; } +u32 module_dgst_size () { return DGST_SIZE; } +u32 module_opti_type () { return OPTI_TYPE; } +u32 module_dgst_pos0 () { return DGST_POS0; } +u32 module_dgst_pos1 () { return DGST_POS1; } +u32 module_dgst_pos2 () { return DGST_POS2; } +u32 module_dgst_pos3 () { return DGST_POS3; } +const char *module_st_hash () { return ST_HASH; } +const char *module_st_pass () { return ST_PASS; } + +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) +{ + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + return hashconfig_salt_min (hashconfig, user_options, user_options_extra, optimized_kernel); +} + +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) +{ + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + return hashconfig_salt_max (hashconfig, user_options, user_options_extra, optimized_kernel); +} + +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) +{ + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + return hashconfig_pw_min (hashconfig, user_options, user_options_extra, optimized_kernel); +} + +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) +{ + const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); + + return hashconfig_pw_max (hashconfig, user_options, user_options_extra, optimized_kernel); +} + +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, const int *line_len) +{ + u32 *digest = (u32 *) digest_buf; + + token_t token; + + token.token_cnt = 1; + + token.len_min[0] = 32; + token.len_max[0] = 32; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH + | TOKEN_ATTR_VERIFY_HEX; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, (const int) *line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *hash_pos = token.buf[0]; + + digest[0] = hex_to_u32 (hash_pos + 0); + digest[1] = hex_to_u32 (hash_pos + 8); + digest[2] = hex_to_u32 (hash_pos + 16); + digest[3] = hex_to_u32 (hash_pos + 24); + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + digest[0] -= MD4M_A; + digest[1] -= MD4M_B; + digest[2] -= MD4M_C; + digest[3] -= MD4M_D; + } + + return (PARSER_OK); +} + +void 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, int *line_len) +{ + const u32 *digest = (const u32 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = digest[2]; + tmp[3] = digest[3]; + + if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) + { + tmp[0] += MD4M_A; + tmp[1] += MD4M_B; + tmp[2] += MD4M_C; + tmp[3] += MD4M_D; + } + + const int out_len = snprintf (line_buf, HCBUFSIZ_LARGE, "%08x%08x%08x%08x", + tmp[0], + tmp[1], + tmp[2], + tmp[3]); + + *line_len = out_len; +} + +void module_register (module_ctx_t *module_ctx) +{ + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_dgst_size = module_dgst_size; + module_ctx->module_opti_type = module_opti_type; + 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_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_salt_min = module_salt_min; + module_ctx->module_salt_max = module_salt_max; + module_ctx->module_pw_min = module_pw_min; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode = module_hash_encode; +} diff --git a/src/Makefile b/src/Makefile index 7e8dc5528..87b37a2df 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,7 +4,7 @@ ## SHARED := 0 -DEBUG := 0 +DEBUG := 1 PRODUCTION := 0 PRODUCTION_VERSION := v5.1.0 ENABLE_BRAIN := 1 @@ -367,6 +367,7 @@ default: $(HASHCAT_FRONTEND) clean: $(RM) -f $(HASHCAT_FRONTEND) $(RM) -f $(HASHCAT_LIBRARY) + $(RM) -f modules/*.so $(RM) -f obj/*.o $(RM) -f *.bin *.exe $(RM) -f *.pid @@ -526,7 +527,7 @@ ifeq ($(SHARED),1) $(HASHCAT_FRONTEND): src/main.c $(HASHCAT_LIBRARY) $(CC) $(CFLAGS_NATIVE) $^ -o $@ $(HASHCAT_LIBRARY) $(LFLAGS_NATIVE) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" else -$(HASHCAT_FRONTEND): src/main.c $(NATIVE_STATIC_OBJS) +$(HASHCAT_FRONTEND): src/main.c $(NATIVE_STATIC_OBJS) modules/m01000.so $(CC) $(CFLAGS_NATIVE) $^ -o $@ $(LFLAGS_NATIVE) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" endif diff --git a/src/hashcat.c b/src/hashcat.c index 1dccc3a44..708fdb352 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -920,6 +920,7 @@ int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct h hashcat_ctx->logfile_ctx = (logfile_ctx_t *) hcmalloc (sizeof (logfile_ctx_t)); hashcat_ctx->loopback_ctx = (loopback_ctx_t *) hcmalloc (sizeof (loopback_ctx_t)); hashcat_ctx->mask_ctx = (mask_ctx_t *) hcmalloc (sizeof (mask_ctx_t)); + hashcat_ctx->module_ctx = (module_ctx_t *) hcmalloc (sizeof (module_ctx_t)); hashcat_ctx->opencl_ctx = (opencl_ctx_t *) hcmalloc (sizeof (opencl_ctx_t)); hashcat_ctx->outcheck_ctx = (outcheck_ctx_t *) hcmalloc (sizeof (outcheck_ctx_t)); hashcat_ctx->outfile_ctx = (outfile_ctx_t *) hcmalloc (sizeof (outfile_ctx_t)); @@ -953,6 +954,7 @@ void hashcat_destroy (hashcat_ctx_t *hashcat_ctx) hcfree (hashcat_ctx->logfile_ctx); hcfree (hashcat_ctx->loopback_ctx); hcfree (hashcat_ctx->mask_ctx); + hcfree (hashcat_ctx->module_ctx); hcfree (hashcat_ctx->opencl_ctx); hcfree (hashcat_ctx->outcheck_ctx); hcfree (hashcat_ctx->outfile_ctx); diff --git a/src/hashes.c b/src/hashes.c index 523cd3048..dec0504f1 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -535,6 +535,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; + module_ctx_t *module_ctx = hashcat_ctx->module_ctx; user_options_t *user_options = hashcat_ctx->user_options; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; @@ -777,7 +778,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) size_t input_len = strlen (input_buf); char *hash_buf = NULL; - size_t hash_len = 0; + int hash_len = 0; hlfmt_hash (hashcat_ctx, hashlist_format, input_buf, input_len, &hash_buf, &hash_len); @@ -919,7 +920,11 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) memset (hashes_buf[hashes_cnt].hook_salt, 0, hashconfig->hook_salt_size); } - parser_status = hashconfig->parse_func ((u8 *) in, sizeof (hccapx_t), &hashes_buf[hashes_cnt], hashconfig); + const int decode_sz = sizeof (hccapx_t); + + hash_t *hash = &hashes_buf[hashes_cnt]; + + parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, in, &decode_sz); if (parser_status != PARSER_OK) { @@ -939,7 +944,13 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { if (hash_len == 32) { - parser_status = hashconfig->parse_func ((u8 *) hash_buf, 16, &hashes_buf[hashes_cnt], hashconfig); + const int decode_sz = 16; + + hash_t *hash; + + hash = &hashes_buf[hashes_cnt]; + + parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash_buf + 0, &decode_sz); if (parser_status == PARSER_OK) { @@ -953,7 +964,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) event_log_warning (hashcat_ctx, "Hash '%s': %s", input_buf, strparser (parser_status)); } - parser_status = hashconfig->parse_func ((u8 *) hash_buf + 16, 16, &hashes_buf[hashes_cnt], hashconfig); + hash = &hashes_buf[hashes_cnt]; + + parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash_buf + 16, &decode_sz); if (parser_status == PARSER_OK) { @@ -969,7 +982,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else { - parser_status = hashconfig->parse_func ((u8 *) hash_buf, (u32) hash_len, &hashes_buf[hashes_cnt], hashconfig); + hash_t *hash = &hashes_buf[hashes_cnt]; + + parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash_buf, &hash_len); if (parser_status == PARSER_OK) { @@ -990,7 +1005,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) for (int keyslot_idx = 0; keyslot_idx < LUKS_NUMKEYS; keyslot_idx++) { - parser_status = luks_parse_hash ((u8 *) hash_buf, (u32) hash_len, &hashes_buf[hashes_cnt], hashconfig, keyslot_idx); + parser_status = luks_parse_hash ((u8 *) hash_buf, (const int) hash_len, &hashes_buf[hashes_cnt], hashconfig, keyslot_idx); if (parser_status != PARSER_OK) { @@ -1007,7 +1022,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else { - parser_status = hashconfig->parse_func ((u8 *) hash_buf, (u32) hash_len, &hashes_buf[hashes_cnt], hashconfig); + hash_t *hash = &hashes_buf[hashes_cnt]; + + parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash_buf, &hash_len); if (parser_status == PARSER_OK) { @@ -1053,8 +1070,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) break; } - char *hash_buf = NULL; - size_t hash_len = 0; + char *hash_buf = NULL; + int hash_len = 0; hlfmt_hash (hashcat_ctx, hashlist_format, line_buf, line_len, &hash_buf, &hash_len); @@ -1072,8 +1089,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) if (user_options->username == true) { - char *user_buf = NULL; - size_t user_len = 0; + char *user_buf = NULL; + int user_len = 0; hlfmt_user (hashcat_ctx, hashlist_format, line_buf, line_len, &user_buf, &user_len); @@ -1137,7 +1154,13 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) { if (hash_len == 32) { - int parser_status = hashconfig->parse_func ((u8 *) hash_buf, 16, &hashes_buf[hashes_cnt], hashconfig); + const int decode_sz = 16; + + hash_t *hash; + + hash = &hashes_buf[hashes_cnt]; + + int parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash_buf + 0, &decode_sz); if (parser_status < PARSER_GLOBAL_ZERO) { @@ -1159,7 +1182,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) hashes_cnt++; - parser_status = hashconfig->parse_func ((u8 *) hash_buf + 16, 16, &hashes_buf[hashes_cnt], hashconfig); + hash = &hashes_buf[hashes_cnt]; + + parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash_buf + 16, &decode_sz); if (parser_status < PARSER_GLOBAL_ZERO) { @@ -1183,7 +1208,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else { - int parser_status = hashconfig->parse_func ((u8 *) hash_buf, (u32) hash_len, &hashes_buf[hashes_cnt], hashconfig); + hash_t *hash = &hashes_buf[hashes_cnt]; + + int parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash_buf, &hash_len); if (parser_status < PARSER_GLOBAL_ZERO) { @@ -1208,7 +1235,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) } else { - int parser_status = hashconfig->parse_func ((u8 *) hash_buf, (u32) hash_len, &hashes_buf[hashes_cnt], hashconfig); + hash_t *hash = &hashes_buf[hashes_cnt]; + + int parser_status = module_ctx->module_hash_decode (hashconfig, hash->digest, hash->salt, hash->esalt, hash_buf, &hash_len); if (parser_status < PARSER_GLOBAL_ZERO) { @@ -1687,6 +1716,7 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) folder_config_t *folder_config = hashcat_ctx->folder_config; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; + module_ctx_t *module_ctx = hashcat_ctx->module_ctx; user_options_t *user_options = hashcat_ctx->user_options; if (hashconfig->st_hash == NULL) return 0; @@ -1736,7 +1766,9 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) tmpdata[i] = c; } - parser_status = hashconfig->parse_func ((u8 *) tmpdata, sizeof (hccapx_t), &hash, hashconfig); + const int decode_sz = sizeof (hccapx_t); + + parser_status = module_ctx->module_hash_decode (hashconfig, hash.digest, hash.salt, hash.esalt, tmpdata, &decode_sz); hcfree (tmpdata); @@ -1766,7 +1798,9 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) fclose (fp); - parser_status = hashconfig->parse_func ((u8 *) tmpfile_bin, (u32) strlen (tmpfile_bin), &hash, hashconfig); + const int decode_sz = strlen (tmpfile_bin); + + parser_status = module_ctx->module_hash_decode (hashconfig, hash.digest, hash.salt, hash.esalt, tmpfile_bin, &decode_sz); unlink (tmpfile_bin); @@ -1790,14 +1824,9 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) } } - // Make sure that we do not modify constant data. Make a copy of the constant self-test hash - // Note: sometimes parse_func () modifies the data internally. We always need to use a copy of the original data - - char *tmpdata = hcstrdup (hashconfig->st_hash); + const int decode_sz = strlen (hashconfig->st_hash); - parser_status = hashconfig->parse_func ((u8 *) tmpdata, (u32) strlen (hashconfig->st_hash), &hash, hashconfig_st); - - hcfree (tmpdata); + parser_status = module_ctx->module_hash_decode (hashconfig_st, hash.digest, hash.salt, hash.esalt, hashconfig->st_hash, &decode_sz); hcfree (hashconfig_st); } diff --git a/src/interface.c b/src/interface.c index 5ed4a3baa..b63ad5063 100644 --- a/src/interface.c +++ b/src/interface.c @@ -23,6 +23,7 @@ #include "interface.h" #include "filehandling.h" #include "ext_lzma.h" +#include "modules.h" static const char *ST_PASS_HASHCAT_PLAIN = "hashcat"; static const char *ST_PASS_HASHCAT_EXCL = "hashcat!"; @@ -28647,6 +28648,8 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) default: return -1; } + module_register (hashcat_ctx->module_ctx); + if (user_options->keyboard_layout_mapping) { if ((hashconfig->opts_type & OPTS_TYPE_KEYBOARD_MAPPING) == 0) @@ -28997,10 +29000,10 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) const bool optimized_kernel = (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL); - hashconfig->pw_min = hashconfig_pw_min (hashcat_ctx, optimized_kernel); - hashconfig->pw_max = hashconfig_pw_max (hashcat_ctx, optimized_kernel); - hashconfig->salt_min = hashconfig_salt_min (hashcat_ctx, optimized_kernel); - hashconfig->salt_max = hashconfig_salt_max (hashcat_ctx, optimized_kernel); + hashconfig->pw_min = hashconfig_pw_min (hashconfig, user_options, user_options_extra, optimized_kernel); + hashconfig->pw_max = hashconfig_pw_max (hashconfig, user_options, user_options_extra, optimized_kernel); + hashconfig->salt_min = hashconfig_salt_min (hashconfig, user_options, user_options_extra, optimized_kernel); + hashconfig->salt_max = hashconfig_salt_max (hashconfig, user_options, user_options_extra, optimized_kernel); return 0; } @@ -29158,10 +29161,8 @@ u32 hashconfig_get_kernel_loops (hashcat_ctx_t *hashcat_ctx) return kernel_loops_fixed; } -int hashconfig_pw_min (const hashcat_ctx_t *hashcat_ctx, const bool optimized_kernel) +int hashconfig_pw_min (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) { - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - // pw_min : algo specific hard min length u32 pw_min = PW_MIN; @@ -29189,12 +29190,8 @@ int hashconfig_pw_min (const hashcat_ctx_t *hashcat_ctx, const bool optimized_ke return pw_min; } -int hashconfig_pw_max (const hashcat_ctx_t *hashcat_ctx, const bool optimized_kernel) +int hashconfig_pw_max (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) { - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - const user_options_t *user_options = hashcat_ctx->user_options; - const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - // pw_max : some algo suffer from support for long passwords, // the user need to add -L to enable support for them @@ -29436,10 +29433,8 @@ int hashconfig_pw_max (const hashcat_ctx_t *hashcat_ctx, const bool optimized_ke return pw_max; } -int hashconfig_salt_min (const hashcat_ctx_t *hashcat_ctx, const bool optimized_kernel) +int hashconfig_salt_min (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) { - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - // salt_min : this limit is only interessting for generic hash types that support a salt u32 salt_min = SALT_MIN; @@ -29467,10 +29462,8 @@ int hashconfig_salt_min (const hashcat_ctx_t *hashcat_ctx, const bool optimized_ return salt_min; } -int hashconfig_salt_max (const hashcat_ctx_t *hashcat_ctx, const bool optimized_kernel) +int hashconfig_salt_max (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) { - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - // salt_max : this limit is only interessting for generic hash types that support a salt u32 salt_max = SALT_MAX; diff --git a/src/outfile.c b/src/outfile.c index 2d0dbd822..117b75e3d 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -140,12 +140,13 @@ static int execute_keyboard_layout_mapping (u32 plain_buf[64], const int plain_l int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len) { - const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - const hashes_t *hashes = hashcat_ctx->hashes; - const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; - const user_options_t *user_options = hashcat_ctx->user_options; + const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashes_t *hashes = hashcat_ctx->hashes; + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; + const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; const u64 gidvid = plain->gidvid; const u32 il_pos = plain->il_pos; @@ -356,7 +357,7 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl } } - const u32 pw_max = hashconfig_pw_max (hashcat_ctx, false); + const u32 pw_max = hashconfig_pw_max (hashconfig, user_options, user_options_extra, false); if (plain_len > (int) hashconfig->pw_max) plain_len = MIN (plain_len, (int) pw_max); diff --git a/src/outfile_check.c b/src/outfile_check.c index b0539b6c1..7410c2fea 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -23,6 +23,7 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; + module_ctx_t *module_ctx = hashcat_ctx->module_ctx; outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; user_options_t *user_options = hashcat_ctx->user_options; @@ -226,12 +227,13 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx) } else // "normal" case: hash in the outfile is the same as the hash in the original hash file { - parser_status = hashconfig->parse_func ((u8 *) line_buf, (u32) line_len - 1, &hash_buf, hashconfig); + const int decode_sz = line_len - 1; + + parser_status = module_ctx->module_hash_decode (hashconfig, hash_buf.digest, hash_buf.salt, hash_buf.esalt, line_buf, &decode_sz); } if (parser_status != PARSER_OK) continue; - salt_t *salt_buf = salts_buf; if (is_salted == true) diff --git a/src/potfile.c b/src/potfile.c index 9a6f5f452..951e28bfd 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -377,8 +377,9 @@ void potfile_update_hashes (hashcat_ctx_t *hashcat_ctx, hash_t *hash_buf, char * int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) { - hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const hashes_t *hashes = hashcat_ctx->hashes; + const module_ctx_t *module_ctx = hashcat_ctx->module_ctx; const potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; if (potfile_ctx->enabled == false) return 0; @@ -501,12 +502,13 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) } } - // special case for a split hash if (hashconfig->hash_mode == 3000) { - int parser_status = hashconfig->parse_func ((u8 *) LM_ZERO_HASH, 16, &hash_buf, hashconfig); + const int decode_sz = 16; + + const int parser_status = module_ctx->module_hash_decode (hashconfig, hash_buf.digest, hash_buf.salt, hash_buf.esalt, LM_ZERO_HASH, &decode_sz); if (parser_status == PARSER_OK) { @@ -545,7 +547,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) char *line_hash_buf = line_buf; - size_t line_hash_len = last_separator - line_buf; + int line_hash_len = last_separator - line_buf; line_hash_buf[line_hash_len] = 0; @@ -640,7 +642,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) } else { - int parser_status = hashconfig->parse_func ((u8 *) line_hash_buf, (u32) line_hash_len, &hash_buf, hashconfig); + const int parser_status = module_ctx->module_hash_decode (hashconfig, hash_buf.digest, hash_buf.salt, hash_buf.esalt, line_hash_buf, &line_hash_len); if (parser_status != PARSER_OK) continue;