1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-29 03:18:30 +00:00

Improve Purge rule backwards compatibility and simplify code

This commit is contained in:
Gabriele Gristina 2024-11-01 18:27:51 +01:00
parent 33092b13c3
commit caf1f6a478
7 changed files with 51 additions and 94 deletions

View File

@ -713,6 +713,18 @@ DECLSPEC int mangle_purgeclass_s (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u
return (out_len); return (out_len);
} }
DECLSPEC int mangle_purgeclass (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
{
if (p0 == 'l') return mangle_purgeclass_l (p0, p1, buf, len);
else if (p0 == 'u') return mangle_purgeclass_u (p0, p1, buf, len);
else if (p0 == 'd') return mangle_purgeclass_d (p0, p1, buf, len);
else if (p0 == 'h') return mangle_purgeclass_lh (p0, p1, buf, len);
else if (p0 == 'H') return mangle_purgeclass_uh (p0, p1, buf, len);
else if (p0 == 's') return mangle_purgeclass_s (p0, p1, buf, len);
return len;
}
DECLSPEC int mangle_dupechar_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len) DECLSPEC int mangle_dupechar_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
{ {
const int out_len = len + p0; const int out_len = len + p0;
@ -943,12 +955,7 @@ DECLSPEC int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED
case RULE_OP_MANGLE_TRUNCATE_AT: out_len = mangle_truncate_at (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break; case RULE_OP_MANGLE_TRUNCATE_AT: out_len = mangle_truncate_at (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_REPLACE: out_len = mangle_replace (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break; case RULE_OP_MANGLE_REPLACE: out_len = mangle_replace (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PURGECHAR: out_len = mangle_purgechar (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break; case RULE_OP_MANGLE_PURGECHAR: out_len = mangle_purgechar (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_L: out_len = mangle_purgeclass_l (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break; case RULE_OP_MANGLE_PURGECLASS: out_len = mangle_purgeclass (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_U: out_len = mangle_purgeclass_u (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_D: out_len = mangle_purgeclass_d (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_LH: out_len = mangle_purgeclass_lh (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_UH: out_len = mangle_purgeclass_uh (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_S: out_len = mangle_purgeclass_s (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_FIRST: out_len = mangle_dupechar_first (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break; case RULE_OP_MANGLE_DUPECHAR_FIRST: out_len = mangle_dupechar_first (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_LAST: out_len = mangle_dupechar_last (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break; case RULE_OP_MANGLE_DUPECHAR_LAST: out_len = mangle_dupechar_last (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_ALL: out_len = mangle_dupechar_all (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break; case RULE_OP_MANGLE_DUPECHAR_ALL: out_len = mangle_dupechar_all (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;

View File

@ -40,12 +40,7 @@
#define RULE_OP_MANGLE_TRUNCATE_AT '\'' #define RULE_OP_MANGLE_TRUNCATE_AT '\''
#define RULE_OP_MANGLE_REPLACE 's' #define RULE_OP_MANGLE_REPLACE 's'
#define RULE_OP_MANGLE_PURGECHAR '@' #define RULE_OP_MANGLE_PURGECHAR '@'
#define RULE_OP_MANGLE_PURGECLASS_L 0x01 #define RULE_OP_MANGLE_PURGECLASS 0x01
#define RULE_OP_MANGLE_PURGECLASS_U 0x02
#define RULE_OP_MANGLE_PURGECLASS_D 0x03
#define RULE_OP_MANGLE_PURGECLASS_LH 0x04
#define RULE_OP_MANGLE_PURGECLASS_UH 0x05
#define RULE_OP_MANGLE_PURGECLASS_S 0x06
#define RULE_OP_MANGLE_TOGGLECASE_REC 'a' #define RULE_OP_MANGLE_TOGGLECASE_REC 'a'
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z' #define RULE_OP_MANGLE_DUPECHAR_FIRST 'z'
#define RULE_OP_MANGLE_DUPECHAR_LAST 'Z' #define RULE_OP_MANGLE_DUPECHAR_LAST 'Z'
@ -109,12 +104,7 @@ DECLSPEC int mangle_overstrike (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8
DECLSPEC int mangle_truncate_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len); DECLSPEC int mangle_truncate_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_replace (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len); DECLSPEC int mangle_replace (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_purgechar (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len); DECLSPEC int mangle_purgechar (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_purgeclass_l (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len); DECLSPEC int mangle_purgeclass (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_purgeclass_u (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_purgeclass_d (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_purgeclass_lh (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_purgeclass_uh (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_purgeclass_s (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_dupechar_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len); DECLSPEC int mangle_dupechar_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_dupechar_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len); DECLSPEC int mangle_dupechar_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
DECLSPEC int mangle_dupechar_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len); DECLSPEC int mangle_dupechar_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);

View File

@ -2114,6 +2114,18 @@ DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass_s (MAYBE_UNUSED const u32 p0
return out_len; return out_len;
} }
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len)
{
if ((u8)p0 == 'l') return rule_op_mangle_purgeclass_l (p0, p1, buf0, buf1, in_len);
else if ((u8)p0 == 'u') return rule_op_mangle_purgeclass_u (p0, p1, buf0, buf1, in_len);
else if ((u8)p0 == 'd') return rule_op_mangle_purgeclass_d (p0, p1, buf0, buf1, in_len);
else if ((u8)p0 == 'h') return rule_op_mangle_purgeclass_lh (p0, p1, buf0, buf1, in_len);
else if ((u8)p0 == 'H') return rule_op_mangle_purgeclass_uh (p0, p1, buf0, buf1, in_len);
else if ((u8)p0 == 's') return rule_op_mangle_purgeclass_s (p0, p1, buf0, buf1, in_len);
return in_len;
}
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len) DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len)
{ {
if ( in_len == 0) return in_len; if ( in_len == 0) return in_len;
@ -2670,12 +2682,7 @@ DECLSPEC u32 apply_rule_optimized (const u32 name, const u32 p0, const u32 p1, P
case RULE_OP_MANGLE_TRUNCATE_AT: out_len = rule_op_mangle_truncate_at (p0, p1, buf0, buf1, out_len); break; case RULE_OP_MANGLE_TRUNCATE_AT: out_len = rule_op_mangle_truncate_at (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_REPLACE: out_len = rule_op_mangle_replace (p0, p1, buf0, buf1, out_len); break; case RULE_OP_MANGLE_REPLACE: out_len = rule_op_mangle_replace (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_PURGECHAR: out_len = rule_op_mangle_purgechar (p0, p1, buf0, buf1, out_len); break; case RULE_OP_MANGLE_PURGECHAR: out_len = rule_op_mangle_purgechar (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_L: out_len = rule_op_mangle_purgeclass_l (p0, p1, buf0, buf1, out_len); break; case RULE_OP_MANGLE_PURGECLASS: out_len = rule_op_mangle_purgeclass (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_U: out_len = rule_op_mangle_purgeclass_u (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_D: out_len = rule_op_mangle_purgeclass_d (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_LH: out_len = rule_op_mangle_purgeclass_lh (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_UH: out_len = rule_op_mangle_purgeclass_uh (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_PURGECLASS_S: out_len = rule_op_mangle_purgeclass_s (p0, p1, buf0, buf1, out_len); break;
//case RULE_OP_MANGLE_TOGGLECASE_REC: out_len = rule_op_mangle_togglecase_rec (p0, p1, buf0, buf1, out_len); break; //case RULE_OP_MANGLE_TOGGLECASE_REC: out_len = rule_op_mangle_togglecase_rec (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_FIRST: out_len = rule_op_mangle_dupechar_first (p0, p1, buf0, buf1, out_len); break; case RULE_OP_MANGLE_DUPECHAR_FIRST: out_len = rule_op_mangle_dupechar_first (p0, p1, buf0, buf1, out_len); break;
case RULE_OP_MANGLE_DUPECHAR_LAST: out_len = rule_op_mangle_dupechar_last (p0, p1, buf0, buf1, out_len); break; case RULE_OP_MANGLE_DUPECHAR_LAST: out_len = rule_op_mangle_dupechar_last (p0, p1, buf0, buf1, out_len); break;

View File

@ -46,12 +46,7 @@
#define RULE_OP_MANGLE_TRUNCATE_AT '\'' #define RULE_OP_MANGLE_TRUNCATE_AT '\''
#define RULE_OP_MANGLE_REPLACE 's' #define RULE_OP_MANGLE_REPLACE 's'
#define RULE_OP_MANGLE_PURGECHAR '@' #define RULE_OP_MANGLE_PURGECHAR '@'
#define RULE_OP_MANGLE_PURGECLASS_L 0x01 #define RULE_OP_MANGLE_PURGECLASS 0x01
#define RULE_OP_MANGLE_PURGECLASS_U 0x02
#define RULE_OP_MANGLE_PURGECLASS_D 0x03
#define RULE_OP_MANGLE_PURGECLASS_LH 0x04
#define RULE_OP_MANGLE_PURGECLASS_UH 0x05
#define RULE_OP_MANGLE_PURGECLASS_S 0x06
#define RULE_OP_MANGLE_TOGGLECASE_REC 'a' #define RULE_OP_MANGLE_TOGGLECASE_REC 'a'
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z' #define RULE_OP_MANGLE_DUPECHAR_FIRST 'z'
#define RULE_OP_MANGLE_DUPECHAR_LAST 'Z' #define RULE_OP_MANGLE_DUPECHAR_LAST 'Z'
@ -119,12 +114,7 @@ DECLSPEC u32 search_on_register (const u32 in, const u32 p0);
DECLSPEC u32 replace_on_register (const u32 in, const u32 r, const u32 p1); DECLSPEC u32 replace_on_register (const u32 in, const u32 r, const u32 p1);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_replace (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len); DECLSPEC HC_INLINE_RP u32 rule_op_mangle_replace (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgechar (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len); DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgechar (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass_l (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len); DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass_u (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass_d (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass_lh (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass_uh (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgeclass_s (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len); DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupechar_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len); DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupechar_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupechar_all (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len); DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupechar_all (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED PRIVATE_AS u32 *buf0, MAYBE_UNUSED PRIVATE_AS u32 *buf1, const u32 in_len);

View File

@ -331,12 +331,7 @@ typedef enum rule_functions
RULE_OP_MANGLE_TRUNCATE_AT = '\'', RULE_OP_MANGLE_TRUNCATE_AT = '\'',
RULE_OP_MANGLE_REPLACE = 's', RULE_OP_MANGLE_REPLACE = 's',
RULE_OP_MANGLE_PURGECHAR = '@', RULE_OP_MANGLE_PURGECHAR = '@',
RULE_OP_MANGLE_PURGECLASS_L = 0x01, RULE_OP_MANGLE_PURGECLASS = 0x01,
RULE_OP_MANGLE_PURGECLASS_U = 0x02,
RULE_OP_MANGLE_PURGECLASS_D = 0x03,
RULE_OP_MANGLE_PURGECLASS_LH = 0x04,
RULE_OP_MANGLE_PURGECLASS_UH = 0x05,
RULE_OP_MANGLE_PURGECLASS_S = 0x06,
RULE_OP_MANGLE_TOGGLECASE_REC = 'a', RULE_OP_MANGLE_TOGGLECASE_REC = 'a',
RULE_OP_MANGLE_DUPECHAR_FIRST = 'z', RULE_OP_MANGLE_DUPECHAR_FIRST = 'z',
RULE_OP_MANGLE_DUPECHAR_LAST = 'Z', RULE_OP_MANGLE_DUPECHAR_LAST = 'Z',

View File

@ -390,42 +390,28 @@ int cpu_rule_to_kernel_rule (char *rule_buf, u32 rule_len, kernel_rule_t *rule)
case RULE_OP_MANGLE_PURGECHAR: case RULE_OP_MANGLE_PURGECHAR:
if ((rule_pos + 1) < rule_len && rule_buf[rule_pos+1] == '?') if ((rule_pos + 1) < rule_len && rule_buf[rule_pos+1] == '?')
{ {
if ((rule_pos + 2) == rule_len) return -1; if ((rule_pos + 2) == rule_len)
{
SET_NAME (rule, rule_buf[rule_pos]);
SET_P0 (rule, rule_buf[rule_pos]);
break;
}
switch (rule_buf[rule_pos+2]) { switch (rule_buf[rule_pos+2]) {
case ' ':
case '?': case '?':
SET_NAME (rule, rule_buf[rule_pos]); SET_NAME (rule, rule_buf[rule_pos]);
SET_P0 (rule, rule_buf[rule_pos]); SET_P0 (rule, rule_buf[rule_pos]);
INCR_POS; INCR_POS;
break; break;
case 'l': case 'l':
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_L);
INCR_POS;
INCR_POS;
break;
case 'u': case 'u':
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_U);
INCR_POS;
INCR_POS;
break;
case 'd': case 'd':
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_D);
INCR_POS;
INCR_POS;
break;
case 'h': case 'h':
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_LH);
INCR_POS;
INCR_POS;
break;
case 'H': case 'H':
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_UH);
INCR_POS;
INCR_POS;
break;
case 's': case 's':
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_S); SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS);
INCR_POS; SET_P0 (rule, rule_buf[rule_pos+1]);
INCR_POS; INCR_POS;
break; break;
default : default :
@ -665,38 +651,13 @@ int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
case RULE_OP_MANGLE_PURGECHAR: case RULE_OP_MANGLE_PURGECHAR:
rule_buf[rule_pos] = rule_cmd; rule_buf[rule_pos] = rule_cmd;
GET_P0 (rule); GET_P0 (rule);
if (rule_buf[rule_pos] == '?') rule_buf[++rule_pos] = '?'; if (rule_buf[rule_pos] == '?') rule_buf[++rule_pos] = '?'; // force @??
break; break;
case RULE_OP_MANGLE_PURGECLASS_L: case RULE_OP_MANGLE_PURGECLASS:
rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR; rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR;
rule_buf[rule_pos++] = '?'; rule_buf[rule_pos] = '?';
rule_buf[rule_pos] = 'l'; GET_P0 (rule);
break;
case RULE_OP_MANGLE_PURGECLASS_U:
rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR;
rule_buf[rule_pos++] = '?';
rule_buf[rule_pos] = 'u';
break;
case RULE_OP_MANGLE_PURGECLASS_D:
rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR;
rule_buf[rule_pos++] = '?';
rule_buf[rule_pos] = 'd';
break;
case RULE_OP_MANGLE_PURGECLASS_LH:
rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR;
rule_buf[rule_pos++] = '?';
rule_buf[rule_pos] = 'h';
break;
case RULE_OP_MANGLE_PURGECLASS_UH:
rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR;
rule_buf[rule_pos++] = '?';
rule_buf[rule_pos] = 'H';
break;
case RULE_OP_MANGLE_PURGECLASS_S:
rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR;
rule_buf[rule_pos++] = '?';
rule_buf[rule_pos] = 's';
break; break;
case RULE_OP_MANGLE_TOGGLECASE_REC: case RULE_OP_MANGLE_TOGGLECASE_REC:

View File

@ -809,9 +809,16 @@ int _old_apply_rule (const char *rule, int rule_len, char in[RP_PASSWORD_SIZE],
NEXT_RULEPOS (rule_pos); NEXT_RULEPOS (rule_pos);
if (rule_new[rule_pos] == '?') if (rule_new[rule_pos] == '?')
{ {
if ((rule_pos + 1) == rule_len_new)
{
out_len = mangle_purgechar (out, out_len, rule_new[rule_pos]);
break;
}
NEXT_RULEPOS (rule_pos); NEXT_RULEPOS (rule_pos);
switch (rule_new[rule_pos]) switch (rule_new[rule_pos])
{ {
case ' ': out_len = mangle_purgechar (out, out_len, rule_new[rule_pos-1]); break;
case '?': out_len = mangle_purgechar (out, out_len, rule_new[rule_pos]); break; case '?': out_len = mangle_purgechar (out, out_len, rule_new[rule_pos]); break;
case 'l': out_len = mangle_purgeclass_l (out, out_len); break; case 'l': out_len = mangle_purgeclass_l (out, out_len); break;
case 'u': out_len = mangle_purgeclass_u (out, out_len); break; case 'u': out_len = mangle_purgeclass_u (out, out_len); break;