mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-29 18:08:46 +00:00
enum-ify --increment and --increment-inverse
This commit is contained in:
parent
ce86bfac17
commit
3db7f01dfa
@ -887,6 +887,12 @@ typedef void * hc_dynlib_t;
|
||||
typedef void * hc_dynfunc_t;
|
||||
#endif
|
||||
|
||||
typedef enum increment {
|
||||
INCREMENT_NONE,
|
||||
INCREMENT_NORMAL,
|
||||
INCREMENT_INVERSED,
|
||||
} increment_t;
|
||||
|
||||
/**
|
||||
* structs
|
||||
*/
|
||||
@ -2350,8 +2356,7 @@ typedef struct user_options
|
||||
bool hex_charset;
|
||||
bool hex_salt;
|
||||
bool hex_wordlist;
|
||||
bool increment;
|
||||
bool increment_inverse;
|
||||
increment_t increment;
|
||||
bool keep_guessing;
|
||||
bool keyspace;
|
||||
bool left;
|
||||
|
@ -1114,7 +1114,7 @@ static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask, const char
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->increment == true)
|
||||
if (user_options->increment != INCREMENT_NONE)
|
||||
{
|
||||
const u32 mask_length = mp_get_length (mask, hashconfig->opts_type);
|
||||
|
||||
@ -1145,7 +1145,7 @@ static int mask_append (hashcat_ctx_t *hashcat_ctx, const char *mask, const char
|
||||
mask_truncated_next += snprintf (mask_truncated, 256, "%s,", prepend);
|
||||
}
|
||||
|
||||
if (user_options->increment_inverse == true)
|
||||
if (user_options->increment == INCREMENT_INVERSED)
|
||||
{
|
||||
if (mp_get_truncated_mask (hashcat_ctx, reverseMask (mask, ""), strlen (mask), increment_len, mask_truncated_next) == -1)
|
||||
{
|
||||
|
@ -222,7 +222,6 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
|
||||
user_options->hook_threads = HOOK_THREADS;
|
||||
user_options->identify = IDENTIFY;
|
||||
user_options->increment = INCREMENT;
|
||||
user_options->increment = INCREMENT_INVERSE;
|
||||
user_options->increment_max = INCREMENT_MAX;
|
||||
user_options->increment_min = INCREMENT_MIN;
|
||||
user_options->induction_dir = NULL;
|
||||
@ -526,7 +525,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
|
||||
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_INCREMENT: increment_parse(hashcat_ctx); break;
|
||||
case IDX_INCREMENT_INVERSE: user_options->increment_inverse = true; break;
|
||||
case IDX_INCREMENT_INVERSE: user_options->increment = INCREMENT_INVERSED; break;
|
||||
case IDX_INCREMENT_MIN: user_options->increment_min = hc_strtoul (optarg, NULL, 10);
|
||||
user_options->increment_min_chgd = true; break;
|
||||
case IDX_INCREMENT_MAX: user_options->increment_max = hc_strtoul (optarg, NULL, 10);
|
||||
@ -875,28 +874,28 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((user_options->increment == true) && (user_options->progress_only == true))
|
||||
if ((user_options->increment != INCREMENT_NONE) && (user_options->progress_only == true))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Increment is not allowed in combination with --progress-only.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((user_options->increment == true) && (user_options->speed_only == true))
|
||||
if ((user_options->increment != INCREMENT_NONE) && (user_options->speed_only == true))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Increment is not allowed in combination with --speed-only.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT))
|
||||
if ((user_options->increment != INCREMENT_NONE) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Increment is not allowed in attack mode 0 (straight).");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
|
||||
if ((user_options->increment != INCREMENT_NONE) && (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Increment is not allowed in attack mode 9 (association).");
|
||||
|
||||
@ -910,14 +909,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((user_options->increment == false) && (user_options->increment_min_chgd == true))
|
||||
if ((user_options->increment == INCREMENT_NONE) && (user_options->increment_min_chgd == true))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Increment-min is only supported when combined with -i/--increment.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((user_options->increment == false) && (user_options->increment_max_chgd == true))
|
||||
if ((user_options->increment == INCREMENT_NONE) && (user_options->increment_max_chgd == true))
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Increment-max is only supported combined with -i/--increment.");
|
||||
|
||||
@ -1301,14 +1300,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (user_options->increment == true)
|
||||
if (user_options->increment == INCREMENT_NORMAL)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Can't change --increment (-i) in benchmark mode.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (user_options->increment_inverse == true)
|
||||
if (user_options->increment == INCREMENT_INVERSED)
|
||||
{
|
||||
event_log_error (hashcat_ctx, "Can't change --increment-inverse in benchmark mode.");
|
||||
|
||||
@ -1892,8 +1891,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
user_options->attack_mode = ATTACK_MODE_BF;
|
||||
user_options->hwmon_temp_abort = 0;
|
||||
user_options->increment = false;
|
||||
user_options->increment_inverse = false;
|
||||
user_options->increment = INCREMENT_NONE;
|
||||
user_options->left = false;
|
||||
user_options->logfile = false;
|
||||
user_options->spin_damp = 0;
|
||||
@ -2053,7 +2051,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
|
||||
user_options->custom_charset_2 = DEF_MASK_CS_2;
|
||||
user_options->custom_charset_3 = DEF_MASK_CS_3;
|
||||
|
||||
user_options->increment = true;
|
||||
user_options->increment = INCREMENT_NORMAL;
|
||||
}
|
||||
}
|
||||
else if (user_options->stdout_flag == true)
|
||||
@ -2064,7 +2062,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
|
||||
user_options->custom_charset_2 = DEF_MASK_CS_2;
|
||||
user_options->custom_charset_3 = DEF_MASK_CS_3;
|
||||
|
||||
user_options->increment = true;
|
||||
user_options->increment = INCREMENT_NORMAL;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2075,7 +2073,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
|
||||
user_options->custom_charset_2 = DEF_MASK_CS_2;
|
||||
user_options->custom_charset_3 = DEF_MASK_CS_3;
|
||||
|
||||
user_options->increment = true;
|
||||
user_options->increment = INCREMENT_NORMAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3202,13 +3200,13 @@ void increment_parse (hashcat_ctx_t *hashcat_ctx)
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
// Set increment inverse when -ii
|
||||
if (user_options->increment == true)
|
||||
if (user_options->increment == INCREMENT_NORMAL)
|
||||
{
|
||||
user_options->increment_inverse = true;
|
||||
user_options->increment = INCREMENT_INVERSED;
|
||||
}
|
||||
else
|
||||
{
|
||||
user_options->increment = true;
|
||||
user_options->increment = INCREMENT_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3269,7 +3267,6 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
|
||||
logfile_top_uint (user_options->hook_threads);
|
||||
logfile_top_uint (user_options->identify);
|
||||
logfile_top_uint (user_options->increment);
|
||||
logfile_top_uint (user_options->increment_inverse);
|
||||
logfile_top_uint (user_options->increment_max);
|
||||
logfile_top_uint (user_options->increment_min);
|
||||
logfile_top_uint (user_options->keep_guessing);
|
||||
|
Loading…
Reference in New Issue
Block a user