1
mirror of https://github.com/hashcat/hashcat synced 2024-11-20 23:27:31 +01:00

Get rid of hash_mode in outfile_check.c

This commit is contained in:
jsteube 2018-12-20 10:33:29 +01:00
parent ce0e19f185
commit 6928e5bfbe
7 changed files with 83 additions and 46 deletions

View File

@ -298,6 +298,7 @@ u64 default_hook_size (MAYBE_UNUSED const hashconfig_t *hash
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);
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);
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);

View File

@ -26,6 +26,7 @@ u64 module_hook_size (MAYBE_UNUSED const hashconfig_t *hash
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);
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);
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);

View File

@ -959,6 +959,7 @@ struct hashconfig
bool dictstat_disable;
bool hlfmt_disable;
bool warmup_disable;
bool outfile_check_disable;
u32 pwdump_column;
};
@ -2261,6 +2262,7 @@ typedef struct module_ctx
u64 (*module_kern_type) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *);
u32 (*module_opti_type) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *);
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 *);
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 *);
@ -2273,6 +2275,7 @@ typedef struct module_ctx
u64 (*module_tmp_size) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *);
bool (*module_warmup_disable) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *);
int (*module_hash_decode_outfile) (const hashconfig_t *, void *, salt_t *, void *, const char *, const int);
int (*module_hash_decode) (const hashconfig_t *, void *, salt_t *, void *, const char *, const int);
int (*module_hash_encode) (const hashconfig_t *, const void *, const salt_t *, const void *, char *, int);

View File

@ -131,6 +131,7 @@ void module_init (module_ctx_t *module_ctx)
module_ctx->module_forced_kernel_loops = NULL;
module_ctx->module_forced_kernel_threads = NULL;
module_ctx->module_forced_outfile_format = NULL;
module_ctx->module_hash_decode_outfile = NULL;
module_ctx->module_hash_decode = module_hash_decode;
module_ctx->module_hash_encode = module_hash_encode;
module_ctx->module_hash_mode = NULL;
@ -144,6 +145,7 @@ void module_init (module_ctx_t *module_ctx)
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_outfile_check_disable = NULL;
module_ctx->module_pwdump_column = module_pwdump_column;
module_ctx->module_pw_max = NULL;
module_ctx->module_pw_min = NULL;

View File

@ -690,6 +690,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
hashconfig->kern_type = default_kern_type (hashconfig, user_options, user_options_extra);
hashconfig->opti_type = default_opti_type (hashconfig, user_options, user_options_extra);
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->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);
@ -733,6 +734,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
if (module_ctx->module_kern_type) hashconfig->kern_type = module_ctx->module_kern_type (hashconfig, user_options, user_options_extra);
if (module_ctx->module_opti_type) hashconfig->opti_type = module_ctx->module_opti_type (hashconfig, user_options, user_options_extra);
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_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);
@ -1369,6 +1371,13 @@ bool default_warmup_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_
return warmup_disable;
}
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)
{
const bool outfile_check_disable = false;
return outfile_check_disable;
}
bool default_hlfmt_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 hlfmt_disable = false;

View File

@ -28362,3 +28362,63 @@ static void precompute_salt_md5 (const u32 *salt_buf, const u32 salt_len, u8 *sa
u32_to_hex (digest[2], salt_pc + 16);
u32_to_hex (digest[3], salt_pc + 24);
}
u32 outfile_check_disable
{
if ((user_options->hash_mode == 5200) ||
((user_options->hash_mode >= 6200) && (user_options->hash_mode <= 6299)) ||
(user_options->hash_mode == 9000) ||
((user_options->hash_mode >= 13700) && (user_options->hash_mode <= 13799)) ||
(user_options->hash_mode == 14600)) return 0;
}
int module_hash_decode_outfile (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)
{
if ((hash_mode == 2500) || (hash_mode == 2501)) // special case WPA/WPA2
{
// fake the parsing of the salt
u32 identifier_len = 32 + 1 + 12 + 1 + 12 + 1; // format is [ID_MD5]:[MAC1]:[MAC2]:$salt:$pass
if (line_len < identifier_len) continue;
hash_buf.salt->salt_len = line_len - identifier_len;
memcpy (hash_buf.salt->salt_buf, line_buf + identifier_len, hash_buf.salt->salt_len);
// fake the parsing of the digest
if (is_valid_hex_string ((u8 *) line_buf, 32) == false) break;
u32 *digest = (u32 *) hash_buf.digest;
digest[0] = hex_to_u32 ((u8 *) line_buf + 0);
digest[1] = hex_to_u32 ((u8 *) line_buf + 8);
digest[2] = hex_to_u32 ((u8 *) line_buf + 16);
digest[3] = hex_to_u32 ((u8 *) line_buf + 24);
digest[0] = byte_swap_32 (digest[0]);
digest[1] = byte_swap_32 (digest[1]);
digest[2] = byte_swap_32 (digest[2]);
digest[3] = byte_swap_32 (digest[3]);
parser_status = PARSER_OK;
}
else if (hash_mode == 6800) // special case LastPass (only email address in outfile/potfile)
{
// fake the parsing of the hash/salt
hash_buf.salt->salt_len = line_len;
memcpy (hash_buf.salt->salt_buf, line_buf, line_len);
parser_status = PARSER_OK;
}
}

View File

@ -185,45 +185,9 @@ static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
int parser_status = PARSER_HASH_LENGTH;
if ((hash_mode == 2500) || (hash_mode == 2501)) // special case WPA/WPA2
if (module_ctx->module_hash_decode_outfile)
{
// fake the parsing of the salt
u32 identifier_len = 32 + 1 + 12 + 1 + 12 + 1; // format is [ID_MD5]:[MAC1]:[MAC2]:$salt:$pass
if ((line_len - 1) < identifier_len) continue;
hash_buf.salt->salt_len = line_len - 1 - identifier_len;
memcpy (hash_buf.salt->salt_buf, line_buf + identifier_len, hash_buf.salt->salt_len);
// fake the parsing of the digest
if (is_valid_hex_string ((u8 *) line_buf, 32) == false) break;
u32 *digest = (u32 *) hash_buf.digest;
digest[0] = hex_to_u32 ((u8 *) line_buf + 0);
digest[1] = hex_to_u32 ((u8 *) line_buf + 8);
digest[2] = hex_to_u32 ((u8 *) line_buf + 16);
digest[3] = hex_to_u32 ((u8 *) line_buf + 24);
digest[0] = byte_swap_32 (digest[0]);
digest[1] = byte_swap_32 (digest[1]);
digest[2] = byte_swap_32 (digest[2]);
digest[3] = byte_swap_32 (digest[3]);
parser_status = PARSER_OK;
}
else if (hash_mode == 6800) // special case LastPass (only email address in outfile/potfile)
{
// fake the parsing of the hash/salt
hash_buf.salt->salt_len = line_len - 1;
memcpy (hash_buf.salt->salt_buf, line_buf, line_len - 1);
parser_status = PARSER_OK;
parser_status = module_ctx->module_hash_decode_outfile (hashconfig, hash_buf.digest, hash_buf.salt, hash_buf.esalt, line_buf, line_len - 1);
}
else // "normal" case: hash in the outfile is the same as the hash in the original hash file
{
@ -338,9 +302,10 @@ HC_API_CALL void *thread_outfile_remove (void *p)
int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
folder_config_t *folder_config = hashcat_ctx->folder_config;
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_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;
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
outcheck_ctx->enabled = false;
@ -353,11 +318,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->outfile_check_timer == 0) return 0;
if ((user_options->hash_mode == 5200) ||
((user_options->hash_mode >= 6200) && (user_options->hash_mode <= 6299)) ||
(user_options->hash_mode == 9000) ||
((user_options->hash_mode >= 13700) && (user_options->hash_mode <= 13799)) ||
(user_options->hash_mode == 14600)) return 0;
if (hashconfig->outfile_check_disable == true) return 0;
if (user_options->outfile_check_dir == NULL)
{