1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 08:08:10 +00:00

Remove lookup table for speed, add vector datatype support for CPU and unit-test script for -m 24900

This commit is contained in:
Jens Steube 2021-03-27 14:08:22 +01:00
parent 98ee8c4168
commit de19c31dee
6 changed files with 199 additions and 297 deletions

View File

@ -46,22 +46,6 @@ KERNEL_FQ void m24900_m04 (KERN_ATTR_RULES ())
const u32 pw_len = pws[gid].pw_len & 63;
/**
* lookup table
*/
const u8 sof_lut[64] =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x00, 0x00
};
/**
* loop
*/
@ -160,37 +144,21 @@ KERNEL_FQ void m24900_m04 (KERN_ATTR_RULES ())
c += MD5M_C;
d += MD5M_D;
u16 t_abcd = ((a & 0xff) + ((a >> 8) & 0xff));
u8 a_12 = (t_abcd % 0x3e);
const u32x a0 = (((a >> 0) & 0xff) + ((a >> 8) & 0xff)) % 62;
const u32x a1 = (((a >> 16) & 0xff) + ((a >> 24) & 0xff)) % 62;
const u32x b0 = (((b >> 0) & 0xff) + ((b >> 8) & 0xff)) % 62;
const u32x b1 = (((b >> 16) & 0xff) + ((b >> 24) & 0xff)) % 62;
const u32x c0 = (((c >> 0) & 0xff) + ((c >> 8) & 0xff)) % 62;
const u32x c1 = (((c >> 16) & 0xff) + ((c >> 24) & 0xff)) % 62;
const u32x d0 = (((d >> 0) & 0xff) + ((d >> 8) & 0xff)) % 62;
const u32x d1 = (((d >> 16) & 0xff) + ((d >> 24) & 0xff)) % 62;
t_abcd = (((a >> 16 )& 0xff) + ((a >> 24) & 0xff));
u8 a_34 = (t_abcd % 0x3e);
t_abcd = ((b & 0xff) + ((b >> 8) & 0xff));
u8 b_12 = (t_abcd % 0x3e);
t_abcd = (((b >> 16) & 0xff) + ((b >> 24) & 0xff));
u8 b_34 = (t_abcd % 0x3e);
t_abcd = ((c & 0xff) + ((c >> 8) & 0xff));
u8 c_12 = (t_abcd % 0x3e);
t_abcd = (((c >> 16 )& 0xff) + ((c >> 24) & 0xff));
u8 c_34 = (t_abcd % 0x3e);
t_abcd = ((d & 0xff) + ((d >> 8) & 0xff));
u8 d_12 = (t_abcd % 0x3e);
t_abcd = (((d >> 16) & 0xff) + ((d >> 24) & 0xff));
u8 d_34 = (t_abcd % 0x3e);
a = (sof_lut[a_12]) + (sof_lut[a_34] << 8) + (sof_lut[b_12] << 16) + (sof_lut[b_34] << 24);
b = (sof_lut[c_12]) + (sof_lut[c_34] << 8) + (sof_lut[d_12] << 16) + (sof_lut[d_34] << 24);
u32x z = 0;
COMPARE_M_SIMD (a, b, z, z);
const u32x ax = (a0 << 0) | (a1 << 8);
const u32x bx = (b0 << 0) | (b1 << 8);
const u32x cx = (c0 << 0) | (c1 << 8);
const u32x dx = (d0 << 0) | (d1 << 8);
COMPARE_M_SIMD (ax, bx, cx, dx);
}
}
@ -240,24 +208,8 @@ KERNEL_FQ void m24900_s04 (KERN_ATTR_RULES ())
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
0,
0
};
/**
* lookup table
*/
const u8 sof_lut[64] =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x00, 0x00
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
};
/**
@ -358,37 +310,21 @@ KERNEL_FQ void m24900_s04 (KERN_ATTR_RULES ())
c += MD5M_C;
d += MD5M_D;
u16 t_abcd = ((a & 0xff) + ((a >> 8) & 0xff));
u8 a_12 = (t_abcd % 0x3e);
const u32x a0 = (((a >> 0) & 0xff) + ((a >> 8) & 0xff)) % 62;
const u32x a1 = (((a >> 16) & 0xff) + ((a >> 24) & 0xff)) % 62;
const u32x b0 = (((b >> 0) & 0xff) + ((b >> 8) & 0xff)) % 62;
const u32x b1 = (((b >> 16) & 0xff) + ((b >> 24) & 0xff)) % 62;
const u32x c0 = (((c >> 0) & 0xff) + ((c >> 8) & 0xff)) % 62;
const u32x c1 = (((c >> 16) & 0xff) + ((c >> 24) & 0xff)) % 62;
const u32x d0 = (((d >> 0) & 0xff) + ((d >> 8) & 0xff)) % 62;
const u32x d1 = (((d >> 16) & 0xff) + ((d >> 24) & 0xff)) % 62;
t_abcd = (((a >> 16 )& 0xff) + ((a >> 24) & 0xff));
u8 a_34 = (t_abcd % 0x3e);
t_abcd = ((b & 0xff) + ((b >> 8) & 0xff));
u8 b_12 = (t_abcd % 0x3e);
t_abcd = (((b >> 16) & 0xff) + ((b >> 24) & 0xff));
u8 b_34 = (t_abcd % 0x3e);
t_abcd = ((c & 0xff) + ((c >> 8) & 0xff));
u8 c_12 = (t_abcd % 0x3e);
t_abcd = (((c >> 16 )& 0xff) + ((c >> 24) & 0xff));
u8 c_34 = (t_abcd % 0x3e);
t_abcd = ((d & 0xff) + ((d >> 8) & 0xff));
u8 d_12 = (t_abcd % 0x3e);
t_abcd = (((d >> 16) & 0xff) + ((d >> 24) & 0xff));
u8 d_34 = (t_abcd % 0x3e);
a = (sof_lut[a_12]) + (sof_lut[a_34] << 8) + (sof_lut[b_12] << 16) + (sof_lut[b_34] << 24);
b = (sof_lut[c_12]) + (sof_lut[c_34] << 8) + (sof_lut[d_12] << 16) + (sof_lut[d_34] << 24);
u32x z = 0;
COMPARE_S_SIMD (a, b, z, z);
const u32x ax = (a0 << 0) | (a1 << 8);
const u32x bx = (b0 << 0) | (b1 << 8);
const u32x cx = (c0 << 0) | (c1 << 8);
const u32x dx = (d0 << 0) | (d1 << 8);
COMPARE_S_SIMD (ax, bx, cx, dx);
}
}

View File

@ -45,22 +45,6 @@ KERNEL_FQ void m24900_m04 (KERN_ATTR_BASIC ())
const u32 pw_l_len = pws[gid].pw_len & 63;
/**
* lookup table
*/
const u8 sof_lut[64] =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x00, 0x00
};
/**
* loop
*/
@ -218,36 +202,21 @@ KERNEL_FQ void m24900_m04 (KERN_ATTR_BASIC ())
c += MD5M_C;
d += MD5M_D;
u16 t_abcd = ((a & 0xff) + ((a >> 8) & 0xff));
u8 a_12 = (t_abcd % 0x3e);
const u32x a0 = (((a >> 0) & 0xff) + ((a >> 8) & 0xff)) % 62;
const u32x a1 = (((a >> 16) & 0xff) + ((a >> 24) & 0xff)) % 62;
const u32x b0 = (((b >> 0) & 0xff) + ((b >> 8) & 0xff)) % 62;
const u32x b1 = (((b >> 16) & 0xff) + ((b >> 24) & 0xff)) % 62;
const u32x c0 = (((c >> 0) & 0xff) + ((c >> 8) & 0xff)) % 62;
const u32x c1 = (((c >> 16) & 0xff) + ((c >> 24) & 0xff)) % 62;
const u32x d0 = (((d >> 0) & 0xff) + ((d >> 8) & 0xff)) % 62;
const u32x d1 = (((d >> 16) & 0xff) + ((d >> 24) & 0xff)) % 62;
t_abcd = (((a >> 16 )& 0xff) + ((a >> 24) & 0xff));
u8 a_34 = (t_abcd % 0x3e);
const u32x ax = (a0 << 0) | (a1 << 8);
const u32x bx = (b0 << 0) | (b1 << 8);
const u32x cx = (c0 << 0) | (c1 << 8);
const u32x dx = (d0 << 0) | (d1 << 8);
t_abcd = ((b & 0xff) + ((b >> 8) & 0xff));
u8 b_12 = (t_abcd % 0x3e);
t_abcd = (((b >> 16) & 0xff) + ((b >> 24) & 0xff));
u8 b_34 = (t_abcd % 0x3e);
t_abcd = ((c & 0xff) + ((c >> 8) & 0xff));
u8 c_12 = (t_abcd % 0x3e);
t_abcd = (((c >> 16 )& 0xff) + ((c >> 24) & 0xff));
u8 c_34 = (t_abcd % 0x3e);
t_abcd = ((d & 0xff) + ((d >> 8) & 0xff));
u8 d_12 = (t_abcd % 0x3e);
t_abcd = (((d >> 16) & 0xff) + ((d >> 24) & 0xff));
u8 d_34 = (t_abcd % 0x3e);
a = (sof_lut[a_12]) + (sof_lut[a_34] << 8) + (sof_lut[b_12] << 16) + (sof_lut[b_34] << 24);
b = (sof_lut[c_12]) + (sof_lut[c_34] << 8) + (sof_lut[d_12] << 16) + (sof_lut[d_34] << 24);
u32x z = 0;
COMPARE_M_SIMD (a, b, z, z);
COMPARE_M_SIMD (ax, bx, cx, dx);
}
}
@ -289,22 +258,6 @@ KERNEL_FQ void m24900_s04 (KERN_ATTR_BASIC ())
const u32 pw_l_len = pws[gid].pw_len & 63;
/**
* lookup table
*/
const u8 sof_lut[64] =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x00, 0x00
};
/**
* digest
*/
@ -313,8 +266,8 @@ KERNEL_FQ void m24900_s04 (KERN_ATTR_BASIC ())
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
0,
0
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3]
};
/**
@ -474,36 +427,21 @@ KERNEL_FQ void m24900_s04 (KERN_ATTR_BASIC ())
c += MD5M_C;
d += MD5M_D;
u16 t_abcd = ((a & 0xff) + ((a >> 8) & 0xff));
u8 a_12 = (t_abcd % 0x3e);
const u32x a0 = (((a >> 0) & 0xff) + ((a >> 8) & 0xff)) % 62;
const u32x a1 = (((a >> 16) & 0xff) + ((a >> 24) & 0xff)) % 62;
const u32x b0 = (((b >> 0) & 0xff) + ((b >> 8) & 0xff)) % 62;
const u32x b1 = (((b >> 16) & 0xff) + ((b >> 24) & 0xff)) % 62;
const u32x c0 = (((c >> 0) & 0xff) + ((c >> 8) & 0xff)) % 62;
const u32x c1 = (((c >> 16) & 0xff) + ((c >> 24) & 0xff)) % 62;
const u32x d0 = (((d >> 0) & 0xff) + ((d >> 8) & 0xff)) % 62;
const u32x d1 = (((d >> 16) & 0xff) + ((d >> 24) & 0xff)) % 62;
t_abcd = (((a >> 16 )& 0xff) + ((a >> 24) & 0xff));
u8 a_34 = (t_abcd % 0x3e);
const u32x ax = (a0 << 0) | (a1 << 8);
const u32x bx = (b0 << 0) | (b1 << 8);
const u32x cx = (c0 << 0) | (c1 << 8);
const u32x dx = (d0 << 0) | (d1 << 8);
t_abcd = ((b & 0xff) + ((b >> 8) & 0xff));
u8 b_12 = (t_abcd % 0x3e);
t_abcd = (((b >> 16) & 0xff) + ((b >> 24) & 0xff));
u8 b_34 = (t_abcd % 0x3e);
t_abcd = ((c & 0xff) + ((c >> 8) & 0xff));
u8 c_12 = (t_abcd % 0x3e);
t_abcd = (((c >> 16 )& 0xff) + ((c >> 24) & 0xff));
u8 c_34 = (t_abcd % 0x3e);
t_abcd = ((d & 0xff) + ((d >> 8) & 0xff));
u8 d_12 = (t_abcd % 0x3e);
t_abcd = (((d >> 16) & 0xff) + ((d >> 24) & 0xff));
u8 d_34 = (t_abcd % 0x3e);
a = (sof_lut[a_12]) + (sof_lut[a_34] << 8) + (sof_lut[b_12] << 16) + (sof_lut[b_34] << 24);
b = (sof_lut[c_12]) + (sof_lut[c_34] << 8) + (sof_lut[d_12] << 16) + (sof_lut[d_34] << 24);
u32x z = 0;
COMPARE_S_SIMD (a, b, z, z);
COMPARE_S_SIMD (ax, bx, cx, dx);
}
}

View File

@ -23,22 +23,6 @@ DECLSPEC void m24900m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
/**
* lookup table
*/
const u8 sof_lut[64] =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x00, 0x00
};
/**
* loop
*/
@ -157,36 +141,21 @@ DECLSPEC void m24900m (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER
c += MD5M_C;
d += MD5M_D;
u16 t_abcd = ((a & 0xff) + ((a >> 8) & 0xff));
u8 a_12 = (t_abcd % 0x3e);
const u32x a0 = (((a >> 0) & 0xff) + ((a >> 8) & 0xff)) % 62;
const u32x a1 = (((a >> 16) & 0xff) + ((a >> 24) & 0xff)) % 62;
const u32x b0 = (((b >> 0) & 0xff) + ((b >> 8) & 0xff)) % 62;
const u32x b1 = (((b >> 16) & 0xff) + ((b >> 24) & 0xff)) % 62;
const u32x c0 = (((c >> 0) & 0xff) + ((c >> 8) & 0xff)) % 62;
const u32x c1 = (((c >> 16) & 0xff) + ((c >> 24) & 0xff)) % 62;
const u32x d0 = (((d >> 0) & 0xff) + ((d >> 8) & 0xff)) % 62;
const u32x d1 = (((d >> 16) & 0xff) + ((d >> 24) & 0xff)) % 62;
t_abcd = (((a >> 16 )& 0xff) + ((a >> 24) & 0xff));
u8 a_34 = (t_abcd % 0x3e);
const u32x ax = (a0 << 0) | (a1 << 8);
const u32x bx = (b0 << 0) | (b1 << 8);
const u32x cx = (c0 << 0) | (c1 << 8);
const u32x dx = (d0 << 0) | (d1 << 8);
t_abcd = ((b & 0xff) + ((b >> 8) & 0xff));
u8 b_12 = (t_abcd % 0x3e);
t_abcd = (((b >> 16) & 0xff) + ((b >> 24) & 0xff));
u8 b_34 = (t_abcd % 0x3e);
t_abcd = ((c & 0xff) + ((c >> 8) & 0xff));
u8 c_12 = (t_abcd % 0x3e);
t_abcd = (((c >> 16 )& 0xff) + ((c >> 24) & 0xff));
u8 c_34 = (t_abcd % 0x3e);
t_abcd = ((d & 0xff) + ((d >> 8) & 0xff));
u8 d_12 = (t_abcd % 0x3e);
t_abcd = (((d >> 16) & 0xff) + ((d >> 24) & 0xff));
u8 d_34 = (t_abcd % 0x3e);
a = (sof_lut[a_12]) + (sof_lut[a_34] << 8) + (sof_lut[b_12] << 16) + (sof_lut[b_34] << 24);
b = (sof_lut[c_12]) + (sof_lut[c_34] << 8) + (sof_lut[d_12] << 16) + (sof_lut[d_34] << 24);
u32x z = 0;
COMPARE_M_SIMD (a, b, z, z);
COMPARE_M_SIMD (ax, bx, cx, dx);
}
}
@ -207,24 +176,8 @@ DECLSPEC void m24900s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R1],
0,
0
};
/**
* lookup table
*/
const u8 sof_lut[64] =
{
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74,
0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x00, 0x00
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R2],
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R3],
};
/**
@ -345,36 +298,21 @@ DECLSPEC void m24900s (u32 *w0, u32 *w1, u32 *w2, u32 *w3, const u32 pw_len, KER
c += MD5M_C;
d += MD5M_D;
u16 t_abcd = ((a & 0xff) + ((a >> 8) & 0xff));
u8 a_12 = (t_abcd % 0x3e);
const u32x a0 = (((a >> 0) & 0xff) + ((a >> 8) & 0xff)) % 62;
const u32x a1 = (((a >> 16) & 0xff) + ((a >> 24) & 0xff)) % 62;
const u32x b0 = (((b >> 0) & 0xff) + ((b >> 8) & 0xff)) % 62;
const u32x b1 = (((b >> 16) & 0xff) + ((b >> 24) & 0xff)) % 62;
const u32x c0 = (((c >> 0) & 0xff) + ((c >> 8) & 0xff)) % 62;
const u32x c1 = (((c >> 16) & 0xff) + ((c >> 24) & 0xff)) % 62;
const u32x d0 = (((d >> 0) & 0xff) + ((d >> 8) & 0xff)) % 62;
const u32x d1 = (((d >> 16) & 0xff) + ((d >> 24) & 0xff)) % 62;
t_abcd = (((a >> 16 )& 0xff) + ((a >> 24) & 0xff));
u8 a_34 = (t_abcd % 0x3e);
const u32x ax = (a0 << 0) | (a1 << 8);
const u32x bx = (b0 << 0) | (b1 << 8);
const u32x cx = (c0 << 0) | (c1 << 8);
const u32x dx = (d0 << 0) | (d1 << 8);
t_abcd = ((b & 0xff) + ((b >> 8) & 0xff));
u8 b_12 = (t_abcd % 0x3e);
t_abcd = (((b >> 16) & 0xff) + ((b >> 24) & 0xff));
u8 b_34 = (t_abcd % 0x3e);
t_abcd = ((c & 0xff) + ((c >> 8) & 0xff));
u8 c_12 = (t_abcd % 0x3e);
t_abcd = (((c >> 16 )& 0xff) + ((c >> 24) & 0xff));
u8 c_34 = (t_abcd % 0x3e);
t_abcd = ((d & 0xff) + ((d >> 8) & 0xff));
u8 d_12 = (t_abcd % 0x3e);
t_abcd = (((d >> 16) & 0xff) + ((d >> 24) & 0xff));
u8 d_34 = (t_abcd % 0x3e);
a = (sof_lut[a_12]) + (sof_lut[a_34] << 8) + (sof_lut[b_12] << 16) + (sof_lut[b_34] << 24);
b = (sof_lut[c_12]) + (sof_lut[c_34] << 8) + (sof_lut[d_12] << 16) + (sof_lut[d_34] << 24);
u32x z = 0;
COMPARE_S_SIMD (a, b, z, z);
COMPARE_S_SIMD (ax, bx, cx, dx);
}
}

View File

@ -14,8 +14,8 @@
- Added hash-mode: RAR3-p (Uncompressed)
- Added hash-mode: RSA/DSA/EC/OPENSSH Private Keys
- Added hash-mode: SQLCipher
- Added hash-mode: sha1(sha1($pass).$salt)
- Added hash-mode: Dahua Authentication MD5
- Added hash-mode: sha1(sha1($pass).$salt)
##
## Bugs

View File

@ -21,7 +21,6 @@ static const char *HASH_NAME = "Dahua Authentication MD5";
static const u64 KERN_TYPE = 24900;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_PRECOMPUTE_INIT
| OPTI_TYPE_MEET_IN_MIDDLE
| OPTI_TYPE_NOT_ITERATED
| OPTI_TYPE_NOT_SALTED
| OPTI_TYPE_RAW_HASH;
@ -47,6 +46,42 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
u32 dahua_decode (const u32 in)
{
if (in >= 'a')
{
return (in - 61);
}
else if (in >= 'A')
{
return (in - 55);
}
else
{
return (in - 48);
}
return -1;
}
u32 dahua_encode (const u32 in)
{
if (in < 10)
{
return (in + 48);
}
else if (in < 36)
{
return (in + 55);
}
else
{
return (in + 61);
}
return -1;
}
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len)
{
u32 *digest = (u32 *) digest_buf;
@ -63,16 +98,21 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
u8 temp_hex_buf[17] = { 0 };
const u8 *hash_pos = token.buf[0];
hex_encode ((u8 *) hash_pos, 8, temp_hex_buf);
const u32 a0 = dahua_decode (hash_pos[0]);
const u32 a1 = dahua_decode (hash_pos[1]);
const u32 b0 = dahua_decode (hash_pos[2]);
const u32 b1 = dahua_decode (hash_pos[3]);
const u32 c0 = dahua_decode (hash_pos[4]);
const u32 c1 = dahua_decode (hash_pos[5]);
const u32 d0 = dahua_decode (hash_pos[6]);
const u32 d1 = dahua_decode (hash_pos[7]);
digest[0] = hex_to_u32 (temp_hex_buf + 0);
digest[1] = hex_to_u32 (temp_hex_buf + 8);
digest[2] = 0;
digest[3] = 0;
digest[0] = (a0 << 0) | (a1 << 8);
digest[1] = (b0 << 0) | (b1 << 8);
digest[2] = (c0 << 0) | (c1 << 8);
digest[3] = (d0 << 0) | (d1 << 8);
return (PARSER_OK);
}
@ -81,24 +121,16 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
{
const u32 *digest = (const u32 *) digest_buf;
// we can not change anything in the original buffer, otherwise destroying sorting
// therefore create some local buffer
u32 tmp[4];
tmp[0] = digest[0];
tmp[1] = digest[1];
tmp[2] = 0;
tmp[3] = 0;
u8 *out_buf = (u8 *) line_buf;
u8 ht_buf[17] = { 0 };
u32_to_hex (tmp[0], ht_buf + 0);
u32_to_hex (tmp[1], ht_buf + 8);
hex_decode (ht_buf, 16, (u8 *) out_buf);
out_buf[0] = (u8) dahua_encode ((digest[0] >> 0) & 0xff);
out_buf[1] = (u8) dahua_encode ((digest[0] >> 8) & 0xff);
out_buf[2] = (u8) dahua_encode ((digest[1] >> 0) & 0xff);
out_buf[3] = (u8) dahua_encode ((digest[1] >> 8) & 0xff);
out_buf[4] = (u8) dahua_encode ((digest[2] >> 0) & 0xff);
out_buf[5] = (u8) dahua_encode ((digest[2] >> 8) & 0xff);
out_buf[6] = (u8) dahua_encode ((digest[3] >> 0) & 0xff);
out_buf[7] = (u8) dahua_encode ((digest[3] >> 8) & 0xff);
const int out_len = 8;

View File

@ -0,0 +1,58 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
use MIME::Base64 qw (encode_base64 decode_base64);
use Digest::MD5 qw (md5);
sub module_constraints { [[0, 256], [-1, -1], [0, 55], [-1, -1], [-1, -1]] }
my $itoa62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
sub module_generate_hash
{
my $word = shift;
my $digest = md5 ($word);
my @chksum;
for (my $i = 0, my $j = 0; $i < 16; $i += 2, $j += 1)
{
$chksum[$j] = (ord (substr ($digest, $i + 0, 1)) + ord (substr ($digest, $i + 1, 1))) % 62;
printf ("%d\n", $chksum[$j]);
$chksum[$j] = substr ($itoa62, $chksum[$j], 1);
}
my $res = join "", @chksum;
my $hash = sprintf ("%s", $res);
return $hash;
}
sub module_verify_hash
{
my $line = shift;
my ($hash, $word) = split (':', $line);
return unless defined $hash;
return unless defined $word;
my $word_packed = pack_if_HEX_notation ($word);
my $new_hash = module_generate_hash ($word_packed);
return ($new_hash, $word);
}
1;