Fixing HEX wordlist support in -m 3000 see #3050

pull/3055/head
b0lek 2 years ago committed by GitHub
parent 8b9fa631ce
commit 8804c62d49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -97,7 +97,7 @@ int load_segment (hashcat_ctx_t *hashcat_ctx, HCFILE *fp)
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;
@ -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 (i == 7)
if (i == cutlen)
{
*off = i;
if (cutlen == 20) buf[i-1]=']'; // add ] in $HEX[] format
*len = i;
return;
// but continue a loop to skip rest of the line
}
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--;
*len = i;
if (i < cutlen + 1) *len = i;
return;
}
*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)
@ -615,7 +655,13 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx)
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;
}
}
/**

Loading…
Cancel
Save