From ea22065b9cb6ff05524adef428406349bac8c5df Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 19 Dec 2018 10:13:51 +0100 Subject: [PATCH] Get rid of hash_mode in user_options.c --- include/interface.h | 1 + include/modules.h | 1 + include/types.h | 2 ++ modules/m01000.c | 1 + src/interface.c | 9 +++++++++ src/interface_migrate.c | 20 ++++++++++++++++++++ src/user_options.c | 33 --------------------------------- 7 files changed, 34 insertions(+), 33 deletions(-) diff --git a/include/interface.h b/include/interface.h index f9b612d21..07d145816 100644 --- a/include/interface.h +++ b/include/interface.h @@ -367,6 +367,7 @@ u32 default_dgst_size (MAYBE_UNUSED const hashconfig_t *hash 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); u32 default_forced_kernel_threads (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_forced_kernel_loops (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_forced_outfile_format (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_mode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); u32 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); diff --git a/include/modules.h b/include/modules.h index 05be0c4e5..a65b9ce48 100644 --- a/include/modules.h +++ b/include/modules.h @@ -16,6 +16,7 @@ u32 module_dgst_size (MAYBE_UNUSED const hashconfig_t *hash 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); u32 module_forced_kernel_threads (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_forced_kernel_loops (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_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); const char *module_hash_name (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); u32 module_hash_mode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); u32 module_hash_type (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); diff --git a/include/types.h b/include/types.h index 31de34ff0..15c03a373 100644 --- a/include/types.h +++ b/include/types.h @@ -949,6 +949,7 @@ struct hashconfig u32 forced_kernel_threads; u32 forced_kernel_loops; + u32 forced_outfile_format; bool dictstat_disable; bool hlfmt_disable; @@ -2240,6 +2241,7 @@ typedef struct module_ctx u64 (*module_esalt_size) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); u32 (*module_forced_kernel_threads) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); u32 (*module_forced_kernel_loops) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); + u32 (*module_forced_outfile_format) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); const char *(*module_hash_name) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); u32 (*module_hash_mode) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); u32 (*module_hash_type) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); diff --git a/modules/m01000.c b/modules/m01000.c index 7c74d9f68..06cac0331 100644 --- a/modules/m01000.c +++ b/modules/m01000.c @@ -126,6 +126,7 @@ void module_register (module_ctx_t *module_ctx) module_ctx->module_esalt_size = NULL; module_ctx->module_forced_kernel_threads = NULL; module_ctx->module_forced_kernel_loops = NULL; + module_ctx->module_forced_outfile_format = NULL; module_ctx->module_hash_decode = module_hash_decode; module_ctx->module_hash_encode = module_hash_encode; module_ctx->module_hash_mode = NULL; diff --git a/src/interface.c b/src/interface.c index 4c2bd80f0..76d1cdf90 100644 --- a/src/interface.c +++ b/src/interface.c @@ -868,6 +868,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->esalt_size = default_esalt_size (hashconfig, user_options, user_options_extra); hashconfig->forced_kernel_threads = default_forced_kernel_threads (hashconfig, user_options, user_options_extra); hashconfig->forced_kernel_loops = default_forced_kernel_loops (hashconfig, user_options, user_options_extra); + hashconfig->forced_outfile_format = default_forced_outfile_format (hashconfig, user_options, user_options_extra); hashconfig->hash_name = default_hash_name (hashconfig, user_options, user_options_extra); hashconfig->hash_mode = default_hash_mode (hashconfig, user_options, user_options_extra); hashconfig->hash_type = default_hash_type (hashconfig, user_options, user_options_extra); @@ -899,6 +900,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) if (module_ctx->module_esalt_size) hashconfig->esalt_size = module_ctx->module_esalt_size (hashconfig, user_options, user_options_extra); if (module_ctx->module_forced_kernel_threads) hashconfig->forced_kernel_threads = module_ctx->module_forced_kernel_threads (hashconfig, user_options, user_options_extra); if (module_ctx->module_forced_kernel_loops) hashconfig->forced_kernel_loops = module_ctx->module_forced_kernel_loops (hashconfig, user_options, user_options_extra); + if (module_ctx->module_forced_outfile_format) hashconfig->forced_outfile_format = module_ctx->module_forced_outfile_format (hashconfig, user_options, user_options_extra); if (module_ctx->module_hash_name) hashconfig->hash_name = module_ctx->module_hash_name (hashconfig, user_options, user_options_extra); if (module_ctx->module_hash_mode) hashconfig->hash_mode = module_ctx->module_hash_mode (hashconfig, user_options, user_options_extra); if (module_ctx->module_hash_type) hashconfig->hash_type = module_ctx->module_hash_type (hashconfig, user_options, user_options_extra); @@ -1862,6 +1864,13 @@ u32 default_forced_kernel_loops (MAYBE_UNUSED const hashconfig_t *hashconfig, MA return forced_kernel_loops; } +u32 default_forced_outfile_format (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 forced_outfile_format = user_options->outfile_format; + + return forced_outfile_format; +} + 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; diff --git a/src/interface_migrate.c b/src/interface_migrate.c index 06e9d0133..eac450b33 100644 --- a/src/interface_migrate.c +++ b/src/interface_migrate.c @@ -28167,3 +28167,23 @@ bool default_hlfmt_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_U } + +u32 default_forced_outfile_format +{ + + if (user_options->hash_mode == 9710) + { + user_options->outfile_format = 5; + } + + if (user_options->hash_mode == 9810) + { + user_options->outfile_format = 5; + } + + if (user_options->hash_mode == 10410) + { + user_options->outfile_format = 5; + } + +} diff --git a/src/user_options.c b/src/user_options.c index 3acb76e91..e3a7c22cf 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -621,21 +621,6 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if (user_options->username == true) - { - if ((user_options->hash_mode == 2500) - || (user_options->hash_mode == 2501) - || (user_options->hash_mode == 5200) - || ((user_options->hash_mode >= 6200) && (user_options->hash_mode <= 6299)) - || ((user_options->hash_mode >= 13700) && (user_options->hash_mode <= 13799)) - || (user_options->hash_mode == 9000)) - { - event_log_error (hashcat_ctx, "Combining --username with targets of hash-mode %u is not supported.", user_options->hash_mode); - - return -1; - } - } - if (user_options->outfile_format > 16) { event_log_error (hashcat_ctx, "Invalid --outfile-format value specified."); @@ -1591,24 +1576,6 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->limit += user_options->skip; } - if (user_options->hash_mode == 9710) - { - user_options->outfile_format = 5; - user_options->outfile_format_chgd = 1; - } - - if (user_options->hash_mode == 9810) - { - user_options->outfile_format = 5; - user_options->outfile_format_chgd = 1; - } - - if (user_options->hash_mode == 10410) - { - user_options->outfile_format = 5; - user_options->outfile_format_chgd = 1; - } - if (user_options->markov_threshold == 0) { user_options->markov_threshold = 0x100;