1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-27 02:18:21 +00:00

Fixing HEX wordlist support in -m 3000 see #3050

This commit is contained in:
b0lek 2021-12-11 19:38:30 +01:00 committed by GitHub
parent 8b9fa631ce
commit 8804c62d49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -97,7 +97,7 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, HCFILE *fp)
return 0; return 0;
} }
void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off) void get_next_word_lm_gen (char *buf, u64 sz, u64 *len, u64 *off, u64 cutlen)
{ {
char *ptr = buf; char *ptr = buf;
@ -105,12 +105,11 @@ void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off)
{ {
if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20; if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
if (i == 7) if (i == cutlen)
{ {
*off = i; if (cutlen == 20) buf[i-1]=']'; // add ] in $HEX[] format
*len = i; *len = i;
// but continue a loop to skip rest of the line
return;
} }
if (*ptr != '\n') continue; if (*ptr != '\n') continue;
@ -119,13 +118,54 @@ void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off)
if ((i > 0) && (buf[i - 1] == '\r')) i--; if ((i > 0) && (buf[i - 1] == '\r')) i--;
*len = i; if (i < cutlen + 1) *len = i;
return; return;
} }
*off = sz; *off = sz;
*len = sz; if (sz<cutlen) *len = sz;
}
void get_next_word_lm_hex (char *buf, u64 sz, u64 *len, u64 *off)
{
// this one is called if --hex-wordlist is uesed
// we need 14 hex-digits to get 7 characters
get_next_word_lm_gen(buf, sz, len, off, 14);
}
void get_next_word_lm_text (char *buf, u64 sz, u64 *len, u64 *off)
{
// check if not $HEX[..] format
bool hex = true;
if (sz<8) hex=false;
if (hex && (buf[0] != '$')) hex = false;
if (hex && (buf[1] != 'H')) hex = false;
if (hex && (buf[2] != 'E')) hex = false;
if (hex && (buf[3] != 'X')) hex = false;
if (hex && (buf[4] != '[')) hex = false;
if (hex){
char *ptr = buf;
for (u64 i = 0; i < sz; i++, ptr++)
{
if (*ptr == ']')
{
if ((i & 1) == 0) hex=false; // not even number of characters
else
break;
}
}
}
if (hex)
{
//$HEX[] format so we need max 14 hex-digits + 6 chars '$HEX[]'
get_next_word_lm_gen(buf, sz, len, off, 20);
}
else
{
// threat it as normal string
get_next_word_lm_gen(buf, sz, len, off, 7);
}
} }
void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off) void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off)
@ -615,7 +655,13 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->opts_type & OPTS_TYPE_PT_LM) if (hashconfig->opts_type & OPTS_TYPE_PT_LM)
{ {
wl_data->func = get_next_word_lm; if (hashconfig->opts_type & OPTS_TYPE_PT_HEX){
wl_data->func = get_next_word_lm_hex;
}
else
{
wl_data->func = get_next_word_lm_text;
}
} }
/** /**