diff --git a/include/types.h b/include/types.h index 3f1a1cb9f..fcb3fd305 100644 --- a/include/types.h +++ b/include/types.h @@ -423,6 +423,8 @@ typedef enum opts_type OPTS_TYPE_AUX3 = (1ULL << 37), OPTS_TYPE_AUX4 = (1ULL << 38), OPTS_TYPE_BINARY_HASHFILE = (1ULL << 39), + OPTS_TYPE_BINARY_HASHFILE_OPTIONAL + = (1ULL << 40), // this allows us to not enforce the use of a binary file. requires OPTS_TYPE_BINARY_HASHFILE set to be effective. OPTS_TYPE_PT_ADD06 = (1ULL << 41), OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 42), OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 43), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately diff --git a/src/hashes.c b/src/hashes.c index 653df4e39..9f76e58de 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -633,18 +633,33 @@ int hashes_init_filename (hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) { - hashes->hashlist_mode = HL_MODE_FILE_BINARY; - - if ((user_options->benchmark == false) && (user_options->keyspace == false)) + if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE_OPTIONAL) { - if (hc_path_read (user_options_extra->hc_hash) == false) + if ((user_options->benchmark == false) && (user_options->keyspace == false)) { - event_log_error (hashcat_ctx, "%s: %s", user_options_extra->hc_hash, strerror (errno)); + hashes->hashlist_mode = (hc_path_exist (user_options_extra->hc_hash) == true) ? HL_MODE_FILE_PLAIN : HL_MODE_ARG; - return -1; + if (hashes->hashlist_mode == HL_MODE_FILE_PLAIN) + { + hashes->hashfile = user_options_extra->hc_hash; + } } + } + else + { + hashes->hashlist_mode = HL_MODE_FILE_BINARY; - hashes->hashfile = user_options_extra->hc_hash; + if ((user_options->benchmark == false) && (user_options->keyspace == false)) + { + if (hc_path_read (user_options_extra->hc_hash) == false) + { + event_log_error (hashcat_ctx, "%s: %s", user_options_extra->hc_hash, strerror (errno)); + + return -1; + } + + hashes->hashfile = user_options_extra->hc_hash; + } } } else @@ -1858,30 +1873,37 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx) { if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) { - char *tmpfile_bin; - - hc_asprintf (&tmpfile_bin, "%s/selftest.hash", folder_config->session_dir); - - HCFILE fp; - - hc_fopen (&fp, tmpfile_bin, "wb"); - - const size_t st_hash_len = strlen (hashconfig->st_hash); - - for (size_t i = 0; i < st_hash_len; i += 2) + if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE_OPTIONAL) { - const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + i); - - hc_fputc (c, &fp); + parser_status = module_ctx->module_hash_decode (hashconfig, hash.digest, hash.salt, hash.esalt, hash.hook_salt, hash.hash_info, hashconfig->st_hash, strlen (hashconfig->st_hash)); } + else + { + char *tmpfile_bin; - hc_fclose (&fp); + hc_asprintf (&tmpfile_bin, "%s/selftest.hash", folder_config->session_dir); - parser_status = module_ctx->module_hash_decode (hashconfig, hash.digest, hash.salt, hash.esalt, hash.hook_salt, hash.hash_info, tmpfile_bin, strlen (tmpfile_bin)); + HCFILE fp; - unlink (tmpfile_bin); + hc_fopen (&fp, tmpfile_bin, "wb"); - hcfree (tmpfile_bin); + const size_t st_hash_len = strlen (hashconfig->st_hash); + + for (size_t i = 0; i < st_hash_len; i += 2) + { + const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + i); + + hc_fputc (c, &fp); + } + + hc_fclose (&fp); + + parser_status = module_ctx->module_hash_decode (hashconfig, hash.digest, hash.salt, hash.esalt, hash.hook_salt, hash.hash_info, tmpfile_bin, strlen (tmpfile_bin)); + + unlink (tmpfile_bin); + + hcfree (tmpfile_bin); + } } else { diff --git a/src/modules/module_22000.c b/src/modules/module_22000.c index 0a6114e8e..996f6eda5 100644 --- a/src/modules/module_22000.c +++ b/src/modules/module_22000.c @@ -35,6 +35,7 @@ static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_AUX3 | OPTS_TYPE_AUX4 | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_BINARY_HASHFILE_OPTIONAL | OPTS_TYPE_DEEP_COMP_KERNEL | OPTS_TYPE_COPY_TMPS; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; diff --git a/src/modules/module_22001.c b/src/modules/module_22001.c index 0eded3201..5b8737c3d 100644 --- a/src/modules/module_22001.c +++ b/src/modules/module_22001.c @@ -35,6 +35,7 @@ static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE | OPTS_TYPE_AUX3 | OPTS_TYPE_AUX4 | OPTS_TYPE_BINARY_HASHFILE + | OPTS_TYPE_BINARY_HASHFILE_OPTIONAL | OPTS_TYPE_DEEP_COMP_KERNEL | OPTS_TYPE_COPY_TMPS | OPTS_TYPE_POTFILE_NOPASS; diff --git a/src/status.c b/src/status.c index 4234e5d60..a9f56190a 100644 --- a/src/status.c +++ b/src/status.c @@ -330,7 +330,17 @@ char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx) if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) { - return hcstrdup (hashes->hashfile); + if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE_OPTIONAL) + { + if (hashes->hashfile) + { + return hcstrdup (hashes->hashfile); + } + } + else + { + return hcstrdup (hashes->hashfile); + } } char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);