mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-29 03:18:30 +00:00
Extended the Purge (@) rule operation to support Classes, Fixed d3ad0ne.rule to support the new Purge (@) rule handling
This commit is contained in:
parent
6716447dfc
commit
33092b13c3
176
OpenCL/inc_rp.cl
176
OpenCL/inc_rp.cl
@ -28,6 +28,50 @@
|
|||||||
#define PASTE_PW pw;
|
#define PASTE_PW pw;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CONSTANT_AS u8 s_lookup[128] =
|
||||||
|
{
|
||||||
|
[0 ... 31] = 0, // control characters
|
||||||
|
[32] = 1, // whitespace
|
||||||
|
[33 ... 47] = 1, // from '!' to '/'
|
||||||
|
[48 ... 57] = 0, // digits
|
||||||
|
[58 ... 64] = 1, // from ':' to '@'
|
||||||
|
[65 ... 90] = 0, // uppercase
|
||||||
|
[91 ... 96] = 1, // from '[' to '`'
|
||||||
|
[97 ... 122] = 0, // lowercase
|
||||||
|
[123 ... 126] = 1, // from '{' to '~'
|
||||||
|
[127] = 0 // del
|
||||||
|
};
|
||||||
|
|
||||||
|
HC_INLINE bool is_l (u8 c)
|
||||||
|
{
|
||||||
|
return (c >= 'a' && c <= 'z');
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_u (u8 c)
|
||||||
|
{
|
||||||
|
return (c >= 'A' && c <= 'Z');
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_d (u8 c)
|
||||||
|
{
|
||||||
|
return (c >= '0' && c <= '9');
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_lh (u8 c)
|
||||||
|
{
|
||||||
|
return (is_d (c) || (c >= 'a' && c <= 'f'));
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_uh (u8 c)
|
||||||
|
{
|
||||||
|
return (is_d (c) || (c >= 'A' && c <= 'F'));
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_s (u8 c)
|
||||||
|
{
|
||||||
|
return s_lookup[c] == 1;
|
||||||
|
}
|
||||||
|
|
||||||
DECLSPEC u32 generate_cmask (const u32 value)
|
DECLSPEC u32 generate_cmask (const u32 value)
|
||||||
{
|
{
|
||||||
const u32 rmask = ((value & 0x40404040u) >> 1u)
|
const u32 rmask = ((value & 0x40404040u) >> 1u)
|
||||||
@ -543,6 +587,132 @@ DECLSPEC int mangle_purgechar (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p
|
|||||||
return (out_len);
|
return (out_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DECLSPEC int mangle_purgeclass_l (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||||
|
{
|
||||||
|
int out_len = 0;
|
||||||
|
|
||||||
|
for (int pos = 0; pos < len; pos++)
|
||||||
|
{
|
||||||
|
if (is_l (buf[pos])) continue;
|
||||||
|
|
||||||
|
buf[out_len] = buf[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int pos = out_len; pos < len; pos++)
|
||||||
|
{
|
||||||
|
buf[pos] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (out_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLSPEC int mangle_purgeclass_u (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||||
|
{
|
||||||
|
int out_len = 0;
|
||||||
|
|
||||||
|
for (int pos = 0; pos < len; pos++)
|
||||||
|
{
|
||||||
|
if (is_u (buf[pos])) continue;
|
||||||
|
|
||||||
|
buf[out_len] = buf[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int pos = out_len; pos < len; pos++)
|
||||||
|
{
|
||||||
|
buf[pos] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (out_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLSPEC int mangle_purgeclass_d (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||||
|
{
|
||||||
|
int out_len = 0;
|
||||||
|
|
||||||
|
for (int pos = 0; pos < len; pos++)
|
||||||
|
{
|
||||||
|
if (is_d (buf[pos])) continue;
|
||||||
|
|
||||||
|
buf[out_len] = buf[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int pos = out_len; pos < len; pos++)
|
||||||
|
{
|
||||||
|
buf[pos] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (out_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLSPEC int mangle_purgeclass_lh (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||||
|
{
|
||||||
|
int out_len = 0;
|
||||||
|
|
||||||
|
for (int pos = 0; pos < len; pos++)
|
||||||
|
{
|
||||||
|
if (is_lh (buf[pos])) continue;
|
||||||
|
|
||||||
|
buf[out_len] = buf[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int pos = out_len; pos < len; pos++)
|
||||||
|
{
|
||||||
|
buf[pos] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (out_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLSPEC int mangle_purgeclass_uh (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||||
|
{
|
||||||
|
int out_len = 0;
|
||||||
|
|
||||||
|
for (int pos = 0; pos < len; pos++)
|
||||||
|
{
|
||||||
|
if (is_uh (buf[pos])) continue;
|
||||||
|
|
||||||
|
buf[out_len] = buf[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int pos = out_len; pos < len; pos++)
|
||||||
|
{
|
||||||
|
buf[pos] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (out_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
DECLSPEC int mangle_purgeclass_s (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||||
|
{
|
||||||
|
int out_len = 0;
|
||||||
|
|
||||||
|
for (int pos = 0; pos < len; pos++)
|
||||||
|
{
|
||||||
|
if (is_s (buf[pos])) continue;
|
||||||
|
|
||||||
|
buf[out_len] = buf[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int pos = out_len; pos < len; pos++)
|
||||||
|
{
|
||||||
|
buf[pos] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (out_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;
|
||||||
@ -773,6 +943,12 @@ 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_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;
|
||||||
|
@ -40,6 +40,12 @@
|
|||||||
#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_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'
|
||||||
@ -103,6 +109,12 @@ 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_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);
|
||||||
|
@ -13,6 +13,50 @@
|
|||||||
#define MAYBE_UNUSED
|
#define MAYBE_UNUSED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CONSTANT_AS u8 s_lookup_optimized[128] =
|
||||||
|
{
|
||||||
|
[0 ... 31] = 0, // control characters
|
||||||
|
[32] = 1, // whitespace
|
||||||
|
[33 ... 47] = 1, // from '!' to '/'
|
||||||
|
[48 ... 57] = 0, // digits
|
||||||
|
[58 ... 64] = 1, // from ':' to '@'
|
||||||
|
[65 ... 90] = 0, // uppercase
|
||||||
|
[91 ... 96] = 1, // from '[' to '`'
|
||||||
|
[97 ... 122] = 0, // lowercase
|
||||||
|
[123 ... 126] = 1, // from '{' to '~'
|
||||||
|
[127] = 0 // del
|
||||||
|
};
|
||||||
|
|
||||||
|
HC_INLINE bool is_l (u8 c)
|
||||||
|
{
|
||||||
|
return (c >= 'a' && c <= 'z');
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_u (u8 c)
|
||||||
|
{
|
||||||
|
return (c >= 'A' && c <= 'Z');
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_d (u8 c)
|
||||||
|
{
|
||||||
|
return (c >= '0' && c <= '9');
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_lh (u8 c)
|
||||||
|
{
|
||||||
|
return (is_d (c) || (c >= 'a' && c <= 'f'));
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_uh (u8 c)
|
||||||
|
{
|
||||||
|
return (is_d (c) || (c >= 'A' && c <= 'F'));
|
||||||
|
}
|
||||||
|
|
||||||
|
HC_INLINE bool is_s (u8 c)
|
||||||
|
{
|
||||||
|
return s_lookup_optimized[c] == 1;
|
||||||
|
}
|
||||||
|
|
||||||
DECLSPEC u32 generate_cmask_optimized (const u32 value)
|
DECLSPEC u32 generate_cmask_optimized (const u32 value)
|
||||||
{
|
{
|
||||||
const u32 rmask = ((value & 0x40404040u) >> 1u)
|
const u32 rmask = ((value & 0x40404040u) >> 1u)
|
||||||
@ -1824,6 +1868,252 @@ DECLSPEC HC_INLINE_RP u32 rule_op_mangle_purgechar (MAYBE_UNUSED const u32 p0, M
|
|||||||
return out_len;
|
return out_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)
|
||||||
|
{
|
||||||
|
u32 out_len = 0;
|
||||||
|
|
||||||
|
u32 buf_in[8];
|
||||||
|
|
||||||
|
buf_in[0] = buf0[0];
|
||||||
|
buf_in[1] = buf0[1];
|
||||||
|
buf_in[2] = buf0[2];
|
||||||
|
buf_in[3] = buf0[3];
|
||||||
|
buf_in[4] = buf1[0];
|
||||||
|
buf_in[5] = buf1[1];
|
||||||
|
buf_in[6] = buf1[2];
|
||||||
|
buf_in[7] = buf1[3];
|
||||||
|
|
||||||
|
u32 buf_out[8] = { 0 };
|
||||||
|
|
||||||
|
PRIVATE_AS u8 *in = (PRIVATE_AS u8 *) buf_in;
|
||||||
|
PRIVATE_AS u8 *out = (PRIVATE_AS u8 *) buf_out;
|
||||||
|
|
||||||
|
for (u32 pos = 0; pos < in_len; pos++)
|
||||||
|
{
|
||||||
|
if (is_l (in[pos])) continue;
|
||||||
|
|
||||||
|
out[out_len] = in[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf0[0] = buf_out[0];
|
||||||
|
buf0[1] = buf_out[1];
|
||||||
|
buf0[2] = buf_out[2];
|
||||||
|
buf0[3] = buf_out[3];
|
||||||
|
buf1[0] = buf_out[4];
|
||||||
|
buf1[1] = buf_out[5];
|
||||||
|
buf1[2] = buf_out[6];
|
||||||
|
buf1[3] = buf_out[7];
|
||||||
|
|
||||||
|
return out_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)
|
||||||
|
{
|
||||||
|
u32 out_len = 0;
|
||||||
|
|
||||||
|
u32 buf_in[8];
|
||||||
|
|
||||||
|
buf_in[0] = buf0[0];
|
||||||
|
buf_in[1] = buf0[1];
|
||||||
|
buf_in[2] = buf0[2];
|
||||||
|
buf_in[3] = buf0[3];
|
||||||
|
buf_in[4] = buf1[0];
|
||||||
|
buf_in[5] = buf1[1];
|
||||||
|
buf_in[6] = buf1[2];
|
||||||
|
buf_in[7] = buf1[3];
|
||||||
|
|
||||||
|
u32 buf_out[8] = { 0 };
|
||||||
|
|
||||||
|
PRIVATE_AS u8 *in = (PRIVATE_AS u8 *) buf_in;
|
||||||
|
PRIVATE_AS u8 *out = (PRIVATE_AS u8 *) buf_out;
|
||||||
|
|
||||||
|
for (u32 pos = 0; pos < in_len; pos++)
|
||||||
|
{
|
||||||
|
if (is_u (in[pos])) continue;
|
||||||
|
|
||||||
|
out[out_len] = in[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf0[0] = buf_out[0];
|
||||||
|
buf0[1] = buf_out[1];
|
||||||
|
buf0[2] = buf_out[2];
|
||||||
|
buf0[3] = buf_out[3];
|
||||||
|
buf1[0] = buf_out[4];
|
||||||
|
buf1[1] = buf_out[5];
|
||||||
|
buf1[2] = buf_out[6];
|
||||||
|
buf1[3] = buf_out[7];
|
||||||
|
|
||||||
|
return out_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)
|
||||||
|
{
|
||||||
|
u32 out_len = 0;
|
||||||
|
|
||||||
|
u32 buf_in[8];
|
||||||
|
|
||||||
|
buf_in[0] = buf0[0];
|
||||||
|
buf_in[1] = buf0[1];
|
||||||
|
buf_in[2] = buf0[2];
|
||||||
|
buf_in[3] = buf0[3];
|
||||||
|
buf_in[4] = buf1[0];
|
||||||
|
buf_in[5] = buf1[1];
|
||||||
|
buf_in[6] = buf1[2];
|
||||||
|
buf_in[7] = buf1[3];
|
||||||
|
|
||||||
|
u32 buf_out[8] = { 0 };
|
||||||
|
|
||||||
|
PRIVATE_AS u8 *in = (PRIVATE_AS u8 *) buf_in;
|
||||||
|
PRIVATE_AS u8 *out = (PRIVATE_AS u8 *) buf_out;
|
||||||
|
|
||||||
|
for (u32 pos = 0; pos < in_len; pos++)
|
||||||
|
{
|
||||||
|
if (is_d (in[pos])) continue;
|
||||||
|
|
||||||
|
out[out_len] = in[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf0[0] = buf_out[0];
|
||||||
|
buf0[1] = buf_out[1];
|
||||||
|
buf0[2] = buf_out[2];
|
||||||
|
buf0[3] = buf_out[3];
|
||||||
|
buf1[0] = buf_out[4];
|
||||||
|
buf1[1] = buf_out[5];
|
||||||
|
buf1[2] = buf_out[6];
|
||||||
|
buf1[3] = buf_out[7];
|
||||||
|
|
||||||
|
return out_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)
|
||||||
|
{
|
||||||
|
u32 out_len = 0;
|
||||||
|
|
||||||
|
u32 buf_in[8];
|
||||||
|
|
||||||
|
buf_in[0] = buf0[0];
|
||||||
|
buf_in[1] = buf0[1];
|
||||||
|
buf_in[2] = buf0[2];
|
||||||
|
buf_in[3] = buf0[3];
|
||||||
|
buf_in[4] = buf1[0];
|
||||||
|
buf_in[5] = buf1[1];
|
||||||
|
buf_in[6] = buf1[2];
|
||||||
|
buf_in[7] = buf1[3];
|
||||||
|
|
||||||
|
u32 buf_out[8] = { 0 };
|
||||||
|
|
||||||
|
PRIVATE_AS u8 *in = (PRIVATE_AS u8 *) buf_in;
|
||||||
|
PRIVATE_AS u8 *out = (PRIVATE_AS u8 *) buf_out;
|
||||||
|
|
||||||
|
for (u32 pos = 0; pos < in_len; pos++)
|
||||||
|
{
|
||||||
|
if (is_lh (in[pos])) continue;
|
||||||
|
|
||||||
|
out[out_len] = in[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf0[0] = buf_out[0];
|
||||||
|
buf0[1] = buf_out[1];
|
||||||
|
buf0[2] = buf_out[2];
|
||||||
|
buf0[3] = buf_out[3];
|
||||||
|
buf1[0] = buf_out[4];
|
||||||
|
buf1[1] = buf_out[5];
|
||||||
|
buf1[2] = buf_out[6];
|
||||||
|
buf1[3] = buf_out[7];
|
||||||
|
|
||||||
|
return out_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)
|
||||||
|
{
|
||||||
|
u32 out_len = 0;
|
||||||
|
|
||||||
|
u32 buf_in[8];
|
||||||
|
|
||||||
|
buf_in[0] = buf0[0];
|
||||||
|
buf_in[1] = buf0[1];
|
||||||
|
buf_in[2] = buf0[2];
|
||||||
|
buf_in[3] = buf0[3];
|
||||||
|
buf_in[4] = buf1[0];
|
||||||
|
buf_in[5] = buf1[1];
|
||||||
|
buf_in[6] = buf1[2];
|
||||||
|
buf_in[7] = buf1[3];
|
||||||
|
|
||||||
|
u32 buf_out[8] = { 0 };
|
||||||
|
|
||||||
|
PRIVATE_AS u8 *in = (PRIVATE_AS u8 *) buf_in;
|
||||||
|
PRIVATE_AS u8 *out = (PRIVATE_AS u8 *) buf_out;
|
||||||
|
|
||||||
|
for (u32 pos = 0; pos < in_len; pos++)
|
||||||
|
{
|
||||||
|
if (is_uh (in[pos])) continue;
|
||||||
|
|
||||||
|
out[out_len] = in[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf0[0] = buf_out[0];
|
||||||
|
buf0[1] = buf_out[1];
|
||||||
|
buf0[2] = buf_out[2];
|
||||||
|
buf0[3] = buf_out[3];
|
||||||
|
buf1[0] = buf_out[4];
|
||||||
|
buf1[1] = buf_out[5];
|
||||||
|
buf1[2] = buf_out[6];
|
||||||
|
buf1[3] = buf_out[7];
|
||||||
|
|
||||||
|
return out_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)
|
||||||
|
{
|
||||||
|
u32 out_len = 0;
|
||||||
|
|
||||||
|
u32 buf_in[8];
|
||||||
|
|
||||||
|
buf_in[0] = buf0[0];
|
||||||
|
buf_in[1] = buf0[1];
|
||||||
|
buf_in[2] = buf0[2];
|
||||||
|
buf_in[3] = buf0[3];
|
||||||
|
buf_in[4] = buf1[0];
|
||||||
|
buf_in[5] = buf1[1];
|
||||||
|
buf_in[6] = buf1[2];
|
||||||
|
buf_in[7] = buf1[3];
|
||||||
|
|
||||||
|
u32 buf_out[8] = { 0 };
|
||||||
|
|
||||||
|
PRIVATE_AS u8 *in = (PRIVATE_AS u8 *) buf_in;
|
||||||
|
PRIVATE_AS u8 *out = (PRIVATE_AS u8 *) buf_out;
|
||||||
|
|
||||||
|
for (u32 pos = 0; pos < in_len; pos++)
|
||||||
|
{
|
||||||
|
if (is_s (in[pos])) continue;
|
||||||
|
|
||||||
|
out[out_len] = in[pos];
|
||||||
|
|
||||||
|
out_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf0[0] = buf_out[0];
|
||||||
|
buf0[1] = buf_out[1];
|
||||||
|
buf0[2] = buf_out[2];
|
||||||
|
buf0[3] = buf_out[3];
|
||||||
|
buf1[0] = buf_out[4];
|
||||||
|
buf1[1] = buf_out[5];
|
||||||
|
buf1[2] = buf_out[6];
|
||||||
|
buf1[3] = buf_out[7];
|
||||||
|
|
||||||
|
return out_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;
|
||||||
@ -2380,6 +2670,12 @@ 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_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;
|
||||||
|
@ -46,6 +46,12 @@
|
|||||||
#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_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'
|
||||||
@ -113,6 +119,12 @@ 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_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);
|
||||||
|
@ -133,6 +133,8 @@
|
|||||||
- Hardware Monitor: avoid sprintf in src/ext_iokit.c
|
- Hardware Monitor: avoid sprintf in src/ext_iokit.c
|
||||||
- Help: show supported hash-modes only with -hh
|
- Help: show supported hash-modes only with -hh
|
||||||
- Makefile: prevent make failure with Apple Silicon in case of partial rebuild
|
- Makefile: prevent make failure with Apple Silicon in case of partial rebuild
|
||||||
|
- Rules: Extended the Purge (@) rule operation to support Classes
|
||||||
|
- Rules: Fixed d3ad0ne.rule to support the new Purge (@) rule handling
|
||||||
- Rules: Rename best64.rule to best66.rule and remove the unknown section from it
|
- Rules: Rename best64.rule to best66.rule and remove the unknown section from it
|
||||||
|
|
||||||
* changes v6.2.5 -> v6.2.6
|
* changes v6.2.5 -> v6.2.6
|
||||||
|
@ -25,6 +25,7 @@ Gabriele "matrix" Gristina <matrix@hashcat.net> (@gm4tr1x)
|
|||||||
* Apple macOS port
|
* Apple macOS port
|
||||||
* Apple Silicon support
|
* Apple Silicon support
|
||||||
* Universal binary on Apple Silicon
|
* Universal binary on Apple Silicon
|
||||||
|
* Extended the Purge (@) rule operation to support Classes
|
||||||
* Hardware monitor initial code base and maintenance
|
* Hardware monitor initial code base and maintenance
|
||||||
* Test suite initial code base and maintenance
|
* Test suite initial code base and maintenance
|
||||||
* Makefile initial code base
|
* Makefile initial code base
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#define RULE_OP_MANGLE_OVERSTRIKE 'o' // overwrite with char X at pos N
|
#define RULE_OP_MANGLE_OVERSTRIKE 'o' // overwrite with char X at pos N
|
||||||
#define RULE_OP_MANGLE_TRUNCATE_AT '\''// cut the word at pos N
|
#define RULE_OP_MANGLE_TRUNCATE_AT '\''// cut the word at pos N
|
||||||
#define RULE_OP_MANGLE_REPLACE 's' // replace all chars X with char Y
|
#define RULE_OP_MANGLE_REPLACE 's' // replace all chars X with char Y
|
||||||
#define RULE_OP_MANGLE_PURGECHAR '@' // purge all instances of char X
|
#define RULE_OP_MANGLE_PURGECHAR '@' // purge all instances of char X (@X) or purge all instances of chars in class X (@?X)
|
||||||
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z' // prepend first char of word to itself N times. ex: hello -> hhhello
|
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z' // prepend first char of word to itself N times. ex: hello -> hhhello
|
||||||
#define RULE_OP_MANGLE_DUPECHAR_LAST 'Z' // append last char of word to itself N times. ex: hello -> hellooo
|
#define RULE_OP_MANGLE_DUPECHAR_LAST 'Z' // append last char of word to itself N times. ex: hello -> hellooo
|
||||||
#define RULE_OP_MANGLE_DUPECHAR_ALL 'q' // duplicate all chars. ex: hello -> hheelllloo
|
#define RULE_OP_MANGLE_DUPECHAR_ALL 'q' // duplicate all chars. ex: hello -> hheelllloo
|
||||||
|
@ -46,6 +46,9 @@ typedef struct
|
|||||||
bool class_num (const u8 c);
|
bool class_num (const u8 c);
|
||||||
bool class_lower (const u8 c);
|
bool class_lower (const u8 c);
|
||||||
bool class_upper (const u8 c);
|
bool class_upper (const u8 c);
|
||||||
|
bool class_lower_hex (const u8 c);
|
||||||
|
bool class_upper_hex (const u8 c);
|
||||||
|
bool class_sym (const u8 c);
|
||||||
bool class_alpha (const u8 c);
|
bool class_alpha (const u8 c);
|
||||||
|
|
||||||
int conv_ctoi (const u8 c);
|
int conv_ctoi (const u8 c);
|
||||||
|
@ -331,6 +331,12 @@ 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_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',
|
||||||
|
@ -5823,7 +5823,7 @@ O05 o28
|
|||||||
*74 O6B
|
*74 O6B
|
||||||
*75 $5
|
*75 $5
|
||||||
*75 $m
|
*75 $m
|
||||||
*75 @? '7
|
*75 @?? '7
|
||||||
*75 D1
|
*75 D1
|
||||||
*75 D4
|
*75 D4
|
||||||
*75 D6
|
*75 D6
|
||||||
|
93
src/rp.c
93
src/rp.c
@ -106,6 +106,21 @@ bool class_upper (const u8 c)
|
|||||||
return ((c >= 'A') && (c <= 'Z'));
|
return ((c >= 'A') && (c <= 'Z'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool class_lower_hex (const u8 c)
|
||||||
|
{
|
||||||
|
return ((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f'));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool class_upper_hex (const u8 c)
|
||||||
|
{
|
||||||
|
return ((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool class_sym (const u8 c)
|
||||||
|
{
|
||||||
|
return ((c == ' ') || ((c >= '!') && (c <= '/')) || ((c >= ':') && (c <= '@')) || ((c >= '[') && (c <= '`')) || ((c >= '{') && (c <= '~')));
|
||||||
|
}
|
||||||
|
|
||||||
bool class_alpha (const u8 c)
|
bool class_alpha (const u8 c)
|
||||||
{
|
{
|
||||||
return (class_lower (c) || class_upper (c));
|
return (class_lower (c) || class_upper (c));
|
||||||
@ -373,6 +388,52 @@ int cpu_rule_to_kernel_rule (char *rule_buf, u32 rule_len, kernel_rule_t *rule)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RULE_OP_MANGLE_PURGECHAR:
|
case RULE_OP_MANGLE_PURGECHAR:
|
||||||
|
if ((rule_pos + 1) < rule_len && rule_buf[rule_pos+1] == '?')
|
||||||
|
{
|
||||||
|
if ((rule_pos + 2) == rule_len) return -1;
|
||||||
|
|
||||||
|
switch (rule_buf[rule_pos+2]) {
|
||||||
|
case '?':
|
||||||
|
SET_NAME (rule, rule_buf[rule_pos]);
|
||||||
|
SET_P0 (rule, rule_buf[rule_pos]);
|
||||||
|
INCR_POS;
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_L);
|
||||||
|
INCR_POS;
|
||||||
|
INCR_POS;
|
||||||
|
break;
|
||||||
|
case 'u':
|
||||||
|
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_U);
|
||||||
|
INCR_POS;
|
||||||
|
INCR_POS;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_D);
|
||||||
|
INCR_POS;
|
||||||
|
INCR_POS;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_LH);
|
||||||
|
INCR_POS;
|
||||||
|
INCR_POS;
|
||||||
|
break;
|
||||||
|
case 'H':
|
||||||
|
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_UH);
|
||||||
|
INCR_POS;
|
||||||
|
INCR_POS;
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
SET_NAME (rule, RULE_OP_MANGLE_PURGECLASS_S);
|
||||||
|
INCR_POS;
|
||||||
|
INCR_POS;
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
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]);
|
||||||
break;
|
break;
|
||||||
@ -604,6 +665,38 @@ 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] = '?';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RULE_OP_MANGLE_PURGECLASS_L:
|
||||||
|
rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR;
|
||||||
|
rule_buf[rule_pos++] = '?';
|
||||||
|
rule_buf[rule_pos] = 'l';
|
||||||
|
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:
|
||||||
|
127
src/rp_cpu.c
127
src/rp_cpu.c
@ -347,6 +347,114 @@ static int mangle_purgechar (char arr[RP_PASSWORD_SIZE], int arr_len, char c)
|
|||||||
return (ret_len);
|
return (ret_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mangle_purgeclass_l (char arr[RP_PASSWORD_SIZE], int arr_len)
|
||||||
|
{
|
||||||
|
int arr_pos;
|
||||||
|
|
||||||
|
int ret_len;
|
||||||
|
|
||||||
|
for (ret_len = 0, arr_pos = 0; arr_pos < arr_len; arr_pos++)
|
||||||
|
{
|
||||||
|
if (class_lower (arr[arr_pos])) continue;
|
||||||
|
|
||||||
|
arr[ret_len] = arr[arr_pos];
|
||||||
|
|
||||||
|
ret_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mangle_purgeclass_u (char arr[RP_PASSWORD_SIZE], int arr_len)
|
||||||
|
{
|
||||||
|
int arr_pos;
|
||||||
|
|
||||||
|
int ret_len;
|
||||||
|
|
||||||
|
for (ret_len = 0, arr_pos = 0; arr_pos < arr_len; arr_pos++)
|
||||||
|
{
|
||||||
|
if (class_upper (arr[arr_pos])) continue;
|
||||||
|
|
||||||
|
arr[ret_len] = arr[arr_pos];
|
||||||
|
|
||||||
|
ret_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mangle_purgeclass_d (char arr[RP_PASSWORD_SIZE], int arr_len)
|
||||||
|
{
|
||||||
|
int arr_pos;
|
||||||
|
|
||||||
|
int ret_len;
|
||||||
|
|
||||||
|
for (ret_len = 0, arr_pos = 0; arr_pos < arr_len; arr_pos++)
|
||||||
|
{
|
||||||
|
if (class_num (arr[arr_pos])) continue;
|
||||||
|
|
||||||
|
arr[ret_len] = arr[arr_pos];
|
||||||
|
|
||||||
|
ret_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mangle_purgeclass_lh (char arr[RP_PASSWORD_SIZE], int arr_len)
|
||||||
|
{
|
||||||
|
int arr_pos;
|
||||||
|
|
||||||
|
int ret_len;
|
||||||
|
|
||||||
|
for (ret_len = 0, arr_pos = 0; arr_pos < arr_len; arr_pos++)
|
||||||
|
{
|
||||||
|
if (class_lower_hex (arr[arr_pos])) continue;
|
||||||
|
|
||||||
|
arr[ret_len] = arr[arr_pos];
|
||||||
|
|
||||||
|
ret_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mangle_purgeclass_uh (char arr[RP_PASSWORD_SIZE], int arr_len)
|
||||||
|
{
|
||||||
|
int arr_pos;
|
||||||
|
|
||||||
|
int ret_len;
|
||||||
|
|
||||||
|
for (ret_len = 0, arr_pos = 0; arr_pos < arr_len; arr_pos++)
|
||||||
|
{
|
||||||
|
if (class_upper_hex (arr[arr_pos])) continue;
|
||||||
|
|
||||||
|
arr[ret_len] = arr[arr_pos];
|
||||||
|
|
||||||
|
ret_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mangle_purgeclass_s (char arr[RP_PASSWORD_SIZE], int arr_len)
|
||||||
|
{
|
||||||
|
int arr_pos;
|
||||||
|
|
||||||
|
int ret_len;
|
||||||
|
|
||||||
|
for (ret_len = 0, arr_pos = 0; arr_pos < arr_len; arr_pos++)
|
||||||
|
{
|
||||||
|
if (class_sym (arr[arr_pos])) continue;
|
||||||
|
|
||||||
|
arr[ret_len] = arr[arr_pos];
|
||||||
|
|
||||||
|
ret_len++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ret_len);
|
||||||
|
}
|
||||||
|
|
||||||
static int mangle_dupeblock_prepend (char arr[RP_PASSWORD_SIZE], int arr_len, int ulen)
|
static int mangle_dupeblock_prepend (char arr[RP_PASSWORD_SIZE], int arr_len, int ulen)
|
||||||
{
|
{
|
||||||
if (ulen > arr_len) return (arr_len);
|
if (ulen > arr_len) return (arr_len);
|
||||||
@ -699,6 +807,23 @@ int _old_apply_rule (const char *rule, int rule_len, char in[RP_PASSWORD_SIZE],
|
|||||||
|
|
||||||
case RULE_OP_MANGLE_PURGECHAR:
|
case RULE_OP_MANGLE_PURGECHAR:
|
||||||
NEXT_RULEPOS (rule_pos);
|
NEXT_RULEPOS (rule_pos);
|
||||||
|
if (rule_new[rule_pos] == '?')
|
||||||
|
{
|
||||||
|
NEXT_RULEPOS (rule_pos);
|
||||||
|
switch (rule_new[rule_pos])
|
||||||
|
{
|
||||||
|
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 'u': out_len = mangle_purgeclass_u (out, out_len); break;
|
||||||
|
case 'd': out_len = mangle_purgeclass_d (out, out_len); break;
|
||||||
|
case 'h': out_len = mangle_purgeclass_lh (out, out_len); break;
|
||||||
|
case 'H': out_len = mangle_purgeclass_uh (out, out_len); break;
|
||||||
|
case 's': out_len = mangle_purgeclass_s (out, out_len); break;
|
||||||
|
default : return (RULE_RC_SYNTAX_ERROR);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
out_len = mangle_purgechar (out, out_len, rule_new[rule_pos]);
|
out_len = mangle_purgechar (out, out_len, rule_new[rule_pos]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -921,7 +1046,9 @@ int run_rule_engine (const int rule_len, const char *rule_buf)
|
|||||||
if (rule_len == 0) return 0;
|
if (rule_len == 0) return 0;
|
||||||
|
|
||||||
if (rule_len == 1)
|
if (rule_len == 1)
|
||||||
|
{
|
||||||
if (rule_buf[0] == RULE_OP_MANGLE_NOOP) return 0;
|
if (rule_buf[0] == RULE_OP_MANGLE_NOOP) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user