mirror of
https://github.com/hashcat/hashcat
synced 2024-12-23 14:13:43 +01:00
Fix broken hex notation
This commit is contained in:
parent
88ebca40b8
commit
9d43111730
@ -26,7 +26,7 @@ int conv_itoc (const u8 c);
|
||||
|
||||
int generate_random_rule (char rule_buf[RP_RULE_SIZE], const u32 rp_gen_func_min, const u32 rp_gen_func_max);
|
||||
|
||||
bool is_hex_notation (char *rule_buf, u32 rule_len, u32 rule_pos);
|
||||
bool is_hex_notation (const char *rule_buf, u32 rule_len, u32 rule_pos);
|
||||
|
||||
int cpu_rule_to_kernel_rule (char *rule_buf, u32 rule_len, kernel_rule_t *rule);
|
||||
int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule);
|
||||
|
6
src/rp.c
6
src/rp.c
@ -218,8 +218,8 @@ int generate_random_rule (char rule_buf[RP_RULE_SIZE], const u32 rp_gen_func_min
|
||||
#define INCR_POS if (++rule_pos == rule_len) return (-1)
|
||||
|
||||
#define SET_NAME(rule,val) (rule)->cmds[rule_cnt] = ((val) & 0xff) << 0
|
||||
#define SET_P0(rule,val) INCR_POS; if (is_hex_notation (rule_buf, rule_len, rule_pos) == true) { (rule)->cmds[rule_cnt] |= (hex_convert (rule_buf[rule_pos + 3] & 0xff) << 8) | (hex_convert (rule_buf[rule_pos + 2] & 0xff) << 12); rule_pos += 4; } else { (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 8; }
|
||||
#define SET_P1(rule,val) INCR_POS; if (is_hex_notation (rule_buf, rule_len, rule_pos) == true) { (rule)->cmds[rule_cnt] |= (hex_convert (rule_buf[rule_pos + 3] & 0xff) << 16) | (hex_convert (rule_buf[rule_pos + 2] & 0xff) << 20); rule_pos += 4; } else { (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 16; }
|
||||
#define SET_P0(rule,val) INCR_POS; if (is_hex_notation (rule_buf, rule_len, rule_pos) == true) { (rule)->cmds[rule_cnt] |= (hex_convert (rule_buf[rule_pos + 3] & 0xff) << 8) | (hex_convert (rule_buf[rule_pos + 2] & 0xff) << 12); rule_pos += 3; } else { (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 8; }
|
||||
#define SET_P1(rule,val) INCR_POS; if (is_hex_notation (rule_buf, rule_len, rule_pos) == true) { (rule)->cmds[rule_cnt] |= (hex_convert (rule_buf[rule_pos + 3] & 0xff) << 16) | (hex_convert (rule_buf[rule_pos + 2] & 0xff) << 20); rule_pos += 3; } else { (rule)->cmds[rule_cnt] |= ((val) & 0xff) << 16; }
|
||||
#define GET_NAME(rule) rule_cmd = (((rule)->cmds[rule_cnt] >> 0) & 0xff)
|
||||
#define GET_P0(rule) INCR_POS; rule_buf[rule_pos] = (((rule)->cmds[rule_cnt] >> 8) & 0xff)
|
||||
#define GET_P1(rule) INCR_POS; rule_buf[rule_pos] = (((rule)->cmds[rule_cnt] >> 16) & 0xff)
|
||||
@ -229,7 +229,7 @@ int generate_random_rule (char rule_buf[RP_RULE_SIZE], const u32 rp_gen_func_min
|
||||
#define GET_P0_CONV(rule) INCR_POS; rule_buf[rule_pos] = (char) conv_itoc (((rule)->cmds[rule_cnt] >> 8) & 0xff)
|
||||
#define GET_P1_CONV(rule) INCR_POS; rule_buf[rule_pos] = (char) conv_itoc (((rule)->cmds[rule_cnt] >> 16) & 0xff)
|
||||
|
||||
bool is_hex_notation (char *rule_buf, u32 rule_len, u32 rule_pos)
|
||||
bool is_hex_notation (const char *rule_buf, u32 rule_len, u32 rule_pos)
|
||||
{
|
||||
if ((rule_pos + 4) > rule_len) return false;
|
||||
|
||||
|
24
src/rp_cpu.c
24
src/rp_cpu.c
@ -492,25 +492,33 @@ int _old_apply_rule (const char *rule, int rule_len, char in[RP_PASSWORD_SIZE],
|
||||
|
||||
memcpy (out, in, out_len);
|
||||
|
||||
char *rule_new = hcstrdup (rule);
|
||||
char *rule_new = (char *) hcmalloc (rule_len);
|
||||
|
||||
int rule_len_new = 0;
|
||||
|
||||
int rule_pos;
|
||||
|
||||
for (rule_pos = 0; rule_pos < rule_len; rule_pos++)
|
||||
{
|
||||
if (is_hex_notation (rule_new, rule_len, rule_pos))
|
||||
if (is_hex_notation (rule, rule_len, rule_pos))
|
||||
{
|
||||
const u8 c = hex_to_u8 ((u8 *)rule_new + rule_pos + 2);
|
||||
const u8 c = hex_to_u8 (&rule[rule_pos + 2]);
|
||||
|
||||
rule_new[rule_pos + 0] = c;
|
||||
rule_new[rule_pos + 1] = ' ';
|
||||
rule_new[rule_pos + 2] = ' ';
|
||||
rule_new[rule_pos + 3] = ' ';
|
||||
rule_pos += 3;
|
||||
|
||||
rule_new[rule_len_new] = c;
|
||||
|
||||
rule_len_new++;
|
||||
}
|
||||
else
|
||||
{
|
||||
rule_new[rule_len_new] = rule[rule_pos];
|
||||
|
||||
rule_len_new++;
|
||||
}
|
||||
}
|
||||
|
||||
for (rule_pos = 0; rule_pos < rule_len; rule_pos++)
|
||||
for (rule_pos = 0; rule_pos < rule_len_new; rule_pos++)
|
||||
{
|
||||
int upos, upos2;
|
||||
int ulen;
|
||||
|
Loading…
Reference in New Issue
Block a user