1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-25 17:38:23 +00:00

OpenCL Kernels: Use three separate comparison kernels (depending on keyver) for WPA instead of one

This commit is contained in:
jsteube 2018-02-13 09:13:35 +01:00
parent 31da893a40
commit fe4413797e
9 changed files with 1147 additions and 901 deletions

View File

@ -3,7 +3,7 @@
* License.....: MIT
*/
__constant static u32a c_append_helper[64][16] =
__constant u32a c_append_helper[64][16] =
{
{ 0x000000ff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
{ 0x0000ff00, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 },

View File

@ -243,6 +243,395 @@ __kernel void m02500_loop (__global pw_t *pws, __global const kernel_rule_t *rul
}
__kernel void m02500_comp (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global wpa_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const wpa_t *wpa_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
{
// not in use here, special case...
}
__kernel void m02500_aux1 (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global wpa_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const wpa_t *wpa_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
{
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
if (gid >= gid_max) return;
u32 out[8];
out[0] = tmps[gid].out[0];
out[1] = tmps[gid].out[1];
out[2] = tmps[gid].out[2];
out[3] = tmps[gid].out[3];
out[4] = tmps[gid].out[4];
out[5] = tmps[gid].out[5];
out[6] = tmps[gid].out[6];
out[7] = tmps[gid].out[7];
const u32 digest_pos = loop_pos;
const u32 digest_cur = digests_offset + digest_pos;
__global const wpa_t *wpa = &wpa_bufs[digest_cur];
u32 pke[32];
pke[ 0] = wpa->pke[ 0];
pke[ 1] = wpa->pke[ 1];
pke[ 2] = wpa->pke[ 2];
pke[ 3] = wpa->pke[ 3];
pke[ 4] = wpa->pke[ 4];
pke[ 5] = wpa->pke[ 5];
pke[ 6] = wpa->pke[ 6];
pke[ 7] = wpa->pke[ 7];
pke[ 8] = wpa->pke[ 8];
pke[ 9] = wpa->pke[ 9];
pke[10] = wpa->pke[10];
pke[11] = wpa->pke[11];
pke[12] = wpa->pke[12];
pke[13] = wpa->pke[13];
pke[14] = wpa->pke[14];
pke[15] = wpa->pke[15];
pke[16] = wpa->pke[16];
pke[17] = wpa->pke[17];
pke[18] = wpa->pke[18];
pke[19] = wpa->pke[19];
pke[20] = wpa->pke[20];
pke[21] = wpa->pke[21];
pke[22] = wpa->pke[22];
pke[23] = wpa->pke[23];
pke[24] = wpa->pke[24];
pke[25] = wpa->pke[25];
pke[26] = wpa->pke[26];
pke[27] = wpa->pke[27];
pke[28] = wpa->pke[28];
pke[29] = wpa->pke[29];
pke[30] = wpa->pke[30];
pke[31] = wpa->pke[31];
u32 to;
if (wpa->nonce_compare < 0)
{
to = pke[15] << 24
| pke[16] >> 8;
}
else
{
to = pke[23] << 24
| pke[24] >> 8;
}
const u32 nonce_error_corrections = wpa->nonce_error_corrections;
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
{
u32 t = to;
t = swap32_S (t);
t -= nonce_error_corrections / 2;
t += nonce_error_correction;
t = swap32_S (t);
if (wpa->nonce_compare < 0)
{
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
}
else
{
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
}
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = out[0];
w0[1] = out[1];
w0[2] = out[2];
w0[3] = out[3];
w1[0] = out[4];
w1[1] = out[5];
w1[2] = out[6];
w1[3] = out[7];
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
u32 keymic[4];
keymic[0] = 0;
keymic[1] = 0;
keymic[2] = 0;
keymic[3] = 0;
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = swap32_S (digest[0]);
t0[1] = swap32_S (digest[1]);
t0[2] = swap32_S (digest[2]);
t0[3] = swap32_S (digest[3]);
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
md5_hmac_ctx_t ctx2;
md5_hmac_init_64 (&ctx2, t0, t1, t2, t3);
md5_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
md5_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
/**
* final compare
*/
if ((keymic[0] == wpa->keymic[0])
&& (keymic[1] == wpa->keymic[1])
&& (keymic[2] == wpa->keymic[2])
&& (keymic[3] == wpa->keymic[3]))
{
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0);
}
}
}
}
__kernel void m02500_aux2 (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global wpa_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const wpa_t *wpa_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
{
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
if (gid >= gid_max) return;
u32 out[8];
out[0] = tmps[gid].out[0];
out[1] = tmps[gid].out[1];
out[2] = tmps[gid].out[2];
out[3] = tmps[gid].out[3];
out[4] = tmps[gid].out[4];
out[5] = tmps[gid].out[5];
out[6] = tmps[gid].out[6];
out[7] = tmps[gid].out[7];
const u32 digest_pos = loop_pos;
const u32 digest_cur = digests_offset + digest_pos;
__global const wpa_t *wpa = &wpa_bufs[digest_cur];
u32 pke[32];
pke[ 0] = wpa->pke[ 0];
pke[ 1] = wpa->pke[ 1];
pke[ 2] = wpa->pke[ 2];
pke[ 3] = wpa->pke[ 3];
pke[ 4] = wpa->pke[ 4];
pke[ 5] = wpa->pke[ 5];
pke[ 6] = wpa->pke[ 6];
pke[ 7] = wpa->pke[ 7];
pke[ 8] = wpa->pke[ 8];
pke[ 9] = wpa->pke[ 9];
pke[10] = wpa->pke[10];
pke[11] = wpa->pke[11];
pke[12] = wpa->pke[12];
pke[13] = wpa->pke[13];
pke[14] = wpa->pke[14];
pke[15] = wpa->pke[15];
pke[16] = wpa->pke[16];
pke[17] = wpa->pke[17];
pke[18] = wpa->pke[18];
pke[19] = wpa->pke[19];
pke[20] = wpa->pke[20];
pke[21] = wpa->pke[21];
pke[22] = wpa->pke[22];
pke[23] = wpa->pke[23];
pke[24] = wpa->pke[24];
pke[25] = wpa->pke[25];
pke[26] = wpa->pke[26];
pke[27] = wpa->pke[27];
pke[28] = wpa->pke[28];
pke[29] = wpa->pke[29];
pke[30] = wpa->pke[30];
pke[31] = wpa->pke[31];
u32 to;
if (wpa->nonce_compare < 0)
{
to = pke[15] << 24
| pke[16] >> 8;
}
else
{
to = pke[23] << 24
| pke[24] >> 8;
}
const u32 nonce_error_corrections = wpa->nonce_error_corrections;
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
{
u32 t = to;
t = swap32_S (t);
t -= nonce_error_corrections / 2;
t += nonce_error_correction;
t = swap32_S (t);
if (wpa->nonce_compare < 0)
{
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
}
else
{
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
}
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = out[0];
w0[1] = out[1];
w0[2] = out[2];
w0[3] = out[3];
w1[0] = out[4];
w1[1] = out[5];
w1[2] = out[6];
w1[3] = out[7];
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
u32 keymic[4];
keymic[0] = 0;
keymic[1] = 0;
keymic[2] = 0;
keymic[3] = 0;
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = digest[0];
t0[1] = digest[1];
t0[2] = digest[2];
t0[3] = digest[3];
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
sha1_hmac_ctx_t ctx2;
sha1_hmac_init_64 (&ctx2, t0, t1, t2, t3);
sha1_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
sha1_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
/**
* final compare
*/
if ((keymic[0] == wpa->keymic[0])
&& (keymic[1] == wpa->keymic[1])
&& (keymic[2] == wpa->keymic[2])
&& (keymic[3] == wpa->keymic[3]))
{
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0);
}
}
}
}
__kernel void m02500_aux3 (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global wpa_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const wpa_t *wpa_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
{
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
@ -419,448 +808,86 @@ __kernel void m02500_comp (__global pw_t *pws, __global const kernel_rule_t *rul
keymic[2] = 0;
keymic[3] = 0;
if (wpa->keyver == 1)
sha256_hmac_ctx_t ctx1;
sha256_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha256_hmac_update (&ctx1, pke, 102);
sha256_hmac_final (&ctx1);
u32 digest[4];
digest[0] = swap32_S (ctx1.opad.h[0]);
digest[1] = swap32_S (ctx1.opad.h[1]);
digest[2] = swap32_S (ctx1.opad.h[2]);
digest[3] = swap32_S (ctx1.opad.h[3]);
// AES CMAC
u32 ks[44];
aes128_set_encrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3, s_te4);
u32 m[4];
m[0] = 0;
m[1] = 0;
m[2] = 0;
m[3] = 0;
u32 iv[4];
iv[0] = 0;
iv[1] = 0;
iv[2] = 0;
iv[3] = 0;
int eapol_left;
int eapol_idx;
for (eapol_left = wpa->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4)
{
sha1_hmac_ctx_t ctx1;
m[0] = wpa->eapol[eapol_idx + 0] ^ iv[0];
m[1] = wpa->eapol[eapol_idx + 1] ^ iv[1];
m[2] = wpa->eapol[eapol_idx + 2] ^ iv[2];
m[3] = wpa->eapol[eapol_idx + 3] ^ iv[3];
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = swap32_S (digest[0]);
t0[1] = swap32_S (digest[1]);
t0[2] = swap32_S (digest[2]);
t0[3] = swap32_S (digest[3]);
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
md5_hmac_ctx_t ctx2;
md5_hmac_init_64 (&ctx2, t0, t1, t2, t3);
md5_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
md5_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4);
}
else if (wpa->keyver == 2)
m[0] = wpa->eapol[eapol_idx + 0];
m[1] = wpa->eapol[eapol_idx + 1];
m[2] = wpa->eapol[eapol_idx + 2];
m[3] = wpa->eapol[eapol_idx + 3];
u32 k[4];
k[0] = 0;
k[1] = 0;
k[2] = 0;
k[3] = 0;
aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4);
make_kn (k);
if (eapol_left < 16)
{
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = digest[0];
t0[1] = digest[1];
t0[2] = digest[2];
t0[3] = digest[3];
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
sha1_hmac_ctx_t ctx2;
sha1_hmac_init_64 (&ctx2, t0, t1, t2, t3);
sha1_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
sha1_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
}
else if (wpa->keyver == 3)
{
sha256_hmac_ctx_t ctx1;
sha256_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha256_hmac_update (&ctx1, pke, 102);
sha256_hmac_final (&ctx1);
u32 digest[4];
digest[0] = swap32_S (ctx1.opad.h[0]);
digest[1] = swap32_S (ctx1.opad.h[1]);
digest[2] = swap32_S (ctx1.opad.h[2]);
digest[3] = swap32_S (ctx1.opad.h[3]);
// AES CMAC
u32 ks[44];
aes128_set_encrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3, s_te4);
u32 m[4];
m[0] = 0;
m[1] = 0;
m[2] = 0;
m[3] = 0;
u32 iv[4];
iv[0] = 0;
iv[1] = 0;
iv[2] = 0;
iv[3] = 0;
int eapol_left;
int eapol_idx;
for (eapol_left = wpa->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4)
{
m[0] = wpa->eapol[eapol_idx + 0] ^ iv[0];
m[1] = wpa->eapol[eapol_idx + 1] ^ iv[1];
m[2] = wpa->eapol[eapol_idx + 2] ^ iv[2];
m[3] = wpa->eapol[eapol_idx + 3] ^ iv[3];
aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4);
}
m[0] = wpa->eapol[eapol_idx + 0];
m[1] = wpa->eapol[eapol_idx + 1];
m[2] = wpa->eapol[eapol_idx + 2];
m[3] = wpa->eapol[eapol_idx + 3];
u32 k[4];
k[0] = 0;
k[1] = 0;
k[2] = 0;
k[3] = 0;
aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4);
make_kn (k);
if (eapol_left < 16)
{
make_kn (k);
}
m[0] ^= k[0];
m[1] ^= k[1];
m[2] ^= k[2];
m[3] ^= k[3];
m[0] ^= iv[0];
m[1] ^= iv[1];
m[2] ^= iv[2];
m[3] ^= iv[3];
aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4);
}
/**
* final compare
*/
m[0] ^= k[0];
m[1] ^= k[1];
m[2] ^= k[2];
m[3] ^= k[3];
if ((keymic[0] == wpa->keymic[0])
&& (keymic[1] == wpa->keymic[1])
&& (keymic[2] == wpa->keymic[2])
&& (keymic[3] == wpa->keymic[3]))
{
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0);
}
}
}
m[0] ^= iv[0];
m[1] ^= iv[1];
m[2] ^= iv[2];
m[3] ^= iv[3];
// the same code again, but with BE order for the t++
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
{
u32 t = to;
t -= nonce_error_corrections / 2;
t += nonce_error_correction;
if (t == to) continue; // we already had this checked in the LE loop
if (wpa->nonce_compare < 0)
{
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
}
else
{
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
}
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = out[0];
w0[1] = out[1];
w0[2] = out[2];
w0[3] = out[3];
w1[0] = out[4];
w1[1] = out[5];
w1[2] = out[6];
w1[3] = out[7];
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
u32 keymic[4];
keymic[0] = 0;
keymic[1] = 0;
keymic[2] = 0;
keymic[3] = 0;
if (wpa->keyver == 1)
{
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = swap32_S (digest[0]);
t0[1] = swap32_S (digest[1]);
t0[2] = swap32_S (digest[2]);
t0[3] = swap32_S (digest[3]);
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
md5_hmac_ctx_t ctx2;
md5_hmac_init_64 (&ctx2, t0, t1, t2, t3);
md5_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
md5_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
}
else if (wpa->keyver == 2)
{
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = digest[0];
t0[1] = digest[1];
t0[2] = digest[2];
t0[3] = digest[3];
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
sha1_hmac_ctx_t ctx2;
sha1_hmac_init_64 (&ctx2, t0, t1, t2, t3);
sha1_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
sha1_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
}
else if (wpa->keyver == 3)
{
sha256_hmac_ctx_t ctx1;
sha256_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha256_hmac_update (&ctx1, pke, 102);
sha256_hmac_final (&ctx1);
u32 digest[4];
digest[0] = swap32_S (ctx1.opad.h[0]);
digest[1] = swap32_S (ctx1.opad.h[1]);
digest[2] = swap32_S (ctx1.opad.h[2]);
digest[3] = swap32_S (ctx1.opad.h[3]);
// AES CMAC
u32 ks[44];
aes128_set_encrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3, s_te4);
u32 m[4];
m[0] = 0;
m[1] = 0;
m[2] = 0;
m[3] = 0;
u32 iv[4];
iv[0] = 0;
iv[1] = 0;
iv[2] = 0;
iv[3] = 0;
int eapol_left;
int eapol_idx;
for (eapol_left = wpa->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4)
{
m[0] = wpa->eapol[eapol_idx + 0] ^ iv[0];
m[1] = wpa->eapol[eapol_idx + 1] ^ iv[1];
m[2] = wpa->eapol[eapol_idx + 2] ^ iv[2];
m[3] = wpa->eapol[eapol_idx + 3] ^ iv[3];
aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4);
}
m[0] = wpa->eapol[eapol_idx + 0];
m[1] = wpa->eapol[eapol_idx + 1];
m[2] = wpa->eapol[eapol_idx + 2];
m[3] = wpa->eapol[eapol_idx + 3];
u32 k[4];
k[0] = 0;
k[1] = 0;
k[2] = 0;
k[3] = 0;
aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4);
make_kn (k);
if (eapol_left < 16)
{
make_kn (k);
}
m[0] ^= k[0];
m[1] ^= k[1];
m[2] ^= k[2];
m[3] ^= k[3];
m[0] ^= iv[0];
m[1] ^= iv[1];
m[2] ^= iv[2];
m[3] ^= iv[3];
aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4);
}
aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4);
/**
* final compare

View File

@ -118,6 +118,395 @@ __kernel void m02501_loop (__global pw_t *pws, __global const kernel_rule_t *rul
}
__kernel void m02501_comp (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global wpapmk_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const wpa_t *wpa_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
{
// not in use here, special case...
}
__kernel void m02501_aux1 (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global wpa_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const wpa_t *wpa_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
{
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
if (gid >= gid_max) return;
u32 out[8];
out[0] = tmps[gid].out[0];
out[1] = tmps[gid].out[1];
out[2] = tmps[gid].out[2];
out[3] = tmps[gid].out[3];
out[4] = tmps[gid].out[4];
out[5] = tmps[gid].out[5];
out[6] = tmps[gid].out[6];
out[7] = tmps[gid].out[7];
const u32 digest_pos = loop_pos;
const u32 digest_cur = digests_offset + digest_pos;
__global const wpa_t *wpa = &wpa_bufs[digest_cur];
u32 pke[32];
pke[ 0] = wpa->pke[ 0];
pke[ 1] = wpa->pke[ 1];
pke[ 2] = wpa->pke[ 2];
pke[ 3] = wpa->pke[ 3];
pke[ 4] = wpa->pke[ 4];
pke[ 5] = wpa->pke[ 5];
pke[ 6] = wpa->pke[ 6];
pke[ 7] = wpa->pke[ 7];
pke[ 8] = wpa->pke[ 8];
pke[ 9] = wpa->pke[ 9];
pke[10] = wpa->pke[10];
pke[11] = wpa->pke[11];
pke[12] = wpa->pke[12];
pke[13] = wpa->pke[13];
pke[14] = wpa->pke[14];
pke[15] = wpa->pke[15];
pke[16] = wpa->pke[16];
pke[17] = wpa->pke[17];
pke[18] = wpa->pke[18];
pke[19] = wpa->pke[19];
pke[20] = wpa->pke[20];
pke[21] = wpa->pke[21];
pke[22] = wpa->pke[22];
pke[23] = wpa->pke[23];
pke[24] = wpa->pke[24];
pke[25] = wpa->pke[25];
pke[26] = wpa->pke[26];
pke[27] = wpa->pke[27];
pke[28] = wpa->pke[28];
pke[29] = wpa->pke[29];
pke[30] = wpa->pke[30];
pke[31] = wpa->pke[31];
u32 to;
if (wpa->nonce_compare < 0)
{
to = pke[15] << 24
| pke[16] >> 8;
}
else
{
to = pke[23] << 24
| pke[24] >> 8;
}
const u32 nonce_error_corrections = wpa->nonce_error_corrections;
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
{
u32 t = to;
t = swap32_S (t);
t -= nonce_error_corrections / 2;
t += nonce_error_correction;
t = swap32_S (t);
if (wpa->nonce_compare < 0)
{
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
}
else
{
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
}
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = out[0];
w0[1] = out[1];
w0[2] = out[2];
w0[3] = out[3];
w1[0] = out[4];
w1[1] = out[5];
w1[2] = out[6];
w1[3] = out[7];
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
u32 keymic[4];
keymic[0] = 0;
keymic[1] = 0;
keymic[2] = 0;
keymic[3] = 0;
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = swap32_S (digest[0]);
t0[1] = swap32_S (digest[1]);
t0[2] = swap32_S (digest[2]);
t0[3] = swap32_S (digest[3]);
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
md5_hmac_ctx_t ctx2;
md5_hmac_init_64 (&ctx2, t0, t1, t2, t3);
md5_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
md5_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
/**
* final compare
*/
if ((keymic[0] == wpa->keymic[0])
&& (keymic[1] == wpa->keymic[1])
&& (keymic[2] == wpa->keymic[2])
&& (keymic[3] == wpa->keymic[3]))
{
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0);
}
}
}
}
__kernel void m02501_aux2 (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global wpa_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const wpa_t *wpa_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
{
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
if (gid >= gid_max) return;
u32 out[8];
out[0] = tmps[gid].out[0];
out[1] = tmps[gid].out[1];
out[2] = tmps[gid].out[2];
out[3] = tmps[gid].out[3];
out[4] = tmps[gid].out[4];
out[5] = tmps[gid].out[5];
out[6] = tmps[gid].out[6];
out[7] = tmps[gid].out[7];
const u32 digest_pos = loop_pos;
const u32 digest_cur = digests_offset + digest_pos;
__global const wpa_t *wpa = &wpa_bufs[digest_cur];
u32 pke[32];
pke[ 0] = wpa->pke[ 0];
pke[ 1] = wpa->pke[ 1];
pke[ 2] = wpa->pke[ 2];
pke[ 3] = wpa->pke[ 3];
pke[ 4] = wpa->pke[ 4];
pke[ 5] = wpa->pke[ 5];
pke[ 6] = wpa->pke[ 6];
pke[ 7] = wpa->pke[ 7];
pke[ 8] = wpa->pke[ 8];
pke[ 9] = wpa->pke[ 9];
pke[10] = wpa->pke[10];
pke[11] = wpa->pke[11];
pke[12] = wpa->pke[12];
pke[13] = wpa->pke[13];
pke[14] = wpa->pke[14];
pke[15] = wpa->pke[15];
pke[16] = wpa->pke[16];
pke[17] = wpa->pke[17];
pke[18] = wpa->pke[18];
pke[19] = wpa->pke[19];
pke[20] = wpa->pke[20];
pke[21] = wpa->pke[21];
pke[22] = wpa->pke[22];
pke[23] = wpa->pke[23];
pke[24] = wpa->pke[24];
pke[25] = wpa->pke[25];
pke[26] = wpa->pke[26];
pke[27] = wpa->pke[27];
pke[28] = wpa->pke[28];
pke[29] = wpa->pke[29];
pke[30] = wpa->pke[30];
pke[31] = wpa->pke[31];
u32 to;
if (wpa->nonce_compare < 0)
{
to = pke[15] << 24
| pke[16] >> 8;
}
else
{
to = pke[23] << 24
| pke[24] >> 8;
}
const u32 nonce_error_corrections = wpa->nonce_error_corrections;
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
{
u32 t = to;
t = swap32_S (t);
t -= nonce_error_corrections / 2;
t += nonce_error_correction;
t = swap32_S (t);
if (wpa->nonce_compare < 0)
{
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
}
else
{
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
}
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = out[0];
w0[1] = out[1];
w0[2] = out[2];
w0[3] = out[3];
w1[0] = out[4];
w1[1] = out[5];
w1[2] = out[6];
w1[3] = out[7];
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
u32 keymic[4];
keymic[0] = 0;
keymic[1] = 0;
keymic[2] = 0;
keymic[3] = 0;
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = digest[0];
t0[1] = digest[1];
t0[2] = digest[2];
t0[3] = digest[3];
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
sha1_hmac_ctx_t ctx2;
sha1_hmac_init_64 (&ctx2, t0, t1, t2, t3);
sha1_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
sha1_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
/**
* final compare
*/
if ((keymic[0] == wpa->keymic[0])
&& (keymic[1] == wpa->keymic[1])
&& (keymic[2] == wpa->keymic[2])
&& (keymic[3] == wpa->keymic[3]))
{
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0);
}
}
}
}
__kernel void m02501_aux3 (__global pw_t *pws, __global const kernel_rule_t *rules_buf, __global const pw_t *combs_buf, __global const bf_t *bfs_buf, __global wpa_tmp_t *tmps, __global void *hooks, __global const u32 *bitmaps_buf_s1_a, __global const u32 *bitmaps_buf_s1_b, __global const u32 *bitmaps_buf_s1_c, __global const u32 *bitmaps_buf_s1_d, __global const u32 *bitmaps_buf_s2_a, __global const u32 *bitmaps_buf_s2_b, __global const u32 *bitmaps_buf_s2_c, __global const u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global const digest_t *digests_buf, __global u32 *hashes_shown, __global const salt_t *salt_bufs, __global const wpa_t *wpa_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV0_buf, __global u32 *d_scryptV1_buf, __global u32 *d_scryptV2_buf, __global u32 *d_scryptV3_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u64 gid_max)
{
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
@ -294,448 +683,86 @@ __kernel void m02501_comp (__global pw_t *pws, __global const kernel_rule_t *rul
keymic[2] = 0;
keymic[3] = 0;
if (wpa->keyver == 1)
sha256_hmac_ctx_t ctx1;
sha256_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha256_hmac_update (&ctx1, pke, 102);
sha256_hmac_final (&ctx1);
u32 digest[4];
digest[0] = swap32_S (ctx1.opad.h[0]);
digest[1] = swap32_S (ctx1.opad.h[1]);
digest[2] = swap32_S (ctx1.opad.h[2]);
digest[3] = swap32_S (ctx1.opad.h[3]);
// AES CMAC
u32 ks[44];
aes128_set_encrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3, s_te4);
u32 m[4];
m[0] = 0;
m[1] = 0;
m[2] = 0;
m[3] = 0;
u32 iv[4];
iv[0] = 0;
iv[1] = 0;
iv[2] = 0;
iv[3] = 0;
int eapol_left;
int eapol_idx;
for (eapol_left = wpa->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4)
{
sha1_hmac_ctx_t ctx1;
m[0] = wpa->eapol[eapol_idx + 0] ^ iv[0];
m[1] = wpa->eapol[eapol_idx + 1] ^ iv[1];
m[2] = wpa->eapol[eapol_idx + 2] ^ iv[2];
m[3] = wpa->eapol[eapol_idx + 3] ^ iv[3];
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = swap32_S (digest[0]);
t0[1] = swap32_S (digest[1]);
t0[2] = swap32_S (digest[2]);
t0[3] = swap32_S (digest[3]);
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
md5_hmac_ctx_t ctx2;
md5_hmac_init_64 (&ctx2, t0, t1, t2, t3);
md5_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
md5_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4);
}
else if (wpa->keyver == 2)
m[0] = wpa->eapol[eapol_idx + 0];
m[1] = wpa->eapol[eapol_idx + 1];
m[2] = wpa->eapol[eapol_idx + 2];
m[3] = wpa->eapol[eapol_idx + 3];
u32 k[4];
k[0] = 0;
k[1] = 0;
k[2] = 0;
k[3] = 0;
aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4);
make_kn (k);
if (eapol_left < 16)
{
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = digest[0];
t0[1] = digest[1];
t0[2] = digest[2];
t0[3] = digest[3];
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
sha1_hmac_ctx_t ctx2;
sha1_hmac_init_64 (&ctx2, t0, t1, t2, t3);
sha1_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
sha1_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
}
else if (wpa->keyver == 3)
{
sha256_hmac_ctx_t ctx1;
sha256_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha256_hmac_update (&ctx1, pke, 102);
sha256_hmac_final (&ctx1);
u32 digest[4];
digest[0] = swap32_S (ctx1.opad.h[0]);
digest[1] = swap32_S (ctx1.opad.h[1]);
digest[2] = swap32_S (ctx1.opad.h[2]);
digest[3] = swap32_S (ctx1.opad.h[3]);
// AES CMAC
u32 ks[44];
aes128_set_encrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3, s_te4);
u32 m[4];
m[0] = 0;
m[1] = 0;
m[2] = 0;
m[3] = 0;
u32 iv[4];
iv[0] = 0;
iv[1] = 0;
iv[2] = 0;
iv[3] = 0;
int eapol_left;
int eapol_idx;
for (eapol_left = wpa->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4)
{
m[0] = wpa->eapol[eapol_idx + 0] ^ iv[0];
m[1] = wpa->eapol[eapol_idx + 1] ^ iv[1];
m[2] = wpa->eapol[eapol_idx + 2] ^ iv[2];
m[3] = wpa->eapol[eapol_idx + 3] ^ iv[3];
aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4);
}
m[0] = wpa->eapol[eapol_idx + 0];
m[1] = wpa->eapol[eapol_idx + 1];
m[2] = wpa->eapol[eapol_idx + 2];
m[3] = wpa->eapol[eapol_idx + 3];
u32 k[4];
k[0] = 0;
k[1] = 0;
k[2] = 0;
k[3] = 0;
aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4);
make_kn (k);
if (eapol_left < 16)
{
make_kn (k);
}
m[0] ^= k[0];
m[1] ^= k[1];
m[2] ^= k[2];
m[3] ^= k[3];
m[0] ^= iv[0];
m[1] ^= iv[1];
m[2] ^= iv[2];
m[3] ^= iv[3];
aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4);
}
/**
* final compare
*/
m[0] ^= k[0];
m[1] ^= k[1];
m[2] ^= k[2];
m[3] ^= k[3];
if ((keymic[0] == wpa->keymic[0])
&& (keymic[1] == wpa->keymic[1])
&& (keymic[2] == wpa->keymic[2])
&& (keymic[3] == wpa->keymic[3]))
{
if (atomic_inc (&hashes_shown[digest_cur]) == 0)
{
mark_hash (plains_buf, d_return_buf, salt_pos, digests_cnt, digest_pos, digest_cur, gid, 0);
}
}
}
m[0] ^= iv[0];
m[1] ^= iv[1];
m[2] ^= iv[2];
m[3] ^= iv[3];
// the same code again, but with BE order for the t++
for (u32 nonce_error_correction = 0; nonce_error_correction <= nonce_error_corrections; nonce_error_correction++)
{
u32 t = to;
t -= nonce_error_corrections / 2;
t += nonce_error_correction;
if (t == to) continue; // we already had this checked in the LE loop
if (wpa->nonce_compare < 0)
{
pke[15] = (pke[15] & ~0x000000ff) | (t >> 24);
pke[16] = (pke[16] & ~0xffffff00) | (t << 8);
}
else
{
pke[23] = (pke[23] & ~0x000000ff) | (t >> 24);
pke[24] = (pke[24] & ~0xffffff00) | (t << 8);
}
u32 w0[4];
u32 w1[4];
u32 w2[4];
u32 w3[4];
w0[0] = out[0];
w0[1] = out[1];
w0[2] = out[2];
w0[3] = out[3];
w1[0] = out[4];
w1[1] = out[5];
w1[2] = out[6];
w1[3] = out[7];
w2[0] = 0;
w2[1] = 0;
w2[2] = 0;
w2[3] = 0;
w3[0] = 0;
w3[1] = 0;
w3[2] = 0;
w3[3] = 0;
u32 keymic[4];
keymic[0] = 0;
keymic[1] = 0;
keymic[2] = 0;
keymic[3] = 0;
if (wpa->keyver == 1)
{
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = swap32_S (digest[0]);
t0[1] = swap32_S (digest[1]);
t0[2] = swap32_S (digest[2]);
t0[3] = swap32_S (digest[3]);
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
md5_hmac_ctx_t ctx2;
md5_hmac_init_64 (&ctx2, t0, t1, t2, t3);
md5_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
md5_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
}
else if (wpa->keyver == 2)
{
sha1_hmac_ctx_t ctx1;
sha1_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha1_hmac_update (&ctx1, pke, 100);
sha1_hmac_final (&ctx1);
u32 digest[4];
digest[0] = ctx1.opad.h[0];
digest[1] = ctx1.opad.h[1];
digest[2] = ctx1.opad.h[2];
digest[3] = ctx1.opad.h[3];
u32 t0[4];
u32 t1[4];
u32 t2[4];
u32 t3[4];
t0[0] = digest[0];
t0[1] = digest[1];
t0[2] = digest[2];
t0[3] = digest[3];
t1[0] = 0;
t1[1] = 0;
t1[2] = 0;
t1[3] = 0;
t2[0] = 0;
t2[1] = 0;
t2[2] = 0;
t2[3] = 0;
t3[0] = 0;
t3[1] = 0;
t3[2] = 0;
t3[3] = 0;
sha1_hmac_ctx_t ctx2;
sha1_hmac_init_64 (&ctx2, t0, t1, t2, t3);
sha1_hmac_update_global (&ctx2, wpa->eapol, wpa->eapol_len);
sha1_hmac_final (&ctx2);
keymic[0] = ctx2.opad.h[0];
keymic[1] = ctx2.opad.h[1];
keymic[2] = ctx2.opad.h[2];
keymic[3] = ctx2.opad.h[3];
}
else if (wpa->keyver == 3)
{
sha256_hmac_ctx_t ctx1;
sha256_hmac_init_64 (&ctx1, w0, w1, w2, w3);
sha256_hmac_update (&ctx1, pke, 102);
sha256_hmac_final (&ctx1);
u32 digest[4];
digest[0] = swap32_S (ctx1.opad.h[0]);
digest[1] = swap32_S (ctx1.opad.h[1]);
digest[2] = swap32_S (ctx1.opad.h[2]);
digest[3] = swap32_S (ctx1.opad.h[3]);
// AES CMAC
u32 ks[44];
aes128_set_encrypt_key (ks, digest, s_te0, s_te1, s_te2, s_te3, s_te4);
u32 m[4];
m[0] = 0;
m[1] = 0;
m[2] = 0;
m[3] = 0;
u32 iv[4];
iv[0] = 0;
iv[1] = 0;
iv[2] = 0;
iv[3] = 0;
int eapol_left;
int eapol_idx;
for (eapol_left = wpa->eapol_len, eapol_idx = 0; eapol_left > 16; eapol_left -= 16, eapol_idx += 4)
{
m[0] = wpa->eapol[eapol_idx + 0] ^ iv[0];
m[1] = wpa->eapol[eapol_idx + 1] ^ iv[1];
m[2] = wpa->eapol[eapol_idx + 2] ^ iv[2];
m[3] = wpa->eapol[eapol_idx + 3] ^ iv[3];
aes128_encrypt (ks, m, iv, s_te0, s_te1, s_te2, s_te3, s_te4);
}
m[0] = wpa->eapol[eapol_idx + 0];
m[1] = wpa->eapol[eapol_idx + 1];
m[2] = wpa->eapol[eapol_idx + 2];
m[3] = wpa->eapol[eapol_idx + 3];
u32 k[4];
k[0] = 0;
k[1] = 0;
k[2] = 0;
k[3] = 0;
aes128_encrypt (ks, k, k, s_te0, s_te1, s_te2, s_te3, s_te4);
make_kn (k);
if (eapol_left < 16)
{
make_kn (k);
}
m[0] ^= k[0];
m[1] ^= k[1];
m[2] ^= k[2];
m[3] ^= k[3];
m[0] ^= iv[0];
m[1] ^= iv[1];
m[2] ^= iv[2];
m[3] ^= iv[3];
aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4);
}
aes128_encrypt (ks, m, keymic, s_te0, s_te1, s_te2, s_te3, s_te4);
/**
* final compare

View File

@ -64,6 +64,7 @@
- OpenCL Kernels: Replace variables from uXX to uXXa if used in __constant space
- OpenCL Kernels: Use a special kernel to initialize the password buffer used during autotune measurements, to reduce startup time
- OpenCL Kernels: Refactored kernel thread management from native to maximum per kernel
- OpenCL Kernels: Use three separate comparison kernels (depending on keyver) for WPA instead of one
- OpenCL Runtime: Add current timestamp to OpenCL kernel source in order to force OpenCL JiT compiler to recompile and not use the cache
- OpenCL Runtime: Enforce to use OpenCL version 1.2 to restrain OpenCL runtimes to make use of the __generic address space qualifier
- OpenCL Runtime: Updated rocm detection

View File

@ -220,14 +220,18 @@ typedef enum combinator_mode
typedef enum kern_run
{
KERN_RUN_1 = 1000,
KERN_RUN_12 = 1500,
KERN_RUN_2 = 2000,
KERN_RUN_23 = 2500,
KERN_RUN_3 = 3000,
KERN_RUN_4 = 4000,
KERN_RUN_INIT2 = 5000,
KERN_RUN_LOOP2 = 6000
KERN_RUN_1 = 1000,
KERN_RUN_12 = 1500,
KERN_RUN_2 = 2000,
KERN_RUN_23 = 2500,
KERN_RUN_3 = 3000,
KERN_RUN_4 = 4000,
KERN_RUN_INIT2 = 5000,
KERN_RUN_LOOP2 = 6000,
KERN_RUN_AUX1 = 7001,
KERN_RUN_AUX2 = 7002,
KERN_RUN_AUX3 = 7003,
KERN_RUN_AUX4 = 7004,
} kern_run_t;
@ -376,7 +380,11 @@ typedef enum opts_type
OPTS_TYPE_HOOK23 = (1ULL << 31),
OPTS_TYPE_INIT2 = (1ULL << 32),
OPTS_TYPE_LOOP2 = (1ULL << 33),
OPTS_TYPE_BINARY_HASHFILE = (1ULL << 34),
OPTS_TYPE_AUX1 = (1ULL << 34),
OPTS_TYPE_AUX2 = (1ULL << 35),
OPTS_TYPE_AUX3 = (1ULL << 36),
OPTS_TYPE_AUX4 = (1ULL << 37),
OPTS_TYPE_BINARY_HASHFILE = (1ULL << 38),
} opts_type_t;
@ -938,6 +946,10 @@ typedef struct hc_device_param
u32 kernel_wgs_memset;
u32 kernel_wgs_atinit;
u32 kernel_wgs_decompress;
u32 kernel_wgs_aux1;
u32 kernel_wgs_aux2;
u32 kernel_wgs_aux3;
u32 kernel_wgs_aux4;
u32 kernel_preferred_wgs_multiple1;
u32 kernel_preferred_wgs_multiple12;
@ -955,6 +967,10 @@ typedef struct hc_device_param
u32 kernel_preferred_wgs_multiple_memset;
u32 kernel_preferred_wgs_multiple_atinit;
u32 kernel_preferred_wgs_multiple_decompress;
u32 kernel_preferred_wgs_multiple_aux1;
u32 kernel_preferred_wgs_multiple_aux2;
u32 kernel_preferred_wgs_multiple_aux3;
u32 kernel_preferred_wgs_multiple_aux4;
u64 kernel_local_mem_size1;
u64 kernel_local_mem_size12;
@ -972,6 +988,10 @@ typedef struct hc_device_param
u64 kernel_local_mem_size_memset;
u64 kernel_local_mem_size_atinit;
u64 kernel_local_mem_size_decompress;
u64 kernel_local_mem_size_aux1;
u64 kernel_local_mem_size_aux2;
u64 kernel_local_mem_size_aux3;
u64 kernel_local_mem_size_aux4;
u32 kernel_threads;
@ -1042,6 +1062,10 @@ typedef struct hc_device_param
double exec_us_prev4[EXPECTED_ITERATIONS];
double exec_us_prev_init2[EXPECTED_ITERATIONS];
double exec_us_prev_loop2[EXPECTED_ITERATIONS];
double exec_us_prev_aux1[EXPECTED_ITERATIONS];
double exec_us_prev_aux2[EXPECTED_ITERATIONS];
double exec_us_prev_aux3[EXPECTED_ITERATIONS];
double exec_us_prev_aux4[EXPECTED_ITERATIONS];
// this is "current" speed
@ -1085,6 +1109,10 @@ typedef struct hc_device_param
cl_kernel kernel_memset;
cl_kernel kernel_atinit;
cl_kernel kernel_decompress;
cl_kernel kernel_aux1;
cl_kernel kernel_aux2;
cl_kernel kernel_aux3;
cl_kernel kernel_aux4;
cl_context context;

View File

@ -248,6 +248,10 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
memset (device_param->exec_us_prev4, 0, EXPECTED_ITERATIONS * sizeof (double));
memset (device_param->exec_us_prev_init2, 0, EXPECTED_ITERATIONS * sizeof (double));
memset (device_param->exec_us_prev_loop2, 0, EXPECTED_ITERATIONS * sizeof (double));
memset (device_param->exec_us_prev_aux1, 0, EXPECTED_ITERATIONS * sizeof (double));
memset (device_param->exec_us_prev_aux2, 0, EXPECTED_ITERATIONS * sizeof (double));
memset (device_param->exec_us_prev_aux3, 0, EXPECTED_ITERATIONS * sizeof (double));
memset (device_param->exec_us_prev_aux4, 0, EXPECTED_ITERATIONS * sizeof (double));
// store

View File

@ -22371,6 +22371,9 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
hashconfig->salt_type = SALT_TYPE_EMBEDDED;
hashconfig->attack_exec = ATTACK_EXEC_OUTSIDE_KERNEL;
hashconfig->opts_type = OPTS_TYPE_PT_GENERATE_LE
| OPTS_TYPE_AUX1
| OPTS_TYPE_AUX2
| OPTS_TYPE_AUX3
| OPTS_TYPE_BINARY_HASHFILE;
hashconfig->kern_type = KERN_TYPE_WPA;
hashconfig->dgst_size = DGST_SIZE_4_4;
@ -22389,6 +22392,9 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
hashconfig->salt_type = SALT_TYPE_EMBEDDED;
hashconfig->attack_exec = ATTACK_EXEC_OUTSIDE_KERNEL;
hashconfig->opts_type = OPTS_TYPE_PT_GENERATE_LE
| OPTS_TYPE_AUX1
| OPTS_TYPE_AUX2
| OPTS_TYPE_AUX3
| OPTS_TYPE_BINARY_HASHFILE;
hashconfig->kern_type = KERN_TYPE_WPAPMK;
hashconfig->dgst_size = DGST_SIZE_4_4;

View File

@ -1401,23 +1401,50 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
if (run_comp == true)
{
u32 loops_cnt = 1;
if ((hashconfig->hash_mode == 2500) || (hashconfig->hash_mode == 2501))
{
loops_cnt = hashes->salts_buf[salt_pos].digests_cnt;
const u32 loops_cnt = hashes->salts_buf[salt_pos].digests_cnt;
for (u32 loops_pos = 0; loops_pos < loops_cnt; loops_pos++)
{
device_param->kernel_params_buf32[28] = loops_pos;
device_param->kernel_params_buf32[29] = loops_cnt;
const u32 digests_offset = hashes->salts_buf[salt_pos].digests_offset;
wpa_t *wpas = (wpa_t *) hashes->esalts_buf;
wpa_t *wpa = &wpas[digests_offset + loops_pos];
printf ("%u\n", wpa->keyver);
if (wpa->keyver == 1)
{
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX1, pws_cnt, false, 0);
if (CL_rc == -1) return -1;
}
else if (wpa->keyver == 2)
{
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX2, pws_cnt, false, 0);
if (CL_rc == -1) return -1;
}
else if (wpa->keyver == 3)
{
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX3, pws_cnt, false, 0);
if (CL_rc == -1) return -1;
}
if (status_ctx->run_thread_level2 == false) break;
}
}
for (u32 loops_pos = 0; loops_pos < loops_cnt; loops_pos++)
else
{
device_param->kernel_params_buf32[28] = loops_pos;
device_param->kernel_params_buf32[29] = loops_cnt;
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_3, pws_cnt, false, 0);
if (CL_rc == -1) return -1;
if (status_ctx->run_thread_level2 == false) break;
}
}
}
@ -1523,6 +1550,22 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con
kernel = device_param->kernel_loop2;
kernel_threads = device_param->kernel_wgs_loop2;
break;
case KERN_RUN_AUX1:
kernel = device_param->kernel_aux1;
kernel_threads = device_param->kernel_wgs_aux1;
break;
case KERN_RUN_AUX2:
kernel = device_param->kernel_aux2;
kernel_threads = device_param->kernel_wgs_aux2;
break;
case KERN_RUN_AUX3:
kernel = device_param->kernel_aux3;
kernel_threads = device_param->kernel_wgs_aux3;
break;
case KERN_RUN_AUX4:
kernel = device_param->kernel_aux4;
kernel_threads = device_param->kernel_wgs_aux4;
break;
default:
event_log_error (hashcat_ctx, "Invalid kernel specified.");
return -1;
@ -1614,12 +1657,16 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con
{
switch (kern_run)
{
case KERN_RUN_1: if (device_param->exec_us_prev1[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev1[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_2: if (device_param->exec_us_prev2[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev2[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_3: if (device_param->exec_us_prev3[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev3[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_4: if (device_param->exec_us_prev4[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev4[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_INIT2: if (device_param->exec_us_prev_init2[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev_init2[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_LOOP2: if (device_param->exec_us_prev_loop2[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev_loop2[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_1: if (device_param->exec_us_prev1[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev1[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_2: if (device_param->exec_us_prev2[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev2[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_3: if (device_param->exec_us_prev3[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev3[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_4: if (device_param->exec_us_prev4[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev4[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_INIT2: if (device_param->exec_us_prev_init2[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev_init2[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_LOOP2: if (device_param->exec_us_prev_loop2[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev_loop2[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_AUX1: if (device_param->exec_us_prev_aux1[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev_aux1[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_AUX2: if (device_param->exec_us_prev_aux2[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev_aux2[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_AUX3: if (device_param->exec_us_prev_aux3[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev_aux3[iteration] * device_param->nvidia_spin_damp)); break;
case KERN_RUN_AUX4: if (device_param->exec_us_prev_aux4[iteration] > 0) usleep ((useconds_t)(device_param->exec_us_prev_aux4[iteration] * device_param->nvidia_spin_damp)); break;
}
}
}
@ -1643,12 +1690,16 @@ int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, con
{
switch (kern_run)
{
case KERN_RUN_1: device_param->exec_us_prev1[iteration] = exec_us; break;
case KERN_RUN_2: device_param->exec_us_prev2[iteration] = exec_us; break;
case KERN_RUN_3: device_param->exec_us_prev3[iteration] = exec_us; break;
case KERN_RUN_4: device_param->exec_us_prev4[iteration] = exec_us; break;
case KERN_RUN_INIT2: device_param->exec_us_prev_init2[iteration] = exec_us; break;
case KERN_RUN_LOOP2: device_param->exec_us_prev_loop2[iteration] = exec_us; break;
case KERN_RUN_1: device_param->exec_us_prev1[iteration] = exec_us; break;
case KERN_RUN_2: device_param->exec_us_prev2[iteration] = exec_us; break;
case KERN_RUN_3: device_param->exec_us_prev3[iteration] = exec_us; break;
case KERN_RUN_4: device_param->exec_us_prev4[iteration] = exec_us; break;
case KERN_RUN_INIT2: device_param->exec_us_prev_init2[iteration] = exec_us; break;
case KERN_RUN_LOOP2: device_param->exec_us_prev_loop2[iteration] = exec_us; break;
case KERN_RUN_AUX1: device_param->exec_us_prev_aux1[iteration] = exec_us; break;
case KERN_RUN_AUX2: device_param->exec_us_prev_aux2[iteration] = exec_us; break;
case KERN_RUN_AUX3: device_param->exec_us_prev_aux3[iteration] = exec_us; break;
case KERN_RUN_AUX4: device_param->exec_us_prev_aux4[iteration] = exec_us; break;
}
}
}
@ -5624,6 +5675,98 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
if (CL_rc == -1) return -1;
}
// aux1
if (hashconfig->opts_type & OPTS_TYPE_AUX1)
{
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux1", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux1);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_aux1, &device_param->kernel_wgs_aux1);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_aux1, &device_param->kernel_local_mem_size_aux1);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_aux1, &device_param->kernel_preferred_wgs_multiple_aux1);
if (CL_rc == -1) return -1;
}
// aux2
if (hashconfig->opts_type & OPTS_TYPE_AUX2)
{
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux2", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux2);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_aux2, &device_param->kernel_wgs_aux2);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_aux2, &device_param->kernel_local_mem_size_aux2);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_aux2, &device_param->kernel_preferred_wgs_multiple_aux2);
if (CL_rc == -1) return -1;
}
// aux3
if (hashconfig->opts_type & OPTS_TYPE_AUX3)
{
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux3", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux3);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_aux3, &device_param->kernel_wgs_aux3);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_aux3, &device_param->kernel_local_mem_size_aux3);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_aux3, &device_param->kernel_preferred_wgs_multiple_aux3);
if (CL_rc == -1) return -1;
}
// aux4
if (hashconfig->opts_type & OPTS_TYPE_AUX4)
{
snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_aux4", hashconfig->kern_type);
CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_aux4);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_aux4, &device_param->kernel_wgs_aux4);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_aux4, &device_param->kernel_local_mem_size_aux4);
if (CL_rc == -1) return -1;
CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_aux4, &device_param->kernel_preferred_wgs_multiple_aux4);
if (CL_rc == -1) return -1;
}
}
// GPU memset
@ -6224,6 +6367,10 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx)
if (device_param->kernel_memset) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_memset);
if (device_param->kernel_atinit) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_atinit);
if (device_param->kernel_decompress)hc_clReleaseKernel (hashcat_ctx, device_param->kernel_decompress);
if (device_param->kernel_aux1) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_aux1);
if (device_param->kernel_aux2) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_aux2);
if (device_param->kernel_aux3) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_aux3);
if (device_param->kernel_aux4) hc_clReleaseKernel (hashcat_ctx, device_param->kernel_aux4);
if (device_param->program) hc_clReleaseProgram (hashcat_ctx, device_param->program);
if (device_param->program_mp) hc_clReleaseProgram (hashcat_ctx, device_param->program_mp);

View File

@ -412,11 +412,17 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
{
device_param->kernel_params_buf32[28] = 0;
device_param->kernel_params_buf32[29] = 1;
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX1, 1, false, 0);
if (CL_rc == -1) return -1;
}
else
{
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0);
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0);
if (CL_rc == -1) return -1;
if (CL_rc == -1) return -1;
}
}
// check : check if cracked