Add module_hash_decode_zero_hash()

pull/1833/head
jsteube 5 years ago
parent 3ad6fab63e
commit cfc9772e0e

@ -19,7 +19,6 @@ static const u32 MODULE_VERSION_MINIMUM = 520;
* zero hashes shutcut
*/
static const char LM_ZERO_HASH[] = "aad3b435b51404ee";
static const char LM_MASKED_PLAIN[] = "[notfound]";
/**
@ -301,6 +300,7 @@ u64 default_opts_type (MAYBE_UNUSED const hashconfig_t *hash
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);
bool default_potfile_keep_all_hashes (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);

@ -29,6 +29,7 @@ u64 module_opts_type (MAYBE_UNUSED const hashconfig_t *hash
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);
bool module_potfile_keep_all_hashes (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);
@ -41,6 +42,8 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hash
u64 module_tmp_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);
bool module_warmup_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);
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);
int module_hash_decode_zero_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf);
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, MAYBE_UNUSED const int line_len);
int 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, MAYBE_UNUSED const int line_size);

@ -962,6 +962,7 @@ struct hashconfig
bool outfile_check_disable;
bool outfile_check_nocomp;
bool potfile_disable;
bool potfile_keep_all_hashes;
u32 pwdump_column;
};
@ -1564,8 +1565,6 @@ typedef struct potfile_ctx
{
bool enabled;
bool keep_all_hashes;
FILE *fp;
char *filename;
@ -2267,6 +2266,7 @@ typedef struct module_ctx
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 *);
bool (*module_potfile_keep_all_hashes) (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 *);
@ -2280,6 +2280,7 @@ typedef struct module_ctx
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_zero_hash) (const hashconfig_t *, void *, salt_t *, void *);
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);

@ -132,6 +132,7 @@ void module_init (module_ctx_t *module_ctx)
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_zero_hash = NULL;
module_ctx->module_hash_decode = module_hash_decode;
module_ctx->module_hash_encode = module_hash_encode;
module_ctx->module_hash_mode = NULL;
@ -148,6 +149,7 @@ void module_init (module_ctx_t *module_ctx)
module_ctx->module_outfile_check_disable = NULL;
module_ctx->module_outfile_check_nocomp = NULL;
module_ctx->module_potfile_disable = NULL;
module_ctx->module_potfile_keep_all_hashes = NULL;
module_ctx->module_pwdump_column = module_pwdump_column;
module_ctx->module_pw_max = NULL;
module_ctx->module_pw_min = NULL;

@ -1346,7 +1346,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
for (u32 hashes_pos = 1; hashes_pos < hashes_cnt; hashes_pos++)
{
if (potfile_ctx->keep_all_hashes == true)
if (hashconfig->potfile_keep_all_hashes == true)
{
// do not sort, because we need to keep all hashes in this particular case
}

@ -693,6 +693,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
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->potfile_keep_all_hashes = default_potfile_keep_all_hashes (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);
@ -739,6 +740,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
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_potfile_keep_all_hashes) hashconfig->potfile_keep_all_hashes = module_ctx->module_potfile_keep_all_hashes (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);
@ -1396,6 +1398,23 @@ bool default_hlfmt_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_U
return hlfmt_disable;
}
bool default_potfile_keep_all_hashes (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 potfile_keep_all_hashes = false;
// keep all hashes if --username was combined with --left or --show
if (user_options->username == true)
{
if ((user_options->show == true) || (user_options->left == true))
{
potfile_keep_all_hashes = true;
}
}
return potfile_keep_all_hashes;
}
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)
{
const u32 pwdump_column = PWDUMP_COLUMN_INVALID;

@ -28444,3 +28444,28 @@ int module_hash_decode_outfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY
}
}
int module_hash_decode_zero_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf)
{
if (hashconfig->hash_mode == 3000)
{
static const char LM_ZERO_HASH[] = "aad3b435b51404ee";
return module_hash_decode (hashconfig, digest, salt, esalt, LM_ZERO_HASH, 16);
}
bool potfile_keep_all_hashes
{
// keep all hashes if -m 3000 was combined with --left or --show
if (user_options->hash_mode == 3000)
{
if ((user_options->show == true) || (user_options->left == true))
{
potfile_ctx->keep_all_hashes = true;
}
}
}

@ -124,28 +124,6 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx)
potfile_ctx->fp = NULL;
}
// keep all hashes if --username was combined with --left or --show
potfile_ctx->keep_all_hashes = false;
if (user_options->username == true)
{
if ((user_options->show == true) || (user_options->left == true))
{
potfile_ctx->keep_all_hashes = true;
}
}
// keep all hashes if -m 3000 was combined with --left or --show
if (user_options->hash_mode == 3000)
{
if ((user_options->show == true) || (user_options->left == true))
{
potfile_ctx->keep_all_hashes = true;
}
}
// starting from here, we should allocate some scratch buffer for later use
u8 *out_buf = (u8 *) hcmalloc (HCBUFSIZ_LARGE);
@ -440,7 +418,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
pot_tree_entry_t *tree_entry_cache = NULL;
pot_hash_node_t *tree_nodes_cache = NULL;
if (potfile_ctx->keep_all_hashes == true)
if (hashconfig->potfile_keep_all_hashes == true)
{
// we need *at most* one entry for every hash
// (if there are no hashes with the same keys (hash + salt), a counter example would be: same hash but different user name)
@ -510,15 +488,13 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
}
}
// special case for a split hash
// do not use this unless really needed, for example as in LM
if (hashconfig->hash_mode == 3000)
if (module_ctx->module_hash_decode_zero_hash)
{
const int parser_status = module_ctx->module_hash_decode (hashconfig, hash_buf.digest, hash_buf.salt, hash_buf.esalt, LM_ZERO_HASH, 16);
module_ctx->module_hash_decode_zero_hash (hashconfig, hash_buf.digest, hash_buf.salt, hash_buf.esalt);
if (parser_status == PARSER_OK)
{
if (potfile_ctx->keep_all_hashes == true)
if (hashconfig->potfile_keep_all_hashes == true)
{
potfile_update_hashes (hashcat_ctx, &hash_buf, NULL, 0, all_hashes_tree);
}
@ -529,7 +505,6 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
potfile_update_hash (hashcat_ctx, found, NULL, 0);
}
}
}
const int rc = potfile_read_open (hashcat_ctx);
@ -652,7 +627,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
if (parser_status != PARSER_OK) continue;
if (potfile_ctx->keep_all_hashes == true)
if (hashconfig->potfile_keep_all_hashes == true)
{
potfile_update_hashes (hashcat_ctx, &hash_buf, line_pw_buf, (u32) line_pw_len, all_hashes_tree);
@ -669,8 +644,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
potfile_read_close (hashcat_ctx);
if (potfile_ctx->keep_all_hashes == true)
if (hashconfig->potfile_keep_all_hashes == true)
{
pot_tree_destroy (all_hashes_tree); // this could be slow (should we just skip it?)

Loading…
Cancel
Save