1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-27 00:48:13 +00:00

Support loading hash from command line in -m 22000 and -m 22001

Fixes #2742
This commit is contained in:
Jens Steube 2021-04-04 11:38:02 +02:00
parent 6daea9c7c1
commit 1323ef3a82
5 changed files with 62 additions and 26 deletions

View File

@ -423,6 +423,8 @@ typedef enum opts_type
OPTS_TYPE_AUX3 = (1ULL << 37), OPTS_TYPE_AUX3 = (1ULL << 37),
OPTS_TYPE_AUX4 = (1ULL << 38), OPTS_TYPE_AUX4 = (1ULL << 38),
OPTS_TYPE_BINARY_HASHFILE = (1ULL << 39), 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_PT_ADD06 = (1ULL << 41),
OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 42), 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 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

View File

@ -632,6 +632,20 @@ int hashes_init_filename (hashcat_ctx_t *hashcat_ctx)
*/ */
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
{
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE_OPTIONAL)
{
if ((user_options->benchmark == false) && (user_options->keyspace == false))
{
hashes->hashlist_mode = (hc_path_exist (user_options_extra->hc_hash) == true) ? HL_MODE_FILE_PLAIN : HL_MODE_ARG;
if (hashes->hashlist_mode == HL_MODE_FILE_PLAIN)
{
hashes->hashfile = user_options_extra->hc_hash;
}
}
}
else
{ {
hashes->hashlist_mode = HL_MODE_FILE_BINARY; hashes->hashlist_mode = HL_MODE_FILE_BINARY;
@ -647,6 +661,7 @@ int hashes_init_filename (hashcat_ctx_t *hashcat_ctx)
hashes->hashfile = user_options_extra->hc_hash; hashes->hashfile = user_options_extra->hc_hash;
} }
} }
}
else else
{ {
hashes->hashlist_mode = (hc_path_exist (user_options_extra->hc_hash) == true) ? HL_MODE_FILE_PLAIN : HL_MODE_ARG; hashes->hashlist_mode = (hc_path_exist (user_options_extra->hc_hash) == true) ? HL_MODE_FILE_PLAIN : HL_MODE_ARG;
@ -1857,6 +1872,12 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
else else
{ {
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
{
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE_OPTIONAL)
{
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; char *tmpfile_bin;
@ -1883,6 +1904,7 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
hcfree (tmpfile_bin); hcfree (tmpfile_bin);
} }
}
else else
{ {
hashconfig_t *hashconfig_st = (hashconfig_t *) hcmalloc (sizeof (hashconfig_t)); hashconfig_t *hashconfig_st = (hashconfig_t *) hcmalloc (sizeof (hashconfig_t));

View File

@ -35,6 +35,7 @@ static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE
| OPTS_TYPE_AUX3 | OPTS_TYPE_AUX3
| OPTS_TYPE_AUX4 | OPTS_TYPE_AUX4
| OPTS_TYPE_BINARY_HASHFILE | OPTS_TYPE_BINARY_HASHFILE
| OPTS_TYPE_BINARY_HASHFILE_OPTIONAL
| OPTS_TYPE_DEEP_COMP_KERNEL | OPTS_TYPE_DEEP_COMP_KERNEL
| OPTS_TYPE_COPY_TMPS; | OPTS_TYPE_COPY_TMPS;
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;

View File

@ -35,6 +35,7 @@ static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE
| OPTS_TYPE_AUX3 | OPTS_TYPE_AUX3
| OPTS_TYPE_AUX4 | OPTS_TYPE_AUX4
| OPTS_TYPE_BINARY_HASHFILE | OPTS_TYPE_BINARY_HASHFILE
| OPTS_TYPE_BINARY_HASHFILE_OPTIONAL
| OPTS_TYPE_DEEP_COMP_KERNEL | OPTS_TYPE_DEEP_COMP_KERNEL
| OPTS_TYPE_COPY_TMPS | OPTS_TYPE_COPY_TMPS
| OPTS_TYPE_POTFILE_NOPASS; | OPTS_TYPE_POTFILE_NOPASS;

View File

@ -329,9 +329,19 @@ char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx)
} }
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
{
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE_OPTIONAL)
{
if (hashes->hashfile)
{ {
return hcstrdup (hashes->hashfile); return hcstrdup (hashes->hashfile);
} }
}
else
{
return hcstrdup (hashes->hashfile);
}
}
char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);