mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-24 15:38:47 +00:00
Merge pull request #4201 from matrix/RC4_KPA
Added hash-modes: RC4 40-bit DropN, RC4 72-bit DropN, RC4 104-bit DropN
This commit is contained in:
commit
b9938f34d6
@ -136,6 +136,113 @@ DECLSPEC void rc4_init_40 (LOCAL_AS u32 *S, PRIVATE_AS const u32 *key, const u64
|
||||
j += GET_KEY8 (S, 255, lid) + d0; rc4_swap (S, 255, j, lid);
|
||||
}
|
||||
|
||||
DECLSPEC void rc4_init_72 (LOCAL_AS u32 *S, PRIVATE_AS const u32 *key, const u64 lid)
|
||||
{
|
||||
u32 v = 0x03020100;
|
||||
u32 a = 0x04040404;
|
||||
|
||||
#ifdef _unroll
|
||||
#pragma unroll
|
||||
#endif
|
||||
for (u8 i = 0; i < 64; i++)
|
||||
{
|
||||
SET_KEY32 (S, i, v, lid); v += a;
|
||||
}
|
||||
|
||||
const u8 d0 = v8a_from_v32_S (key[0]);
|
||||
const u8 d1 = v8b_from_v32_S (key[0]);
|
||||
const u8 d2 = v8c_from_v32_S (key[0]);
|
||||
const u8 d3 = v8d_from_v32_S (key[0]);
|
||||
const u8 d4 = v8a_from_v32_S (key[1]);
|
||||
const u8 d5 = v8b_from_v32_S (key[1]);
|
||||
const u8 d6 = v8c_from_v32_S (key[1]);
|
||||
const u8 d7 = v8d_from_v32_S (key[1]);
|
||||
const u8 d8 = v8a_from_v32_S (key[2]);
|
||||
|
||||
u8 j = 0;
|
||||
|
||||
#ifdef _unroll
|
||||
#pragma unroll
|
||||
#endif
|
||||
for (u32 i = 0; i < 252; i += 9)
|
||||
{
|
||||
j += GET_KEY8 (S, i + 0, lid) + d0; rc4_swap (S, i + 0, j, lid);
|
||||
j += GET_KEY8 (S, i + 1, lid) + d1; rc4_swap (S, i + 1, j, lid);
|
||||
j += GET_KEY8 (S, i + 2, lid) + d2; rc4_swap (S, i + 2, j, lid);
|
||||
j += GET_KEY8 (S, i + 3, lid) + d3; rc4_swap (S, i + 3, j, lid);
|
||||
j += GET_KEY8 (S, i + 4, lid) + d4; rc4_swap (S, i + 4, j, lid);
|
||||
j += GET_KEY8 (S, i + 5, lid) + d5; rc4_swap (S, i + 5, j, lid);
|
||||
j += GET_KEY8 (S, i + 6, lid) + d6; rc4_swap (S, i + 6, j, lid);
|
||||
j += GET_KEY8 (S, i + 7, lid) + d7; rc4_swap (S, i + 7, j, lid);
|
||||
j += GET_KEY8 (S, i + 8, lid) + d8; rc4_swap (S, i + 8, j, lid);
|
||||
}
|
||||
|
||||
j += GET_KEY8 (S, 252, lid) + d0; rc4_swap (S, 252, j, lid);
|
||||
j += GET_KEY8 (S, 253, lid) + d1; rc4_swap (S, 253, j, lid);
|
||||
j += GET_KEY8 (S, 254, lid) + d2; rc4_swap (S, 254, j, lid);
|
||||
j += GET_KEY8 (S, 255, lid) + d3; rc4_swap (S, 255, j, lid);
|
||||
}
|
||||
|
||||
DECLSPEC void rc4_init_104 (LOCAL_AS u32 *S, PRIVATE_AS const u32 *key, const u64 lid)
|
||||
{
|
||||
u32 v = 0x03020100;
|
||||
u32 a = 0x04040404;
|
||||
|
||||
#ifdef _unroll
|
||||
#pragma unroll
|
||||
#endif
|
||||
for (u8 i = 0; i < 64; i++)
|
||||
{
|
||||
SET_KEY32 (S, i, v, lid); v += a;
|
||||
}
|
||||
|
||||
const u8 d0 = v8a_from_v32_S(key[0]);
|
||||
const u8 d1 = v8b_from_v32_S(key[0]);
|
||||
const u8 d2 = v8c_from_v32_S(key[0]);
|
||||
const u8 d3 = v8d_from_v32_S(key[0]);
|
||||
const u8 d4 = v8a_from_v32_S(key[1]);
|
||||
const u8 d5 = v8b_from_v32_S(key[1]);
|
||||
const u8 d6 = v8c_from_v32_S(key[1]);
|
||||
const u8 d7 = v8d_from_v32_S(key[1]);
|
||||
const u8 d8 = v8a_from_v32_S(key[2]);
|
||||
const u8 d9 = v8b_from_v32_S(key[2]);
|
||||
const u8 d10 = v8c_from_v32_S(key[2]);
|
||||
const u8 d11 = v8d_from_v32_S(key[2]);
|
||||
const u8 d12 = v8a_from_v32_S(key[3]);
|
||||
|
||||
u8 j = 0;
|
||||
|
||||
#ifdef _unroll
|
||||
#pragma unroll
|
||||
#endif
|
||||
for (u32 i = 0; i < 247; i += 13)
|
||||
{
|
||||
j += GET_KEY8(S, i + 0, lid) + d0; rc4_swap(S, i + 0, j, lid);
|
||||
j += GET_KEY8(S, i + 1, lid) + d1; rc4_swap(S, i + 1, j, lid);
|
||||
j += GET_KEY8(S, i + 2, lid) + d2; rc4_swap(S, i + 2, j, lid);
|
||||
j += GET_KEY8(S, i + 3, lid) + d3; rc4_swap(S, i + 3, j, lid);
|
||||
j += GET_KEY8(S, i + 4, lid) + d4; rc4_swap(S, i + 4, j, lid);
|
||||
j += GET_KEY8(S, i + 5, lid) + d5; rc4_swap(S, i + 5, j, lid);
|
||||
j += GET_KEY8(S, i + 6, lid) + d6; rc4_swap(S, i + 6, j, lid);
|
||||
j += GET_KEY8(S, i + 7, lid) + d7; rc4_swap(S, i + 7, j, lid);
|
||||
j += GET_KEY8(S, i + 8, lid) + d8; rc4_swap(S, i + 8, j, lid);
|
||||
j += GET_KEY8(S, i + 9, lid) + d9; rc4_swap(S, i + 9, j, lid);
|
||||
j += GET_KEY8(S, i + 10, lid) + d10; rc4_swap(S, i + 10, j, lid);
|
||||
j += GET_KEY8(S, i + 11, lid) + d11; rc4_swap(S, i + 11, j, lid);
|
||||
j += GET_KEY8(S, i + 12, lid) + d12; rc4_swap(S, i + 12, j, lid);
|
||||
}
|
||||
|
||||
j += GET_KEY8(S, 247, lid) + d0; rc4_swap(S, 247, j, lid);
|
||||
j += GET_KEY8(S, 248, lid) + d1; rc4_swap(S, 248, j, lid);
|
||||
j += GET_KEY8(S, 249, lid) + d2; rc4_swap(S, 249, j, lid);
|
||||
j += GET_KEY8(S, 250, lid) + d3; rc4_swap(S, 250, j, lid);
|
||||
j += GET_KEY8(S, 251, lid) + d4; rc4_swap(S, 251, j, lid);
|
||||
j += GET_KEY8(S, 252, lid) + d5; rc4_swap(S, 252, j, lid);
|
||||
j += GET_KEY8(S, 253, lid) + d6; rc4_swap(S, 253, j, lid);
|
||||
j += GET_KEY8(S, 254, lid) + d7; rc4_swap(S, 254, j, lid);
|
||||
j += GET_KEY8(S, 255, lid) + d8; rc4_swap(S, 255, j, lid);
|
||||
}
|
||||
|
||||
DECLSPEC void rc4_init_128 (LOCAL_AS u32 *S, PRIVATE_AS const u32 *key, const u64 lid)
|
||||
{
|
||||
u32 v = 0x03020100;
|
||||
@ -196,6 +303,27 @@ DECLSPEC void rc4_swap (LOCAL_AS u32 *S, const u8 i, const u8 j, const u64 lid)
|
||||
SET_KEY8 (S, j, tmp, lid);
|
||||
}
|
||||
|
||||
DECLSPEC void rc4_dropN (LOCAL_AS u32 *S, PRIVATE_AS u8 *i, PRIVATE_AS u8 *j, const u32 n, const u64 lid)
|
||||
{
|
||||
u8 a = *i;
|
||||
u8 b = *j;
|
||||
|
||||
for (u32 z = 0; z < n; z++)
|
||||
{
|
||||
a += 1;
|
||||
b += GET_KEY8 (S, a, lid);
|
||||
|
||||
rc4_swap (S, a, b, lid);
|
||||
|
||||
u8 idx = GET_KEY8 (S, a, lid) + GET_KEY8 (S, b, lid);
|
||||
|
||||
GET_KEY8 (S, idx, lid);
|
||||
}
|
||||
|
||||
*i = a;
|
||||
*j = b;
|
||||
}
|
||||
|
||||
DECLSPEC u8 rc4_next_16 (LOCAL_AS u32 *S, const u8 i, const u8 j, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, const u64 lid)
|
||||
{
|
||||
u8 a = i;
|
||||
|
@ -11,8 +11,11 @@ DECLSPEC void SET_KEY8 (LOCAL_AS u32 *S, const u8 k, const u8 v, const u64 lid)
|
||||
DECLSPEC void SET_KEY32 (LOCAL_AS u32 *S, const u8 k, const u32 v, const u64 lid);
|
||||
|
||||
DECLSPEC void rc4_init_40 (LOCAL_AS u32 *S, PRIVATE_AS const u32 *key, const u64 lid);
|
||||
DECLSPEC void rc4_init_72 (LOCAL_AS u32 *S, PRIVATE_AS const u32 *key, const u64 lid);
|
||||
DECLSPEC void rc4_init_104 (LOCAL_AS u32 *S, PRIVATE_AS const u32 *key, const u64 lid);
|
||||
DECLSPEC void rc4_init_128 (LOCAL_AS u32 *S, PRIVATE_AS const u32 *key, const u64 lid);
|
||||
DECLSPEC void rc4_swap (LOCAL_AS u32 *S, const u8 i, const u8 j, const u64 lid);
|
||||
DECLSPEC void rc4_dropN (LOCAL_AS u32 *S, PRIVATE_AS u8 *i, PRIVATE_AS u8 *j, const u32 n, const u64 lid);
|
||||
DECLSPEC u8 rc4_next_16 (LOCAL_AS u32 *S, const u8 i, const u8 j, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, const u64 lid);
|
||||
DECLSPEC u8 rc4_next_16_global (LOCAL_AS u32 *S, const u8 i, const u8 j, GLOBAL_AS const u32 *in, PRIVATE_AS u32 *out, const u64 lid);
|
||||
|
||||
|
239
OpenCL/m40000_a0-optimized.cl
Normal file
239
OpenCL/m40000_a0-optimized.cl
Normal file
@ -0,0 +1,239 @@
|
||||
/**
|
||||
* 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)
|
||||
#include M2S(INCLUDE_PATH/inc_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[8] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m04 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
*/
|
||||
|
||||
const u64 lid = get_local_id (0);
|
||||
const u64 gid = get_global_id (0);
|
||||
|
||||
if (gid >= GID_CNT) return;
|
||||
|
||||
u32 pw_buf0[4];
|
||||
u32 pw_buf1[4] = { 0 };
|
||||
|
||||
pw_buf0[0] = pws[gid].i[0];
|
||||
pw_buf0[1] = pws[gid].i[1];
|
||||
pw_buf0[2] = 0;
|
||||
pw_buf0[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
u32x w0[4] = { 0 };
|
||||
u32x w1[4] = { 0 };
|
||||
|
||||
apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
|
||||
|
||||
rc4_init_40 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 5)
|
||||
{
|
||||
out[1] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[2] = out[3] = 0;
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m08 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m16 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s04 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
*/
|
||||
|
||||
const u64 lid = get_local_id (0);
|
||||
const u64 gid = get_global_id (0);
|
||||
|
||||
if (gid >= GID_CNT) return;
|
||||
|
||||
u32 pw_buf0[4];
|
||||
u32 pw_buf1[4] = { 0 };
|
||||
|
||||
pw_buf0[0] = pws[gid].i[0];
|
||||
pw_buf0[1] = pws[gid].i[1];
|
||||
pw_buf0[2] = 0;
|
||||
pw_buf0[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
u32x w0[4] = { 0 };
|
||||
u32x w1[4] = { 0 };
|
||||
|
||||
apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
|
||||
|
||||
/**
|
||||
* pdf
|
||||
*/
|
||||
|
||||
rc4_init_40 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 5)
|
||||
{
|
||||
out[1] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[2] = out[3] = 0;
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s08 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s16 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
335
OpenCL/m40000_a1-optimized.cl
Normal file
335
OpenCL/m40000_a1-optimized.cl
Normal file
@ -0,0 +1,335 @@
|
||||
/**
|
||||
* 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_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[8] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
*/
|
||||
|
||||
const u64 lid = get_local_id (0);
|
||||
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_l_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
|
||||
|
||||
const u32x pw_len = (pw_l_len + pw_r_len) & 63;
|
||||
|
||||
/**
|
||||
* concat password candidate
|
||||
*/
|
||||
|
||||
u32x wordl0[4] = { 0 };
|
||||
u32x wordl1[4] = { 0 };
|
||||
u32x wordl2[4] = { 0 };
|
||||
u32x wordl3[4] = { 0 };
|
||||
|
||||
wordl0[0] = pw_buf0[0];
|
||||
wordl0[1] = pw_buf0[1];
|
||||
wordl0[2] = pw_buf0[2];
|
||||
wordl0[3] = pw_buf0[3];
|
||||
wordl1[0] = pw_buf1[0];
|
||||
wordl1[1] = pw_buf1[1];
|
||||
wordl1[2] = pw_buf1[2];
|
||||
wordl1[3] = pw_buf1[3];
|
||||
|
||||
u32x wordr0[4] = { 0 };
|
||||
u32x wordr1[4] = { 0 };
|
||||
u32x wordr2[4] = { 0 };
|
||||
u32x wordr3[4] = { 0 };
|
||||
|
||||
wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
|
||||
wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
|
||||
wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
|
||||
wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
|
||||
wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
|
||||
wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
|
||||
wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
|
||||
wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
|
||||
|
||||
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
|
||||
}
|
||||
|
||||
u32x w0[4];
|
||||
|
||||
w0[0] = wordl0[0] | wordr0[0];
|
||||
w0[1] = wordl0[1] | wordr0[1];
|
||||
w0[2] = 0;
|
||||
w0[3] = 0;
|
||||
|
||||
rc4_init_40 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 5)
|
||||
{
|
||||
out[1] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[2] = out[3] = 0;
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
*/
|
||||
|
||||
const u64 lid = get_local_id (0);
|
||||
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_l_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
|
||||
|
||||
const u32x pw_len = (pw_l_len + pw_r_len) & 63;
|
||||
|
||||
/**
|
||||
* concat password candidate
|
||||
*/
|
||||
|
||||
u32x wordl0[4] = { 0 };
|
||||
u32x wordl1[4] = { 0 };
|
||||
u32x wordl2[4] = { 0 };
|
||||
u32x wordl3[4] = { 0 };
|
||||
|
||||
wordl0[0] = pw_buf0[0];
|
||||
wordl0[1] = pw_buf0[1];
|
||||
wordl0[2] = pw_buf0[2];
|
||||
wordl0[3] = pw_buf0[3];
|
||||
wordl1[0] = pw_buf1[0];
|
||||
wordl1[1] = pw_buf1[1];
|
||||
wordl1[2] = pw_buf1[2];
|
||||
wordl1[3] = pw_buf1[3];
|
||||
|
||||
u32x wordr0[4] = { 0 };
|
||||
u32x wordr1[4] = { 0 };
|
||||
u32x wordr2[4] = { 0 };
|
||||
u32x wordr3[4] = { 0 };
|
||||
|
||||
wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
|
||||
wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
|
||||
wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
|
||||
wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
|
||||
wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
|
||||
wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
|
||||
wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
|
||||
wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
|
||||
|
||||
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
|
||||
}
|
||||
|
||||
u32x w0[4];
|
||||
|
||||
w0[0] = wordl0[0] | wordr0[0];
|
||||
w0[1] = wordl0[1] | wordr0[1];
|
||||
w0[2] = 0;
|
||||
w0[3] = 0;
|
||||
|
||||
rc4_init_40 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 5)
|
||||
{
|
||||
out[1] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[2] = out[3] = 0;
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
487
OpenCL/m40000_a3-optimized.cl
Normal file
487
OpenCL/m40000_a3-optimized.cl
Normal file
@ -0,0 +1,487 @@
|
||||
/**
|
||||
* 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_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[8] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
DECLSPEC void m40000m (LOCAL_AS u32 *S, PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* modifiers are taken from args
|
||||
*/
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
u32 w0l = w0[0];
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32 w0r = ix_create_bft (bfs_buf, il_pos);
|
||||
|
||||
const u32 w0lr = w0l | w0r;
|
||||
|
||||
w0[0] = w0lr;
|
||||
|
||||
rc4_init_40 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 5)
|
||||
{
|
||||
out[1] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[2] = out[3] = 0;
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
DECLSPEC void m40000s (LOCAL_AS u32 *S, PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* modifiers are taken from args
|
||||
*/
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
u32 w0l = w0[0];
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32 w0r = ix_create_bft (bfs_buf, il_pos);
|
||||
|
||||
const u32 w0lr = w0l | w0r;
|
||||
|
||||
w0[0] = w0lr;
|
||||
|
||||
rc4_init_40 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 5)
|
||||
{
|
||||
out[1] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[2] = out[3] = 0;
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = 0;
|
||||
w1[1] = 0;
|
||||
w1[2] = 0;
|
||||
w1[3] = 0;
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40000m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40000m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_m16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = pws[gid].i[ 8];
|
||||
w2[1] = pws[gid].i[ 9];
|
||||
w2[2] = pws[gid].i[10];
|
||||
w2[3] = pws[gid].i[11];
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = pws[gid].i[12];
|
||||
w3[1] = pws[gid].i[13];
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40000m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = 0;
|
||||
w1[1] = 0;
|
||||
w1[2] = 0;
|
||||
w1[3] = 0;
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40000s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40000s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40000_s16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = pws[gid].i[ 8];
|
||||
w2[1] = pws[gid].i[ 9];
|
||||
w2[2] = pws[gid].i[10];
|
||||
w2[3] = pws[gid].i[11];
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = pws[gid].i[12];
|
||||
w3[1] = pws[gid].i[13];
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40000s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
|
||||
}
|
263
OpenCL/m40001_a0-optimized.cl
Normal file
263
OpenCL/m40001_a0-optimized.cl
Normal file
@ -0,0 +1,263 @@
|
||||
/**
|
||||
* 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)
|
||||
#include M2S(INCLUDE_PATH/inc_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[12] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m04 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 pw_buf0[4];
|
||||
u32 pw_buf1[4] = { 0 };
|
||||
|
||||
pw_buf0[0] = pws[gid].i[ 0];
|
||||
pw_buf0[1] = pws[gid].i[ 1];
|
||||
pw_buf0[2] = pws[gid].i[ 2];
|
||||
pw_buf0[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
u32x w0[4] = { 0 };
|
||||
u32x w1[4] = { 0 };
|
||||
|
||||
apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
|
||||
|
||||
rc4_init_72 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 9)
|
||||
{
|
||||
out[2] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[3] = 0;
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m08 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m16 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s04 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 pw_buf0[4];
|
||||
u32 pw_buf1[4] = { 0 };
|
||||
|
||||
pw_buf0[0] = pws[gid].i[ 0];
|
||||
pw_buf0[1] = pws[gid].i[ 1];
|
||||
pw_buf0[2] = pws[gid].i[ 2];
|
||||
pw_buf0[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
u32x w0[4] = { 0 };
|
||||
u32x w1[4] = { 0 };
|
||||
|
||||
apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
|
||||
|
||||
/**
|
||||
* pdf
|
||||
*/
|
||||
|
||||
rc4_init_72 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 9)
|
||||
{
|
||||
out[2] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[3] = 0;
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s08 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s16 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
359
OpenCL/m40001_a1-optimized.cl
Normal file
359
OpenCL/m40001_a1-optimized.cl
Normal file
@ -0,0 +1,359 @@
|
||||
/**
|
||||
* 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_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[12] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 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_l_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
|
||||
|
||||
const u32x pw_len = (pw_l_len + pw_r_len) & 63;
|
||||
|
||||
/**
|
||||
* concat password candidate
|
||||
*/
|
||||
|
||||
u32x wordl0[4] = { 0 };
|
||||
u32x wordl1[4] = { 0 };
|
||||
u32x wordl2[4] = { 0 };
|
||||
u32x wordl3[4] = { 0 };
|
||||
|
||||
wordl0[0] = pw_buf0[0];
|
||||
wordl0[1] = pw_buf0[1];
|
||||
wordl0[2] = pw_buf0[2];
|
||||
wordl0[3] = pw_buf0[3];
|
||||
wordl1[0] = pw_buf1[0];
|
||||
wordl1[1] = pw_buf1[1];
|
||||
wordl1[2] = pw_buf1[2];
|
||||
wordl1[3] = pw_buf1[3];
|
||||
|
||||
u32x wordr0[4] = { 0 };
|
||||
u32x wordr1[4] = { 0 };
|
||||
u32x wordr2[4] = { 0 };
|
||||
u32x wordr3[4] = { 0 };
|
||||
|
||||
wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
|
||||
wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
|
||||
wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
|
||||
wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
|
||||
wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
|
||||
wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
|
||||
wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
|
||||
wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
|
||||
|
||||
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
|
||||
}
|
||||
|
||||
u32x w0[4];
|
||||
|
||||
w0[0] = wordl0[0] | wordr0[0];
|
||||
w0[1] = wordl0[1] | wordr0[1];
|
||||
w0[2] = wordl0[2] | wordr0[2];
|
||||
w0[3] = 0;
|
||||
|
||||
rc4_init_72 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 9)
|
||||
{
|
||||
out[2] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[3] = 0;
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 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_l_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
|
||||
|
||||
const u32x pw_len = (pw_l_len + pw_r_len) & 63;
|
||||
|
||||
/**
|
||||
* concat password candidate
|
||||
*/
|
||||
|
||||
u32x wordl0[4] = { 0 };
|
||||
u32x wordl1[4] = { 0 };
|
||||
u32x wordl2[4] = { 0 };
|
||||
u32x wordl3[4] = { 0 };
|
||||
|
||||
wordl0[0] = pw_buf0[0];
|
||||
wordl0[1] = pw_buf0[1];
|
||||
wordl0[2] = pw_buf0[2];
|
||||
wordl0[3] = pw_buf0[3];
|
||||
wordl1[0] = pw_buf1[0];
|
||||
wordl1[1] = pw_buf1[1];
|
||||
wordl1[2] = pw_buf1[2];
|
||||
wordl1[3] = pw_buf1[3];
|
||||
|
||||
u32x wordr0[4] = { 0 };
|
||||
u32x wordr1[4] = { 0 };
|
||||
u32x wordr2[4] = { 0 };
|
||||
u32x wordr3[4] = { 0 };
|
||||
|
||||
wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
|
||||
wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
|
||||
wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
|
||||
wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
|
||||
wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
|
||||
wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
|
||||
wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
|
||||
wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
|
||||
|
||||
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
|
||||
}
|
||||
|
||||
u32x w0[4];
|
||||
|
||||
w0[0] = wordl0[0] | wordr0[0];
|
||||
w0[1] = wordl0[1] | wordr0[1];
|
||||
w0[2] = wordl0[2] | wordr0[2];
|
||||
w0[3] = 0;
|
||||
|
||||
rc4_init_72 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 9)
|
||||
{
|
||||
out[2] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[3] = 0;
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
509
OpenCL/m40001_a3-optimized.cl
Normal file
509
OpenCL/m40001_a3-optimized.cl
Normal file
@ -0,0 +1,509 @@
|
||||
/**
|
||||
* 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_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[12] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
DECLSPEC void m40001m (LOCAL_AS u32 *S, PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* modifiers are taken from args
|
||||
*/
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
u32 w0l = w0[0];
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32 w0r = ix_create_bft (bfs_buf, il_pos);
|
||||
|
||||
const u32 w0lr = w0l | w0r;
|
||||
|
||||
w0[0] = w0lr;
|
||||
|
||||
rc4_init_72 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 9)
|
||||
{
|
||||
out[2] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[3] = 0;
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
DECLSPEC void m40001s (LOCAL_AS u32 *S, PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* modifiers are taken from args
|
||||
*/
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
u32 w0l = w0[0];
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32 w0r = ix_create_bft (bfs_buf, il_pos);
|
||||
|
||||
const u32 w0lr = w0l | w0r;
|
||||
|
||||
w0[0] = w0lr;
|
||||
|
||||
rc4_init_72 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 9)
|
||||
{
|
||||
out[2] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
out[3] = 0;
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = 0;
|
||||
w1[1] = 0;
|
||||
w1[2] = 0;
|
||||
w1[3] = 0;
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40001m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40001m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_m16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = pws[gid].i[ 8];
|
||||
w2[1] = pws[gid].i[ 9];
|
||||
w2[2] = pws[gid].i[10];
|
||||
w2[3] = pws[gid].i[11];
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = pws[gid].i[12];
|
||||
w3[1] = pws[gid].i[13];
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40001m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = 0;
|
||||
w1[1] = 0;
|
||||
w1[2] = 0;
|
||||
w1[3] = 0;
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40001s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40001s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40001_s16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = pws[gid].i[ 8];
|
||||
w2[1] = pws[gid].i[ 9];
|
||||
w2[2] = pws[gid].i[10];
|
||||
w2[3] = pws[gid].i[11];
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = pws[gid].i[12];
|
||||
w3[1] = pws[gid].i[13];
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40001s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
|
||||
}
|
281
OpenCL/m40002_a0-optimized.cl
Normal file
281
OpenCL/m40002_a0-optimized.cl
Normal file
@ -0,0 +1,281 @@
|
||||
/**
|
||||
* 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)
|
||||
#include M2S(INCLUDE_PATH/inc_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[16] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m04 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 pw_buf0[4];
|
||||
u32 pw_buf1[4] = { 0 };
|
||||
|
||||
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];
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
u32x w0[4] = { 0 };
|
||||
u32x w1[4] = { 0 };
|
||||
|
||||
apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
|
||||
|
||||
rc4_init_104 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 13)
|
||||
{
|
||||
out[3] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[3] = 0;
|
||||
|
||||
if (pt_len < 9)
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 11)
|
||||
{
|
||||
out[2] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m08 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m16 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s04 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 pw_buf0[4];
|
||||
u32 pw_buf1[4] = { 0 };
|
||||
|
||||
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];
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
u32x w0[4] = { 0 };
|
||||
u32x w1[4] = { 0 };
|
||||
|
||||
apply_rules_vect_optimized (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
|
||||
|
||||
/**
|
||||
* pdf
|
||||
*/
|
||||
|
||||
rc4_init_104 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 13)
|
||||
{
|
||||
out[3] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[3] = 0;
|
||||
|
||||
if (pt_len < 9)
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 11)
|
||||
{
|
||||
out[2] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s08 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s16 (KERN_ATTR_RULES_ESALT (rc4_t))
|
||||
{
|
||||
}
|
377
OpenCL/m40002_a1-optimized.cl
Normal file
377
OpenCL/m40002_a1-optimized.cl
Normal file
@ -0,0 +1,377 @@
|
||||
/**
|
||||
* 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_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[16] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 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_l_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
|
||||
|
||||
const u32x pw_len = (pw_l_len + pw_r_len) & 63;
|
||||
|
||||
/**
|
||||
* concat password candidate
|
||||
*/
|
||||
|
||||
u32x wordl0[4] = { 0 };
|
||||
u32x wordl1[4] = { 0 };
|
||||
u32x wordl2[4] = { 0 };
|
||||
u32x wordl3[4] = { 0 };
|
||||
|
||||
wordl0[0] = pw_buf0[0];
|
||||
wordl0[1] = pw_buf0[1];
|
||||
wordl0[2] = pw_buf0[2];
|
||||
wordl0[3] = pw_buf0[3];
|
||||
wordl1[0] = pw_buf1[0];
|
||||
wordl1[1] = pw_buf1[1];
|
||||
wordl1[2] = pw_buf1[2];
|
||||
wordl1[3] = pw_buf1[3];
|
||||
|
||||
u32x wordr0[4] = { 0 };
|
||||
u32x wordr1[4] = { 0 };
|
||||
u32x wordr2[4] = { 0 };
|
||||
u32x wordr3[4] = { 0 };
|
||||
|
||||
wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
|
||||
wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
|
||||
wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
|
||||
wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
|
||||
wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
|
||||
wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
|
||||
wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
|
||||
wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
|
||||
|
||||
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
|
||||
}
|
||||
|
||||
u32x w0[4];
|
||||
|
||||
w0[0] = wordl0[0] | wordr0[0];
|
||||
w0[1] = wordl0[1] | wordr0[1];
|
||||
w0[2] = wordl0[2] | wordr0[2];
|
||||
w0[3] = wordl0[3] | wordr0[3];
|
||||
|
||||
rc4_init_104 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 13)
|
||||
{
|
||||
out[3] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[3] = 0;
|
||||
|
||||
if (pt_len < 9)
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 11)
|
||||
{
|
||||
out[2] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 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_l_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* shared
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos) & 63;
|
||||
|
||||
const u32x pw_len = (pw_l_len + pw_r_len) & 63;
|
||||
|
||||
/**
|
||||
* concat password candidate
|
||||
*/
|
||||
|
||||
u32x wordl0[4] = { 0 };
|
||||
u32x wordl1[4] = { 0 };
|
||||
u32x wordl2[4] = { 0 };
|
||||
u32x wordl3[4] = { 0 };
|
||||
|
||||
wordl0[0] = pw_buf0[0];
|
||||
wordl0[1] = pw_buf0[1];
|
||||
wordl0[2] = pw_buf0[2];
|
||||
wordl0[3] = pw_buf0[3];
|
||||
wordl1[0] = pw_buf1[0];
|
||||
wordl1[1] = pw_buf1[1];
|
||||
wordl1[2] = pw_buf1[2];
|
||||
wordl1[3] = pw_buf1[3];
|
||||
|
||||
u32x wordr0[4] = { 0 };
|
||||
u32x wordr1[4] = { 0 };
|
||||
u32x wordr2[4] = { 0 };
|
||||
u32x wordr3[4] = { 0 };
|
||||
|
||||
wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
|
||||
wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
|
||||
wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
|
||||
wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
|
||||
wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
|
||||
wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
|
||||
wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
|
||||
wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
|
||||
|
||||
if (COMBS_MODE == COMBINATOR_MODE_BASE_LEFT)
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
|
||||
}
|
||||
|
||||
u32x w0[4];
|
||||
|
||||
w0[0] = wordl0[0] | wordr0[0];
|
||||
w0[1] = wordl0[1] | wordr0[1];
|
||||
w0[2] = wordl0[2] | wordr0[2];
|
||||
w0[3] = wordl0[3] | wordr0[3];
|
||||
|
||||
rc4_init_104 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 13)
|
||||
{
|
||||
out[3] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[3] = 0;
|
||||
|
||||
if (pt_len < 9)
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 11)
|
||||
{
|
||||
out[2] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
}
|
527
OpenCL/m40002_a3-optimized.cl
Normal file
527
OpenCL/m40002_a3-optimized.cl
Normal file
@ -0,0 +1,527 @@
|
||||
/**
|
||||
* 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_cipher_rc4.cl)
|
||||
#endif
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
CONSTANT_VK u32 pt_masks[16] =
|
||||
{
|
||||
0x00000000,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0x0000FFFF,
|
||||
0x00FFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0x000000FF,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
DECLSPEC void m40002m (LOCAL_AS u32 *S, PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* modifiers are taken from args
|
||||
*/
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
u32 w0l = w0[0];
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32 w0r = ix_create_bft (bfs_buf, il_pos);
|
||||
|
||||
const u32 w0lr = w0l | w0r;
|
||||
|
||||
w0[0] = w0lr;
|
||||
|
||||
rc4_init_104 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 13)
|
||||
{
|
||||
out[3] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[3] = 0;
|
||||
|
||||
if (pt_len < 9)
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 11)
|
||||
{
|
||||
out[2] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
COMPARE_M_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
DECLSPEC void m40002s (LOCAL_AS u32 *S, PRIVATE_AS u32 *w0, PRIVATE_AS u32 *w1, PRIVATE_AS u32 *w2, PRIVATE_AS u32 *w3, const u32 pw_len, KERN_ATTR_FUNC_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* modifiers are taken from args
|
||||
*/
|
||||
|
||||
/**
|
||||
* digest
|
||||
*/
|
||||
|
||||
const u32 search[4] =
|
||||
{
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R0],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R1],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R2],
|
||||
digests_buf[DIGESTS_OFFSET_HOST].digest_buf[DGST_R3]
|
||||
};
|
||||
|
||||
/**
|
||||
* loop
|
||||
*/
|
||||
|
||||
const u32 dropN = esalt_bufs[DIGESTS_OFFSET_HOST].dropN;
|
||||
const u32 pt_len = esalt_bufs[DIGESTS_OFFSET_HOST].pt_len;
|
||||
|
||||
const u32 ct[4] =
|
||||
{
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[0],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[1],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[2],
|
||||
esalt_bufs[DIGESTS_OFFSET_HOST].ct[3]
|
||||
};
|
||||
|
||||
u32 w0l = w0[0];
|
||||
|
||||
for (u32 il_pos = 0; il_pos < IL_CNT; il_pos += VECT_SIZE)
|
||||
{
|
||||
const u32 w0r = ix_create_bft (bfs_buf, il_pos);
|
||||
|
||||
const u32 w0lr = w0l | w0r;
|
||||
|
||||
w0[0] = w0lr;
|
||||
|
||||
rc4_init_104 (S, w0, lid);
|
||||
|
||||
u32 out[4];
|
||||
|
||||
u8 i = 0;
|
||||
u8 j = 0;
|
||||
|
||||
if (dropN > 0)
|
||||
{
|
||||
rc4_dropN (S, &i, &j, dropN, lid);
|
||||
}
|
||||
|
||||
rc4_next_16 (S, i, j, ct, out, lid);
|
||||
|
||||
if (pt_len == 13)
|
||||
{
|
||||
out[3] &= pt_masks[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[3] = 0;
|
||||
|
||||
if (pt_len < 9)
|
||||
{
|
||||
out[2] = 0;
|
||||
|
||||
if (pt_len < 5)
|
||||
{
|
||||
out[1] = 0;
|
||||
|
||||
if (pt_len >= 1 && pt_len <= 3)
|
||||
{
|
||||
out[0] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 7)
|
||||
{
|
||||
out[1] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
else if (pt_len <= 11)
|
||||
{
|
||||
out[2] &= pt_masks[pt_len];
|
||||
}
|
||||
}
|
||||
|
||||
COMPARE_S_SIMD (out[0], out[1], out[2], out[3]);
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = 0;
|
||||
w1[1] = 0;
|
||||
w1[2] = 0;
|
||||
w1[3] = 0;
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40002m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40002m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_m16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = pws[gid].i[ 8];
|
||||
w2[1] = pws[gid].i[ 9];
|
||||
w2[2] = pws[gid].i[10];
|
||||
w2[3] = pws[gid].i[11];
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = pws[gid].i[12];
|
||||
w3[1] = pws[gid].i[13];
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40002m (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s04 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = 0;
|
||||
w1[1] = 0;
|
||||
w1[2] = 0;
|
||||
w1[3] = 0;
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40002s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s08 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = 0;
|
||||
w2[1] = 0;
|
||||
w2[2] = 0;
|
||||
w2[3] = 0;
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = 0;
|
||||
w3[1] = 0;
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40002s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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 FIXED_THREAD_COUNT(FIXED_LOCAL_SIZE) m40002_s16 (KERN_ATTR_ESALT (rc4_t))
|
||||
{
|
||||
/**
|
||||
* 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 w0[4];
|
||||
|
||||
w0[0] = pws[gid].i[ 0];
|
||||
w0[1] = pws[gid].i[ 1];
|
||||
w0[2] = pws[gid].i[ 2];
|
||||
w0[3] = pws[gid].i[ 3];
|
||||
|
||||
u32 w1[4];
|
||||
|
||||
w1[0] = pws[gid].i[ 4];
|
||||
w1[1] = pws[gid].i[ 5];
|
||||
w1[2] = pws[gid].i[ 6];
|
||||
w1[3] = pws[gid].i[ 7];
|
||||
|
||||
u32 w2[4];
|
||||
|
||||
w2[0] = pws[gid].i[ 8];
|
||||
w2[1] = pws[gid].i[ 9];
|
||||
w2[2] = pws[gid].i[10];
|
||||
w2[3] = pws[gid].i[11];
|
||||
|
||||
u32 w3[4];
|
||||
|
||||
w3[0] = pws[gid].i[12];
|
||||
w3[1] = pws[gid].i[13];
|
||||
w3[2] = 0;
|
||||
w3[3] = 0;
|
||||
|
||||
const u32 pw_len = pws[gid].pw_len & 63;
|
||||
|
||||
/**
|
||||
* main
|
||||
*/
|
||||
|
||||
LOCAL_VK u32 S[64 * FIXED_LOCAL_SIZE];
|
||||
|
||||
m40002s (S, w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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);
|
||||
}
|
@ -38,6 +38,9 @@
|
||||
- Added hash-mode: NetIQ SSPR (SHA-1 with Salt)
|
||||
- Added hash-mode: NetIQ SSPR (SHA-256 with Salt)
|
||||
- Added hash-mode: NetIQ SSPR (SHA-512 with Salt)
|
||||
- Added hash-mode: RC4 104-bit DropN
|
||||
- Added hash-mode: RC4 40-bit DropN
|
||||
- Added hash-mode: RC4 72-bit DropN
|
||||
- Added hash-mode: RSA Security Analytics / NetWitness (sha256)
|
||||
- Added hash-mode: SecureCRT MasterPassphrase v2
|
||||
- Added hash-mode: Veeam VB
|
||||
|
@ -480,6 +480,9 @@ NVIDIA GPUs require "NVIDIA Driver" (440.64 or later) and "CUDA Toolkit" (9.0 or
|
||||
- ENCsecurity Datavault (MD5/no keychain)
|
||||
- ENCsecurity Datavault (MD5/keychain)
|
||||
- SecureCRT MasterPassphrase v2
|
||||
- RC4 40-bit DropN
|
||||
- RC4 72-bit DropN
|
||||
- RC4 104-bit DropN
|
||||
|
||||
##
|
||||
## Attack-Modes
|
||||
|
@ -584,8 +584,10 @@ typedef enum parser_rc
|
||||
PARSER_FILE_SIZE = -41,
|
||||
PARSER_IV_LENGTH = -42,
|
||||
PARSER_CT_LENGTH = -43,
|
||||
PARSER_CRYPTOAPI_KERNELTYPE = -44,
|
||||
PARSER_CRYPTOAPI_KEYSIZE = -45,
|
||||
PARSER_PT_LENGTH = -44,
|
||||
PARSER_PT_OFFSET = -45,
|
||||
PARSER_CRYPTOAPI_KERNELTYPE = -46,
|
||||
PARSER_CRYPTOAPI_KEYSIZE = -47,
|
||||
PARSER_HAVE_ERRNO = -100,
|
||||
PARSER_UNKNOWN_ERROR = -255
|
||||
|
||||
|
412
src/modules/module_40000.c
Normal file
412
src/modules/module_40000.c
Normal file
@ -0,0 +1,412 @@
|
||||
/**
|
||||
* 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"
|
||||
#include "emu_inc_hash_md5.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; // originally DGST_SIZE_4_2
|
||||
static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_CIPHER_KPA;
|
||||
static const char *HASH_NAME = "RC4 40-bit DropN";
|
||||
static const u64 KERN_TYPE = 40000;
|
||||
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
||||
| OPTI_TYPE_NOT_ITERATED
|
||||
| OPTI_TYPE_NOT_SALTED;
|
||||
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
||||
| OPTS_TYPE_SUGGEST_KG // collisions by using pt_len != pass_len
|
||||
| OPTS_TYPE_PT_GENERATE_LE;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
static const char *ST_PASS = "hashc";
|
||||
static const char *ST_HASH = "$rc4$40$0$e9a41693b759cf88929ca31203694f$0$48656c6c6f";
|
||||
|
||||
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; }
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
static const char *SIGNATURE_RC4 = "$rc4$";
|
||||
static const u32 RC4_KEY_BITS = 40;
|
||||
static const u32 PW_LEN = RC4_KEY_BITS / 8; // 5
|
||||
|
||||
bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param)
|
||||
{
|
||||
if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU))
|
||||
{
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (strncmp (device_param->device_name, "Intel", 5) == 0)
|
||||
{
|
||||
// Intel Iris Graphics, Metal Version 244.303, compiler timeout but only with -a0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param)
|
||||
{
|
||||
char *jit_build_options = NULL;
|
||||
|
||||
u32 native_threads = 0;
|
||||
|
||||
if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)
|
||||
{
|
||||
native_threads = 1;
|
||||
}
|
||||
else if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)
|
||||
{
|
||||
#if defined (__APPLE__)
|
||||
|
||||
native_threads = 32;
|
||||
|
||||
#else
|
||||
|
||||
if (device_param->device_local_mem_size < 49152)
|
||||
{
|
||||
native_threads = MIN (device_param->kernel_preferred_wgs_multiple, 32); // We can't just set 32, because Intel GPU need 8
|
||||
}
|
||||
else
|
||||
{
|
||||
native_threads = device_param->kernel_preferred_wgs_multiple;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u -D _unroll", native_threads);
|
||||
|
||||
return jit_build_options;
|
||||
}
|
||||
|
||||
u64 module_esalt_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)
|
||||
{
|
||||
const u64 esalt_size = (const u64) sizeof (rc4_t);
|
||||
|
||||
return esalt_size;
|
||||
}
|
||||
|
||||
u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u32 pw_min = PW_LEN;
|
||||
|
||||
return pw_min;
|
||||
}
|
||||
|
||||
u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u32 pw_max = PW_LEN;
|
||||
|
||||
return pw_max;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
rc4_t *rc4 = (rc4_t *) esalt_buf;
|
||||
|
||||
hc_token_t token;
|
||||
|
||||
memset (&token, 0, sizeof (hc_token_t));
|
||||
|
||||
token.token_cnt = 6;
|
||||
|
||||
token.signatures_cnt = 1;
|
||||
token.signatures_buf[0] = SIGNATURE_RC4;
|
||||
|
||||
token.len[0] = strlen (SIGNATURE_RC4);
|
||||
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_SIGNATURE;
|
||||
// key bit
|
||||
|
||||
token.sep[1] = '$';
|
||||
token.len_min[1] = 2;
|
||||
token.len_max[1] = 3;
|
||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// dropN
|
||||
|
||||
token.sep[2] = '$';
|
||||
token.len_min[2] = 1;
|
||||
token.len_max[2] = 3;
|
||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// ciphertext
|
||||
|
||||
token.sep[3] = '$';
|
||||
token.len_min[3] = 1 * 2;
|
||||
token.len_max[3] = 64 * 2;
|
||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
// plaintext offset
|
||||
|
||||
token.sep[4] = '$';
|
||||
token.len[4] = 1;
|
||||
token.attr[4] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// plaintext
|
||||
|
||||
token.sep[5] = '$';
|
||||
token.len_min[5] = 1 * 2;
|
||||
token.len_max[5] = 64 * 2;
|
||||
token.attr[5] = TOKEN_ATTR_VERIFY_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);
|
||||
|
||||
// key bit
|
||||
|
||||
const u8 *key_bit_pos = token.buf[1];
|
||||
|
||||
u32 key_bit = hc_strtoul ((const char *) key_bit_pos, NULL, 10);
|
||||
|
||||
if (key_bit != RC4_KEY_BITS) return (PARSER_KEY_SIZE);
|
||||
|
||||
// dropN
|
||||
|
||||
const u8 *dropN_pos = token.buf[2];
|
||||
|
||||
rc4->dropN = hc_strtoul ((const char *) dropN_pos, NULL, 10);
|
||||
|
||||
// ciphertext
|
||||
|
||||
u32 salt_len = 0;
|
||||
u32 salt_buf[16];
|
||||
|
||||
memset (salt_buf, 0, sizeof (salt_buf));
|
||||
|
||||
u8 *salt_buf_ptr = (u8 *) salt_buf;
|
||||
|
||||
const u8 *ciphertext_pos = token.buf[3];
|
||||
const u32 ciphertext_len = token.len[3];
|
||||
|
||||
rc4->ct_len = ciphertext_len / 2;
|
||||
|
||||
u8 *ct = (u8 *) rc4->ct;
|
||||
|
||||
for (u32 i = 0, j = 0; i < rc4->ct_len; i += 1, j += 2)
|
||||
{
|
||||
ct[i] = hex_to_u8 (ciphertext_pos + j);
|
||||
|
||||
salt_buf_ptr[i] = ct[i];
|
||||
salt_len++;
|
||||
}
|
||||
|
||||
// fake salt (part 1)
|
||||
|
||||
md5_ctx_t md5_ctx;
|
||||
|
||||
md5_init (&md5_ctx);
|
||||
md5_update (&md5_ctx, salt_buf, salt_len);
|
||||
|
||||
// plaintext offset
|
||||
|
||||
const u8 *pt_offset_pos = token.buf[4];
|
||||
|
||||
rc4->pt_off = hc_strtoul ((const char *) pt_offset_pos, NULL, 10);
|
||||
|
||||
if (rc4->pt_off > rc4->ct_len) return PARSER_PT_OFFSET;
|
||||
|
||||
// plaintext
|
||||
|
||||
const u8 *plaintext_pos = token.buf[5];
|
||||
const u32 plaintext_len = token.len[5];
|
||||
|
||||
rc4->pt_len = plaintext_len / 2;
|
||||
|
||||
if (rc4->pt_len > rc4->ct_len) return PARSER_PT_LENGTH;
|
||||
|
||||
if ((rc4->pt_off + rc4->pt_len) > rc4->ct_len) return PARSER_PT_OFFSET;
|
||||
|
||||
u8 *pt = (u8 *) rc4->pt;
|
||||
u8 *dgst = (u8 *) digest;
|
||||
|
||||
salt_len = 0;
|
||||
memset (salt_buf, 0, sizeof (salt_buf));
|
||||
|
||||
for (u32 i = 0, j = 0; i < rc4->pt_len; i += 1, j += 2)
|
||||
{
|
||||
pt[i] = hex_to_u8 (plaintext_pos + j);
|
||||
|
||||
dgst[i] = pt[i];
|
||||
|
||||
salt_buf[i] = pt[i];
|
||||
salt_len++;
|
||||
}
|
||||
|
||||
// fake salt (part 2)
|
||||
|
||||
md5_update (&md5_ctx, salt_buf, salt_len);
|
||||
md5_final (&md5_ctx);
|
||||
|
||||
salt->salt_buf[0] = md5_ctx.h[0];
|
||||
salt->salt_buf[1] = md5_ctx.h[1];
|
||||
salt->salt_buf[2] = md5_ctx.h[2];
|
||||
salt->salt_buf[3] = md5_ctx.h[3];
|
||||
|
||||
salt->salt_len = 16;
|
||||
|
||||
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 rc4_t *rc4 = (const rc4_t *) esalt_buf;
|
||||
|
||||
snprintf (line_buf, line_size, "%s%u$%u$", SIGNATURE_RC4, RC4_KEY_BITS, rc4->dropN);
|
||||
|
||||
u8 *out_buf = (u8 *) line_buf;
|
||||
|
||||
int out_len = strlen (line_buf);
|
||||
|
||||
u8 *ct = (u8 *) rc4->ct;
|
||||
|
||||
for (u32 i = 0; i < rc4->ct_len; i++)
|
||||
{
|
||||
u8_to_hex (ct[i], out_buf + out_len); out_len += 2;
|
||||
}
|
||||
|
||||
out_buf[out_len++] = '$';
|
||||
|
||||
char tmp_buf[10] = { 0 };
|
||||
|
||||
snprintf ((char *) tmp_buf, sizeof (tmp_buf), "%u", rc4->pt_off);
|
||||
|
||||
snprintf ((char *) out_buf + out_len, sizeof (tmp_buf), "%u", rc4->pt_off);
|
||||
|
||||
out_len += strlen (tmp_buf);
|
||||
|
||||
out_buf[out_len++] = '$';
|
||||
|
||||
u8 *dgst = (u8 *) digest;
|
||||
|
||||
for (u32 i = 0; i < rc4->pt_len; i++)
|
||||
{
|
||||
u8_to_hex (dgst[i], out_buf + out_len); out_len += 2;
|
||||
}
|
||||
|
||||
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_esalt_size;
|
||||
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_jit_build_options;
|
||||
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_pw_max;
|
||||
module_ctx->module_pw_min = module_pw_min;
|
||||
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_unstable_warning;
|
||||
module_ctx->module_warmup_disable = MODULE_DEFAULT;
|
||||
}
|
412
src/modules/module_40001.c
Normal file
412
src/modules/module_40001.c
Normal file
@ -0,0 +1,412 @@
|
||||
/**
|
||||
* 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"
|
||||
#include "emu_inc_hash_md5.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_CIPHER_KPA;
|
||||
static const char *HASH_NAME = "RC4 72-bit DropN";
|
||||
static const u64 KERN_TYPE = 40001;
|
||||
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
||||
| OPTI_TYPE_NOT_ITERATED
|
||||
| OPTI_TYPE_NOT_SALTED;
|
||||
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
||||
| OPTS_TYPE_SUGGEST_KG // collisions by using pt_len != pass_len
|
||||
| OPTS_TYPE_PT_GENERATE_LE;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
static const char *ST_PASS = "hashcat12";
|
||||
static const char *ST_HASH = "$rc4$72$0$90eaa8d71c$0$48656c6c6f";
|
||||
|
||||
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; }
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
static const char *SIGNATURE_RC4 = "$rc4$";
|
||||
static const u32 RC4_KEY_BITS = 72;
|
||||
static const u32 PW_LEN = RC4_KEY_BITS / 8; // 9
|
||||
|
||||
bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param)
|
||||
{
|
||||
if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU))
|
||||
{
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (strncmp (device_param->device_name, "Intel", 5) == 0)
|
||||
{
|
||||
// Intel Iris Graphics, Metal Version 244.303, compiler timeout but only with -a0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param)
|
||||
{
|
||||
char *jit_build_options = NULL;
|
||||
|
||||
u32 native_threads = 0;
|
||||
|
||||
if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)
|
||||
{
|
||||
native_threads = 1;
|
||||
}
|
||||
else if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)
|
||||
{
|
||||
#if defined (__APPLE__)
|
||||
|
||||
native_threads = 32;
|
||||
|
||||
#else
|
||||
|
||||
if (device_param->device_local_mem_size < 49152)
|
||||
{
|
||||
native_threads = MIN (device_param->kernel_preferred_wgs_multiple, 32); // We can't just set 32, because Intel GPU need 8
|
||||
}
|
||||
else
|
||||
{
|
||||
native_threads = device_param->kernel_preferred_wgs_multiple;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u -D _unroll", native_threads);
|
||||
|
||||
return jit_build_options;
|
||||
}
|
||||
|
||||
u64 module_esalt_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)
|
||||
{
|
||||
const u64 esalt_size = (const u64) sizeof (rc4_t);
|
||||
|
||||
return esalt_size;
|
||||
}
|
||||
|
||||
u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u32 pw_min = PW_LEN;
|
||||
|
||||
return pw_min;
|
||||
}
|
||||
|
||||
u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u32 pw_max = PW_LEN;
|
||||
|
||||
return pw_max;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
rc4_t *rc4 = (rc4_t *) esalt_buf;
|
||||
|
||||
hc_token_t token;
|
||||
|
||||
memset (&token, 0, sizeof (hc_token_t));
|
||||
|
||||
token.token_cnt = 6;
|
||||
|
||||
token.signatures_cnt = 1;
|
||||
token.signatures_buf[0] = SIGNATURE_RC4;
|
||||
|
||||
token.len[0] = strlen (SIGNATURE_RC4);
|
||||
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_SIGNATURE;
|
||||
// key bit
|
||||
|
||||
token.sep[1] = '$';
|
||||
token.len_min[1] = 2;
|
||||
token.len_max[1] = 3;
|
||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// dropN
|
||||
|
||||
token.sep[2] = '$';
|
||||
token.len_min[2] = 1;
|
||||
token.len_max[2] = 3;
|
||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// ciphertext
|
||||
|
||||
token.sep[3] = '$';
|
||||
token.len_min[3] = 1 * 2;
|
||||
token.len_max[3] = 64 * 2;
|
||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
// plaintext offset
|
||||
|
||||
token.sep[4] = '$';
|
||||
token.len[4] = 1;
|
||||
token.attr[4] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// plaintext
|
||||
|
||||
token.sep[5] = '$';
|
||||
token.len_min[5] = 1 * 2;
|
||||
token.len_max[5] = 64 * 2;
|
||||
token.attr[5] = TOKEN_ATTR_VERIFY_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);
|
||||
|
||||
// key bit
|
||||
|
||||
const u8 *key_bit_pos = token.buf[1];
|
||||
|
||||
u32 key_bit = hc_strtoul ((const char *) key_bit_pos, NULL, 10);
|
||||
|
||||
if (key_bit != RC4_KEY_BITS) return (PARSER_KEY_SIZE);
|
||||
|
||||
// dropN
|
||||
|
||||
const u8 *dropN_pos = token.buf[2];
|
||||
|
||||
rc4->dropN = hc_strtoul ((const char *) dropN_pos, NULL, 10);
|
||||
|
||||
// ciphertext
|
||||
|
||||
u32 salt_len = 0;
|
||||
u32 salt_buf[16];
|
||||
|
||||
memset (salt_buf, 0, sizeof (salt_buf));
|
||||
|
||||
u8 *salt_buf_ptr = (u8 *) salt_buf;
|
||||
|
||||
const u8 *ciphertext_pos = token.buf[3];
|
||||
const u32 ciphertext_len = token.len[3];
|
||||
|
||||
rc4->ct_len = ciphertext_len / 2;
|
||||
|
||||
u8 *ct = (u8 *) rc4->ct;
|
||||
|
||||
for (u32 i = 0, j = 0; i < rc4->ct_len; i += 1, j += 2)
|
||||
{
|
||||
ct[i] = hex_to_u8 (ciphertext_pos + j);
|
||||
|
||||
salt_buf_ptr[i] = ct[i];
|
||||
salt_len++;
|
||||
}
|
||||
|
||||
// fake salt (part 1)
|
||||
|
||||
md5_ctx_t md5_ctx;
|
||||
|
||||
md5_init (&md5_ctx);
|
||||
md5_update (&md5_ctx, salt_buf, salt_len);
|
||||
|
||||
// plaintext offset
|
||||
|
||||
const u8 *pt_offset_pos = token.buf[4];
|
||||
|
||||
rc4->pt_off = hc_strtoul ((const char *) pt_offset_pos, NULL, 10);
|
||||
|
||||
if (rc4->pt_off > rc4->ct_len) return PARSER_PT_OFFSET;
|
||||
|
||||
// plaintext
|
||||
|
||||
const u8 *plaintext_pos = token.buf[5];
|
||||
const u32 plaintext_len = token.len[5];
|
||||
|
||||
rc4->pt_len = plaintext_len / 2;
|
||||
|
||||
if (rc4->pt_len > rc4->ct_len) return PARSER_PT_LENGTH;
|
||||
|
||||
if ((rc4->pt_off + rc4->pt_len) > rc4->ct_len) return PARSER_PT_OFFSET;
|
||||
|
||||
u8 *pt = (u8 *) rc4->pt;
|
||||
u8 *dgst = (u8 *) digest;
|
||||
|
||||
salt_len = 0;
|
||||
memset (salt_buf, 0, sizeof (salt_buf));
|
||||
|
||||
for (u32 i = 0, j = 0; i < rc4->pt_len; i += 1, j += 2)
|
||||
{
|
||||
pt[i] = hex_to_u8 (plaintext_pos + j);
|
||||
|
||||
dgst[i] = pt[i];
|
||||
|
||||
salt_buf[i] = pt[i];
|
||||
salt_len++;
|
||||
}
|
||||
|
||||
// fake salt (part 2)
|
||||
|
||||
md5_update (&md5_ctx, salt_buf, salt_len);
|
||||
md5_final (&md5_ctx);
|
||||
|
||||
salt->salt_buf[0] = md5_ctx.h[0];
|
||||
salt->salt_buf[1] = md5_ctx.h[1];
|
||||
salt->salt_buf[2] = md5_ctx.h[2];
|
||||
salt->salt_buf[3] = md5_ctx.h[3];
|
||||
|
||||
salt->salt_len = 16;
|
||||
|
||||
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 rc4_t *rc4 = (const rc4_t *) esalt_buf;
|
||||
|
||||
snprintf (line_buf, line_size, "%s%u$%u$", SIGNATURE_RC4, RC4_KEY_BITS, rc4->dropN);
|
||||
|
||||
u8 *out_buf = (u8 *) line_buf;
|
||||
|
||||
int out_len = strlen (line_buf);
|
||||
|
||||
u8 *ct = (u8 *) rc4->ct;
|
||||
|
||||
for (u32 i = 0; i < rc4->ct_len; i++)
|
||||
{
|
||||
u8_to_hex (ct[i], out_buf + out_len); out_len += 2;
|
||||
}
|
||||
|
||||
out_buf[out_len++] = '$';
|
||||
|
||||
char tmp_buf[10] = { 0 };
|
||||
|
||||
snprintf ((char *) tmp_buf, sizeof (tmp_buf), "%u", rc4->pt_off);
|
||||
|
||||
snprintf ((char *) out_buf + out_len, sizeof (tmp_buf), "%u", rc4->pt_off);
|
||||
|
||||
out_len += strlen (tmp_buf);
|
||||
|
||||
out_buf[out_len++] = '$';
|
||||
|
||||
u8 *dgst = (u8 *) digest;
|
||||
|
||||
for (u32 i = 0; i < rc4->pt_len; i++)
|
||||
{
|
||||
u8_to_hex (dgst[i], out_buf + out_len); out_len += 2;
|
||||
}
|
||||
|
||||
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_esalt_size;
|
||||
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_jit_build_options;
|
||||
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_pw_max;
|
||||
module_ctx->module_pw_min = module_pw_min;
|
||||
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_unstable_warning;
|
||||
module_ctx->module_warmup_disable = MODULE_DEFAULT;
|
||||
}
|
412
src/modules/module_40002.c
Normal file
412
src/modules/module_40002.c
Normal file
@ -0,0 +1,412 @@
|
||||
/**
|
||||
* 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"
|
||||
#include "emu_inc_hash_md5.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_CIPHER_KPA;
|
||||
static const char *HASH_NAME = "RC4 104-bit DropN";
|
||||
static const u64 KERN_TYPE = 40002;
|
||||
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
||||
| OPTI_TYPE_NOT_ITERATED
|
||||
| OPTI_TYPE_NOT_SALTED;
|
||||
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
||||
| OPTS_TYPE_SUGGEST_KG // collisions by using pt_len != pass_len
|
||||
| OPTS_TYPE_PT_GENERATE_LE;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
static const char *ST_PASS = "hashcat123456";
|
||||
static const char *ST_HASH = "$rc4$104$0$a04245c3d7$0$48656c6c6f";
|
||||
|
||||
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; }
|
||||
|
||||
typedef struct rc4
|
||||
{
|
||||
u32 dropN;
|
||||
u32 ct_len;
|
||||
u32 pt_len;
|
||||
u32 pt_off;
|
||||
|
||||
u32 pt[2];
|
||||
u32 ct[16];
|
||||
|
||||
} rc4_t;
|
||||
|
||||
static const char *SIGNATURE_RC4 = "$rc4$";
|
||||
static const u32 RC4_KEY_BITS = 104;
|
||||
static const u32 PW_LEN = RC4_KEY_BITS / 8; // 13
|
||||
|
||||
bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hc_device_param_t *device_param)
|
||||
{
|
||||
if ((device_param->opencl_platform_vendor_id == VENDOR_ID_APPLE) && (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU))
|
||||
{
|
||||
if (device_param->is_metal == true)
|
||||
{
|
||||
if (strncmp (device_param->device_name, "Intel", 5) == 0)
|
||||
{
|
||||
// Intel Iris Graphics, Metal Version 244.303, compiler timeout but only with -a0
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param)
|
||||
{
|
||||
char *jit_build_options = NULL;
|
||||
|
||||
u32 native_threads = 0;
|
||||
|
||||
if (device_param->opencl_device_type & CL_DEVICE_TYPE_CPU)
|
||||
{
|
||||
native_threads = 1;
|
||||
}
|
||||
else if (device_param->opencl_device_type & CL_DEVICE_TYPE_GPU)
|
||||
{
|
||||
#if defined (__APPLE__)
|
||||
|
||||
native_threads = 32;
|
||||
|
||||
#else
|
||||
|
||||
if (device_param->device_local_mem_size < 49152)
|
||||
{
|
||||
native_threads = MIN (device_param->kernel_preferred_wgs_multiple, 32); // We can't just set 32, because Intel GPU need 8
|
||||
}
|
||||
else
|
||||
{
|
||||
native_threads = device_param->kernel_preferred_wgs_multiple;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
hc_asprintf (&jit_build_options, "-D FIXED_LOCAL_SIZE=%u -D _unroll", native_threads);
|
||||
|
||||
return jit_build_options;
|
||||
}
|
||||
|
||||
u64 module_esalt_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)
|
||||
{
|
||||
const u64 esalt_size = (const u64) sizeof (rc4_t);
|
||||
|
||||
return esalt_size;
|
||||
}
|
||||
|
||||
u32 module_pw_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u32 pw_min = PW_LEN;
|
||||
|
||||
return pw_min;
|
||||
}
|
||||
|
||||
u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u32 pw_max = PW_LEN;
|
||||
|
||||
return pw_max;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
rc4_t *rc4 = (rc4_t *) esalt_buf;
|
||||
|
||||
hc_token_t token;
|
||||
|
||||
memset (&token, 0, sizeof (hc_token_t));
|
||||
|
||||
token.token_cnt = 6;
|
||||
|
||||
token.signatures_cnt = 1;
|
||||
token.signatures_buf[0] = SIGNATURE_RC4;
|
||||
|
||||
token.len[0] = strlen (SIGNATURE_RC4);
|
||||
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_SIGNATURE;
|
||||
// key bit
|
||||
|
||||
token.sep[1] = '$';
|
||||
token.len_min[1] = 2;
|
||||
token.len_max[1] = 3;
|
||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// dropN
|
||||
|
||||
token.sep[2] = '$';
|
||||
token.len_min[2] = 1;
|
||||
token.len_max[2] = 3;
|
||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// ciphertext
|
||||
|
||||
token.sep[3] = '$';
|
||||
token.len_min[3] = 1 * 2;
|
||||
token.len_max[3] = 64 * 2;
|
||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_HEX;
|
||||
|
||||
// plaintext offset
|
||||
|
||||
token.sep[4] = '$';
|
||||
token.len[4] = 1;
|
||||
token.attr[4] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||
|
||||
// plaintext
|
||||
|
||||
token.sep[5] = '$';
|
||||
token.len_min[5] = 1 * 2;
|
||||
token.len_max[5] = 64 * 2;
|
||||
token.attr[5] = TOKEN_ATTR_VERIFY_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);
|
||||
|
||||
// key bit
|
||||
|
||||
const u8 *key_bit_pos = token.buf[1];
|
||||
|
||||
u32 key_bit = hc_strtoul ((const char *) key_bit_pos, NULL, 10);
|
||||
|
||||
if (key_bit != RC4_KEY_BITS) return (PARSER_KEY_SIZE);
|
||||
|
||||
// dropN
|
||||
|
||||
const u8 *dropN_pos = token.buf[2];
|
||||
|
||||
rc4->dropN = hc_strtoul ((const char *) dropN_pos, NULL, 10);
|
||||
|
||||
// ciphertext
|
||||
|
||||
u32 salt_len = 0;
|
||||
u32 salt_buf[16];
|
||||
|
||||
memset (salt_buf, 0, sizeof (salt_buf));
|
||||
|
||||
u8 *salt_buf_ptr = (u8 *) salt_buf;
|
||||
|
||||
const u8 *ciphertext_pos = token.buf[3];
|
||||
const u32 ciphertext_len = token.len[3];
|
||||
|
||||
rc4->ct_len = ciphertext_len / 2;
|
||||
|
||||
u8 *ct = (u8 *) rc4->ct;
|
||||
|
||||
for (u32 i = 0, j = 0; i < rc4->ct_len; i += 1, j += 2)
|
||||
{
|
||||
ct[i] = hex_to_u8 (ciphertext_pos + j);
|
||||
|
||||
salt_buf_ptr[i] = ct[i];
|
||||
salt_len++;
|
||||
}
|
||||
|
||||
// fake salt (part 1)
|
||||
|
||||
md5_ctx_t md5_ctx;
|
||||
|
||||
md5_init (&md5_ctx);
|
||||
md5_update (&md5_ctx, salt_buf, salt_len);
|
||||
|
||||
// plaintext offset
|
||||
|
||||
const u8 *pt_offset_pos = token.buf[4];
|
||||
|
||||
rc4->pt_off = hc_strtoul ((const char *) pt_offset_pos, NULL, 10);
|
||||
|
||||
if (rc4->pt_off > rc4->ct_len) return PARSER_PT_OFFSET;
|
||||
|
||||
// plaintext
|
||||
|
||||
const u8 *plaintext_pos = token.buf[5];
|
||||
const u32 plaintext_len = token.len[5];
|
||||
|
||||
rc4->pt_len = plaintext_len / 2;
|
||||
|
||||
if (rc4->pt_len > rc4->ct_len) return PARSER_PT_LENGTH;
|
||||
|
||||
if ((rc4->pt_off + rc4->pt_len) > rc4->ct_len) return PARSER_PT_OFFSET;
|
||||
|
||||
u8 *pt = (u8 *) rc4->pt;
|
||||
u8 *dgst = (u8 *) digest;
|
||||
|
||||
salt_len = 0;
|
||||
memset (salt_buf, 0, sizeof (salt_buf));
|
||||
|
||||
for (u32 i = 0, j = 0; i < rc4->pt_len; i += 1, j += 2)
|
||||
{
|
||||
pt[i] = hex_to_u8 (plaintext_pos + j);
|
||||
|
||||
dgst[i] = pt[i];
|
||||
|
||||
salt_buf[i] = pt[i];
|
||||
salt_len++;
|
||||
}
|
||||
|
||||
// fake salt (part 2)
|
||||
|
||||
md5_update (&md5_ctx, salt_buf, salt_len);
|
||||
md5_final (&md5_ctx);
|
||||
|
||||
salt->salt_buf[0] = md5_ctx.h[0];
|
||||
salt->salt_buf[1] = md5_ctx.h[1];
|
||||
salt->salt_buf[2] = md5_ctx.h[2];
|
||||
salt->salt_buf[3] = md5_ctx.h[3];
|
||||
|
||||
salt->salt_len = 16;
|
||||
|
||||
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 rc4_t *rc4 = (const rc4_t *) esalt_buf;
|
||||
|
||||
snprintf (line_buf, line_size, "%s%u$%u$", SIGNATURE_RC4, RC4_KEY_BITS, rc4->dropN);
|
||||
|
||||
u8 *out_buf = (u8 *) line_buf;
|
||||
|
||||
int out_len = strlen (line_buf);
|
||||
|
||||
u8 *ct = (u8 *) rc4->ct;
|
||||
|
||||
for (u32 i = 0; i < rc4->ct_len; i++)
|
||||
{
|
||||
u8_to_hex (ct[i], out_buf + out_len); out_len += 2;
|
||||
}
|
||||
|
||||
out_buf[out_len++] = '$';
|
||||
|
||||
char tmp_buf[10] = { 0 };
|
||||
|
||||
snprintf ((char *) tmp_buf, sizeof (tmp_buf), "%u", rc4->pt_off);
|
||||
|
||||
snprintf ((char *) out_buf + out_len, sizeof (tmp_buf), "%u", rc4->pt_off);
|
||||
|
||||
out_len += strlen (tmp_buf);
|
||||
|
||||
out_buf[out_len++] = '$';
|
||||
|
||||
u8 *dgst = (u8 *) digest;
|
||||
|
||||
for (u32 i = 0; i < rc4->pt_len; i++)
|
||||
{
|
||||
u8_to_hex (dgst[i], out_buf + out_len); out_len += 2;
|
||||
}
|
||||
|
||||
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_esalt_size;
|
||||
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_jit_build_options;
|
||||
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_pw_max;
|
||||
module_ctx->module_pw_min = module_pw_min;
|
||||
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_unstable_warning;
|
||||
module_ctx->module_warmup_disable = MODULE_DEFAULT;
|
||||
}
|
@ -67,6 +67,10 @@ static const char *const PA_040 = "Invalid or unsupported cipher";
|
||||
static const char *const PA_041 = "Invalid filesize";
|
||||
static const char *const PA_042 = "IV length exception";
|
||||
static const char *const PA_043 = "CT length exception";
|
||||
static const char *const PA_044 = "PT length exception";
|
||||
static const char *const PA_045 = "PT offset exception";
|
||||
static const char *const PA_046 = "Invalid or unsupported CryptoAPI hash type";
|
||||
static const char *const PA_047 = "Invalid CryptoAPI key size";
|
||||
static const char *const PA_255 = "Unknown error";
|
||||
|
||||
static const char *const OPTI_STR_OPTIMIZED_KERNEL = "Optimized-Kernel";
|
||||
@ -1104,6 +1108,10 @@ const char *strparser (const u32 parser_status)
|
||||
case PARSER_FILE_SIZE: return PA_041;
|
||||
case PARSER_IV_LENGTH: return PA_042;
|
||||
case PARSER_CT_LENGTH: return PA_043;
|
||||
case PARSER_PT_LENGTH: return PA_044;
|
||||
case PARSER_PT_OFFSET: return PA_045;
|
||||
case PARSER_CRYPTOAPI_KERNELTYPE: return PA_046;
|
||||
case PARSER_CRYPTOAPI_KEYSIZE: return PA_047;
|
||||
}
|
||||
|
||||
return PA_255;
|
||||
|
@ -336,6 +336,7 @@ function init()
|
||||
done 9< "${OUTD}/${hash_type}_passwords.txt"
|
||||
|
||||
min_len=0
|
||||
fixed_len=0
|
||||
|
||||
if [ "${hash_type}" -eq 2500 ]; then
|
||||
min_len=7 # means length 8, since we start with 0
|
||||
@ -351,6 +352,14 @@ function init()
|
||||
min_len=7 # means length 8, since we start with 0
|
||||
elif [ "${hash_type}" -eq 22000 ]; then
|
||||
min_len=7 # means length 8, since we start with 0
|
||||
elif [ "${hash_type}" -eq 40000 ]; then
|
||||
fixed_len=5
|
||||
elif [ "${hash_type}" -eq 40001 ]; then
|
||||
min_len=5
|
||||
fixed_len=9
|
||||
elif [ "${hash_type}" -eq 40002 ]; then
|
||||
min_len=5
|
||||
fixed_len=13
|
||||
fi
|
||||
|
||||
# generate multiple pass/hash foreach len (2 to 8)
|
||||
@ -366,7 +375,11 @@ function init()
|
||||
rm -rf "${OUTD}/${hash_type}_dict1_multi_${i}" "${OUTD}/${hash_type}_dict2_multi_${i}"
|
||||
touch "${OUTD}/${hash_type}_dict1_multi_${i}" "${OUTD}/${hash_type}_dict2_multi_${i}"
|
||||
|
||||
perl tools/test.pl single "${hash_type}" ${i} > "${cmd_file}"
|
||||
if [ "${fixed_len}" -eq "${i}" ]; then
|
||||
perl tools/test.pl single "${hash_type}" ${i} > "${cmd_file}"
|
||||
else
|
||||
perl tools/test.pl single "${hash_type}" ${fixed_len} > "${cmd_file}"
|
||||
fi
|
||||
|
||||
sed 's/^echo *|.*$//' "${cmd_file}" | awk '{print $2}' > "${OUTD}/${hash_type}_passwords_multi_${i}.txt"
|
||||
sed 's/^echo *|/echo "" |/' "${cmd_file}" | awk '{t="";for(i=10;i<=NF;i++){if(t){t=t" "$i}else{t=$i}};print t}' | cut -d"'" -f2 > "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
|
||||
@ -768,6 +781,7 @@ function attack_1()
|
||||
fi
|
||||
|
||||
echo "> Testing hash type $hash_type with attack mode 1, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
|
||||
|
||||
i=1
|
||||
while read -r -u 9 hash; do
|
||||
|
||||
@ -1915,6 +1929,7 @@ function attack_6()
|
||||
e_nm=0
|
||||
cnt=0
|
||||
|
||||
min=1
|
||||
max=9
|
||||
|
||||
if [ "${hash_type}" -eq 2500 ]; then
|
||||
@ -1929,6 +1944,12 @@ function attack_6()
|
||||
max=5
|
||||
elif [ "${hash_type}" -eq 22000 ]; then
|
||||
max=5
|
||||
elif [ "${hash_type}" -eq 40000 ]; then
|
||||
min=5
|
||||
elif [ "${hash_type}" -eq 40001 ]; then
|
||||
min=8
|
||||
elif [ "${hash_type}" -eq 40002 ]; then
|
||||
min=8
|
||||
fi
|
||||
|
||||
if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then
|
||||
@ -1941,6 +1962,11 @@ function attack_6()
|
||||
i=2
|
||||
while [ "$i" -lt "$max" ]; do
|
||||
|
||||
if [ "$i" -lt "$min" ]; then
|
||||
i=$((i + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
hash_file=${OUTD}/${hash_type}_hashes_multi_${i}.txt
|
||||
|
||||
# if file_only -> decode all base64 "hashes" and put them in the temporary file
|
||||
@ -2368,6 +2394,12 @@ function attack_7()
|
||||
max=5
|
||||
elif [ "${hash_type}" -eq 22000 ]; then
|
||||
max=5
|
||||
elif [ "${hash_type}" -eq 40000 ]; then
|
||||
min=5
|
||||
elif [ "${hash_type}" -eq 40001 ]; then
|
||||
max=3
|
||||
elif [ "${hash_type}" -eq 40002 ]; then
|
||||
max=3
|
||||
fi
|
||||
|
||||
if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then
|
||||
@ -2383,7 +2415,13 @@ function attack_7()
|
||||
hash_file=${OUTD}/${hash_type}_hashes_multi_${i}.txt
|
||||
dict_file=${OUTD}/${hash_type}_dict2_multi_${i}
|
||||
|
||||
mask=${mask_7[$i]}
|
||||
if [ "${hash_type}" -eq 40001 ]; then
|
||||
mask=${mask_7[((i+10))]}
|
||||
elif [ "${hash_type}" -eq 40002 ]; then
|
||||
mask=${mask_7[((i+10))]}
|
||||
else
|
||||
mask=${mask_7[$i]}
|
||||
fi
|
||||
|
||||
# if file_only -> decode all base64 "hashes" and put them in the temporary file
|
||||
|
||||
|
84
tools/test_modules/m40000.pm
Normal file
84
tools/test_modules/m40000.pm
Normal file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Crypt::RC4;
|
||||
|
||||
sub module_constraints { [[-1, -1], [-1, -1], [5, 5], [-1, -1], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $dropN = shift;
|
||||
my $ciphertext = shift;
|
||||
my $plaintext_offset = shift;
|
||||
my $plaintext = shift;
|
||||
|
||||
if (!defined $plaintext || !defined $dropN)
|
||||
{
|
||||
$dropN = random_number (0, 512);
|
||||
$plaintext = random_string (random_number (5, 64));
|
||||
}
|
||||
|
||||
my $cipher = Crypt::RC4->new ($word);
|
||||
|
||||
if ($dropN gt 0)
|
||||
{
|
||||
$cipher->RC4("\x00" x $dropN);
|
||||
}
|
||||
|
||||
my $digest = unpack ("H*", $cipher->RC4 ($plaintext));
|
||||
|
||||
if (defined $ciphertext)
|
||||
{
|
||||
if (substr ($ciphertext, 0, 10) eq $digest)
|
||||
{
|
||||
$digest = $ciphertext;
|
||||
}
|
||||
}
|
||||
|
||||
my $hash = sprintf ('$rc4$40$%d$%s$0$%s', $dropN, $digest, substr (unpack ("H*", $plaintext), 0, 10));
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub module_verify_hash
|
||||
{
|
||||
my $line = shift;
|
||||
|
||||
my ($hash, $word) = split (':', $line);
|
||||
|
||||
return unless defined $hash;
|
||||
return unless defined $word;
|
||||
|
||||
my $signature = substr ($hash, 0, 8);
|
||||
|
||||
return unless ($signature eq "\$rc4\$40\$");
|
||||
|
||||
my @data = split ('\$', $hash);
|
||||
|
||||
return unless scalar (@data) == 7;
|
||||
|
||||
shift @data;
|
||||
shift @data;
|
||||
shift @data;
|
||||
|
||||
my $dropN = shift @data;
|
||||
my $ciphertext = shift @data;
|
||||
my $plaintext_offset = shift @data;
|
||||
my $plaintext = pack ("H*", shift @data);
|
||||
|
||||
my $word_packed = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word_packed, $dropN, $ciphertext, $plaintext_offset, $plaintext);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
84
tools/test_modules/m40001.pm
Normal file
84
tools/test_modules/m40001.pm
Normal file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Crypt::RC4;
|
||||
|
||||
sub module_constraints { [[-1, -1], [-1, -1], [9, 9], [-1, -1], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $dropN = shift;
|
||||
my $ciphertext = shift;
|
||||
my $plaintext_offset = shift;
|
||||
my $plaintext = shift;
|
||||
|
||||
if (!defined $plaintext || !defined $dropN)
|
||||
{
|
||||
$dropN = random_number (0, 512);
|
||||
$plaintext = random_string (random_number (5, 64));
|
||||
}
|
||||
|
||||
my $cipher = Crypt::RC4->new ($word);
|
||||
|
||||
if ($dropN gt 0)
|
||||
{
|
||||
$cipher->RC4("\x00" x $dropN);
|
||||
}
|
||||
|
||||
my $digest = unpack ("H*", $cipher->RC4 ($plaintext));
|
||||
|
||||
if (defined $ciphertext)
|
||||
{
|
||||
if (substr ($ciphertext, 0, 10) eq $digest)
|
||||
{
|
||||
$digest = $ciphertext;
|
||||
}
|
||||
}
|
||||
|
||||
my $hash = sprintf ('$rc4$72$%d$%s$0$%s', $dropN, $digest, substr (unpack ("H*", $plaintext), 0, 10));
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub module_verify_hash
|
||||
{
|
||||
my $line = shift;
|
||||
|
||||
my ($hash, $word) = split (':', $line);
|
||||
|
||||
return unless defined $hash;
|
||||
return unless defined $word;
|
||||
|
||||
my $signature = substr ($hash, 0, 8);
|
||||
|
||||
return unless ($signature eq "\$rc4\$72\$");
|
||||
|
||||
my @data = split ('\$', $hash);
|
||||
|
||||
return unless scalar (@data) == 7;
|
||||
|
||||
shift @data;
|
||||
shift @data;
|
||||
shift @data;
|
||||
|
||||
my $dropN = shift @data;
|
||||
my $ciphertext = shift @data;
|
||||
my $plaintext_offset = shift @data;
|
||||
my $plaintext = pack ("H*", shift @data);
|
||||
|
||||
my $word_packed = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word_packed, $dropN, $ciphertext, $plaintext_offset, $plaintext);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
84
tools/test_modules/m40002.pm
Normal file
84
tools/test_modules/m40002.pm
Normal file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
##
|
||||
## Author......: See docs/credits.txt
|
||||
## License.....: MIT
|
||||
##
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Crypt::RC4;
|
||||
|
||||
sub module_constraints { [[-1, -1], [-1, -1], [13, 13], [-1, -1], [-1, -1]] }
|
||||
|
||||
sub module_generate_hash
|
||||
{
|
||||
my $word = shift;
|
||||
my $dropN = shift;
|
||||
my $ciphertext = shift;
|
||||
my $plaintext_offset = shift;
|
||||
my $plaintext = shift;
|
||||
|
||||
if (!defined $plaintext || !defined $dropN)
|
||||
{
|
||||
$dropN = random_number (0, 512);
|
||||
$plaintext = random_string (random_number (5, 64));
|
||||
}
|
||||
|
||||
my $cipher = Crypt::RC4->new ($word);
|
||||
|
||||
if ($dropN gt 0)
|
||||
{
|
||||
$cipher->RC4("\x00" x $dropN);
|
||||
}
|
||||
|
||||
my $digest = unpack ("H*", $cipher->RC4 ($plaintext));
|
||||
|
||||
if (defined $ciphertext)
|
||||
{
|
||||
if (substr ($ciphertext, 0, 10) eq $digest)
|
||||
{
|
||||
$digest = $ciphertext;
|
||||
}
|
||||
}
|
||||
|
||||
my $hash = sprintf ('$rc4$104$%d$%s$0$%s', $dropN, $digest, substr (unpack ("H*", $plaintext), 0, 10));
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub module_verify_hash
|
||||
{
|
||||
my $line = shift;
|
||||
|
||||
my ($hash, $word) = split (':', $line);
|
||||
|
||||
return unless defined $hash;
|
||||
return unless defined $word;
|
||||
|
||||
my $signature = substr ($hash, 0, 9);
|
||||
|
||||
return unless ($signature eq "\$rc4\$104\$");
|
||||
|
||||
my @data = split ('\$', $hash);
|
||||
|
||||
return unless scalar (@data) == 7;
|
||||
|
||||
shift @data;
|
||||
shift @data;
|
||||
shift @data;
|
||||
|
||||
my $dropN = shift @data;
|
||||
my $ciphertext = shift @data;
|
||||
my $plaintext_offset = shift @data;
|
||||
my $plaintext = pack ("H*", shift @data);
|
||||
|
||||
my $word_packed = pack_if_HEX_notation ($word);
|
||||
|
||||
my $new_hash = module_generate_hash ($word_packed, $dropN, $ciphertext, $plaintext_offset, $plaintext);
|
||||
|
||||
return ($new_hash, $word);
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue
Block a user