mirror of
https://github.com/hashcat/hashcat.git
synced 2024-12-23 07:08:19 +00:00
code style and formatting fixes in wordlist.c
This commit is contained in:
parent
60cf7fdccd
commit
e870f1a03b
@ -107,8 +107,10 @@ void get_next_word_lm_gen (char *buf, u64 sz, u64 *len, u64 *off, u64 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;
|
||||
|
||||
// but continue a loop to skip rest of the line
|
||||
}
|
||||
|
||||
@ -124,57 +126,67 @@ void get_next_word_lm_gen (char *buf, u64 sz, u64 *len, u64 *off, u64 cutlen)
|
||||
}
|
||||
|
||||
*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)
|
||||
{
|
||||
// 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
|
||||
// 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++)
|
||||
{
|
||||
if ((i & 1) == 0)
|
||||
{
|
||||
if (is_valid_hex_char(buf[i]))
|
||||
if (is_valid_hex_char(buf[i+1]))
|
||||
{
|
||||
if (buf[i] == '6')
|
||||
if (buf[i+1] > '0')
|
||||
buf[i] = '4';
|
||||
if (buf[i] == '7')
|
||||
if (buf[i+1] < 'B')
|
||||
buf[i] = '5';
|
||||
}
|
||||
if (is_valid_hex_char (buf[i]))
|
||||
if (is_valid_hex_char (buf[i + 1]))
|
||||
{
|
||||
if (buf[i] == '6')
|
||||
if (buf[i+1] > '0')
|
||||
buf[i] = '4';
|
||||
if (buf[i] == '7')
|
||||
if (buf[i+1] < 'B')
|
||||
buf[i] = '5';
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 12) break; // stop when 7 chars are converted
|
||||
}
|
||||
|
||||
// call generic next_word
|
||||
get_next_word_lm_gen(buf, sz, len, off, 14);
|
||||
|
||||
get_next_word_lm_gen (buf, sz, len, off, 14);
|
||||
}
|
||||
|
||||
void get_next_word_lm_hex_or_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+5; // starting after '['
|
||||
|
||||
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 + 5; // starting after '['
|
||||
|
||||
for (u64 i = 5; i < sz; i++, ptr++)
|
||||
{
|
||||
if (*ptr == ']')
|
||||
{
|
||||
if ((i & 1) == 0) hex=false; // not even number of characters
|
||||
if ((i & 1) == 0) hex = false; // not even number of characters
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_valid_hex_char(*ptr) == false)
|
||||
if (is_valid_hex_char (*ptr) == false)
|
||||
{
|
||||
hex = false;
|
||||
break;
|
||||
@ -182,13 +194,13 @@ void get_next_word_lm_hex_or_text (char *buf, u64 sz, u64 *len, u64 *off)
|
||||
// upcase character if it is a letter 'a-z'
|
||||
if ((i & 1) == 1) // if first hex-char
|
||||
{
|
||||
if (is_valid_hex_char(buf[i+1]))
|
||||
if (is_valid_hex_char (buf[i + 1]))
|
||||
{
|
||||
if (buf[i] == '6')
|
||||
if (buf[i+1] > '0')
|
||||
if (buf[i + 1] > '0')
|
||||
buf[i] = '4';
|
||||
if (buf[i] == '7')
|
||||
if (buf[i+1] < 'B')
|
||||
if (buf[i + 1] < 'B')
|
||||
buf[i] = '5';
|
||||
}
|
||||
}
|
||||
@ -198,18 +210,18 @@ void get_next_word_lm_hex_or_text (char *buf, u64 sz, u64 *len, u64 *off)
|
||||
if (hex)
|
||||
{
|
||||
//$HEX[] format so we need max 14 hex-digits + 6 chars '$HEX[]'
|
||||
get_next_word_lm_gen(buf, sz, len, off, 20);
|
||||
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);
|
||||
get_next_word_lm_gen (buf, sz, len, off, 7);
|
||||
}
|
||||
}
|
||||
|
||||
void get_next_word_lm_text (char *buf, u64 sz, u64 *len, u64 *off)
|
||||
{
|
||||
get_next_word_lm_gen(buf, sz, len, off, 7);
|
||||
get_next_word_lm_gen (buf, sz, len, off, 7);
|
||||
}
|
||||
|
||||
void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off)
|
||||
@ -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_HEX){
|
||||
if (hashconfig->opts_type & OPTS_TYPE_PT_HEX)
|
||||
{
|
||||
wl_data->func = get_next_word_lm_hex; // all hex in file
|
||||
}
|
||||
else
|
||||
@ -707,7 +720,9 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx)
|
||||
if (user_options->wordlist_autohex_disable == false)
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user