1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-22 06:28:16 +00:00

Merge pull request #4055 from flaggx1/feature_increase_custom_charsets

Increase custom charsets to 8
This commit is contained in:
hashcat-bot 2025-07-09 14:30:21 +02:00 committed by GitHub
commit 029a79fced
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 176 additions and 13 deletions

View File

@ -824,6 +824,10 @@ typedef enum user_options_map
IDX_CUSTOM_CHARSET_2 = '2',
IDX_CUSTOM_CHARSET_3 = '3',
IDX_CUSTOM_CHARSET_4 = '4',
IDX_CUSTOM_CHARSET_5 = '5',
IDX_CUSTOM_CHARSET_6 = '6',
IDX_CUSTOM_CHARSET_7 = '7',
IDX_CUSTOM_CHARSET_8 = '8',
IDX_DEBUG_FILE = 0xff12,
IDX_DEBUG_MODE = 0xff13,
IDX_DEPRECATED_CHECK_DISABLE = 0xff14,
@ -2487,7 +2491,6 @@ typedef struct user_options
char *bridge_parameter3;
char *bridge_parameter4;
char *cpu_affinity;
char *custom_charset_4;
char *debug_file;
char *induction_dir;
char *keyboard_layout_mapping;
@ -2506,6 +2509,11 @@ typedef struct user_options
const char *custom_charset_1;
const char *custom_charset_2;
const char *custom_charset_3;
const char *custom_charset_4;
const char *custom_charset_5;
const char *custom_charset_6;
const char *custom_charset_7;
const char *custom_charset_8;
const char *encoding_from;
const char *encoding_to;
const char *rule_buf_l;

View File

@ -345,6 +345,34 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx)
XXH64_update (state, custom_charset_4, strlen (custom_charset_4));
}
if (user_options->custom_charset_5)
{
const char *custom_charset_5 = user_options->custom_charset_5;
XXH64_update (state, custom_charset_5, strlen (custom_charset_5));
}
if (user_options->custom_charset_6)
{
const char *custom_charset_6 = user_options->custom_charset_6;
XXH64_update (state, custom_charset_6, strlen (custom_charset_6));
}
if (user_options->custom_charset_7)
{
const char *custom_charset_7 = user_options->custom_charset_7;
XXH64_update (state, custom_charset_7, strlen (custom_charset_7));
}
if (user_options->custom_charset_8)
{
const char *custom_charset_8 = user_options->custom_charset_8;
XXH64_update (state, custom_charset_8, strlen (custom_charset_8));
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
@ -405,6 +433,34 @@ u32 brain_compute_attack (hashcat_ctx_t *hashcat_ctx)
XXH64_update (state, custom_charset_4, strlen (custom_charset_4));
}
if (user_options->custom_charset_5)
{
const char *custom_charset_5 = user_options->custom_charset_5;
XXH64_update (state, custom_charset_5, strlen (custom_charset_5));
}
if (user_options->custom_charset_6)
{
const char *custom_charset_6 = user_options->custom_charset_6;
XXH64_update (state, custom_charset_6, strlen (custom_charset_6));
}
if (user_options->custom_charset_7)
{
const char *custom_charset_7 = user_options->custom_charset_7;
XXH64_update (state, custom_charset_7, strlen (custom_charset_7));
}
if (user_options->custom_charset_8)
{
const char *custom_charset_8 = user_options->custom_charset_8;
XXH64_update (state, custom_charset_8, strlen (custom_charset_8));
}
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 5 // 4*charset, 1*mask
#define MAX_MFS 9 // 8*charset, 1*mask
static int sp_comp_val (const void *p1, const void *p2)
{
@ -314,6 +314,18 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_
case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, mp_usr, mp_usr_offset);
break;
case '5': if (mp_usr[4].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 5 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[4].cs_buf, mp_usr[4].cs_len, mp_usr, mp_usr_offset);
break;
case '6': if (mp_usr[5].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 6 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[5].cs_buf, mp_usr[5].cs_len, mp_usr, mp_usr_offset);
break;
case '7': if (mp_usr[6].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 7 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[6].cs_buf, mp_usr[6].cs_len, mp_usr, mp_usr_offset);
break;
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 '?': 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);
@ -427,6 +439,18 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l
case '4': if (mp_usr[3].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 4 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[3].cs_buf, mp_usr[3].cs_len, css_buf, css_pos);
break;
case '5': if (mp_usr[4].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 5 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[4].cs_buf, mp_usr[4].cs_len, css_buf, css_pos);
break;
case '6': if (mp_usr[5].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 6 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[5].cs_buf, mp_usr[5].cs_len, css_buf, css_pos);
break;
case '7': if (mp_usr[6].cs_len == 0) { event_log_error (hashcat_ctx, "Custom-charset 7 is undefined."); return -1; }
rc = mp_add_cs_buf (hashcat_ctx, mp_usr[6].cs_buf, mp_usr[6].cs_len, css_buf, css_pos);
break;
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 '?': 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);
@ -1416,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 (4, 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;
@ -1443,6 +1467,10 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->custom_charset_2) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1) == -1) return -1; }
if (user_options->custom_charset_3) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2) == -1) return -1; }
if (user_options->custom_charset_4) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3) == -1) return -1; }
if (user_options->custom_charset_5) { if (mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_5, 4) == -1) return -1; }
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->benchmark == true)
{
@ -1739,6 +1767,9 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx)
mfs_buf[2].mf_len = 0;
mfs_buf[3].mf_len = 0;
mfs_buf[4].mf_len = 0;
mfs_buf[5].mf_len = 0;
mfs_buf[6].mf_len = 0;
mfs_buf[7].mf_len = 0;
size_t mfs_cnt = 0;
@ -1796,11 +1827,19 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_2 = NULL;
user_options->custom_charset_3 = NULL;
user_options->custom_charset_4 = NULL;
user_options->custom_charset_5 = NULL;
user_options->custom_charset_6 = NULL;
user_options->custom_charset_7 = NULL;
user_options->custom_charset_8 = NULL;
mp_reset_usr (mask_ctx->mp_usr, 0);
mp_reset_usr (mask_ctx->mp_usr, 1);
mp_reset_usr (mask_ctx->mp_usr, 2);
mp_reset_usr (mask_ctx->mp_usr, 3);
mp_reset_usr (mask_ctx->mp_usr, 4);
mp_reset_usr (mask_ctx->mp_usr, 5);
mp_reset_usr (mask_ctx->mp_usr, 6);
mp_reset_usr (mask_ctx->mp_usr, 7);
for (size_t i = 0; i < mfs_cnt; i++)
{
@ -1825,6 +1864,26 @@ int mask_ctx_parse_maskfile (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_4 = mfs_buf[3].mf_buf;
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3);
break;
case 4:
user_options->custom_charset_5 = mfs_buf[4].mf_buf;
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_5, 4);
break;
case 5:
user_options->custom_charset_6 = mfs_buf[5].mf_buf;
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_6, 5);
break;
case 6:
user_options->custom_charset_7 = mfs_buf[6].mf_buf;
mp_setup_usr (hashcat_ctx, mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_7, 6);
break;
case 7:
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;
}
}

View File

@ -394,6 +394,10 @@ int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx)
if (user_options->custom_charset_2) has_mask_cs = true;
if (user_options->custom_charset_3) has_mask_cs = true;
if (user_options->custom_charset_4) has_mask_cs = true;
if (user_options->custom_charset_5) has_mask_cs = true;
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->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
{
@ -778,17 +782,25 @@ char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx)
const char *custom_charset_2 = user_options->custom_charset_2;
const char *custom_charset_3 = user_options->custom_charset_3;
const char *custom_charset_4 = user_options->custom_charset_4;
const char *custom_charset_5 = user_options->custom_charset_5;
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;
if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != 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 = "Undefined";
if (custom_charset_2 == NULL) custom_charset_2 = "Undefined";
if (custom_charset_3 == NULL) custom_charset_3 = "Undefined";
if (custom_charset_4 == NULL) custom_charset_4 = "Undefined";
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", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4);
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

@ -139,6 +139,10 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] =
" -2, --custom-charset2 | CS | User-defined charset ?2 | -2 ?l?d?s",
" -3, --custom-charset3 | CS | User-defined charset ?3 |",
" -4, --custom-charset4 | CS | User-defined charset ?4 |",
" -5, --custom-charset5 | CS | User-defined charset ?5 |",
" -6, --custom-charset6 | CS | User-defined charset ?6 |",
" -7, --custom-charset7 | CS | User-defined charset ?7 |",
" -8, --custom-charset8 | CS | User-defined charset ?8 |",
" --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 = "hHVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:R:z";
static const char *const short_options = "hHVvm: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:R:z";
#else
static const char *const short_options = "hHVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:R:";
static const char *const short_options = "hHVvm: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:R:";
#endif
static char *const SEPARATOR = ":";
@ -59,6 +59,10 @@ static const struct option long_options[] =
{"custom-charset2", required_argument, NULL, IDX_CUSTOM_CHARSET_2},
{"custom-charset3", required_argument, NULL, IDX_CUSTOM_CHARSET_3},
{"custom-charset4", required_argument, NULL, IDX_CUSTOM_CHARSET_4},
{"custom-charset5", required_argument, NULL, IDX_CUSTOM_CHARSET_5},
{"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},
{"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},
@ -220,6 +224,10 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
user_options->custom_charset_2 = NULL;
user_options->custom_charset_3 = NULL;
user_options->custom_charset_4 = NULL;
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->debug_file = NULL;
user_options->debug_mode = DEBUG_MODE;
user_options->deprecated_check = DEPRECATED_CHECK;
@ -569,6 +577,10 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_CUSTOM_CHARSET_2: user_options->custom_charset_2 = optarg; break;
case IDX_CUSTOM_CHARSET_3: user_options->custom_charset_3 = optarg; break;
case IDX_CUSTOM_CHARSET_4: user_options->custom_charset_4 = optarg; break;
case IDX_CUSTOM_CHARSET_5: user_options->custom_charset_5 = optarg; break;
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_SLOW_CANDIDATES: user_options->slow_candidates = true; break;
#ifdef WITH_BRAIN
case IDX_BRAIN_CLIENT: user_options->brain_client = true; break;
@ -1428,7 +1440,11 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if ((user_options->custom_charset_1 != NULL)
|| (user_options->custom_charset_2 != NULL)
|| (user_options->custom_charset_3 != NULL)
|| (user_options->custom_charset_4 != NULL))
|| (user_options->custom_charset_4 != NULL)
|| (user_options->custom_charset_5 != NULL)
|| (user_options->custom_charset_6 != NULL)
|| (user_options->custom_charset_7 != NULL)
|| (user_options->custom_charset_8 != NULL))
{
if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) || (user_options->attack_mode == ATTACK_MODE_ASSOCIATION))
{
@ -1603,7 +1619,11 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if ((user_options->custom_charset_1 != NULL)
|| (user_options->custom_charset_2 != NULL)
|| (user_options->custom_charset_3 != NULL)
|| (user_options->custom_charset_4 != NULL))
|| (user_options->custom_charset_4 != NULL)
|| (user_options->custom_charset_5 != NULL)
|| (user_options->custom_charset_6 != NULL)
|| (user_options->custom_charset_7 != NULL)
|| (user_options->custom_charset_8 != NULL))
{
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
@ -3366,6 +3386,10 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
logfile_top_string (user_options->custom_charset_2);
logfile_top_string (user_options->custom_charset_3);
logfile_top_string (user_options->custom_charset_4);
logfile_top_string (user_options->custom_charset_5);
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->debug_file);
logfile_top_string (user_options->encoding_from);
logfile_top_string (user_options->encoding_to);