code style and formatting fixes in wordlist.c

pull/3193/head
philsmd 2 years ago committed by GitHub
parent 60cf7fdccd
commit e870f1a03b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -108,7 +108,9 @@ void get_next_word_lm_gen (char *buf, u64 sz, u64 *len, u64 *off, u64 cutlen)
if (i == cutlen) if (i == cutlen)
{ {
if (cutlen == 20) buf[i - 1]= ']'; // add ] in $HEX[] format if (cutlen == 20) buf[i - 1]= ']'; // add ] in $HEX[] format
*len = i; *len = i;
// but continue a loop to skip rest of the line // but continue a loop to skip rest of the line
} }
@ -124,14 +126,16 @@ void get_next_word_lm_gen (char *buf, u64 sz, u64 *len, u64 *off, u64 cutlen)
} }
*off = sz; *off = sz;
if (sz < cutlen) *len = sz; if (sz < cutlen) *len = sz;
} }
void get_next_word_lm_hex (char *buf, u64 sz, u64 *len, u64 *off) void get_next_word_lm_hex (char *buf, u64 sz, u64 *len, u64 *off)
{ {
// this one is called if --hex-wordlist is uesed // this one is called if --hex-wordlist is used
// we need 14 hex-digits to get 7 characters // we need 14 hex-digits to get 7 characters
// but first convert 7 chars to upper case if thay are a-z // but first convert 7 chars to upper case if they are a-z
for (u64 i = 5; i < sz; i++) for (u64 i = 5; i < sz; i++)
{ {
if ((i & 1) == 0) if ((i & 1) == 0)
@ -147,9 +151,12 @@ void get_next_word_lm_hex (char *buf, u64 sz, u64 *len, u64 *off)
buf[i] = '5'; buf[i] = '5';
} }
} }
if (i == 12) break; // stop when 7 chars are converted if (i == 12) break; // stop when 7 chars are converted
} }
// call generic next_word // call generic next_word
get_next_word_lm_gen (buf, sz, len, off, 14); get_next_word_lm_gen (buf, sz, len, off, 14);
} }
@ -157,14 +164,19 @@ void get_next_word_lm_hex_or_text (char *buf, u64 sz, u64 *len, u64 *off)
{ {
// check if not $HEX[..] format // check if not $HEX[..] format
bool hex = true; bool hex = true;
if (sz < 8) hex = false; if (sz < 8) hex = false;
if (hex && (buf[0] != '$')) hex = false; if (hex && (buf[0] != '$')) hex = false;
if (hex && (buf[1] != 'H')) hex = false; if (hex && (buf[1] != 'H')) hex = false;
if (hex && (buf[2] != 'E')) hex = false; if (hex && (buf[2] != 'E')) hex = false;
if (hex && (buf[3] != 'X')) hex = false; if (hex && (buf[3] != 'X')) hex = false;
if (hex && (buf[4] != '[')) hex = false; if (hex && (buf[4] != '[')) hex = false;
if (hex){
if (hex)
{
char *ptr = buf + 5; // starting after '[' char *ptr = buf + 5; // starting after '['
for (u64 i = 5; i < sz; i++, ptr++) for (u64 i = 5; i < sz; i++, ptr++)
{ {
if (*ptr == ']') if (*ptr == ']')
@ -699,7 +711,8 @@ 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)
{ {
if (hashconfig->opts_type & OPTS_TYPE_PT_HEX){ if (hashconfig->opts_type & OPTS_TYPE_PT_HEX)
{
wl_data->func = get_next_word_lm_hex; // all hex in file wl_data->func = get_next_word_lm_hex; // all hex in file
} }
else else
@ -707,7 +720,9 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->wordlist_autohex_disable == false) if (user_options->wordlist_autohex_disable == false)
{ {
wl_data->func = get_next_word_lm_hex_or_text; // might be $HEX[] notation wl_data->func = get_next_word_lm_hex_or_text; // might be $HEX[] notation
}else{ }
else
{
wl_data->func = get_next_word_lm_text; // treat as nromal text wl_data->func = get_next_word_lm_text; // treat as nromal text
} }
} }

Loading…
Cancel
Save