mirror of
https://github.com/hashcat/hashcat.git
synced 2025-08-02 03:48:16 +00:00
Merge pull request #4107 from matrix/rule_purgeclass
Add support to character class rules
This commit is contained in:
commit
483c59e3ee
556
OpenCL/inc_rp.cl
556
OpenCL/inc_rp.cl
@ -7,7 +7,9 @@
|
||||
#include "inc_types.h"
|
||||
#include "inc_platform.h"
|
||||
#include "inc_common.h"
|
||||
|
||||
#include "inc_rp.h"
|
||||
#include "inc_rp_common.cl"
|
||||
|
||||
#ifndef MAYBE_UNUSED
|
||||
#define MAYBE_UNUSED
|
||||
@ -28,17 +30,6 @@
|
||||
#define PASTE_PW pw;
|
||||
#endif
|
||||
|
||||
DECLSPEC u32 generate_cmask (const u32 value)
|
||||
{
|
||||
const u32 rmask = ((value & 0x40404040u) >> 1u)
|
||||
& ~((value & 0x80808080u) >> 2u);
|
||||
|
||||
const u32 hmask = (value & 0x1f1f1f1fu) + 0x05050505u;
|
||||
const u32 lmask = (value & 0x1f1f1f1fu) + 0x1f1f1f1fu;
|
||||
|
||||
return rmask & ~hmask & lmask;
|
||||
}
|
||||
|
||||
DECLSPEC void append_four_byte (PRIVATE_AS const u32 *buf_src, const int off_src, PRIVATE_AS u32 *buf_dst, const int off_dst)
|
||||
{
|
||||
const int sd = off_src / 4;
|
||||
@ -194,7 +185,7 @@ DECLSPEC int mangle_lrest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, P
|
||||
buf[idx] = t | generate_cmask (t);
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_lrest_ufirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
@ -210,7 +201,7 @@ DECLSPEC int mangle_lrest_ufirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u
|
||||
|
||||
buf[0] = t & ~(0x00000020 & generate_cmask (t));
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_urest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
@ -222,7 +213,7 @@ DECLSPEC int mangle_urest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, P
|
||||
buf[idx] = t & ~(generate_cmask (t));
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_urest_lfirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
@ -238,7 +229,7 @@ DECLSPEC int mangle_urest_lfirst (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u
|
||||
|
||||
buf[0] = t | (0x00000020 & generate_cmask (t));
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_trest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
@ -250,12 +241,12 @@ DECLSPEC int mangle_trest (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, P
|
||||
buf[idx] = t ^ generate_cmask (t);
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_toggle_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
const u8 p0d = p0 / 4;
|
||||
const u8 p0m = p0 & 3;
|
||||
@ -266,12 +257,12 @@ DECLSPEC int mangle_toggle_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p
|
||||
|
||||
buf[p0d] = t ^ (generate_cmask (t) & tmp);
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_toggle_at_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
u8 occurence = 0;
|
||||
|
||||
@ -295,7 +286,7 @@ DECLSPEC int mangle_toggle_at_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const
|
||||
buf[idx] = t ^ (generate_cmask (t) & out);
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_reverse (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
@ -307,25 +298,25 @@ DECLSPEC int mangle_reverse (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1,
|
||||
exchange_byte (buf, l, r);
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_dupeword (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
const int out_len = len * 2;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
append_block (buf, 0, buf, len, len);
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_dupeword_times (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
const int out_len = (len * p0) + len;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
int out_pos = len;
|
||||
|
||||
@ -339,14 +330,14 @@ DECLSPEC int mangle_dupeword_times (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const
|
||||
}
|
||||
}
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_reflect (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
const int out_len = len * 2;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
append_block (buf, 0, buf, len, len);
|
||||
|
||||
@ -364,18 +355,18 @@ DECLSPEC int mangle_append (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1,
|
||||
{
|
||||
const int out_len = len + 1;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
buf[len] = p0;
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_prepend (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
const int out_len = len + 1;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
for (int pos = len - 1; pos >= 0; pos--)
|
||||
{
|
||||
@ -384,7 +375,7 @@ DECLSPEC int mangle_prepend (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1,
|
||||
|
||||
buf[0] = p0;
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_rotate_left (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
@ -394,7 +385,7 @@ DECLSPEC int mangle_rotate_left (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8
|
||||
exchange_byte (buf, l, r);
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_rotate_right (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
@ -404,12 +395,12 @@ DECLSPEC int mangle_rotate_right (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u
|
||||
exchange_byte (buf, l, r);
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_delete_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
for (int pos = p0; pos < len - 1; pos++)
|
||||
{
|
||||
@ -435,9 +426,9 @@ DECLSPEC int mangle_delete_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8
|
||||
|
||||
DECLSPEC int mangle_extract (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
if ((p0 + p1) > len) return (len);
|
||||
if ((p0 + p1) > len) return len;
|
||||
|
||||
for (int pos = 0; pos < p1; pos++)
|
||||
{
|
||||
@ -449,14 +440,14 @@ DECLSPEC int mangle_extract (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1,
|
||||
buf[pos] = 0;
|
||||
}
|
||||
|
||||
return (p1);
|
||||
return p1;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_omit (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
if ((p0 + p1) > len) return (len);
|
||||
if ((p0 + p1) > len) return len;
|
||||
|
||||
for (int pos = p0; pos < len - p1; pos++)
|
||||
{
|
||||
@ -473,11 +464,11 @@ DECLSPEC int mangle_omit (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PR
|
||||
|
||||
DECLSPEC int mangle_insert (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len + 1) return (len);
|
||||
if (p0 >= len + 1) return len;
|
||||
|
||||
const int out_len = len + 1;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
for (int pos = len - 1; pos > p0 - 1; pos--)
|
||||
{
|
||||
@ -486,28 +477,28 @@ DECLSPEC int mangle_insert (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1,
|
||||
|
||||
buf[p0] = p1;
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_overstrike (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
buf[p0] = p1;
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_truncate_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
for (int pos = p0; pos < len; pos++)
|
||||
{
|
||||
buf[pos] = 0;
|
||||
}
|
||||
|
||||
return (p0);
|
||||
return p0;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
@ -519,7 +510,91 @@ DECLSPEC int mangle_replace (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1,
|
||||
buf[pos] = p1;
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_class_l (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
for (int pos = 0; pos < len; pos++)
|
||||
{
|
||||
if (!is_l (buf[pos])) continue;
|
||||
|
||||
buf[pos] = p1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_class_u (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
for (int pos = 0; pos < len; pos++)
|
||||
{
|
||||
if (!is_u (buf[pos])) continue;
|
||||
|
||||
buf[pos] = p1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_class_d (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
for (int pos = 0; pos < len; pos++)
|
||||
{
|
||||
if (!is_d (buf[pos])) continue;
|
||||
|
||||
buf[pos] = p1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_class_lh (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
for (int pos = 0; pos < len; pos++)
|
||||
{
|
||||
if (!is_lh (buf[pos])) continue;
|
||||
|
||||
buf[pos] = p1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_class_uh (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
for (int pos = 0; pos < len; pos++)
|
||||
{
|
||||
if (!is_uh (buf[pos])) continue;
|
||||
|
||||
buf[pos] = p1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_class_s (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
for (int pos = 0; pos < len; pos++)
|
||||
{
|
||||
if (!is_s (buf[pos])) continue;
|
||||
|
||||
buf[pos] = p1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_class (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 == 'l') return mangle_replace_class_l (p0, p1, buf, len);
|
||||
else if (p0 == 'u') return mangle_replace_class_u (p0, p1, buf, len);
|
||||
else if (p0 == 'd') return mangle_replace_class_d (p0, p1, buf, len);
|
||||
else if (p0 == 'h') return mangle_replace_class_lh (p0, p1, buf, len);
|
||||
else if (p0 == 'H') return mangle_replace_class_uh (p0, p1, buf, len);
|
||||
else if (p0 == 's') return mangle_replace_class_s (p0, p1, buf, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_purgechar (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
@ -540,15 +615,153 @@ DECLSPEC int mangle_purgechar (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p
|
||||
buf[pos] = 0;
|
||||
}
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_purgechar_class_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_purgechar_class_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_purgechar_class_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_purgechar_class_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_purgechar_class_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_purgechar_class_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_purgechar_class (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 == 'l') return mangle_purgechar_class_l (p0, p1, buf, len);
|
||||
else if (p0 == 'u') return mangle_purgechar_class_u (p0, p1, buf, len);
|
||||
else if (p0 == 'd') return mangle_purgechar_class_d (p0, p1, buf, len);
|
||||
else if (p0 == 'h') return mangle_purgechar_class_lh (p0, p1, buf, len);
|
||||
else if (p0 == 'H') return mangle_purgechar_class_uh (p0, p1, buf, len);
|
||||
else if (p0 == 's') return mangle_purgechar_class_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)
|
||||
{
|
||||
const int out_len = len + p0;
|
||||
|
||||
if (len == 0) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (len == 0) return len;
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
const u8 c = buf[0];
|
||||
|
||||
@ -557,15 +770,15 @@ DECLSPEC int mangle_dupechar_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const
|
||||
mangle_prepend (c, 0, buf, len + i);
|
||||
}
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_dupechar_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
const int out_len = len + p0;
|
||||
|
||||
if (len == 0) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (len == 0) return len;
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
const u8 c = buf[len - 1];
|
||||
|
||||
@ -574,14 +787,14 @@ DECLSPEC int mangle_dupechar_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const
|
||||
mangle_append (c, 0, buf, len + i);
|
||||
}
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_dupechar_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
const int out_len = len + len;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
for (int pos = len - 1; pos >= 0; pos--)
|
||||
{
|
||||
@ -592,100 +805,100 @@ DECLSPEC int mangle_dupechar_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u
|
||||
buf[new_pos + 1] = buf[pos];
|
||||
}
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_switch_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len < 2) return (len);
|
||||
if (len < 2) return len;
|
||||
|
||||
exchange_byte (buf, 0, 1);
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_switch_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len < 2) return (len);
|
||||
if (len < 2) return len;
|
||||
|
||||
exchange_byte (buf, len - 2, len - 1);
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_switch_at (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p1 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
if (p1 >= len) return len;
|
||||
|
||||
exchange_byte (buf, p0, p1);
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_chr_shiftl (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
buf[p0] <<= 1;
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_chr_shiftr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
buf[p0] >>= 1;
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_chr_incr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
buf[p0]++;
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_chr_decr (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
buf[p0]--;
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_np1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if ((p0 + 1) >= len) return (len);
|
||||
if ((p0 + 1) >= len) return len;
|
||||
|
||||
buf[p0] = buf[p0 + 1];
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_replace_nm1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 == 0) return (len);
|
||||
if (p0 == 0) return len;
|
||||
|
||||
if (p0 >= len) return (len);
|
||||
if (p0 >= len) return len;
|
||||
|
||||
buf[p0] = buf[p0 - 1];
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_dupeblock_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 > len) return (len);
|
||||
if (p0 > len) return len;
|
||||
|
||||
const int out_len = len + p0;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
for (int i = 0; i < p0; i++)
|
||||
{
|
||||
@ -694,16 +907,16 @@ DECLSPEC int mangle_dupeblock_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED cons
|
||||
mangle_insert (i, c, buf, len + i);
|
||||
}
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_dupeblock_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len)
|
||||
{
|
||||
if (p0 > len) return (len);
|
||||
if (p0 > len) return len;
|
||||
|
||||
const int out_len = len + p0;
|
||||
|
||||
if (out_len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (out_len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
for (int i = 0; i < p0; i++)
|
||||
{
|
||||
@ -712,12 +925,12 @@ DECLSPEC int mangle_dupeblock_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const
|
||||
mangle_append (c, 0, buf, len + i);
|
||||
}
|
||||
|
||||
return (out_len);
|
||||
return out_len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len >= RP_PASSWORD_SIZE) return (len);
|
||||
if (len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
u32 rem = 0xff;
|
||||
|
||||
@ -739,7 +952,181 @@ DECLSPEC int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p
|
||||
buf[idx] &= ~(generate_cmask (buf[idx]) & out);
|
||||
}
|
||||
|
||||
return (len);
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_title_sep_class_l (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
u32 rem = 0xff;
|
||||
|
||||
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
|
||||
{
|
||||
const u32 t = buf[idx];
|
||||
|
||||
buf[idx] = t | generate_cmask (t);
|
||||
|
||||
u32 out = rem;
|
||||
|
||||
rem = 0;
|
||||
|
||||
if (is_l ((t >> 0) & 0xff)) out |= 0x0000ff00;
|
||||
if (is_l ((t >> 8) & 0xff)) out |= 0x00ff0000;
|
||||
if (is_l ((t >> 16) & 0xff)) out |= 0xff000000;
|
||||
if (is_l ((t >> 24) & 0xff)) rem |= 0x000000ff;
|
||||
|
||||
buf[idx] &= ~(generate_cmask (buf[idx]) & out);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_title_sep_class_u (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
u32 rem = 0xff;
|
||||
|
||||
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
|
||||
{
|
||||
const u32 t = buf[idx];
|
||||
|
||||
buf[idx] = t | generate_cmask (t);
|
||||
|
||||
u32 out = rem;
|
||||
|
||||
rem = 0;
|
||||
|
||||
if (is_u ((t >> 0) & 0xff)) out |= 0x0000ff00;
|
||||
if (is_u ((t >> 8) & 0xff)) out |= 0x00ff0000;
|
||||
if (is_u ((t >> 16) & 0xff)) out |= 0xff000000;
|
||||
if (is_u ((t >> 24) & 0xff)) rem |= 0x000000ff;
|
||||
|
||||
buf[idx] &= ~(generate_cmask (buf[idx]) & out);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_title_sep_class_d (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
u32 rem = 0xff;
|
||||
|
||||
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
|
||||
{
|
||||
const u32 t = buf[idx];
|
||||
|
||||
buf[idx] = t | generate_cmask (t);
|
||||
|
||||
u32 out = rem;
|
||||
|
||||
rem = 0;
|
||||
|
||||
if (is_d ((t >> 0) & 0xff)) out |= 0x0000ff00;
|
||||
if (is_d ((t >> 8) & 0xff)) out |= 0x00ff0000;
|
||||
if (is_d ((t >> 16) & 0xff)) out |= 0xff000000;
|
||||
if (is_d ((t >> 24) & 0xff)) rem |= 0x000000ff;
|
||||
|
||||
buf[idx] &= ~(generate_cmask (buf[idx]) & out);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_title_sep_class_lh (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
u32 rem = 0xff;
|
||||
|
||||
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
|
||||
{
|
||||
const u32 t = buf[idx];
|
||||
|
||||
buf[idx] = t | generate_cmask (t);
|
||||
|
||||
u32 out = rem;
|
||||
|
||||
rem = 0;
|
||||
|
||||
if (is_lh ((t >> 0) & 0xff)) out |= 0x0000ff00;
|
||||
if (is_lh ((t >> 8) & 0xff)) out |= 0x00ff0000;
|
||||
if (is_lh ((t >> 16) & 0xff)) out |= 0xff000000;
|
||||
if (is_lh ((t >> 24) & 0xff)) rem |= 0x000000ff;
|
||||
|
||||
buf[idx] &= ~(generate_cmask (buf[idx]) & out);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_title_sep_class_uh (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
u32 rem = 0xff;
|
||||
|
||||
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
|
||||
{
|
||||
const u32 t = buf[idx];
|
||||
|
||||
buf[idx] = t | generate_cmask (t);
|
||||
|
||||
u32 out = rem;
|
||||
|
||||
rem = 0;
|
||||
|
||||
if (is_uh ((t >> 0) & 0xff)) out |= 0x0000ff00;
|
||||
if (is_uh ((t >> 8) & 0xff)) out |= 0x00ff0000;
|
||||
if (is_uh ((t >> 16) & 0xff)) out |= 0xff000000;
|
||||
if (is_uh ((t >> 24) & 0xff)) rem |= 0x000000ff;
|
||||
|
||||
buf[idx] &= ~(generate_cmask (buf[idx]) & out);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_title_sep_class_s (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (len >= RP_PASSWORD_SIZE) return len;
|
||||
|
||||
u32 rem = 0xff;
|
||||
|
||||
for (int i = 0, idx = 0; i < len; i += 4, idx += 1)
|
||||
{
|
||||
const u32 t = buf[idx];
|
||||
|
||||
buf[idx] = t | generate_cmask (t);
|
||||
|
||||
u32 out = rem;
|
||||
|
||||
rem = 0;
|
||||
|
||||
if (is_s ((t >> 0) & 0xff)) out |= 0x0000ff00;
|
||||
if (is_s ((t >> 8) & 0xff)) out |= 0x00ff0000;
|
||||
if (is_s ((t >> 16) & 0xff)) out |= 0xff000000;
|
||||
if (is_s ((t >> 24) & 0xff)) rem |= 0x000000ff;
|
||||
|
||||
buf[idx] &= ~(generate_cmask (buf[idx]) & out);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int mangle_title_sep_class (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len)
|
||||
{
|
||||
if (p0 == 'l') return mangle_title_sep_class_l (p0, p1, buf, len);
|
||||
else if (p0 == 'u') return mangle_title_sep_class_u (p0, p1, buf, len);
|
||||
else if (p0 == 'd') return mangle_title_sep_class_d (p0, p1, buf, len);
|
||||
else if (p0 == 'h') return mangle_title_sep_class_lh (p0, p1, buf, len);
|
||||
else if (p0 == 'H') return mangle_title_sep_class_uh (p0, p1, buf, len);
|
||||
else if (p0 == 's') return mangle_title_sep_class_s (p0, p1, buf, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
DECLSPEC int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int in_len)
|
||||
@ -772,7 +1159,9 @@ DECLSPEC int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED
|
||||
case RULE_OP_MANGLE_OVERSTRIKE: out_len = mangle_overstrike (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_CLASS: out_len = mangle_replace_class (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_CLASS: out_len = mangle_purgechar_class (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_ALL: out_len = mangle_dupechar_all (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
|
||||
@ -788,6 +1177,7 @@ DECLSPEC int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_FIRST: out_len = mangle_dupeblock_first (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
|
||||
case RULE_OP_MANGLE_DUPEBLOCK_LAST: out_len = mangle_dupeblock_last (p0, p1, (PRIVATE_AS u8 *) buf, out_len); break;
|
||||
case RULE_OP_MANGLE_TITLE_SEP: out_len = mangle_title_sep (p0, p1, buf, out_len); break;
|
||||
case RULE_OP_MANGLE_TITLE_SEP_CLASS: out_len = mangle_title_sep_class (p0, p1, buf, out_len); break;
|
||||
case RULE_OP_MANGLE_TITLE: out_len = mangle_title_sep (' ', p1, buf, out_len); break;
|
||||
}
|
||||
|
||||
|
@ -6,72 +6,8 @@
|
||||
#ifndef INC_RP_H
|
||||
#define INC_RP_H
|
||||
|
||||
#ifndef DECLSPEC
|
||||
#define DECLSPEC
|
||||
#endif
|
||||
#include "inc_rp_common.h"
|
||||
|
||||
#ifndef MAYBE_UNUSED
|
||||
#define MAYBE_UNUSED
|
||||
#endif
|
||||
|
||||
#define RULE_OP_MANGLE_NOOP ':'
|
||||
#define RULE_OP_MANGLE_LREST 'l'
|
||||
#define RULE_OP_MANGLE_UREST 'u'
|
||||
#define RULE_OP_MANGLE_LREST_UFIRST 'c'
|
||||
#define RULE_OP_MANGLE_UREST_LFIRST 'C'
|
||||
#define RULE_OP_MANGLE_TREST 't'
|
||||
#define RULE_OP_MANGLE_TOGGLE_AT 'T'
|
||||
#define RULE_OP_MANGLE_TOGGLE_AT_SEP '3'
|
||||
#define RULE_OP_MANGLE_REVERSE 'r'
|
||||
#define RULE_OP_MANGLE_DUPEWORD 'd'
|
||||
#define RULE_OP_MANGLE_DUPEWORD_TIMES 'p'
|
||||
#define RULE_OP_MANGLE_REFLECT 'f'
|
||||
#define RULE_OP_MANGLE_ROTATE_LEFT '{'
|
||||
#define RULE_OP_MANGLE_ROTATE_RIGHT '}'
|
||||
#define RULE_OP_MANGLE_APPEND '$'
|
||||
#define RULE_OP_MANGLE_PREPEND '^'
|
||||
#define RULE_OP_MANGLE_DELETE_FIRST '['
|
||||
#define RULE_OP_MANGLE_DELETE_LAST ']'
|
||||
#define RULE_OP_MANGLE_DELETE_AT 'D'
|
||||
#define RULE_OP_MANGLE_EXTRACT 'x'
|
||||
#define RULE_OP_MANGLE_OMIT 'O'
|
||||
#define RULE_OP_MANGLE_INSERT 'i'
|
||||
#define RULE_OP_MANGLE_OVERSTRIKE 'o'
|
||||
#define RULE_OP_MANGLE_TRUNCATE_AT '\''
|
||||
#define RULE_OP_MANGLE_REPLACE 's'
|
||||
#define RULE_OP_MANGLE_PURGECHAR '@'
|
||||
#define RULE_OP_MANGLE_TOGGLECASE_REC 'a'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_LAST 'Z'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_ALL 'q'
|
||||
#define RULE_OP_MANGLE_TITLE_SEP 'e'
|
||||
|
||||
#define RULE_OP_REJECT_LESS '<'
|
||||
#define RULE_OP_REJECT_GREATER '>'
|
||||
#define RULE_OP_REJECT_CONTAIN '!'
|
||||
#define RULE_OP_REJECT_NOT_CONTAIN '/'
|
||||
#define RULE_OP_REJECT_EQUAL_FIRST '('
|
||||
#define RULE_OP_REJECT_EQUAL_LAST ')'
|
||||
#define RULE_OP_REJECT_EQUAL_AT '='
|
||||
#define RULE_OP_REJECT_CONTAINS '%'
|
||||
|
||||
/* hashcat only */
|
||||
#define RULE_OP_MANGLE_SWITCH_FIRST 'k'
|
||||
#define RULE_OP_MANGLE_SWITCH_LAST 'K'
|
||||
#define RULE_OP_MANGLE_SWITCH_AT '*'
|
||||
#define RULE_OP_MANGLE_CHR_SHIFTL 'L'
|
||||
#define RULE_OP_MANGLE_CHR_SHIFTR 'R'
|
||||
#define RULE_OP_MANGLE_CHR_INCR '+'
|
||||
#define RULE_OP_MANGLE_CHR_DECR '-'
|
||||
#define RULE_OP_MANGLE_REPLACE_NP1 '.'
|
||||
#define RULE_OP_MANGLE_REPLACE_NM1 ','
|
||||
#define RULE_OP_MANGLE_DUPEBLOCK_FIRST 'y'
|
||||
#define RULE_OP_MANGLE_DUPEBLOCK_LAST 'Y'
|
||||
#define RULE_OP_MANGLE_TITLE 'E'
|
||||
|
||||
#define RP_PASSWORD_SIZE 256
|
||||
|
||||
DECLSPEC u32 generate_cmask (const u32 value);
|
||||
DECLSPEC void append_four_byte (PRIVATE_AS const u32 *buf_src, const int off_src, PRIVATE_AS u32 *buf_dst, const int off_dst);
|
||||
DECLSPEC void append_three_byte (PRIVATE_AS const u32 *buf_src, const int off_src, PRIVATE_AS u32 *buf_dst, const int off_dst);
|
||||
DECLSPEC void append_two_byte (PRIVATE_AS const u32 *buf_src, const int off_src, PRIVATE_AS u32 *buf_dst, const int off_dst);
|
||||
@ -102,7 +38,9 @@ DECLSPEC int mangle_insert (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1,
|
||||
DECLSPEC int mangle_overstrike (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_class (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_class (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_all (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
|
||||
@ -118,6 +56,7 @@ DECLSPEC int mangle_replace_nm1 (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8
|
||||
DECLSPEC int mangle_dupeblock_first (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
|
||||
DECLSPEC int mangle_dupeblock_last (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u8 *buf, const int len);
|
||||
DECLSPEC int mangle_title_sep (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len);
|
||||
DECLSPEC int mangle_title_sep_class (MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int len);
|
||||
DECLSPEC int apply_rule (const u32 name, MAYBE_UNUSED const u8 p0, MAYBE_UNUSED const u8 p1, PRIVATE_AS u32 *buf, const int in_len);
|
||||
DECLSPEC int apply_rules (CONSTANT_AS const u32 *cmds, PRIVATE_AS u32 *buf, const int in_len);
|
||||
|
||||
|
86
OpenCL/inc_rp_common.cl
Normal file
86
OpenCL/inc_rp_common.cl
Normal file
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "inc_vendor.h"
|
||||
#include "inc_types.h"
|
||||
#include "inc_platform.h"
|
||||
#include "inc_common.h"
|
||||
#include "inc_rp_common.h"
|
||||
|
||||
#ifdef HC_CPU_OPENCL_EMU_H
|
||||
#undef DECLSPEC
|
||||
#define DECLSPEC static
|
||||
#endif
|
||||
|
||||
CONSTANT_VK static u8 s_lookup[128] =
|
||||
{
|
||||
// 0-31: control characters (0)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 32: whitespace (1)
|
||||
1,
|
||||
// 33-47: punctuation (1)
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
// 48-57: digits (0)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 58-64: punctuation (1)
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
// 65-90: uppercase letters (0)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 91-96: punctuation (1)
|
||||
1, 1, 1, 1, 1, 1,
|
||||
// 97-122: lowercase letters (0)
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
// 123-126: punctuation (1)
|
||||
1, 1, 1, 1,
|
||||
// 127: DEL (0)
|
||||
0
|
||||
};
|
||||
|
||||
DECLSPEC MAYBE_UNUSED bool is_l (u8 c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z');
|
||||
}
|
||||
|
||||
DECLSPEC MAYBE_UNUSED bool is_u (u8 c)
|
||||
{
|
||||
return (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
DECLSPEC MAYBE_UNUSED bool is_d (u8 c)
|
||||
{
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
DECLSPEC MAYBE_UNUSED bool is_lh (u8 c)
|
||||
{
|
||||
return (is_d (c) || (c >= 'a' && c <= 'f'));
|
||||
}
|
||||
|
||||
DECLSPEC MAYBE_UNUSED bool is_uh (u8 c)
|
||||
{
|
||||
return (is_d (c) || (c >= 'A' && c <= 'F'));
|
||||
}
|
||||
|
||||
DECLSPEC MAYBE_UNUSED bool is_s (u8 c)
|
||||
{
|
||||
return s_lookup[c] == 1;
|
||||
}
|
||||
|
||||
DECLSPEC MAYBE_UNUSED u32 generate_cmask (const u32 value)
|
||||
{
|
||||
const u32 rmask = ((value & 0x40404040u) >> 1u)
|
||||
& ~((value & 0x80808080u) >> 2u);
|
||||
|
||||
const u32 hmask = (value & 0x1f1f1f1fu) + 0x05050505u;
|
||||
const u32 lmask = (value & 0x1f1f1f1fu) + 0x1f1f1f1fu;
|
||||
|
||||
return rmask & ~hmask & lmask;
|
||||
}
|
||||
|
||||
#ifdef HC_CPU_OPENCL_EMU_H
|
||||
#undef DECLSPEC
|
||||
#define DECLSPEC
|
||||
#endif
|
83
OpenCL/inc_rp_common.h
Normal file
83
OpenCL/inc_rp_common.h
Normal file
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifndef INC_RP_COMMON_H
|
||||
#define INC_RP_COMMON_H
|
||||
|
||||
#ifdef IS_METAL
|
||||
#define HC_INLINE_RP __attribute__ ((noinline))
|
||||
#else
|
||||
#define HC_INLINE_RP
|
||||
#endif
|
||||
|
||||
#define RULE_OP_MANGLE_NOOP ':'
|
||||
#define RULE_OP_MANGLE_LREST 'l'
|
||||
#define RULE_OP_MANGLE_UREST 'u'
|
||||
#define RULE_OP_MANGLE_LREST_UFIRST 'c'
|
||||
#define RULE_OP_MANGLE_UREST_LFIRST 'C'
|
||||
#define RULE_OP_MANGLE_TREST 't'
|
||||
#define RULE_OP_MANGLE_TOGGLE_AT 'T'
|
||||
#define RULE_OP_MANGLE_TOGGLE_AT_SEP '3'
|
||||
#define RULE_OP_MANGLE_REVERSE 'r'
|
||||
#define RULE_OP_MANGLE_DUPEWORD 'd'
|
||||
#define RULE_OP_MANGLE_DUPEWORD_TIMES 'p'
|
||||
#define RULE_OP_MANGLE_REFLECT 'f'
|
||||
#define RULE_OP_MANGLE_ROTATE_LEFT '{'
|
||||
#define RULE_OP_MANGLE_ROTATE_RIGHT '}'
|
||||
#define RULE_OP_MANGLE_APPEND '$'
|
||||
#define RULE_OP_MANGLE_PREPEND '^'
|
||||
#define RULE_OP_MANGLE_DELETE_FIRST '['
|
||||
#define RULE_OP_MANGLE_DELETE_LAST ']'
|
||||
#define RULE_OP_MANGLE_DELETE_AT 'D'
|
||||
#define RULE_OP_MANGLE_EXTRACT 'x'
|
||||
#define RULE_OP_MANGLE_OMIT 'O'
|
||||
#define RULE_OP_MANGLE_INSERT 'i'
|
||||
#define RULE_OP_MANGLE_OVERSTRIKE 'o'
|
||||
#define RULE_OP_MANGLE_TRUNCATE_AT '\''
|
||||
#define RULE_OP_MANGLE_REPLACE 's'
|
||||
#define RULE_OP_MANGLE_PURGECHAR '@'
|
||||
#define RULE_OP_MANGLE_TOGGLECASE_REC 'a'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_LAST 'Z'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_ALL 'q'
|
||||
#define RULE_OP_MANGLE_TITLE_SEP 'e'
|
||||
|
||||
#define RULE_OP_REJECT_LESS '<'
|
||||
#define RULE_OP_REJECT_GREATER '>'
|
||||
#define RULE_OP_REJECT_CONTAIN '!'
|
||||
#define RULE_OP_REJECT_NOT_CONTAIN '/'
|
||||
#define RULE_OP_REJECT_EQUAL_FIRST '('
|
||||
#define RULE_OP_REJECT_EQUAL_LAST ')'
|
||||
#define RULE_OP_REJECT_EQUAL_AT '='
|
||||
#define RULE_OP_REJECT_CONTAINS '%'
|
||||
|
||||
/* hashcat only */
|
||||
#define RULE_OP_MANGLE_SWITCH_FIRST 'k'
|
||||
#define RULE_OP_MANGLE_SWITCH_LAST 'K'
|
||||
#define RULE_OP_MANGLE_SWITCH_AT '*'
|
||||
#define RULE_OP_MANGLE_CHR_SHIFTL 'L'
|
||||
#define RULE_OP_MANGLE_CHR_SHIFTR 'R'
|
||||
#define RULE_OP_MANGLE_CHR_INCR '+'
|
||||
#define RULE_OP_MANGLE_CHR_DECR '-'
|
||||
#define RULE_OP_MANGLE_REPLACE_NP1 '.'
|
||||
#define RULE_OP_MANGLE_REPLACE_NM1 ','
|
||||
#define RULE_OP_MANGLE_DUPEBLOCK_FIRST 'y'
|
||||
#define RULE_OP_MANGLE_DUPEBLOCK_LAST 'Y'
|
||||
#define RULE_OP_MANGLE_TITLE 'E'
|
||||
|
||||
/* using character classes */
|
||||
#define RULE_OP_MANGLE_REPLACE_CLASS 0x01
|
||||
#define RULE_OP_MANGLE_PURGECHAR_CLASS 0x02
|
||||
#define RULE_OP_MANGLE_TITLE_SEP_CLASS 0x03
|
||||
#define RULE_OP_REJECT_CONTAIN_CLASS 0x04
|
||||
#define RULE_OP_REJECT_NOT_CONTAIN_CLASS 0x05
|
||||
#define RULE_OP_REJECT_EQUAL_FIRST_CLASS 0x06
|
||||
#define RULE_OP_REJECT_EQUAL_LAST_CLASS 0x07
|
||||
#define RULE_OP_REJECT_EQUAL_AT_CLASS 0x08
|
||||
#define RULE_OP_REJECT_CONTAINS_CLASS 0x09
|
||||
|
||||
#define RP_PASSWORD_SIZE 256
|
||||
|
||||
#endif // INC_RP_COMMON_H
|
File diff suppressed because it is too large
Load Diff
@ -6,76 +6,8 @@
|
||||
#ifndef INC_RP_OPTIMIZED_H
|
||||
#define INC_RP_OPTIMIZED_H
|
||||
|
||||
#ifndef DECLSPEC
|
||||
#define DECLSPEC
|
||||
#endif
|
||||
#include "inc_rp_common.h"
|
||||
|
||||
#ifndef MAYBE_UNUSED
|
||||
#define MAYBE_UNUSED
|
||||
#endif
|
||||
|
||||
#ifdef IS_METAL
|
||||
#define HC_INLINE_RP __attribute__ ((noinline))
|
||||
#else
|
||||
#define HC_INLINE_RP
|
||||
#endif
|
||||
|
||||
#define RULE_OP_MANGLE_NOOP ':'
|
||||
#define RULE_OP_MANGLE_LREST 'l'
|
||||
#define RULE_OP_MANGLE_UREST 'u'
|
||||
#define RULE_OP_MANGLE_LREST_UFIRST 'c'
|
||||
#define RULE_OP_MANGLE_UREST_LFIRST 'C'
|
||||
#define RULE_OP_MANGLE_TREST 't'
|
||||
#define RULE_OP_MANGLE_TOGGLE_AT 'T'
|
||||
#define RULE_OP_MANGLE_TOGGLE_AT_SEP '3'
|
||||
#define RULE_OP_MANGLE_REVERSE 'r'
|
||||
#define RULE_OP_MANGLE_DUPEWORD 'd'
|
||||
#define RULE_OP_MANGLE_DUPEWORD_TIMES 'p'
|
||||
#define RULE_OP_MANGLE_REFLECT 'f'
|
||||
#define RULE_OP_MANGLE_ROTATE_LEFT '{'
|
||||
#define RULE_OP_MANGLE_ROTATE_RIGHT '}'
|
||||
#define RULE_OP_MANGLE_APPEND '$'
|
||||
#define RULE_OP_MANGLE_PREPEND '^'
|
||||
#define RULE_OP_MANGLE_DELETE_FIRST '['
|
||||
#define RULE_OP_MANGLE_DELETE_LAST ']'
|
||||
#define RULE_OP_MANGLE_DELETE_AT 'D'
|
||||
#define RULE_OP_MANGLE_EXTRACT 'x'
|
||||
#define RULE_OP_MANGLE_OMIT 'O'
|
||||
#define RULE_OP_MANGLE_INSERT 'i'
|
||||
#define RULE_OP_MANGLE_OVERSTRIKE 'o'
|
||||
#define RULE_OP_MANGLE_TRUNCATE_AT '\''
|
||||
#define RULE_OP_MANGLE_REPLACE 's'
|
||||
#define RULE_OP_MANGLE_PURGECHAR '@'
|
||||
#define RULE_OP_MANGLE_TOGGLECASE_REC 'a'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_LAST 'Z'
|
||||
#define RULE_OP_MANGLE_DUPECHAR_ALL 'q'
|
||||
#define RULE_OP_MANGLE_TITLE_SEP 'e'
|
||||
|
||||
#define RULE_OP_REJECT_LESS '<'
|
||||
#define RULE_OP_REJECT_GREATER '>'
|
||||
#define RULE_OP_REJECT_CONTAIN '!'
|
||||
#define RULE_OP_REJECT_NOT_CONTAIN '/'
|
||||
#define RULE_OP_REJECT_EQUAL_FIRST '('
|
||||
#define RULE_OP_REJECT_EQUAL_LAST ')'
|
||||
#define RULE_OP_REJECT_EQUAL_AT '='
|
||||
#define RULE_OP_REJECT_CONTAINS '%'
|
||||
|
||||
/* hashcat only */
|
||||
#define RULE_OP_MANGLE_SWITCH_FIRST 'k'
|
||||
#define RULE_OP_MANGLE_SWITCH_LAST 'K'
|
||||
#define RULE_OP_MANGLE_SWITCH_AT '*'
|
||||
#define RULE_OP_MANGLE_CHR_SHIFTL 'L'
|
||||
#define RULE_OP_MANGLE_CHR_SHIFTR 'R'
|
||||
#define RULE_OP_MANGLE_CHR_INCR '+'
|
||||
#define RULE_OP_MANGLE_CHR_DECR '-'
|
||||
#define RULE_OP_MANGLE_REPLACE_NP1 '.'
|
||||
#define RULE_OP_MANGLE_REPLACE_NM1 ','
|
||||
#define RULE_OP_MANGLE_DUPEBLOCK_FIRST 'y'
|
||||
#define RULE_OP_MANGLE_DUPEBLOCK_LAST 'Y'
|
||||
#define RULE_OP_MANGLE_TITLE 'E'
|
||||
|
||||
DECLSPEC u32 generate_cmask_optimized (const u32 value);
|
||||
DECLSPEC void truncate_right_optimized (PRIVATE_AS u32 *buf0, PRIVATE_AS u32 *buf1, const u32 offset);
|
||||
DECLSPEC void truncate_left_optimized (PRIVATE_AS u32 *buf0, PRIVATE_AS u32 *buf1, const u32 offset);
|
||||
DECLSPEC void lshift_block_optimized (PRIVATE_AS const u32 *in0, PRIVATE_AS const u32 *in1, PRIVATE_AS u32 *out0, PRIVATE_AS u32 *out1);
|
||||
@ -112,7 +44,9 @@ DECLSPEC HC_INLINE_RP u32 rule_op_mangle_truncate_at (MAYBE_UNUSED const u32 p0,
|
||||
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 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_class (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_class (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_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);
|
||||
@ -129,6 +63,7 @@ DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupeblock_first (MAYBE_UNUSED const u32
|
||||
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_dupeblock_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 u32 toggle_on_register (const u32 in, const u32 r);
|
||||
DECLSPEC HC_INLINE_RP u32 rule_op_mangle_title_sep (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_title_sep_class (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 u32 apply_rule_optimized (const u32 name, const u32 p0, const u32 p1, PRIVATE_AS u32 *buf0, PRIVATE_AS u32 *buf1, const u32 in_len);
|
||||
DECLSPEC u32 apply_rules_optimized (CONSTANT_AS const u32 *cmds, PRIVATE_AS u32 *buf0, PRIVATE_AS u32 *buf1, const u32 len);
|
||||
DECLSPEC u32x apply_rules_vect_optimized (PRIVATE_AS const u32 *pw_buf0, PRIVATE_AS const u32 *pw_buf1, const u32 pw_len, CONSTANT_AS const kernel_rule_t *kernel_rules, const u32 il_pos, PRIVATE_AS u32x *buf0, PRIVATE_AS u32x *buf1);
|
||||
|
@ -200,6 +200,7 @@
|
||||
- Help: show supported hash-modes only with -hh
|
||||
- Makefile: prevent make failure with Apple Silicon in case of partial rebuild
|
||||
- Makefile: updated MACOSX_DEPLOYMENT_TARGET to 15.0
|
||||
- Rules: Add support to character class rules
|
||||
- Rules: Rename best64.rule to best66.rule and remove the unknown section from it
|
||||
- Kernel: Renamed multiple defines in CAST cipher to fit expected naming convention of the C++ language standard
|
||||
|
||||
|
@ -25,6 +25,7 @@ Gabriele "matrix" Gristina <matrix@hashcat.net> (@gm4tr1x)
|
||||
* Apple macOS port
|
||||
* Apple Silicon support
|
||||
* Universal binary on Apple Silicon
|
||||
* Add support to character class rules
|
||||
* Hardware monitor initial code base and maintenance
|
||||
* Test suite initial code base and maintenance
|
||||
* Edge case testing suite
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define RULE_OP_MANGLE_OMIT 'O' // omit X chars of word at pos N
|
||||
#define RULE_OP_MANGLE_INSERT 'i' // insert 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_PURGECHAR '@' // purge all instances of char X
|
||||
#define RULE_OP_MANGLE_DUPECHAR_FIRST 'z' // prepend first char of word to itself N times. ex: hello -> hhhello
|
||||
@ -59,3 +59,19 @@
|
||||
#define RULE_OP_REJECT_CONTAINS '%' // reject plains that contain char X less than N times
|
||||
#define RULE_OP_REJECT_MEMORY 'Q' // reject plains that match the plain saved (see M), i.e. if unchanged
|
||||
#define RULE_LAST_REJECTED_SAVED_POS 'p' // pos of the char last found with '/' or '%'
|
||||
|
||||
/* using character classes */
|
||||
|
||||
#define RULE_OP_CLASS_BASED '~'
|
||||
#define RULE_OP_MANGLE_REPLACE_CLASS 0x01 // replace all instances of chars in class C with char Y, ~s?CY
|
||||
#define RULE_OP_MANGLE_PURGECHAR_CLASS 0x02 // purge all instances of chars in class C, ~@?C
|
||||
#define RULE_OP_MANGLE_TITLE_SEP_CLASS 0x03 // lowercase everything then upper case the first letter and every letter after chars in class C, ~e?C
|
||||
|
||||
/* using character classes, with -j or -k only */
|
||||
|
||||
#define RULE_OP_REJECT_CONTAIN_CLASS 0x04 // reject plains that contain chars in class C, ~!?C
|
||||
#define RULE_OP_REJECT_NOT_CONTAIN_CLASS 0x05 // reject plains that do not contain chars in class C, ~/?C
|
||||
#define RULE_OP_REJECT_EQUAL_FIRST_CLASS 0x06 // reject plains that do not contain chars in class C at first pos, ~(?C
|
||||
#define RULE_OP_REJECT_EQUAL_LAST_CLASS 0x07 // reject plains that do not contain chars in class C at last pos, ~)?C
|
||||
#define RULE_OP_REJECT_EQUAL_AT_CLASS 0x08 // reject plains that do not contain chars in class C at pos N, ~=N?C
|
||||
#define RULE_OP_REJECT_CONTAINS_CLASS 0x09 // reject plains that contain chars in class C less than N times, ~%N?C
|
||||
|
@ -46,6 +46,9 @@ typedef struct
|
||||
bool class_num (const u8 c);
|
||||
bool class_lower (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);
|
||||
|
||||
int conv_ctoi (const u8 c);
|
||||
|
@ -377,6 +377,18 @@ typedef enum rule_functions
|
||||
RULE_OP_MANGLE_DUPEBLOCK_LAST = 'Y',
|
||||
RULE_OP_MANGLE_TITLE = 'E',
|
||||
|
||||
/* using character classes */
|
||||
RULE_OP_CLASS_BASED = '~',
|
||||
RULE_OP_MANGLE_REPLACE_CLASS = 0x01,
|
||||
RULE_OP_MANGLE_PURGECHAR_CLASS = 0x02,
|
||||
RULE_OP_MANGLE_TITLE_SEP_CLASS = 0x03,
|
||||
RULE_OP_REJECT_CONTAIN_CLASS = 0x04,
|
||||
RULE_OP_REJECT_NOT_CONTAIN_CLASS = 0x05,
|
||||
RULE_OP_REJECT_EQUAL_FIRST_CLASS = 0x06,
|
||||
RULE_OP_REJECT_EQUAL_LAST_CLASS = 0x07,
|
||||
RULE_OP_REJECT_EQUAL_AT_CLASS = 0x08,
|
||||
RULE_OP_REJECT_CONTAINS_CLASS = 0x09,
|
||||
|
||||
} rule_functions_t;
|
||||
|
||||
typedef enum salt_type
|
||||
|
@ -431,7 +431,7 @@ CXXFLAGS :=
|
||||
##
|
||||
|
||||
EMU_OBJS_ALL := emu_general emu_inc_common emu_inc_platform emu_inc_scalar emu_inc_simd
|
||||
EMU_OBJS_ALL += emu_inc_rp emu_inc_rp_optimized
|
||||
EMU_OBJS_ALL += emu_inc_rp_common emu_inc_rp emu_inc_rp_optimized
|
||||
EMU_OBJS_ALL += emu_inc_hash_md4 emu_inc_hash_md5 emu_inc_hash_ripemd160 emu_inc_hash_sha1 emu_inc_hash_sha256 emu_inc_hash_sha384 emu_inc_hash_sha512 emu_inc_hash_streebog256 emu_inc_hash_streebog512 emu_inc_ecc_secp256k1 emu_inc_bignum_operations
|
||||
EMU_OBJS_ALL += emu_inc_cipher_aes emu_inc_cipher_camellia emu_inc_cipher_des emu_inc_cipher_kuznyechik emu_inc_cipher_serpent emu_inc_cipher_twofish
|
||||
EMU_OBJS_ALL += emu_inc_hash_base58
|
||||
|
11
src/emu_inc_rp_common.c
Normal file
11
src/emu_inc_rp_common.c
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "emu_general.h"
|
||||
|
||||
#include "inc_rp_common.cl"
|
||||
|
110
src/rp.c
110
src/rp.c
@ -106,6 +106,21 @@ bool class_upper (const u8 c)
|
||||
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)
|
||||
{
|
||||
return (class_lower (c) || class_upper (c));
|
||||
@ -217,7 +232,7 @@ int generate_random_rule (char rule_buf[RP_RULE_SIZE], const u32 rp_gen_func_min
|
||||
}
|
||||
}
|
||||
|
||||
return (rule_pos);
|
||||
return rule_pos;
|
||||
}
|
||||
|
||||
#define INCR_POS if (++rule_pos == rule_len) return (-1)
|
||||
@ -463,6 +478,77 @@ int cpu_rule_to_kernel_rule (char *rule_buf, u32 rule_len, kernel_rule_t *rule)
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_CLASS_BASED: // ~
|
||||
switch (rule_buf[rule_pos+1])
|
||||
{
|
||||
case RULE_OP_MANGLE_REPLACE: // ~s?CY
|
||||
SET_NAME (rule, RULE_OP_MANGLE_REPLACE_CLASS);
|
||||
INCR_POS;
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PURGECHAR: // ~@?C
|
||||
SET_NAME (rule, RULE_OP_MANGLE_PURGECHAR_CLASS);
|
||||
INCR_POS;
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TITLE_SEP: // ~e?C
|
||||
SET_NAME (rule, RULE_OP_MANGLE_TITLE_SEP_CLASS);
|
||||
INCR_POS;
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
|
||||
/*
|
||||
case '!': // ~!?C
|
||||
SET_NAME (rule, RULE_OP_REJECT_CONTAIN_CLASS);
|
||||
INCR_POS;
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
case '/': // ~/?C
|
||||
SET_NAME (rule, RULE_OP_REJECT_NOT_CONTAIN_CLASS);
|
||||
INCR_POS;
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
case '(': // ~(?C
|
||||
SET_NAME (rule, RULE_OP_REJECT_EQUAL_FIRST_CLASS);
|
||||
INCR_POS;
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
case '(': // ~)?C
|
||||
SET_NAME (rule, RULE_OP_REJECT_EQUAL_LAST_CLASS);
|
||||
INCR_POS;
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
case '=': // ~=N?C
|
||||
SET_NAME (rule, RULE_OP_REJECT_EQUAL_AT_CLASS);
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
INCR_POS;
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
case '%': // ~%N?C
|
||||
SET_NAME (rule, RULE_OP_REJECT_CONTAINS_CLASS);
|
||||
INCR_POS;
|
||||
SET_P0 (rule, rule_buf[rule_pos]);
|
||||
INCR_POS;
|
||||
SET_P1 (rule, rule_buf[rule_pos]);
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@ -692,6 +778,28 @@ int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
|
||||
GET_P1 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_REPLACE_CLASS:
|
||||
rule_buf[rule_pos++] = RULE_OP_CLASS_BASED;
|
||||
rule_buf[rule_pos++] = RULE_OP_MANGLE_REPLACE;
|
||||
rule_buf[rule_pos] = '?';
|
||||
GET_P0 (rule);
|
||||
GET_P1 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_PURGECHAR_CLASS:
|
||||
rule_buf[rule_pos++] = RULE_OP_CLASS_BASED;
|
||||
rule_buf[rule_pos++] = RULE_OP_MANGLE_PURGECHAR;
|
||||
rule_buf[rule_pos] = '?';
|
||||
GET_P0 (rule);
|
||||
break;
|
||||
|
||||
case RULE_OP_MANGLE_TITLE_SEP_CLASS:
|
||||
rule_buf[rule_pos++] = RULE_OP_CLASS_BASED;
|
||||
rule_buf[rule_pos++] = RULE_OP_MANGLE_TITLE_SEP;
|
||||
rule_buf[rule_pos] = '?';
|
||||
GET_P0 (rule);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
if (rule_pos == 0) return -1;
|
||||
return rule_pos - 1;
|
||||
|
1137
src/rp_cpu.c
1137
src/rp_cpu.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user