Add DJB2 module

pull/3768/head
Dakota 11 months ago
parent 11502c77e2
commit 56a3450fb6

@ -0,0 +1,184 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include M2S(INCLUDE_PATH/inc_vendor.h)
#include M2S(INCLUDE_PATH/inc_types.h)
#include M2S(INCLUDE_PATH/inc_platform.cl)
#include M2S(INCLUDE_PATH/inc_common.cl)
#include M2S(INCLUDE_PATH/inc_rp_optimized.h)
#include M2S(INCLUDE_PATH/inc_rp_optimized.cl)
#include M2S(INCLUDE_PATH/inc_simd.cl)
#endif
DECLSPEC u32 djb2 (const u32 init, PRIVATE_AS const u32 *w, const u32 pw_len)
{
u32 hash = init;
for (u32 i = 0; i < pw_len; i += 4)
{
u32 tmp = w[i / 4];
const u32 left = pw_len - i;
const u32 c = (left > 4) ? 4 : left;
switch (c)
{
case 1:
hash *= 33; hash += (tmp >> 0) & 0xff;
break;
case 2:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
break;
case 3:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
break;
case 4:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
hash *= 33; hash += (tmp >> 24) & 0xff;
break;
}
}
return hash;
}
KERNEL_FQ void m66600_m04 (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
u32 pw_buf0[4];
u32 pw_buf1[4];
pw_buf0[0] = pws[gid].i[0];
pw_buf0[1] = pws[gid].i[1];
pw_buf0[2] = pws[gid].i[2];
pw_buf0[3] = pws[gid].i[3];
pw_buf1[0] = pws[gid].i[4];
pw_buf1[1] = pws[gid].i[5];
pw_buf1[2] = pws[gid].i[6];
pw_buf1[3] = pws[gid].i[7];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* loop
*/
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
{
u32x w[16] = { 0 };
const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w + 0, w + 4);
u32x hash = djb2 (0, w, out_len);
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m66600_m08 (KERN_ATTR_RULES ())
{
}
KERNEL_FQ void m66600_m16 (KERN_ATTR_RULES ())
{
}
KERNEL_FQ void m66600_s04 (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
u32 pw_buf0[4];
u32 pw_buf1[4];
pw_buf0[0] = pws[gid].i[0];
pw_buf0[1] = pws[gid].i[1];
pw_buf0[2] = pws[gid].i[2];
pw_buf0[3] = pws[gid].i[3];
pw_buf1[0] = pws[gid].i[4];
pw_buf1[1] = pws[gid].i[5];
pw_buf1[2] = pws[gid].i[6];
pw_buf1[3] = pws[gid].i[7];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
0,
0,
0
};
/**
* loop
*/
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
{
u32x w[16] = { 0 };
const u32x out_len = apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w + 0, w + 4);
u32x hash = djb2 (0, w, out_len);
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m66600_s08 (KERN_ATTR_RULES ())
{
}
KERNEL_FQ void m66600_s16 (KERN_ATTR_RULES ())
{
}

@ -0,0 +1,143 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include M2S(INCLUDE_PATH/inc_vendor.h)
#include M2S(INCLUDE_PATH/inc_types.h)
#include M2S(INCLUDE_PATH/inc_platform.cl)
#include M2S(INCLUDE_PATH/inc_common.cl)
#include M2S(INCLUDE_PATH/inc_rp.h)
#include M2S(INCLUDE_PATH/inc_rp.cl)
#include M2S(INCLUDE_PATH/inc_scalar.cl)
#include M2S(INCLUDE_PATH/inc_hash_md5.cl)
#endif
DECLSPEC u32 djb2 (const u32 init, PRIVATE_AS const u32 *w, const u32 pw_len)
{
u32 hash = init;
for (u32 i = 0; i < pw_len; i += 4)
{
u32 tmp = w[i / 4];
const u32 left = pw_len - i;
const u32 c = (left > 4) ? 4 : left;
switch (c)
{
case 1:
hash *= 33; hash += (tmp >> 0) & 0xff;
break;
case 2:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
break;
case 3:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
break;
case 4:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
hash *= 33; hash += (tmp >> 24) & 0xff;
break;
}
}
return hash;
}
KERNEL_FQ void m66600_mxx (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
/**
* base
*/
COPY_PW (pws[gid]);
/**
* loop
*/
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++)
{
pw_t tmp = PASTE_PW;
tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len);
const u32 hash = djb2 (0, tmp.i, tmp.pw_len);
const u32 r0 = hash;
const u32 r1 = 0;
const u32 r2 = 0;
const u32 r3 = 0;
COMPARE_M_SCALAR (r0, r1, r2, r3);
}
}
KERNEL_FQ void m66600_sxx (KERN_ATTR_RULES ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
0,
0,
0
};
/**
* base
*/
COPY_PW (pws[gid]);
/**
* loop
*/
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++)
{
pw_t tmp = PASTE_PW;
tmp.pw_len = apply_rules (rules_buf[il_pos].cmds, tmp.i, tmp.pw_len);
const u32 hash = djb2 (0, tmp.i, tmp.pw_len);
const u32 r0 = hash;
const u32 r1 = 0;
const u32 r2 = 0;
const u32 r3 = 0;
COMPARE_S_SCALAR (r0, r1, r2, r3);
}
}

@ -0,0 +1,170 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include M2S(INCLUDE_PATH/inc_vendor.h)
#include M2S(INCLUDE_PATH/inc_types.h)
#include M2S(INCLUDE_PATH/inc_platform.cl)
#include M2S(INCLUDE_PATH/inc_common.cl)
#include M2S(INCLUDE_PATH/inc_scalar.cl)
#include M2S(INCLUDE_PATH/inc_simd.cl)
#include M2S(INCLUDE_PATH/inc_hash_md5.cl)
#endif
DECLSPEC u32 djb2_g (const u32 init, GLOBAL_AS const u32 *w, const u32 pw_len)
{
u32 hash = init;
for (u32 i = 0; i < pw_len; i += 4)
{
u32 tmp = w[i / 4];
const u32 left = pw_len - i;
const u32 c = (left > 4) ? 4 : left;
switch (c)
{
case 1:
hash *= 33; hash += (tmp >> 0) & 0xff;
break;
case 2:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
break;
case 3:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
break;
case 4:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
hash *= 33; hash += (tmp >> 24) & 0xff;
break;
}
}
return hash;
}
KERNEL_FQ void m66600_m04 (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
/**
* loop
*/
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
{
u32 hash = 0;
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
{
hash = djb2_g (hash, pws[gid].i, pws[gid].pw_len);
hash = djb2_g (hash, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
}
else
{
hash = djb2_g (hash, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
hash = djb2_g (hash, pws[gid].i, pws[gid].pw_len);
}
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m66600_m08 (KERN_ATTR_BASIC ())
{
}
KERNEL_FQ void m66600_m16 (KERN_ATTR_BASIC ())
{
}
KERNEL_FQ void m66600_s04 (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
0,
0,
0
};
/**
* loop
*/
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
{
u32 hash = 0;
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
{
hash = djb2_g (hash, pws[gid].i, pws[gid].pw_len);
hash = djb2_g (hash, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
}
else
{
hash = djb2_g (hash, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
hash = djb2_g (hash, pws[gid].i, pws[gid].pw_len);
}
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m66600_s08 (KERN_ATTR_BASIC ())
{
}
KERNEL_FQ void m66600_s16 (KERN_ATTR_BASIC ())
{
}

@ -0,0 +1,143 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
//#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include M2S(INCLUDE_PATH/inc_vendor.h)
#include M2S(INCLUDE_PATH/inc_types.h)
#include M2S(INCLUDE_PATH/inc_platform.cl)
#include M2S(INCLUDE_PATH/inc_common.cl)
#include M2S(INCLUDE_PATH/inc_scalar.cl)
#include M2S(INCLUDE_PATH/inc_hash_md5.cl)
#endif
DECLSPEC u32 djb2_g (const u32 init, GLOBAL_AS const u32 *w, const u32 pw_len)
{
u32 hash = init;
for (u32 i = 0; i < pw_len; i += 4)
{
u32 tmp = w[i / 4];
const u32 left = pw_len - i;
const u32 c = (left > 4) ? 4 : left;
switch (c)
{
case 1:
hash *= 33; hash += (tmp >> 0) & 0xff;
break;
case 2:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
break;
case 3:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
break;
case 4:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
hash *= 33; hash += (tmp >> 24) & 0xff;
break;
}
}
return hash;
}
KERNEL_FQ void m66600_mxx (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
/**
* loop
*/
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++)
{
u32 hash = 0;
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
{
hash = djb2_g (hash, pws[gid].i, pws[gid].pw_len);
hash = djb2_g (hash, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
}
else
{
hash = djb2_g (hash, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
hash = djb2_g (hash, pws[gid].i, pws[gid].pw_len);
}
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_M_SCALAR (r0, r1, r2, r3);
}
}
KERNEL_FQ void m66600_sxx (KERN_ATTR_BASIC ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
0,
0,
0
};
/**
* loop
*/
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos++)
{
u32 hash = 0;
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
{
hash = djb2_g (hash, pws[gid].i, pws[gid].pw_len);
hash = djb2_g (hash, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
}
else
{
hash = djb2_g (hash, combs_buf[il_pos].i, combs_buf[il_pos].pw_len);
hash = djb2_g (hash, pws[gid].i, pws[gid].pw_len);
}
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_S_SCALAR (r0, r1, r2, r3);
}
}

@ -0,0 +1,381 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include M2S(INCLUDE_PATH/inc_vendor.h)
#include M2S(INCLUDE_PATH/inc_types.h)
#include M2S(INCLUDE_PATH/inc_platform.cl)
#include M2S(INCLUDE_PATH/inc_common.cl)
#include M2S(INCLUDE_PATH/inc_simd.cl)
#include M2S(INCLUDE_PATH/inc_hash_md5.cl)
#endif
DECLSPEC u32x djb2_w0 (const u32x init, const u32x w0, PRIVATE_AS const u32 *w, const u32 pw_len)
{
u32x hash = init;
u32x tmp0 = w0;
const u32 c0 = (pw_len > 4) ? 4 : pw_len;
switch (c0)
{
case 1: hash += tmp0 & 0xff; tmp0 >>= 8; break;
case 2: hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; break;
case 3: hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; break;
case 4: hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; break;
}
for (u32 i = 4; i < pw_len; i += 4)
{
u32 tmp = w[i / 4];
const u32 left = pw_len - i;
const u32 c = (left > 4) ? 4 : left;
switch (c)
{
case 1:
hash *= 33; hash += (tmp >> 0) & 0xff;
break;
case 2:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
break;
case 3:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
break;
case 4:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
hash *= 33; hash += (tmp >> 24) & 0xff;
break;
}
}
return hash;
}
DECLSPEC void m6660m (PRIVATE_AS const u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTOR ())
{
/**
* modifiers are taken from args
*/
/**
* loop
*/
u32 w0l = w[0];
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
const u32x hash = djb2_w0 (0, w0, w, pw_len);
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
DECLSPEC void m6660s (PRIVATE_AS const u32 *w, const u32 pw_len, KERN_ATTR_FUNC_VECTOR ())
{
/**
* modifiers are taken from args
*/
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
0,
0,
0
};
/**
* loop
*/
u32 w0l = w[0];
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
const u32x hash = djb2_w0 (0, w0, w, pw_len);
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m6660_m04 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
const u64 lsz = get_local_size (0);
if (gid >= GID_CNT) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = 0;
w[ 5] = 0;
w[ 6] = 0;
w[ 7] = 0;
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = pws[gid].i[14];
w[15] = 0;
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m6660m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz);
}
KERNEL_FQ void m6660_m08 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
const u64 lsz = get_local_size (0);
if (gid >= GID_CNT) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = pws[gid].i[14];
w[15] = 0;
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m6660m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz);
}
KERNEL_FQ void m6660_m16 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
const u64 lsz = get_local_size (0);
if (gid >= GID_CNT) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = pws[gid].i[ 8];
w[ 9] = pws[gid].i[ 9];
w[10] = pws[gid].i[10];
w[11] = pws[gid].i[11];
w[12] = pws[gid].i[12];
w[13] = pws[gid].i[13];
w[14] = pws[gid].i[14];
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m6660m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz);
}
KERNEL_FQ void m6660_s04 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
const u64 lsz = get_local_size (0);
if (gid >= GID_CNT) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = 0;
w[ 5] = 0;
w[ 6] = 0;
w[ 7] = 0;
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = pws[gid].i[14];
w[15] = 0;
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m6660s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz);
}
KERNEL_FQ void m6660_s08 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
const u64 lsz = get_local_size (0);
if (gid >= GID_CNT) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = pws[gid].i[14];
w[15] = 0;
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m6660s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz);
}
KERNEL_FQ void m6660_s16 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
const u64 lsz = get_local_size (0);
if (gid >= GID_CNT) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = pws[gid].i[ 8];
w[ 9] = pws[gid].i[ 9];
w[10] = pws[gid].i[10];
w[11] = pws[gid].i[11];
w[12] = pws[gid].i[12];
w[13] = pws[gid].i[13];
w[14] = pws[gid].i[14];
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m6660s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, kernel_param, gid, lid, lsz);
}

@ -0,0 +1,177 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include M2S(INCLUDE_PATH/inc_vendor.h)
#include M2S(INCLUDE_PATH/inc_types.h)
#include M2S(INCLUDE_PATH/inc_platform.cl)
#include M2S(INCLUDE_PATH/inc_common.cl)
#include M2S(INCLUDE_PATH/inc_simd.cl)
#include M2S(INCLUDE_PATH/inc_hash_md5.cl)
#endif
DECLSPEC u32x djb2_w0 (const u32x init, const u32x w0, PRIVATE_AS const u32 *w, const u32 pw_len)
{
u32x hash = init;
u32x tmp0 = w0;
const u32 c0 = (pw_len > 4) ? 4 : pw_len;
switch (c0)
{
case 1: hash += tmp0 & 0xff; tmp0 >>= 8; break;
case 2: hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; break;
case 3: hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; break;
case 4: hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; hash *= 33;
hash += tmp0 & 0xff; tmp0 >>= 8; break;
}
for (u32 i = 4; i < pw_len; i += 4)
{
u32 tmp = w[i / 4];
const u32 left = pw_len - i;
const u32 c = (left > 4) ? 4 : left;
switch (c)
{
case 1:
hash *= 33; hash += (tmp >> 0) & 0xff;
break;
case 2:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
break;
case 3:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
break;
case 4:
hash *= 33; hash += (tmp >> 0) & 0xff;
hash *= 33; hash += (tmp >> 8) & 0xff;
hash *= 33; hash += (tmp >> 16) & 0xff;
hash *= 33; hash += (tmp >> 24) & 0xff;
break;
}
}
return hash;
}
KERNEL_FQ void m66600_mxx (KERN_ATTR_VECTOR ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
/**
* base
*/
const u32 pw_len = pws[gid].pw_len;
u32 w[64] = { 0 };
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
{
w[idx] = pws[gid].i[idx];
}
/**
* loop
*/
u32x w0l = w[0];
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
u32x hash = djb2_w0 (0, w0, w, pw_len);
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m66600_sxx (KERN_ATTR_VECTOR ())
{
/**
* modifier
*/
const u64 lid = get_local_id (0);
const u64 gid = get_global_id (0);
if (gid >= GID_CNT) return;
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
0,
0,
0
};
/**
* base
*/
const u32 pw_len = pws[gid].pw_len;
u32 w[64] = { 0 };
for (u32 i = 0, idx = 0; i < pw_len; i += 4, idx += 1)
{
w[idx] = pws[gid].i[idx];
}
/**
* loop
*/
u32x w0l = w[0];
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
u32x hash = djb2_w0 (0, w0, w, pw_len);
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}

@ -0,0 +1,165 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "modules.h"
#include "bitops.h"
#include "convert.h"
#include "shared.h"
static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL;
static const u32 DGST_POS0 = 0;
static const u32 DGST_POS1 = 1;
static const u32 DGST_POS2 = 2;
static const u32 DGST_POS3 = 3;
static const u32 DGST_SIZE = DGST_SIZE_4_4;
static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_CHECKSUM;
static const char *HASH_NAME = "DBJ2";
static const u64 KERN_TYPE = 66600;
static const u32 OPTI_TYPE = OPTI_TYPE_RAW_HASH;
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
| OPTS_TYPE_PT_GENERATE_LE
| OPTS_TYPE_SUGGEST_KG;
static const u32 SALT_TYPE = SALT_TYPE_NONE;
static const char *ST_PASS = "hashcat";
static const char *ST_HASH = "3048cedc";
u32 module_attack_exec (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 ATTACK_EXEC; }
u32 module_dgst_pos0 (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 DGST_POS0; }
u32 module_dgst_pos1 (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 DGST_POS1; }
u32 module_dgst_pos2 (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 DGST_POS2; }
u32 module_dgst_pos3 (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 DGST_POS3; }
u32 module_dgst_size (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 DGST_SIZE; }
u32 module_hash_category (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 HASH_CATEGORY; }
const char *module_hash_name (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 HASH_NAME; }
u64 module_kern_type (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 KERN_TYPE; }
u32 module_opti_type (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 OPTI_TYPE; }
u64 module_opts_type (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 OPTS_TYPE; }
u32 module_salt_type (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 SALT_TYPE; }
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; }
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;
hc_token_t token;
memset (&token, 0, sizeof (hc_token_t));
token.token_cnt = 1;
token.len[0] = 8;
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
| TOKEN_ATTR_VERIFY_HEX;
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
const u8 *hash_pos = token.buf[0];
digest[0] = hex_to_u32 (hash_pos);
digest[0] = byte_swap_32 (digest[0]);
return (PARSER_OK);
}
int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size)
{
const u32 *digest = (const u32 *) digest_buf;
const u32 tmp = byte_swap_32 (digest[0]);
u8 *out_buf = (u8 *) line_buf;
u32_to_hex (tmp, out_buf);
const int out_len = 8;
return out_len;
}
void module_init (module_ctx_t *module_ctx)
{
module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT;
module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT;
module_ctx->module_attack_exec = module_attack_exec;
module_ctx->module_benchmark_esalt = MODULE_DEFAULT;
module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT;
module_ctx->module_benchmark_mask = MODULE_DEFAULT;
module_ctx->module_benchmark_charset = MODULE_DEFAULT;
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
module_ctx->module_deep_comp_kernel = MODULE_DEFAULT;
module_ctx->module_deprecated_notice = MODULE_DEFAULT;
module_ctx->module_dgst_pos0 = module_dgst_pos0;
module_ctx->module_dgst_pos1 = module_dgst_pos1;
module_ctx->module_dgst_pos2 = module_dgst_pos2;
module_ctx->module_dgst_pos3 = module_dgst_pos3;
module_ctx->module_dgst_size = module_dgst_size;
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
module_ctx->module_esalt_size = MODULE_DEFAULT;
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
module_ctx->module_forced_outfile_format = MODULE_DEFAULT;
module_ctx->module_hash_binary_count = MODULE_DEFAULT;
module_ctx->module_hash_binary_parse = MODULE_DEFAULT;
module_ctx->module_hash_binary_save = MODULE_DEFAULT;
module_ctx->module_hash_decode_postprocess = MODULE_DEFAULT;
module_ctx->module_hash_decode_potfile = MODULE_DEFAULT;
module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT;
module_ctx->module_hash_decode = module_hash_decode;
module_ctx->module_hash_encode_status = MODULE_DEFAULT;
module_ctx->module_hash_encode_potfile = MODULE_DEFAULT;
module_ctx->module_hash_encode = module_hash_encode;
module_ctx->module_hash_init_selftest = MODULE_DEFAULT;
module_ctx->module_hash_mode = MODULE_DEFAULT;
module_ctx->module_hash_category = module_hash_category;
module_ctx->module_hash_name = module_hash_name;
module_ctx->module_hashes_count_min = MODULE_DEFAULT;
module_ctx->module_hashes_count_max = MODULE_DEFAULT;
module_ctx->module_hlfmt_disable = MODULE_DEFAULT;
module_ctx->module_hook_extra_param_size = MODULE_DEFAULT;
module_ctx->module_hook_extra_param_init = MODULE_DEFAULT;
module_ctx->module_hook_extra_param_term = MODULE_DEFAULT;
module_ctx->module_hook12 = MODULE_DEFAULT;
module_ctx->module_hook23 = MODULE_DEFAULT;
module_ctx->module_hook_salt_size = MODULE_DEFAULT;
module_ctx->module_hook_size = MODULE_DEFAULT;
module_ctx->module_jit_build_options = MODULE_DEFAULT;
module_ctx->module_jit_cache_disable = MODULE_DEFAULT;
module_ctx->module_kernel_accel_max = MODULE_DEFAULT;
module_ctx->module_kernel_accel_min = MODULE_DEFAULT;
module_ctx->module_kernel_loops_max = MODULE_DEFAULT;
module_ctx->module_kernel_loops_min = MODULE_DEFAULT;
module_ctx->module_kernel_threads_max = MODULE_DEFAULT;
module_ctx->module_kernel_threads_min = MODULE_DEFAULT;
module_ctx->module_kern_type = module_kern_type;
module_ctx->module_kern_type_dynamic = MODULE_DEFAULT;
module_ctx->module_opti_type = module_opti_type;
module_ctx->module_opts_type = module_opts_type;
module_ctx->module_outfile_check_disable = MODULE_DEFAULT;
module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT;
module_ctx->module_potfile_custom_check = MODULE_DEFAULT;
module_ctx->module_potfile_disable = MODULE_DEFAULT;
module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT;
module_ctx->module_pwdump_column = MODULE_DEFAULT;
module_ctx->module_pw_max = MODULE_DEFAULT;
module_ctx->module_pw_min = MODULE_DEFAULT;
module_ctx->module_salt_max = MODULE_DEFAULT;
module_ctx->module_salt_min = MODULE_DEFAULT;
module_ctx->module_salt_type = module_salt_type;
module_ctx->module_separator = MODULE_DEFAULT;
module_ctx->module_st_hash = module_st_hash;
module_ctx->module_st_pass = module_st_pass;
module_ctx->module_tmp_size = MODULE_DEFAULT;
module_ctx->module_unstable_warning = MODULE_DEFAULT;
module_ctx->module_warmup_disable = MODULE_DEFAULT;
}

@ -0,0 +1,57 @@
#!/usr/bin/env perl
##
## Author......: See docs/credits.txt
## License.....: MIT
##
use strict;
use warnings;
sub module_constraints { [[0, 255], [-1, -1], [0, 55], [-1, -1], [-1, -1]] }
sub djb2
{
my $word = shift;
my @chars = unpack ("C*", $word);
my $hash = 0;
while (my $c = shift @chars)
{
$hash = ($hash * 33) & 0xffffffff;
$hash = ($hash + $c) & 0xffffffff;
}
return $hash;
}
sub module_generate_hash
{
my $word = shift;
my $digest = djb2 ($word);
my $hash = sprintf ("%08x", $digest);
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;
Loading…
Cancel
Save