2 * Author......: Jens Steube <jens.steube@gmail.com>
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
24 #include "include/kernel_functions.c"
26 #include "common_nv.c"
29 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
30 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
34 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
35 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
39 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
40 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
51 __device__ static void swap (RC4_KEY *rc4_key, const u8 i, const u8 j)
56 rc4_key->S[i] = rc4_key->S[j];
60 __device__ static void rc4_init_16 (RC4_KEY *rc4_key, const u32 data[4])
65 u32 *ptr = (u32 *) rc4_key->S;
68 for (u32 i = 0; i < 64; i++)
75 for (u32 i = 0; i < 16; i++)
83 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
84 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
85 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
86 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
90 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
91 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
92 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
93 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
97 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
98 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
99 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
100 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
104 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
105 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
106 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
107 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
111 __device__ static u8 rc4_next_16 (RC4_KEY *rc4_key, u8 i, u8 j, const u32 in[4], u32 out[4])
113 for (u32 k = 0; k < 4; k++)
122 swap (rc4_key, i, j);
124 idx = rc4_key->S[i] + rc4_key->S[j];
126 xor4 |= rc4_key->S[idx] << 0;
131 swap (rc4_key, i, j);
133 idx = rc4_key->S[i] + rc4_key->S[j];
135 xor4 |= rc4_key->S[idx] << 8;
140 swap (rc4_key, i, j);
142 idx = rc4_key->S[i] + rc4_key->S[j];
144 xor4 |= rc4_key->S[idx] << 16;
149 swap (rc4_key, i, j);
151 idx = rc4_key->S[i] + rc4_key->S[j];
153 xor4 |= rc4_key->S[idx] << 24;
155 out[k] = in[k] ^ xor4;
161 __device__ static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
185 MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
186 MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
187 MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
188 MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
189 MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
190 MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
191 MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
192 MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
193 MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
194 MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
195 MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
196 MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
197 MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
198 MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
199 MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
200 MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
202 MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
203 MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
204 MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
205 MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
206 MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
207 MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
208 MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
209 MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
210 MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
211 MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
212 MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
213 MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
214 MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
215 MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
216 MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
217 MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
219 MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
220 MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
221 MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
222 MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
223 MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
224 MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
225 MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
226 MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
227 MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
228 MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
229 MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
230 MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
231 MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
232 MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
233 MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
234 MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
236 MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
237 MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
238 MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
239 MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
240 MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
241 MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
242 MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
243 MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
244 MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
245 MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
246 MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
247 MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
248 MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
249 MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
250 MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
251 MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
259 __device__ __constant__ comb_t c_combs[1024];
261 extern "C" __global__ void __launch_bounds__ (64, 1) m09710_m04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const oldoffice01_t *oldoffice01_bufs, u32 *d_return_buf, u32 *d_scryptV_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
267 const u32 lid = threadIdx.x;
269 __shared__ RC4_KEY rc4_keys[64];
271 RC4_KEY *rc4_key = &rc4_keys[lid];
277 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
279 if (gid >= gid_max) return;
283 wordl0[0] = pws[gid].i[ 0];
284 wordl0[1] = pws[gid].i[ 1];
285 wordl0[2] = pws[gid].i[ 2];
286 wordl0[3] = pws[gid].i[ 3];
290 wordl1[0] = pws[gid].i[ 4];
291 wordl1[1] = pws[gid].i[ 5];
292 wordl1[2] = pws[gid].i[ 6];
293 wordl1[3] = pws[gid].i[ 7];
309 const u32 pw_l_len = pws[gid].pw_len;
311 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
313 switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, c_combs[0].pw_len);
320 const u32 version = oldoffice01_bufs[salt_pos].version;
322 u32 encryptedVerifier[4];
324 encryptedVerifier[0] = oldoffice01_bufs[salt_pos].encryptedVerifier[0];
325 encryptedVerifier[1] = oldoffice01_bufs[salt_pos].encryptedVerifier[1];
326 encryptedVerifier[2] = oldoffice01_bufs[salt_pos].encryptedVerifier[2];
327 encryptedVerifier[3] = oldoffice01_bufs[salt_pos].encryptedVerifier[3];
333 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
337 wordr0[0] = c_combs[il_pos].i[0];
338 wordr0[1] = c_combs[il_pos].i[1];
339 wordr0[2] = c_combs[il_pos].i[2];
340 wordr0[3] = c_combs[il_pos].i[3];
344 wordr1[0] = c_combs[il_pos].i[4];
345 wordr1[1] = c_combs[il_pos].i[5];
346 wordr1[2] = c_combs[il_pos].i[6];
347 wordr1[3] = c_combs[il_pos].i[7];
363 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
365 switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
368 // first md5 to generate RC4 128 bit key
375 w0_t[0] = wordl0[0] | wordr0[0];
376 w0_t[1] = (wordl0[1] | wordr0[1]) & 0xff;
399 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
410 rc4_init_16 (rc4_key, key);
414 u8 j = rc4_next_16 (rc4_key, 0, 0, encryptedVerifier, out);
438 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
440 rc4_next_16 (rc4_key, 16, j, digest, out);
442 const u32x r0 = out[0];
443 const u32x r1 = out[1];
444 const u32x r2 = out[2];
445 const u32x r3 = out[3];
447 #include VECT_COMPARE_M
451 extern "C" __global__ void __launch_bounds__ (64, 1) m09710_m08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const oldoffice01_t *oldoffice01_bufs, u32 *d_return_buf, u32 *d_scryptV_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
455 extern "C" __global__ void __launch_bounds__ (64, 1) m09710_m16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const oldoffice01_t *oldoffice01_bufs, u32 *d_return_buf, u32 *d_scryptV_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
459 extern "C" __global__ void __launch_bounds__ (64, 1) m09710_s04 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const oldoffice01_t *oldoffice01_bufs, u32 *d_return_buf, u32 *d_scryptV_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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
465 const u32 lid = threadIdx.x;
467 __shared__ RC4_KEY rc4_keys[64];
469 RC4_KEY *rc4_key = &rc4_keys[lid];
475 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
477 if (gid >= gid_max) return;
481 wordl0[0] = pws[gid].i[ 0];
482 wordl0[1] = pws[gid].i[ 1];
483 wordl0[2] = pws[gid].i[ 2];
484 wordl0[3] = pws[gid].i[ 3];
488 wordl1[0] = pws[gid].i[ 4];
489 wordl1[1] = pws[gid].i[ 5];
490 wordl1[2] = pws[gid].i[ 6];
491 wordl1[3] = pws[gid].i[ 7];
507 const u32 pw_l_len = pws[gid].pw_len;
509 if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
511 switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, c_combs[0].pw_len);
518 const u32 search[4] =
520 digests_buf[digests_offset].digest_buf[DGST_R0],
521 digests_buf[digests_offset].digest_buf[DGST_R1],
522 digests_buf[digests_offset].digest_buf[DGST_R2],
523 digests_buf[digests_offset].digest_buf[DGST_R3]
530 const u32 version = oldoffice01_bufs[salt_pos].version;
532 u32 encryptedVerifier[4];
534 encryptedVerifier[0] = oldoffice01_bufs[salt_pos].encryptedVerifier[0];
535 encryptedVerifier[1] = oldoffice01_bufs[salt_pos].encryptedVerifier[1];
536 encryptedVerifier[2] = oldoffice01_bufs[salt_pos].encryptedVerifier[2];
537 encryptedVerifier[3] = oldoffice01_bufs[salt_pos].encryptedVerifier[3];
543 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
547 wordr0[0] = c_combs[il_pos].i[0];
548 wordr0[1] = c_combs[il_pos].i[1];
549 wordr0[2] = c_combs[il_pos].i[2];
550 wordr0[3] = c_combs[il_pos].i[3];
554 wordr1[0] = c_combs[il_pos].i[4];
555 wordr1[1] = c_combs[il_pos].i[5];
556 wordr1[2] = c_combs[il_pos].i[6];
557 wordr1[3] = c_combs[il_pos].i[7];
573 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
575 switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
578 // first md5 to generate RC4 128 bit key
585 w0_t[0] = wordl0[0] | wordr0[0];
586 w0_t[1] = (wordl0[1] | wordr0[1]) & 0xff;
609 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
620 rc4_init_16 (rc4_key, key);
624 u8 j = rc4_next_16 (rc4_key, 0, 0, encryptedVerifier, out);
648 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
650 rc4_next_16 (rc4_key, 16, j, digest, out);
652 const u32x r0 = out[0];
653 const u32x r1 = out[1];
654 const u32x r2 = out[2];
655 const u32x r3 = out[3];
657 #include VECT_COMPARE_S
661 extern "C" __global__ void __launch_bounds__ (64, 1) m09710_s08 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const oldoffice01_t *oldoffice01_bufs, u32 *d_return_buf, u32 *d_scryptV_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
665 extern "C" __global__ void __launch_bounds__ (64, 1) m09710_s16 (const pw_t *pws, const gpu_rule_t *rules_buf, const comb_t *combs_buf, const bf_t *bfs_buf, const void *tmps, void *hooks, const u32 *bitmaps_buf_s1_a, const u32 *bitmaps_buf_s1_b, const u32 *bitmaps_buf_s1_c, const u32 *bitmaps_buf_s1_d, const u32 *bitmaps_buf_s2_a, const u32 *bitmaps_buf_s2_b, const u32 *bitmaps_buf_s2_c, const u32 *bitmaps_buf_s2_d, plain_t *plains_buf, const digest_t *digests_buf, u32 *hashes_shown, const salt_t *salt_bufs, const oldoffice01_t *oldoffice01_bufs, u32 *d_return_buf, u32 *d_scryptV_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)