1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-25 09:28:20 +00:00

Reduce user-defined charsets to 8. Remove unnecessary code.

This commit is contained in:
Flaggx1 2024-07-25 07:07:27 -04:00
parent 7d75520343
commit d299b2833e
6 changed files with 16 additions and 77 deletions

View File

@ -759,7 +759,6 @@ typedef enum user_options_map
IDX_CUSTOM_CHARSET_6 = '6',
IDX_CUSTOM_CHARSET_7 = '7',
IDX_CUSTOM_CHARSET_8 = '8',
IDX_CUSTOM_CHARSET_9 = '9',
IDX_DEBUG_FILE = 0xff12,
IDX_DEBUG_MODE = 0xff13,
IDX_DEPRECATED_CHECK_DISABLE = 0xff14,
@ -2396,7 +2395,6 @@ typedef struct user_options
char *brain_session_whitelist;
#endif
char *cpu_affinity;
char *custom_charset_9;
char *debug_file;
char *induction_dir;
char *keyboard_layout_mapping;

View File

@ -373,13 +373,6 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx)
XXH64_update (state, custom_charset_8, strlen (custom_charset_8));
}
if (user_options->custom_charset_9)
{
const char *custom_charset_9 = user_options->custom_charset_9;
XXH64_update (state, custom_charset_9, strlen (custom_charset_9));
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
@ -469,13 +462,6 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx)
XXH64_update (state, custom_charset_8, strlen (custom_charset_8));
}
if (user_options->custom_charset_9)
{
const char *custom_charset_9 = user_options->custom_charset_9;
XXH64_update (state, custom_charset_9, strlen (custom_charset_9));
}
const int hex_wordlist = user_options->hex_wordlist;
XXH64_update (state, &hex_wordlist, sizeof (hex_wordlist));

View File

@ -18,7 +18,7 @@
static const char *const DEF_MASK = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d";
#define MAX_MFS 10 // 9*charset, 1*mask
#define MAX_MFS 9 // 8*charset, 1*mask
static int sp_comp_val (const void *p1, const void *p2)
{
@ -326,9 +326,6 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_
case '8': if (mp_usr[7].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 8 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[7].cs_buf, mp_usr[7].cs_len, mp_usr, mp_usr_offset);
break;
case '9': if (mp_usr[8].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 9 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[8].cs_buf, mp_usr[8].cs_len, mp_usr, mp_usr_offset);
break;
case '?': rc = mp_add_cs_buf (hashcat_ctx, &p0, 1, mp_usr, mp_usr_offset);
break;
default: event_log_error (hashcat_ctx, "Syntax error in mask: %s", in_buf);
@ -454,9 +451,6 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l
case '8': if (mp_usr[7].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 8 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[7].cs_buf, mp_usr[7].cs_len, css_buf, css_pos);
break;
case '9': if (mp_usr[8].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 9 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[8].cs_buf, mp_usr[8].cs_len, css_buf, css_pos);
break;
case '?': rc = mp_add_cs_buf (hashcat_ctx, &chr, 1, css_buf, css_pos);
break;
default: event_log_error (hashcat_ctx, "Syntax error in mask: %s", mask_buf);
@ -1446,7 +1440,7 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
mask_ctx->enabled = true;
mask_ctx->mp_sys = (cs_t *) hccalloc (8, sizeof (cs_t));
mask_ctx->mp_usr = (cs_t *) hccalloc (9, sizeof (cs_t));
mask_ctx->mp_usr = (cs_t *) hccalloc (8, sizeof (cs_t));
mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t));
mask_ctx->css_cnt = 0;
@ -1477,7 +1471,6 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->custom_charset_6) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_6, 5) == -1) return -1; }
if (user_options->custom_charset_7) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_7, 6) == -1) return -1; }
if (user_options->custom_charset_8) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_8, 7) == -1) return -1; }
if (user_options->custom_charset_9) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_9, 8) == -1) return -1; }
if (user_options->benchmark == true)
{
@ -1777,7 +1770,6 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx)
mfs_buf[5].mf_len = 0;
mfs_buf[6].mf_len = 0;
mfs_buf[7].mf_len = 0;
mfs_buf[8].mf_len = 0;
size_t mfs_cnt = 0;
@ -1839,7 +1831,6 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_6 = NULL;
user_options->custom_charset_7 = NULL;
user_options->custom_charset_8 = NULL;
user_options->custom_charset_9 = NULL;
mp_reset_usr (mask_ctx->mp_usr, 0);
mp_reset_usr (mask_ctx->mp_usr, 1);
@ -1849,7 +1840,6 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx)
mp_reset_usr (mask_ctx->mp_usr, 5);
mp_reset_usr (mask_ctx->mp_usr, 6);
mp_reset_usr (mask_ctx->mp_usr, 7);
mp_reset_usr (mask_ctx->mp_usr, 8);
for (size_t i = 0; i < mfs_cnt; i++)
{
@ -1894,11 +1884,6 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_8 = mfs_buf[7].mf_buf;
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_8, 7);
break;
case 8:
user_options->custom_charset_9 = mfs_buf[8].mf_buf;
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_9, 8);
break;
}
}

View File

@ -398,7 +398,6 @@ int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx)
if (user_options->custom_charset_6) has_mask_cs = true;
if (user_options->custom_charset_7) has_mask_cs = true;
if (user_options->custom_charset_8) has_mask_cs = true;
if (user_options->custom_charset_9) has_mask_cs = true;
if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
{
@ -787,23 +786,21 @@ char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx)
const char *custom_charset_6 = user_options->custom_charset_6;
const char *custom_charset_7 = user_options->custom_charset_7;
const char *custom_charset_8 = user_options->custom_charset_8;
const char *custom_charset_9 = user_options->custom_charset_9;
if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL) || (custom_charset_5 != NULL) || (custom_charset_6 != NULL) || (custom_charset_7 != NULL) || (custom_charset_8 != NULL) || (custom_charset_9 != NULL))
if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL) || (custom_charset_5 != NULL) || (custom_charset_6 != NULL) || (custom_charset_7 != NULL) || (custom_charset_8 != NULL));
{
char *tmp_buf;
if (custom_charset_1 == NULL) custom_charset_1 = "Undef";
if (custom_charset_2 == NULL) custom_charset_2 = "Undef";
if (custom_charset_3 == NULL) custom_charset_3 = "Undef";
if (custom_charset_4 == NULL) custom_charset_4 = "Undef";
if (custom_charset_5 == NULL) custom_charset_5 = "Undef";
if (custom_charset_6 == NULL) custom_charset_6 = "Undef";
if (custom_charset_7 == NULL) custom_charset_7 = "Undef";
if (custom_charset_8 == NULL) custom_charset_8 = "Undef";
if (custom_charset_9 == NULL) custom_charset_9 = "Undef";
if (custom_charset_1 == NULL) custom_charset_1 = "N/A";
if (custom_charset_2 == NULL) custom_charset_2 = "N/A";
if (custom_charset_3 == NULL) custom_charset_3 = "N/A";
if (custom_charset_4 == NULL) custom_charset_4 = "N/A";
if (custom_charset_5 == NULL) custom_charset_5 = "N/A";
if (custom_charset_6 == NULL) custom_charset_6 = "N/A";
if (custom_charset_7 == NULL) custom_charset_7 = "N/A";
if (custom_charset_8 == NULL) custom_charset_8 = "N/A";
hc_asprintf (&tmp_buf, "-1 %s, -2 %s, -3 %s, -4 %s, -5 %s, -6 %s, -7 %s, -8 %s, -9 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4, custom_charset_5, custom_charset_6, custom_charset_7, custom_charset_8, custom_charset_9);
hc_asprintf (&tmp_buf, "-1 %s, -2 %s, -3 %s, -4 %s, -5 %s, -6 %s, -7 %s, -8 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4, custom_charset_5, custom_charset_6, custom_charset_7, custom_charset_8);
return tmp_buf;
}

View File

@ -134,7 +134,6 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] =
" -6, --custom-charset6 | CS | User-defined charset ?6 |",
" -7, --custom-charset7 | CS | User-defined charset ?7 |",
" -8, --custom-charset8 | CS | User-defined charset ?8 |",
" -9, --custom-charset9 | CS | User-defined charset ?9 |",
" --identify | | Shows all supported algorithms for input hashes | --identify my.hash",
" -i, --increment | | Enable mask increment mode |",
" --increment-min | Num | Start mask incrementing at X | --increment-min=4",

View File

@ -21,9 +21,9 @@
#endif
#ifdef WITH_BRAIN
static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:9:iIbw:OMSY:z";
static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:iIbw:OMSY:z";
#else
static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:9:iIbw:OMSY:";
static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:5:6:7:8:iIbw:OMSY:";
#endif
static char *const SEPARATOR = ":";
@ -55,7 +55,6 @@ static const struct option long_options[] =
{"custom-charset6", required_argument, NULL, IDX_CUSTOM_CHARSET_6},
{"custom-charset7", required_argument, NULL, IDX_CUSTOM_CHARSET_7},
{"custom-charset8", required_argument, NULL, IDX_CUSTOM_CHARSET_8},
{"custom-charset9", required_argument, NULL, IDX_CUSTOM_CHARSET_9},
{"debug-file", required_argument, NULL, IDX_DEBUG_FILE},
{"debug-mode", required_argument, NULL, IDX_DEBUG_MODE},
{"deprecated-check-disable", no_argument, NULL, IDX_DEPRECATED_CHECK_DISABLE},
@ -171,11 +170,6 @@ static const char *const RULE_BUF_L = ":";
static const char *const DEF_MASK_CS_1 = "?l?d?u";
static const char *const DEF_MASK_CS_2 = "?l?d";
static const char *const DEF_MASK_CS_3 = "?l?d*!$@_";
static const char *const DEF_MASK_CS_4 = "a";
static const char *const DEF_MASK_CS_5 = "b";
static const char *const DEF_MASK_CS_6 = "c";
static const char *const DEF_MASK_CS_7 = "d";
static const char *const DEF_MASK_CS_8 = "e";
int user_options_init (hashcat_ctx_t *hashcat_ctx)
{
@ -217,7 +211,6 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_6 = NULL;
user_options->custom_charset_7 = NULL;
user_options->custom_charset_8 = NULL;
user_options->custom_charset_9 = NULL;
user_options->debug_file = NULL;
user_options->debug_mode = DEBUG_MODE;
user_options->deprecated_check = DEPRECATED_CHECK;
@ -551,7 +544,6 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_CUSTOM_CHARSET_6: user_options->custom_charset_6 = optarg; break;
case IDX_CUSTOM_CHARSET_7: user_options->custom_charset_7 = optarg; break;
case IDX_CUSTOM_CHARSET_8: user_options->custom_charset_8 = optarg; break;
case IDX_CUSTOM_CHARSET_9: user_options->custom_charset_9 = optarg; break;
case IDX_SLOW_CANDIDATES: user_options->slow_candidates = true; break;
#ifdef WITH_BRAIN
case IDX_BRAIN_CLIENT: user_options->brain_client = true; break;
@ -1353,8 +1345,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
|| (user_options->custom_charset_5 != NULL)
|| (user_options->custom_charset_6 != NULL)
|| (user_options->custom_charset_7 != NULL)
|| (user_options->custom_charset_8 != NULL)
|| (user_options->custom_charset_9 != NULL))
|| (user_options->custom_charset_8 != NULL))
{
if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
{
@ -1526,8 +1517,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
|| (user_options->custom_charset_5 != NULL)
|| (user_options->custom_charset_6 != NULL)
|| (user_options->custom_charset_7 != NULL)
|| (user_options->custom_charset_8 != NULL)
|| (user_options->custom_charset_9 != NULL))
|| (user_options->custom_charset_8 != NULL))
{
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
@ -2071,11 +2061,6 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_1 = DEF_MASK_CS_1;
user_options->custom_charset_2 = DEF_MASK_CS_2;
user_options->custom_charset_3 = DEF_MASK_CS_3;
user_options->custom_charset_4 = DEF_MASK_CS_4;
user_options->custom_charset_5 = DEF_MASK_CS_5;
user_options->custom_charset_6 = DEF_MASK_CS_6;
user_options->custom_charset_7 = DEF_MASK_CS_7;
user_options->custom_charset_8 = DEF_MASK_CS_8;
user_options->increment = true;
}
@ -2087,11 +2072,6 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_1 = DEF_MASK_CS_1;
user_options->custom_charset_2 = DEF_MASK_CS_2;
user_options->custom_charset_3 = DEF_MASK_CS_3;
user_options->custom_charset_4 = DEF_MASK_CS_4;
user_options->custom_charset_5 = DEF_MASK_CS_5;
user_options->custom_charset_6 = DEF_MASK_CS_6;
user_options->custom_charset_7 = DEF_MASK_CS_7;
user_options->custom_charset_8 = DEF_MASK_CS_8;
user_options->increment = true;
}
@ -2103,11 +2083,6 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_1 = DEF_MASK_CS_1;
user_options->custom_charset_2 = DEF_MASK_CS_2;
user_options->custom_charset_3 = DEF_MASK_CS_3;
user_options->custom_charset_4 = DEF_MASK_CS_4;
user_options->custom_charset_5 = DEF_MASK_CS_5;
user_options->custom_charset_6 = DEF_MASK_CS_6;
user_options->custom_charset_7 = DEF_MASK_CS_7;
user_options->custom_charset_8 = DEF_MASK_CS_8;
user_options->increment = true;
}
@ -3248,7 +3223,6 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
logfile_top_string (user_options->custom_charset_6);
logfile_top_string (user_options->custom_charset_7);
logfile_top_string (user_options->custom_charset_8);
logfile_top_string (user_options->custom_charset_9);
logfile_top_string (user_options->debug_file);
logfile_top_string (user_options->encoding_from);
logfile_top_string (user_options->encoding_to);