1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-15 19:18:23 +00:00

Commandline: Throw an error if separator character given by the user with -p option is not exactly 1 byte

This commit is contained in:
Jens Steube 2021-07-22 18:54:02 +02:00
parent 5024865d87
commit f9e74045b5
6 changed files with 42 additions and 18 deletions

View File

@ -28,6 +28,7 @@
## Technical ## Technical
## ##
- Commandline: Throw an error if separator character given by the user with -p option is not exactly 1 byte
- Kernel Cache: Add kernel threads into hash computation which is later used in the kernel cache filename - Kernel Cache: Add kernel threads into hash computation which is later used in the kernel cache filename
- HIP Kernels: Got rid of hip/hip_runtime.h dependancy to enable more easy integration of the HIP backend on Windows - HIP Kernels: Got rid of hip/hip_runtime.h dependancy to enable more easy integration of the HIP backend on Windows
- SCRYPT Kernels: Add more optimized values for some new NV/AMD GPUs - SCRYPT Kernels: Add more optimized values for some new NV/AMD GPUs

View File

@ -671,7 +671,6 @@ typedef enum user_options_defaults
SCRYPT_TMTO = 0, SCRYPT_TMTO = 0,
SEGMENT_SIZE = 33554432, SEGMENT_SIZE = 33554432,
SELF_TEST_DISABLE = false, SELF_TEST_DISABLE = false,
SEPARATOR = ':',
SHOW = false, SHOW = false,
SKIP = 0, SKIP = 0,
SLOW_CANDIDATES = false, SLOW_CANDIDATES = false,
@ -2105,6 +2104,7 @@ typedef struct user_options
bool skip_chgd; bool skip_chgd;
bool limit_chgd; bool limit_chgd;
bool scrypt_tmto_chgd; bool scrypt_tmto_chgd;
bool separator_chgd;
bool advice_disable; bool advice_disable;
bool benchmark; bool benchmark;
@ -2174,7 +2174,7 @@ typedef struct user_options
char *potfile_path; char *potfile_path;
char *restore_file_path; char *restore_file_path;
char **rp_files; char **rp_files;
char separator; char *separator;
char *truecrypt_keyfiles; char *truecrypt_keyfiles;
char *veracrypt_keyfiles; char *veracrypt_keyfiles;
const char *custom_charset_1; const char *custom_charset_1;
@ -2240,6 +2240,8 @@ typedef struct user_options_extra
u32 wordlist_mode; u32 wordlist_mode;
char separator;
char *hc_hash; // can be filename or string char *hc_hash; // can be filename or string
int hc_workc; // can be 0 in bf-mode = default mask int hc_workc; // can be 0 in bf-mode = default mask

View File

@ -1977,7 +1977,7 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
memcpy (hashconfig_st, hashconfig, sizeof (hashconfig_t)); memcpy (hashconfig_st, hashconfig, sizeof (hashconfig_t));
hashconfig_st->separator = SEPARATOR; hashconfig_st->separator = ':';
if (user_options->hex_salt) if (user_options->hex_salt)
{ {

View File

@ -621,7 +621,7 @@ u64 default_hook_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED
char default_separator (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) char default_separator (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{ {
return user_options->separator; return user_options_extra->separator;
} }
bool default_dictstat_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_dictstat_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)

View File

@ -623,7 +623,7 @@ void compress_terminal_line_length (char *out_buf, const size_t keep_from_beginn
*ptr1 = 0; *ptr1 = 0;
} }
void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_t *user_options) void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_options_extra)
{ {
if (hashconfig_init (hashcat_ctx) == 0) if (hashconfig_init (hashcat_ctx) == 0)
{ {
@ -676,7 +676,7 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_t *user_options)
event_log_info (hashcat_ctx, " Example.Hash........: %s", hashconfig->st_hash); event_log_info (hashcat_ctx, " Example.Hash........: %s", hashconfig->st_hash);
} }
if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options->separator, false)) if (need_hexify ((const u8 *) hashconfig->st_pass, strlen (hashconfig->st_pass), user_options_extra->separator, false))
{ {
char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE); char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
@ -728,8 +728,9 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_t *user_options)
void hash_info (hashcat_ctx_t *hashcat_ctx) void hash_info (hashcat_ctx_t *hashcat_ctx)
{ {
folder_config_t *folder_config = hashcat_ctx->folder_config; folder_config_t *folder_config = hashcat_ctx->folder_config;
user_options_t *user_options = hashcat_ctx->user_options; user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
event_log_info (hashcat_ctx, "Hash Info:"); event_log_info (hashcat_ctx, "Hash Info:");
event_log_info (hashcat_ctx, "=========="); event_log_info (hashcat_ctx, "==========");
@ -737,7 +738,7 @@ void hash_info (hashcat_ctx_t *hashcat_ctx)
if (user_options->hash_mode_chgd == true) if (user_options->hash_mode_chgd == true)
{ {
hash_info_single (hashcat_ctx, user_options); hash_info_single (hashcat_ctx, user_options_extra);
} }
else else
{ {
@ -751,7 +752,7 @@ void hash_info (hashcat_ctx_t *hashcat_ctx)
if (hc_path_exist (modulefile) == false) continue; if (hc_path_exist (modulefile) == false) continue;
hash_info_single (hashcat_ctx, user_options); hash_info_single (hashcat_ctx, user_options_extra);
} }
hcfree (modulefile); hcfree (modulefile);

View File

@ -25,6 +25,8 @@ static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4
static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMS"; static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMS";
#endif #endif
static char *SEPARATOR = ":";
static const struct option long_options[] = static const struct option long_options[] =
{ {
{"advice-disable", no_argument, NULL, IDX_ADVICE_DISABLE}, {"advice-disable", no_argument, NULL, IDX_ADVICE_DISABLE},
@ -482,7 +484,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
user_options->segment_size_chgd = true; break; user_options->segment_size_chgd = true; break;
case IDX_SCRYPT_TMTO: user_options->scrypt_tmto = hc_strtoul (optarg, NULL, 10); case IDX_SCRYPT_TMTO: user_options->scrypt_tmto = hc_strtoul (optarg, NULL, 10);
user_options->scrypt_tmto_chgd = true; break; user_options->scrypt_tmto_chgd = true; break;
case IDX_SEPARATOR: user_options->separator = optarg[0]; break; case IDX_SEPARATOR: user_options->separator = optarg;
user_options->separator_chgd = true; break;
case IDX_BITMAP_MIN: user_options->bitmap_min = hc_strtoul (optarg, NULL, 10); break; case IDX_BITMAP_MIN: user_options->bitmap_min = hc_strtoul (optarg, NULL, 10); break;
case IDX_BITMAP_MAX: user_options->bitmap_max = hc_strtoul (optarg, NULL, 10); break; case IDX_BITMAP_MAX: user_options->bitmap_max = hc_strtoul (optarg, NULL, 10); break;
case IDX_HOOK_THREADS: user_options->hook_threads = hc_strtoul (optarg, NULL, 10); break; case IDX_HOOK_THREADS: user_options->hook_threads = hc_strtoul (optarg, NULL, 10); break;
@ -583,6 +586,16 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
} }
#endif #endif
if (user_options->separator_chgd == true)
{
if (strlen (user_options->separator) != 1)
{
event_log_error (hashcat_ctx, "Separator length has to be exactly 1 byte.");
return -1;
}
}
if (user_options->slow_candidates == true) if (user_options->slow_candidates == true)
{ {
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
@ -2085,18 +2098,25 @@ void user_options_extra_init (hashcat_ctx_t *hashcat_ctx)
user_options_t *user_options = hashcat_ctx->user_options; user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
// separator
if (user_options->separator)
{
user_options_extra->separator = user_options->separator[0];
}
// attack-kern // attack-kern
user_options_extra->attack_kern = ATTACK_KERN_NONE; user_options_extra->attack_kern = ATTACK_KERN_NONE;
switch (user_options->attack_mode) switch (user_options->attack_mode)
{ {
case ATTACK_MODE_STRAIGHT: user_options_extra->attack_kern = ATTACK_KERN_STRAIGHT; break; case ATTACK_MODE_STRAIGHT: user_options_extra->attack_kern = ATTACK_KERN_STRAIGHT; break;
case ATTACK_MODE_COMBI: user_options_extra->attack_kern = ATTACK_KERN_COMBI; break; case ATTACK_MODE_COMBI: user_options_extra->attack_kern = ATTACK_KERN_COMBI; break;
case ATTACK_MODE_BF: user_options_extra->attack_kern = ATTACK_KERN_BF; break; case ATTACK_MODE_BF: user_options_extra->attack_kern = ATTACK_KERN_BF; break;
case ATTACK_MODE_HYBRID1: user_options_extra->attack_kern = ATTACK_KERN_COMBI; break; case ATTACK_MODE_HYBRID1: user_options_extra->attack_kern = ATTACK_KERN_COMBI; break;
case ATTACK_MODE_HYBRID2: user_options_extra->attack_kern = ATTACK_KERN_COMBI; break; case ATTACK_MODE_HYBRID2: user_options_extra->attack_kern = ATTACK_KERN_COMBI; break;
case ATTACK_MODE_ASSOCIATION: user_options_extra->attack_kern = ATTACK_KERN_STRAIGHT; break; case ATTACK_MODE_ASSOCIATION: user_options_extra->attack_kern = ATTACK_KERN_STRAIGHT; break;
} }
// rules // rules
@ -3027,7 +3047,6 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
user_options_t *user_options = hashcat_ctx->user_options; user_options_t *user_options = hashcat_ctx->user_options;
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
logfile_top_char (user_options->separator);
#ifdef WITH_BRAIN #ifdef WITH_BRAIN
logfile_top_string (user_options->brain_session_whitelist); logfile_top_string (user_options->brain_session_whitelist);
#endif #endif
@ -3052,6 +3071,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
logfile_top_string (user_options->rule_buf_l); logfile_top_string (user_options->rule_buf_l);
logfile_top_string (user_options->rule_buf_r); logfile_top_string (user_options->rule_buf_r);
logfile_top_string (user_options->session); logfile_top_string (user_options->session);
logfile_top_string (user_options->separator);
logfile_top_string (user_options->truecrypt_keyfiles); logfile_top_string (user_options->truecrypt_keyfiles);
logfile_top_string (user_options->veracrypt_keyfiles); logfile_top_string (user_options->veracrypt_keyfiles);
#ifdef WITH_BRAIN #ifdef WITH_BRAIN