1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-26 00:18:36 +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_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

View File

@ -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
{

View File

@ -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;

View File

@ -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;

View File

@ -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);