From 3ad6fab63eed1f6b2cafe04b180b695015a043d4 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 20 Dec 2018 11:04:37 +0100 Subject: [PATCH] Add module_potfile_disable() --- include/interface.h | 1 + include/modules.h | 1 + include/types.h | 2 ++ modules/module_01000.c | 1 + src/dictstat.c | 3 +++ src/interface.c | 10 ++++++++++ src/interface_migrate.c | 12 ++++++++++++ src/outfile_check.c | 14 ++++++++++++-- src/potfile.c | 30 +++++++++++++++++++----------- 9 files changed, 61 insertions(+), 13 deletions(-) diff --git a/include/interface.h b/include/interface.h index 99dca34b7..3b8e32cf7 100644 --- a/include/interface.h +++ b/include/interface.h @@ -300,6 +300,7 @@ u32 default_opti_type (MAYBE_UNUSED const hashconfig_t *hash 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); bool default_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); bool default_outfile_check_nocomp (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +bool default_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); u32 default_pwdump_column (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); diff --git a/include/modules.h b/include/modules.h index 69cd60180..3139068fe 100644 --- a/include/modules.h +++ b/include/modules.h @@ -28,6 +28,7 @@ u32 module_opti_type (MAYBE_UNUSED const hashconfig_t *hash 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); bool module_outfile_check_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); bool module_outfile_check_nocomp (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); +bool module_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra); u32 module_pwdump_column (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); diff --git a/include/types.h b/include/types.h index d4b159506..279aa99f4 100644 --- a/include/types.h +++ b/include/types.h @@ -961,6 +961,7 @@ struct hashconfig bool warmup_disable; bool outfile_check_disable; bool outfile_check_nocomp; + bool potfile_disable; u32 pwdump_column; }; @@ -2265,6 +2266,7 @@ typedef struct module_ctx u64 (*module_opts_type) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); bool (*module_outfile_check_disable) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); bool (*module_outfile_check_nocomp) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); + bool (*module_potfile_disable) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); u32 (*module_pwdump_column) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *); 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 *); diff --git a/modules/module_01000.c b/modules/module_01000.c index 72d5c3712..2c6d41b0e 100644 --- a/modules/module_01000.c +++ b/modules/module_01000.c @@ -147,6 +147,7 @@ void module_init (module_ctx_t *module_ctx) module_ctx->module_opts_type = module_opts_type; module_ctx->module_outfile_check_disable = NULL; module_ctx->module_outfile_check_nocomp = NULL; + module_ctx->module_potfile_disable = NULL; module_ctx->module_pwdump_column = module_pwdump_column; module_ctx->module_pw_max = NULL; module_ctx->module_pw_min = NULL; diff --git a/src/dictstat.c b/src/dictstat.c index 6c643fb93..e7b52cc41 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -74,10 +74,13 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) void dictstat_destroy (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx; if (dictstat_ctx->enabled == false) return; + if (hashconfig->dictstat_disable == true) return; + hcfree (dictstat_ctx->filename); hcfree (dictstat_ctx->base); diff --git a/src/interface.c b/src/interface.c index 024902e44..6d9d6edda 100644 --- a/src/interface.c +++ b/src/interface.c @@ -692,6 +692,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->opts_type = default_opts_type (hashconfig, user_options, user_options_extra); hashconfig->outfile_check_disable = default_outfile_check_disable (hashconfig, user_options, user_options_extra); hashconfig->outfile_check_nocomp = default_outfile_check_nocomp (hashconfig, user_options, user_options_extra); + hashconfig->potfile_disable = default_potfile_disable (hashconfig, user_options, user_options_extra); hashconfig->pwdump_column = default_pwdump_column (hashconfig, user_options, user_options_extra); hashconfig->salt_type = default_salt_type (hashconfig, user_options, user_options_extra); hashconfig->separator = default_separator (hashconfig, user_options, user_options_extra); @@ -737,6 +738,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) if (module_ctx->module_opts_type) hashconfig->opts_type = module_ctx->module_opts_type (hashconfig, user_options, user_options_extra); if (module_ctx->module_outfile_check_disable) hashconfig->outfile_check_disable = module_ctx->module_outfile_check_disable (hashconfig, user_options, user_options_extra); if (module_ctx->module_outfile_check_nocomp) hashconfig->outfile_check_nocomp = module_ctx->module_outfile_check_nocomp (hashconfig, user_options, user_options_extra); + if (module_ctx->module_potfile_disable) hashconfig->potfile_disable = module_ctx->module_potfile_disable (hashconfig, user_options, user_options_extra); if (module_ctx->module_pwdump_column) hashconfig->pwdump_column = module_ctx->module_pwdump_column (hashconfig, user_options, user_options_extra); if (module_ctx->module_salt_type) hashconfig->salt_type = module_ctx->module_salt_type (hashconfig, user_options, user_options_extra); if (module_ctx->module_separator) hashconfig->separator = module_ctx->module_separator (hashconfig, user_options, user_options_extra); @@ -1401,6 +1403,14 @@ u32 default_pwdump_column (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UN return pwdump_column; } +bool default_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + const bool potfile_disable = false; + + return potfile_disable; +} + + // migrate void to_hccapx_t (hashcat_ctx_t *hashcat_ctx, hccapx_t *hccapx, const u32 salt_pos, const u32 digest_pos) diff --git a/src/interface_migrate.c b/src/interface_migrate.c index 319767d40..1822abe01 100644 --- a/src/interface_migrate.c +++ b/src/interface_migrate.c @@ -28375,6 +28375,18 @@ bool outfile_check_disable (user_options->hash_mode == 14600)) return 0; } +bool potfile_disable +{ + + if (hashconfig->hash_mode == 5200) return 0; + if ((hashconfig->hash_mode >= 6200) + && (hashconfig->hash_mode <= 6299)) return 0; + if (hashconfig->hash_mode == 9000) return 0; + if ((hashconfig->hash_mode >= 13700) + && (hashconfig->hash_mode <= 13799)) return 0; + if (hashconfig->hash_mode == 14600) return 0; +} + bool outfile_check_nocomp { if (hash_mode == 6800) diff --git a/src/outfile_check.c b/src/outfile_check.c index 186a8637d..f1857d2a8 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -289,6 +289,13 @@ HC_API_CALL void *thread_outfile_remove (void *p) { hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx; + + if (hashconfig->outfile_check_disable == true) return NULL; + + if (outcheck_ctx->enabled == false) return NULL; + const int rc = outfile_remove (hashcat_ctx); if (rc == -1) return NULL; @@ -312,10 +319,10 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->progress_only == true) return 0; if (user_options->opencl_info == true) return 0; - if (user_options->outfile_check_timer == 0) return 0; - if (hashconfig->outfile_check_disable == true) return 0; + if (user_options->outfile_check_timer == 0) return 0; + if (user_options->outfile_check_dir == NULL) { hc_asprintf (&outcheck_ctx->root_directory, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR); @@ -342,11 +349,14 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) void outcheck_ctx_destroy (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx; user_options_t *user_options = hashcat_ctx->user_options; if (outcheck_ctx->enabled == false) return; + if (hashconfig->outfile_check_disable == true) return; + if (rmdir (outcheck_ctx->root_directory) == -1) { if (errno == ENOENT) diff --git a/src/potfile.c b/src/potfile.c index 4eee11fa8..ec6c5bed1 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -90,9 +90,10 @@ void pot_tree_destroy (pot_tree_entry_t *tree) int potfile_init (hashcat_ctx_t *hashcat_ctx) { - folder_config_t *folder_config = hashcat_ctx->folder_config; - potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; - user_options_t *user_options = hashcat_ctx->user_options; + const folder_config_t *folder_config = hashcat_ctx->folder_config; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; potfile_ctx->enabled = false; @@ -107,6 +108,8 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->version == true) return 0; if (user_options->potfile_disable == true) return 0; + if (hashconfig->potfile_disable == true) return 0; + potfile_ctx->enabled = true; if (user_options->potfile_path == NULL) @@ -178,10 +181,13 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) void potfile_destroy (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; if (potfile_ctx->enabled == false) return; + if (hashconfig->potfile_disable == true) return; + hcfree (potfile_ctx->out_buf); hcfree (potfile_ctx->tmp_buf); @@ -208,10 +214,13 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx) void potfile_read_close (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; if (potfile_ctx->enabled == false) return; + if (hashconfig->potfile_disable == true) return; + if (potfile_ctx->fp == NULL) return; fclose (potfile_ctx->fp); @@ -239,10 +248,13 @@ int potfile_write_open (hashcat_ctx_t *hashcat_ctx) void potfile_write_close (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx; if (potfile_ctx->enabled == false) return; + if (hashconfig->potfile_disable == true) return; + fclose (potfile_ctx->fp); } @@ -254,6 +266,8 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 * if (potfile_ctx->enabled == false) return; + if (hashconfig->potfile_disable == true) return; + u8 *tmp_buf = potfile_ctx->tmp_buf; int tmp_len = 0; @@ -384,6 +398,8 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) if (potfile_ctx->enabled == false) return 0; + if (hashconfig->potfile_disable == true) return 0; + // if no potfile exists yet we don't need to do anything here if (hc_path_exist (potfile_ctx->filename) == false) return 0; @@ -393,14 +409,6 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx) // no solution for these special hash types (for instane because they use hashfile in output etc) - if (hashconfig->hash_mode == 5200) return 0; - if ((hashconfig->hash_mode >= 6200) - && (hashconfig->hash_mode <= 6299)) return 0; - if (hashconfig->hash_mode == 9000) return 0; - if ((hashconfig->hash_mode >= 13700) - && (hashconfig->hash_mode <= 13799)) return 0; - if (hashconfig->hash_mode == 14600) return 0; - hash_t hash_buf; hash_buf.digest = hcmalloc (hashconfig->dgst_size);