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"
27 #include "include/rp_gpu.h"
31 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
32 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
36 #define VECT_COMPARE_S "check_single_vect2_comp4.c"
37 #define VECT_COMPARE_M "check_multi_vect2_comp4.c"
41 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
42 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
53 __device__ static void swap (RC4_KEY *rc4_key, const u8 i, const u8 j)
58 rc4_key->S[i] = rc4_key->S[j];
62 __device__ static void rc4_init_16 (RC4_KEY *rc4_key, const u32 data[4])
67 u32 *ptr = (u32 *) rc4_key->S;
70 for (u32 i = 0; i < 64; i++)
77 for (u32 i = 0; i < 16; i++)
85 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
86 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
87 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
88 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
92 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
93 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
94 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
95 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
99 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
100 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
101 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
102 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
106 j += rc4_key->S[idx] + (v >> 0); swap (rc4_key, idx, j); idx++;
107 j += rc4_key->S[idx] + (v >> 8); swap (rc4_key, idx, j); idx++;
108 j += rc4_key->S[idx] + (v >> 16); swap (rc4_key, idx, j); idx++;
109 j += rc4_key->S[idx] + (v >> 24); swap (rc4_key, idx, j); idx++;
113 __device__ static u8 rc4_next_16 (RC4_KEY *rc4_key, u8 i, u8 j, const u32 in[4], u32 out[4])
115 for (u32 k = 0; k < 4; k++)
124 swap (rc4_key, i, j);
126 idx = rc4_key->S[i] + rc4_key->S[j];
128 xor4 |= rc4_key->S[idx] << 0;
133 swap (rc4_key, i, j);
135 idx = rc4_key->S[i] + rc4_key->S[j];
137 xor4 |= rc4_key->S[idx] << 8;
142 swap (rc4_key, i, j);
144 idx = rc4_key->S[i] + rc4_key->S[j];
146 xor4 |= rc4_key->S[idx] << 16;
151 swap (rc4_key, i, j);
153 idx = rc4_key->S[i] + rc4_key->S[j];
155 xor4 |= rc4_key->S[idx] << 24;
157 out[k] = in[k] ^ xor4;
163 __device__ static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
187 MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
188 MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
189 MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
190 MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
191 MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
192 MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
193 MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
194 MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
195 MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
196 MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
197 MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
198 MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
199 MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
200 MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
201 MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
202 MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
204 MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
205 MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
206 MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
207 MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
208 MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
209 MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
210 MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
211 MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
212 MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
213 MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
214 MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
215 MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
216 MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
217 MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
218 MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
219 MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
221 MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
222 MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
223 MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
224 MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
225 MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
226 MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
227 MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
228 MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
229 MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
230 MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
231 MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
232 MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
233 MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
234 MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
235 MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
236 MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
238 MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
239 MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
240 MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
241 MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
242 MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
243 MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
244 MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
245 MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
246 MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
247 MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
248 MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
249 MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
250 MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
251 MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
252 MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
253 MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
261 __device__ __constant__ gpu_rule_t c_rules[1024];
263 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
269 const u32 lid = threadIdx.x;
271 __shared__ RC4_KEY rc4_keys[64];
273 RC4_KEY *rc4_key = &rc4_keys[lid];
279 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
281 if (gid >= gid_max) return;
285 pw_buf0[0] = pws[gid].i[ 0];
286 pw_buf0[1] = pws[gid].i[ 1];
287 pw_buf0[2] = pws[gid].i[ 2];
288 pw_buf0[3] = pws[gid].i[ 3];
292 pw_buf1[0] = pws[gid].i[ 4];
293 pw_buf1[1] = pws[gid].i[ 5];
294 pw_buf1[2] = pws[gid].i[ 6];
295 pw_buf1[3] = pws[gid].i[ 7];
297 const u32 pw_len = pws[gid].pw_len;
303 const u32 version = oldoffice01_bufs[salt_pos].version;
305 u32 encryptedVerifier[4];
307 encryptedVerifier[0] = oldoffice01_bufs[salt_pos].encryptedVerifier[0];
308 encryptedVerifier[1] = oldoffice01_bufs[salt_pos].encryptedVerifier[1];
309 encryptedVerifier[2] = oldoffice01_bufs[salt_pos].encryptedVerifier[2];
310 encryptedVerifier[3] = oldoffice01_bufs[salt_pos].encryptedVerifier[3];
316 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
346 apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
348 // first md5 to generate RC4 128 bit key
356 w0_t[1] = w0[1] & 0xff;
379 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
390 rc4_init_16 (rc4_key, key);
394 u8 j = rc4_next_16 (rc4_key, 0, 0, encryptedVerifier, out);
418 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
420 rc4_next_16 (rc4_key, 16, j, digest, out);
422 const u32x r0 = out[0];
423 const u32x r1 = out[1];
424 const u32x r2 = out[2];
425 const u32x r3 = out[3];
427 #include VECT_COMPARE_M
431 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)
435 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)
439 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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
445 const u32 lid = threadIdx.x;
447 __shared__ RC4_KEY rc4_keys[64];
449 RC4_KEY *rc4_key = &rc4_keys[lid];
455 const u32 gid = (blockIdx.x * blockDim.x) + threadIdx.x;
457 if (gid >= gid_max) return;
461 pw_buf0[0] = pws[gid].i[ 0];
462 pw_buf0[1] = pws[gid].i[ 1];
463 pw_buf0[2] = pws[gid].i[ 2];
464 pw_buf0[3] = pws[gid].i[ 3];
468 pw_buf1[0] = pws[gid].i[ 4];
469 pw_buf1[1] = pws[gid].i[ 5];
470 pw_buf1[2] = pws[gid].i[ 6];
471 pw_buf1[3] = pws[gid].i[ 7];
473 const u32 pw_len = pws[gid].pw_len;
479 const u32 search[4] =
481 digests_buf[digests_offset].digest_buf[DGST_R0],
482 digests_buf[digests_offset].digest_buf[DGST_R1],
483 digests_buf[digests_offset].digest_buf[DGST_R2],
484 digests_buf[digests_offset].digest_buf[DGST_R3]
491 const u32 version = oldoffice01_bufs[salt_pos].version;
493 u32 encryptedVerifier[4];
495 encryptedVerifier[0] = oldoffice01_bufs[salt_pos].encryptedVerifier[0];
496 encryptedVerifier[1] = oldoffice01_bufs[salt_pos].encryptedVerifier[1];
497 encryptedVerifier[2] = oldoffice01_bufs[salt_pos].encryptedVerifier[2];
498 encryptedVerifier[3] = oldoffice01_bufs[salt_pos].encryptedVerifier[3];
504 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
534 apply_rules (c_rules[il_pos].cmds, w0, w1, pw_len);
536 // first md5 to generate RC4 128 bit key
544 w0_t[1] = w0[1] & 0xff;
567 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
578 rc4_init_16 (rc4_key, key);
582 u8 j = rc4_next_16 (rc4_key, 0, 0, encryptedVerifier, out);
606 md5_transform (w0_t, w1_t, w2_t, w3_t, digest);
608 rc4_next_16 (rc4_key, 16, j, digest, out);
610 const u32x r0 = out[0];
611 const u32x r1 = out[1];
612 const u32x r2 = out[2];
613 const u32x r3 = out[3];
615 #include VECT_COMPARE_S
619 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)
623 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)