implements the enhancement mentioned in issue #10 (cancel on next checkpoint)
[hashcat.git] / src / oclHashcat.c
1 /**
2 * Author......: Jens Steube <jens.steube@gmail.com>
3 * License.....: MIT
4 */
5
6 #include <common.h>
7 #include <shared.h>
8 #include <rp_gpu_on_cpu.h>
9
10 #include <getopt.h>
11
12 #ifdef _CUDA
13 const char *PROGNAME = "cudaHashcat";
14 #elif _OCL
15 const char *PROGNAME = "oclHashcat";
16 #endif
17
18 const char *VERSION_TXT = "2.01";
19 const uint VERSION_BIN = 201;
20 const uint RESTORE_MIN = 200;
21
22 #define INCR_RULES 10000
23 #define INCR_SALTS 100000
24 #define INCR_MASKS 1000
25 #define INCR_POT 1000
26
27 // comment-out for kernel source mode
28
29 #define BINARY_KERNEL
30
31 #define USAGE 0
32 #define VERSION 0
33 #define QUIET 0
34 #define MARKOV_THRESHOLD 0
35 #define MARKOV_DISABLE 0
36 #define MARKOV_CLASSIC 0
37 #define BENCHMARK 0
38 #define BENCHMARK_MODE 1
39 #define RESTORE 0
40 #define RESTORE_TIMER 60
41 #define RESTORE_DISABLE 0
42 #define STATUS 0
43 #define STATUS_TIMER 10
44 #define STATUS_AUTOMAT 0
45 #define LOOPBACK 0
46 #define WEAK_HASH_THRESHOLD 100
47 #define SHOW 0
48 #define LEFT 0
49 #define USERNAME 0
50 #define REMOVE 0
51 #define REMOVE_TIMER 60
52 #define SKIP 0
53 #define LIMIT 0
54 #define KEYSPACE 0
55 #define POTFILE_DISABLE 0
56 #define DEBUG_MODE 0
57 #define RP_GEN 0
58 #define RP_GEN_FUNC_MIN 1
59 #define RP_GEN_FUNC_MAX 4
60 #define RP_GEN_SEED 0
61 #define RULE_BUF_L ":"
62 #define RULE_BUF_R ":"
63 #define FORCE 0
64 #define RUNTIME 0
65 #define HEX_CHARSET 0
66 #define HEX_SALT 0
67 #define HEX_WORDLIST 0
68 #define OUTFILE_FORMAT 3
69 #define OUTFILE_AUTOHEX 1
70 #define OUTFILE_CHECK_TIMER 5
71 #define ATTACK_MODE 0
72 #define HASH_MODE 0
73 #define SEGMENT_SIZE 32
74 #define INCREMENT 0
75 #define INCREMENT_MIN 1
76 #define INCREMENT_MAX PW_MAX
77 #define SEPARATOR ':'
78 #define BITMAP_MIN 16
79 #define BITMAP_MAX 24
80 #define GPU_ASYNC 0
81 #define GPU_TEMP_DISABLE 0
82 #define GPU_TEMP_ABORT 90
83 #define GPU_TEMP_RETAIN 80
84 #define WORKLOAD_PROFILE 2
85 #define GPU_ACCEL 0
86 #define GPU_LOOPS 0
87 #define GPU_RULES 1024
88 #define GPU_COMBS 1024
89 #define GPU_BFS 1024
90 #define GPU_THREADS_AMD 64
91 #define GPU_THREADS_NV 256
92 #define POWERTUNE_ENABLE 0
93 #define LOGFILE_DISABLE 0
94 #define SCRYPT_TMTO 0
95
96 #define VECT_SIZE_1 1
97 #define VECT_SIZE_2 2
98 #define VECT_SIZE_4 4
99 #define VECT_SIZE_8 8
100
101 #define WL_MODE_STDIN 1
102 #define WL_MODE_FILE 2
103 #define WL_MODE_MASK 3
104
105 #define HL_MODE_FILE 4
106 #define HL_MODE_ARG 5
107
108 #define HLFMT_HASHCAT 0
109 #define HLFMT_PWDUMP 1
110 #define HLFMT_PASSWD 2
111 #define HLFMT_SHADOW 3
112 #define HLFMT_DCC 4
113 #define HLFMT_DCC2 5
114 #define HLFMT_NETNTLM1 7
115 #define HLFMT_NETNTLM2 8
116 #define HLFMT_NSLDAP 9
117 #define HLFMT_NSLDAPS 10
118 #define HLFMTS_CNT 11
119
120 #define ATTACK_MODE_STRAIGHT 0
121 #define ATTACK_MODE_COMBI 1
122 #define ATTACK_MODE_TOGGLE 2
123 #define ATTACK_MODE_BF 3
124 #define ATTACK_MODE_PERM 4
125 #define ATTACK_MODE_TABLE 5
126 #define ATTACK_MODE_HYBRID1 6
127 #define ATTACK_MODE_HYBRID2 7
128 #define ATTACK_MODE_NONE 100
129
130 #define ATTACK_KERN_STRAIGHT 0
131 #define ATTACK_KERN_COMBI 1
132 #define ATTACK_KERN_BF 3
133 #define ATTACK_KERN_NONE 100
134
135 #define ATTACK_EXEC_ON_CPU 10
136 #define ATTACK_EXEC_ON_GPU 11
137
138 #define COMBINATOR_MODE_BASE_LEFT 10001
139 #define COMBINATOR_MODE_BASE_RIGHT 10002
140
141 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
142 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
143
144 #define MAX_CUT_TRIES 4
145
146 #define MAX_DICTSTAT 10000
147
148 #define NUM_DEFAULT_BENCHMARK_ALGORITHMS 128
149
150 #define global_free(attr) \
151 { \
152 myfree ((void *) data.attr); \
153 \
154 data.attr = NULL; \
155 }
156
157 #define local_free(attr) \
158 { \
159 myfree ((void *) attr); \
160 \
161 attr = NULL; \
162 }
163
164 static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
165 {
166 900,
167 0,
168 5100,
169 100,
170 1400,
171 10800,
172 1700,
173 5000,
174 10100,
175 6000,
176 6100,
177 6900,
178 11700,
179 11800,
180 400,
181 8900,
182 11900,
183 12000,
184 10900,
185 12100,
186 23,
187 2500,
188 5300,
189 5400,
190 5500,
191 5600,
192 7300,
193 7500,
194 8300,
195 11100,
196 11200,
197 11400,
198 121,
199 2611,
200 2711,
201 2811,
202 8400,
203 11,
204 2612,
205 7900,
206 21,
207 11000,
208 124,
209 10000,
210 3711,
211 7600,
212 12,
213 131,
214 132,
215 1731,
216 200,
217 300,
218 3100,
219 112,
220 12300,
221 8000,
222 141,
223 1441,
224 1600,
225 12600,
226 1421,
227 101,
228 111,
229 1711,
230 3000,
231 1000,
232 1100,
233 2100,
234 12800,
235 1500,
236 12400,
237 500,
238 3200,
239 7400,
240 1800,
241 122,
242 1722,
243 7100,
244 6300,
245 6700,
246 6400,
247 6500,
248 2400,
249 2410,
250 5700,
251 9200,
252 9300,
253 22,
254 501,
255 5800,
256 8100,
257 8500,
258 7200,
259 9900,
260 7700,
261 7800,
262 10300,
263 8600,
264 8700,
265 9100,
266 133,
267 11600,
268 12500,
269 6211,
270 6221,
271 6231,
272 6241,
273 8800,
274 12200,
275 9700,
276 9710,
277 9800,
278 9810,
279 9400,
280 9500,
281 9600,
282 10400,
283 10410,
284 10500,
285 10600,
286 10700,
287 9000,
288 5200,
289 6800,
290 6600,
291 8200,
292 11300,
293 12700
294 };
295
296 /**
297 * types
298 */
299
300 static void (*get_next_word_func) (char *, uint32_t, uint32_t *, uint32_t *);
301
302 /**
303 * globals
304 */
305
306 static unsigned int full01 = 0x01010101;
307 static unsigned int full80 = 0x80808080;
308
309 int SUPPRESS_OUTPUT = 0;
310
311 hc_thread_mutex_t mux_adl;
312 hc_thread_mutex_t mux_counter;
313 hc_thread_mutex_t mux_dispatcher;
314 hc_thread_mutex_t mux_display;
315
316 hc_global_data_t data;
317
318 const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint stop [q]uit => ";
319
320 const char *USAGE_MINI[] =
321 {
322 "Usage: %s [options]... hash|hashfile|hccapfile [dictionary|mask|directory]...",
323 "",
324 "Try --help for more help.",
325 NULL
326 };
327
328 const char *USAGE_BIG[] =
329 {
330 "%s, advanced password recovery",
331 "",
332 "Usage: %s [options]... hash|hashfile|hccapfile [dictionary|mask|directory]...",
333 "",
334 "=======",
335 "Options",
336 "=======",
337 "",
338 "* General:",
339 "",
340 " -m, --hash-type=NUM Hash-type, see references below",
341 " -a, --attack-mode=NUM Attack-mode, see references below",
342 " -V, --version Print version",
343 " -h, --help Print help",
344 " --quiet Suppress output",
345 "",
346 "* Benchmark:",
347 "",
348 " -b, --benchmark Run benchmark",
349 " --benchmark-mode=NUM Benchmark-mode, see references below",
350 "",
351 "* Misc:",
352 "",
353 " --hex-charset Assume charset is given in hex",
354 " --hex-salt Assume salt is given in hex",
355 " --hex-wordlist Assume words in wordlist is given in hex",
356 " --force Ignore warnings",
357 " --status Enable automatic update of the status-screen",
358 " --status-timer=NUM Seconds between status-screen update",
359 " --status-automat Display the status view in a machine readable format",
360 " --loopback Add new plains to induct directory",
361 " --weak-hash-threshold=NUM Threshold when to stop checking for weak hashes, default is 100 salts",
362 "",
363 "* Markov:",
364 "",
365 " --markov-hcstat=FILE Specify hcstat file to use, default is hashcat.hcstat",
366 " --markov-disable Disables markov-chains, emulates classic brute-force",
367 " --markov-classic Enables classic markov-chains, no per-position enhancement",
368 " -t, --markov-threshold=NUM Threshold when to stop accepting new markov-chains",
369 "",
370 "* Session:",
371 "",
372 " --runtime=NUM Abort session after NUM seconds of runtime",
373 " --session=STR Define specific session name",
374 " --restore Restore session from --session",
375 " --restore-disable Do not write restore file",
376 "",
377 "* Files:",
378 "",
379 " -o, --outfile=FILE Define outfile for recovered hash",
380 " --outfile-format=NUM Define outfile-format for recovered hash, see references below",
381 " --outfile-autohex-disable Disable the use of $HEX[] in output plains",
382 " --outfile-check-timer=NUM Seconds between outfile checks",
383 " -p, --separator=CHAR Separator char for hashlists and outfile",
384 " --show Show cracked passwords only",
385 " --left Show un-cracked passwords only",
386 " --username Enable ignoring of usernames in hashfile (recommended: also use --show)",
387 " --remove Enable remove of hash once it is cracked",
388 " --remove-timer=NUM Update input hash file each NUM seconds",
389 " --potfile-disable Do not write potfile",
390 " --debug-mode=NUM Defines the debug mode (hybrid only by using rules), see references below",
391 " --debug-file=FILE Output file for debugging rules (see also --debug-mode)",
392 " --induction-dir=FOLDER Specify induction directory to use, default is $session.induct",
393 " --outfile-check-dir=FOLDER Specify the outfile directory which should be monitored, default is $session.outfiles",
394 " --logfile-disable Disable the logfile",
395 " --truecrypt-keyfiles=FILE Keyfiles used, seperate with comma",
396 "",
397 "* Resources:",
398 "",
399 " -c, --segment-size=NUM Size in MB to cache from the wordfile",
400 " --bitmap-min=NUM Minimum number of bits allowed for bitmaps",
401 " --bitmap-max=NUM Maximum number of bits allowed for bitmaps",
402 " --cpu-affinity=STR Locks to CPU devices, seperate with comma",
403 " --gpu-async Use non-blocking async calls (NV only)",
404 " -d, --gpu-devices=STR Devices to use, separate with comma",
405 " -w, --workload-profile=NUM Enable a specific workload profile, see references below",
406 " -n, --gpu-accel=NUM Workload tuning: 1, 8, 40, 80, 160",
407 " -u, --gpu-loops=NUM Workload fine-tuning: 8 - 1024",
408 " --gpu-temp-disable Disable temperature and fanspeed readings and triggers",
409 " --gpu-temp-abort=NUM Abort session if GPU temperature reaches NUM degrees celsius",
410 " --gpu-temp-retain=NUM Try to retain GPU temperature at NUM degrees celsius (AMD only)",
411 " --powertune-enable Enable automatic power tuning option (AMD OverDrive 6 only)",
412 " --scrypt-tmto=NUM Manually override automatically calculated TMTO value for scrypt",
413 "",
414 "* Distributed:",
415 "",
416 " -s, --skip=NUM Skip number of words",
417 " -l, --limit=NUM Limit number of words",
418 " --keyspace Show keyspace base:mod values and quit",
419 "",
420 "* Rules:",
421 "",
422 " -j, --rule-left=RULE Single rule applied to each word from left dict",
423 " -k, --rule-right=RULE Single rule applied to each word from right dict",
424 " -r, --rules-file=FILE Rules-file, multi use: -r 1.rule -r 2.rule",
425 " -g, --generate-rules=NUM Generate NUM random rules",
426 " --generate-rules-func-min=NUM Force NUM functions per random rule min",
427 " --generate-rules-func-max=NUM Force NUM functions per random rule max",
428 " --generate-rules-seed=NUM Force RNG seed to NUM",
429 "",
430 "* Custom charsets:",
431 "",
432 " -1, --custom-charset1=CS User-defined charsets",
433 " -2, --custom-charset2=CS Example:",
434 " -3, --custom-charset3=CS --custom-charset1=?dabcdef : sets charset ?1 to 0123456789abcdef",
435 " -4, --custom-charset4=CS -2 mycharset.hcchr : sets charset ?2 to chars contained in file",
436 "",
437 "* Increment:",
438 "",
439 " -i, --increment Enable increment mode",
440 " --increment-min=NUM Start incrementing at NUM",
441 " --increment-max=NUM Stop incrementing at NUM",
442 "",
443 "==========",
444 "References",
445 "==========",
446 "",
447 "* Workload Profile:",
448 "",
449 " 1 = Reduced performance profile (low latency desktop)",
450 " 2 = Default performance profile",
451 " 3 = Tuned performance profile (high latency desktop)",
452 "",
453 "* Benchmark Settings:",
454 "",
455 " 0 = Manual Tuning",
456 " 1 = Performance Tuning, default",
457 "",
458 "* Outfile Formats:",
459 "",
460 " 1 = hash[:salt]",
461 " 2 = plain",
462 " 3 = hash[:salt]:plain",
463 " 4 = hex_plain",
464 " 5 = hash[:salt]:hex_plain",
465 " 6 = plain:hex_plain",
466 " 7 = hash[:salt]:plain:hex_plain",
467 " 8 = crackpos",
468 " 9 = hash[:salt]:crackpos",
469 " 10 = plain:crackpos",
470 " 11 = hash[:salt]:plain:crackpos",
471 " 12 = hex_plain:crackpos",
472 " 13 = hash[:salt]:hex_plain:crackpos",
473 " 14 = plain:hex_plain:crackpos",
474 " 15 = hash[:salt]:plain:hex_plain:crackpos",
475 "",
476 "* Debug mode output formats (for hybrid mode only, by using rules):",
477 "",
478 " 1 = save finding rule",
479 " 2 = save original word",
480 " 3 = save original word and finding rule",
481 " 4 = save original word, finding rule and modified plain",
482 "",
483 "* Built-in charsets:",
484 "",
485 " ?l = abcdefghijklmnopqrstuvwxyz",
486 " ?u = ABCDEFGHIJKLMNOPQRSTUVWXYZ",
487 " ?d = 0123456789",
488 " ?s = !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
489 " ?a = ?l?u?d?s",
490 " ?b = 0x00 - 0xff",
491 "",
492 "* Attack modes:",
493 "",
494 " 0 = Straight",
495 " 1 = Combination",
496 " 3 = Brute-force",
497 " 6 = Hybrid dict + mask",
498 " 7 = Hybrid mask + dict",
499 "",
500 "* Hash types:",
501 "",
502 "[[ Roll-your-own: Raw Hashes ]]",
503 "",
504 " 900 = MD4",
505 " 0 = MD5",
506 " 5100 = Half MD5",
507 " 100 = SHA1",
508 " 10800 = SHA-384",
509 " 1400 = SHA-256",
510 " 1700 = SHA-512",
511 " 5000 = SHA-3(Keccak)",
512 " 10100 = SipHash",
513 " 6000 = RipeMD160",
514 " 6100 = Whirlpool",
515 " 6900 = GOST R 34.11-94",
516 " 11700 = GOST R 34.11-2012 (Streebog) 256-bit",
517 " 11800 = GOST R 34.11-2012 (Streebog) 512-bit",
518 "",
519 "[[ Roll-your-own: Iterated and / or Salted Hashes ]]",
520 "",
521 " 10 = md5($pass.$salt)",
522 " 20 = md5($salt.$pass)",
523 " 30 = md5(unicode($pass).$salt)",
524 " 40 = md5($salt.unicode($pass))",
525 " 3800 = md5($salt.$pass.$salt)",
526 " 3710 = md5($salt.md5($pass))",
527 " 2600 = md5(md5($pass)",
528 " 4300 = md5(strtoupper(md5($pass)))",
529 " 4400 = md5(sha1($pass))",
530 " 110 = sha1($pass.$salt)",
531 " 120 = sha1($salt.$pass)",
532 " 130 = sha1(unicode($pass).$salt)",
533 " 140 = sha1($salt.unicode($pass))",
534 " 4500 = sha1(sha1($pass)",
535 " 4700 = sha1(md5($pass))",
536 " 4900 = sha1($salt.$pass.$salt)",
537 " 1410 = sha256($pass.$salt)",
538 " 1420 = sha256($salt.$pass)",
539 " 1430 = sha256(unicode($pass).$salt)",
540 " 1440 = sha256($salt.unicode($pass))",
541 " 1710 = sha512($pass.$salt)",
542 " 1720 = sha512($salt.$pass)",
543 " 1730 = sha512(unicode($pass).$salt)",
544 " 1740 = sha512($salt.unicode($pass))",
545 "",
546 "[[ Roll-your-own: Authenticated Hashes ]]",
547 "",
548 " 50 = HMAC-MD5 (key = $pass)",
549 " 60 = HMAC-MD5 (key = $salt)",
550 " 150 = HMAC-SHA1 (key = $pass)",
551 " 160 = HMAC-SHA1 (key = $salt)",
552 " 1450 = HMAC-SHA256 (key = $pass)",
553 " 1460 = HMAC-SHA256 (key = $salt)",
554 " 1750 = HMAC-SHA512 (key = $pass)",
555 " 1760 = HMAC-SHA512 (key = $salt)",
556 "",
557 "[[ Generic KDF ]]",
558 "",
559 " 400 = phpass",
560 " 8900 = scrypt",
561 " 11900 = PBKDF2-HMAC-MD5",
562 " 12000 = PBKDF2-HMAC-SHA1",
563 " 10900 = PBKDF2-HMAC-SHA256",
564 " 12100 = PBKDF2-HMAC-SHA512",
565 "",
566 "[[ Network protocols, Challenge-Response ]]",
567 "",
568 " 23 = Skype",
569 " 2500 = WPA/WPA2",
570 " 4800 = iSCSI CHAP authentication, MD5(Chap)",
571 " 5300 = IKE-PSK MD5",
572 " 5400 = IKE-PSK SHA1",
573 " 5500 = NetNTLMv1",
574 " 5500 = NetNTLMv1 + ESS",
575 " 5600 = NetNTLMv2",
576 " 7300 = IPMI2 RAKP HMAC-SHA1",
577 " 7500 = Kerberos 5 AS-REQ Pre-Auth etype 23",
578 " 8300 = DNSSEC (NSEC3)",
579 " 10200 = Cram MD5",
580 " 11100 = PostgreSQL Challenge-Response Authentication (MD5)",
581 " 11200 = MySQL Challenge-Response Authentication (SHA1)",
582 " 11400 = SIP digest authentication (MD5)",
583 "",
584 "[[ Forums, CMS, E-Commerce, Frameworks, Middleware, Wiki, Management ]]",
585 "",
586 " 121 = SMF (Simple Machines Forum)",
587 " 400 = phpBB3",
588 " 2611 = vBulletin < v3.8.5",
589 " 2711 = vBulletin > v3.8.5",
590 " 2811 = MyBB",
591 " 2811 = IPB (Invison Power Board)",
592 " 8400 = WBB3 (Woltlab Burning Board)",
593 " 11 = Joomla < 2.5.18",
594 " 400 = Joomla > 2.5.18",
595 " 400 = Wordpress",
596 " 2612 = PHPS",
597 " 7900 = Drupal7",
598 " 21 = osCommerce",
599 " 21 = xt:Commerce",
600 " 11000 = PrestaShop",
601 " 124 = Django (SHA-1)",
602 " 10000 = Django (PBKDF2-SHA256)",
603 " 3711 = Mediawiki B type",
604 " 7600 = Redmine",
605 "",
606 "[[ Database Server ]]",
607 "",
608 " 12 = PostgreSQL",
609 " 131 = MSSQL(2000)",
610 " 132 = MSSQL(2005)",
611 " 1731 = MSSQL(2012)",
612 " 1731 = MSSQL(2014)",
613 " 200 = MySQL323",
614 " 300 = MySQL4.1/MySQL5",
615 " 3100 = Oracle H: Type (Oracle 7+)",
616 " 112 = Oracle S: Type (Oracle 11+)",
617 " 12300 = Oracle T: Type (Oracle 12+)",
618 " 8000 = Sybase ASE",
619 "",
620 "[[ HTTP, SMTP, LDAP Server]]",
621 "",
622 " 141 = EPiServer 6.x < v4",
623 " 1441 = EPiServer 6.x > v4",
624 " 1600 = Apache $apr1$",
625 " 12600 = ColdFusion 10+",
626 " 1421 = hMailServer",
627 " 101 = nsldap, SHA-1(Base64), Netscape LDAP SHA",
628 " 111 = nsldaps, SSHA-1(Base64), Netscape LDAP SSHA",
629 " 1711 = SSHA-512(Base64), LDAP {SSHA512}",
630 "",
631 "[[ Checksums ]]",
632 "",
633 " 11500 = CRC32",
634 "",
635 "[[ Operating-Systems ]]",
636 "",
637 " 3000 = LM",
638 " 1000 = NTLM",
639 " 1100 = Domain Cached Credentials (DCC), MS Cache",
640 " 2100 = Domain Cached Credentials 2 (DCC2), MS Cache 2",
641 " 12800 = MS-AzureSync PBKDF2-HMAC-SHA256",
642 " 1500 = descrypt, DES(Unix), Traditional DES",
643 " 12400 = BSDiCrypt, Extended DES",
644 " 500 = md5crypt $1$, MD5(Unix)",
645 " 3200 = bcrypt $2*$, Blowfish(Unix)",
646 " 7400 = sha256crypt $5$, SHA256(Unix)",
647 " 1800 = sha512crypt $6$, SHA512(Unix)",
648 " 122 = OSX v10.4",
649 " 122 = OSX v10.5",
650 " 122 = OSX v10.6",
651 " 1722 = OSX v10.7",
652 " 7100 = OSX v10.8",
653 " 7100 = OSX v10.9",
654 " 7100 = OSX v10.10",
655 " 6300 = AIX {smd5}",
656 " 6700 = AIX {ssha1}",
657 " 6400 = AIX {ssha256}",
658 " 6500 = AIX {ssha512}",
659 " 2400 = Cisco-PIX",
660 " 2410 = Cisco-ASA",
661 " 500 = Cisco-IOS $1$",
662 " 5700 = Cisco-IOS $4$",
663 " 9200 = Cisco-IOS $8$",
664 " 9300 = Cisco-IOS $9$",
665 " 22 = Juniper Netscreen/SSG (ScreenOS)",
666 " 501 = Juniper IVE",
667 " 5800 = Android PIN",
668 " 8100 = Citrix Netscaler",
669 " 8500 = RACF",
670 " 7200 = GRUB 2",
671 " 9900 = Radmin2",
672 "",
673 "[[ Enterprise Application Software (EAS) ]]",
674 "",
675 " 7700 = SAP CODVN B (BCODE)",
676 " 7800 = SAP CODVN F/G (PASSCODE)",
677 " 10300 = SAP CODVN H (PWDSALTEDHASH) iSSHA-1",
678 " 8600 = Lotus Notes/Domino 5",
679 " 8700 = Lotus Notes/Domino 6",
680 " 9100 = Lotus Notes/Domino 8",
681 " 133 = PeopleSoft",
682 "",
683 "[[ Archives ]]",
684 "",
685 " 11600 = 7-Zip",
686 " 12500 = RAR3-hp",
687 "",
688 "[[ Full-Disk encryptions (FDE) ]]",
689 "",
690 " 62XY = TrueCrypt 5.0+",
691 " X = 1 = PBKDF2-HMAC-RipeMD160",
692 " X = 2 = PBKDF2-HMAC-SHA512",
693 " X = 3 = PBKDF2-HMAC-Whirlpool",
694 " X = 4 = PBKDF2-HMAC-RipeMD160 + boot-mode",
695 " Y = 1 = XTS 512 bit (Ciphers: AES or Serpent or Twofish)",
696 " Y = 2 = XTS 1024 bit (Ciphers: AES or Serpent or Twofish or AES-Twofish or Serpent-AES or Twofish-Serpent)",
697 " Y = 3 = XTS 1536 bit (Ciphers: All)",
698 " 8800 = Android FDE < v4.3",
699 " 12200 = eCryptfs",
700 "",
701 "[[ Documents ]]",
702 "",
703 " 9700 = MS Office <= 2003 MD5 + RC4, oldoffice$0, oldoffice$1",
704 " 9710 = MS Office <= 2003 MD5 + RC4, collider-mode #1",
705 " 9720 = MS Office <= 2003 MD5 + RC4, collider-mode #2",
706 " 9800 = MS Office <= 2003 SHA1 + RC4, oldoffice$3, oldoffice$4",
707 " 9810 = MS Office <= 2003 SHA1 + RC4, collider-mode #1",
708 " 9820 = MS Office <= 2003 SHA1 + RC4, collider-mode #2",
709 " 9400 = MS Office 2007",
710 " 9500 = MS Office 2010",
711 " 9600 = MS Office 2013",
712 " 10400 = PDF 1.1 - 1.3 (Acrobat 2 - 4)",
713 " 10410 = PDF 1.1 - 1.3 (Acrobat 2 - 4) + collider-mode #1",
714 " 10420 = PDF 1.1 - 1.3 (Acrobat 2 - 4) + collider-mode #2",
715 " 10500 = PDF 1.4 - 1.6 (Acrobat 5 - 8)",
716 " 10600 = PDF 1.7 Level 3 (Acrobat 9)",
717 " 10700 = PDF 1.7 Level 8 (Acrobat 10 - 11)",
718 "",
719 "[[ Password Managers ]]",
720 "",
721 " 9000 = Password Safe v2",
722 " 5200 = Password Safe v3",
723 " 6800 = Lastpass",
724 " 6600 = 1Password, agilekeychain",
725 " 8200 = 1Password, cloudkeychain",
726 " 11300 = Bitcoin/Litecoin wallet.dat",
727 " 12700 = Blockchain, My Wallet",
728 "",
729 NULL
730 };
731
732 /**
733 * oclHashcat specific functions
734 */
735
736 void status_display_automat ()
737 {
738 FILE *out = stdout;
739
740 fprintf (out, "STATUS\t%u\t", data.devices_status);
741
742 /**
743 * speed new
744 */
745
746 fprintf (out, "SPEED\t");
747
748 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
749 {
750 hc_device_param_t *device_param = &data.devices_param[device_id];
751
752 uint64_t speed_cnt = 0;
753 float speed_ms = 0;
754
755 for (int i = 0; i < SPEED_CACHE; i++)
756 {
757 float rec_ms;
758
759 hc_timer_get (device_param->speed_rec[i], rec_ms);
760
761 if (rec_ms > SPEED_MAXAGE) continue;
762
763 speed_cnt += device_param->speed_cnt[i];
764 speed_ms += device_param->speed_ms[i];
765 }
766
767 speed_cnt /= SPEED_CACHE;
768 speed_ms /= SPEED_CACHE;
769
770 fprintf (out, "%llu\t%f\t", (unsigned long long int) speed_cnt, speed_ms);
771 }
772
773 /**
774 * words_cur
775 */
776
777 uint64_t words_cur = get_lowest_words_done ();
778
779 fprintf (out, "CURKU\t%llu\t", (unsigned long long int) words_cur);
780
781 /**
782 * counter
783 */
784
785 uint salts_left = data.salts_cnt - data.salts_done;
786
787 if (salts_left == 0) salts_left = 1;
788
789 uint64_t progress_total = data.words_cnt * salts_left;
790
791 uint64_t all_done = 0;
792 uint64_t all_rejected = 0;
793 uint64_t all_restored = 0;
794
795 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
796 {
797 if (salts_left > 1)
798 {
799 // otherwise the final cracked status shows 0/XXX progress
800
801 if (data.salts_shown[salt_pos] == 1) continue;
802 }
803
804 all_done += data.words_progress_done[salt_pos];
805 all_rejected += data.words_progress_rejected[salt_pos];
806 all_restored += data.words_progress_restored[salt_pos];
807 }
808
809 uint64_t progress_cur = all_restored + all_done + all_rejected;
810 uint64_t progress_end = progress_total;
811
812 uint64_t progress_skip = 0;
813
814 if (data.skip)
815 {
816 progress_skip = MIN (data.skip, data.words_base) * salts_left;
817
818 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.gpu_rules_cnt;
819 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt;
820 else if (data.attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt;
821 }
822
823 if (data.limit)
824 {
825 progress_end = MIN (data.limit, data.words_base) * salts_left;
826
827 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.gpu_rules_cnt;
828 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt;
829 else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
830 }
831
832 uint64_t progress_cur_relative_skip = progress_cur - progress_skip;
833 uint64_t progress_end_relative_skip = progress_end - progress_skip;
834
835 fprintf (out, "PROGRESS\t%llu\t%llu\t", (unsigned long long int) progress_cur_relative_skip, (unsigned long long int) progress_end_relative_skip);
836
837 /**
838 * cracks
839 */
840
841 fprintf (out, "RECHASH\t%u\t%u\t", data.digests_done, data.digests_cnt);
842 fprintf (out, "RECSALT\t%u\t%u\t", data.salts_done, data.salts_cnt);
843
844 /**
845 * temperature
846 */
847
848 if (data.gpu_temp_disable == 0)
849 {
850 fprintf (out, "TEMP\t");
851
852 hc_thread_mutex_lock (mux_adl);
853
854 for (uint i = 0; i < data.devices_cnt; i++)
855 {
856 int temp = hm_get_temperature_with_device_id (i);
857
858 fprintf (out, "%d\t", temp);
859 }
860
861 hc_thread_mutex_unlock (mux_adl);
862 }
863
864 #ifdef _WIN
865 fputc ('\r', out);
866 fputc ('\n', out);
867 #endif
868
869 #ifdef _POSIX
870 fputc ('\n', out);
871 #endif
872
873 fflush (out);
874 }
875
876 void status_display ()
877 {
878 if (data.devices_status == STATUS_INIT) return;
879 if (data.devices_status == STATUS_STARTING) return;
880 if (data.devices_status == STATUS_BYPASS) return;
881
882 if (data.status_automat == 1)
883 {
884 status_display_automat ();
885
886 return;
887 }
888
889 char tmp_buf[1000];
890
891 uint tmp_len = 0;
892
893 log_info ("Session.Name...: %s", data.session);
894
895 char *status_type = strstatus (data.devices_status);
896
897 uint hash_mode = data.hash_mode;
898
899 char *hash_type = strhashtype (hash_mode); // not a bug
900
901 log_info ("Status.........: %s", status_type);
902
903 /**
904 * show rules
905 */
906
907 if (data.rp_files_cnt)
908 {
909 uint i;
910
911 for (i = 0, tmp_len = 0; i < data.rp_files_cnt - 1 && tmp_len < sizeof (tmp_buf); i++)
912 {
913 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s), ", data.rp_files[i]);
914 }
915
916 snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", data.rp_files[i]);
917
918 log_info ("Rules.Type.....: %s", tmp_buf);
919
920 tmp_len = 0;
921 }
922
923 if (data.rp_gen)
924 {
925 log_info ("Rules.Type.....: Generated (%u)", data.rp_gen);
926
927 if (data.rp_gen_seed)
928 {
929 log_info ("Rules.Seed.....: %u", data.rp_gen_seed);
930 }
931 }
932
933 /**
934 * show input
935 */
936
937 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
938 {
939 if (data.wordlist_mode == WL_MODE_FILE)
940 {
941 if (data.dictfile != NULL) log_info ("Input.Mode.....: File (%s)", data.dictfile);
942 }
943 else if (data.wordlist_mode == WL_MODE_STDIN)
944 {
945 log_info ("Input.Mode.....: Pipe");
946 }
947 }
948 else if (data.attack_mode == ATTACK_MODE_COMBI)
949 {
950 if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
951 if (data.dictfile2 != NULL) log_info ("Input.Right....: File (%s)", data.dictfile2);
952 }
953 else if (data.attack_mode == ATTACK_MODE_BF)
954 {
955 char *mask = data.mask;
956
957 if (mask != NULL)
958 {
959 uint mask_len = data.css_cnt;
960
961 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "Mask (%s)", mask);
962
963 if (mask_len > 0)
964 {
965 if (data.opti_type & OPTI_TYPE_SINGLE_HASH)
966 {
967 if (data.opti_type & OPTI_TYPE_APPENDED_SALT)
968 {
969 mask_len -= data.salts_buf[0].salt_len;
970 }
971 }
972
973 if (data.opts_type & OPTS_TYPE_PT_UNICODE) mask_len /= 2;
974
975 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " [%i]", mask_len);
976 }
977
978 if (data.maskcnt > 1)
979 {
980 float mask_percentage = (float) data.maskpos / (float) data.maskcnt;
981
982 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100);
983 }
984
985 log_info ("Input.Mode.....: %s", tmp_buf);
986 }
987
988 tmp_len = 0;
989 }
990 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
991 {
992 if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
993 if (data.mask != NULL) log_info ("Input.Right....: Mask (%s) [%i]", data.mask, data.css_cnt);
994 }
995 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
996 {
997 if (data.mask != NULL) log_info ("Input.Left.....: Mask (%s) [%i]", data.mask, data.css_cnt);
998 if (data.dictfile != NULL) log_info ("Input.Right....: File (%s)", data.dictfile);
999 }
1000
1001 if (data.digests_cnt == 1)
1002 {
1003 if (data.hash_mode == 2500)
1004 {
1005 wpa_t *wpa = (wpa_t *) data.esalts_buf;
1006
1007 uint pke[25];
1008
1009 char *pke_ptr = (char *) pke;
1010
1011 for (uint i = 0; i < 25; i++)
1012 {
1013 pke[i] = byte_swap_32 (wpa->pke[i]);
1014 }
1015
1016 char mac1[6];
1017 char mac2[6];
1018
1019 memcpy (mac1, pke_ptr + 23, 6);
1020 memcpy (mac2, pke_ptr + 29, 6);
1021
1022 log_info ("Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)",
1023 (char *) data.salts_buf[0].salt_buf,
1024 mac1[0] & 0xff,
1025 mac1[1] & 0xff,
1026 mac1[2] & 0xff,
1027 mac1[3] & 0xff,
1028 mac1[4] & 0xff,
1029 mac1[5] & 0xff,
1030 mac2[0] & 0xff,
1031 mac2[1] & 0xff,
1032 mac2[2] & 0xff,
1033 mac2[3] & 0xff,
1034 mac2[4] & 0xff,
1035 mac2[5] & 0xff);
1036 }
1037 else if (data.hash_mode == 5200)
1038 {
1039 log_info ("Hash.Target....: File (%s)", data.hashfile);
1040 }
1041 else if (data.hash_mode == 9000)
1042 {
1043 log_info ("Hash.Target....: File (%s)", data.hashfile);
1044 }
1045 else if ((data.hash_mode >= 6200) && (data.hash_mode <= 6299))
1046 {
1047 log_info ("Hash.Target....: File (%s)", data.hashfile);
1048 }
1049 else
1050 {
1051 char out_buf[4096];
1052
1053 ascii_digest (out_buf, 0, 0);
1054
1055 // limit length
1056 if (strlen (out_buf) > 40)
1057 {
1058 out_buf[41] = '.';
1059 out_buf[42] = '.';
1060 out_buf[43] = '.';
1061 out_buf[44] = 0;
1062 }
1063
1064 log_info ("Hash.Target....: %s", out_buf);
1065 }
1066 }
1067 else
1068 {
1069 if (data.hash_mode == 3000)
1070 {
1071 char out_buf1[4096];
1072 char out_buf2[4096];
1073
1074 ascii_digest (out_buf1, 0, 0);
1075 ascii_digest (out_buf2, 0, 1);
1076
1077 log_info ("Hash.Target....: %s, %s", out_buf1, out_buf2);
1078 }
1079 else
1080 {
1081 log_info ("Hash.Target....: File (%s)", data.hashfile);
1082 }
1083 }
1084
1085 log_info ("Hash.Type......: %s", hash_type);
1086
1087 /**
1088 * speed new
1089 */
1090
1091 uint64_t speed_cnt[DEVICES_MAX];
1092 float speed_ms[DEVICES_MAX];
1093
1094 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1095 {
1096 hc_device_param_t *device_param = &data.devices_param[device_id];
1097
1098 // we need to clear values (set to 0) because in case the gpu does
1099 // not get new candidates it idles around but speed display would
1100 // show it as working.
1101 // if we instantly set it to 0 after reading it happens that the
1102 // speed can be shown as zero if the users refreshs to fast.
1103 // therefore, we add a timestamp when a stat was recorded and if its
1104 // to old we will not use it
1105
1106 speed_cnt[device_id] = 0;
1107 speed_ms[device_id] = 0;
1108
1109 for (int i = 0; i < SPEED_CACHE; i++)
1110 {
1111 float rec_ms;
1112
1113 hc_timer_get (device_param->speed_rec[i], rec_ms);
1114
1115 if (rec_ms > SPEED_MAXAGE) continue;
1116
1117 speed_cnt[device_id] += device_param->speed_cnt[i];
1118 speed_ms[device_id] += device_param->speed_ms[i];
1119 }
1120
1121 speed_cnt[device_id] /= SPEED_CACHE;
1122 speed_ms[device_id] /= SPEED_CACHE;
1123 }
1124
1125 float hashes_all_ms = 0;
1126
1127 float hashes_dev_ms[DEVICES_MAX];
1128
1129 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1130 {
1131 hashes_dev_ms[device_id] = 0;
1132
1133 if (speed_ms[device_id])
1134 {
1135 hashes_dev_ms[device_id] = speed_cnt[device_id] / speed_ms[device_id];
1136
1137 hashes_all_ms += hashes_dev_ms[device_id];
1138 }
1139 }
1140
1141 /**
1142 * timers
1143 */
1144
1145 float ms_running = 0;
1146
1147 hc_timer_get (data.timer_running, ms_running);
1148
1149 float ms_paused = data.ms_paused;
1150
1151 if (data.devices_status == STATUS_PAUSED)
1152 {
1153 float ms_paused_tmp = 0;
1154
1155 hc_timer_get (data.timer_paused, ms_paused_tmp);
1156
1157 ms_paused += ms_paused_tmp;
1158 }
1159
1160 #ifdef WIN
1161
1162 __time64_t sec_run = ms_running / 1000;
1163
1164 #else
1165
1166 time_t sec_run = ms_running / 1000;
1167
1168 #endif
1169
1170 if (sec_run)
1171 {
1172 char display_run[32];
1173
1174 struct tm tm_run;
1175
1176 struct tm *tmp;
1177
1178 #ifdef WIN
1179
1180 tmp = _gmtime64 (&sec_run);
1181
1182 #else
1183
1184 tmp = gmtime (&sec_run);
1185
1186 #endif
1187
1188 if (tmp != NULL)
1189 {
1190 memcpy (&tm_run, tmp, sizeof (struct tm));
1191
1192 format_timer_display (&tm_run, display_run, sizeof (tm_run));
1193
1194 char *start = ctime (&data.proc_start);
1195
1196 size_t start_len = strlen (start);
1197
1198 if (start[start_len - 1] == '\n') start[start_len - 1] = 0;
1199 if (start[start_len - 2] == '\r') start[start_len - 2] = 0;
1200
1201 log_info ("Time.Started...: %s (%s)", start, display_run);
1202 }
1203 }
1204 else
1205 {
1206 log_info ("Time.Started...: 0 secs");
1207 }
1208
1209 /**
1210 * counters
1211 */
1212
1213 uint salts_left = data.salts_cnt - data.salts_done;
1214
1215 if (salts_left == 0) salts_left = 1;
1216
1217 uint64_t progress_total = data.words_cnt * salts_left;
1218
1219 uint64_t all_done = 0;
1220 uint64_t all_rejected = 0;
1221 uint64_t all_restored = 0;
1222
1223 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
1224 {
1225 if (salts_left > 1)
1226 {
1227 // otherwise the final cracked status shows 0/XXX progress
1228
1229 if (data.salts_shown[salt_pos] == 1) continue;
1230 }
1231
1232 all_done += data.words_progress_done[salt_pos];
1233 all_rejected += data.words_progress_rejected[salt_pos];
1234 all_restored += data.words_progress_restored[salt_pos];
1235 }
1236
1237 uint64_t progress_cur = all_restored + all_done + all_rejected;
1238 uint64_t progress_end = progress_total;
1239
1240 uint64_t progress_skip = 0;
1241
1242 if (data.skip)
1243 {
1244 progress_skip = MIN (data.skip, data.words_base) * salts_left;
1245
1246 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.gpu_rules_cnt;
1247 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt;
1248 else if (data.attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt;
1249 }
1250
1251 if (data.limit)
1252 {
1253 progress_end = MIN (data.limit, data.words_base) * salts_left;
1254
1255 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.gpu_rules_cnt;
1256 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt;
1257 else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
1258 }
1259
1260 uint64_t progress_cur_relative_skip = progress_cur - progress_skip;
1261 uint64_t progress_end_relative_skip = progress_end - progress_skip;
1262
1263 float speed_ms_real = ms_running - ms_paused;
1264 uint64_t speed_plains_real = all_done;
1265
1266 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1267 {
1268 if (data.devices_status != STATUS_CRACKED)
1269 {
1270 uint64_t words_per_ms = 0;
1271
1272 if (speed_plains_real && speed_ms_real)
1273 {
1274 words_per_ms = speed_plains_real / speed_ms_real;
1275 }
1276
1277 #ifdef WIN
1278 __time64_t sec_etc = 0;
1279 #else
1280 time_t sec_etc = 0;
1281 #endif
1282
1283 if (words_per_ms)
1284 {
1285 uint64_t progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip;
1286
1287 uint64_t ms_left = progress_left_relative_skip / words_per_ms;
1288
1289 sec_etc = ms_left / 1000;
1290 }
1291
1292 if (sec_etc == 0)
1293 {
1294 log_info ("Time.Estimated.: 0 secs");
1295 }
1296 else if ((uint64_t) sec_etc > ETC_MAX)
1297 {
1298 log_info ("Time.Estimated.: > 10 Years");
1299 }
1300 else
1301 {
1302 char display_etc[32];
1303
1304 struct tm tm_etc;
1305
1306 struct tm *tmp;
1307
1308 #ifdef WIN
1309
1310 tmp = _gmtime64 (&sec_etc);
1311
1312 #else
1313
1314 tmp = gmtime (&sec_etc);
1315
1316 #endif
1317
1318 if (tmp != NULL)
1319 {
1320 memcpy (&tm_etc, tmp, sizeof (tm_etc));
1321
1322 format_timer_display (&tm_etc, display_etc, sizeof (display_etc));
1323
1324 time_t now;
1325
1326 time (&now);
1327
1328 now += sec_etc;
1329
1330 char *etc = ctime (&now);
1331
1332 size_t etc_len = strlen (etc);
1333
1334 if (etc[etc_len - 1] == '\n') etc[etc_len - 1] = 0;
1335 if (etc[etc_len - 2] == '\r') etc[etc_len - 2] = 0;
1336
1337 log_info ("Time.Estimated.: %s (%s)", etc, display_etc);
1338 }
1339 }
1340 }
1341 }
1342
1343 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1344 {
1345 char display_dev_cur[16];
1346
1347 memset (display_dev_cur, 0, sizeof (display_dev_cur));
1348
1349 strncpy (display_dev_cur, "0.00", 4);
1350
1351 format_speed_display (hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur));
1352
1353 log_info ("Speed.GPU.#%d...: %9sH/s", device_id + 1, display_dev_cur);
1354 }
1355
1356 char display_all_cur[16];
1357
1358 memset (display_all_cur, 0, sizeof (display_all_cur));
1359
1360 strncpy (display_all_cur, "0.00", 4);
1361
1362 format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur));
1363
1364 if (data.devices_cnt > 1) log_info ("Speed.GPU.#*...: %9sH/s", display_all_cur);
1365
1366 const float digests_percent = (float) data.digests_done / data.digests_cnt;
1367 const float salts_percent = (float) data.salts_done / data.salts_cnt;
1368
1369 log_info ("Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", data.digests_done, data.digests_cnt, digests_percent * 100, data.salts_done, data.salts_cnt, salts_percent * 100);
1370
1371 // crack-per-time
1372
1373 if (data.digests_cnt > 100)
1374 {
1375 time_t now = time (NULL);
1376
1377 int cpt_cur_min = 0;
1378 int cpt_cur_hour = 0;
1379 int cpt_cur_day = 0;
1380
1381 for (int i = 0; i < CPT_BUF; i++)
1382 {
1383 const uint cracked = data.cpt_buf[i].cracked;
1384 const time_t timestamp = data.cpt_buf[i].timestamp;
1385
1386 if ((timestamp + 60) > now)
1387 {
1388 cpt_cur_min += cracked;
1389 }
1390
1391 if ((timestamp + 3600) > now)
1392 {
1393 cpt_cur_hour += cracked;
1394 }
1395
1396 if ((timestamp + 86400) > now)
1397 {
1398 cpt_cur_day += cracked;
1399 }
1400 }
1401
1402 float cpt_avg_min = (float) data.cpt_total / ((speed_ms_real / 1000) / 60);
1403 float cpt_avg_hour = (float) data.cpt_total / ((speed_ms_real / 1000) / 3600);
1404 float cpt_avg_day = (float) data.cpt_total / ((speed_ms_real / 1000) / 86400);
1405
1406 if ((data.cpt_start + 86400) < now)
1407 {
1408 log_info ("Recovered/Time.: CUR:%llu,%llu,%llu AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1409 cpt_cur_min,
1410 cpt_cur_hour,
1411 cpt_cur_day,
1412 cpt_avg_min,
1413 cpt_avg_hour,
1414 cpt_avg_day);
1415 }
1416 else if ((data.cpt_start + 3600) < now)
1417 {
1418 log_info ("Recovered/Time.: CUR:%llu,%llu,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1419 cpt_cur_min,
1420 cpt_cur_hour,
1421 cpt_avg_min,
1422 cpt_avg_hour,
1423 cpt_avg_day);
1424 }
1425 else if ((data.cpt_start + 60) < now)
1426 {
1427 log_info ("Recovered/Time.: CUR:%llu,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1428 cpt_cur_min,
1429 cpt_avg_min,
1430 cpt_avg_hour,
1431 cpt_avg_day);
1432 }
1433 else
1434 {
1435 log_info ("Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1436 cpt_avg_min,
1437 cpt_avg_hour,
1438 cpt_avg_day);
1439 }
1440 }
1441
1442 // Restore point
1443
1444 uint64_t restore_point = get_lowest_words_done ();
1445
1446 uint64_t restore_total = data.words_base;
1447
1448 float percent_restore = 0;
1449
1450 if (restore_total != 0) percent_restore = (float) restore_point / (float) restore_total;
1451
1452 if (progress_end_relative_skip)
1453 {
1454 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1455 {
1456 float percent_finished = (float) progress_cur_relative_skip / (float) progress_end_relative_skip;
1457 float percent_rejected = 0.0;
1458
1459 if (progress_cur)
1460 {
1461 percent_rejected = (float) (all_rejected) / (float) progress_cur;
1462 }
1463
1464 log_info ("Progress.......: %llu/%llu (%.02f%%)", (unsigned long long int) progress_cur_relative_skip, (unsigned long long int) progress_end_relative_skip, percent_finished * 100);
1465 log_info ("Rejected.......: %llu/%llu (%.02f%%)", (unsigned long long int) all_rejected, (unsigned long long int) progress_cur_relative_skip, percent_rejected * 100);
1466
1467 if (data.restore_disable == 0)
1468 {
1469 if (percent_finished != 1)
1470 {
1471 log_info ("Restore.Point..: %llu/%llu (%.02f%%)", (unsigned long long int) restore_point, (unsigned long long int) restore_total, percent_restore * 100);
1472 }
1473 }
1474 }
1475 }
1476 else
1477 {
1478 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1479 {
1480 log_info ("Progress.......: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1481 log_info ("Rejected.......: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1482
1483 if (data.restore_disable == 0)
1484 {
1485 log_info ("Restore.Point..: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1486 }
1487 }
1488 else
1489 {
1490 log_info ("Progress.......: %llu", (unsigned long long int) progress_cur_relative_skip);
1491 log_info ("Rejected.......: %llu", (unsigned long long int) all_rejected);
1492
1493 // --restore not allowed if stdin is used -- really? why?
1494
1495 //if (data.restore_disable == 0)
1496 //{
1497 // log_info ("Restore.Point..: %llu", (unsigned long long int) restore_point);
1498 //}
1499 }
1500 }
1501
1502 if (data.gpu_temp_disable == 0)
1503 {
1504 hc_thread_mutex_lock (mux_adl);
1505
1506 for (uint i = 0; i < data.devices_cnt; i++)
1507 {
1508 if (data.hm_device[i].fan_supported == 1)
1509 {
1510 const int temperature = hm_get_temperature_with_device_id (i);
1511 const int utilization = hm_get_utilization_with_device_id (i);
1512 const int fanspeed = hm_get_fanspeed_with_device_id (i);
1513
1514 #ifdef _OCL
1515 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed);
1516 #else
1517 #ifdef LINUX
1518 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed);
1519 #else
1520 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2drpm Fan", i + 1, utilization, temperature, fanspeed);
1521 #endif
1522 #endif
1523 }
1524 else
1525 {
1526 const int temperature = hm_get_temperature_with_device_id (i);
1527 const int utilization = hm_get_utilization_with_device_id (i);
1528
1529 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, N/A Fan", i + 1, utilization, temperature);
1530 }
1531 }
1532
1533 hc_thread_mutex_unlock (mux_adl);
1534 }
1535 }
1536
1537 static void status_benchmark ()
1538 {
1539 if (data.devices_status == STATUS_INIT) return;
1540 if (data.devices_status == STATUS_STARTING) return;
1541
1542 if (data.words_cnt == 0) return;
1543
1544 uint64_t speed_cnt[DEVICES_MAX];
1545 float speed_ms[DEVICES_MAX];
1546
1547 uint device_id;
1548
1549 for (device_id = 0; device_id < data.devices_cnt; device_id++)
1550 {
1551 hc_device_param_t *device_param = &data.devices_param[device_id];
1552
1553 speed_cnt[device_id] = 0;
1554 speed_ms[device_id] = 0;
1555
1556 for (int i = 0; i < SPEED_CACHE; i++)
1557 {
1558 speed_cnt[device_id] += device_param->speed_cnt[i];
1559 speed_ms[device_id] += device_param->speed_ms[i];
1560 }
1561
1562 speed_cnt[device_id] /= SPEED_CACHE;
1563 speed_ms[device_id] /= SPEED_CACHE;
1564 }
1565
1566 float hashes_all_ms = 0;
1567
1568 float hashes_dev_ms[DEVICES_MAX];
1569
1570 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1571 {
1572 hashes_dev_ms[device_id] = 0;
1573
1574 if (speed_ms[device_id])
1575 {
1576 hashes_dev_ms[device_id] = speed_cnt[device_id] / speed_ms[device_id];
1577
1578 hashes_all_ms += hashes_dev_ms[device_id];
1579 }
1580 }
1581
1582 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1583 {
1584 char display_dev_cur[16];
1585
1586 memset (display_dev_cur, 0, sizeof (display_dev_cur));
1587
1588 strncpy (display_dev_cur, "0.00", 4);
1589
1590 format_speed_display (hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur));
1591
1592 log_info ("Speed.GPU.#%d.: %9sH/s", device_id + 1, display_dev_cur);
1593 }
1594
1595 char display_all_cur[16];
1596
1597 memset (display_all_cur, 0, sizeof (display_all_cur));
1598
1599 strncpy (display_all_cur, "0.00", 4);
1600
1601 format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur));
1602
1603 if (data.devices_cnt > 1) log_info ("Speed.GPU.#*.: %9sH/s", display_all_cur);
1604 }
1605
1606 /**
1607 * oclHashcat -only- functions
1608 */
1609
1610 static uint convert_from_hex (char *line_buf, const uint line_len)
1611 {
1612 if (line_len & 1) return (line_len); // not in hex
1613
1614 if (data.hex_wordlist == 1)
1615 {
1616 uint i;
1617 uint j;
1618
1619 for (i = 0, j = 0; j < line_len; i += 1, j += 2)
1620 {
1621 line_buf[i] = hex_to_char (&line_buf[j]);
1622 }
1623
1624 memset (line_buf + i, 0, line_len - i);
1625
1626 return (i);
1627 }
1628 else if (line_len >= 6) // $HEX[] = 6
1629 {
1630 if (line_buf[0] != '$') return (line_len);
1631 if (line_buf[1] != 'H') return (line_len);
1632 if (line_buf[2] != 'E') return (line_len);
1633 if (line_buf[3] != 'X') return (line_len);
1634 if (line_buf[4] != '[') return (line_len);
1635 if (line_buf[line_len - 1] != ']') return (line_len);
1636
1637 uint i;
1638 uint j;
1639
1640 for (i = 0, j = 5; j < line_len - 1; i += 1, j += 2)
1641 {
1642 line_buf[i] = hex_to_char (&line_buf[j]);
1643 }
1644
1645 memset (line_buf + i, 0, line_len - i);
1646
1647 return (i);
1648 }
1649
1650 return (line_len);
1651 }
1652
1653 static uint count_lines (FILE *fd)
1654 {
1655 uint cnt = 0;
1656
1657 char *buf = (char *) mymalloc (BUFSIZ);
1658
1659 size_t nread_tmp = 0;
1660
1661 char *ptr = buf;
1662
1663 while (!feof (fd))
1664 {
1665 size_t nread = fread (buf, sizeof (char), BUFSIZ, fd);
1666 nread_tmp = nread;
1667
1668 if (nread < 1) continue;
1669
1670 ptr = buf;
1671
1672 do
1673 {
1674 if (*ptr++ == '\n') cnt++;
1675
1676 } while (nread--);
1677 }
1678
1679 // special case (if last line did not contain a newline char ... at the very end of the file)
1680
1681 if (nread_tmp > 3)
1682 {
1683 ptr -= 2;
1684
1685 if (*ptr != '\n')
1686 {
1687 ptr--;
1688
1689 if (*ptr != '\n') // needed ? different on windows systems?
1690 {
1691 cnt++;
1692 }
1693 }
1694 }
1695
1696 myfree (buf);
1697
1698 return cnt;
1699 }
1700
1701 static void clear_prompt ()
1702 {
1703 fputc ('\r', stdout);
1704
1705 for (size_t i = 0; i < strlen (PROMPT); i++)
1706 {
1707 fputc (' ', stdout);
1708 }
1709
1710 fputc ('\r', stdout);
1711
1712 fflush (stdout);
1713 }
1714
1715 static void gidd_to_pw_t (hc_device_param_t *device_param, const uint64_t gidd, pw_t *pw)
1716 {
1717 #ifdef _CUDA
1718 hc_cuCtxPushCurrent (device_param->context);
1719
1720 hc_cuMemcpyDtoH (pw, device_param->d_pws_buf + (gidd * sizeof (pw_t)), sizeof (pw_t));
1721
1722 hc_cuCtxPopCurrent (&device_param->context);
1723
1724 #elif _OCL
1725 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL);
1726
1727 #endif
1728 }
1729
1730 static void check_hash (hc_device_param_t *device_param, const uint salt_pos, const uint digest_pos)
1731 {
1732 char *outfile = data.outfile;
1733 uint quiet = data.quiet;
1734 FILE *pot_fp = data.pot_fp;
1735 uint loopback = data.loopback;
1736 uint debug_mode = data.debug_mode;
1737 char *debug_file = data.debug_file;
1738
1739 char debug_rule_buf[BLOCK_SIZE];
1740 int debug_rule_len = 0; // -1 error
1741 uint debug_plain_len = 0;
1742
1743 unsigned char debug_plain_ptr[BLOCK_SIZE];
1744
1745 // hash
1746
1747 char out_buf[4096]; memset (out_buf, 0, sizeof (out_buf));
1748
1749 ascii_digest (out_buf, salt_pos, digest_pos);
1750
1751 uint idx = data.salts_buf[salt_pos].digests_offset + digest_pos;
1752
1753 // plain
1754
1755 plain_t plain;
1756
1757 #ifdef _CUDA
1758 hc_cuCtxPushCurrent (device_param->context);
1759
1760 hc_cuMemcpyDtoH (&plain, device_param->d_plain_bufs + (idx * sizeof (plain_t)), sizeof (plain_t));
1761
1762 hc_cuCtxPopCurrent (&device_param->context);
1763 #elif _OCL
1764 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, idx * sizeof (plain_t), sizeof (plain_t), &plain, 0, NULL, NULL);
1765 #endif
1766
1767 uint gidvid = plain.gidvid;
1768 uint il_pos = plain.il_pos;
1769
1770 uint64_t crackpos = device_param->words_off;
1771
1772 uint plain_buf[16];
1773
1774 unsigned char *plain_ptr = (unsigned char *) plain_buf;
1775 unsigned int plain_len = 0;
1776
1777 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
1778 {
1779 uint64_t gidd = gidvid / device_param->gpu_vector_width;
1780 uint64_t gidm = gidvid % device_param->gpu_vector_width;
1781
1782 pw_t pw;
1783
1784 gidd_to_pw_t (device_param, gidd, &pw);
1785
1786 for (int i = 0, j = gidm; i < 16; i++, j += device_param->gpu_vector_width)
1787 {
1788 plain_buf[i] = pw.hi1[0][j];
1789 }
1790
1791 plain_len = pw.pw_len;
1792
1793 const uint off = device_param->innerloop_pos + il_pos;
1794
1795 if (debug_mode > 0)
1796 {
1797 debug_rule_len = 0;
1798
1799 // save rule
1800 if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4))
1801 {
1802 memset (debug_rule_buf, 0, sizeof (debug_rule_buf));
1803
1804 debug_rule_len = gpu_rule_to_cpu_rule (debug_rule_buf, &data.gpu_rules_buf[off]);
1805 }
1806
1807 // save plain
1808 if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4))
1809 {
1810 memset (debug_plain_ptr, 0, sizeof (debug_plain_ptr));
1811
1812 memcpy (debug_plain_ptr, plain_ptr, plain_len);
1813
1814 debug_plain_len = plain_len;
1815 }
1816 }
1817
1818 plain_len = apply_rules (data.gpu_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], plain_len);
1819
1820 crackpos += gidvid;
1821 crackpos *= data.gpu_rules_cnt;
1822 crackpos += device_param->innerloop_pos + il_pos;
1823
1824 if (plain_len > data.pw_max) plain_len = data.pw_max;
1825 }
1826 else if (data.attack_mode == ATTACK_MODE_COMBI)
1827 {
1828 uint64_t gidd = gidvid / device_param->gpu_vector_width;
1829 uint64_t gidm = gidvid % device_param->gpu_vector_width;
1830
1831 pw_t pw;
1832
1833 gidd_to_pw_t (device_param, gidd, &pw);
1834
1835 for (int i = 0, j = gidm; i < 16; i++, j += device_param->gpu_vector_width)
1836 {
1837 plain_buf[i] = pw.hi1[0][j];
1838 }
1839
1840 plain_len = pw.pw_len;
1841
1842 char *comb_buf = (char *) device_param->combs_buf[il_pos].i;
1843 uint comb_len = device_param->combs_buf[il_pos].pw_len;
1844
1845 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
1846 {
1847 memcpy (plain_ptr + plain_len, comb_buf, comb_len);
1848 }
1849 else
1850 {
1851 memmove (plain_ptr + comb_len, plain_ptr, plain_len);
1852
1853 memcpy (plain_ptr, comb_buf, comb_len);
1854 }
1855
1856 plain_len += comb_len;
1857
1858 crackpos += gidvid;
1859 crackpos *= data.combs_cnt;
1860 crackpos += device_param->innerloop_pos + il_pos;
1861
1862 if (data.pw_max != PW_DICTMAX1)
1863 {
1864 if (plain_len > data.pw_max) plain_len = data.pw_max;
1865 }
1866 }
1867 else if (data.attack_mode == ATTACK_MODE_BF)
1868 {
1869 uint64_t l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid;
1870 uint64_t r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos;
1871
1872 uint l_start = device_param->kernel_params_mp_l_buf32[5];
1873 uint r_start = device_param->kernel_params_mp_r_buf32[5];
1874
1875 uint l_stop = device_param->kernel_params_mp_l_buf32[4];
1876 uint r_stop = device_param->kernel_params_mp_r_buf32[4];
1877
1878 sp_exec (l_off, (char *) plain_ptr + l_start, data.root_css_buf, data.markov_css_buf, l_start, l_start + l_stop);
1879 sp_exec (r_off, (char *) plain_ptr + r_start, data.root_css_buf, data.markov_css_buf, r_start, r_start + r_stop);
1880
1881 plain_len = data.css_cnt;
1882
1883 crackpos += gidvid;
1884 crackpos *= data.bfs_cnt;
1885 crackpos += device_param->innerloop_pos + il_pos;
1886 }
1887 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
1888 {
1889 uint64_t gidd = gidvid / device_param->gpu_vector_width;
1890 uint64_t gidm = gidvid % device_param->gpu_vector_width;
1891
1892 pw_t pw;
1893
1894 gidd_to_pw_t (device_param, gidd, &pw);
1895
1896 for (int i = 0, j = gidm; i < 16; i++, j += device_param->gpu_vector_width)
1897 {
1898 plain_buf[i] = pw.hi1[0][j];
1899 }
1900
1901 plain_len = pw.pw_len;
1902
1903 uint64_t off = device_param->kernel_params_mp_buf64[3] + il_pos;
1904
1905 uint start = 0;
1906 uint stop = device_param->kernel_params_mp_buf32[4];
1907
1908 sp_exec (off, (char *) plain_ptr + plain_len, data.root_css_buf, data.markov_css_buf, start, start + stop);
1909
1910 plain_len += start + stop;
1911
1912 crackpos += gidvid;
1913 crackpos *= data.combs_cnt;
1914 crackpos += device_param->innerloop_pos + il_pos;
1915
1916 if (data.pw_max != PW_DICTMAX1)
1917 {
1918 if (plain_len > data.pw_max) plain_len = data.pw_max;
1919 }
1920 }
1921 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
1922 {
1923 uint64_t gidd = gidvid / device_param->gpu_vector_width;
1924 uint64_t gidm = gidvid % device_param->gpu_vector_width;
1925
1926 pw_t pw;
1927
1928 gidd_to_pw_t (device_param, gidd, &pw);
1929
1930 for (int i = 0, j = gidm; i < 16; i++, j += device_param->gpu_vector_width)
1931 {
1932 plain_buf[i] = pw.hi1[0][j];
1933 }
1934
1935 plain_len = pw.pw_len;
1936
1937 uint64_t off = device_param->kernel_params_mp_buf64[3] + il_pos;
1938
1939 uint start = 0;
1940 uint stop = device_param->kernel_params_mp_buf32[4];
1941
1942 memmove (plain_ptr + stop, plain_ptr, plain_len);
1943
1944 sp_exec (off, (char *) plain_ptr, data.root_css_buf, data.markov_css_buf, start, start + stop);
1945
1946 plain_len += start + stop;
1947
1948 crackpos += gidvid;
1949 crackpos *= data.combs_cnt;
1950 crackpos += device_param->innerloop_pos + il_pos;
1951
1952 if (data.pw_max != PW_DICTMAX1)
1953 {
1954 if (plain_len > data.pw_max) plain_len = data.pw_max;
1955 }
1956 }
1957
1958 if (data.opti_type & OPTI_TYPE_BRUTE_FORCE) // lots of optimizations can happen here
1959 {
1960 if (data.opti_type & OPTI_TYPE_SINGLE_HASH)
1961 {
1962 if (data.opti_type & OPTI_TYPE_APPENDED_SALT)
1963 {
1964 plain_len = plain_len - data.salts_buf[0].salt_len;
1965 }
1966 }
1967
1968 if (data.opts_type & OPTS_TYPE_PT_UNICODE)
1969 {
1970 for (uint i = 0, j = 0; i < plain_len; i += 2, j += 1)
1971 {
1972 plain_ptr[j] = plain_ptr[i];
1973 }
1974
1975 plain_len = plain_len / 2;
1976 }
1977 }
1978
1979 // if enabled, update also the potfile
1980
1981 if (pot_fp)
1982 {
1983 fprintf (pot_fp, "%s:", out_buf);
1984
1985 format_plain (pot_fp, plain_ptr, plain_len, 1);
1986
1987 fputc ('\n', pot_fp);
1988
1989 fflush (pot_fp);
1990 }
1991
1992 // outfile
1993
1994 FILE *out_fp = NULL;
1995
1996 if (outfile != NULL)
1997 {
1998 if ((out_fp = fopen (outfile, "ab")) == NULL)
1999 {
2000 log_error ("ERROR: %s: %s", outfile, strerror (errno));
2001
2002 out_fp = stdout;
2003 }
2004 }
2005 else
2006 {
2007 out_fp = stdout;
2008
2009 if (quiet == 0) clear_prompt ();
2010 }
2011
2012 format_output (out_fp, out_buf, plain_ptr, plain_len, crackpos, NULL, 0);
2013
2014 if (outfile != NULL)
2015 {
2016 if (out_fp != stdout)
2017 {
2018 fclose (out_fp);
2019 }
2020 }
2021 else
2022 {
2023 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
2024 {
2025 if ((data.devices_status != STATUS_CRACKED) && (data.status != 1))
2026 {
2027 if (quiet == 0) fprintf (stdout, "%s", PROMPT);
2028 if (quiet == 0) fflush (stdout);
2029 }
2030 }
2031 }
2032
2033 // loopback
2034
2035 if (loopback)
2036 {
2037 char *loopback_file = data.loopback_file;
2038
2039 FILE *fb_fp = NULL;
2040
2041 if ((fb_fp = fopen (loopback_file, "ab")) != NULL)
2042 {
2043 format_plain (fb_fp, plain_ptr, plain_len, 1);
2044
2045 fputc ('\n', fb_fp);
2046
2047 fclose (fb_fp);
2048 }
2049 }
2050
2051 // (rule) debug mode
2052
2053 // the next check implies that:
2054 // - (data.attack_mode == ATTACK_MODE_STRAIGHT)
2055 // - debug_mode > 0
2056
2057 if ((debug_plain_len > 0) || (debug_rule_len > 0))
2058 {
2059 if (debug_rule_len < 0) debug_rule_len = 0;
2060
2061 if ((quiet == 0) && (debug_file == NULL)) clear_prompt ();
2062
2063 format_debug (debug_file, debug_mode, debug_plain_ptr, debug_plain_len, plain_ptr, plain_len, debug_rule_buf, debug_rule_len);
2064
2065 if ((quiet == 0) && (debug_file == NULL))
2066 {
2067 fprintf (stdout, "%s", PROMPT);
2068 fflush (stdout);
2069 }
2070 }
2071 }
2072
2073 static void check_cracked (hc_device_param_t *device_param, const uint salt_pos)
2074 {
2075 salt_t *salt_buf = &data.salts_buf[salt_pos];
2076
2077 int found = 0;
2078
2079 #ifdef _CUDA
2080
2081 hc_cuCtxPushCurrent (device_param->context);
2082
2083 hc_cuMemcpyDtoH (device_param->result, device_param->d_result, device_param->size_results);
2084
2085 hc_cuCtxPopCurrent (&device_param->context);
2086
2087 for (uint i = 0; i < GPU_THREADS_NV; i++) if (device_param->result[i] == 1) found = 1;
2088
2089 #elif _OCL
2090
2091 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_result, CL_TRUE, 0, device_param->size_results, device_param->result, 0, NULL, NULL);
2092
2093 for (uint i = 0; i < GPU_THREADS_AMD; i++) if (device_param->result[i] == 1) found = 1;
2094
2095 #endif
2096
2097 if (found == 1)
2098 {
2099 // display hack (for weak hashes etc, it could be that there is still something to clear on the current line)
2100
2101 log_info_nn ("");
2102
2103 #ifdef _CUDA
2104
2105 hc_cuCtxPushCurrent (device_param->context);
2106
2107 hc_cuMemcpyDtoH (&data.digests_shown_tmp[salt_buf->digests_offset], device_param->d_digests_shown + (salt_buf->digests_offset * sizeof (uint)), salt_buf->digests_cnt * sizeof (uint));
2108
2109 hc_cuCtxPopCurrent (&device_param->context);
2110
2111 #elif _OCL
2112
2113 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (uint), salt_buf->digests_cnt * sizeof (uint), &data.digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL);
2114
2115 #endif
2116
2117 uint cpt_cracked = 0;
2118
2119 for (uint digest_pos = 0; digest_pos < salt_buf->digests_cnt; digest_pos++)
2120 {
2121 uint idx = salt_buf->digests_offset + digest_pos;
2122
2123 if (data.digests_shown_tmp[idx] == 0) continue;
2124
2125 if (data.digests_shown[idx] == 1) continue;
2126
2127 if ((data.opts_type & OPTS_TYPE_PT_NEVERCRACK) == 0)
2128 {
2129 data.digests_shown[idx] = 1;
2130
2131 data.digests_done++;
2132
2133 cpt_cracked++;
2134
2135 salt_buf->digests_done++;
2136
2137 if (salt_buf->digests_done == salt_buf->digests_cnt)
2138 {
2139 data.salts_shown[salt_pos] = 1;
2140
2141 data.salts_done++;
2142 }
2143 }
2144
2145 if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
2146
2147 check_hash (device_param, salt_pos, digest_pos);
2148 }
2149
2150 if (cpt_cracked > 0)
2151 {
2152 data.cpt_buf[data.cpt_pos].timestamp = time (NULL);
2153 data.cpt_buf[data.cpt_pos].cracked = cpt_cracked;
2154
2155 data.cpt_pos++;
2156
2157 data.cpt_total += cpt_cracked;
2158
2159 if (data.cpt_pos == CPT_BUF) data.cpt_pos = 0;
2160 }
2161
2162 if (data.opts_type & OPTS_TYPE_PT_NEVERCRACK)
2163 {
2164 // we need to reset cracked state on the gpu
2165 // otherwise host thinks again and again the hash was cracked
2166 // and returns invalid password each time
2167
2168 memset (data.digests_shown_tmp, 0, salt_buf->digests_cnt * sizeof (uint));
2169
2170 #ifdef _CUDA
2171
2172 hc_cuCtxPushCurrent (device_param->context);
2173
2174 hc_cuMemsetD8 (device_param->d_digests_shown + (salt_buf->digests_offset * sizeof (uint)), 0, salt_buf->digests_cnt * sizeof (uint));
2175
2176 hc_cuCtxPopCurrent (&device_param->context);
2177
2178 #elif _OCL
2179
2180 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (uint), salt_buf->digests_cnt * sizeof (uint), &data.digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL);
2181
2182 #endif
2183 }
2184
2185 #ifdef _CUDA
2186
2187 hc_cuCtxPushCurrent (device_param->context);
2188
2189 hc_cuMemsetD8 (device_param->d_result, 0, device_param->size_results);
2190
2191 hc_cuCtxPopCurrent (&device_param->context);
2192
2193 #elif _OCL
2194
2195 memset (device_param->result, 0, device_param->size_results);
2196
2197 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_result, CL_TRUE, 0, device_param->size_results, device_param->result, 0, NULL, NULL);
2198
2199 #endif
2200 }
2201 }
2202
2203 static void save_hash ()
2204 {
2205 char *hashfile = data.hashfile;
2206
2207 char new_hashfile[256];
2208 char old_hashfile[256];
2209
2210 memset (new_hashfile, 0, sizeof (new_hashfile));
2211 memset (old_hashfile, 0, sizeof (old_hashfile));
2212
2213 snprintf (new_hashfile, 255, "%s.new", hashfile);
2214 snprintf (old_hashfile, 255, "%s.old", hashfile);
2215
2216 unlink (new_hashfile);
2217
2218 char separator = data.separator;
2219
2220 FILE *fp = fopen (new_hashfile, "wb");
2221
2222 if (fp == NULL)
2223 {
2224 log_error ("ERROR: %s: %s", new_hashfile, strerror (errno));
2225
2226 exit (-1);
2227 }
2228
2229 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
2230 {
2231 if (data.salts_shown[salt_pos] == 1) continue;
2232
2233 salt_t *salt_buf = &data.salts_buf[salt_pos];
2234
2235 for (uint digest_pos = 0; digest_pos < salt_buf->digests_cnt; digest_pos++)
2236 {
2237 uint idx = salt_buf->digests_offset + digest_pos;
2238
2239 if (data.digests_shown[idx] == 1) continue;
2240
2241 if (data.hash_mode != 2500)
2242 {
2243 char out_buf[4096];
2244
2245 memset (out_buf, 0, sizeof (out_buf));
2246
2247 if (data.username == 1)
2248 {
2249 user_t *user = data.hash_info[idx]->user;
2250
2251 uint i;
2252
2253 for (i = 0; i < user->user_len; i++) fputc (user->user_name[i], fp);
2254
2255 fputc (separator, fp);
2256 }
2257
2258 ascii_digest (out_buf, salt_pos, digest_pos);
2259
2260 fputs (out_buf, fp);
2261
2262 log_out (fp, "");
2263 }
2264 else
2265 {
2266 hccap_t hccap;
2267
2268 to_hccap_t (&hccap, salt_pos, digest_pos);
2269
2270 fwrite (&hccap, sizeof (hccap_t), 1, fp);
2271 }
2272 }
2273 }
2274
2275 fflush (fp);
2276
2277 fclose (fp);
2278
2279 unlink (old_hashfile);
2280
2281 if (rename (hashfile, old_hashfile) != 0)
2282 {
2283 log_error ("ERROR: Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno));
2284
2285 exit (-1);
2286 }
2287
2288 unlink (hashfile);
2289
2290 if (rename (new_hashfile, hashfile) != 0)
2291 {
2292 log_error ("ERROR: Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno));
2293
2294 exit (-1);
2295 }
2296
2297 unlink (old_hashfile);
2298 }
2299
2300 static float find_gpu_blocks_div (const uint64_t total_left, const uint gpu_blocks_all)
2301 {
2302 // function called only in case gpu_blocks_all > words_left)
2303
2304 float gpu_blocks_div = (float) (total_left) / gpu_blocks_all;
2305
2306 gpu_blocks_div += gpu_blocks_div / 100;
2307
2308 uint32_t gpu_blocks_new = (uint32_t) (gpu_blocks_all * gpu_blocks_div);
2309
2310 while (gpu_blocks_new < total_left)
2311 {
2312 gpu_blocks_div += gpu_blocks_div / 100;
2313
2314 gpu_blocks_new = (uint32_t) (gpu_blocks_all * gpu_blocks_div);
2315 }
2316
2317 if (data.quiet == 0)
2318 {
2319 clear_prompt ();
2320
2321 log_info ("");
2322
2323 log_info ("INFO: approaching final keyspace, workload adjusted");
2324
2325 log_info ("");
2326
2327 fprintf (stdout, "%s", PROMPT);
2328
2329 fflush (stdout);
2330 }
2331
2332 if ((gpu_blocks_all * gpu_blocks_div) < 8) return 1;
2333
2334 return gpu_blocks_div;
2335 }
2336
2337 static void run_kernel (const uint kern_run, hc_device_param_t *device_param, const uint num)
2338 {
2339 // uint gpu_vector_width = device_param->gpu_vector_width;
2340
2341 // uint num_elements = mydivc32 (num, gpu_vector_width);
2342
2343 uint num_elements = num;
2344
2345 device_param->kernel_params_buf32[30] = data.combs_mode;
2346 device_param->kernel_params_buf32[31] = num;
2347
2348 uint gpu_threads = device_param->gpu_threads;
2349
2350 while (num_elements % gpu_threads) num_elements++;
2351
2352 #ifdef _CUDA
2353 CUfunction function = NULL;
2354
2355 switch (kern_run)
2356 {
2357 case KERN_RUN_1: function = device_param->function1; break;
2358 case KERN_RUN_12: function = device_param->function12; break;
2359 case KERN_RUN_2: function = device_param->function2; break;
2360 case KERN_RUN_23: function = device_param->function23; break;
2361 case KERN_RUN_3: function = device_param->function3; break;
2362 }
2363
2364 num_elements /= gpu_threads;
2365
2366 hc_cuCtxPushCurrent (device_param->context);
2367
2368 hc_cuLaunchKernel (function, num_elements, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, device_param->kernel_params, NULL);
2369
2370 hc_cuStreamSynchronize (device_param->stream);
2371
2372 hc_cuCtxPopCurrent (&device_param->context);
2373
2374 #elif _OCL
2375
2376 cl_kernel kernel = NULL;
2377
2378 switch (kern_run)
2379 {
2380 case KERN_RUN_1: kernel = device_param->kernel1; break;
2381 case KERN_RUN_12: kernel = device_param->kernel12; break;
2382 case KERN_RUN_2: kernel = device_param->kernel2; break;
2383 case KERN_RUN_23: kernel = device_param->kernel23; break;
2384 case KERN_RUN_3: kernel = device_param->kernel3; break;
2385 }
2386
2387 hc_clSetKernelArg (kernel, 21, sizeof (cl_uint), device_param->kernel_params[21]);
2388 hc_clSetKernelArg (kernel, 22, sizeof (cl_uint), device_param->kernel_params[22]);
2389 hc_clSetKernelArg (kernel, 23, sizeof (cl_uint), device_param->kernel_params[23]);
2390 hc_clSetKernelArg (kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]);
2391 hc_clSetKernelArg (kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]);
2392 hc_clSetKernelArg (kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]);
2393 hc_clSetKernelArg (kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]);
2394 hc_clSetKernelArg (kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]);
2395 hc_clSetKernelArg (kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]);
2396 hc_clSetKernelArg (kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]);
2397 hc_clSetKernelArg (kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]);
2398
2399 if ((data.opts_type & OPTS_TYPE_PT_BITSLICE) && (data.attack_mode == ATTACK_MODE_BF))
2400 {
2401 const size_t global_work_size[3] = { num_elements, 32, 1 };
2402 const size_t local_work_size[3] = { gpu_threads / 32, 32, 1 };
2403
2404 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 2, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2405 }
2406 else
2407 {
2408 const size_t global_work_size[3] = { num_elements, 1, 1 };
2409 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2410
2411 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2412 }
2413
2414 hc_clFlush (device_param->command_queue);
2415
2416 hc_clFinish (device_param->command_queue);
2417
2418 #endif
2419 }
2420
2421 static void run_kernel_mp (const uint kern_run, hc_device_param_t *device_param, const uint num)
2422 {
2423 // uint gpu_vector_width = device_param->gpu_vector_width;
2424
2425 // uint num_elements = mydivc32 (num, gpu_vector_width);
2426
2427 uint num_elements = num;
2428
2429 switch (kern_run)
2430 {
2431 case KERN_RUN_MP: device_param->kernel_params_mp_buf32[8] = num; break;
2432 case KERN_RUN_MP_R: device_param->kernel_params_mp_r_buf32[8] = num; break;
2433 case KERN_RUN_MP_L: device_param->kernel_params_mp_l_buf32[9] = num; break;
2434 }
2435
2436 // causes problems with special threads like in bcrypt
2437 // const uint gpu_threads = device_param->gpu_threads;
2438
2439 #ifdef _CUDA
2440
2441 const uint gpu_threads = GPU_THREADS_NV;
2442
2443 while (num_elements % gpu_threads) num_elements++;
2444
2445 CUfunction function = NULL;
2446
2447 switch (kern_run)
2448 {
2449 case KERN_RUN_MP: function = device_param->function_mp; break;
2450 case KERN_RUN_MP_R: function = device_param->function_mp_r; break;
2451 case KERN_RUN_MP_L: function = device_param->function_mp_l; break;
2452 }
2453
2454 void **kernel_params = NULL;
2455
2456 switch (kern_run)
2457 {
2458 case KERN_RUN_MP: kernel_params = device_param->kernel_params_mp; break;
2459 case KERN_RUN_MP_R: kernel_params = device_param->kernel_params_mp_r; break;
2460 case KERN_RUN_MP_L: kernel_params = device_param->kernel_params_mp_l; break;
2461 }
2462
2463 num_elements /= gpu_threads;
2464
2465 hc_cuCtxPushCurrent (device_param->context);
2466
2467 hc_cuLaunchKernel (function, num_elements, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, kernel_params, NULL);
2468
2469 hc_cuStreamSynchronize (device_param->stream);
2470
2471 hc_cuCtxPopCurrent (&device_param->context);
2472
2473 #elif _OCL
2474
2475 const uint gpu_threads = GPU_THREADS_AMD;
2476
2477 while (num_elements % gpu_threads) num_elements++;
2478
2479 cl_kernel kernel = NULL;
2480
2481 switch (kern_run)
2482 {
2483 case KERN_RUN_MP: kernel = device_param->kernel_mp; break;
2484 case KERN_RUN_MP_R: kernel = device_param->kernel_mp_r; break;
2485 case KERN_RUN_MP_L: kernel = device_param->kernel_mp_l; break;
2486 }
2487
2488 switch (kern_run)
2489 {
2490 case KERN_RUN_MP: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp[3]);
2491 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp[4]);
2492 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp[5]);
2493 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp[6]);
2494 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp[7]);
2495 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp[8]);
2496 break;
2497 case KERN_RUN_MP_R: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_r[3]);
2498 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_r[4]);
2499 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_r[5]);
2500 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_r[6]);
2501 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_r[7]);
2502 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_r[8]);
2503 break;
2504 case KERN_RUN_MP_L: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_l[3]);
2505 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_l[4]);
2506 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_l[5]);
2507 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_l[6]);
2508 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_l[7]);
2509 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_l[8]);
2510 hc_clSetKernelArg (kernel, 9, sizeof (cl_uint), device_param->kernel_params_mp_l[9]);
2511 break;
2512 }
2513
2514 const size_t global_work_size[3] = { num_elements, 1, 1 };
2515 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2516
2517 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2518
2519 hc_clFlush (device_param->command_queue);
2520
2521 hc_clFinish (device_param->command_queue);
2522
2523 #endif
2524 }
2525
2526 static void run_kernel_tb (hc_device_param_t *device_param, const uint num)
2527 {
2528 uint num_elements = num;
2529
2530 uint gpu_threads = device_param->gpu_threads;
2531
2532 while (num_elements % gpu_threads) num_elements++;
2533
2534 #ifdef _CUDA
2535
2536 CUfunction function = device_param->function_tb;
2537
2538 void **kernel_params = device_param->kernel_params_tb;
2539
2540 hc_cuCtxPushCurrent (device_param->context);
2541
2542 hc_cuLaunchKernel (function, num_elements / gpu_threads, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, kernel_params, NULL);
2543
2544 hc_cuStreamSynchronize (device_param->stream);
2545
2546 hc_cuCtxPopCurrent (&device_param->context);
2547
2548 #elif _OCL
2549
2550 cl_kernel kernel = device_param->kernel_tb;
2551
2552 const size_t global_work_size[3] = { num_elements, 1, 1 };
2553 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2554
2555 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2556
2557 hc_clFlush (device_param->command_queue);
2558
2559 hc_clFinish (device_param->command_queue);
2560
2561 #endif
2562 }
2563
2564 static void run_kernel_tm (hc_device_param_t *device_param)
2565 {
2566 const uint num_elements = 1024; // fixed
2567
2568 const uint gpu_threads = 32;
2569
2570 #ifdef _CUDA
2571
2572 CUfunction function = device_param->function_tm;
2573
2574 void **kernel_params = device_param->kernel_params_tm;
2575
2576 hc_cuCtxPushCurrent (device_param->context);
2577
2578 hc_cuLaunchKernel (function, num_elements / gpu_threads, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, kernel_params, NULL);
2579
2580 hc_cuStreamSynchronize (device_param->stream);
2581
2582 hc_cuCtxPopCurrent (&device_param->context);
2583
2584 #elif _OCL
2585
2586 cl_kernel kernel = device_param->kernel_tm;
2587
2588 const size_t global_work_size[3] = { num_elements, 1, 1 };
2589 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2590
2591 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2592
2593 hc_clFlush (device_param->command_queue);
2594
2595 hc_clFinish (device_param->command_queue);
2596
2597 #endif
2598 }
2599
2600 static void run_kernel_amp (hc_device_param_t *device_param, const uint num)
2601 {
2602 // uint gpu_vector_width = device_param->gpu_vector_width;
2603
2604 // uint num_elements = mydivc32 (num, gpu_vector_width);
2605
2606 uint num_elements = num;
2607
2608 device_param->kernel_params_amp_buf32[5] = data.combs_mode;
2609 device_param->kernel_params_amp_buf32[6] = num_elements;
2610
2611 // causes problems with special threads like in bcrypt
2612 // const uint gpu_threads = device_param->gpu_threads;
2613
2614 #ifdef _CUDA
2615
2616 const uint gpu_threads = GPU_THREADS_NV;
2617
2618 while (num_elements % gpu_threads) num_elements++;
2619
2620 CUfunction function = device_param->function_amp;
2621
2622 void **kernel_params = device_param->kernel_params_amp;
2623
2624 num_elements /= gpu_threads;
2625
2626 hc_cuCtxPushCurrent (device_param->context);
2627
2628 hc_cuLaunchKernel (function, num_elements, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, kernel_params, NULL);
2629
2630 hc_cuStreamSynchronize (device_param->stream);
2631
2632 hc_cuCtxPopCurrent (&device_param->context);
2633
2634 #elif _OCL
2635
2636 const uint gpu_threads = GPU_THREADS_AMD;
2637
2638 while (num_elements % gpu_threads) num_elements++;
2639
2640 cl_kernel kernel = device_param->kernel_amp;
2641
2642 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]);
2643 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_amp[6]);
2644
2645 const size_t global_work_size[3] = { num_elements, 1, 1 };
2646 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2647
2648 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2649
2650 hc_clFlush (device_param->command_queue);
2651
2652 hc_clFinish (device_param->command_queue);
2653
2654 #endif
2655 }
2656
2657 #ifdef _OCL
2658 static void run_kernel_bzero (hc_device_param_t *device_param, cl_mem buf, const uint size)
2659 {
2660 const cl_uchar zero = 0;
2661
2662 hc_clEnqueueFillBuffer (device_param->command_queue, buf, &zero, sizeof (cl_uchar), 0, size, 0, NULL, NULL);
2663 }
2664 #elif _CUDA
2665 static void run_kernel_bzero (hc_device_param_t *device_param, CUdeviceptr buf, const uint size)
2666 {
2667 hc_cuCtxPushCurrent (device_param->context);
2668
2669 hc_cuMemsetD8 (buf, 0, size);
2670
2671 hc_cuCtxPopCurrent (&device_param->context);
2672 }
2673 #endif
2674
2675 static int run_rule_engine (const int rule_len, const char *rule_buf)
2676 {
2677 if (rule_len == 0)
2678 {
2679 return 0;
2680 }
2681 else if (rule_len == 1)
2682 {
2683 if (rule_buf[0] == RULE_OP_MANGLE_NOOP) return 0;
2684 }
2685
2686 return 1;
2687 }
2688
2689 static void run_copy (hc_device_param_t *device_param, const uint pws_cnt)
2690 {
2691 #ifdef _CUDA
2692 hc_cuCtxPushCurrent (device_param->context);
2693 #endif
2694
2695 // clear some leftovers from previous run (maskfiles, etc)
2696
2697 #ifdef _CUDA
2698 if (device_param->c_bfs != 0) // should be only true in this specific case: if (data.attack_kern == ATTACK_KERN_BF)
2699 {
2700 hc_cuMemsetD8 (device_param->c_bfs, 0, device_param->c_bytes);
2701 }
2702 #endif
2703
2704 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
2705 {
2706 #ifdef _CUDA
2707 hc_cuMemcpyHtoD (device_param->d_pws_buf, device_param->pws_buf, pws_cnt * sizeof (pw_t));
2708 #elif _OCL
2709 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
2710 #endif
2711 }
2712 else if (data.attack_kern == ATTACK_KERN_COMBI)
2713 {
2714 #ifdef _CUDA
2715 hc_cuMemcpyHtoD (device_param->d_pws_buf, device_param->pws_buf, pws_cnt * sizeof (pw_t));
2716 #elif _OCL
2717 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
2718 #endif
2719 }
2720 else if (data.attack_kern == ATTACK_KERN_BF)
2721 {
2722 const uint64_t off = device_param->words_off;
2723
2724 device_param->kernel_params_mp_l_buf64[3] = off;
2725
2726 run_kernel_mp (KERN_RUN_MP_L, device_param, pws_cnt);
2727 }
2728
2729 #ifdef _CUDA
2730 hc_cuCtxPopCurrent (&device_param->context);
2731 #endif
2732 }
2733
2734 static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, const uint pws_cnt)
2735 {
2736 const uint gpu_loops = data.gpu_loops;
2737
2738 // init speed timer
2739
2740 uint speed_pos = device_param->speed_pos;
2741
2742 #ifdef _POSIX
2743 if (device_param->timer_speed.tv_sec == 0)
2744 {
2745 hc_timer_set (&device_param->timer_speed);
2746 }
2747 #endif
2748
2749 #ifdef _WIN
2750 if (device_param->timer_speed.QuadPart == 0)
2751 {
2752 hc_timer_set (&device_param->timer_speed);
2753 }
2754 #endif
2755
2756 // find higest password length, this is for optimization stuff
2757
2758 uint highest_pw_len = 0;
2759
2760 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
2761 {
2762 }
2763 else if (data.attack_kern == ATTACK_KERN_COMBI)
2764 {
2765 }
2766 else if (data.attack_kern == ATTACK_KERN_BF)
2767 {
2768 highest_pw_len = device_param->kernel_params_mp_l_buf32[4]
2769 + device_param->kernel_params_mp_l_buf32[5];
2770 }
2771
2772 // bitslice optimization stuff
2773
2774 if (data.attack_mode == ATTACK_MODE_BF)
2775 {
2776 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
2777 {
2778 run_kernel_tb (device_param, pws_cnt);
2779 }
2780 }
2781
2782 // iteration type
2783
2784 uint innerloop_step = 0;
2785 uint innerloop_cnt = 0;
2786
2787 if (data.attack_exec == ATTACK_EXEC_ON_GPU) innerloop_step = gpu_loops;
2788 else innerloop_step = 1;
2789
2790 if (data.attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = data.gpu_rules_cnt;
2791 else if (data.attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = data.combs_cnt;
2792 else if (data.attack_kern == ATTACK_KERN_BF) innerloop_cnt = data.bfs_cnt;
2793
2794 // loop start: most outer loop = salt iteration, then innerloops (if multi)
2795
2796 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
2797 {
2798 while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
2799
2800 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
2801
2802 if (data.devices_status == STATUS_CRACKED) break;
2803 if (data.devices_status == STATUS_ABORTED) break;
2804 if (data.devices_status == STATUS_QUIT) break;
2805 if (data.devices_status == STATUS_BYPASS) break;
2806
2807 if (data.salts_shown[salt_pos] == 1) continue;
2808
2809 salt_t *salt_buf = &data.salts_buf[salt_pos];
2810
2811 device_param->kernel_params_buf32[24] = salt_pos;
2812 device_param->kernel_params_buf32[28] = salt_buf->digests_cnt;
2813 device_param->kernel_params_buf32[29] = salt_buf->digests_offset;
2814
2815 FILE *combs_fp = device_param->combs_fp;
2816
2817 if (data.attack_mode == ATTACK_MODE_COMBI)
2818 {
2819 rewind (combs_fp);
2820 }
2821
2822 // innerloops
2823
2824 for (uint innerloop_pos = 0; innerloop_pos < innerloop_cnt; innerloop_pos += innerloop_step)
2825 {
2826 while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
2827
2828 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
2829
2830 if (data.devices_status == STATUS_CRACKED) break;
2831 if (data.devices_status == STATUS_ABORTED) break;
2832 if (data.devices_status == STATUS_QUIT) break;
2833 if (data.devices_status == STATUS_BYPASS) break;
2834
2835 uint innerloop_left = innerloop_cnt - innerloop_pos;
2836
2837 if (innerloop_left > innerloop_step) innerloop_left = innerloop_step;
2838
2839 device_param->innerloop_pos = innerloop_pos;
2840 device_param->innerloop_left = innerloop_left;
2841
2842 device_param->kernel_params_buf32[27] = innerloop_left;
2843
2844 if (innerloop_left == 0) continue;
2845
2846 // initialize amplifiers
2847
2848 if (data.attack_mode == ATTACK_MODE_COMBI)
2849 {
2850 char line_buf[BUFSIZ];
2851
2852 uint i = 0;
2853
2854 while (i < innerloop_left)
2855 {
2856 if (feof (combs_fp)) break;
2857
2858 int line_len = fgetl (combs_fp, line_buf);
2859
2860 if (line_len >= PW_MAX1) continue;
2861
2862 line_len = convert_from_hex (line_buf, line_len);
2863
2864 char *line_buf_new = line_buf;
2865
2866 if (run_rule_engine (data.rule_len_r, data.rule_buf_r))
2867 {
2868 char rule_buf_out[BLOCK_SIZE];
2869
2870 memset (rule_buf_out, 0, sizeof (rule_buf_out));
2871
2872 int rule_len_out = _old_apply_rule (data.rule_buf_r, data.rule_len_r, line_buf, line_len, rule_buf_out);
2873
2874 if (rule_len_out < 0)
2875 {
2876 data.words_progress_rejected[salt_pos] += pw_cnt;
2877
2878 continue;
2879 }
2880
2881 line_len = rule_len_out;
2882
2883 line_buf_new = rule_buf_out;
2884 }
2885
2886 line_len = MIN (line_len, PW_DICTMAX);
2887
2888 char *ptr = (char *) device_param->combs_buf[i].i;
2889
2890 memcpy (ptr, line_buf_new, line_len);
2891
2892 memset (ptr + line_len, 0, PW_DICTMAX1 - line_len);
2893
2894 if (data.opts_type & OPTS_TYPE_PT_UPPER)
2895 {
2896 uppercase (ptr, line_len);
2897 }
2898
2899 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
2900 {
2901 if (data.opts_type & OPTS_TYPE_PT_ADD80)
2902 {
2903 ptr[line_len] = 0x80;
2904 }
2905
2906 if (data.opts_type & OPTS_TYPE_PT_ADD01)
2907 {
2908 ptr[line_len] = 0x01;
2909 }
2910 }
2911
2912 device_param->combs_buf[i].pw_len = line_len;
2913
2914 i++;
2915 }
2916
2917 for (uint j = i; j < innerloop_left; j++)
2918 {
2919 device_param->combs_buf[j].i[0] = 0;
2920 device_param->combs_buf[j].i[1] = 0;
2921 device_param->combs_buf[j].i[2] = 0;
2922 device_param->combs_buf[j].i[3] = 0;
2923 device_param->combs_buf[j].i[4] = 0;
2924 device_param->combs_buf[j].i[5] = 0;
2925 device_param->combs_buf[j].i[6] = 0;
2926 device_param->combs_buf[j].i[7] = 0;
2927
2928 device_param->combs_buf[j].pw_len = 0;
2929 }
2930
2931 innerloop_left = i;
2932 }
2933 else if (data.attack_mode == ATTACK_MODE_BF)
2934 {
2935 uint64_t off = innerloop_pos;
2936
2937 device_param->kernel_params_mp_r_buf64[3] = off;
2938
2939 const uint gpu_vector_width = device_param->gpu_vector_width;
2940
2941 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2942
2943 run_kernel_mp (KERN_RUN_MP_R, device_param, innerloop_left_d);
2944 }
2945 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
2946 {
2947 uint64_t off = innerloop_pos;
2948
2949 device_param->kernel_params_mp_buf64[3] = off;
2950
2951 const uint gpu_vector_width = device_param->gpu_vector_width;
2952
2953 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2954
2955 run_kernel_mp (KERN_RUN_MP, device_param, innerloop_left_d);
2956 }
2957 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
2958 {
2959 uint64_t off = innerloop_pos;
2960
2961 device_param->kernel_params_mp_buf64[3] = off;
2962
2963 const uint gpu_vector_width = device_param->gpu_vector_width;
2964
2965 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2966
2967 run_kernel_mp (KERN_RUN_MP, device_param, innerloop_left_d);
2968 }
2969
2970 // copy amplifiers
2971
2972 #ifdef _CUDA
2973 hc_cuCtxPushCurrent (device_param->context);
2974
2975 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
2976 {
2977 hc_cuMemcpyDtoD (device_param->c_rules, device_param->d_rules + (innerloop_pos * sizeof (gpu_rule_t)), innerloop_left * sizeof (gpu_rule_t));
2978 }
2979 else if (data.attack_mode == ATTACK_MODE_COMBI)
2980 {
2981 hc_cuMemcpyHtoD (device_param->c_combs, device_param->combs_buf, innerloop_left * sizeof (comb_t));
2982 }
2983 else if (data.attack_mode == ATTACK_MODE_BF)
2984 {
2985 hc_cuMemcpyDtoD (device_param->c_bfs, device_param->d_bfs, innerloop_left * sizeof (bf_t));
2986 }
2987 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
2988 {
2989 hc_cuMemcpyDtoD (device_param->c_combs, device_param->d_combs, innerloop_left * sizeof (comb_t));
2990 }
2991 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
2992 {
2993 hc_cuMemcpyDtoD (device_param->c_combs, device_param->d_combs, innerloop_left * sizeof (comb_t));
2994 }
2995
2996 hc_cuCtxPopCurrent (&device_param->context);
2997
2998 #elif _OCL
2999 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
3000 {
3001 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (gpu_rule_t), 0, innerloop_left * sizeof (gpu_rule_t), 0, NULL, NULL);
3002 }
3003 else if (data.attack_mode == ATTACK_MODE_COMBI)
3004 {
3005 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (comb_t), device_param->combs_buf, 0, NULL, NULL);
3006 }
3007 else if (data.attack_mode == ATTACK_MODE_BF)
3008 {
3009 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL);
3010 }
3011 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
3012 {
3013 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL);
3014 }
3015 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
3016 {
3017 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL);
3018 }
3019
3020 #endif
3021
3022 if (data.attack_exec == ATTACK_EXEC_ON_GPU)
3023 {
3024 if (data.attack_mode == ATTACK_MODE_BF)
3025 {
3026 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
3027 {
3028 const uint size_tm = 32 * sizeof (bs_word_t);
3029
3030 #ifdef _CUDA
3031 run_kernel_bzero (device_param, device_param->d_tm, size_tm);
3032 #elif _OCL
3033 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
3034 #endif
3035
3036 run_kernel_tm (device_param);
3037
3038 #ifdef _CUDA
3039 hc_cuCtxPushCurrent (device_param->context);
3040
3041 hc_cuMemcpyDtoD (device_param->c_tm, device_param->d_tm, size_tm);
3042
3043 hc_cuCtxPopCurrent (&device_param->context);
3044 #elif _OCL
3045 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL);
3046 #endif
3047 }
3048 }
3049
3050 if (highest_pw_len < 16)
3051 {
3052 run_kernel (KERN_RUN_1, device_param, pws_cnt);
3053 }
3054 else if (highest_pw_len < 32)
3055 {
3056 run_kernel (KERN_RUN_2, device_param, pws_cnt);
3057 }
3058 else
3059 {
3060 run_kernel (KERN_RUN_3, device_param, pws_cnt);
3061 }
3062 }
3063 else
3064 {
3065 run_kernel_amp (device_param, pws_cnt);
3066
3067 run_kernel (KERN_RUN_1, device_param, pws_cnt);
3068
3069 if (data.opts_type & OPTS_TYPE_HOOK12)
3070 {
3071 run_kernel (KERN_RUN_12, device_param, pws_cnt);
3072 }
3073
3074 uint iter = salt_buf->salt_iter;
3075
3076 for (uint loop_pos = 0; loop_pos < iter; loop_pos += gpu_loops)
3077 {
3078 uint loop_left = iter - loop_pos;
3079
3080 loop_left = MIN (loop_left, gpu_loops);
3081
3082 device_param->kernel_params_buf32[25] = loop_pos;
3083 device_param->kernel_params_buf32[26] = loop_left;
3084
3085 run_kernel (KERN_RUN_2, device_param, pws_cnt);
3086
3087 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
3088
3089 if (data.devices_status == STATUS_CRACKED) break;
3090 if (data.devices_status == STATUS_ABORTED) break;
3091 if (data.devices_status == STATUS_QUIT) break;
3092 }
3093
3094 if (data.opts_type & OPTS_TYPE_HOOK23)
3095 {
3096 run_kernel (KERN_RUN_23, device_param, pws_cnt);
3097
3098 #ifdef _CUDA
3099 hc_cuCtxPushCurrent (device_param->context);
3100
3101 hc_cuMemcpyDtoH (device_param->hooks_buf, device_param->d_hooks, device_param->size_hooks);
3102
3103 hc_cuCtxPopCurrent (&device_param->context);
3104 #elif _OCL
3105 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL);
3106 #endif
3107
3108 // do something with data
3109
3110
3111 #ifdef _CUDA
3112 hc_cuCtxPushCurrent (device_param->context);
3113
3114 hc_cuMemcpyHtoD (device_param->d_hooks, device_param->hooks_buf, device_param->size_hooks);
3115
3116 hc_cuCtxPopCurrent (&device_param->context);
3117 #elif _OCL
3118 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL);
3119 #endif
3120 }
3121
3122 run_kernel (KERN_RUN_3, device_param, pws_cnt);
3123 }
3124
3125 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
3126
3127 if (data.devices_status == STATUS_CRACKED) break;
3128 if (data.devices_status == STATUS_ABORTED) break;
3129 if (data.devices_status == STATUS_QUIT) break;
3130
3131 /**
3132 * result
3133 */
3134
3135 hc_thread_mutex_lock (mux_display);
3136
3137 check_cracked (device_param, salt_pos);
3138
3139 hc_thread_mutex_unlock (mux_display);
3140
3141 /**
3142 * progress
3143 */
3144
3145 uint64_t perf_sum_all = (uint64_t) pw_cnt * (uint64_t) innerloop_left;
3146
3147 hc_thread_mutex_lock (mux_counter);
3148
3149 data.words_progress_done[salt_pos] += perf_sum_all;
3150
3151 hc_thread_mutex_unlock (mux_counter);
3152
3153 /**
3154 * speed
3155 */
3156
3157 float speed_ms;
3158
3159 hc_timer_get (device_param->timer_speed, speed_ms);
3160
3161 hc_timer_set (&device_param->timer_speed);
3162
3163 hc_thread_mutex_lock (mux_display);
3164
3165 device_param->speed_cnt[speed_pos] = perf_sum_all;
3166
3167 device_param->speed_ms[speed_pos] = speed_ms;
3168
3169 device_param->speed_rec[speed_pos] = device_param->timer_speed;
3170
3171 hc_thread_mutex_unlock (mux_display);
3172
3173 speed_pos++;
3174
3175 if (speed_pos == SPEED_CACHE)
3176 {
3177 speed_pos = 0;
3178 }
3179 }
3180 }
3181
3182 device_param->speed_pos = speed_pos;
3183 }
3184
3185 static void load_segment (wl_data_t *wl_data, FILE *fd)
3186 {
3187 // NOTE: use (never changing) ->incr here instead of ->avail otherwise the buffer gets bigger and bigger
3188
3189 wl_data->pos = 0;
3190
3191 wl_data->cnt = fread (wl_data->buf, 1, wl_data->incr - 1000, fd);
3192
3193 wl_data->buf[wl_data->cnt] = 0;
3194
3195 if (wl_data->cnt == 0) return;
3196
3197 if (wl_data->buf[wl_data->cnt - 1] == '\n') return;
3198
3199 while (!feof (fd))
3200 {
3201 if (wl_data->cnt == wl_data->avail)
3202 {
3203 wl_data->buf = (char *) myrealloc (wl_data->buf, wl_data->avail, wl_data->incr);
3204
3205 wl_data->avail += wl_data->incr;
3206 }
3207
3208 const int c = fgetc (fd);
3209
3210 if (c == EOF) break;
3211
3212 wl_data->buf[wl_data->cnt] = (char) c;
3213
3214 wl_data->cnt++;
3215
3216 if (c == '\n') break;
3217 }
3218
3219 // ensure stream ends with a newline
3220
3221 if (wl_data->buf[wl_data->cnt - 1] != '\n')
3222 {
3223 wl_data->cnt++;
3224
3225 wl_data->buf[wl_data->cnt - 1] = '\n';
3226 }
3227
3228 return;
3229 }
3230
3231 static void get_next_word_lm (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3232 {
3233 char *ptr = buf;
3234
3235 for (uint32_t i = 0; i < sz; i++, ptr++)
3236 {
3237 if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
3238
3239 if (i == 7)
3240 {
3241 *off = i;
3242 *len = i;
3243
3244 return;
3245 }
3246
3247 if (*ptr != '\n') continue;
3248
3249 *off = i + 1;
3250
3251 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3252
3253 *len = i;
3254
3255 return;
3256 }
3257
3258 *off = sz;
3259 *len = sz;
3260 }
3261
3262 static void get_next_word_uc (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3263 {
3264 char *ptr = buf;
3265
3266 for (uint32_t i = 0; i < sz; i++, ptr++)
3267 {
3268 if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
3269
3270 if (*ptr != '\n') continue;
3271
3272 *off = i + 1;
3273
3274 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3275
3276 *len = i;
3277
3278 return;
3279 }
3280
3281 *off = sz;
3282 *len = sz;
3283 }
3284
3285 static void get_next_word_std (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3286 {
3287 char *ptr = buf;
3288
3289 for (uint32_t i = 0; i < sz; i++, ptr++)
3290 {
3291 if (*ptr != '\n') continue;
3292
3293 *off = i + 1;
3294
3295 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3296
3297 *len = i;
3298
3299 return;
3300 }
3301
3302 *off = sz;
3303 *len = sz;
3304 }
3305
3306 static void get_next_word (wl_data_t *wl_data, FILE *fd, char **out_buf, uint *out_len)
3307 {
3308 while (wl_data->pos < wl_data->cnt)
3309 {
3310 uint off;
3311 uint len;
3312
3313 char *ptr = wl_data->buf + wl_data->pos;
3314
3315 get_next_word_func (ptr, wl_data->cnt - wl_data->pos, &len, &off);
3316
3317 wl_data->pos += off;
3318
3319 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3320 {
3321 char rule_buf_out[BLOCK_SIZE];
3322
3323 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3324
3325 int rule_len_out = -1;
3326
3327 if (len < BLOCK_SIZE)
3328 {
3329 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, ptr, len, rule_buf_out);
3330 }
3331
3332 if (rule_len_out < 0)
3333 {
3334 continue;
3335 }
3336
3337 if (rule_len_out > PW_MAX)
3338 {
3339 continue;
3340 }
3341 }
3342 else
3343 {
3344 if (len > PW_MAX)
3345 {
3346 continue;
3347 }
3348 }
3349
3350 *out_buf = ptr;
3351 *out_len = len;
3352
3353 return;
3354 }
3355
3356 if (feof (fd))
3357 {
3358 fprintf (stderr, "bug!!\n");
3359
3360 return;
3361 }
3362
3363 load_segment (wl_data, fd);
3364
3365 get_next_word (wl_data, fd, out_buf, out_len);
3366 }
3367
3368 #ifdef _POSIX
3369 static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, size_t *dictstat_nmemb)
3370 #endif
3371
3372 #ifdef _WIN
3373 static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, uint *dictstat_nmemb)
3374 #endif
3375 {
3376 hc_signal (NULL);
3377
3378 dictstat_t d;
3379
3380 d.cnt = 0;
3381
3382 #ifdef _POSIX
3383 fstat (fileno (fd), &d.stat);
3384 #endif
3385
3386 #ifdef _WIN
3387 _fstat64 (fileno (fd), &d.stat);
3388 #endif
3389
3390 d.stat.st_mode = 0;
3391 d.stat.st_nlink = 0;
3392 d.stat.st_uid = 0;
3393 d.stat.st_gid = 0;
3394 d.stat.st_rdev = 0;
3395 d.stat.st_atime = 0;
3396
3397 #ifdef _POSIX
3398 d.stat.st_blksize = 0;
3399 d.stat.st_blocks = 0;
3400 #endif
3401
3402 if (d.stat.st_size == 0) return 0;
3403
3404 dictstat_t *d_cache = (dictstat_t *) lfind (&d, dictstat_base, dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
3405
3406 if (run_rule_engine (data.rule_len_l, data.rule_buf_l) == 0)
3407 {
3408 if (d_cache)
3409 {
3410 uint64_t cnt = d_cache->cnt;
3411
3412 uint64_t keyspace = cnt;
3413
3414 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
3415 {
3416 keyspace *= data.gpu_rules_cnt;
3417 }
3418 else if (data.attack_kern == ATTACK_KERN_COMBI)
3419 {
3420 keyspace *= data.combs_cnt;
3421 }
3422
3423 if (data.quiet == 0) log_info ("Cache-hit dictionary stats %s: %llu bytes, %llu words, %llu keyspace", dictfile, (unsigned long long int) d.stat.st_size, (unsigned long long int) cnt, (unsigned long long int) keyspace);
3424 if (data.quiet == 0) log_info ("");
3425
3426 hc_signal (sigHandler_default);
3427
3428 return (keyspace);
3429 }
3430 }
3431
3432 time_t now = 0;
3433 time_t prev = 0;
3434
3435 uint64_t comp = 0;
3436 uint64_t cnt = 0;
3437 uint64_t cnt2 = 0;
3438
3439 while (!feof (fd))
3440 {
3441 load_segment (wl_data, fd);
3442
3443 comp += wl_data->cnt;
3444
3445 uint32_t i = 0;
3446
3447 while (i < wl_data->cnt)
3448 {
3449 uint32_t len;
3450 uint32_t off;
3451
3452 get_next_word_func (wl_data->buf + i, wl_data->cnt - i, &len, &off);
3453
3454 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3455 {
3456 char rule_buf_out[BLOCK_SIZE];
3457
3458 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3459
3460 int rule_len_out = -1;
3461
3462 if (len < BLOCK_SIZE)
3463 {
3464 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, wl_data->buf + i, len, rule_buf_out);
3465 }
3466
3467 if (rule_len_out < 0)
3468 {
3469 len = PW_MAX1;
3470 }
3471 else
3472 {
3473 len = rule_len_out;
3474 }
3475 }
3476
3477 if (len < PW_MAX1)
3478 {
3479 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
3480 {
3481 cnt += data.gpu_rules_cnt;
3482 }
3483 else if (data.attack_kern == ATTACK_KERN_COMBI)
3484 {
3485 cnt += data.combs_cnt;
3486 }
3487
3488 d.cnt++;
3489 }
3490
3491 i += off;
3492
3493 cnt2++;
3494 }
3495
3496 time (&now);
3497
3498 if ((now - prev) == 0) continue;
3499
3500 float percent = (float) comp / (float) d.stat.st_size;
3501
3502 if (data.quiet == 0) log_info_nn ("Generating dictionary stats for %s: %llu bytes (%.2f%%), %llu words, %llu keyspace", dictfile, (unsigned long long int) comp, percent * 100, (unsigned long long int) cnt2, (unsigned long long int) cnt);
3503
3504 time (&prev);
3505 }
3506
3507 if (data.quiet == 0) log_info ("Generated dictionary stats for %s: %llu bytes, %llu words, %llu keyspace", dictfile, (unsigned long long int) comp, (unsigned long long int) cnt2, (unsigned long long int) cnt);
3508 if (data.quiet == 0) log_info ("");
3509
3510 lsearch (&d, dictstat_base, dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
3511
3512 hc_signal (sigHandler_default);
3513
3514 return (cnt);
3515 }
3516
3517 static uint get_gpu_vector_width (const uint hash_mode, const uint attack_mode, const uint attack_exec, const uint opti_type, const uint vliw)
3518 {
3519 uint gpu_vector_width = 0;
3520
3521 if ((attack_mode == ATTACK_MODE_BF) && (attack_exec == ATTACK_EXEC_ON_GPU) && (opti_type & OPTI_TYPE_SCALAR_MODE))
3522 {
3523 return VECT_SIZE_1;
3524 }
3525
3526 #ifdef _CUDA
3527 if ((attack_mode == ATTACK_MODE_STRAIGHT) && (attack_exec == ATTACK_EXEC_ON_GPU))
3528 {
3529 return VECT_SIZE_1;
3530 }
3531
3532 if (vliw == 1)
3533 {
3534 switch (hash_mode)
3535 {
3536 default: gpu_vector_width = VECT_SIZE_1; break;
3537 }
3538 }
3539 else if (vliw == 2)
3540 {
3541 switch (hash_mode)
3542 {
3543 case 0: gpu_vector_width = VECT_SIZE_4; break;
3544 case 10: gpu_vector_width = VECT_SIZE_4; break;
3545 case 11: gpu_vector_width = VECT_SIZE_4; break;
3546 case 12: gpu_vector_width = VECT_SIZE_4; break;
3547 case 20: gpu_vector_width = VECT_SIZE_4; break;
3548 case 21: gpu_vector_width = VECT_SIZE_4; break;
3549 case 22: gpu_vector_width = VECT_SIZE_4; break;
3550 case 23: gpu_vector_width = VECT_SIZE_4; break;
3551 case 30: gpu_vector_width = VECT_SIZE_4; break;
3552 case 40: gpu_vector_width = VECT_SIZE_4; break;
3553 case 50: gpu_vector_width = VECT_SIZE_4; break;
3554 case 60: gpu_vector_width = VECT_SIZE_4; break;
3555 case 100: gpu_vector_width = VECT_SIZE_4; break;
3556 case 101: gpu_vector_width = VECT_SIZE_4; break;
3557 case 110: gpu_vector_width = VECT_SIZE_4; break;
3558 case 111: gpu_vector_width = VECT_SIZE_4; break;
3559 case 112: gpu_vector_width = VECT_SIZE_4; break;
3560 case 120: gpu_vector_width = VECT_SIZE_4; break;
3561 case 121: gpu_vector_width = VECT_SIZE_4; break;
3562 case 122: gpu_vector_width = VECT_SIZE_4; break;
3563 case 124: gpu_vector_width = VECT_SIZE_4; break;
3564 case 130: gpu_vector_width = VECT_SIZE_4; break;
3565 case 131: gpu_vector_width = VECT_SIZE_4; break;
3566 case 132: gpu_vector_width = VECT_SIZE_4; break;
3567 case 133: gpu_vector_width = VECT_SIZE_4; break;
3568 case 140: gpu_vector_width = VECT_SIZE_4; break;
3569 case 141: gpu_vector_width = VECT_SIZE_4; break;
3570 case 150: gpu_vector_width = VECT_SIZE_4; break;
3571 case 160: gpu_vector_width = VECT_SIZE_4; break;
3572 case 190: gpu_vector_width = VECT_SIZE_4; break;
3573 case 200: gpu_vector_width = VECT_SIZE_4; break;
3574 case 400: gpu_vector_width = VECT_SIZE_2; break;
3575 case 500: gpu_vector_width = VECT_SIZE_2; break;
3576 case 501: gpu_vector_width = VECT_SIZE_2; break;
3577 case 900: gpu_vector_width = VECT_SIZE_4; break;
3578 case 1000: gpu_vector_width = VECT_SIZE_4; break;
3579 case 1100: gpu_vector_width = VECT_SIZE_4; break;
3580 case 2400: gpu_vector_width = VECT_SIZE_4; break;
3581 case 2410: gpu_vector_width = VECT_SIZE_4; break;
3582 case 2600: gpu_vector_width = VECT_SIZE_4; break;
3583 case 2611: gpu_vector_width = VECT_SIZE_4; break;
3584 case 2612: gpu_vector_width = VECT_SIZE_4; break;
3585 case 2711: gpu_vector_width = VECT_SIZE_4; break;
3586 case 2811: gpu_vector_width = VECT_SIZE_4; break;
3587 case 3710: gpu_vector_width = VECT_SIZE_4; break;
3588 case 3800: gpu_vector_width = VECT_SIZE_4; break;
3589 case 3711: gpu_vector_width = VECT_SIZE_4; break;
3590 case 4300: gpu_vector_width = VECT_SIZE_4; break;
3591 case 4800: gpu_vector_width = VECT_SIZE_4; break;
3592 case 4900: gpu_vector_width = VECT_SIZE_4; break;
3593 case 5100: gpu_vector_width = VECT_SIZE_4; break;
3594 case 9900: gpu_vector_width = VECT_SIZE_4; break;
3595 case 10200: gpu_vector_width = VECT_SIZE_4; break;
3596 case 11000: gpu_vector_width = VECT_SIZE_4; break;
3597 case 11500: gpu_vector_width = VECT_SIZE_4; break;
3598
3599 default: gpu_vector_width = VECT_SIZE_1; break;
3600 }
3601 }
3602 #endif
3603
3604 #ifdef _OCL
3605 if (vliw == 1)
3606 {
3607 switch (hash_mode)
3608 {
3609 default: gpu_vector_width = VECT_SIZE_1; break;
3610 }
3611 }
3612 else if (vliw == 4)
3613 {
3614 switch (hash_mode)
3615 {
3616 case 150: gpu_vector_width = VECT_SIZE_2; break;
3617 case 160: gpu_vector_width = VECT_SIZE_2; break;
3618 case 300: gpu_vector_width = VECT_SIZE_2; break;
3619 case 1400: gpu_vector_width = VECT_SIZE_2; break;
3620 case 1410: gpu_vector_width = VECT_SIZE_2; break;
3621 case 1420: gpu_vector_width = VECT_SIZE_2; break;
3622 case 1421: gpu_vector_width = VECT_SIZE_2; break;
3623 case 1430: gpu_vector_width = VECT_SIZE_2; break;
3624 case 1440: gpu_vector_width = VECT_SIZE_2; break;
3625 case 1441: gpu_vector_width = VECT_SIZE_2; break;
3626 case 1450: gpu_vector_width = VECT_SIZE_1; break;
3627 case 1460: gpu_vector_width = VECT_SIZE_2; break;
3628 case 1500: gpu_vector_width = VECT_SIZE_1; break;
3629 case 1700: gpu_vector_width = VECT_SIZE_1; break;
3630 case 1710: gpu_vector_width = VECT_SIZE_1; break;
3631 case 1711: gpu_vector_width = VECT_SIZE_1; break;
3632 case 1720: gpu_vector_width = VECT_SIZE_1; break;
3633 case 1722: gpu_vector_width = VECT_SIZE_1; break;
3634 case 1730: gpu_vector_width = VECT_SIZE_1; break;
3635 case 1731: gpu_vector_width = VECT_SIZE_1; break;
3636 case 1740: gpu_vector_width = VECT_SIZE_1; break;
3637 case 1750: gpu_vector_width = VECT_SIZE_1; break;
3638 case 1760: gpu_vector_width = VECT_SIZE_1; break;
3639 case 1800: gpu_vector_width = VECT_SIZE_1; break;
3640 case 2100: gpu_vector_width = VECT_SIZE_2; break;
3641 case 2500: gpu_vector_width = VECT_SIZE_2; break;
3642 case 3000: gpu_vector_width = VECT_SIZE_1; break;
3643 case 3100: gpu_vector_width = VECT_SIZE_2; break;
3644 case 3200: gpu_vector_width = VECT_SIZE_1; break;
3645 case 5000: gpu_vector_width = VECT_SIZE_1; break;
3646 case 5200: gpu_vector_width = VECT_SIZE_2; break;
3647 case 5600: gpu_vector_width = VECT_SIZE_2; break;
3648 case 5700: gpu_vector_width = VECT_SIZE_2; break;
3649 case 6100: gpu_vector_width = VECT_SIZE_2; break;
3650 case 6211:
3651 case 6212:
3652 case 6213:
3653 case 6221:
3654 case 6222:
3655 case 6223:
3656 case 6231:
3657 case 6232:
3658 case 6233:
3659 case 6241:
3660 case 6242:
3661 case 6243: gpu_vector_width = VECT_SIZE_1; break;
3662 case 6400: gpu_vector_width = VECT_SIZE_1; break;
3663 case 6500: gpu_vector_width = VECT_SIZE_1; break;
3664 case 6600: gpu_vector_width = VECT_SIZE_1; break;
3665 case 6700: gpu_vector_width = VECT_SIZE_2; break;
3666 case 6800: gpu_vector_width = VECT_SIZE_1; break;
3667 case 6900: gpu_vector_width = VECT_SIZE_1; break;
3668 case 7100: gpu_vector_width = VECT_SIZE_1; break;
3669 case 7200: gpu_vector_width = VECT_SIZE_1; break;
3670 case 7300: gpu_vector_width = VECT_SIZE_1; break;
3671 case 7400: gpu_vector_width = VECT_SIZE_1; break;
3672 case 7500: gpu_vector_width = VECT_SIZE_1; break;
3673 case 7700: gpu_vector_width = VECT_SIZE_1; break;
3674 case 7800: gpu_vector_width = VECT_SIZE_1; break;
3675 case 7900: gpu_vector_width = VECT_SIZE_1; break;
3676 case 8000: gpu_vector_width = VECT_SIZE_2; break;
3677 case 8200: gpu_vector_width = VECT_SIZE_1; break;
3678 case 8500: gpu_vector_width = VECT_SIZE_2; break;
3679 case 8700: gpu_vector_width = VECT_SIZE_2; break;
3680 case 8800: gpu_vector_width = VECT_SIZE_1; break;
3681 case 8900: gpu_vector_width = VECT_SIZE_1; break;
3682 case 9000: gpu_vector_width = VECT_SIZE_1; break;
3683 case 9100: gpu_vector_width = VECT_SIZE_1; break;
3684 case 9200: gpu_vector_width = VECT_SIZE_1; break;
3685 case 9300: gpu_vector_width = VECT_SIZE_1; break;
3686 case 9400: gpu_vector_width = VECT_SIZE_1; break;
3687 case 9500: gpu_vector_width = VECT_SIZE_1; break;
3688 case 9600: gpu_vector_width = VECT_SIZE_1; break;
3689 case 9700: gpu_vector_width = VECT_SIZE_1; break;
3690 case 9710: gpu_vector_width = VECT_SIZE_1; break;
3691 case 9720: gpu_vector_width = VECT_SIZE_2; break;
3692 case 9800: gpu_vector_width = VECT_SIZE_1; break;
3693 case 9810: gpu_vector_width = VECT_SIZE_1; break;
3694 case 9820: gpu_vector_width = VECT_SIZE_2; break;
3695 case 10000: gpu_vector_width = VECT_SIZE_1; break;
3696 case 10100: gpu_vector_width = VECT_SIZE_1; break;
3697 case 10400: gpu_vector_width = VECT_SIZE_1; break;
3698 case 10410: gpu_vector_width = VECT_SIZE_1; break;
3699 case 10420: gpu_vector_width = VECT_SIZE_2; break;
3700 case 10500: gpu_vector_width = VECT_SIZE_1; break;
3701 case 10600: gpu_vector_width = VECT_SIZE_2; break;
3702 case 10700: gpu_vector_width = VECT_SIZE_1; break;
3703 case 10800: gpu_vector_width = VECT_SIZE_1; break;
3704 case 10900: gpu_vector_width = VECT_SIZE_1; break;
3705 case 11100: gpu_vector_width = VECT_SIZE_2; break;
3706 case 11200: gpu_vector_width = VECT_SIZE_2; break;
3707 case 11300: gpu_vector_width = VECT_SIZE_1; break;
3708 case 11400: gpu_vector_width = VECT_SIZE_1; break;
3709 case 11600: gpu_vector_width = VECT_SIZE_1; break;
3710 case 11700: gpu_vector_width = VECT_SIZE_1; break;
3711 case 11800: gpu_vector_width = VECT_SIZE_1; break;
3712 case 11900: gpu_vector_width = VECT_SIZE_1; break;
3713 case 12000: gpu_vector_width = VECT_SIZE_1; break;
3714 case 12100: gpu_vector_width = VECT_SIZE_1; break;
3715 case 12200: gpu_vector_width = VECT_SIZE_1; break;
3716 case 12300: gpu_vector_width = VECT_SIZE_1; break;
3717 case 12500: gpu_vector_width = VECT_SIZE_1; break;
3718 case 12700: gpu_vector_width = VECT_SIZE_1; break;
3719 case 12800: gpu_vector_width = VECT_SIZE_1; break;
3720
3721 default: gpu_vector_width = VECT_SIZE_4; break;
3722 }
3723 }
3724 else if (vliw == 5)
3725 {
3726 switch (hash_mode)
3727 {
3728 case 150: gpu_vector_width = VECT_SIZE_2; break;
3729 case 160: gpu_vector_width = VECT_SIZE_2; break;
3730 case 300: gpu_vector_width = VECT_SIZE_2; break;
3731 case 1400: gpu_vector_width = VECT_SIZE_2; break;
3732 case 1410: gpu_vector_width = VECT_SIZE_2; break;
3733 case 1420: gpu_vector_width = VECT_SIZE_2; break;
3734 case 1421: gpu_vector_width = VECT_SIZE_2; break;
3735 case 1430: gpu_vector_width = VECT_SIZE_2; break;
3736 case 1440: gpu_vector_width = VECT_SIZE_2; break;
3737 case 1441: gpu_vector_width = VECT_SIZE_2; break;
3738 case 1450: gpu_vector_width = VECT_SIZE_1; break;
3739 case 1460: gpu_vector_width = VECT_SIZE_2; break;
3740 case 1500: gpu_vector_width = VECT_SIZE_1; break;
3741 case 1700: gpu_vector_width = VECT_SIZE_1; break;
3742 case 1710: gpu_vector_width = VECT_SIZE_1; break;
3743 case 1711: gpu_vector_width = VECT_SIZE_1; break;
3744 case 1720: gpu_vector_width = VECT_SIZE_1; break;
3745 case 1722: gpu_vector_width = VECT_SIZE_1; break;
3746 case 1730: gpu_vector_width = VECT_SIZE_1; break;
3747 case 1731: gpu_vector_width = VECT_SIZE_1; break;
3748 case 1740: gpu_vector_width = VECT_SIZE_1; break;
3749 case 1750: gpu_vector_width = VECT_SIZE_1; break;
3750 case 1760: gpu_vector_width = VECT_SIZE_1; break;
3751 case 1800: gpu_vector_width = VECT_SIZE_1; break;
3752 case 2100: gpu_vector_width = VECT_SIZE_2; break;
3753 case 2500: gpu_vector_width = VECT_SIZE_2; break;
3754 case 3000: gpu_vector_width = VECT_SIZE_1; break;
3755 case 3100: gpu_vector_width = VECT_SIZE_2; break;
3756 case 3200: gpu_vector_width = VECT_SIZE_1; break;
3757 case 5000: gpu_vector_width = VECT_SIZE_1; break;
3758 case 5200: gpu_vector_width = VECT_SIZE_2; break;
3759 case 5400: gpu_vector_width = VECT_SIZE_2; break;
3760 case 5600: gpu_vector_width = VECT_SIZE_2; break;
3761 case 5700: gpu_vector_width = VECT_SIZE_2; break;
3762 case 6100: gpu_vector_width = VECT_SIZE_2; break;
3763 case 6211:
3764 case 6212:
3765 case 6213:
3766 case 6221:
3767 case 6222:
3768 case 6223:
3769 case 6231:
3770 case 6232:
3771 case 6233:
3772 case 6241:
3773 case 6242:
3774 case 6243: gpu_vector_width = VECT_SIZE_1; break;
3775 case 6400: gpu_vector_width = VECT_SIZE_1; break;
3776 case 6500: gpu_vector_width = VECT_SIZE_1; break;
3777 case 6600: gpu_vector_width = VECT_SIZE_1; break;
3778 case 6700: gpu_vector_width = VECT_SIZE_2; break;
3779 case 6800: gpu_vector_width = VECT_SIZE_1; break;
3780 case 6900: gpu_vector_width = VECT_SIZE_1; break;
3781 case 7100: gpu_vector_width = VECT_SIZE_1; break;
3782 case 7200: gpu_vector_width = VECT_SIZE_1; break;
3783 case 7300: gpu_vector_width = VECT_SIZE_1; break;
3784 case 7400: gpu_vector_width = VECT_SIZE_1; break;
3785 case 7500: gpu_vector_width = VECT_SIZE_1; break;
3786 case 7700: gpu_vector_width = VECT_SIZE_1; break;
3787 case 7800: gpu_vector_width = VECT_SIZE_1; break;
3788 case 7900: gpu_vector_width = VECT_SIZE_1; break;
3789 case 8000: gpu_vector_width = VECT_SIZE_2; break;
3790 case 8200: gpu_vector_width = VECT_SIZE_1; break;
3791 case 8300: gpu_vector_width = VECT_SIZE_2; break;
3792 case 8400: gpu_vector_width = VECT_SIZE_2; break;
3793 case 8500: gpu_vector_width = VECT_SIZE_2; break;
3794 case 8700: gpu_vector_width = VECT_SIZE_2; break;
3795 case 8800: gpu_vector_width = VECT_SIZE_1; break;
3796 case 8900: gpu_vector_width = VECT_SIZE_1; break;
3797 case 9000: gpu_vector_width = VECT_SIZE_1; break;
3798 case 9100: gpu_vector_width = VECT_SIZE_1; break;
3799 case 9200: gpu_vector_width = VECT_SIZE_1; break;
3800 case 9300: gpu_vector_width = VECT_SIZE_1; break;
3801 case 9400: gpu_vector_width = VECT_SIZE_1; break;
3802 case 9500: gpu_vector_width = VECT_SIZE_1; break;
3803 case 9600: gpu_vector_width = VECT_SIZE_1; break;
3804 case 9700: gpu_vector_width = VECT_SIZE_1; break;
3805 case 9710: gpu_vector_width = VECT_SIZE_1; break;
3806 case 9720: gpu_vector_width = VECT_SIZE_2; break;
3807 case 9800: gpu_vector_width = VECT_SIZE_1; break;
3808 case 9810: gpu_vector_width = VECT_SIZE_1; break;
3809 case 9820: gpu_vector_width = VECT_SIZE_2; break;
3810 case 10000: gpu_vector_width = VECT_SIZE_1; break;
3811 case 10100: gpu_vector_width = VECT_SIZE_1; break;
3812 case 10400: gpu_vector_width = VECT_SIZE_1; break;
3813 case 10410: gpu_vector_width = VECT_SIZE_1; break;
3814 case 10420: gpu_vector_width = VECT_SIZE_2; break;
3815 case 10500: gpu_vector_width = VECT_SIZE_1; break;
3816 case 10600: gpu_vector_width = VECT_SIZE_2; break;
3817 case 10700: gpu_vector_width = VECT_SIZE_1; break;
3818 case 10800: gpu_vector_width = VECT_SIZE_1; break;
3819 case 10900: gpu_vector_width = VECT_SIZE_1; break;
3820 case 11100: gpu_vector_width = VECT_SIZE_2; break;
3821 case 11200: gpu_vector_width = VECT_SIZE_2; break;
3822 case 11300: gpu_vector_width = VECT_SIZE_1; break;
3823 case 11400: gpu_vector_width = VECT_SIZE_1; break;
3824 case 11600: gpu_vector_width = VECT_SIZE_1; break;
3825 case 11700: gpu_vector_width = VECT_SIZE_1; break;
3826 case 11800: gpu_vector_width = VECT_SIZE_1; break;
3827 case 11900: gpu_vector_width = VECT_SIZE_1; break;
3828 case 12000: gpu_vector_width = VECT_SIZE_1; break;
3829 case 12100: gpu_vector_width = VECT_SIZE_1; break;
3830 case 12200: gpu_vector_width = VECT_SIZE_1; break;
3831 case 12300: gpu_vector_width = VECT_SIZE_1; break;
3832 case 12500: gpu_vector_width = VECT_SIZE_1; break;
3833 case 12700: gpu_vector_width = VECT_SIZE_1; break;
3834 case 12800: gpu_vector_width = VECT_SIZE_1; break;
3835
3836 default: gpu_vector_width = VECT_SIZE_4; break;
3837 }
3838 }
3839 #endif
3840
3841 return gpu_vector_width;
3842 }
3843
3844 static void pw_transpose_to_hi1 (const pw_t *p1, pw_t *p2)
3845 {
3846 memcpy (p2->hi1, p1->hi1, 64 * sizeof (uint));
3847 }
3848
3849 static void pw_transpose_to_hi2 (const pw_t *p1, pw_t *p2)
3850 {
3851 p2->hi2[0][ 0] = p1->hi2[0][ 0];
3852 p2->hi2[0][ 2] = p1->hi2[0][ 1];
3853 p2->hi2[0][ 4] = p1->hi2[0][ 2];
3854 p2->hi2[0][ 6] = p1->hi2[0][ 3];
3855 p2->hi2[0][ 8] = p1->hi2[0][ 4];
3856 p2->hi2[0][10] = p1->hi2[0][ 5];
3857 p2->hi2[0][12] = p1->hi2[0][ 6];
3858 p2->hi2[0][14] = p1->hi2[0][ 7];
3859 p2->hi2[0][16] = p1->hi2[0][ 8];
3860 p2->hi2[0][18] = p1->hi2[0][ 9];
3861 p2->hi2[0][20] = p1->hi2[0][10];
3862 p2->hi2[0][22] = p1->hi2[0][11];
3863 p2->hi2[0][24] = p1->hi2[0][12];
3864 p2->hi2[0][26] = p1->hi2[0][13];
3865 p2->hi2[0][28] = p1->hi2[0][14];
3866 p2->hi2[0][30] = p1->hi2[0][15];
3867 p2->hi2[1][ 0] = p1->hi2[0][16];
3868 p2->hi2[1][ 2] = p1->hi2[0][17];
3869 p2->hi2[1][ 4] = p1->hi2[0][18];
3870 p2->hi2[1][ 6] = p1->hi2[0][19];
3871 p2->hi2[1][ 8] = p1->hi2[0][20];
3872 p2->hi2[1][10] = p1->hi2[0][21];
3873 p2->hi2[1][12] = p1->hi2[0][22];
3874 p2->hi2[1][14] = p1->hi2[0][23];
3875 p2->hi2[1][16] = p1->hi2[0][24];
3876 p2->hi2[1][18] = p1->hi2[0][25];
3877 p2->hi2[1][20] = p1->hi2[0][26];
3878 p2->hi2[1][22] = p1->hi2[0][27];
3879 p2->hi2[1][24] = p1->hi2[0][28];
3880 p2->hi2[1][26] = p1->hi2[0][29];
3881 p2->hi2[1][28] = p1->hi2[0][30];
3882 p2->hi2[1][30] = p1->hi2[0][31];
3883
3884 p2->hi2[0][ 1] = p1->hi2[1][ 0];
3885 p2->hi2[0][ 3] = p1->hi2[1][ 1];
3886 p2->hi2[0][ 5] = p1->hi2[1][ 2];
3887 p2->hi2[0][ 7] = p1->hi2[1][ 3];
3888 p2->hi2[0][ 9] = p1->hi2[1][ 4];
3889 p2->hi2[0][11] = p1->hi2[1][ 5];
3890 p2->hi2[0][13] = p1->hi2[1][ 6];
3891 p2->hi2[0][15] = p1->hi2[1][ 7];
3892 p2->hi2[0][17] = p1->hi2[1][ 8];
3893 p2->hi2[0][19] = p1->hi2[1][ 9];
3894 p2->hi2[0][21] = p1->hi2[1][10];
3895 p2->hi2[0][23] = p1->hi2[1][11];
3896 p2->hi2[0][25] = p1->hi2[1][12];
3897 p2->hi2[0][27] = p1->hi2[1][13];
3898 p2->hi2[0][29] = p1->hi2[1][14];
3899 p2->hi2[0][31] = p1->hi2[1][15];
3900 p2->hi2[1][ 1] = p1->hi2[1][16];
3901 p2->hi2[1][ 3] = p1->hi2[1][17];
3902 p2->hi2[1][ 5] = p1->hi2[1][18];
3903 p2->hi2[1][ 7] = p1->hi2[1][19];
3904 p2->hi2[1][ 9] = p1->hi2[1][20];
3905 p2->hi2[1][11] = p1->hi2[1][21];
3906 p2->hi2[1][13] = p1->hi2[1][22];
3907 p2->hi2[1][15] = p1->hi2[1][23];
3908 p2->hi2[1][17] = p1->hi2[1][24];
3909 p2->hi2[1][19] = p1->hi2[1][25];
3910 p2->hi2[1][21] = p1->hi2[1][26];
3911 p2->hi2[1][23] = p1->hi2[1][27];
3912 p2->hi2[1][25] = p1->hi2[1][28];
3913 p2->hi2[1][27] = p1->hi2[1][29];
3914 p2->hi2[1][29] = p1->hi2[1][30];
3915 p2->hi2[1][31] = p1->hi2[1][31];
3916 }
3917
3918 static void pw_transpose_to_hi4 (const pw_t *p1, pw_t *p2)
3919 {
3920 p2->hi4[0][ 0] = p1->hi4[0][ 0];
3921 p2->hi4[0][ 4] = p1->hi4[0][ 1];
3922 p2->hi4[0][ 8] = p1->hi4[0][ 2];
3923 p2->hi4[0][12] = p1->hi4[0][ 3];
3924 p2->hi4[1][ 0] = p1->hi4[0][ 4];
3925 p2->hi4[1][ 4] = p1->hi4[0][ 5];
3926 p2->hi4[1][ 8] = p1->hi4[0][ 6];
3927 p2->hi4[1][12] = p1->hi4[0][ 7];
3928 p2->hi4[2][ 0] = p1->hi4[0][ 8];
3929 p2->hi4[2][ 4] = p1->hi4[0][ 9];
3930 p2->hi4[2][ 8] = p1->hi4[0][10];
3931 p2->hi4[2][12] = p1->hi4[0][11];
3932 p2->hi4[3][ 0] = p1->hi4[0][12];
3933 p2->hi4[3][ 4] = p1->hi4[0][13];
3934 p2->hi4[3][ 8] = p1->hi4[0][14];
3935 p2->hi4[3][12] = p1->hi4[0][15];
3936
3937 p2->hi4[0][ 1] = p1->hi4[1][ 0];
3938 p2->hi4[0][ 5] = p1->hi4[1][ 1];
3939 p2->hi4[0][ 9] = p1->hi4[1][ 2];
3940 p2->hi4[0][13] = p1->hi4[1][ 3];
3941 p2->hi4[1][ 1] = p1->hi4[1][ 4];
3942 p2->hi4[1][ 5] = p1->hi4[1][ 5];
3943 p2->hi4[1][ 9] = p1->hi4[1][ 6];
3944 p2->hi4[1][13] = p1->hi4[1][ 7];
3945 p2->hi4[2][ 1] = p1->hi4[1][ 8];
3946 p2->hi4[2][ 5] = p1->hi4[1][ 9];
3947 p2->hi4[2][ 9] = p1->hi4[1][10];
3948 p2->hi4[2][13] = p1->hi4[1][11];
3949 p2->hi4[3][ 1] = p1->hi4[1][12];
3950 p2->hi4[3][ 5] = p1->hi4[1][13];
3951 p2->hi4[3][ 9] = p1->hi4[1][14];
3952 p2->hi4[3][13] = p1->hi4[1][15];
3953
3954 p2->hi4[0][ 2] = p1->hi4[2][ 0];
3955 p2->hi4[0][ 6] = p1->hi4[2][ 1];
3956 p2->hi4[0][10] = p1->hi4[2][ 2];
3957 p2->hi4[0][14] = p1->hi4[2][ 3];
3958 p2->hi4[1][ 2] = p1->hi4[2][ 4];
3959 p2->hi4[1][ 6] = p1->hi4[2][ 5];
3960 p2->hi4[1][10] = p1->hi4[2][ 6];
3961 p2->hi4[1][14] = p1->hi4[2][ 7];
3962 p2->hi4[2][ 2] = p1->hi4[2][ 8];
3963 p2->hi4[2][ 6] = p1->hi4[2][ 9];
3964 p2->hi4[2][10] = p1->hi4[2][10];
3965 p2->hi4[2][14] = p1->hi4[2][11];
3966 p2->hi4[3][ 2] = p1->hi4[2][12];
3967 p2->hi4[3][ 6] = p1->hi4[2][13];
3968 p2->hi4[3][10] = p1->hi4[2][14];
3969 p2->hi4[3][14] = p1->hi4[2][15];
3970
3971 p2->hi4[0][ 3] = p1->hi4[3][ 0];
3972 p2->hi4[0][ 7] = p1->hi4[3][ 1];
3973 p2->hi4[0][11] = p1->hi4[3][ 2];
3974 p2->hi4[0][15] = p1->hi4[3][ 3];
3975 p2->hi4[1][ 3] = p1->hi4[3][ 4];
3976 p2->hi4[1][ 7] = p1->hi4[3][ 5];
3977 p2->hi4[1][11] = p1->hi4[3][ 6];
3978 p2->hi4[1][15] = p1->hi4[3][ 7];
3979 p2->hi4[2][ 3] = p1->hi4[3][ 8];
3980 p2->hi4[2][ 7] = p1->hi4[3][ 9];
3981 p2->hi4[2][11] = p1->hi4[3][10];
3982 p2->hi4[2][15] = p1->hi4[3][11];
3983 p2->hi4[3][ 3] = p1->hi4[3][12];
3984 p2->hi4[3][ 7] = p1->hi4[3][13];
3985 p2->hi4[3][11] = p1->hi4[3][14];
3986 p2->hi4[3][15] = p1->hi4[3][15];
3987 }
3988
3989 static uint pw_add_to_hc1 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
3990 {
3991 if (data.devices_status == STATUS_BYPASS) return 0;
3992
3993 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
3994
3995 uint cache_cnt = pw_cache->cnt;
3996
3997 uint8_t *pw_hc1 = pw_cache->pw_buf.hc1[cache_cnt];
3998
3999 memcpy (pw_hc1, pw_buf, pw_len);
4000
4001 memset (pw_hc1 + pw_len, 0, 256 - pw_len);
4002
4003 uint pws_cnt = device_param->pws_cnt;
4004
4005 cache_cnt++;
4006
4007 if (cache_cnt == VECT_SIZE_1)
4008 {
4009 pw_t *pw = device_param->pws_buf + pws_cnt;
4010
4011 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4012
4013 pw->pw_len = pw_len;
4014
4015 pws_cnt++;
4016
4017 device_param->pws_cnt = pws_cnt;
4018 device_param->pw_cnt = pws_cnt * 1;
4019
4020 cache_cnt = 0;
4021 }
4022
4023 pw_cache->cnt = cache_cnt;
4024
4025 return pws_cnt;
4026 }
4027
4028 static uint pw_add_to_hc2 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
4029 {
4030 if (data.devices_status == STATUS_BYPASS) return 0;
4031
4032 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
4033
4034 uint cache_cnt = pw_cache->cnt;
4035
4036 uint8_t *pw_hc2 = pw_cache->pw_buf.hc2[cache_cnt];
4037
4038 memcpy (pw_hc2, pw_buf, pw_len);
4039
4040 memset (pw_hc2 + pw_len, 0, 128 - pw_len);
4041
4042 uint pws_cnt = device_param->pws_cnt;
4043
4044 cache_cnt++;
4045
4046 if (cache_cnt == VECT_SIZE_2)
4047 {
4048 pw_t *pw = device_param->pws_buf + pws_cnt;
4049
4050 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4051
4052 pw->pw_len = pw_len;
4053
4054 pws_cnt++;
4055
4056 device_param->pws_cnt = pws_cnt;
4057 device_param->pw_cnt = pws_cnt * 2;
4058
4059 cache_cnt = 0;
4060 }
4061
4062 pw_cache->cnt = cache_cnt;
4063
4064 return pws_cnt;
4065 }
4066
4067 static uint pw_add_to_hc4 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
4068 {
4069 if (data.devices_status == STATUS_BYPASS) return 0;
4070
4071 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
4072
4073 uint cache_cnt = pw_cache->cnt;
4074
4075 uint8_t *pw_hc4 = pw_cache->pw_buf.hc4[cache_cnt];
4076
4077 memcpy (pw_hc4, pw_buf, pw_len);
4078
4079 memset (pw_hc4 + pw_len, 0, 64 - pw_len);
4080
4081 uint pws_cnt = device_param->pws_cnt;
4082
4083 cache_cnt++;
4084
4085 if (cache_cnt == VECT_SIZE_4)
4086 {
4087 pw_t *pw = device_param->pws_buf + pws_cnt;
4088
4089 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4090
4091 pw->pw_len = pw_len;
4092
4093 pws_cnt++;
4094
4095 device_param->pws_cnt = pws_cnt;
4096 device_param->pw_cnt = pws_cnt * 4;
4097
4098 cache_cnt = 0;
4099 }
4100
4101 pw_cache->cnt = cache_cnt;
4102
4103 return pws_cnt;
4104 }
4105
4106 static void *thread_monitor (void *p)
4107 {
4108 uint runtime_check = 0;
4109 uint remove_check = 0;
4110 uint status_check = 0;
4111 uint hwmon_check = 0;
4112 uint restore_check = 0;
4113
4114 uint restore_left = data.restore_timer;
4115 uint remove_left = data.remove_timer;
4116 uint status_left = data.status_timer;
4117
4118 #ifdef _OCL
4119 #ifndef OSX
4120
4121 int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
4122
4123 // temperature controller "loopback" values
4124
4125 int *temp_diff_old = (int *) mycalloc (data.devices_cnt, sizeof (int));
4126 int *temp_diff_sum = (int *) mycalloc (data.devices_cnt, sizeof (int));
4127
4128 int temp_threshold = 1; // degrees celcius
4129
4130 int fan_speed_min = 15; // in percentage
4131 int fan_speed_max = 100;
4132
4133 time_t last_temp_check_time;
4134
4135 #endif
4136 #endif
4137
4138 uint sleep_time = 1;
4139
4140 if (data.runtime)
4141 runtime_check = 1;
4142
4143 if (data.restore_timer)
4144 restore_check = 1;
4145
4146 if ((data.remove == 1) && (data.hashlist_mode == HL_MODE_FILE))
4147 remove_check = 1;
4148
4149 if (data.status == 1)
4150 status_check = 1;
4151
4152 if (data.gpu_temp_disable == 0)
4153 {
4154 #ifdef _OCL
4155 #ifndef OSX
4156 time (&last_temp_check_time);
4157 #endif
4158 #endif
4159
4160 hwmon_check = 1;
4161 }
4162
4163 if ((runtime_check == 0) && (remove_check == 0) && (status_check == 0) && (hwmon_check == 0) && (restore_check == 0))
4164 {
4165 return (p);
4166 }
4167
4168 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4169 {
4170 hc_sleep (sleep_time);
4171
4172 if (data.devices_status != STATUS_RUNNING) continue;
4173
4174 if (hwmon_check == 1)
4175 {
4176 hc_thread_mutex_lock (mux_adl);
4177
4178 #ifdef _OCL
4179 #ifndef OSX
4180
4181 time_t temp_check_time;
4182
4183 time (&temp_check_time);
4184
4185 uint Ta = temp_check_time - last_temp_check_time; // set Ta = sleep_time; is not good enough (see --remove etc)
4186
4187 if (Ta == 0) Ta = 1;
4188
4189 #endif
4190 #endif
4191
4192 for (uint i = 0; i < data.devices_cnt; i++)
4193 {
4194 const int temperature = hm_get_temperature_with_device_id (i);
4195
4196 if (temperature > (int) data.gpu_temp_abort)
4197 {
4198 log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", i + 1);
4199
4200 if (data.devices_status != STATUS_QUIT) myabort ();
4201
4202 break;
4203 }
4204
4205 #ifdef _OCL
4206 #ifndef OSX
4207
4208 const int gpu_temp_retain = data.gpu_temp_retain;
4209
4210 if (gpu_temp_retain)
4211 {
4212 if (data.hm_device[i].fan_supported == 1)
4213 {
4214 int temp_cur = temperature;
4215
4216 int temp_diff_new = gpu_temp_retain - temp_cur;
4217
4218 temp_diff_sum[i] = temp_diff_sum[i] + temp_diff_new;
4219
4220 // calculate Ta value (time difference in seconds between the last check and this check)
4221
4222 last_temp_check_time = temp_check_time;
4223
4224 float Kp = 1.8;
4225 float Ki = 0.005;
4226 float Kd = 6;
4227
4228 // PID controller (3-term controller: proportional - Kp, integral - Ki, derivative - Kd)
4229
4230 int fan_diff_required = (int) (Kp * (float)temp_diff_new + Ki * Ta * (float)temp_diff_sum[i] + Kd * ((float)(temp_diff_new - temp_diff_old[i])) / Ta);
4231
4232 if (abs (fan_diff_required) >= temp_threshold)
4233 {
4234 const int fan_speed_cur = hm_get_fanspeed_with_device_id (i);
4235
4236 int fan_speed_level = fan_speed_cur;
4237
4238 if (fan_speed_chgd[i] == 0) fan_speed_level = temp_cur;
4239
4240 int fan_speed_new = fan_speed_level - fan_diff_required;
4241
4242 if (fan_speed_new > fan_speed_max) fan_speed_new = fan_speed_max;
4243 if (fan_speed_new < fan_speed_min) fan_speed_new = fan_speed_min;
4244
4245 if (fan_speed_new != fan_speed_cur)
4246 {
4247 int freely_change_fan_speed = (fan_speed_chgd[i] == 1);
4248 int fan_speed_must_change = (fan_speed_new > fan_speed_cur);
4249
4250 if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1))
4251 {
4252 hm_set_fanspeed_with_device_id (i, fan_speed_new);
4253
4254 fan_speed_chgd[i] = 1;
4255 }
4256
4257 temp_diff_old[i] = temp_diff_new;
4258 }
4259 }
4260 }
4261 }
4262
4263 #endif
4264 #endif
4265 }
4266
4267 hc_thread_mutex_unlock (mux_adl);
4268 }
4269
4270 if (restore_check == 1)
4271 {
4272 restore_left--;
4273
4274 if (restore_left == 0)
4275 {
4276 if (data.restore_disable == 0) cycle_restore ();
4277
4278 restore_left = data.restore_timer;
4279 }
4280 }
4281
4282 if ((runtime_check == 1) && (data.runtime_start > 0))
4283 {
4284 time_t runtime_cur;
4285
4286 time (&runtime_cur);
4287
4288 int runtime_left = data.runtime_start + data.runtime - runtime_cur;
4289
4290 if (runtime_left <= 0)
4291 {
4292 if (data.benchmark == 0)
4293 {
4294 if (data.quiet == 0) log_info ("\nNOTE: Runtime limit reached, aborting...\n");
4295 }
4296
4297 if (data.devices_status != STATUS_QUIT) myabort ();
4298 }
4299 }
4300
4301 if (remove_check == 1)
4302 {
4303 remove_left--;
4304
4305 if (remove_left == 0)
4306 {
4307 if (data.digests_saved != data.digests_done)
4308 {
4309 data.digests_saved = data.digests_done;
4310
4311 save_hash ();
4312 }
4313
4314 remove_left = data.remove_timer;
4315 }
4316 }
4317
4318 if (status_check == 1)
4319 {
4320 status_left--;
4321
4322 if (status_left == 0)
4323 {
4324 hc_thread_mutex_lock (mux_display);
4325
4326 if (data.quiet == 0) clear_prompt ();
4327
4328 if (data.quiet == 0) log_info ("");
4329
4330 status_display ();
4331
4332 if (data.quiet == 0) log_info ("");
4333
4334 hc_thread_mutex_unlock (mux_display);
4335
4336 status_left = data.status_timer;
4337 }
4338 }
4339 }
4340
4341 #ifdef _OCL
4342 #ifndef OSX
4343 myfree (fan_speed_chgd);
4344
4345 myfree (temp_diff_old);
4346 myfree (temp_diff_sum);
4347 #endif
4348 #endif
4349
4350 p = NULL;
4351
4352 return (p);
4353 }
4354
4355 static void *thread_outfile_remove (void *p)
4356 {
4357 // some hash-dependent constants
4358 char *outfile_dir = data.outfile_check_directory;
4359 uint dgst_size = data.dgst_size;
4360 uint isSalted = data.isSalted;
4361 uint esalt_size = data.esalt_size;
4362 uint hash_mode = data.hash_mode;
4363
4364 uint outfile_check_timer = data.outfile_check_timer;
4365
4366 char separator = data.separator;
4367
4368 // some hash-dependent functions
4369 int (*sort_by_digest) (const void *, const void *) = data.sort_by_digest;
4370 int (*parse_func) (char *, uint, hash_t *) = data.parse_func;
4371
4372 // buffers
4373 hash_t hash_buf;
4374
4375 memset (&hash_buf, 0, sizeof (hash_buf));
4376
4377 hash_buf.digest = mymalloc (dgst_size);
4378
4379 if (isSalted) hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
4380
4381 if (esalt_size) hash_buf.esalt = (void *) mymalloc (esalt_size);
4382
4383 uint digest_buf[64];
4384
4385 outfile_data_t *out_info = NULL;
4386
4387 char **out_files = NULL;
4388
4389 time_t folder_mtime = 0;
4390
4391 int out_cnt = 0;
4392
4393 uint check_left = outfile_check_timer; // or 1 if we want to check it at startup
4394
4395 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4396 {
4397 hc_sleep (1);
4398
4399 if (data.devices_status != STATUS_RUNNING) continue;
4400
4401 check_left--;
4402
4403 if (check_left == 0)
4404 {
4405 struct stat outfile_check_stat;
4406
4407 if (stat (outfile_dir, &outfile_check_stat) == 0)
4408 {
4409 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
4410
4411 if (is_dir == 1)
4412 {
4413 if (outfile_check_stat.st_mtime > folder_mtime)
4414 {
4415 char **out_files_new = scan_directory (outfile_dir);
4416
4417 int out_cnt_new = count_dictionaries (out_files_new);
4418
4419 outfile_data_t *out_info_new = NULL;
4420
4421 if (out_cnt_new > 0)
4422 {
4423 out_info_new = (outfile_data_t *) mycalloc (out_cnt_new, sizeof (outfile_data_t));
4424
4425 for (int i = 0; i < out_cnt_new; i++)
4426 {
4427 out_info_new[i].file_name = out_files_new[i];
4428
4429 // check if there are files that we have seen/checked before (and not changed)
4430
4431 for (int j = 0; j < out_cnt; j++)
4432 {
4433 if (strcmp (out_info[j].file_name, out_info_new[i].file_name) == 0)
4434 {
4435 struct stat outfile_stat;
4436
4437 if (stat (out_info_new[i].file_name, &outfile_stat) == 0)
4438 {
4439 if (outfile_stat.st_ctime == out_info[j].ctime)
4440 {
4441 out_info_new[i].ctime = out_info[j].ctime;
4442 out_info_new[i].seek = out_info[j].seek;
4443 }
4444 }
4445 }
4446 }
4447 }
4448 }
4449
4450 local_free (out_info);
4451 local_free (out_files);
4452
4453 out_files = out_files_new;
4454 out_cnt = out_cnt_new;
4455 out_info = out_info_new;
4456
4457 folder_mtime = outfile_check_stat.st_mtime;
4458 }
4459
4460 for (int j = 0; j < out_cnt; j++)
4461 {
4462 FILE *fp = fopen (out_info[j].file_name, "rb");
4463
4464 if (fp != NULL)
4465 {
4466 //hc_thread_mutex_lock (mux_display);
4467
4468 #ifdef _POSIX
4469 struct stat outfile_stat;
4470
4471 fstat (fileno (fp), &outfile_stat);
4472 #endif
4473
4474 #ifdef _WIN
4475 struct stat64 outfile_stat;
4476
4477 _fstat64 (fileno (fp), &outfile_stat);
4478 #endif
4479
4480 if (outfile_stat.st_ctime > out_info[j].ctime)
4481 {
4482 out_info[j].ctime = outfile_stat.st_ctime;
4483 out_info[j].seek = 0;
4484 }
4485
4486 fseek (fp, out_info[j].seek, SEEK_SET);
4487
4488 while (!feof (fp))
4489 {
4490 char line_buf[BUFSIZ];
4491
4492 memset (line_buf, 0, BUFSIZ);
4493
4494 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
4495
4496 if (ptr == NULL) break;
4497
4498 int line_len = strlen (line_buf);
4499
4500 if (line_len <= 0) continue;
4501
4502 int iter = MAX_CUT_TRIES;
4503
4504 for (uint i = line_len - 1; i && iter; i--, line_len--)
4505 {
4506 if (line_buf[i] != separator) continue;
4507
4508 int parser_status = PARSER_OK;
4509
4510 if ((hash_mode != 2500) && (hash_mode != 6800))
4511 {
4512 parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
4513 }
4514
4515 uint found = 0;
4516
4517 if (parser_status == PARSER_OK)
4518 {
4519 for (uint salt_pos = 0; (found == 0) && (salt_pos < data.salts_cnt); salt_pos++)
4520 {
4521 if (data.salts_shown[salt_pos] == 1) continue;
4522
4523 salt_t *salt_buf = &data.salts_buf[salt_pos];
4524
4525 for (uint digest_pos = 0; (found == 0) && (digest_pos < salt_buf->digests_cnt); digest_pos++)
4526 {
4527 uint idx = salt_buf->digests_offset + digest_pos;
4528
4529 if (data.digests_shown[idx] == 1) continue;
4530
4531 uint cracked = 0;
4532
4533 if (hash_mode == 6800)
4534 {
4535 if (i == salt_buf->salt_len)
4536 {
4537 cracked = (memcmp (line_buf, salt_buf->salt_buf, salt_buf->salt_len) == 0);
4538 }
4539 }
4540 else if (hash_mode == 2500)
4541 {
4542 // BSSID : MAC1 : MAC2 (:plain)
4543 if (i == (salt_buf->salt_len + 1 + 12 + 1 + 12))
4544 {
4545 cracked = (memcmp (line_buf, salt_buf->salt_buf, salt_buf->salt_len) == 0);
4546
4547 if (!cracked) continue;
4548
4549 // now compare MAC1 and MAC2 too, since we have this additional info
4550 char *mac1_pos = line_buf + salt_buf->salt_len + 1;
4551 char *mac2_pos = mac1_pos + 12 + 1;
4552
4553 wpa_t *wpas = (wpa_t *) data.esalts_buf;
4554 wpa_t *wpa = &wpas[salt_pos];
4555
4556 uint pke[25];
4557
4558 char *pke_ptr = (char *) pke;
4559
4560 for (uint i = 0; i < 25; i++)
4561 {
4562 pke[i] = byte_swap_32 (wpa->pke[i]);
4563 }
4564
4565 unsigned char mac1[6];
4566 unsigned char mac2[6];
4567
4568 memcpy (mac1, pke_ptr + 23, 6);
4569 memcpy (mac2, pke_ptr + 29, 6);
4570
4571 // compare hex string(s) vs binary MAC address(es)
4572
4573 for (uint i = 0, j = 0; i < 6; i++, j += 2)
4574 {
4575 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
4576 {
4577 cracked = 0;
4578 break;
4579 }
4580 }
4581
4582 // early skip ;)
4583 if (!cracked) continue;
4584
4585 for (uint i = 0, j = 0; i < 6; i++, j += 2)
4586 {
4587 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
4588 {
4589 cracked = 0;
4590 break;
4591 }
4592 }
4593 }
4594 }
4595 else
4596 {
4597 char *digests_buf_ptr = (char *) data.digests_buf;
4598
4599 memcpy (digest_buf, digests_buf_ptr + (data.salts_buf[salt_pos].digests_offset * dgst_size) + (digest_pos * dgst_size), dgst_size);
4600
4601 cracked = (sort_by_digest (digest_buf, hash_buf.digest) == 0);
4602 }
4603
4604 if (cracked == 1)
4605 {
4606 found = 1;
4607
4608 data.digests_shown[idx] = 1;
4609
4610 data.digests_done++;
4611
4612 salt_buf->digests_done++;
4613
4614 if (salt_buf->digests_done == salt_buf->digests_cnt)
4615 {
4616 data.salts_shown[salt_pos] = 1;
4617
4618 data.salts_done++;
4619
4620 if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
4621 }
4622 }
4623 }
4624
4625 if (data.devices_status == STATUS_CRACKED) break;
4626 }
4627 }
4628
4629 if (found) break;
4630
4631 if (data.devices_status == STATUS_CRACKED) break;
4632
4633 iter--;
4634 }
4635
4636 if (data.devices_status == STATUS_CRACKED) break;
4637 }
4638
4639 out_info[j].seek = ftell (fp);
4640
4641 //hc_thread_mutex_unlock (mux_display);
4642
4643 fclose (fp);
4644 }
4645 }
4646 }
4647 }
4648
4649 check_left = outfile_check_timer;
4650 }
4651 }
4652
4653 if (esalt_size) local_free (hash_buf.esalt);
4654
4655 if (isSalted) local_free (hash_buf.salt);
4656
4657 local_free (hash_buf.digest);
4658
4659 local_free (out_info);
4660
4661 local_free (out_files);
4662
4663 p = NULL;
4664
4665 return (p);
4666 }
4667
4668 static uint get_work (hc_device_param_t *device_param, const uint64_t max)
4669 {
4670 hc_thread_mutex_lock (mux_dispatcher);
4671
4672 const uint64_t words_cur = data.words_cur;
4673 const uint64_t words_base = (data.limit == 0) ? data.words_base : data.limit;
4674
4675 device_param->words_off = words_cur;
4676
4677 const uint64_t words_left = words_base - words_cur;
4678
4679 if (data.gpu_blocks_all > words_left)
4680 {
4681 if (data.gpu_blocks_div == 0)
4682 {
4683 data.gpu_blocks_div = find_gpu_blocks_div (words_left, data.gpu_blocks_all);
4684 }
4685 }
4686
4687 if (data.gpu_blocks_div)
4688 {
4689 if (device_param->gpu_blocks == device_param->gpu_blocks_user)
4690 {
4691 const uint32_t gpu_blocks_new = (float) device_param->gpu_blocks * data.gpu_blocks_div;
4692 const uint32_t gpu_power_new = gpu_blocks_new / device_param->gpu_vector_width;
4693
4694 if (gpu_blocks_new < device_param->gpu_blocks)
4695 {
4696 device_param->gpu_blocks = gpu_blocks_new;
4697 device_param->gpu_power = gpu_power_new;
4698 }
4699 }
4700 }
4701
4702 const uint gpu_blocks = device_param->gpu_blocks;
4703
4704 uint work = MIN (words_left, gpu_blocks);
4705
4706 work = MIN (work, max);
4707
4708 data.words_cur += work;
4709
4710 hc_thread_mutex_unlock (mux_dispatcher);
4711
4712 return work;
4713 }
4714
4715 static void *thread_calc_stdin (void *p)
4716 {
4717 hc_device_param_t *device_param = (hc_device_param_t *) p;
4718
4719 const uint attack_kern = data.attack_kern;
4720
4721 const uint gpu_blocks = device_param->gpu_blocks;
4722
4723 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4724 {
4725 hc_thread_mutex_lock (mux_dispatcher);
4726
4727 if (feof (stdin) != 0)
4728 {
4729 hc_thread_mutex_unlock (mux_dispatcher);
4730
4731 break;
4732 }
4733
4734 uint words_cur = 0;
4735
4736 while (words_cur < gpu_blocks)
4737 {
4738 char buf[BUFSIZ];
4739
4740 char *line_buf = fgets (buf, sizeof (buf), stdin);
4741
4742 if (line_buf == NULL) break;
4743
4744 uint line_len = in_superchop (line_buf);
4745
4746 line_len = convert_from_hex (line_buf, line_len);
4747
4748 // post-process rule engine
4749
4750 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
4751 {
4752 char rule_buf_out[BLOCK_SIZE];
4753
4754 memset (rule_buf_out, 0, sizeof (rule_buf_out));
4755
4756 int rule_len_out = -1;
4757
4758 if (line_len < BLOCK_SIZE)
4759 {
4760 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, line_buf, line_len, rule_buf_out);
4761 }
4762
4763 if (rule_len_out < 0) continue;
4764
4765 line_buf = rule_buf_out;
4766 line_len = rule_len_out;
4767 }
4768
4769 if (line_len > PW_MAX)
4770 {
4771 continue;
4772 }
4773
4774 if (attack_kern == ATTACK_KERN_STRAIGHT)
4775 {
4776 if ((line_len < data.pw_min) || (line_len > data.pw_max))
4777 {
4778 hc_thread_mutex_lock (mux_counter);
4779
4780 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4781 {
4782 data.words_progress_rejected[salt_pos] += data.gpu_rules_cnt;
4783 }
4784
4785 hc_thread_mutex_unlock (mux_counter);
4786
4787 continue;
4788 }
4789 }
4790 else if (attack_kern == ATTACK_KERN_COMBI)
4791 {
4792 // do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
4793 // since we still need to combine the plains
4794
4795 if (line_len > data.pw_max)
4796 {
4797 hc_thread_mutex_lock (mux_counter);
4798
4799 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4800 {
4801 data.words_progress_rejected[salt_pos] += data.combs_cnt;
4802 }
4803
4804 hc_thread_mutex_unlock (mux_counter);
4805
4806 continue;
4807 }
4808 }
4809
4810 device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
4811
4812 words_cur++;
4813
4814 if (data.devices_status == STATUS_CRACKED) break;
4815 if (data.devices_status == STATUS_ABORTED) break;
4816 if (data.devices_status == STATUS_QUIT) break;
4817 if (data.devices_status == STATUS_BYPASS) break;
4818 }
4819
4820 hc_thread_mutex_unlock (mux_dispatcher);
4821
4822 if (data.devices_status == STATUS_CRACKED) break;
4823 if (data.devices_status == STATUS_ABORTED) break;
4824 if (data.devices_status == STATUS_QUIT) break;
4825 if (data.devices_status == STATUS_BYPASS) break;
4826
4827 // we need 2 flushing because we have two independant caches and it can occur
4828 // that one buffer is already at threshold plus for that length also exists
4829 // more data in the 2nd buffer so it would overflow
4830
4831 // flush session 1
4832
4833 {
4834 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4835 {
4836 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4837
4838 const uint pw_cache_cnt = pw_cache->cnt;
4839
4840 if (pw_cache_cnt == 0) continue;
4841
4842 pw_cache->cnt = 0;
4843
4844 uint pws_cnt = device_param->pws_cnt;
4845
4846 pw_t *pw = device_param->pws_buf + pws_cnt;
4847
4848 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4849
4850 pw->pw_len = pw_len;
4851
4852 uint pw_cnt = device_param->pw_cnt;
4853
4854 pw_cnt += pw_cache_cnt;
4855
4856 device_param->pw_cnt = pw_cnt;
4857
4858 pws_cnt++;
4859
4860 device_param->pws_cnt = pws_cnt;
4861
4862 if (pws_cnt == device_param->gpu_power_user) break;
4863 }
4864
4865 const uint pw_cnt = device_param->pw_cnt;
4866 const uint pws_cnt = device_param->pws_cnt;
4867
4868 if (pws_cnt)
4869 {
4870 run_copy (device_param, pws_cnt);
4871
4872 run_cracker (device_param, pw_cnt, pws_cnt);
4873
4874 device_param->pw_cnt = 0;
4875 device_param->pws_cnt = 0;
4876 }
4877 }
4878
4879 // flush session 2
4880
4881 {
4882 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4883 {
4884 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4885
4886 const uint pw_cache_cnt = pw_cache->cnt;
4887
4888 if (pw_cache_cnt == 0) continue;
4889
4890 pw_cache->cnt = 0;
4891
4892 uint pws_cnt = device_param->pws_cnt;
4893
4894 pw_t *pw = device_param->pws_buf + pws_cnt;
4895
4896 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4897
4898 pw->pw_len = pw_len;
4899
4900 uint pw_cnt = device_param->pw_cnt;
4901
4902 pw_cnt += pw_cache_cnt;
4903
4904 device_param->pw_cnt = pw_cnt;
4905
4906 pws_cnt++;
4907
4908 device_param->pws_cnt = pws_cnt;
4909 }
4910
4911 const uint pw_cnt = device_param->pw_cnt;
4912 const uint pws_cnt = device_param->pws_cnt;
4913
4914 if (pws_cnt)
4915 {
4916 run_copy (device_param, pws_cnt);
4917
4918 run_cracker (device_param, pw_cnt, pws_cnt);
4919
4920 device_param->pw_cnt = 0;
4921 device_param->pws_cnt = 0;
4922 }
4923 }
4924 }
4925
4926 return NULL;
4927 }
4928
4929 static void *thread_calc (void *p)
4930 {
4931 hc_device_param_t *device_param = (hc_device_param_t *) p;
4932
4933 const uint attack_mode = data.attack_mode;
4934 const uint attack_kern = data.attack_kern;
4935
4936 if (attack_mode == ATTACK_MODE_BF)
4937 {
4938 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4939 {
4940 const uint work = get_work (device_param, -1);
4941
4942 if (work == 0) break;
4943
4944 const uint64_t words_off = device_param->words_off;
4945 const uint64_t words_fin = words_off + work;
4946
4947 const uint gpu_vector_width = device_param->gpu_vector_width;
4948
4949 const uint pw_cnt = work;
4950 const uint pws_cnt = mydivc32 (work, gpu_vector_width);
4951
4952 device_param->pw_cnt = pw_cnt;
4953 device_param->pws_cnt = pws_cnt;
4954
4955 if (pws_cnt)
4956 {
4957 run_copy (device_param, pws_cnt);
4958
4959 run_cracker (device_param, pw_cnt, pws_cnt);
4960
4961 device_param->pw_cnt = 0;
4962 device_param->pws_cnt = 0;
4963 }
4964
4965 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
4966
4967 if (data.devices_status == STATUS_CRACKED) break;
4968 if (data.devices_status == STATUS_ABORTED) break;
4969 if (data.devices_status == STATUS_QUIT) break;
4970 if (data.devices_status == STATUS_BYPASS) break;
4971
4972 device_param->words_done = words_fin;
4973 }
4974 }
4975 else
4976 {
4977 const uint segment_size = data.segment_size;
4978
4979 char *dictfile = data.dictfile;
4980
4981 if (attack_mode == ATTACK_MODE_COMBI)
4982 {
4983 if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
4984 {
4985 dictfile = data.dictfile2;
4986 }
4987 }
4988
4989 FILE *fd = fopen (dictfile, "rb");
4990
4991 if (fd == NULL)
4992 {
4993 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
4994
4995 return NULL;
4996 }
4997
4998 if (attack_mode == ATTACK_MODE_COMBI)
4999 {
5000 const uint combs_mode = data.combs_mode;
5001
5002 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
5003 {
5004 const char *dictfilec = data.dictfile2;
5005
5006 FILE *combs_fp = fopen (dictfilec, "rb");
5007
5008 if (combs_fp == NULL)
5009 {
5010 log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
5011
5012 fclose (fd);
5013
5014 return NULL;
5015 }
5016
5017 device_param->combs_fp = combs_fp;
5018 }
5019 else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
5020 {
5021 const char *dictfilec = data.dictfile;
5022
5023 FILE *combs_fp = fopen (dictfilec, "rb");
5024
5025 if (combs_fp == NULL)
5026 {
5027 log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
5028
5029 fclose (fd);
5030
5031 return NULL;
5032 }
5033
5034 device_param->combs_fp = combs_fp;
5035 }
5036 }
5037
5038 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
5039
5040 wl_data->buf = (char *) mymalloc (segment_size);
5041 wl_data->avail = segment_size;
5042 wl_data->incr = segment_size;
5043 wl_data->cnt = 0;
5044 wl_data->pos = 0;
5045
5046 uint64_t words_cur = 0;
5047
5048 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
5049 {
5050 uint64_t words_off = 0;
5051 uint64_t words_fin = 0;
5052
5053 uint64_t max = -1;
5054
5055 while (max)
5056 {
5057 const uint work = get_work (device_param, max);
5058
5059 if (work == 0) break;
5060
5061 words_off = device_param->words_off;
5062 words_fin = words_off + work;
5063
5064 char *line_buf;
5065 uint line_len;
5066
5067 for ( ; words_cur < words_off; words_cur++) get_next_word (wl_data, fd, &line_buf, &line_len);
5068
5069 max = 0;
5070
5071 for ( ; words_cur < words_fin; words_cur++)
5072 {
5073 get_next_word (wl_data, fd, &line_buf, &line_len);
5074
5075 line_len = convert_from_hex (line_buf, line_len);
5076
5077 // post-process rule engine
5078
5079 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
5080 {
5081 char rule_buf_out[BLOCK_SIZE];
5082
5083 memset (rule_buf_out, 0, sizeof (rule_buf_out));
5084
5085 int rule_len_out = -1;
5086
5087 if (line_len < BLOCK_SIZE)
5088 {
5089 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, line_buf, line_len, rule_buf_out);
5090 }
5091
5092 if (rule_len_out < 0) continue;
5093
5094 line_buf = rule_buf_out;
5095 line_len = rule_len_out;
5096 }
5097
5098 if (attack_kern == ATTACK_KERN_STRAIGHT)
5099 {
5100 if ((line_len < data.pw_min) || (line_len > data.pw_max))
5101 {
5102 max++;
5103
5104 hc_thread_mutex_lock (mux_counter);
5105
5106 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
5107 {
5108 data.words_progress_rejected[salt_pos] += data.gpu_rules_cnt;
5109 }
5110
5111 hc_thread_mutex_unlock (mux_counter);
5112
5113 continue;
5114 }
5115 }
5116 else if (attack_kern == ATTACK_KERN_COMBI)
5117 {
5118 // do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
5119 // since we still need to combine the plains
5120
5121 if (line_len > data.pw_max)
5122 {
5123 max++;
5124
5125 hc_thread_mutex_lock (mux_counter);
5126
5127 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
5128 {
5129 data.words_progress_rejected[salt_pos] += data.combs_cnt;
5130 }
5131
5132 hc_thread_mutex_unlock (mux_counter);
5133
5134 continue;
5135 }
5136 }
5137
5138 device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
5139
5140 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
5141
5142 if (data.devices_status == STATUS_CRACKED) break;
5143 if (data.devices_status == STATUS_ABORTED) break;
5144 if (data.devices_status == STATUS_QUIT) break;
5145 if (data.devices_status == STATUS_BYPASS) break;
5146 }
5147
5148 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
5149
5150 if (data.devices_status == STATUS_CRACKED) break;
5151 if (data.devices_status == STATUS_ABORTED) break;
5152 if (data.devices_status == STATUS_QUIT) break;
5153 if (data.devices_status == STATUS_BYPASS) break;
5154 }
5155
5156 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
5157
5158 if (data.devices_status == STATUS_CRACKED) break;
5159 if (data.devices_status == STATUS_ABORTED) break;
5160 if (data.devices_status == STATUS_QUIT) break;
5161 if (data.devices_status == STATUS_BYPASS) break;
5162
5163 // we need 2 flushing because we have two independant caches and it can occur
5164 // that one buffer is already at threshold plus for that length also exists
5165 // more data in the 2nd buffer so it would overflow
5166
5167 //
5168 // flush session 1
5169 //
5170
5171 {
5172 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
5173 {
5174 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
5175
5176 const uint pw_cache_cnt = pw_cache->cnt;
5177
5178 if (pw_cache_cnt == 0) continue;
5179
5180 pw_cache->cnt = 0;
5181
5182 uint pws_cnt = device_param->pws_cnt;
5183
5184 pw_t *pw = device_param->pws_buf + pws_cnt;
5185
5186 device_param->pw_transpose (&pw_cache->pw_buf, pw);
5187
5188 pw->pw_len = pw_len;
5189
5190 uint pw_cnt = device_param->pw_cnt;
5191
5192 pw_cnt += pw_cache_cnt;
5193
5194 device_param->pw_cnt = pw_cnt;
5195
5196 pws_cnt++;
5197
5198 device_param->pws_cnt = pws_cnt;
5199
5200 if (pws_cnt == device_param->gpu_power_user) break;
5201 }
5202
5203 const uint pw_cnt = device_param->pw_cnt;
5204 const uint pws_cnt = device_param->pws_cnt;
5205
5206 if (pws_cnt)
5207 {
5208 run_copy (device_param, pws_cnt);
5209
5210 run_cracker (device_param, pw_cnt, pws_cnt);
5211
5212 device_param->pw_cnt = 0;
5213 device_param->pws_cnt = 0;
5214 }
5215
5216 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
5217
5218 if (data.devices_status == STATUS_CRACKED) break;
5219 if (data.devices_status == STATUS_ABORTED) break;
5220 if (data.devices_status == STATUS_QUIT) break;
5221 if (data.devices_status == STATUS_BYPASS) break;
5222 }
5223
5224 //
5225 // flush session 2
5226 //
5227
5228 {
5229 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
5230 {
5231 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
5232
5233 const uint pw_cache_cnt = pw_cache->cnt;
5234
5235 if (pw_cache_cnt == 0) continue;
5236
5237 pw_cache->cnt = 0;
5238
5239 uint pws_cnt = device_param->pws_cnt;
5240
5241 pw_t *pw = device_param->pws_buf + pws_cnt;
5242
5243 device_param->pw_transpose (&pw_cache->pw_buf, pw);
5244
5245 pw->pw_len = pw_len;
5246
5247 uint pw_cnt = device_param->pw_cnt;
5248
5249 pw_cnt += pw_cache_cnt;
5250
5251 device_param->pw_cnt = pw_cnt;
5252
5253 pws_cnt++;
5254
5255 device_param->pws_cnt = pws_cnt;
5256 }
5257
5258 const uint pw_cnt = device_param->pw_cnt;
5259 const uint pws_cnt = device_param->pws_cnt;
5260
5261 if (pws_cnt)
5262 {
5263 run_copy (device_param, pws_cnt);
5264
5265 run_cracker (device_param, pw_cnt, pws_cnt);
5266
5267 device_param->pw_cnt = 0;
5268 device_param->pws_cnt = 0;
5269 }
5270
5271 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
5272
5273 if (data.devices_status == STATUS_CRACKED) break;
5274 if (data.devices_status == STATUS_ABORTED) break;
5275 if (data.devices_status == STATUS_QUIT) break;
5276 if (data.devices_status == STATUS_BYPASS) break;
5277 }
5278
5279 if (words_fin == 0) break;
5280
5281 device_param->words_done = words_fin;
5282 }
5283
5284 if (attack_mode == ATTACK_MODE_COMBI)
5285 {
5286 fclose (device_param->combs_fp);
5287 }
5288
5289 free (wl_data->buf);
5290 free (wl_data);
5291
5292 fclose (fd);
5293 }
5294
5295 return NULL;
5296 }
5297
5298 static void weak_hash_check (hc_device_param_t *device_param, const uint salt_pos, const uint gpu_loops)
5299 {
5300 #ifdef _CUDA
5301 hc_cuCtxPushCurrent (device_param->context);
5302 #endif
5303
5304 salt_t *salt_buf = &data.salts_buf[salt_pos];
5305
5306 device_param->kernel_params_buf32[24] = salt_pos;
5307 device_param->kernel_params_buf32[27] = 1;
5308 device_param->kernel_params_buf32[28] = salt_buf->digests_cnt;
5309 device_param->kernel_params_buf32[29] = salt_buf->digests_offset;
5310 device_param->kernel_params_buf32[30] = 0;
5311 device_param->kernel_params_buf32[31] = 1;
5312
5313 char *dictfile_old = data.dictfile;
5314 char *dictfile2_old = data.dictfile2;
5315 char *mask_old = data.mask;
5316
5317 const char *weak_hash_check = "weak-hash-check";
5318
5319 data.dictfile = (char *) weak_hash_check;
5320 data.dictfile2 = (char *) weak_hash_check;
5321 data.mask = (char *) weak_hash_check;
5322
5323 /**
5324 * run the kernel
5325 */
5326
5327 if (data.attack_exec == ATTACK_EXEC_ON_GPU)
5328 {
5329 run_kernel (KERN_RUN_1, device_param, 1);
5330 }
5331 else
5332 {
5333 run_kernel (KERN_RUN_1, device_param, 1);
5334
5335 const uint iter = salt_buf->salt_iter;
5336
5337 for (uint loop_pos = 0; loop_pos < iter; loop_pos += gpu_loops)
5338 {
5339 uint loop_left = iter - loop_pos;
5340
5341 loop_left = MIN (loop_left, gpu_loops);
5342
5343 device_param->kernel_params_buf32[25] = loop_pos;
5344 device_param->kernel_params_buf32[26] = loop_left;
5345
5346 run_kernel (KERN_RUN_2, device_param, 1);
5347 }
5348
5349 run_kernel (KERN_RUN_3, device_param, 1);
5350 }
5351
5352 /**
5353 * result
5354 */
5355
5356 check_cracked (device_param, salt_pos);
5357
5358 /**
5359 * cleanup
5360 */
5361
5362 device_param->kernel_params_buf32[24] = 0;
5363 device_param->kernel_params_buf32[25] = 0;
5364 device_param->kernel_params_buf32[26] = 0;
5365 device_param->kernel_params_buf32[27] = 0;
5366 device_param->kernel_params_buf32[28] = 0;
5367 device_param->kernel_params_buf32[29] = 0;
5368 device_param->kernel_params_buf32[30] = 0;
5369 device_param->kernel_params_buf32[31] = 0;
5370
5371 data.dictfile = dictfile_old;
5372 data.dictfile2 = dictfile2_old;
5373 data.mask = mask_old;
5374
5375 #ifdef _CUDA
5376 hc_cuCtxPopCurrent (&device_param->context);
5377 #endif
5378 }
5379
5380 // hlfmt hashcat
5381
5382 static void hlfmt_hash_hashcat (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5383 {
5384 if (data.username == 0)
5385 {
5386 *hashbuf_pos = line_buf;
5387 *hashbuf_len = line_len;
5388 }
5389 else
5390 {
5391 char *pos = line_buf;
5392 int len = line_len;
5393
5394 for (int i = 0; i < line_len; i++, pos++, len--)
5395 {
5396 if (line_buf[i] == data.separator)
5397 {
5398 pos++;
5399
5400 len--;
5401
5402 break;
5403 }
5404 }
5405
5406 *hashbuf_pos = pos;
5407 *hashbuf_len = len;
5408 }
5409 }
5410
5411 static void hlfmt_user_hashcat (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5412 {
5413 char *pos = NULL;
5414 int len = 0;
5415
5416 int sep_cnt = 0;
5417
5418 for (int i = 0; i < line_len; i++)
5419 {
5420 if (line_buf[i] == data.separator)
5421 {
5422 sep_cnt++;
5423
5424 continue;
5425 }
5426
5427 if (sep_cnt == 0)
5428 {
5429 if (pos == NULL) pos = line_buf + i;
5430
5431 len++;
5432 }
5433 }
5434
5435 *userbuf_pos = pos;
5436 *userbuf_len = len;
5437 }
5438
5439 // hlfmt pwdump
5440
5441 static int hlfmt_detect_pwdump (char line_buf[BUFSIZ], int line_len)
5442 {
5443 int sep_cnt = 0;
5444
5445 int sep2_len = 0;
5446 int sep3_len = 0;
5447
5448 for (int i = 0; i < line_len; i++)
5449 {
5450 if (line_buf[i] == ':')
5451 {
5452 sep_cnt++;
5453
5454 continue;
5455 }
5456
5457 if (sep_cnt == 2) sep2_len++;
5458 if (sep_cnt == 3) sep3_len++;
5459 }
5460
5461 if ((sep_cnt == 6) && ((sep2_len == 32) || (sep3_len == 32))) return 1;
5462
5463 return 0;
5464 }
5465
5466 static void hlfmt_hash_pwdump (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5467 {
5468 char *pos = NULL;
5469 int len = 0;
5470
5471 int sep_cnt = 0;
5472
5473 for (int i = 0; i < line_len; i++)
5474 {
5475 if (line_buf[i] == ':')
5476 {
5477 sep_cnt++;
5478
5479 continue;
5480 }
5481
5482 if (data.hash_mode == 1000)
5483 {
5484 if (sep_cnt == 3)
5485 {
5486 if (pos == NULL) pos = line_buf + i;
5487
5488 len++;
5489 }
5490 }
5491 else if (data.hash_mode == 3000)
5492 {
5493 if (sep_cnt == 2)
5494 {
5495 if (pos == NULL) pos = line_buf + i;
5496
5497 len++;
5498 }
5499 }
5500 }
5501
5502 *hashbuf_pos = pos;
5503 *hashbuf_len = len;
5504 }
5505
5506 static void hlfmt_user_pwdump (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5507 {
5508 char *pos = NULL;
5509 int len = 0;
5510
5511 int sep_cnt = 0;
5512
5513 for (int i = 0; i < line_len; i++)
5514 {
5515 if (line_buf[i] == ':')
5516 {
5517 sep_cnt++;
5518
5519 continue;
5520 }
5521
5522 if (sep_cnt == 0)
5523 {
5524 if (pos == NULL) pos = line_buf + i;
5525
5526 len++;
5527 }
5528 }
5529
5530 *userbuf_pos = pos;
5531 *userbuf_len = len;
5532 }
5533
5534 // hlfmt passwd
5535
5536 static int hlfmt_detect_passwd (char line_buf[BUFSIZ], int line_len)
5537 {
5538 int sep_cnt = 0;
5539
5540 char sep5_first = 0;
5541 char sep6_first = 0;
5542
5543 for (int i = 0; i < line_len; i++)
5544 {
5545 if (line_buf[i] == ':')
5546 {
5547 sep_cnt++;
5548
5549 continue;
5550 }
5551
5552 if (sep_cnt == 5) if (sep5_first == 0) sep5_first = line_buf[i];
5553 if (sep_cnt == 6) if (sep6_first == 0) sep6_first = line_buf[i];
5554 }
5555
5556 if ((sep_cnt == 6) && ((sep5_first == '/') || (sep6_first == '/'))) return 1;
5557
5558 return 0;
5559 }
5560
5561 static void hlfmt_hash_passwd (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5562 {
5563 char *pos = NULL;
5564 int len = 0;
5565
5566 int sep_cnt = 0;
5567
5568 for (int i = 0; i < line_len; i++)
5569 {
5570 if (line_buf[i] == ':')
5571 {
5572 sep_cnt++;
5573
5574 continue;
5575 }
5576
5577 if (sep_cnt == 1)
5578 {
5579 if (pos == NULL) pos = line_buf + i;
5580
5581 len++;
5582 }
5583 }
5584
5585 *hashbuf_pos = pos;
5586 *hashbuf_len = len;
5587 }
5588
5589 static void hlfmt_user_passwd (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5590 {
5591 char *pos = NULL;
5592 int len = 0;
5593
5594 int sep_cnt = 0;
5595
5596 for (int i = 0; i < line_len; i++)
5597 {
5598 if (line_buf[i] == ':')
5599 {
5600 sep_cnt++;
5601
5602 continue;
5603 }
5604
5605 if (sep_cnt == 0)
5606 {
5607 if (pos == NULL) pos = line_buf + i;
5608
5609 len++;
5610 }
5611 }
5612
5613 *userbuf_pos = pos;
5614 *userbuf_len = len;
5615 }
5616
5617 // hlfmt shadow
5618
5619 static int hlfmt_detect_shadow (char line_buf[BUFSIZ], int line_len)
5620 {
5621 int sep_cnt = 0;
5622
5623 for (int i = 0; i < line_len; i++)
5624 {
5625 if (line_buf[i] == ':') sep_cnt++;
5626 }
5627
5628 if (sep_cnt == 8) return 1;
5629
5630 return 0;
5631 }
5632
5633 static void hlfmt_hash_shadow (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5634 {
5635 hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len);
5636 }
5637
5638 static void hlfmt_user_shadow (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5639 {
5640 hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len);
5641 }
5642
5643 // hlfmt main
5644
5645 static void hlfmt_hash (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5646 {
5647 switch (hashfile_format)
5648 {
5649 case HLFMT_HASHCAT: hlfmt_hash_hashcat (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5650 case HLFMT_PWDUMP: hlfmt_hash_pwdump (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5651 case HLFMT_PASSWD: hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5652 case HLFMT_SHADOW: hlfmt_hash_shadow (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5653 }
5654 }
5655
5656 static void hlfmt_user (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5657 {
5658 switch (hashfile_format)
5659 {
5660 case HLFMT_HASHCAT: hlfmt_user_hashcat (line_buf, line_len, userbuf_pos, userbuf_len); break;
5661 case HLFMT_PWDUMP: hlfmt_user_pwdump (line_buf, line_len, userbuf_pos, userbuf_len); break;
5662 case HLFMT_PASSWD: hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len); break;
5663 case HLFMT_SHADOW: hlfmt_user_shadow (line_buf, line_len, userbuf_pos, userbuf_len); break;
5664 }
5665 }
5666
5667 static uint hlfmt_detect (FILE *fp, uint max_check)
5668 {
5669 // Exception: those formats are wrongly detected as HLFMT_SHADOW, prevent it
5670
5671 if (data.hash_mode == 5300) return HLFMT_HASHCAT;
5672 if (data.hash_mode == 5400) return HLFMT_HASHCAT;
5673
5674 uint *formats_cnt = (uint *) mycalloc (HLFMTS_CNT, sizeof (uint));
5675
5676 uint num_check = 0;
5677
5678 while (!feof (fp))
5679 {
5680 char line_buf[BUFSIZ];
5681
5682 int line_len = fgetl (fp, line_buf);
5683
5684 if (line_len == 0) continue;
5685
5686 if (hlfmt_detect_pwdump (line_buf, line_len)) formats_cnt[HLFMT_PWDUMP]++;
5687 if (hlfmt_detect_passwd (line_buf, line_len)) formats_cnt[HLFMT_PASSWD]++;
5688 if (hlfmt_detect_shadow (line_buf, line_len)) formats_cnt[HLFMT_SHADOW]++;
5689
5690 if (num_check == max_check) break;
5691
5692 num_check++;
5693 }
5694
5695 uint hashlist_format = HLFMT_HASHCAT;
5696
5697 for (int i = 1; i < HLFMTS_CNT; i++)
5698 {
5699 if (formats_cnt[i - 1] >= formats_cnt[i]) continue;
5700
5701 hashlist_format = i;
5702 }
5703
5704 free (formats_cnt);
5705
5706 return hashlist_format;
5707 }
5708
5709 /**
5710 * main
5711 */
5712
5713 #ifdef _OCL
5714 void *__stdcall ADL_Main_Memory_Alloc (const int iSize)
5715 {
5716 return mymalloc (iSize);
5717 }
5718 #endif
5719
5720 static uint generate_bitmaps (const uint digests_cnt, const uint dgst_size, const uint dgst_shifts, char *digests_buf_ptr, const uint bitmap_mask, const uint bitmap_size, uint *bitmap_a, uint *bitmap_b, uint *bitmap_c, uint *bitmap_d, const uint64_t collisions_max)
5721 {
5722 uint64_t collisions = 0;
5723
5724 const uint dgst_pos0 = data.dgst_pos0;
5725 const uint dgst_pos1 = data.dgst_pos1;
5726 const uint dgst_pos2 = data.dgst_pos2;
5727 const uint dgst_pos3 = data.dgst_pos3;
5728
5729 memset (bitmap_a, 0, bitmap_size);
5730 memset (bitmap_b, 0, bitmap_size);
5731 memset (bitmap_c, 0, bitmap_size);
5732 memset (bitmap_d, 0, bitmap_size);
5733
5734 for (uint i = 0; i < digests_cnt; i++)
5735 {
5736 uint *digest_ptr = (uint *) digests_buf_ptr;
5737
5738 digests_buf_ptr += dgst_size;
5739
5740 const uint val0 = 1 << (digest_ptr[dgst_pos0] & 0x1f);
5741 const uint val1 = 1 << (digest_ptr[dgst_pos1] & 0x1f);
5742 const uint val2 = 1 << (digest_ptr[dgst_pos2] & 0x1f);
5743 const uint val3 = 1 << (digest_ptr[dgst_pos3] & 0x1f);
5744
5745 const uint idx0 = (digest_ptr[dgst_pos0] >> dgst_shifts) & bitmap_mask;
5746 const uint idx1 = (digest_ptr[dgst_pos1] >> dgst_shifts) & bitmap_mask;
5747 const uint idx2 = (digest_ptr[dgst_pos2] >> dgst_shifts) & bitmap_mask;
5748 const uint idx3 = (digest_ptr[dgst_pos3] >> dgst_shifts) & bitmap_mask;
5749
5750 if (bitmap_a[idx0] & val0) collisions++;
5751 if (bitmap_b[idx1] & val1) collisions++;
5752 if (bitmap_c[idx2] & val2) collisions++;
5753 if (bitmap_d[idx3] & val3) collisions++;
5754
5755 bitmap_a[idx0] |= val0;
5756 bitmap_b[idx1] |= val1;
5757 bitmap_c[idx2] |= val2;
5758 bitmap_d[idx3] |= val3;
5759
5760 if (collisions >= collisions_max) return 0x7fffffff;
5761 }
5762
5763 return collisions;
5764 }
5765
5766 int main (int argc, char **argv)
5767 {
5768 /**
5769 * To help users a bit
5770 */
5771
5772 char *compute = getenv ("COMPUTE");
5773
5774 if (compute)
5775 {
5776 char display[100];
5777
5778 snprintf (display, sizeof (display) - 1, "DISPLAY=%s", compute);
5779
5780 putenv (display);
5781 }
5782 else
5783 {
5784 if (getenv ("DISPLAY") == NULL)
5785 putenv ((char *) "DISPLAY=:0");
5786 }
5787
5788 /*
5789 if (getenv ("GPU_MAX_ALLOC_PERCENT") == NULL)
5790 putenv ((char *) "GPU_MAX_ALLOC_PERCENT=100");
5791
5792 if (getenv ("GPU_USE_SYNC_OBJECTS") == NULL)
5793 putenv ((char *) "GPU_USE_SYNC_OBJECTS=1");
5794 */
5795
5796 /**
5797 * Real init
5798 */
5799
5800 memset (&data, 0, sizeof (hc_global_data_t));
5801
5802 time_t proc_start;
5803
5804 time (&proc_start);
5805
5806 data.proc_start = proc_start;
5807
5808 int myargc = argc;
5809 char **myargv = argv;
5810
5811 hc_thread_mutex_init (mux_dispatcher);
5812 hc_thread_mutex_init (mux_counter);
5813 hc_thread_mutex_init (mux_display);
5814 hc_thread_mutex_init (mux_adl);
5815
5816 /**
5817 * commandline parameters
5818 */
5819
5820 uint usage = USAGE;
5821 uint version = VERSION;
5822 uint quiet = QUIET;
5823 uint benchmark = BENCHMARK;
5824 uint benchmark_mode = BENCHMARK_MODE;
5825 uint show = SHOW;
5826 uint left = LEFT;
5827 uint username = USERNAME;
5828 uint remove = REMOVE;
5829 uint remove_timer = REMOVE_TIMER;
5830 uint64_t skip = SKIP;
5831 uint64_t limit = LIMIT;
5832 uint keyspace = KEYSPACE;
5833 uint potfile_disable = POTFILE_DISABLE;
5834 uint debug_mode = DEBUG_MODE;
5835 char *debug_file = NULL;
5836 char *induction_dir = NULL;
5837 char *outfile_check_dir = NULL;
5838 uint force = FORCE;
5839 uint runtime = RUNTIME;
5840 uint hash_mode = HASH_MODE;
5841 uint attack_mode = ATTACK_MODE;
5842 uint markov_disable = MARKOV_DISABLE;
5843 uint markov_classic = MARKOV_CLASSIC;
5844 uint markov_threshold = MARKOV_THRESHOLD;
5845 char *markov_hcstat = NULL;
5846 char *outfile = NULL;
5847 uint outfile_format = OUTFILE_FORMAT;
5848 uint outfile_autohex = OUTFILE_AUTOHEX;
5849 uint outfile_check_timer = OUTFILE_CHECK_TIMER;
5850 uint restore = RESTORE;
5851 uint restore_timer = RESTORE_TIMER;
5852 uint restore_disable = RESTORE_DISABLE;
5853 uint status = STATUS;
5854 uint status_timer = STATUS_TIMER;
5855 uint status_automat = STATUS_AUTOMAT;
5856 uint loopback = LOOPBACK;
5857 uint weak_hash_threshold = WEAK_HASH_THRESHOLD;
5858 char *session = NULL;
5859 uint hex_charset = HEX_CHARSET;
5860 uint hex_salt = HEX_SALT;
5861 uint hex_wordlist = HEX_WORDLIST;
5862 uint rp_gen = RP_GEN;
5863 uint rp_gen_func_min = RP_GEN_FUNC_MIN;
5864 uint rp_gen_func_max = RP_GEN_FUNC_MAX;
5865 uint rp_gen_seed = RP_GEN_SEED;
5866 char *rule_buf_l = (char *) RULE_BUF_L;
5867 char *rule_buf_r = (char *) RULE_BUF_R;
5868 uint increment = INCREMENT;
5869 uint increment_min = INCREMENT_MIN;
5870 uint increment_max = INCREMENT_MAX;
5871 char *cpu_affinity = NULL;
5872 uint gpu_async = GPU_ASYNC;
5873 char *gpu_devices = NULL;
5874 char *truecrypt_keyfiles = NULL;
5875 uint workload_profile = WORKLOAD_PROFILE;
5876 uint gpu_accel = GPU_ACCEL;
5877 uint gpu_loops = GPU_LOOPS;
5878 uint gpu_temp_disable = GPU_TEMP_DISABLE;
5879 uint gpu_temp_abort = GPU_TEMP_ABORT;
5880 uint gpu_temp_retain = GPU_TEMP_RETAIN;
5881 uint powertune_enable = POWERTUNE_ENABLE;
5882 uint logfile_disable = LOGFILE_DISABLE;
5883 uint segment_size = SEGMENT_SIZE;
5884 uint scrypt_tmto = SCRYPT_TMTO;
5885 char separator = SEPARATOR;
5886 uint bitmap_min = BITMAP_MIN;
5887 uint bitmap_max = BITMAP_MAX;
5888 char *custom_charset_1 = NULL;
5889 char *custom_charset_2 = NULL;
5890 char *custom_charset_3 = NULL;
5891 char *custom_charset_4 = NULL;
5892
5893 #define IDX_HELP 'h'
5894 #define IDX_VERSION 'V'
5895 #define IDX_VERSION_LOWER 'v'
5896 #define IDX_QUIET 0xff02
5897 #define IDX_SHOW 0xff03
5898 #define IDX_LEFT 0xff04
5899 #define IDX_REMOVE 0xff05
5900 #define IDX_REMOVE_TIMER 0xff37
5901 #define IDX_SKIP 's'
5902 #define IDX_LIMIT 'l'
5903 #define IDX_KEYSPACE 0xff35
5904 #define IDX_POTFILE_DISABLE 0xff06
5905 #define IDX_DEBUG_MODE 0xff43
5906 #define IDX_DEBUG_FILE 0xff44
5907 #define IDX_INDUCTION_DIR 0xff46
5908 #define IDX_OUTFILE_CHECK_DIR 0xff47
5909 #define IDX_USERNAME 0xff07
5910 #define IDX_FORCE 0xff08
5911 #define IDX_RUNTIME 0xff09
5912 #define IDX_BENCHMARK 'b'
5913 #define IDX_BENCHMARK_MODE 0xff32
5914 #define IDX_HASH_MODE 'm'
5915 #define IDX_ATTACK_MODE 'a'
5916 #define IDX_RP_FILE 'r'
5917 #define IDX_RP_GEN 'g'
5918 #define IDX_RP_GEN_FUNC_MIN 0xff10
5919 #define IDX_RP_GEN_FUNC_MAX 0xff11
5920 #define IDX_RP_GEN_SEED 0xff34
5921 #define IDX_RULE_BUF_L 'j'
5922 #define IDX_RULE_BUF_R 'k'
5923 #define IDX_INCREMENT 'i'
5924 #define IDX_INCREMENT_MIN 0xff12
5925 #define IDX_INCREMENT_MAX 0xff13
5926 #define IDX_OUTFILE 'o'
5927 #define IDX_OUTFILE_FORMAT 0xff14
5928 #define IDX_OUTFILE_AUTOHEX_DISABLE 0xff39
5929 #define IDX_OUTFILE_CHECK_TIMER 0xff45
5930 #define IDX_RESTORE 0xff15
5931 #define IDX_RESTORE_DISABLE 0xff27
5932 #define IDX_STATUS 0xff17
5933 #define IDX_STATUS_TIMER 0xff18
5934 #define IDX_STATUS_AUTOMAT 0xff50
5935 #define IDX_LOOPBACK 0xff38
5936 #define IDX_WEAK_HASH_THRESHOLD 0xff42
5937 #define IDX_SESSION 0xff19
5938 #define IDX_HEX_CHARSET 0xff20
5939 #define IDX_HEX_SALT 0xff21
5940 #define IDX_HEX_WORDLIST 0xff40
5941 #define IDX_MARKOV_DISABLE 0xff22
5942 #define IDX_MARKOV_CLASSIC 0xff23
5943 #define IDX_MARKOV_THRESHOLD 't'
5944 #define IDX_MARKOV_HCSTAT 0xff24
5945 #define IDX_CPU_AFFINITY 0xff25
5946 #define IDX_GPU_ASYNC 0xff26
5947 #define IDX_GPU_DEVICES 'd'
5948 #define IDX_WORKLOAD_PROFILE 'w'
5949 #define IDX_GPU_ACCEL 'n'
5950 #define IDX_GPU_LOOPS 'u'
5951 #define IDX_GPU_TEMP_DISABLE 0xff29
5952 #define IDX_GPU_TEMP_ABORT 0xff30
5953 #define IDX_GPU_TEMP_RETAIN 0xff31
5954 #define IDX_POWERTUNE_ENABLE 0xff41
5955 #define IDX_LOGFILE_DISABLE 0xff51
5956 #define IDX_TRUECRYPT_KEYFILES 0xff52
5957 #define IDX_SCRYPT_TMTO 0xff61
5958 #define IDX_SEGMENT_SIZE 'c'
5959 #define IDX_SEPARATOR 'p'
5960 #define IDX_BITMAP_MIN 0xff70
5961 #define IDX_BITMAP_MAX 0xff71
5962 #define IDX_CUSTOM_CHARSET_1 '1'
5963 #define IDX_CUSTOM_CHARSET_2 '2'
5964 #define IDX_CUSTOM_CHARSET_3 '3'
5965 #define IDX_CUSTOM_CHARSET_4 '4'
5966
5967 char short_options[] = "hVvm:a:r:j:k:g:o:t:d:n:u:c:p:s:l:1:2:3:4:ibw:";
5968
5969 struct option long_options[] =
5970 {
5971 {"help", no_argument, 0, IDX_HELP},
5972 {"version", no_argument, 0, IDX_VERSION},
5973 {"quiet", no_argument, 0, IDX_QUIET},
5974 {"show", no_argument, 0, IDX_SHOW},
5975 {"left", no_argument, 0, IDX_LEFT},
5976 {"username", no_argument, 0, IDX_USERNAME},
5977 {"remove", no_argument, 0, IDX_REMOVE},
5978 {"remove-timer", required_argument, 0, IDX_REMOVE_TIMER},
5979 {"skip", required_argument, 0, IDX_SKIP},
5980 {"limit", required_argument, 0, IDX_LIMIT},
5981 {"keyspace", no_argument, 0, IDX_KEYSPACE},
5982 {"potfile-disable", no_argument, 0, IDX_POTFILE_DISABLE},
5983 {"debug-mode", required_argument, 0, IDX_DEBUG_MODE},
5984 {"debug-file", required_argument, 0, IDX_DEBUG_FILE},
5985 {"induction-dir", required_argument, 0, IDX_INDUCTION_DIR},
5986 {"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR},
5987 {"force", no_argument, 0, IDX_FORCE},
5988 {"benchmark", no_argument, 0, IDX_BENCHMARK},
5989 {"benchmark-mode", required_argument, 0, IDX_BENCHMARK_MODE},
5990 {"restore", no_argument, 0, IDX_RESTORE},
5991 {"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE},
5992 {"status", no_argument, 0, IDX_STATUS},
5993 {"status-timer", required_argument, 0, IDX_STATUS_TIMER},
5994 {"status-automat", no_argument, 0, IDX_STATUS_AUTOMAT},
5995 {"loopback", no_argument, 0, IDX_LOOPBACK},
5996 {"weak-hash-threshold",
5997 required_argument, 0, IDX_WEAK_HASH_THRESHOLD},
5998 {"session", required_argument, 0, IDX_SESSION},
5999 {"runtime", required_argument, 0, IDX_RUNTIME},
6000 {"generate-rules", required_argument, 0, IDX_RP_GEN},
6001 {"generate-rules-func-min",
6002 required_argument, 0, IDX_RP_GEN_FUNC_MIN},
6003 {"generate-rules-func-max",
6004 required_argument, 0, IDX_RP_GEN_FUNC_MAX},
6005 {"generate-rules-seed",
6006 required_argument, 0, IDX_RP_GEN_SEED},
6007 {"rule-left", required_argument, 0, IDX_RULE_BUF_L},
6008 {"rule-right", required_argument, 0, IDX_RULE_BUF_R},
6009 {"hash-type", required_argument, 0, IDX_HASH_MODE},
6010 {"attack-mode", required_argument, 0, IDX_ATTACK_MODE},
6011 {"rules-file", required_argument, 0, IDX_RP_FILE},
6012 {"outfile", required_argument, 0, IDX_OUTFILE},
6013 {"outfile-format", required_argument, 0, IDX_OUTFILE_FORMAT},
6014 {"outfile-autohex-disable",
6015 no_argument, 0, IDX_OUTFILE_AUTOHEX_DISABLE},
6016 {"outfile-check-timer",
6017 required_argument, 0, IDX_OUTFILE_CHECK_TIMER},
6018 {"hex-charset", no_argument, 0, IDX_HEX_CHARSET},
6019 {"hex-salt", no_argument, 0, IDX_HEX_SALT},
6020 {"hex-wordlist", no_argument, 0, IDX_HEX_WORDLIST},
6021 {"markov-disable", no_argument, 0, IDX_MARKOV_DISABLE},
6022 {"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC},
6023 {"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD},
6024 {"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT},
6025 {"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
6026 {"gpu-async", no_argument, 0, IDX_GPU_ASYNC},
6027 {"gpu-devices", required_argument, 0, IDX_GPU_DEVICES},
6028 {"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE},
6029 {"gpu-accel", required_argument, 0, IDX_GPU_ACCEL},
6030 {"gpu-loops", required_argument, 0, IDX_GPU_LOOPS},
6031 {"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE},
6032 {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
6033 {"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
6034 {"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
6035 {"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
6036 {"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
6037 {"segment-size", required_argument, 0, IDX_SEGMENT_SIZE},
6038 {"scrypt-tmto", required_argument, 0, IDX_SCRYPT_TMTO},
6039 // deprecated
6040 {"seperator", required_argument, 0, IDX_SEPARATOR},
6041 {"separator", required_argument, 0, IDX_SEPARATOR},
6042 {"bitmap-min", required_argument, 0, IDX_BITMAP_MIN},
6043 {"bitmap-max", required_argument, 0, IDX_BITMAP_MAX},
6044 {"increment", no_argument, 0, IDX_INCREMENT},
6045 {"increment-min", required_argument, 0, IDX_INCREMENT_MIN},
6046 {"increment-max", required_argument, 0, IDX_INCREMENT_MAX},
6047 {"custom-charset1", required_argument, 0, IDX_CUSTOM_CHARSET_1},
6048 {"custom-charset2", required_argument, 0, IDX_CUSTOM_CHARSET_2},
6049 {"custom-charset3", required_argument, 0, IDX_CUSTOM_CHARSET_3},
6050 {"custom-charset4", required_argument, 0, IDX_CUSTOM_CHARSET_4},
6051
6052 {0, 0, 0, 0}
6053 };
6054
6055 uint rp_files_cnt = 0;
6056
6057 char **rp_files = (char **) mycalloc (argc, sizeof (char *));
6058
6059 int option_index;
6060 int c;
6061
6062 optind = 1;
6063 optopt = 0;
6064 option_index = 0;
6065
6066 while (((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1) && optopt == 0)
6067 {
6068 switch (c)
6069 {
6070 case IDX_HELP: usage = 1; break;
6071 case IDX_VERSION:
6072 case IDX_VERSION_LOWER: version = 1; break;
6073 case IDX_RESTORE: restore = 1; break;
6074 case IDX_SESSION: session = optarg; break;
6075 case IDX_SHOW: show = 1; break;
6076 case IDX_LEFT: left = 1; break;
6077 case '?': return (-1);
6078 }
6079 }
6080
6081 if (optopt != 0)
6082 {
6083 log_error ("ERROR: Invalid argument specified");
6084
6085 return (-1);
6086 }
6087
6088 /**
6089 * exit functions
6090 */
6091
6092 if (version)
6093 {
6094 log_info (VERSION_TXT);
6095
6096 return (0);
6097 }
6098
6099 if (usage)
6100 {
6101 usage_big_print (PROGNAME);
6102
6103 return (0);
6104 }
6105
6106 /**
6107 * session
6108 */
6109
6110 if (session == NULL) session = (char *) PROGNAME;
6111
6112 size_t session_size = strlen (session) + 32;
6113
6114 data.session = session;
6115
6116 char *eff_restore_file = (char *) mymalloc (session_size);
6117 char *new_restore_file = (char *) mymalloc (session_size);
6118
6119 snprintf (eff_restore_file, session_size - 1, "%s.restore", session);
6120 snprintf (new_restore_file, session_size - 1, "%s.restore.new", session);
6121
6122 data.eff_restore_file = eff_restore_file;
6123 data.new_restore_file = new_restore_file;
6124
6125 if (((show == 1) || (left == 1)) && (restore == 1))
6126 {
6127 if (show == 1) log_error ("ERROR: Mixing --restore parameter and --show is not supported");
6128 else log_error ("ERROR: Mixing --restore parameter and --left is not supported");
6129
6130 return (-1);
6131 }
6132
6133 // this allows the user to use --show and --left while cracking (i.e. while another instance of oclHashcat is running)
6134 if ((show == 1) || (left == 1))
6135 {
6136 restore_disable = 1;
6137
6138 restore = 0;
6139 }
6140
6141 data.restore_disable = restore_disable;
6142
6143 restore_data_t *rd = init_restore (argc, argv);
6144
6145 data.rd = rd;
6146
6147 /**
6148 * restore file
6149 */
6150
6151 if (restore == 1)
6152 {
6153 read_restore (eff_restore_file, rd);
6154
6155 if (rd->version_bin < RESTORE_MIN)
6156 {
6157 log_error ("ERROR: Incompatible restore-file version");
6158
6159 return (-1);
6160 }
6161
6162 myargc = rd->argc;
6163 myargv = rd->argv;
6164
6165 #ifdef _POSIX
6166 rd->pid = getpid ();
6167 #elif _WIN
6168 rd->pid = GetCurrentProcessId ();
6169 #endif
6170 }
6171
6172 uint hash_mode_chgd = 0;
6173 uint runtime_chgd = 0;
6174 uint gpu_loops_chgd = 0;
6175 uint gpu_accel_chgd = 0;
6176 uint attack_mode_chgd = 0;
6177 uint outfile_format_chgd = 0;
6178 uint rp_gen_seed_chgd = 0;
6179 uint remove_timer_chgd = 0;
6180 uint increment_min_chgd = 0;
6181 uint increment_max_chgd = 0;
6182
6183 #if _OCL
6184 uint gpu_temp_abort_chgd = 0;
6185 uint gpu_temp_retain_chgd = 0;
6186 #endif
6187
6188 optind = 1;
6189 optopt = 0;
6190 option_index = 0;
6191
6192 while (((c = getopt_long (myargc, myargv, short_options, long_options, &option_index)) != -1) && optopt == 0)
6193 {
6194 switch (c)
6195 {
6196 //case IDX_HELP: usage = 1; break;
6197 //case IDX_VERSION: version = 1; break;
6198 //case IDX_RESTORE: restore = 1; break;
6199 case IDX_QUIET: quiet = 1; break;
6200 //case IDX_SHOW: show = 1; break;
6201 case IDX_SHOW: break;
6202 //case IDX_LEFT: left = 1; break;
6203 case IDX_LEFT: break;
6204 case IDX_USERNAME: username = 1; break;
6205 case IDX_REMOVE: remove = 1; break;
6206 case IDX_REMOVE_TIMER: remove_timer = atoi (optarg);
6207 remove_timer_chgd = 1; break;
6208 case IDX_POTFILE_DISABLE: potfile_disable = 1; break;
6209 case IDX_DEBUG_MODE: debug_mode = atoi (optarg); break;
6210 case IDX_DEBUG_FILE: debug_file = optarg; break;
6211 case IDX_INDUCTION_DIR: induction_dir = optarg; break;
6212 case IDX_OUTFILE_CHECK_DIR: outfile_check_dir = optarg; break;
6213 case IDX_FORCE: force = 1; break;
6214 case IDX_SKIP: skip = atoll (optarg); break;
6215 case IDX_LIMIT: limit = atoll (optarg); break;
6216 case IDX_KEYSPACE: keyspace = 1; break;
6217 case IDX_BENCHMARK: benchmark = 1; break;
6218 case IDX_BENCHMARK_MODE: benchmark_mode = atoi (optarg); break;
6219 case IDX_RESTORE: break;
6220 case IDX_RESTORE_DISABLE: restore_disable = 1; break;
6221 case IDX_STATUS: status = 1; break;
6222 case IDX_STATUS_TIMER: status_timer = atoi (optarg); break;
6223 case IDX_STATUS_AUTOMAT: status_automat = 1; break;
6224 case IDX_LOOPBACK: loopback = 1; break;
6225 case IDX_WEAK_HASH_THRESHOLD:
6226 weak_hash_threshold = atoi (optarg); break;
6227 //case IDX_SESSION: session = optarg; break;
6228 case IDX_SESSION: break;
6229 case IDX_HASH_MODE: hash_mode = atoi (optarg);
6230 hash_mode_chgd = 1; break;
6231 case IDX_RUNTIME: runtime = atoi (optarg);
6232 runtime_chgd = 1; break;
6233 case IDX_ATTACK_MODE: attack_mode = atoi (optarg);
6234 attack_mode_chgd = 1; break;
6235 case IDX_RP_FILE: rp_files[rp_files_cnt++] = optarg; break;
6236 case IDX_RP_GEN: rp_gen = atoi (optarg); break;
6237 case IDX_RP_GEN_FUNC_MIN: rp_gen_func_min = atoi (optarg); break;
6238 case IDX_RP_GEN_FUNC_MAX: rp_gen_func_max = atoi (optarg); break;
6239 case IDX_RP_GEN_SEED: rp_gen_seed = atoi (optarg);
6240 rp_gen_seed_chgd = 1; break;
6241 case IDX_RULE_BUF_L: rule_buf_l = optarg; break;
6242 case IDX_RULE_BUF_R: rule_buf_r = optarg; break;
6243 case IDX_MARKOV_DISABLE: markov_disable = 1; break;
6244 case IDX_MARKOV_CLASSIC: markov_classic = 1; break;
6245 case IDX_MARKOV_THRESHOLD: markov_threshold = atoi (optarg); break;
6246 case IDX_MARKOV_HCSTAT: markov_hcstat = optarg; break;
6247 case IDX_OUTFILE: outfile = optarg; break;
6248 case IDX_OUTFILE_FORMAT: outfile_format = atoi (optarg);
6249 outfile_format_chgd = 1; break;
6250 case IDX_OUTFILE_AUTOHEX_DISABLE:
6251 outfile_autohex = 0; break;
6252 case IDX_OUTFILE_CHECK_TIMER:
6253 outfile_check_timer = atoi (optarg); break;
6254 case IDX_HEX_CHARSET: hex_charset = 1; break;
6255 case IDX_HEX_SALT: hex_salt = 1; break;
6256 case IDX_HEX_WORDLIST: hex_wordlist = 1; break;
6257 case IDX_CPU_AFFINITY: cpu_affinity = optarg; break;
6258 case IDX_GPU_ASYNC: gpu_async = 1; break;
6259 case IDX_GPU_DEVICES: gpu_devices = optarg; break;
6260 case IDX_WORKLOAD_PROFILE: workload_profile = atoi (optarg); break;
6261 case IDX_GPU_ACCEL: gpu_accel = atoi (optarg);
6262 gpu_accel_chgd = 1; break;
6263 case IDX_GPU_LOOPS: gpu_loops = atoi (optarg);
6264 gpu_loops_chgd = 1; break;
6265 case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break;
6266 case IDX_GPU_TEMP_ABORT:
6267 #if _OCL
6268 gpu_temp_abort_chgd = 1;
6269 #endif
6270 gpu_temp_abort = atoi (optarg); break;
6271 case IDX_GPU_TEMP_RETAIN:
6272 #if _OCL
6273 gpu_temp_retain_chgd = 1;
6274 #endif
6275 gpu_temp_retain = atoi (optarg); break;
6276 case IDX_POWERTUNE_ENABLE: powertune_enable = 1; break;
6277 case IDX_LOGFILE_DISABLE: logfile_disable = 1; break;
6278 case IDX_TRUECRYPT_KEYFILES: truecrypt_keyfiles = optarg; break;
6279 case IDX_SEGMENT_SIZE: segment_size = atoi (optarg); break;
6280 case IDX_SCRYPT_TMTO: scrypt_tmto = atoi (optarg); break;
6281 case IDX_SEPARATOR: separator = optarg[0]; break;
6282 case IDX_BITMAP_MIN: bitmap_min = atoi (optarg); break;
6283 case IDX_BITMAP_MAX: bitmap_max = atoi (optarg); break;
6284 case IDX_INCREMENT: increment = 1; break;
6285 case IDX_INCREMENT_MIN: increment_min = atoi (optarg);
6286 increment_min_chgd = 1; break;
6287 case IDX_INCREMENT_MAX: increment_max = atoi (optarg);
6288 increment_max_chgd = 1; break;
6289 case IDX_CUSTOM_CHARSET_1: custom_charset_1 = optarg; break;
6290 case IDX_CUSTOM_CHARSET_2: custom_charset_2 = optarg; break;
6291 case IDX_CUSTOM_CHARSET_3: custom_charset_3 = optarg; break;
6292 case IDX_CUSTOM_CHARSET_4: custom_charset_4 = optarg; break;
6293
6294 default:
6295 log_error ("ERROR: Invalid argument specified");
6296 return (-1);
6297 }
6298 }
6299
6300 if (optopt != 0)
6301 {
6302 log_error ("ERROR: Invalid argument specified");
6303
6304 return (-1);
6305 }
6306
6307 /**
6308 * Inform user things getting started,
6309 * - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
6310 * - we do not need to check algorithm_pos
6311 */
6312
6313 if (quiet == 0)
6314 {
6315 if (benchmark == 1)
6316 {
6317 log_info ("%s v%.2f starting in benchmark-mode...", PROGNAME, (float) VERSION_BIN / 100);
6318
6319 log_info ("");
6320 }
6321 else if (restore == 1)
6322 {
6323 log_info ("%s v%.2f starting in restore-mode...", PROGNAME, (float) VERSION_BIN / 100);
6324
6325 log_info ("");
6326 }
6327 else
6328 {
6329 log_info ("%s v%.2f starting...", PROGNAME, (float) VERSION_BIN / 100);
6330
6331 log_info ("");
6332 }
6333 }
6334
6335 /**
6336 * sanity check
6337 */
6338
6339 if (attack_mode > 7)
6340 {
6341 log_error ("ERROR: Invalid attack-mode specified");
6342
6343 return (-1);
6344 }
6345
6346 if (runtime_chgd && runtime == 0) // just added to remove compiler warnings for runtime_chgd
6347 {
6348 log_error ("ERROR: Invalid runtime specified");
6349
6350 return (-1);
6351 }
6352
6353 if (hash_mode_chgd && hash_mode > 12800) // just added to remove compiler warnings for hash_mode_chgd
6354 {
6355 log_error ("ERROR: Invalid hash-type specified");
6356
6357 return (-1);
6358 }
6359
6360 // renamed hash modes
6361
6362 if (hash_mode_chgd)
6363 {
6364 int n = -1;
6365
6366 switch (hash_mode)
6367 {
6368 case 123: n = 124;
6369 break;
6370 }
6371
6372 if (n >= 0)
6373 {
6374 log_error ("Old -m specified, use -m %d instead", n);
6375
6376 return (-1);
6377 }
6378 }
6379
6380 if (username == 1)
6381 {
6382 if ((hash_mode == 2500) || (hash_mode == 5200) || ((hash_mode >= 6200) && (hash_mode <= 6299)))
6383 {
6384 log_error ("ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (hash_mode));
6385
6386 return (-1);
6387 }
6388 }
6389
6390 if (outfile_format > 16)
6391 {
6392 log_error ("ERROR: Invalid outfile-format specified");
6393
6394 return (-1);
6395 }
6396
6397 if (left == 1)
6398 {
6399 if (outfile_format_chgd == 1)
6400 {
6401 if (outfile_format > 1)
6402 {
6403 log_error ("ERROR: Mixing outfile-format > 1 is not allowed together with left parameter");
6404
6405 return (-1);
6406 }
6407 }
6408 else
6409 {
6410 outfile_format = OUTFILE_FMT_HASH;
6411 }
6412 }
6413
6414 if (show == 1)
6415 {
6416 if (outfile_format_chgd == 1)
6417 {
6418 if ((outfile_format > 7) && (outfile_format < 16))
6419 {
6420 log_error ("ERROR: Mixing outfile-format > 7 is not allowed together with show parameter");
6421
6422 return (-1);
6423 }
6424 }
6425 }
6426
6427 if (increment_min < INCREMENT_MIN)
6428 {
6429 log_error ("ERROR: Invalid increment-min specified");
6430
6431 return (-1);
6432 }
6433
6434 if (increment_max > INCREMENT_MAX)
6435 {
6436 log_error ("ERROR: Invalid increment-max specified");
6437
6438 return (-1);
6439 }
6440
6441 if (increment_min > increment_max)
6442 {
6443 log_error ("ERROR: Invalid increment-min specified");
6444
6445 return (-1);
6446 }
6447
6448 if ((increment == 1) && (attack_mode == ATTACK_MODE_STRAIGHT))
6449 {
6450 log_error ("ERROR: increment is not allowed in attack-mode 0");
6451
6452 return (-1);
6453 }
6454
6455 if ((increment == 0) && (increment_min_chgd == 1))
6456 {
6457 log_error ("ERROR: increment-min is only supported together with increment switch");
6458
6459 return (-1);
6460 }
6461
6462 if ((increment == 0) && (increment_max_chgd == 1))
6463 {
6464 log_error ("ERROR: increment-max is only supported together with increment switch");
6465
6466 return (-1);
6467 }
6468
6469 if (rp_files_cnt && rp_gen)
6470 {
6471 log_error ("ERROR: Use of both rules-file and rules-generate is not supported");
6472
6473 return (-1);
6474 }
6475
6476 if (rp_files_cnt || rp_gen)
6477 {
6478 if (attack_mode != ATTACK_MODE_STRAIGHT)
6479 {
6480 log_error ("ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0");
6481
6482 return (-1);
6483 }
6484 }
6485
6486 if (rp_gen_func_min > rp_gen_func_max)
6487 {
6488 log_error ("ERROR: Invalid rp-gen-func-min specified");
6489
6490 return (-1);
6491 }
6492
6493 if (gpu_accel_chgd == 1)
6494 {
6495 if (workload_profile != WORKLOAD_PROFILE)
6496 {
6497 log_error ("ERROR: gpu-accel parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
6498
6499 return (-1);
6500 }
6501
6502 if (gpu_accel < 1)
6503 {
6504 log_error ("ERROR: Invalid gpu-accel specified");
6505
6506 return (-1);
6507 }
6508
6509 if (gpu_accel > 800)
6510 {
6511 log_error ("ERROR: Invalid gpu-accel specified");
6512
6513 return (-1);
6514 }
6515 }
6516
6517 if (gpu_loops_chgd == 1)
6518 {
6519 if (workload_profile != WORKLOAD_PROFILE)
6520 {
6521 log_error ("ERROR: gpu-loops parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
6522
6523 return (-1);
6524 }
6525
6526 if (gpu_loops < 1)
6527 {
6528 log_error ("ERROR: Invalid gpu-loops specified");
6529
6530 return (-1);
6531 }
6532
6533 if (gpu_loops > 1024)
6534 {
6535 log_error ("ERROR: Invalid gpu-loops specified");
6536
6537 return (-1);
6538 }
6539 }
6540
6541 if (benchmark == 1)
6542 {
6543 if (workload_profile != WORKLOAD_PROFILE)
6544 {
6545 log_error ("ERROR: Using the workload-profile in benchmark mode is not allowed");
6546
6547 return (-1);
6548 }
6549 }
6550
6551 if ((workload_profile < 1) || (workload_profile > 3))
6552 {
6553 log_error ("ERROR: workload-profile %i not available", workload_profile);
6554
6555 return (-1);
6556 }
6557
6558 if (show == 1 || left == 1)
6559 {
6560 attack_mode = ATTACK_MODE_NONE;
6561
6562 if (remove == 1)
6563 {
6564 log_error ("ERROR: Mixing remove parameter not allowed with show parameter or left parameter");
6565
6566 return (-1);
6567 }
6568
6569 if (potfile_disable == 1)
6570 {
6571 log_error ("ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter");
6572
6573 return (-1);
6574 }
6575 }
6576
6577 uint attack_kern = ATTACK_KERN_NONE;
6578
6579 switch (attack_mode)
6580 {
6581 case ATTACK_MODE_STRAIGHT: attack_kern = ATTACK_KERN_STRAIGHT; break;
6582 case ATTACK_MODE_COMBI: attack_kern = ATTACK_KERN_COMBI; break;
6583 case ATTACK_MODE_BF: attack_kern = ATTACK_KERN_BF; break;
6584 case ATTACK_MODE_HYBRID1: attack_kern = ATTACK_KERN_COMBI; break;
6585 case ATTACK_MODE_HYBRID2: attack_kern = ATTACK_KERN_COMBI; break;
6586 }
6587
6588 if (benchmark == 0)
6589 {
6590 if (keyspace == 1)
6591 {
6592 int num_additional_params = 1;
6593
6594 if (attack_kern == ATTACK_KERN_COMBI)
6595 {
6596 num_additional_params = 2;
6597 }
6598
6599 int keyspace_wordlist_specified = myargc - optind - num_additional_params;
6600
6601 if (keyspace_wordlist_specified == 0) optind--;
6602 }
6603
6604 if (attack_kern == ATTACK_KERN_NONE)
6605 {
6606 if ((optind + 1) != myargc)
6607 {
6608 usage_mini_print (myargv[0]);
6609
6610 return (-1);
6611 }
6612 }
6613 else if (attack_kern == ATTACK_KERN_STRAIGHT)
6614 {
6615 if ((optind + 1) > myargc)
6616 {
6617 usage_mini_print (myargv[0]);
6618
6619 return (-1);
6620 }
6621 }
6622 else if (attack_kern == ATTACK_KERN_COMBI)
6623 {
6624 if ((optind + 3) != myargc)
6625 {
6626 usage_mini_print (myargv[0]);
6627
6628 return (-1);
6629 }
6630 }
6631 else if (attack_kern == ATTACK_KERN_BF)
6632 {
6633 if ((optind + 1) > myargc)
6634 {
6635 usage_mini_print (myargv[0]);
6636
6637 return (-1);
6638 }
6639 }
6640 else
6641 {
6642 usage_mini_print (myargv[0]);
6643
6644 return (-1);
6645 }
6646 }
6647 else
6648 {
6649 if (myargv[optind] != 0)
6650 {
6651 log_error ("ERROR: Invalid argument for benchmark mode specified");
6652
6653 return (-1);
6654 }
6655
6656 if (attack_mode_chgd == 1)
6657 {
6658 if (attack_mode != ATTACK_MODE_BF)
6659 {
6660 log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode");
6661
6662 return (-1);
6663 }
6664 }
6665
6666 if (benchmark_mode == 0)
6667 {
6668 // nothing to do
6669 }
6670 else if (benchmark_mode == 1)
6671 {
6672 if (gpu_accel_chgd == 1 || gpu_loops_chgd == 1)
6673 {
6674 log_error ("ERROR: Benchmark-mode 1 does not allow gpu-accel or gpu-loops changed");
6675
6676 return (-1);
6677 }
6678 }
6679 else
6680 {
6681 log_error ("ERROR: Benchmark-mode must be 0 or 1");
6682
6683 return (-1);
6684 }
6685 }
6686
6687 if (skip != 0 && limit != 0)
6688 {
6689 limit += skip;
6690 }
6691
6692 if (keyspace == 1)
6693 {
6694 if (show == 1)
6695 {
6696 log_error ("ERROR: Mixing show parameter not supported with keyspace parameter");
6697
6698 return (-1);
6699 }
6700 else if (left == 1)
6701 {
6702 log_error ("ERROR: Mixing left parameter not supported wiht keyspace parameter");
6703
6704 return (-1);
6705 }
6706
6707 potfile_disable = 1;
6708
6709 restore_disable = 1;
6710
6711 restore = 0;
6712
6713 weak_hash_threshold = 0;
6714
6715 quiet = 1;
6716 }
6717
6718 if (remove_timer_chgd == 1)
6719 {
6720 if (remove == 0)
6721 {
6722 log_error ("ERROR: Parameter remove-timer require parameter remove enabled");
6723
6724 return (-1);
6725 }
6726
6727 if (remove_timer < 1)
6728 {
6729 log_error ("ERROR: Parameter remove-timer must have a value greater than or equal to 1");
6730
6731 return (-1);
6732 }
6733 }
6734
6735 if (loopback == 1)
6736 {
6737 if (attack_mode == ATTACK_MODE_BF)
6738 {
6739 log_error ("ERROR: Parameter loopback not allowed in attack-mode 3");
6740
6741 return (-1);
6742 }
6743 else if (attack_mode == ATTACK_MODE_STRAIGHT)
6744 {
6745 if ((rp_files_cnt == 0) && (rp_gen == 0))
6746 {
6747 log_error ("ERROR: Parameter loopback not allowed without rules-file or rules-generate");
6748
6749 return (-1);
6750 }
6751 }
6752 }
6753
6754 if (debug_mode > 0)
6755 {
6756 if (attack_mode != ATTACK_MODE_STRAIGHT)
6757 {
6758 log_error ("ERROR: Parameter debug-mode option is only available with attack-mode 0");
6759
6760 return (-1);
6761 }
6762
6763 if ((rp_files_cnt == 0) && (rp_gen == 0))
6764 {
6765 log_error ("ERROR: Parameter debug-mode not allowed without rules-file or rules-generate");
6766
6767 return (-1);
6768 }
6769 }
6770
6771 if (debug_mode > 4)
6772 {
6773 log_error ("ERROR: Invalid debug-mode specified");
6774
6775 return (-1);
6776 }
6777
6778 if (debug_file != NULL)
6779 {
6780 if (debug_mode < 1)
6781 {
6782 log_error ("ERROR: Parameter debug-file requires parameter debug-mode to be set");
6783
6784 return (-1);
6785 }
6786 }
6787
6788 if (induction_dir != NULL)
6789 {
6790 if (attack_mode == ATTACK_MODE_BF)
6791 {
6792 log_error ("ERROR: Parameter induction-dir not allowed with brute-force attacks");
6793
6794 return (-1);
6795 }
6796 }
6797
6798 /**
6799 * induction directory
6800 */
6801
6802 char *induction_directory = NULL;
6803
6804 if (attack_mode != ATTACK_MODE_BF)
6805 {
6806 if (induction_dir == NULL)
6807 {
6808 induction_directory = (char *) mymalloc (session_size);
6809
6810 snprintf (induction_directory, session_size - 1, "%s.%s", session, INDUCT_DIR);
6811
6812 // create induction folder if it does not already exist
6813
6814 if (keyspace == 0)
6815 {
6816 if (rmdir (induction_directory) == -1)
6817 {
6818 if (errno == ENOENT)
6819 {
6820 // good, we can ignore
6821 }
6822 else if (errno == ENOTEMPTY)
6823 {
6824 char *induction_directory_mv = (char *) mymalloc (session_size);
6825
6826 snprintf (induction_directory_mv, session_size - 1, "%s.induct.%d", session, (int) proc_start);
6827
6828 if (rename (induction_directory, induction_directory_mv) != 0)
6829 {
6830 log_error ("ERROR: Rename directory %s to %s: %s", induction_directory, induction_directory_mv, strerror (errno));
6831
6832 return (-1);
6833 }
6834 }
6835 else
6836 {
6837 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6838
6839 return (-1);
6840 }
6841 }
6842
6843 #ifdef _WIN
6844 #define mkdir(name,mode) mkdir (name)
6845 #endif
6846
6847 if (mkdir (induction_directory, 0700) == -1)
6848 {
6849 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6850
6851 return (-1);
6852 }
6853 }
6854 }
6855 else
6856 {
6857 induction_directory = induction_dir;
6858 }
6859 }
6860
6861 data.induction_directory = induction_directory;
6862
6863 /**
6864 * loopback
6865 */
6866
6867 size_t loopback_size = session_size + strlen (LOOPBACK_FILE) + 12;
6868
6869 char *loopback_file = (char *) mymalloc (loopback_size);
6870
6871 /**
6872 * outfile-check directory
6873 */
6874
6875 char *outfile_check_directory = NULL;
6876
6877 if (outfile_check_dir == NULL)
6878 {
6879 outfile_check_directory = (char *) mymalloc (session_size);
6880
6881 snprintf (outfile_check_directory, session_size - 1, "%s.%s", session, OUTFILES_DIR);
6882 }
6883 else
6884 {
6885 outfile_check_directory = outfile_check_dir;
6886 }
6887
6888 data.outfile_check_directory = outfile_check_directory;
6889
6890 if (keyspace == 0)
6891 {
6892 struct stat outfile_check_stat;
6893
6894 if (stat (outfile_check_directory, &outfile_check_stat) == 0)
6895 {
6896 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
6897
6898 if (is_dir == 0)
6899 {
6900 log_error ("ERROR: Directory specified in outfile-check '%s' is not a valid directory", outfile_check_directory);
6901
6902 return (-1);
6903 }
6904 }
6905 else if (outfile_check_dir == NULL)
6906 {
6907 #ifdef _WIN
6908 #define mkdir(name,mode) mkdir (name)
6909 #endif
6910
6911 if (mkdir (outfile_check_directory, 0700) == -1)
6912 {
6913 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
6914
6915 return (-1);
6916 }
6917 }
6918 }
6919
6920 /**
6921 * special other stuff
6922 */
6923
6924 if (hash_mode == 9710)
6925 {
6926 outfile_format = 5;
6927 outfile_format_chgd = 1;
6928 }
6929
6930 if (hash_mode == 9810)
6931 {
6932 outfile_format = 5;
6933 outfile_format_chgd = 1;
6934 }
6935
6936 if (hash_mode == 10410)
6937 {
6938 outfile_format = 5;
6939 outfile_format_chgd = 1;
6940 }
6941
6942 /**
6943 * store stuff
6944 */
6945
6946 data.hash_mode = hash_mode;
6947 data.restore = restore;
6948 data.restore_timer = restore_timer;
6949 data.restore_disable = restore_disable;
6950 data.status = status;
6951 data.status_timer = status_timer;
6952 data.status_automat = status_automat;
6953 data.loopback = loopback;
6954 data.runtime = runtime;
6955 data.remove = remove;
6956 data.remove_timer = remove_timer;
6957 data.debug_mode = debug_mode;
6958 data.debug_file = debug_file;
6959 data.username = username;
6960 data.quiet = quiet;
6961 data.outfile = outfile;
6962 data.outfile_format = outfile_format;
6963 data.outfile_autohex = outfile_autohex;
6964 data.hex_charset = hex_charset;
6965 data.hex_salt = hex_salt;
6966 data.hex_wordlist = hex_wordlist;
6967 data.separator = separator;
6968 data.rp_files = rp_files;
6969 data.rp_files_cnt = rp_files_cnt;
6970 data.rp_gen = rp_gen;
6971 data.rp_gen_seed = rp_gen_seed;
6972 data.force = force;
6973 data.benchmark = benchmark;
6974 data.skip = skip;
6975 data.limit = limit;
6976 data.powertune_enable = powertune_enable;
6977 data.logfile_disable = logfile_disable;
6978 data.truecrypt_keyfiles = truecrypt_keyfiles;
6979 data.scrypt_tmto = scrypt_tmto;
6980
6981 /**
6982 * install_dir
6983 */
6984
6985 char *install_dir = get_install_dir (myargv[0]);
6986
6987 data.install_dir = install_dir;
6988
6989 /**
6990 * cpu affinity
6991 */
6992
6993 if (cpu_affinity)
6994 {
6995 set_cpu_affinity (cpu_affinity);
6996 }
6997
6998 if (rp_gen_seed_chgd == 0)
6999 {
7000 srand (proc_start);
7001 }
7002 else
7003 {
7004 srand (rp_gen_seed);
7005 }
7006
7007 /**
7008 * logfile init
7009 */
7010
7011 if (logfile_disable == 0)
7012 {
7013 size_t logfile_size = strlen (session) + 32;
7014
7015 char *logfile = (char *) mymalloc (logfile_size);
7016
7017 snprintf (logfile, logfile_size - 1, "%s.log", session);
7018
7019 data.logfile = logfile;
7020
7021 char *topid = logfile_generate_topid ();
7022
7023 data.topid = topid;
7024 }
7025
7026 // logfile_append() checks for logfile_disable internally to make it easier from here
7027
7028 #define logfile_top_msg(msg) logfile_append ("%s\t%s", data.topid, (msg));
7029 #define logfile_sub_msg(msg) logfile_append ("%s\t%s\t%s", data.topid, data.subid, (msg));
7030 #define logfile_top_var_uint64(var,val) logfile_append ("%s\t%s\t%llu", data.topid, (var), (val));
7031 #define logfile_sub_var_uint64(var,val) logfile_append ("%s\t%s\t%s\t%llu", data.topid, data.subid, (var), (val));
7032 #define logfile_top_var_uint(var,val) logfile_append ("%s\t%s\t%u", data.topid, (var), (val));
7033 #define logfile_sub_var_uint(var,val) logfile_append ("%s\t%s\t%s\t%u", data.topid, data.subid, (var), (val));
7034 #define logfile_top_var_char(var,val) logfile_append ("%s\t%s\t%c", data.topid, (var), (val));
7035 #define logfile_sub_var_char(var,val) logfile_append ("%s\t%s\t%s\t%c", data.topid, data.subid, (var), (val));
7036 #define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append ("%s\t%s\t%s", data.topid, (var), (val));
7037 #define logfile_sub_var_string(var,val) if ((val) != NULL) logfile_append ("%s\t%s\t%s\t%s", data.topid, data.subid, (var), (val));
7038
7039 #define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var));
7040 #define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
7041 #define logfile_top_uint(var) logfile_top_var_uint (#var, (var));
7042 #define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var));
7043 #define logfile_top_char(var) logfile_top_var_char (#var, (var));
7044 #define logfile_sub_char(var) logfile_sub_var_char (#var, (var));
7045 #define logfile_top_string(var) logfile_top_var_string (#var, (var));
7046 #define logfile_sub_string(var) logfile_sub_var_string (#var, (var));
7047
7048 logfile_top_msg ("START");
7049
7050 logfile_top_uint (attack_mode);
7051 logfile_top_uint (attack_kern);
7052 logfile_top_uint (benchmark);
7053 logfile_top_uint (benchmark_mode);
7054 logfile_top_uint (bitmap_min);
7055 logfile_top_uint (bitmap_max);
7056 logfile_top_uint (debug_mode);
7057 logfile_top_uint (force);
7058 logfile_top_uint (gpu_accel);
7059 logfile_top_uint (gpu_async);
7060 logfile_top_uint (gpu_loops);
7061 logfile_top_uint (gpu_temp_abort);
7062 logfile_top_uint (gpu_temp_disable);
7063 logfile_top_uint (gpu_temp_retain);
7064 logfile_top_uint (hash_mode);
7065 logfile_top_uint (hex_charset);
7066 logfile_top_uint (hex_salt);
7067 logfile_top_uint (hex_wordlist);
7068 logfile_top_uint (increment);
7069 logfile_top_uint (increment_max);
7070 logfile_top_uint (increment_min);
7071 logfile_top_uint (keyspace);
7072 logfile_top_uint (left);
7073 logfile_top_uint (logfile_disable);
7074 logfile_top_uint (loopback);
7075 logfile_top_uint (markov_classic);
7076 logfile_top_uint (markov_disable);
7077 logfile_top_uint (markov_threshold);
7078 logfile_top_uint (outfile_autohex);
7079 logfile_top_uint (outfile_check_timer);
7080 logfile_top_uint (outfile_format);
7081 logfile_top_uint (potfile_disable);
7082 logfile_top_uint (powertune_enable);
7083 logfile_top_uint (scrypt_tmto);
7084 logfile_top_uint (quiet);
7085 logfile_top_uint (remove);
7086 logfile_top_uint (remove_timer);
7087 logfile_top_uint (restore);
7088 logfile_top_uint (restore_disable);
7089 logfile_top_uint (restore_timer);
7090 logfile_top_uint (rp_gen);
7091 logfile_top_uint (rp_gen_func_max);
7092 logfile_top_uint (rp_gen_func_min);
7093 logfile_top_uint (rp_gen_seed);
7094 logfile_top_uint (runtime);
7095 logfile_top_uint (segment_size);
7096 logfile_top_uint (show);
7097 logfile_top_uint (status);
7098 logfile_top_uint (status_automat);
7099 logfile_top_uint (status_timer);
7100 logfile_top_uint (usage);
7101 logfile_top_uint (username);
7102 logfile_top_uint (version);
7103 logfile_top_uint (weak_hash_threshold);
7104 logfile_top_uint (workload_profile);
7105 logfile_top_uint64 (limit);
7106 logfile_top_uint64 (skip);
7107 logfile_top_char (separator);
7108 logfile_top_string (cpu_affinity);
7109 logfile_top_string (custom_charset_1);
7110 logfile_top_string (custom_charset_2);
7111 logfile_top_string (custom_charset_3);
7112 logfile_top_string (custom_charset_4);
7113 logfile_top_string (debug_file);
7114 logfile_top_string (gpu_devices);
7115 logfile_top_string (induction_dir);
7116 logfile_top_string (markov_hcstat);
7117 logfile_top_string (outfile);
7118 logfile_top_string (outfile_check_dir);
7119 logfile_top_string (rule_buf_l);
7120 logfile_top_string (rule_buf_r);
7121 logfile_top_string (session);
7122 logfile_top_string (truecrypt_keyfiles);
7123
7124 /**
7125 * devices
7126 */
7127
7128 uint gpu_devicemask = devices_to_devicemask (gpu_devices);
7129
7130 /**
7131 * benchmark
7132 */
7133
7134 if (benchmark == 1)
7135 {
7136 /**
7137 * disable useless stuff for benchmark
7138 */
7139
7140 restore_timer = 0;
7141 status_timer = 0;
7142 restore_disable = 1;
7143 potfile_disable = 1;
7144 weak_hash_threshold = 0;
7145
7146 data.restore_timer = restore_timer;
7147 data.status_timer = status_timer;
7148 data.restore_disable = restore_disable;
7149
7150 if (benchmark_mode == 1)
7151 {
7152 markov_disable = 1;
7153 }
7154
7155 /**
7156 * force attack mode to be bruteforce
7157 */
7158
7159 attack_mode = ATTACK_MODE_BF;
7160 attack_kern = ATTACK_KERN_BF;
7161
7162 if (runtime_chgd == 0)
7163 {
7164 runtime = 4;
7165
7166 if (benchmark_mode == 1) runtime = 17;
7167
7168 data.runtime = runtime;
7169 }
7170 }
7171
7172 /**
7173 * config
7174 */
7175
7176 uint hash_type = 0;
7177 uint salt_type = 0;
7178 uint attack_exec = 0;
7179 uint opts_type = 0;
7180 uint kern_type = 0;
7181 uint dgst_size = 0;
7182 uint esalt_size = 0;
7183 uint opti_type = 0;
7184 uint dgst_pos0 = -1;
7185 uint dgst_pos1 = -1;
7186 uint dgst_pos2 = -1;
7187 uint dgst_pos3 = -1;
7188
7189 int (*parse_func) (char *, uint, hash_t *);
7190 int (*sort_by_digest) (const void *, const void *);
7191
7192 uint algorithm_pos = 0;
7193 uint algorithm_max = 1;
7194
7195 uint *algorithms = default_benchmark_algorithms;
7196
7197 if (benchmark == 1 && hash_mode_chgd == 0) algorithm_max = NUM_DEFAULT_BENCHMARK_ALGORITHMS;
7198
7199 for (algorithm_pos = 0; algorithm_pos < algorithm_max; algorithm_pos++)
7200 {
7201 /*
7202 * We need to reset 'rd' in benchmark mode otherwise when the user hits 'bypass'
7203 * the following algos are skipped entirely
7204 */
7205
7206 if (algorithm_pos > 0)
7207 {
7208 local_free (rd);
7209
7210 rd = init_restore (argc, argv);
7211
7212 data.rd = rd;
7213 }
7214
7215 /**
7216 * update hash_mode in case of multihash benchmark
7217 */
7218
7219 if (benchmark == 1)
7220 {
7221 if (hash_mode_chgd == 0)
7222 {
7223 hash_mode = algorithms[algorithm_pos];
7224
7225 data.hash_mode = hash_mode;
7226 }
7227
7228 quiet = 1;
7229
7230 data.quiet = quiet;
7231 }
7232
7233 switch (hash_mode)
7234 {
7235 case 0: hash_type = HASH_TYPE_MD5;
7236 salt_type = SALT_TYPE_NONE;
7237 attack_exec = ATTACK_EXEC_ON_GPU;
7238 opts_type = OPTS_TYPE_PT_GENERATE_LE
7239 | OPTS_TYPE_PT_ADD80
7240 | OPTS_TYPE_PT_ADDBITS14;
7241 kern_type = KERN_TYPE_MD5;
7242 dgst_size = DGST_SIZE_4_4;
7243 parse_func = md5_parse_hash;
7244 sort_by_digest = sort_by_digest_4_4;
7245 opti_type = OPTI_TYPE_ZERO_BYTE
7246 | OPTI_TYPE_PRECOMPUTE_INIT
7247 | OPTI_TYPE_PRECOMPUTE_MERKLE
7248 | OPTI_TYPE_SCALAR_MODE
7249 | OPTI_TYPE_MEET_IN_MIDDLE
7250 | OPTI_TYPE_EARLY_SKIP
7251 | OPTI_TYPE_NOT_ITERATED
7252 | OPTI_TYPE_NOT_SALTED
7253 | OPTI_TYPE_RAW_HASH;
7254 dgst_pos0 = 0;
7255 dgst_pos1 = 3;
7256 dgst_pos2 = 2;
7257 dgst_pos3 = 1;
7258 break;
7259
7260 case 10: hash_type = HASH_TYPE_MD5;
7261 salt_type = SALT_TYPE_INTERN;
7262 attack_exec = ATTACK_EXEC_ON_GPU;
7263 opts_type = OPTS_TYPE_PT_GENERATE_LE
7264 | OPTS_TYPE_ST_ADD80
7265 | OPTS_TYPE_ST_ADDBITS14;
7266 kern_type = KERN_TYPE_MD5_PWSLT;
7267 dgst_size = DGST_SIZE_4_4;
7268 parse_func = md5s_parse_hash;
7269 sort_by_digest = sort_by_digest_4_4;
7270 opti_type = OPTI_TYPE_ZERO_BYTE
7271 | OPTI_TYPE_PRECOMPUTE_INIT
7272 | OPTI_TYPE_PRECOMPUTE_MERKLE
7273 | OPTI_TYPE_SCALAR_MODE
7274 | OPTI_TYPE_MEET_IN_MIDDLE
7275 | OPTI_TYPE_EARLY_SKIP
7276 | OPTI_TYPE_NOT_ITERATED
7277 | OPTI_TYPE_APPENDED_SALT
7278 | OPTI_TYPE_RAW_HASH;
7279 dgst_pos0 = 0;
7280 dgst_pos1 = 3;
7281 dgst_pos2 = 2;
7282 dgst_pos3 = 1;
7283 break;
7284
7285 case 11: hash_type = HASH_TYPE_MD5;
7286 salt_type = SALT_TYPE_INTERN;
7287 attack_exec = ATTACK_EXEC_ON_GPU;
7288 opts_type = OPTS_TYPE_PT_GENERATE_LE
7289 | OPTS_TYPE_ST_ADD80
7290 | OPTS_TYPE_ST_ADDBITS14;
7291 kern_type = KERN_TYPE_MD5_PWSLT;
7292 dgst_size = DGST_SIZE_4_4;
7293 parse_func = joomla_parse_hash;
7294 sort_by_digest = sort_by_digest_4_4;
7295 opti_type = OPTI_TYPE_ZERO_BYTE
7296 | OPTI_TYPE_PRECOMPUTE_INIT
7297 | OPTI_TYPE_PRECOMPUTE_MERKLE
7298 | OPTI_TYPE_SCALAR_MODE
7299 | OPTI_TYPE_MEET_IN_MIDDLE
7300 | OPTI_TYPE_EARLY_SKIP
7301 | OPTI_TYPE_NOT_ITERATED
7302 | OPTI_TYPE_APPENDED_SALT
7303 | OPTI_TYPE_RAW_HASH;
7304 dgst_pos0 = 0;
7305 dgst_pos1 = 3;
7306 dgst_pos2 = 2;
7307 dgst_pos3 = 1;
7308 break;
7309
7310 case 12: hash_type = HASH_TYPE_MD5;
7311 salt_type = SALT_TYPE_INTERN;
7312 attack_exec = ATTACK_EXEC_ON_GPU;
7313 opts_type = OPTS_TYPE_PT_GENERATE_LE
7314 | OPTS_TYPE_ST_ADD80
7315 | OPTS_TYPE_ST_ADDBITS14;
7316 kern_type = KERN_TYPE_MD5_PWSLT;
7317 dgst_size = DGST_SIZE_4_4;
7318 parse_func = postgresql_parse_hash;
7319 sort_by_digest = sort_by_digest_4_4;
7320 opti_type = OPTI_TYPE_ZERO_BYTE
7321 | OPTI_TYPE_PRECOMPUTE_INIT
7322 | OPTI_TYPE_PRECOMPUTE_MERKLE
7323 | OPTI_TYPE_SCALAR_MODE
7324 | OPTI_TYPE_MEET_IN_MIDDLE
7325 | OPTI_TYPE_EARLY_SKIP
7326 | OPTI_TYPE_NOT_ITERATED
7327 | OPTI_TYPE_APPENDED_SALT
7328 | OPTI_TYPE_RAW_HASH;
7329 dgst_pos0 = 0;
7330 dgst_pos1 = 3;
7331 dgst_pos2 = 2;
7332 dgst_pos3 = 1;
7333 break;
7334
7335 case 20: hash_type = HASH_TYPE_MD5;
7336 salt_type = SALT_TYPE_INTERN;
7337 attack_exec = ATTACK_EXEC_ON_GPU;
7338 opts_type = OPTS_TYPE_PT_GENERATE_LE
7339 | OPTS_TYPE_PT_ADD80
7340 | OPTS_TYPE_PT_ADDBITS14;
7341 kern_type = KERN_TYPE_MD5_SLTPW;
7342 dgst_size = DGST_SIZE_4_4;
7343 parse_func = md5s_parse_hash;
7344 sort_by_digest = sort_by_digest_4_4;
7345 opti_type = OPTI_TYPE_ZERO_BYTE
7346 | OPTI_TYPE_PRECOMPUTE_INIT
7347 | OPTI_TYPE_PRECOMPUTE_MERKLE
7348 | OPTI_TYPE_EARLY_SKIP
7349 | OPTI_TYPE_NOT_ITERATED
7350 | OPTI_TYPE_PREPENDED_SALT
7351 | OPTI_TYPE_RAW_HASH;
7352 dgst_pos0 = 0;
7353 dgst_pos1 = 3;
7354 dgst_pos2 = 2;
7355 dgst_pos3 = 1;
7356 break;
7357
7358 case 21: hash_type = HASH_TYPE_MD5;
7359 salt_type = SALT_TYPE_INTERN;
7360 attack_exec = ATTACK_EXEC_ON_GPU;
7361 opts_type = OPTS_TYPE_PT_GENERATE_LE
7362 | OPTS_TYPE_PT_ADD80
7363 | OPTS_TYPE_PT_ADDBITS14;
7364 kern_type = KERN_TYPE_MD5_SLTPW;
7365 dgst_size = DGST_SIZE_4_4;
7366 parse_func = osc_parse_hash;
7367 sort_by_digest = sort_by_digest_4_4;
7368 opti_type = OPTI_TYPE_ZERO_BYTE
7369 | OPTI_TYPE_PRECOMPUTE_INIT
7370 | OPTI_TYPE_PRECOMPUTE_MERKLE
7371 | OPTI_TYPE_EARLY_SKIP
7372 | OPTI_TYPE_NOT_ITERATED
7373 | OPTI_TYPE_PREPENDED_SALT
7374 | OPTI_TYPE_RAW_HASH;
7375 dgst_pos0 = 0;
7376 dgst_pos1 = 3;
7377 dgst_pos2 = 2;
7378 dgst_pos3 = 1;
7379 break;
7380
7381 case 22: hash_type = HASH_TYPE_MD5;
7382 salt_type = SALT_TYPE_EMBEDDED;
7383 attack_exec = ATTACK_EXEC_ON_GPU;
7384 opts_type = OPTS_TYPE_PT_GENERATE_LE
7385 | OPTS_TYPE_PT_ADD80
7386 | OPTS_TYPE_PT_ADDBITS14;
7387 kern_type = KERN_TYPE_MD5_SLTPW;
7388 dgst_size = DGST_SIZE_4_4;
7389 parse_func = netscreen_parse_hash;
7390 sort_by_digest = sort_by_digest_4_4;
7391 opti_type = OPTI_TYPE_ZERO_BYTE
7392 | OPTI_TYPE_PRECOMPUTE_INIT
7393 | OPTI_TYPE_PRECOMPUTE_MERKLE
7394 | OPTI_TYPE_EARLY_SKIP
7395 | OPTI_TYPE_NOT_ITERATED
7396 | OPTI_TYPE_PREPENDED_SALT
7397 | OPTI_TYPE_RAW_HASH;
7398 dgst_pos0 = 0;
7399 dgst_pos1 = 3;
7400 dgst_pos2 = 2;
7401 dgst_pos3 = 1;
7402 break;
7403
7404 case 23: hash_type = HASH_TYPE_MD5;
7405 salt_type = SALT_TYPE_EMBEDDED;
7406 attack_exec = ATTACK_EXEC_ON_GPU;
7407 opts_type = OPTS_TYPE_PT_GENERATE_LE
7408 | OPTS_TYPE_PT_ADD80
7409 | OPTS_TYPE_PT_ADDBITS14;
7410 kern_type = KERN_TYPE_MD5_SLTPW;
7411 dgst_size = DGST_SIZE_4_4;
7412 parse_func = skype_parse_hash;
7413 sort_by_digest = sort_by_digest_4_4;
7414 opti_type = OPTI_TYPE_ZERO_BYTE
7415 | OPTI_TYPE_PRECOMPUTE_INIT
7416 | OPTI_TYPE_PRECOMPUTE_MERKLE
7417 | OPTI_TYPE_EARLY_SKIP
7418 | OPTI_TYPE_NOT_ITERATED
7419 | OPTI_TYPE_PREPENDED_SALT
7420 | OPTI_TYPE_RAW_HASH;
7421 dgst_pos0 = 0;
7422 dgst_pos1 = 3;
7423 dgst_pos2 = 2;
7424 dgst_pos3 = 1;
7425 break;
7426
7427 case 30: hash_type = HASH_TYPE_MD5;
7428 salt_type = SALT_TYPE_INTERN;
7429 attack_exec = ATTACK_EXEC_ON_GPU;
7430 opts_type = OPTS_TYPE_PT_GENERATE_LE
7431 | OPTS_TYPE_PT_UNICODE
7432 | OPTS_TYPE_ST_ADD80
7433 | OPTS_TYPE_ST_ADDBITS14;
7434 kern_type = KERN_TYPE_MD5_PWUSLT;
7435 dgst_size = DGST_SIZE_4_4;
7436 parse_func = md5s_parse_hash;
7437 sort_by_digest = sort_by_digest_4_4;
7438 opti_type = OPTI_TYPE_ZERO_BYTE
7439 | OPTI_TYPE_PRECOMPUTE_INIT
7440 | OPTI_TYPE_PRECOMPUTE_MERKLE
7441 | OPTI_TYPE_SCALAR_MODE
7442 | OPTI_TYPE_MEET_IN_MIDDLE
7443 | OPTI_TYPE_EARLY_SKIP
7444 | OPTI_TYPE_NOT_ITERATED
7445 | OPTI_TYPE_APPENDED_SALT
7446 | OPTI_TYPE_RAW_HASH;
7447 dgst_pos0 = 0;
7448 dgst_pos1 = 3;
7449 dgst_pos2 = 2;
7450 dgst_pos3 = 1;
7451 break;
7452
7453 case 40: hash_type = HASH_TYPE_MD5;
7454 salt_type = SALT_TYPE_INTERN;
7455 attack_exec = ATTACK_EXEC_ON_GPU;
7456 opts_type = OPTS_TYPE_PT_GENERATE_LE
7457 | OPTS_TYPE_PT_ADD80
7458 | OPTS_TYPE_PT_ADDBITS14
7459 | OPTS_TYPE_PT_UNICODE;
7460 kern_type = KERN_TYPE_MD5_SLTPWU;
7461 dgst_size = DGST_SIZE_4_4;
7462 parse_func = md5s_parse_hash;
7463 sort_by_digest = sort_by_digest_4_4;
7464 opti_type = OPTI_TYPE_ZERO_BYTE
7465 | OPTI_TYPE_PRECOMPUTE_INIT
7466 | OPTI_TYPE_PRECOMPUTE_MERKLE
7467 | OPTI_TYPE_EARLY_SKIP
7468 | OPTI_TYPE_NOT_ITERATED
7469 | OPTI_TYPE_PREPENDED_SALT
7470 | OPTI_TYPE_RAW_HASH;
7471 dgst_pos0 = 0;
7472 dgst_pos1 = 3;
7473 dgst_pos2 = 2;
7474 dgst_pos3 = 1;
7475 break;
7476
7477 case 50: hash_type = HASH_TYPE_MD5;
7478 salt_type = SALT_TYPE_INTERN;
7479 attack_exec = ATTACK_EXEC_ON_GPU;
7480 opts_type = OPTS_TYPE_PT_GENERATE_LE
7481 | OPTS_TYPE_ST_ADD80
7482 | OPTS_TYPE_ST_ADDBITS14;
7483 kern_type = KERN_TYPE_HMACMD5_PW;
7484 dgst_size = DGST_SIZE_4_4;
7485 parse_func = hmacmd5_parse_hash;
7486 sort_by_digest = sort_by_digest_4_4;
7487 opti_type = OPTI_TYPE_ZERO_BYTE
7488 | OPTI_TYPE_NOT_ITERATED;
7489 dgst_pos0 = 0;
7490 dgst_pos1 = 3;
7491 dgst_pos2 = 2;
7492 dgst_pos3 = 1;
7493 break;
7494
7495 case 60: hash_type = HASH_TYPE_MD5;
7496 salt_type = SALT_TYPE_INTERN;
7497 attack_exec = ATTACK_EXEC_ON_GPU;
7498 opts_type = OPTS_TYPE_PT_GENERATE_LE
7499 | OPTS_TYPE_PT_ADD80
7500 | OPTS_TYPE_PT_ADDBITS14;
7501 kern_type = KERN_TYPE_HMACMD5_SLT;
7502 dgst_size = DGST_SIZE_4_4;
7503 parse_func = hmacmd5_parse_hash;
7504 sort_by_digest = sort_by_digest_4_4;
7505 opti_type = OPTI_TYPE_ZERO_BYTE
7506 | OPTI_TYPE_NOT_ITERATED;
7507 dgst_pos0 = 0;
7508 dgst_pos1 = 3;
7509 dgst_pos2 = 2;
7510 dgst_pos3 = 1;
7511 break;
7512
7513 case 100: hash_type = HASH_TYPE_SHA1;
7514 salt_type = SALT_TYPE_NONE;
7515 attack_exec = ATTACK_EXEC_ON_GPU;
7516 opts_type = OPTS_TYPE_PT_GENERATE_BE
7517 | OPTS_TYPE_PT_ADD80
7518 | OPTS_TYPE_PT_ADDBITS15;
7519 kern_type = KERN_TYPE_SHA1;
7520 dgst_size = DGST_SIZE_4_5;
7521 parse_func = sha1_parse_hash;
7522 sort_by_digest = sort_by_digest_4_5;
7523 opti_type = OPTI_TYPE_ZERO_BYTE
7524 | OPTI_TYPE_PRECOMPUTE_INIT
7525 | OPTI_TYPE_PRECOMPUTE_MERKLE
7526 | OPTI_TYPE_SCALAR_MODE
7527 | OPTI_TYPE_EARLY_SKIP
7528 | OPTI_TYPE_NOT_ITERATED
7529 | OPTI_TYPE_NOT_SALTED
7530 | OPTI_TYPE_RAW_HASH;
7531 dgst_pos0 = 3;
7532 dgst_pos1 = 4;
7533 dgst_pos2 = 2;
7534 dgst_pos3 = 1;
7535 break;
7536
7537 case 101: hash_type = HASH_TYPE_SHA1;
7538 salt_type = SALT_TYPE_NONE;
7539 attack_exec = ATTACK_EXEC_ON_GPU;
7540 opts_type = OPTS_TYPE_PT_GENERATE_BE
7541 | OPTS_TYPE_PT_ADD80
7542 | OPTS_TYPE_PT_ADDBITS15;
7543 kern_type = KERN_TYPE_SHA1;
7544 dgst_size = DGST_SIZE_4_5;
7545 parse_func = sha1b64_parse_hash;
7546 sort_by_digest = sort_by_digest_4_5;
7547 opti_type = OPTI_TYPE_ZERO_BYTE
7548 | OPTI_TYPE_PRECOMPUTE_INIT
7549 | OPTI_TYPE_PRECOMPUTE_MERKLE
7550 | OPTI_TYPE_SCALAR_MODE
7551 | OPTI_TYPE_EARLY_SKIP
7552 | OPTI_TYPE_NOT_ITERATED
7553 | OPTI_TYPE_NOT_SALTED
7554 | OPTI_TYPE_RAW_HASH;
7555 dgst_pos0 = 3;
7556 dgst_pos1 = 4;
7557 dgst_pos2 = 2;
7558 dgst_pos3 = 1;
7559 break;
7560
7561 case 110: hash_type = HASH_TYPE_SHA1;
7562 salt_type = SALT_TYPE_INTERN;
7563 attack_exec = ATTACK_EXEC_ON_GPU;
7564 opts_type = OPTS_TYPE_PT_GENERATE_BE
7565 | OPTS_TYPE_ST_ADD80
7566 | OPTS_TYPE_ST_ADDBITS15;
7567 kern_type = KERN_TYPE_SHA1_PWSLT;
7568 dgst_size = DGST_SIZE_4_5;
7569 parse_func = sha1s_parse_hash;
7570 sort_by_digest = sort_by_digest_4_5;
7571 opti_type = OPTI_TYPE_ZERO_BYTE
7572 | OPTI_TYPE_PRECOMPUTE_INIT
7573 | OPTI_TYPE_PRECOMPUTE_MERKLE
7574 | OPTI_TYPE_SCALAR_MODE
7575 | OPTI_TYPE_EARLY_SKIP
7576 | OPTI_TYPE_NOT_ITERATED
7577 | OPTI_TYPE_APPENDED_SALT
7578 | OPTI_TYPE_RAW_HASH;
7579 dgst_pos0 = 3;
7580 dgst_pos1 = 4;
7581 dgst_pos2 = 2;
7582 dgst_pos3 = 1;
7583 break;
7584
7585 case 111: hash_type = HASH_TYPE_SHA1;
7586 salt_type = SALT_TYPE_EMBEDDED;
7587 attack_exec = ATTACK_EXEC_ON_GPU;
7588 opts_type = OPTS_TYPE_PT_GENERATE_BE
7589 | OPTS_TYPE_ST_ADD80
7590 | OPTS_TYPE_ST_ADDBITS15;
7591 kern_type = KERN_TYPE_SHA1_PWSLT;
7592 dgst_size = DGST_SIZE_4_5;
7593 parse_func = sha1b64s_parse_hash;
7594 sort_by_digest = sort_by_digest_4_5;
7595 opti_type = OPTI_TYPE_ZERO_BYTE
7596 | OPTI_TYPE_PRECOMPUTE_INIT
7597 | OPTI_TYPE_PRECOMPUTE_MERKLE
7598 | OPTI_TYPE_SCALAR_MODE
7599 | OPTI_TYPE_EARLY_SKIP
7600 | OPTI_TYPE_NOT_ITERATED
7601 | OPTI_TYPE_APPENDED_SALT
7602 | OPTI_TYPE_RAW_HASH;
7603 dgst_pos0 = 3;
7604 dgst_pos1 = 4;
7605 dgst_pos2 = 2;
7606 dgst_pos3 = 1;
7607 break;
7608
7609 case 112: hash_type = HASH_TYPE_SHA1;
7610 salt_type = SALT_TYPE_INTERN;
7611 attack_exec = ATTACK_EXEC_ON_GPU;
7612 opts_type = OPTS_TYPE_PT_GENERATE_BE
7613 | OPTS_TYPE_ST_ADD80
7614 | OPTS_TYPE_ST_ADDBITS15
7615 | OPTS_TYPE_ST_HEX;
7616 kern_type = KERN_TYPE_SHA1_PWSLT;
7617 dgst_size = DGST_SIZE_4_5;
7618 parse_func = oracles_parse_hash;
7619 sort_by_digest = sort_by_digest_4_5;
7620 opti_type = OPTI_TYPE_ZERO_BYTE
7621 | OPTI_TYPE_PRECOMPUTE_INIT
7622 | OPTI_TYPE_PRECOMPUTE_MERKLE
7623 | OPTI_TYPE_SCALAR_MODE
7624 | OPTI_TYPE_EARLY_SKIP
7625 | OPTI_TYPE_NOT_ITERATED
7626 | OPTI_TYPE_APPENDED_SALT
7627 | OPTI_TYPE_RAW_HASH;
7628 dgst_pos0 = 3;
7629 dgst_pos1 = 4;
7630 dgst_pos2 = 2;
7631 dgst_pos3 = 1;
7632 break;
7633
7634 case 120: hash_type = HASH_TYPE_SHA1;
7635 salt_type = SALT_TYPE_INTERN;
7636 attack_exec = ATTACK_EXEC_ON_GPU;
7637 opts_type = OPTS_TYPE_PT_GENERATE_BE
7638 | OPTS_TYPE_PT_ADD80
7639 | OPTS_TYPE_PT_ADDBITS15;
7640 kern_type = KERN_TYPE_SHA1_SLTPW;
7641 dgst_size = DGST_SIZE_4_5;
7642 parse_func = sha1s_parse_hash;
7643 sort_by_digest = sort_by_digest_4_5;
7644 opti_type = OPTI_TYPE_ZERO_BYTE
7645 | OPTI_TYPE_PRECOMPUTE_INIT
7646 | OPTI_TYPE_PRECOMPUTE_MERKLE
7647 | OPTI_TYPE_EARLY_SKIP
7648 | OPTI_TYPE_NOT_ITERATED
7649 | OPTI_TYPE_PREPENDED_SALT
7650 | OPTI_TYPE_RAW_HASH;
7651 dgst_pos0 = 3;
7652 dgst_pos1 = 4;
7653 dgst_pos2 = 2;
7654 dgst_pos3 = 1;
7655 break;
7656
7657 case 121: hash_type = HASH_TYPE_SHA1;
7658 salt_type = SALT_TYPE_INTERN;
7659 attack_exec = ATTACK_EXEC_ON_GPU;
7660 opts_type = OPTS_TYPE_PT_GENERATE_BE
7661 | OPTS_TYPE_PT_ADD80
7662 | OPTS_TYPE_PT_ADDBITS15
7663 | OPTS_TYPE_ST_LOWER;
7664 kern_type = KERN_TYPE_SHA1_SLTPW;
7665 dgst_size = DGST_SIZE_4_5;
7666 parse_func = smf_parse_hash;
7667 sort_by_digest = sort_by_digest_4_5;
7668 opti_type = OPTI_TYPE_ZERO_BYTE
7669 | OPTI_TYPE_PRECOMPUTE_INIT
7670 | OPTI_TYPE_PRECOMPUTE_MERKLE
7671 | OPTI_TYPE_EARLY_SKIP
7672 | OPTI_TYPE_NOT_ITERATED
7673 | OPTI_TYPE_PREPENDED_SALT
7674 | OPTI_TYPE_RAW_HASH;
7675 dgst_pos0 = 3;
7676 dgst_pos1 = 4;
7677 dgst_pos2 = 2;
7678 dgst_pos3 = 1;
7679 break;
7680
7681 case 122: hash_type = HASH_TYPE_SHA1;
7682 salt_type = SALT_TYPE_EMBEDDED;
7683 attack_exec = ATTACK_EXEC_ON_GPU;
7684 opts_type = OPTS_TYPE_PT_GENERATE_BE
7685 | OPTS_TYPE_PT_ADD80
7686 | OPTS_TYPE_PT_ADDBITS15
7687 | OPTS_TYPE_ST_HEX;
7688 kern_type = KERN_TYPE_SHA1_SLTPW;
7689 dgst_size = DGST_SIZE_4_5;
7690 parse_func = osx1_parse_hash;
7691 sort_by_digest = sort_by_digest_4_5;
7692 opti_type = OPTI_TYPE_ZERO_BYTE
7693 | OPTI_TYPE_PRECOMPUTE_INIT
7694 | OPTI_TYPE_PRECOMPUTE_MERKLE
7695 | OPTI_TYPE_EARLY_SKIP
7696 | OPTI_TYPE_NOT_ITERATED
7697 | OPTI_TYPE_PREPENDED_SALT
7698 | OPTI_TYPE_RAW_HASH;
7699 dgst_pos0 = 3;
7700 dgst_pos1 = 4;
7701 dgst_pos2 = 2;
7702 dgst_pos3 = 1;
7703 break;
7704
7705 case 124: hash_type = HASH_TYPE_SHA1;
7706 salt_type = SALT_TYPE_EMBEDDED;
7707 attack_exec = ATTACK_EXEC_ON_GPU;
7708 opts_type = OPTS_TYPE_PT_GENERATE_BE
7709 | OPTS_TYPE_PT_ADD80
7710 | OPTS_TYPE_PT_ADDBITS15;
7711 kern_type = KERN_TYPE_SHA1_SLTPW;
7712 dgst_size = DGST_SIZE_4_5;
7713 parse_func = djangosha1_parse_hash;
7714 sort_by_digest = sort_by_digest_4_5;
7715 opti_type = OPTI_TYPE_ZERO_BYTE
7716 | OPTI_TYPE_PRECOMPUTE_INIT
7717 | OPTI_TYPE_PRECOMPUTE_MERKLE
7718 | OPTI_TYPE_EARLY_SKIP
7719 | OPTI_TYPE_NOT_ITERATED
7720 | OPTI_TYPE_PREPENDED_SALT
7721 | OPTI_TYPE_RAW_HASH;
7722 dgst_pos0 = 3;
7723 dgst_pos1 = 4;
7724 dgst_pos2 = 2;
7725 dgst_pos3 = 1;
7726 break;
7727
7728 case 130: hash_type = HASH_TYPE_SHA1;
7729 salt_type = SALT_TYPE_INTERN;
7730 attack_exec = ATTACK_EXEC_ON_GPU;
7731 opts_type = OPTS_TYPE_PT_GENERATE_BE
7732 | OPTS_TYPE_PT_UNICODE
7733 | OPTS_TYPE_ST_ADD80
7734 | OPTS_TYPE_ST_ADDBITS15;
7735 kern_type = KERN_TYPE_SHA1_PWUSLT;
7736 dgst_size = DGST_SIZE_4_5;
7737 parse_func = sha1s_parse_hash;
7738 sort_by_digest = sort_by_digest_4_5;
7739 opti_type = OPTI_TYPE_ZERO_BYTE
7740 | OPTI_TYPE_PRECOMPUTE_INIT
7741 | OPTI_TYPE_PRECOMPUTE_MERKLE
7742 | OPTI_TYPE_SCALAR_MODE
7743 | OPTI_TYPE_EARLY_SKIP
7744 | OPTI_TYPE_NOT_ITERATED
7745 | OPTI_TYPE_APPENDED_SALT
7746 | OPTI_TYPE_RAW_HASH;
7747 dgst_pos0 = 3;
7748 dgst_pos1 = 4;
7749 dgst_pos2 = 2;
7750 dgst_pos3 = 1;
7751 break;
7752
7753 case 131: hash_type = HASH_TYPE_SHA1;
7754 salt_type = SALT_TYPE_EMBEDDED;
7755 attack_exec = ATTACK_EXEC_ON_GPU;
7756 opts_type = OPTS_TYPE_PT_GENERATE_BE
7757 | OPTS_TYPE_PT_UNICODE
7758 | OPTS_TYPE_PT_UPPER
7759 | OPTS_TYPE_ST_ADD80
7760 | OPTS_TYPE_ST_ADDBITS15
7761 | OPTS_TYPE_ST_HEX;
7762 kern_type = KERN_TYPE_SHA1_PWUSLT;
7763 dgst_size = DGST_SIZE_4_5;
7764 parse_func = mssql2000_parse_hash;
7765 sort_by_digest = sort_by_digest_4_5;
7766 opti_type = OPTI_TYPE_ZERO_BYTE
7767 | OPTI_TYPE_PRECOMPUTE_INIT
7768 | OPTI_TYPE_PRECOMPUTE_MERKLE
7769 | OPTI_TYPE_SCALAR_MODE
7770 | OPTI_TYPE_EARLY_SKIP
7771 | OPTI_TYPE_NOT_ITERATED
7772 | OPTI_TYPE_APPENDED_SALT
7773 | OPTI_TYPE_RAW_HASH;
7774 dgst_pos0 = 3;
7775 dgst_pos1 = 4;
7776 dgst_pos2 = 2;
7777 dgst_pos3 = 1;
7778 break;
7779
7780 case 132: hash_type = HASH_TYPE_SHA1;
7781 salt_type = SALT_TYPE_EMBEDDED;
7782 attack_exec = ATTACK_EXEC_ON_GPU;
7783 opts_type = OPTS_TYPE_PT_GENERATE_BE
7784 | OPTS_TYPE_PT_UNICODE
7785 | OPTS_TYPE_ST_ADD80
7786 | OPTS_TYPE_ST_ADDBITS15
7787 | OPTS_TYPE_ST_HEX;
7788 kern_type = KERN_TYPE_SHA1_PWUSLT;
7789 dgst_size = DGST_SIZE_4_5;
7790 parse_func = mssql2005_parse_hash;
7791 sort_by_digest = sort_by_digest_4_5;
7792 opti_type = OPTI_TYPE_ZERO_BYTE
7793 | OPTI_TYPE_PRECOMPUTE_INIT
7794 | OPTI_TYPE_PRECOMPUTE_MERKLE
7795 | OPTI_TYPE_SCALAR_MODE
7796 | OPTI_TYPE_EARLY_SKIP
7797 | OPTI_TYPE_NOT_ITERATED
7798 | OPTI_TYPE_APPENDED_SALT
7799 | OPTI_TYPE_RAW_HASH;
7800 dgst_pos0 = 3;
7801 dgst_pos1 = 4;
7802 dgst_pos2 = 2;
7803 dgst_pos3 = 1;
7804 break;
7805
7806 case 133: hash_type = HASH_TYPE_SHA1;
7807 salt_type = SALT_TYPE_EMBEDDED;
7808 attack_exec = ATTACK_EXEC_ON_GPU;
7809 opts_type = OPTS_TYPE_PT_GENERATE_BE
7810 | OPTS_TYPE_PT_UNICODE
7811 | OPTS_TYPE_ST_ADD80
7812 | OPTS_TYPE_ST_ADDBITS15;
7813 kern_type = KERN_TYPE_SHA1_PWUSLT;
7814 dgst_size = DGST_SIZE_4_5;
7815 parse_func = peoplesoft_parse_hash;
7816 sort_by_digest = sort_by_digest_4_5;
7817 opti_type = OPTI_TYPE_ZERO_BYTE
7818 | OPTI_TYPE_PRECOMPUTE_INIT
7819 | OPTI_TYPE_PRECOMPUTE_MERKLE
7820 | OPTI_TYPE_SCALAR_MODE
7821 | OPTI_TYPE_EARLY_SKIP
7822 | OPTI_TYPE_NOT_ITERATED
7823 | OPTI_TYPE_APPENDED_SALT
7824 | OPTI_TYPE_RAW_HASH;
7825 dgst_pos0 = 3;
7826 dgst_pos1 = 4;
7827 dgst_pos2 = 2;
7828 dgst_pos3 = 1;
7829 break;
7830
7831 case 140: hash_type = HASH_TYPE_SHA1;
7832 salt_type = SALT_TYPE_INTERN;
7833 attack_exec = ATTACK_EXEC_ON_GPU;
7834 opts_type = OPTS_TYPE_PT_GENERATE_BE
7835 | OPTS_TYPE_PT_ADD80
7836 | OPTS_TYPE_PT_ADDBITS15
7837 | OPTS_TYPE_PT_UNICODE;
7838 kern_type = KERN_TYPE_SHA1_SLTPWU;
7839 dgst_size = DGST_SIZE_4_5;
7840 parse_func = sha1s_parse_hash;
7841 sort_by_digest = sort_by_digest_4_5;
7842 opti_type = OPTI_TYPE_ZERO_BYTE
7843 | OPTI_TYPE_PRECOMPUTE_INIT
7844 | OPTI_TYPE_PRECOMPUTE_MERKLE
7845 | OPTI_TYPE_EARLY_SKIP
7846 | OPTI_TYPE_NOT_ITERATED
7847 | OPTI_TYPE_PREPENDED_SALT
7848 | OPTI_TYPE_RAW_HASH;
7849 dgst_pos0 = 3;
7850 dgst_pos1 = 4;
7851 dgst_pos2 = 2;
7852 dgst_pos3 = 1;
7853 break;
7854
7855 case 141: hash_type = HASH_TYPE_SHA1;
7856 salt_type = SALT_TYPE_EMBEDDED;
7857 attack_exec = ATTACK_EXEC_ON_GPU;
7858 opts_type = OPTS_TYPE_PT_GENERATE_BE
7859 | OPTS_TYPE_PT_ADD80
7860 | OPTS_TYPE_PT_ADDBITS15
7861 | OPTS_TYPE_PT_UNICODE
7862 | OPTS_TYPE_ST_BASE64;
7863 kern_type = KERN_TYPE_SHA1_SLTPWU;
7864 dgst_size = DGST_SIZE_4_5;
7865 parse_func = episerver_parse_hash;
7866 sort_by_digest = sort_by_digest_4_5;
7867 opti_type = OPTI_TYPE_ZERO_BYTE
7868 | OPTI_TYPE_PRECOMPUTE_INIT
7869 | OPTI_TYPE_PRECOMPUTE_MERKLE
7870 | OPTI_TYPE_EARLY_SKIP
7871 | OPTI_TYPE_NOT_ITERATED
7872 | OPTI_TYPE_PREPENDED_SALT
7873 | OPTI_TYPE_RAW_HASH;
7874 dgst_pos0 = 3;
7875 dgst_pos1 = 4;
7876 dgst_pos2 = 2;
7877 dgst_pos3 = 1;
7878 break;
7879
7880 case 150: hash_type = HASH_TYPE_SHA1;
7881 salt_type = SALT_TYPE_INTERN;
7882 attack_exec = ATTACK_EXEC_ON_GPU;
7883 opts_type = OPTS_TYPE_PT_GENERATE_BE
7884 | OPTS_TYPE_ST_ADD80
7885 | OPTS_TYPE_ST_ADDBITS15;
7886 kern_type = KERN_TYPE_HMACSHA1_PW;
7887 dgst_size = DGST_SIZE_4_5;
7888 parse_func = hmacsha1_parse_hash;
7889 sort_by_digest = sort_by_digest_4_5;
7890 opti_type = OPTI_TYPE_ZERO_BYTE
7891 | OPTI_TYPE_NOT_ITERATED;
7892 dgst_pos0 = 3;
7893 dgst_pos1 = 4;
7894 dgst_pos2 = 2;
7895 dgst_pos3 = 1;
7896 break;
7897
7898 case 160: hash_type = HASH_TYPE_SHA1;
7899 salt_type = SALT_TYPE_INTERN;
7900 attack_exec = ATTACK_EXEC_ON_GPU;
7901 opts_type = OPTS_TYPE_PT_GENERATE_BE
7902 | OPTS_TYPE_PT_ADD80
7903 | OPTS_TYPE_PT_ADDBITS15;
7904 kern_type = KERN_TYPE_HMACSHA1_SLT;
7905 dgst_size = DGST_SIZE_4_5;
7906 parse_func = hmacsha1_parse_hash;
7907 sort_by_digest = sort_by_digest_4_5;
7908 opti_type = OPTI_TYPE_ZERO_BYTE
7909 | OPTI_TYPE_NOT_ITERATED;
7910 dgst_pos0 = 3;
7911 dgst_pos1 = 4;
7912 dgst_pos2 = 2;
7913 dgst_pos3 = 1;
7914 break;
7915
7916 case 190: hash_type = HASH_TYPE_SHA1;
7917 salt_type = SALT_TYPE_NONE;
7918 attack_exec = ATTACK_EXEC_ON_GPU;
7919 opts_type = OPTS_TYPE_PT_GENERATE_BE
7920 | OPTS_TYPE_PT_ADD80
7921 | OPTS_TYPE_PT_ADDBITS15;
7922 kern_type = KERN_TYPE_SHA1_LINKEDIN;
7923 dgst_size = DGST_SIZE_4_5;
7924 parse_func = sha1linkedin_parse_hash;
7925 sort_by_digest = sort_by_digest_4_5;
7926 opti_type = OPTI_TYPE_ZERO_BYTE
7927 | OPTI_TYPE_PRECOMPUTE_INIT
7928 | OPTI_TYPE_SCALAR_MODE
7929 | OPTI_TYPE_EARLY_SKIP
7930 | OPTI_TYPE_NOT_ITERATED
7931 | OPTI_TYPE_NOT_SALTED;
7932 dgst_pos0 = 0;
7933 dgst_pos1 = 4;
7934 dgst_pos2 = 3;
7935 dgst_pos3 = 2;
7936 break;
7937
7938 case 200: hash_type = HASH_TYPE_MYSQL;
7939 salt_type = SALT_TYPE_NONE;
7940 attack_exec = ATTACK_EXEC_ON_GPU;
7941 opts_type = 0;
7942 kern_type = KERN_TYPE_MYSQL;
7943 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7944 parse_func = mysql323_parse_hash;
7945 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7946 opti_type = OPTI_TYPE_ZERO_BYTE
7947 | OPTI_TYPE_SCALAR_MODE;
7948 dgst_pos0 = 0;
7949 dgst_pos1 = 1;
7950 dgst_pos2 = 2;
7951 dgst_pos3 = 3;
7952 break;
7953
7954 case 300: hash_type = HASH_TYPE_SHA1;
7955 salt_type = SALT_TYPE_NONE;
7956 attack_exec = ATTACK_EXEC_ON_GPU;
7957 opts_type = OPTS_TYPE_PT_GENERATE_BE
7958 | OPTS_TYPE_PT_ADD80
7959 | OPTS_TYPE_PT_ADDBITS15;
7960 kern_type = KERN_TYPE_MYSQL41;
7961 dgst_size = DGST_SIZE_4_5;
7962 parse_func = sha1_parse_hash;
7963 sort_by_digest = sort_by_digest_4_5;
7964 opti_type = OPTI_TYPE_ZERO_BYTE
7965 | OPTI_TYPE_PRECOMPUTE_INIT
7966 | OPTI_TYPE_PRECOMPUTE_MERKLE
7967 | OPTI_TYPE_SCALAR_MODE
7968 | OPTI_TYPE_EARLY_SKIP
7969 | OPTI_TYPE_NOT_ITERATED
7970 | OPTI_TYPE_NOT_SALTED;
7971 dgst_pos0 = 3;
7972 dgst_pos1 = 4;
7973 dgst_pos2 = 2;
7974 dgst_pos3 = 1;
7975 break;
7976
7977 case 400: hash_type = HASH_TYPE_MD5;
7978 salt_type = SALT_TYPE_EMBEDDED;
7979 attack_exec = ATTACK_EXEC_ON_CPU;
7980 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7981 kern_type = KERN_TYPE_PHPASS;
7982 dgst_size = DGST_SIZE_4_4;
7983 parse_func = phpass_parse_hash;
7984 sort_by_digest = sort_by_digest_4_4;
7985 opti_type = OPTI_TYPE_ZERO_BYTE;
7986 dgst_pos0 = 0;
7987 dgst_pos1 = 1;
7988 dgst_pos2 = 2;
7989 dgst_pos3 = 3;
7990 break;
7991
7992 case 500: hash_type = HASH_TYPE_MD5;
7993 salt_type = SALT_TYPE_EMBEDDED;
7994 attack_exec = ATTACK_EXEC_ON_CPU;
7995 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7996 kern_type = KERN_TYPE_MD5CRYPT;
7997 dgst_size = DGST_SIZE_4_4;
7998 parse_func = md5crypt_parse_hash;
7999 sort_by_digest = sort_by_digest_4_4;
8000 opti_type = OPTI_TYPE_ZERO_BYTE;
8001 dgst_pos0 = 0;
8002 dgst_pos1 = 1;
8003 dgst_pos2 = 2;
8004 dgst_pos3 = 3;
8005 break;
8006
8007 case 501: hash_type = HASH_TYPE_MD5;
8008 salt_type = SALT_TYPE_EMBEDDED;
8009 attack_exec = ATTACK_EXEC_ON_CPU;
8010 opts_type = OPTS_TYPE_PT_GENERATE_LE
8011 | OPTS_TYPE_HASH_COPY;
8012 kern_type = KERN_TYPE_MD5CRYPT;
8013 dgst_size = DGST_SIZE_4_4;
8014 parse_func = juniper_parse_hash;
8015 sort_by_digest = sort_by_digest_4_4;
8016 opti_type = OPTI_TYPE_ZERO_BYTE;
8017 dgst_pos0 = 0;
8018 dgst_pos1 = 1;
8019 dgst_pos2 = 2;
8020 dgst_pos3 = 3;
8021 break;
8022
8023 case 900: hash_type = HASH_TYPE_MD4;
8024 salt_type = SALT_TYPE_NONE;
8025 attack_exec = ATTACK_EXEC_ON_GPU;
8026 opts_type = OPTS_TYPE_PT_GENERATE_LE
8027 | OPTS_TYPE_PT_ADD80
8028 | OPTS_TYPE_PT_ADDBITS14;
8029 kern_type = KERN_TYPE_MD4;
8030 dgst_size = DGST_SIZE_4_4;
8031 parse_func = md4_parse_hash;
8032 sort_by_digest = sort_by_digest_4_4;
8033 opti_type = OPTI_TYPE_ZERO_BYTE
8034 | OPTI_TYPE_PRECOMPUTE_INIT
8035 | OPTI_TYPE_PRECOMPUTE_MERKLE
8036 | OPTI_TYPE_SCALAR_MODE
8037 | OPTI_TYPE_MEET_IN_MIDDLE
8038 | OPTI_TYPE_EARLY_SKIP
8039 | OPTI_TYPE_NOT_ITERATED
8040 | OPTI_TYPE_NOT_SALTED
8041 | OPTI_TYPE_RAW_HASH;
8042 dgst_pos0 = 0;
8043 dgst_pos1 = 3;
8044 dgst_pos2 = 2;
8045 dgst_pos3 = 1;
8046 break;
8047
8048 case 1000: hash_type = HASH_TYPE_MD4;
8049 salt_type = SALT_TYPE_NONE;
8050 attack_exec = ATTACK_EXEC_ON_GPU;
8051 opts_type = OPTS_TYPE_PT_GENERATE_LE
8052 | OPTS_TYPE_PT_ADD80
8053 | OPTS_TYPE_PT_ADDBITS14
8054 | OPTS_TYPE_PT_UNICODE;
8055 kern_type = KERN_TYPE_MD4_PWU;
8056 dgst_size = DGST_SIZE_4_4;
8057 parse_func = md4_parse_hash;
8058 sort_by_digest = sort_by_digest_4_4;
8059 opti_type = OPTI_TYPE_ZERO_BYTE
8060 | OPTI_TYPE_PRECOMPUTE_INIT
8061 | OPTI_TYPE_PRECOMPUTE_MERKLE
8062 | OPTI_TYPE_SCALAR_MODE
8063 | OPTI_TYPE_MEET_IN_MIDDLE
8064 | OPTI_TYPE_EARLY_SKIP
8065 | OPTI_TYPE_NOT_ITERATED
8066 | OPTI_TYPE_NOT_SALTED
8067 | OPTI_TYPE_RAW_HASH;
8068 dgst_pos0 = 0;
8069 dgst_pos1 = 3;
8070 dgst_pos2 = 2;
8071 dgst_pos3 = 1;
8072 break;
8073
8074 case 1100: hash_type = HASH_TYPE_MD4;
8075 salt_type = SALT_TYPE_INTERN;
8076 attack_exec = ATTACK_EXEC_ON_GPU;
8077 opts_type = OPTS_TYPE_PT_GENERATE_LE
8078 | OPTS_TYPE_PT_ADD80
8079 | OPTS_TYPE_PT_ADDBITS14
8080 | OPTS_TYPE_PT_UNICODE
8081 | OPTS_TYPE_ST_ADD80
8082 | OPTS_TYPE_ST_UNICODE
8083 | OPTS_TYPE_ST_LOWER;
8084 kern_type = KERN_TYPE_MD44_PWUSLT;
8085 dgst_size = DGST_SIZE_4_4;
8086 parse_func = dcc_parse_hash;
8087 sort_by_digest = sort_by_digest_4_4;
8088 opti_type = OPTI_TYPE_ZERO_BYTE
8089 | OPTI_TYPE_PRECOMPUTE_INIT
8090 | OPTI_TYPE_PRECOMPUTE_MERKLE
8091 | OPTI_TYPE_SCALAR_MODE
8092 | OPTI_TYPE_EARLY_SKIP
8093 | OPTI_TYPE_NOT_ITERATED;
8094 dgst_pos0 = 0;
8095 dgst_pos1 = 3;
8096 dgst_pos2 = 2;
8097 dgst_pos3 = 1;
8098 break;
8099
8100 case 1400: hash_type = HASH_TYPE_SHA256;
8101 salt_type = SALT_TYPE_NONE;
8102 attack_exec = ATTACK_EXEC_ON_GPU;
8103 opts_type = OPTS_TYPE_PT_GENERATE_BE
8104 | OPTS_TYPE_PT_ADD80
8105 | OPTS_TYPE_PT_ADDBITS15;
8106 kern_type = KERN_TYPE_SHA256;
8107 dgst_size = DGST_SIZE_4_8;
8108 parse_func = sha256_parse_hash;
8109 sort_by_digest = sort_by_digest_4_8;
8110 opti_type = OPTI_TYPE_ZERO_BYTE
8111 | OPTI_TYPE_PRECOMPUTE_INIT
8112 | OPTI_TYPE_PRECOMPUTE_MERKLE
8113 | OPTI_TYPE_SCALAR_MODE
8114 | OPTI_TYPE_EARLY_SKIP
8115 | OPTI_TYPE_NOT_ITERATED
8116 | OPTI_TYPE_NOT_SALTED
8117 | OPTI_TYPE_RAW_HASH;
8118 dgst_pos0 = 3;
8119 dgst_pos1 = 7;
8120 dgst_pos2 = 2;
8121 dgst_pos3 = 6;
8122 break;
8123
8124 case 1410: hash_type = HASH_TYPE_SHA256;
8125 salt_type = SALT_TYPE_INTERN;
8126 attack_exec = ATTACK_EXEC_ON_GPU;
8127 opts_type = OPTS_TYPE_PT_GENERATE_BE
8128 | OPTS_TYPE_ST_ADD80
8129 | OPTS_TYPE_ST_ADDBITS15;
8130 kern_type = KERN_TYPE_SHA256_PWSLT;
8131 dgst_size = DGST_SIZE_4_8;
8132 parse_func = sha256s_parse_hash;
8133 sort_by_digest = sort_by_digest_4_8;
8134 opti_type = OPTI_TYPE_ZERO_BYTE
8135 | OPTI_TYPE_PRECOMPUTE_INIT
8136 | OPTI_TYPE_PRECOMPUTE_MERKLE
8137 | OPTI_TYPE_SCALAR_MODE
8138 | OPTI_TYPE_EARLY_SKIP
8139 | OPTI_TYPE_NOT_ITERATED
8140 | OPTI_TYPE_APPENDED_SALT
8141 | OPTI_TYPE_RAW_HASH;
8142 dgst_pos0 = 3;
8143 dgst_pos1 = 7;
8144 dgst_pos2 = 2;
8145 dgst_pos3 = 6;
8146 break;
8147
8148 case 1420: hash_type = HASH_TYPE_SHA256;
8149 salt_type = SALT_TYPE_INTERN;
8150 attack_exec = ATTACK_EXEC_ON_GPU;
8151 opts_type = OPTS_TYPE_PT_GENERATE_BE
8152 | OPTS_TYPE_PT_ADD80
8153 | OPTS_TYPE_PT_ADDBITS15;
8154 kern_type = KERN_TYPE_SHA256_SLTPW;
8155 dgst_size = DGST_SIZE_4_8;
8156 parse_func = sha256s_parse_hash;
8157 sort_by_digest = sort_by_digest_4_8;
8158 opti_type = OPTI_TYPE_ZERO_BYTE
8159 | OPTI_TYPE_PRECOMPUTE_INIT
8160 | OPTI_TYPE_PRECOMPUTE_MERKLE
8161 | OPTI_TYPE_EARLY_SKIP
8162 | OPTI_TYPE_NOT_ITERATED
8163 | OPTI_TYPE_PREPENDED_SALT
8164 | OPTI_TYPE_RAW_HASH;
8165 dgst_pos0 = 3;
8166 dgst_pos1 = 7;
8167 dgst_pos2 = 2;
8168 dgst_pos3 = 6;
8169 break;
8170
8171 case 1421: hash_type = HASH_TYPE_SHA256;
8172 salt_type = SALT_TYPE_EMBEDDED;
8173 attack_exec = ATTACK_EXEC_ON_GPU;
8174 opts_type = OPTS_TYPE_PT_GENERATE_BE
8175 | OPTS_TYPE_PT_ADD80
8176 | OPTS_TYPE_PT_ADDBITS15;
8177 kern_type = KERN_TYPE_SHA256_SLTPW;
8178 dgst_size = DGST_SIZE_4_8;
8179 parse_func = hmailserver_parse_hash;
8180 sort_by_digest = sort_by_digest_4_8;
8181 opti_type = OPTI_TYPE_ZERO_BYTE
8182 | OPTI_TYPE_PRECOMPUTE_INIT
8183 | OPTI_TYPE_PRECOMPUTE_MERKLE
8184 | OPTI_TYPE_EARLY_SKIP
8185 | OPTI_TYPE_NOT_ITERATED
8186 | OPTI_TYPE_PREPENDED_SALT
8187 | OPTI_TYPE_RAW_HASH;
8188 dgst_pos0 = 3;
8189 dgst_pos1 = 7;
8190 dgst_pos2 = 2;
8191 dgst_pos3 = 6;
8192 break;
8193
8194 case 1430: hash_type = HASH_TYPE_SHA256;
8195 salt_type = SALT_TYPE_INTERN;
8196 attack_exec = ATTACK_EXEC_ON_GPU;
8197 opts_type = OPTS_TYPE_PT_GENERATE_BE
8198 | OPTS_TYPE_PT_UNICODE
8199 | OPTS_TYPE_ST_ADD80
8200 | OPTS_TYPE_ST_ADDBITS15;
8201 kern_type = KERN_TYPE_SHA256_PWUSLT;
8202 dgst_size = DGST_SIZE_4_8;
8203 parse_func = sha256s_parse_hash;
8204 sort_by_digest = sort_by_digest_4_8;
8205 opti_type = OPTI_TYPE_ZERO_BYTE
8206 | OPTI_TYPE_PRECOMPUTE_INIT
8207 | OPTI_TYPE_PRECOMPUTE_MERKLE
8208 | OPTI_TYPE_SCALAR_MODE
8209 | OPTI_TYPE_EARLY_SKIP
8210 | OPTI_TYPE_NOT_ITERATED
8211 | OPTI_TYPE_APPENDED_SALT
8212 | OPTI_TYPE_RAW_HASH;
8213 dgst_pos0 = 3;
8214 dgst_pos1 = 7;
8215 dgst_pos2 = 2;
8216 dgst_pos3 = 6;
8217 break;
8218
8219 case 1440: hash_type = HASH_TYPE_SHA256;
8220 salt_type = SALT_TYPE_INTERN;
8221 attack_exec = ATTACK_EXEC_ON_GPU;
8222 opts_type = OPTS_TYPE_PT_GENERATE_BE
8223 | OPTS_TYPE_PT_ADD80
8224 | OPTS_TYPE_PT_ADDBITS15
8225 | OPTS_TYPE_PT_UNICODE;
8226 kern_type = KERN_TYPE_SHA256_SLTPWU;
8227 dgst_size = DGST_SIZE_4_8;
8228 parse_func = sha256s_parse_hash;
8229 sort_by_digest = sort_by_digest_4_8;
8230 opti_type = OPTI_TYPE_ZERO_BYTE
8231 | OPTI_TYPE_PRECOMPUTE_INIT
8232 | OPTI_TYPE_PRECOMPUTE_MERKLE
8233 | OPTI_TYPE_EARLY_SKIP
8234 | OPTI_TYPE_NOT_ITERATED
8235 | OPTI_TYPE_PREPENDED_SALT
8236 | OPTI_TYPE_RAW_HASH;
8237 dgst_pos0 = 3;
8238 dgst_pos1 = 7;
8239 dgst_pos2 = 2;
8240 dgst_pos3 = 6;
8241 break;
8242
8243 case 1441: hash_type = HASH_TYPE_SHA256;
8244 salt_type = SALT_TYPE_EMBEDDED;
8245 attack_exec = ATTACK_EXEC_ON_GPU;
8246 opts_type = OPTS_TYPE_PT_GENERATE_BE
8247 | OPTS_TYPE_PT_ADD80
8248 | OPTS_TYPE_PT_ADDBITS15
8249 | OPTS_TYPE_PT_UNICODE
8250 | OPTS_TYPE_ST_BASE64;
8251 kern_type = KERN_TYPE_SHA256_SLTPWU;
8252 dgst_size = DGST_SIZE_4_8;
8253 parse_func = episerver4_parse_hash;
8254 sort_by_digest = sort_by_digest_4_8;
8255 opti_type = OPTI_TYPE_ZERO_BYTE
8256 | OPTI_TYPE_PRECOMPUTE_INIT
8257 | OPTI_TYPE_PRECOMPUTE_MERKLE
8258 | OPTI_TYPE_EARLY_SKIP
8259 | OPTI_TYPE_NOT_ITERATED
8260 | OPTI_TYPE_PREPENDED_SALT
8261 | OPTI_TYPE_RAW_HASH;
8262 dgst_pos0 = 3;
8263 dgst_pos1 = 7;
8264 dgst_pos2 = 2;
8265 dgst_pos3 = 6;
8266 break;
8267
8268 case 1450: hash_type = HASH_TYPE_SHA256;
8269 salt_type = SALT_TYPE_INTERN;
8270 attack_exec = ATTACK_EXEC_ON_GPU;
8271 opts_type = OPTS_TYPE_PT_GENERATE_BE
8272 | OPTS_TYPE_ST_ADD80;
8273 kern_type = KERN_TYPE_HMACSHA256_PW;
8274 dgst_size = DGST_SIZE_4_8;
8275 parse_func = hmacsha256_parse_hash;
8276 sort_by_digest = sort_by_digest_4_8;
8277 opti_type = OPTI_TYPE_ZERO_BYTE
8278 | OPTI_TYPE_NOT_ITERATED;
8279 dgst_pos0 = 3;
8280 dgst_pos1 = 7;
8281 dgst_pos2 = 2;
8282 dgst_pos3 = 6;
8283 break;
8284
8285 case 1460: hash_type = HASH_TYPE_SHA256;
8286 salt_type = SALT_TYPE_INTERN;
8287 attack_exec = ATTACK_EXEC_ON_GPU;
8288 opts_type = OPTS_TYPE_PT_GENERATE_BE
8289 | OPTS_TYPE_PT_ADD80
8290 | OPTS_TYPE_PT_ADDBITS15;
8291 kern_type = KERN_TYPE_HMACSHA256_SLT;
8292 dgst_size = DGST_SIZE_4_8;
8293 parse_func = hmacsha256_parse_hash;
8294 sort_by_digest = sort_by_digest_4_8;
8295 opti_type = OPTI_TYPE_ZERO_BYTE
8296 | OPTI_TYPE_NOT_ITERATED;
8297 dgst_pos0 = 3;
8298 dgst_pos1 = 7;
8299 dgst_pos2 = 2;
8300 dgst_pos3 = 6;
8301 break;
8302
8303 case 1500: hash_type = HASH_TYPE_DESCRYPT;
8304 salt_type = SALT_TYPE_EMBEDDED;
8305 attack_exec = ATTACK_EXEC_ON_GPU;
8306 opts_type = OPTS_TYPE_PT_GENERATE_LE
8307 | OPTS_TYPE_PT_BITSLICE;
8308 kern_type = KERN_TYPE_DESCRYPT;
8309 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8310 parse_func = descrypt_parse_hash;
8311 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8312 opti_type = OPTI_TYPE_ZERO_BYTE
8313 | OPTI_TYPE_SCALAR_MODE
8314 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8315 dgst_pos0 = 0;
8316 dgst_pos1 = 1;
8317 dgst_pos2 = 2;
8318 dgst_pos3 = 3;
8319 break;
8320
8321 case 1600: hash_type = HASH_TYPE_MD5;
8322 salt_type = SALT_TYPE_EMBEDDED;
8323 attack_exec = ATTACK_EXEC_ON_CPU;
8324 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8325 kern_type = KERN_TYPE_APR1CRYPT;
8326 dgst_size = DGST_SIZE_4_4;
8327 parse_func = md5apr1_parse_hash;
8328 sort_by_digest = sort_by_digest_4_4;
8329 opti_type = OPTI_TYPE_ZERO_BYTE;
8330 dgst_pos0 = 0;
8331 dgst_pos1 = 1;
8332 dgst_pos2 = 2;
8333 dgst_pos3 = 3;
8334 break;
8335
8336 case 1700: hash_type = HASH_TYPE_SHA512;
8337 salt_type = SALT_TYPE_NONE;
8338 attack_exec = ATTACK_EXEC_ON_GPU;
8339 opts_type = OPTS_TYPE_PT_GENERATE_BE
8340 | OPTS_TYPE_PT_ADD80
8341 | OPTS_TYPE_PT_ADDBITS15;
8342 kern_type = KERN_TYPE_SHA512;
8343 dgst_size = DGST_SIZE_8_8;
8344 parse_func = sha512_parse_hash;
8345 sort_by_digest = sort_by_digest_8_8;
8346 opti_type = OPTI_TYPE_ZERO_BYTE
8347 | OPTI_TYPE_PRECOMPUTE_INIT
8348 | OPTI_TYPE_PRECOMPUTE_MERKLE
8349 | OPTI_TYPE_SCALAR_MODE
8350 | OPTI_TYPE_EARLY_SKIP
8351 | OPTI_TYPE_NOT_ITERATED
8352 | OPTI_TYPE_NOT_SALTED
8353 | OPTI_TYPE_RAW_HASH;
8354 dgst_pos0 = 14;
8355 dgst_pos1 = 15;
8356 dgst_pos2 = 6;
8357 dgst_pos3 = 7;
8358 break;
8359
8360 case 1710: hash_type = HASH_TYPE_SHA512;
8361 salt_type = SALT_TYPE_INTERN;
8362 attack_exec = ATTACK_EXEC_ON_GPU;
8363 opts_type = OPTS_TYPE_PT_GENERATE_BE
8364 | OPTS_TYPE_ST_ADD80
8365 | OPTS_TYPE_ST_ADDBITS15;
8366 kern_type = KERN_TYPE_SHA512_PWSLT;
8367 dgst_size = DGST_SIZE_8_8;
8368 parse_func = sha512s_parse_hash;
8369 sort_by_digest = sort_by_digest_8_8;
8370 opti_type = OPTI_TYPE_ZERO_BYTE
8371 | OPTI_TYPE_PRECOMPUTE_INIT
8372 | OPTI_TYPE_PRECOMPUTE_MERKLE
8373 | OPTI_TYPE_SCALAR_MODE
8374 | OPTI_TYPE_EARLY_SKIP
8375 | OPTI_TYPE_NOT_ITERATED
8376 | OPTI_TYPE_APPENDED_SALT
8377 | OPTI_TYPE_RAW_HASH;
8378 dgst_pos0 = 14;
8379 dgst_pos1 = 15;
8380 dgst_pos2 = 6;
8381 dgst_pos3 = 7;
8382 break;
8383
8384 case 1711: hash_type = HASH_TYPE_SHA512;
8385 salt_type = SALT_TYPE_EMBEDDED;
8386 attack_exec = ATTACK_EXEC_ON_GPU;
8387 opts_type = OPTS_TYPE_PT_GENERATE_BE
8388 | OPTS_TYPE_ST_ADD80
8389 | OPTS_TYPE_ST_ADDBITS15;
8390 kern_type = KERN_TYPE_SHA512_PWSLT;
8391 dgst_size = DGST_SIZE_8_8;
8392 parse_func = sha512b64s_parse_hash;
8393 sort_by_digest = sort_by_digest_8_8;
8394 opti_type = OPTI_TYPE_ZERO_BYTE
8395 | OPTI_TYPE_PRECOMPUTE_INIT
8396 | OPTI_TYPE_PRECOMPUTE_MERKLE
8397 | OPTI_TYPE_SCALAR_MODE
8398 | OPTI_TYPE_EARLY_SKIP
8399 | OPTI_TYPE_NOT_ITERATED
8400 | OPTI_TYPE_APPENDED_SALT
8401 | OPTI_TYPE_RAW_HASH;
8402 dgst_pos0 = 14;
8403 dgst_pos1 = 15;
8404 dgst_pos2 = 6;
8405 dgst_pos3 = 7;
8406 break;
8407
8408 case 1720: hash_type = HASH_TYPE_SHA512;
8409 salt_type = SALT_TYPE_INTERN;
8410 attack_exec = ATTACK_EXEC_ON_GPU;
8411 opts_type = OPTS_TYPE_PT_GENERATE_BE
8412 | OPTS_TYPE_PT_ADD80
8413 | OPTS_TYPE_PT_ADDBITS15;
8414 kern_type = KERN_TYPE_SHA512_SLTPW;
8415 dgst_size = DGST_SIZE_8_8;
8416 parse_func = sha512s_parse_hash;
8417 sort_by_digest = sort_by_digest_8_8;
8418 opti_type = OPTI_TYPE_ZERO_BYTE
8419 | OPTI_TYPE_PRECOMPUTE_INIT
8420 | OPTI_TYPE_PRECOMPUTE_MERKLE
8421 | OPTI_TYPE_EARLY_SKIP
8422 | OPTI_TYPE_NOT_ITERATED
8423 | OPTI_TYPE_PREPENDED_SALT
8424 | OPTI_TYPE_RAW_HASH;
8425 dgst_pos0 = 14;
8426 dgst_pos1 = 15;
8427 dgst_pos2 = 6;
8428 dgst_pos3 = 7;
8429 break;
8430
8431 case 1722: hash_type = HASH_TYPE_SHA512;
8432 salt_type = SALT_TYPE_EMBEDDED;
8433 attack_exec = ATTACK_EXEC_ON_GPU;
8434 opts_type = OPTS_TYPE_PT_GENERATE_BE
8435 | OPTS_TYPE_PT_ADD80
8436 | OPTS_TYPE_PT_ADDBITS15
8437 | OPTS_TYPE_ST_HEX;
8438 kern_type = KERN_TYPE_SHA512_SLTPW;
8439 dgst_size = DGST_SIZE_8_8;
8440 parse_func = osx512_parse_hash;
8441 sort_by_digest = sort_by_digest_8_8;
8442 opti_type = OPTI_TYPE_ZERO_BYTE
8443 | OPTI_TYPE_PRECOMPUTE_INIT
8444 | OPTI_TYPE_PRECOMPUTE_MERKLE
8445 | OPTI_TYPE_EARLY_SKIP
8446 | OPTI_TYPE_NOT_ITERATED
8447 | OPTI_TYPE_PREPENDED_SALT
8448 | OPTI_TYPE_RAW_HASH;
8449 dgst_pos0 = 14;
8450 dgst_pos1 = 15;
8451 dgst_pos2 = 6;
8452 dgst_pos3 = 7;
8453 break;
8454
8455 case 1730: hash_type = HASH_TYPE_SHA512;
8456 salt_type = SALT_TYPE_INTERN;
8457 attack_exec = ATTACK_EXEC_ON_GPU;
8458 opts_type = OPTS_TYPE_PT_GENERATE_BE
8459 | OPTS_TYPE_PT_UNICODE
8460 | OPTS_TYPE_ST_ADD80
8461 | OPTS_TYPE_ST_ADDBITS15;
8462 kern_type = KERN_TYPE_SHA512_PWSLTU;
8463 dgst_size = DGST_SIZE_8_8;
8464 parse_func = sha512s_parse_hash;
8465 sort_by_digest = sort_by_digest_8_8;
8466 opti_type = OPTI_TYPE_ZERO_BYTE
8467 | OPTI_TYPE_PRECOMPUTE_INIT
8468 | OPTI_TYPE_PRECOMPUTE_MERKLE
8469 | OPTI_TYPE_SCALAR_MODE
8470 | OPTI_TYPE_EARLY_SKIP
8471 | OPTI_TYPE_NOT_ITERATED
8472 | OPTI_TYPE_APPENDED_SALT
8473 | OPTI_TYPE_RAW_HASH;
8474 dgst_pos0 = 14;
8475 dgst_pos1 = 15;
8476 dgst_pos2 = 6;
8477 dgst_pos3 = 7;
8478 break;
8479
8480 case 1731: hash_type = HASH_TYPE_SHA512;
8481 salt_type = SALT_TYPE_EMBEDDED;
8482 attack_exec = ATTACK_EXEC_ON_GPU;
8483 opts_type = OPTS_TYPE_PT_GENERATE_BE
8484 | OPTS_TYPE_PT_UNICODE
8485 | OPTS_TYPE_ST_ADD80
8486 | OPTS_TYPE_ST_ADDBITS15
8487 | OPTS_TYPE_ST_HEX;
8488 kern_type = KERN_TYPE_SHA512_PWSLTU;
8489 dgst_size = DGST_SIZE_8_8;
8490 parse_func = mssql2012_parse_hash;
8491 sort_by_digest = sort_by_digest_8_8;
8492 opti_type = OPTI_TYPE_ZERO_BYTE
8493 | OPTI_TYPE_PRECOMPUTE_INIT
8494 | OPTI_TYPE_PRECOMPUTE_MERKLE
8495 | OPTI_TYPE_SCALAR_MODE
8496 | OPTI_TYPE_EARLY_SKIP
8497 | OPTI_TYPE_NOT_ITERATED
8498 | OPTI_TYPE_APPENDED_SALT
8499 | OPTI_TYPE_RAW_HASH;
8500 dgst_pos0 = 14;
8501 dgst_pos1 = 15;
8502 dgst_pos2 = 6;
8503 dgst_pos3 = 7;
8504 break;
8505
8506 case 1740: hash_type = HASH_TYPE_SHA512;
8507 salt_type = SALT_TYPE_INTERN;
8508 attack_exec = ATTACK_EXEC_ON_GPU;
8509 opts_type = OPTS_TYPE_PT_GENERATE_BE
8510 | OPTS_TYPE_PT_ADD80
8511 | OPTS_TYPE_PT_ADDBITS15
8512 | OPTS_TYPE_PT_UNICODE;
8513 kern_type = KERN_TYPE_SHA512_SLTPWU;
8514 dgst_size = DGST_SIZE_8_8;
8515 parse_func = sha512s_parse_hash;
8516 sort_by_digest = sort_by_digest_8_8;
8517 opti_type = OPTI_TYPE_ZERO_BYTE
8518 | OPTI_TYPE_PRECOMPUTE_INIT
8519 | OPTI_TYPE_PRECOMPUTE_MERKLE
8520 | OPTI_TYPE_EARLY_SKIP
8521 | OPTI_TYPE_NOT_ITERATED
8522 | OPTI_TYPE_PREPENDED_SALT
8523 | OPTI_TYPE_RAW_HASH;
8524 dgst_pos0 = 14;
8525 dgst_pos1 = 15;
8526 dgst_pos2 = 6;
8527 dgst_pos3 = 7;
8528 break;
8529
8530 case 1750: hash_type = HASH_TYPE_SHA512;
8531 salt_type = SALT_TYPE_INTERN;
8532 attack_exec = ATTACK_EXEC_ON_GPU;
8533 opts_type = OPTS_TYPE_PT_GENERATE_BE
8534 | OPTS_TYPE_ST_ADD80;
8535 kern_type = KERN_TYPE_HMACSHA512_PW;
8536 dgst_size = DGST_SIZE_8_8;
8537 parse_func = hmacsha512_parse_hash;
8538 sort_by_digest = sort_by_digest_8_8;
8539 opti_type = OPTI_TYPE_ZERO_BYTE
8540 | OPTI_TYPE_NOT_ITERATED;
8541 dgst_pos0 = 14;
8542 dgst_pos1 = 15;
8543 dgst_pos2 = 6;
8544 dgst_pos3 = 7;
8545 break;
8546
8547 case 1760: hash_type = HASH_TYPE_SHA512;
8548 salt_type = SALT_TYPE_INTERN;
8549 attack_exec = ATTACK_EXEC_ON_GPU;
8550 opts_type = OPTS_TYPE_PT_GENERATE_BE
8551 | OPTS_TYPE_PT_ADD80
8552 | OPTS_TYPE_PT_ADDBITS15;
8553 kern_type = KERN_TYPE_HMACSHA512_SLT;
8554 dgst_size = DGST_SIZE_8_8;
8555 parse_func = hmacsha512_parse_hash;
8556 sort_by_digest = sort_by_digest_8_8;
8557 opti_type = OPTI_TYPE_ZERO_BYTE
8558 | OPTI_TYPE_NOT_ITERATED;
8559 dgst_pos0 = 14;
8560 dgst_pos1 = 15;
8561 dgst_pos2 = 6;
8562 dgst_pos3 = 7;
8563 break;
8564
8565 case 1800: hash_type = HASH_TYPE_SHA512;
8566 salt_type = SALT_TYPE_EMBEDDED;
8567 attack_exec = ATTACK_EXEC_ON_CPU;
8568 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8569 kern_type = KERN_TYPE_SHA512CRYPT;
8570 dgst_size = DGST_SIZE_8_8;
8571 parse_func = sha512crypt_parse_hash;
8572 sort_by_digest = sort_by_digest_8_8;
8573 opti_type = OPTI_TYPE_ZERO_BYTE;
8574 dgst_pos0 = 0;
8575 dgst_pos1 = 1;
8576 dgst_pos2 = 2;
8577 dgst_pos3 = 3;
8578 break;
8579
8580 case 2100: hash_type = HASH_TYPE_DCC2;
8581 salt_type = SALT_TYPE_EMBEDDED;
8582 attack_exec = ATTACK_EXEC_ON_CPU;
8583 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
8584 | OPTS_TYPE_ST_LOWER
8585 | OPTS_TYPE_ST_UNICODE;
8586 kern_type = KERN_TYPE_DCC2;
8587 dgst_size = DGST_SIZE_4_4;
8588 parse_func = dcc2_parse_hash;
8589 sort_by_digest = sort_by_digest_4_4;
8590 opti_type = OPTI_TYPE_ZERO_BYTE;
8591 dgst_pos0 = 0;
8592 dgst_pos1 = 1;
8593 dgst_pos2 = 2;
8594 dgst_pos3 = 3;
8595 break;
8596
8597 case 2400: hash_type = HASH_TYPE_MD5;
8598 salt_type = SALT_TYPE_NONE;
8599 attack_exec = ATTACK_EXEC_ON_GPU;
8600 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8601 kern_type = KERN_TYPE_MD5PIX;
8602 dgst_size = DGST_SIZE_4_4;
8603 parse_func = md5pix_parse_hash;
8604 sort_by_digest = sort_by_digest_4_4;
8605 opti_type = OPTI_TYPE_ZERO_BYTE
8606 | OPTI_TYPE_PRECOMPUTE_INIT
8607 | OPTI_TYPE_PRECOMPUTE_MERKLE
8608 | OPTI_TYPE_SCALAR_MODE
8609 | OPTI_TYPE_EARLY_SKIP
8610 | OPTI_TYPE_NOT_ITERATED
8611 | OPTI_TYPE_NOT_SALTED;
8612 dgst_pos0 = 0;
8613 dgst_pos1 = 3;
8614 dgst_pos2 = 2;
8615 dgst_pos3 = 1;
8616 break;
8617
8618 case 2410: hash_type = HASH_TYPE_MD5;
8619 salt_type = SALT_TYPE_INTERN;
8620 attack_exec = ATTACK_EXEC_ON_GPU;
8621 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8622 kern_type = KERN_TYPE_MD5ASA;
8623 dgst_size = DGST_SIZE_4_4;
8624 parse_func = md5asa_parse_hash;
8625 sort_by_digest = sort_by_digest_4_4;
8626 opti_type = OPTI_TYPE_ZERO_BYTE
8627 | OPTI_TYPE_PRECOMPUTE_INIT
8628 | OPTI_TYPE_PRECOMPUTE_MERKLE
8629 | OPTI_TYPE_SCALAR_MODE
8630 | OPTI_TYPE_EARLY_SKIP
8631 | OPTI_TYPE_NOT_ITERATED;
8632 dgst_pos0 = 0;
8633 dgst_pos1 = 3;
8634 dgst_pos2 = 2;
8635 dgst_pos3 = 1;
8636 break;
8637
8638 case 2500: hash_type = HASH_TYPE_WPA;
8639 salt_type = SALT_TYPE_EMBEDDED;
8640 attack_exec = ATTACK_EXEC_ON_CPU;
8641 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8642 kern_type = KERN_TYPE_WPA;
8643 dgst_size = DGST_SIZE_4_4;
8644 parse_func = wpa_parse_hash;
8645 sort_by_digest = sort_by_digest_4_4;
8646 opti_type = OPTI_TYPE_ZERO_BYTE;
8647 dgst_pos0 = 0;
8648 dgst_pos1 = 1;
8649 dgst_pos2 = 2;
8650 dgst_pos3 = 3;
8651 break;
8652
8653 case 2600: hash_type = HASH_TYPE_MD5;
8654 salt_type = SALT_TYPE_VIRTUAL;
8655 attack_exec = ATTACK_EXEC_ON_GPU;
8656 opts_type = OPTS_TYPE_PT_GENERATE_LE
8657 | OPTS_TYPE_PT_ADD80
8658 | OPTS_TYPE_PT_ADDBITS14
8659 | OPTS_TYPE_ST_ADD80;
8660 kern_type = KERN_TYPE_MD55_PWSLT1;
8661 dgst_size = DGST_SIZE_4_4;
8662 parse_func = md5md5_parse_hash;
8663 sort_by_digest = sort_by_digest_4_4;
8664 opti_type = OPTI_TYPE_ZERO_BYTE
8665 | OPTI_TYPE_PRECOMPUTE_INIT
8666 | OPTI_TYPE_PRECOMPUTE_MERKLE
8667 | OPTI_TYPE_EARLY_SKIP;
8668 dgst_pos0 = 0;
8669 dgst_pos1 = 3;
8670 dgst_pos2 = 2;
8671 dgst_pos3 = 1;
8672 break;
8673
8674 case 2611: hash_type = HASH_TYPE_MD5;
8675 salt_type = SALT_TYPE_INTERN;
8676 attack_exec = ATTACK_EXEC_ON_GPU;
8677 opts_type = OPTS_TYPE_PT_GENERATE_LE
8678 | OPTS_TYPE_PT_ADD80
8679 | OPTS_TYPE_PT_ADDBITS14
8680 | OPTS_TYPE_ST_ADD80;
8681 kern_type = KERN_TYPE_MD55_PWSLT1;
8682 dgst_size = DGST_SIZE_4_4;
8683 parse_func = vb3_parse_hash;
8684 sort_by_digest = sort_by_digest_4_4;
8685 opti_type = OPTI_TYPE_ZERO_BYTE
8686 | OPTI_TYPE_PRECOMPUTE_INIT
8687 | OPTI_TYPE_PRECOMPUTE_MERKLE
8688 | OPTI_TYPE_EARLY_SKIP;
8689 dgst_pos0 = 0;
8690 dgst_pos1 = 3;
8691 dgst_pos2 = 2;
8692 dgst_pos3 = 1;
8693 break;
8694
8695 case 2612: hash_type = HASH_TYPE_MD5;
8696 salt_type = SALT_TYPE_EMBEDDED;
8697 attack_exec = ATTACK_EXEC_ON_GPU;
8698 opts_type = OPTS_TYPE_PT_GENERATE_LE
8699 | OPTS_TYPE_PT_ADD80
8700 | OPTS_TYPE_PT_ADDBITS14
8701 | OPTS_TYPE_ST_ADD80
8702 | OPTS_TYPE_ST_HEX;
8703 kern_type = KERN_TYPE_MD55_PWSLT1;
8704 dgst_size = DGST_SIZE_4_4;
8705 parse_func = phps_parse_hash;
8706 sort_by_digest = sort_by_digest_4_4;
8707 opti_type = OPTI_TYPE_ZERO_BYTE
8708 | OPTI_TYPE_PRECOMPUTE_INIT
8709 | OPTI_TYPE_PRECOMPUTE_MERKLE
8710 | OPTI_TYPE_EARLY_SKIP;
8711 dgst_pos0 = 0;
8712 dgst_pos1 = 3;
8713 dgst_pos2 = 2;
8714 dgst_pos3 = 1;
8715 break;
8716
8717 case 2711: hash_type = HASH_TYPE_MD5;
8718 salt_type = SALT_TYPE_INTERN;
8719 attack_exec = ATTACK_EXEC_ON_GPU;
8720 opts_type = OPTS_TYPE_PT_GENERATE_LE
8721 | OPTS_TYPE_PT_ADD80
8722 | OPTS_TYPE_PT_ADDBITS14
8723 | OPTS_TYPE_ST_ADD80;
8724 kern_type = KERN_TYPE_MD55_PWSLT2;
8725 dgst_size = DGST_SIZE_4_4;
8726 parse_func = vb30_parse_hash;
8727 sort_by_digest = sort_by_digest_4_4;
8728 opti_type = OPTI_TYPE_ZERO_BYTE
8729 | OPTI_TYPE_PRECOMPUTE_INIT
8730 | OPTI_TYPE_EARLY_SKIP;
8731 dgst_pos0 = 0;
8732 dgst_pos1 = 3;
8733 dgst_pos2 = 2;
8734 dgst_pos3 = 1;
8735 break;
8736
8737 case 2811: hash_type = HASH_TYPE_MD5;
8738 salt_type = SALT_TYPE_INTERN;
8739 attack_exec = ATTACK_EXEC_ON_GPU;
8740 opts_type = OPTS_TYPE_PT_GENERATE_LE
8741 | OPTS_TYPE_PT_ADD80
8742 | OPTS_TYPE_PT_ADDBITS14;
8743 kern_type = KERN_TYPE_MD55_SLTPW;
8744 dgst_size = DGST_SIZE_4_4;
8745 parse_func = ipb2_parse_hash;
8746 sort_by_digest = sort_by_digest_4_4;
8747 opti_type = OPTI_TYPE_ZERO_BYTE
8748 | OPTI_TYPE_PRECOMPUTE_INIT
8749 | OPTI_TYPE_EARLY_SKIP;
8750 dgst_pos0 = 0;
8751 dgst_pos1 = 3;
8752 dgst_pos2 = 2;
8753 dgst_pos3 = 1;
8754 break;
8755
8756 case 3000: hash_type = HASH_TYPE_LM;
8757 salt_type = SALT_TYPE_NONE;
8758 attack_exec = ATTACK_EXEC_ON_GPU;
8759 opts_type = OPTS_TYPE_PT_GENERATE_LE
8760 | OPTS_TYPE_PT_UPPER
8761 | OPTS_TYPE_PT_BITSLICE;
8762 kern_type = KERN_TYPE_LM;
8763 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8764 parse_func = lm_parse_hash;
8765 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8766 opti_type = OPTI_TYPE_ZERO_BYTE
8767 | OPTI_TYPE_SCALAR_MODE
8768 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8769 dgst_pos0 = 0;
8770 dgst_pos1 = 1;
8771 dgst_pos2 = 2;
8772 dgst_pos3 = 3;
8773 break;
8774
8775 case 3100: hash_type = HASH_TYPE_ORACLEH;
8776 salt_type = SALT_TYPE_INTERN;
8777 attack_exec = ATTACK_EXEC_ON_GPU;
8778 opts_type = OPTS_TYPE_PT_GENERATE_LE
8779 | OPTS_TYPE_PT_UPPER
8780 | OPTS_TYPE_ST_UPPER;
8781 kern_type = KERN_TYPE_ORACLEH;
8782 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8783 parse_func = oracleh_parse_hash;
8784 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8785 opti_type = OPTI_TYPE_ZERO_BYTE
8786 | OPTI_TYPE_SCALAR_MODE;
8787 dgst_pos0 = 0;
8788 dgst_pos1 = 1;
8789 dgst_pos2 = 2;
8790 dgst_pos3 = 3;
8791 break;
8792
8793 case 3200: hash_type = HASH_TYPE_BCRYPT;
8794 salt_type = SALT_TYPE_EMBEDDED;
8795 attack_exec = ATTACK_EXEC_ON_CPU;
8796 opts_type = OPTS_TYPE_PT_GENERATE_LE
8797 | OPTS_TYPE_ST_GENERATE_LE;
8798 kern_type = KERN_TYPE_BCRYPT;
8799 dgst_size = DGST_SIZE_4_6;
8800 parse_func = bcrypt_parse_hash;
8801 sort_by_digest = sort_by_digest_4_6;
8802 opti_type = OPTI_TYPE_ZERO_BYTE;
8803 dgst_pos0 = 0;
8804 dgst_pos1 = 1;
8805 dgst_pos2 = 2;
8806 dgst_pos3 = 3;
8807 break;
8808
8809 case 3710: hash_type = HASH_TYPE_MD5;
8810 salt_type = SALT_TYPE_INTERN;
8811 attack_exec = ATTACK_EXEC_ON_GPU;
8812 opts_type = OPTS_TYPE_PT_GENERATE_LE
8813 | OPTS_TYPE_PT_ADD80
8814 | OPTS_TYPE_PT_ADDBITS14;
8815 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8816 dgst_size = DGST_SIZE_4_4;
8817 parse_func = md5s_parse_hash;
8818 sort_by_digest = sort_by_digest_4_4;
8819 opti_type = OPTI_TYPE_ZERO_BYTE
8820 | OPTI_TYPE_PRECOMPUTE_INIT
8821 | OPTI_TYPE_PRECOMPUTE_MERKLE
8822 | OPTI_TYPE_EARLY_SKIP;
8823 dgst_pos0 = 0;
8824 dgst_pos1 = 3;
8825 dgst_pos2 = 2;
8826 dgst_pos3 = 1;
8827 break;
8828
8829 case 3711: hash_type = HASH_TYPE_MD5;
8830 salt_type = SALT_TYPE_EMBEDDED;
8831 attack_exec = ATTACK_EXEC_ON_GPU;
8832 opts_type = OPTS_TYPE_PT_GENERATE_LE
8833 | OPTS_TYPE_PT_ADD80
8834 | OPTS_TYPE_PT_ADDBITS14;
8835 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8836 dgst_size = DGST_SIZE_4_4;
8837 parse_func = mediawiki_b_parse_hash;
8838 sort_by_digest = sort_by_digest_4_4;
8839 opti_type = OPTI_TYPE_ZERO_BYTE
8840 | OPTI_TYPE_PRECOMPUTE_INIT
8841 | OPTI_TYPE_PRECOMPUTE_MERKLE
8842 | OPTI_TYPE_EARLY_SKIP;
8843 dgst_pos0 = 0;
8844 dgst_pos1 = 3;
8845 dgst_pos2 = 2;
8846 dgst_pos3 = 1;
8847 break;
8848
8849 case 3800: hash_type = HASH_TYPE_MD5;
8850 salt_type = SALT_TYPE_INTERN;
8851 attack_exec = ATTACK_EXEC_ON_GPU;
8852 opts_type = OPTS_TYPE_PT_GENERATE_LE
8853 | OPTS_TYPE_ST_ADDBITS14;
8854 kern_type = KERN_TYPE_MD5_SLT_PW_SLT;
8855 dgst_size = DGST_SIZE_4_4;
8856 parse_func = md5s_parse_hash;
8857 sort_by_digest = sort_by_digest_4_4;
8858 opti_type = OPTI_TYPE_ZERO_BYTE
8859 | OPTI_TYPE_PRECOMPUTE_INIT
8860 | OPTI_TYPE_PRECOMPUTE_MERKLE
8861 | OPTI_TYPE_EARLY_SKIP
8862 | OPTI_TYPE_NOT_ITERATED
8863 | OPTI_TYPE_RAW_HASH;
8864 dgst_pos0 = 0;
8865 dgst_pos1 = 3;
8866 dgst_pos2 = 2;
8867 dgst_pos3 = 1;
8868 break;
8869
8870 case 4300: hash_type = HASH_TYPE_MD5;
8871 salt_type = SALT_TYPE_VIRTUAL;
8872 attack_exec = ATTACK_EXEC_ON_GPU;
8873 opts_type = OPTS_TYPE_PT_GENERATE_LE
8874 | OPTS_TYPE_PT_ADD80
8875 | OPTS_TYPE_PT_ADDBITS14
8876 | OPTS_TYPE_ST_ADD80;
8877 kern_type = KERN_TYPE_MD5U5_PWSLT1;
8878 dgst_size = DGST_SIZE_4_4;
8879 parse_func = md5md5_parse_hash;
8880 sort_by_digest = sort_by_digest_4_4;
8881 opti_type = OPTI_TYPE_ZERO_BYTE
8882 | OPTI_TYPE_PRECOMPUTE_INIT
8883 | OPTI_TYPE_PRECOMPUTE_MERKLE
8884 | OPTI_TYPE_EARLY_SKIP;
8885 dgst_pos0 = 0;
8886 dgst_pos1 = 3;
8887 dgst_pos2 = 2;
8888 dgst_pos3 = 1;
8889 break;
8890
8891
8892 case 4400: hash_type = HASH_TYPE_MD5;
8893 salt_type = SALT_TYPE_NONE;
8894 attack_exec = ATTACK_EXEC_ON_GPU;
8895 opts_type = OPTS_TYPE_PT_GENERATE_BE
8896 | OPTS_TYPE_PT_ADD80
8897 | OPTS_TYPE_PT_ADDBITS15;
8898 kern_type = KERN_TYPE_MD5_SHA1;
8899 dgst_size = DGST_SIZE_4_4;
8900 parse_func = md5_parse_hash;
8901 sort_by_digest = sort_by_digest_4_4;
8902 opti_type = OPTI_TYPE_ZERO_BYTE
8903 | OPTI_TYPE_PRECOMPUTE_INIT
8904 | OPTI_TYPE_PRECOMPUTE_MERKLE
8905 | OPTI_TYPE_EARLY_SKIP
8906 | OPTI_TYPE_NOT_ITERATED
8907 | OPTI_TYPE_NOT_SALTED
8908 | OPTI_TYPE_RAW_HASH;
8909 dgst_pos0 = 0;
8910 dgst_pos1 = 3;
8911 dgst_pos2 = 2;
8912 dgst_pos3 = 1;
8913 break;
8914
8915 case 4500: hash_type = HASH_TYPE_SHA1;
8916 salt_type = SALT_TYPE_NONE;
8917 attack_exec = ATTACK_EXEC_ON_GPU;
8918 opts_type = OPTS_TYPE_PT_GENERATE_BE
8919 | OPTS_TYPE_PT_ADD80
8920 | OPTS_TYPE_PT_ADDBITS15;
8921 kern_type = KERN_TYPE_SHA11;
8922 dgst_size = DGST_SIZE_4_5;
8923 parse_func = sha1_parse_hash;
8924 sort_by_digest = sort_by_digest_4_5;
8925 opti_type = OPTI_TYPE_ZERO_BYTE
8926 | OPTI_TYPE_PRECOMPUTE_INIT
8927 | OPTI_TYPE_PRECOMPUTE_MERKLE
8928 | OPTI_TYPE_EARLY_SKIP
8929 | OPTI_TYPE_NOT_SALTED;
8930 dgst_pos0 = 3;
8931 dgst_pos1 = 4;
8932 dgst_pos2 = 2;
8933 dgst_pos3 = 1;
8934 break;
8935
8936 case 4700: hash_type = HASH_TYPE_SHA1;
8937 salt_type = SALT_TYPE_NONE;
8938 attack_exec = ATTACK_EXEC_ON_GPU;
8939 opts_type = OPTS_TYPE_PT_GENERATE_LE
8940 | OPTS_TYPE_PT_ADD80
8941 | OPTS_TYPE_PT_ADDBITS14;
8942 kern_type = KERN_TYPE_SHA1_MD5;
8943 dgst_size = DGST_SIZE_4_5;
8944 parse_func = sha1_parse_hash;
8945 sort_by_digest = sort_by_digest_4_5;
8946 opti_type = OPTI_TYPE_ZERO_BYTE
8947 | OPTI_TYPE_PRECOMPUTE_INIT
8948 | OPTI_TYPE_PRECOMPUTE_MERKLE
8949 | OPTI_TYPE_EARLY_SKIP
8950 | OPTI_TYPE_NOT_ITERATED
8951 | OPTI_TYPE_NOT_SALTED
8952 | OPTI_TYPE_RAW_HASH;
8953 dgst_pos0 = 3;
8954 dgst_pos1 = 4;
8955 dgst_pos2 = 2;
8956 dgst_pos3 = 1;
8957 break;
8958
8959 case 4800: hash_type = HASH_TYPE_MD5;
8960 salt_type = SALT_TYPE_EMBEDDED;
8961 attack_exec = ATTACK_EXEC_ON_GPU;
8962 opts_type = OPTS_TYPE_PT_GENERATE_LE
8963 | OPTS_TYPE_PT_ADDBITS14;
8964 kern_type = KERN_TYPE_MD5_CHAP;
8965 dgst_size = DGST_SIZE_4_4;
8966 parse_func = chap_parse_hash;
8967 sort_by_digest = sort_by_digest_4_4;
8968 opti_type = OPTI_TYPE_ZERO_BYTE
8969 | OPTI_TYPE_PRECOMPUTE_INIT
8970 | OPTI_TYPE_PRECOMPUTE_MERKLE
8971 | OPTI_TYPE_MEET_IN_MIDDLE
8972 | OPTI_TYPE_EARLY_SKIP
8973 | OPTI_TYPE_NOT_ITERATED
8974 | OPTI_TYPE_RAW_HASH;
8975 dgst_pos0 = 0;
8976 dgst_pos1 = 3;
8977 dgst_pos2 = 2;
8978 dgst_pos3 = 1;
8979 break;
8980
8981 case 4900: hash_type = HASH_TYPE_SHA1;
8982 salt_type = SALT_TYPE_INTERN;
8983 attack_exec = ATTACK_EXEC_ON_GPU;
8984 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8985 kern_type = KERN_TYPE_SHA1_SLT_PW_SLT;
8986 dgst_size = DGST_SIZE_4_5;
8987 parse_func = sha1s_parse_hash;
8988 sort_by_digest = sort_by_digest_4_5;
8989 opti_type = OPTI_TYPE_ZERO_BYTE
8990 | OPTI_TYPE_PRECOMPUTE_INIT
8991 | OPTI_TYPE_PRECOMPUTE_MERKLE
8992 | OPTI_TYPE_EARLY_SKIP;
8993 dgst_pos0 = 3;
8994 dgst_pos1 = 4;
8995 dgst_pos2 = 2;
8996 dgst_pos3 = 1;
8997 break;
8998
8999 case 5000: hash_type = HASH_TYPE_KECCAK;
9000 salt_type = SALT_TYPE_EMBEDDED;
9001 attack_exec = ATTACK_EXEC_ON_GPU;
9002 opts_type = OPTS_TYPE_PT_GENERATE_LE
9003 | OPTS_TYPE_PT_ADD01;
9004 kern_type = KERN_TYPE_KECCAK;
9005 dgst_size = DGST_SIZE_8_25;
9006 parse_func = keccak_parse_hash;
9007 sort_by_digest = sort_by_digest_8_25;
9008 opti_type = OPTI_TYPE_ZERO_BYTE
9009 | OPTI_TYPE_RAW_HASH;
9010 dgst_pos0 = 2;
9011 dgst_pos1 = 3;
9012 dgst_pos2 = 4;
9013 dgst_pos3 = 5;
9014 break;
9015
9016 case 5100: hash_type = HASH_TYPE_MD5H;
9017 salt_type = SALT_TYPE_NONE;
9018 attack_exec = ATTACK_EXEC_ON_GPU;
9019 opts_type = OPTS_TYPE_PT_GENERATE_LE
9020 | OPTS_TYPE_PT_ADD80
9021 | OPTS_TYPE_PT_ADDBITS14;
9022 kern_type = KERN_TYPE_MD5H;
9023 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9024 parse_func = md5half_parse_hash;
9025 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9026 opti_type = OPTI_TYPE_ZERO_BYTE
9027 | OPTI_TYPE_RAW_HASH;
9028 dgst_pos0 = 0;
9029 dgst_pos1 = 1;
9030 dgst_pos2 = 2;
9031 dgst_pos3 = 3;
9032 break;
9033
9034 case 5200: hash_type = HASH_TYPE_SHA256;
9035 salt_type = SALT_TYPE_EMBEDDED;
9036 attack_exec = ATTACK_EXEC_ON_CPU;
9037 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9038 kern_type = KERN_TYPE_PSAFE3;
9039 dgst_size = DGST_SIZE_4_8;
9040 parse_func = psafe3_parse_hash;
9041 sort_by_digest = sort_by_digest_4_8;
9042 opti_type = OPTI_TYPE_ZERO_BYTE;
9043 dgst_pos0 = 0;
9044 dgst_pos1 = 1;
9045 dgst_pos2 = 2;
9046 dgst_pos3 = 3;
9047 break;
9048
9049 case 5300: hash_type = HASH_TYPE_MD5;
9050 salt_type = SALT_TYPE_EMBEDDED;
9051 attack_exec = ATTACK_EXEC_ON_GPU;
9052 opts_type = OPTS_TYPE_PT_GENERATE_LE
9053 | OPTS_TYPE_ST_ADD80;
9054 kern_type = KERN_TYPE_IKEPSK_MD5;
9055 dgst_size = DGST_SIZE_4_4;
9056 parse_func = ikepsk_md5_parse_hash;
9057 sort_by_digest = sort_by_digest_4_4;
9058 opti_type = OPTI_TYPE_ZERO_BYTE;
9059 dgst_pos0 = 0;
9060 dgst_pos1 = 3;
9061 dgst_pos2 = 2;
9062 dgst_pos3 = 1;
9063 break;
9064
9065 case 5400: hash_type = HASH_TYPE_SHA1;
9066 salt_type = SALT_TYPE_EMBEDDED;
9067 attack_exec = ATTACK_EXEC_ON_GPU;
9068 opts_type = OPTS_TYPE_PT_GENERATE_BE
9069 | OPTS_TYPE_ST_ADD80;
9070 kern_type = KERN_TYPE_IKEPSK_SHA1;
9071 dgst_size = DGST_SIZE_4_5;
9072 parse_func = ikepsk_sha1_parse_hash;
9073 sort_by_digest = sort_by_digest_4_5;
9074 opti_type = OPTI_TYPE_ZERO_BYTE;
9075 dgst_pos0 = 3;
9076 dgst_pos1 = 4;
9077 dgst_pos2 = 2;
9078 dgst_pos3 = 1;
9079 break;
9080
9081 case 5500: hash_type = HASH_TYPE_NETNTLM;
9082 salt_type = SALT_TYPE_EMBEDDED;
9083 attack_exec = ATTACK_EXEC_ON_GPU;
9084 opts_type = OPTS_TYPE_PT_GENERATE_LE
9085 | OPTS_TYPE_PT_ADD80
9086 | OPTS_TYPE_PT_ADDBITS14
9087 | OPTS_TYPE_PT_UNICODE
9088 | OPTS_TYPE_ST_HEX;
9089 kern_type = KERN_TYPE_NETNTLMv1;
9090 dgst_size = DGST_SIZE_4_4;
9091 parse_func = netntlmv1_parse_hash;
9092 sort_by_digest = sort_by_digest_4_4;
9093 opti_type = OPTI_TYPE_ZERO_BYTE
9094 | OPTI_TYPE_SCALAR_MODE
9095 | OPTI_TYPE_PRECOMPUTE_PERMUT;
9096 dgst_pos0 = 0;
9097 dgst_pos1 = 1;
9098 dgst_pos2 = 2;
9099 dgst_pos3 = 3;
9100 break;
9101
9102 case 5600: hash_type = HASH_TYPE_MD5;
9103 salt_type = SALT_TYPE_EMBEDDED;
9104 attack_exec = ATTACK_EXEC_ON_GPU;
9105 opts_type = OPTS_TYPE_PT_GENERATE_LE
9106 | OPTS_TYPE_PT_ADD80
9107 | OPTS_TYPE_PT_ADDBITS14
9108 | OPTS_TYPE_PT_UNICODE;
9109 kern_type = KERN_TYPE_NETNTLMv2;
9110 dgst_size = DGST_SIZE_4_4;
9111 parse_func = netntlmv2_parse_hash;
9112 sort_by_digest = sort_by_digest_4_4;
9113 opti_type = OPTI_TYPE_ZERO_BYTE;
9114 dgst_pos0 = 0;
9115 dgst_pos1 = 3;
9116 dgst_pos2 = 2;
9117 dgst_pos3 = 1;
9118 break;
9119
9120 case 5700: hash_type = HASH_TYPE_SHA256;
9121 salt_type = SALT_TYPE_NONE;
9122 attack_exec = ATTACK_EXEC_ON_GPU;
9123 opts_type = OPTS_TYPE_PT_GENERATE_BE
9124 | OPTS_TYPE_PT_ADD80
9125 | OPTS_TYPE_PT_ADDBITS15;
9126 kern_type = KERN_TYPE_SHA256;
9127 dgst_size = DGST_SIZE_4_8;
9128 parse_func = cisco4_parse_hash;
9129 sort_by_digest = sort_by_digest_4_8;
9130 opti_type = OPTI_TYPE_ZERO_BYTE
9131 | OPTI_TYPE_PRECOMPUTE_INIT
9132 | OPTI_TYPE_PRECOMPUTE_MERKLE
9133 | OPTI_TYPE_SCALAR_MODE
9134 | OPTI_TYPE_EARLY_SKIP
9135 | OPTI_TYPE_NOT_ITERATED
9136 | OPTI_TYPE_NOT_SALTED
9137 | OPTI_TYPE_RAW_HASH;
9138 dgst_pos0 = 3;
9139 dgst_pos1 = 7;
9140 dgst_pos2 = 2;
9141 dgst_pos3 = 6;
9142 break;
9143
9144 case 5800: hash_type = HASH_TYPE_SHA1;
9145 salt_type = SALT_TYPE_INTERN;
9146 attack_exec = ATTACK_EXEC_ON_CPU;
9147 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
9148 | OPTS_TYPE_ST_ADD80;
9149 kern_type = KERN_TYPE_ANDROIDPIN;
9150 dgst_size = DGST_SIZE_4_5;
9151 parse_func = androidpin_parse_hash;
9152 sort_by_digest = sort_by_digest_4_5;
9153 opti_type = OPTI_TYPE_ZERO_BYTE;
9154 dgst_pos0 = 0;
9155 dgst_pos1 = 1;
9156 dgst_pos2 = 2;
9157 dgst_pos3 = 3;
9158 break;
9159
9160 case 6000: hash_type = HASH_TYPE_RIPEMD160;
9161 salt_type = SALT_TYPE_NONE;
9162 attack_exec = ATTACK_EXEC_ON_GPU;
9163 opts_type = OPTS_TYPE_PT_GENERATE_LE
9164 | OPTS_TYPE_PT_ADD80;
9165 kern_type = KERN_TYPE_RIPEMD160;
9166 dgst_size = DGST_SIZE_4_5;
9167 parse_func = ripemd160_parse_hash;
9168 sort_by_digest = sort_by_digest_4_5;
9169 opti_type = OPTI_TYPE_ZERO_BYTE;
9170 dgst_pos0 = 0;
9171 dgst_pos1 = 1;
9172 dgst_pos2 = 2;
9173 dgst_pos3 = 3;
9174 break;
9175
9176 case 6100: hash_type = HASH_TYPE_WHIRLPOOL;
9177 salt_type = SALT_TYPE_NONE;
9178 attack_exec = ATTACK_EXEC_ON_GPU;
9179 opts_type = OPTS_TYPE_PT_GENERATE_BE
9180 | OPTS_TYPE_PT_ADD80;
9181 kern_type = KERN_TYPE_WHIRLPOOL;
9182 dgst_size = DGST_SIZE_4_16;
9183 parse_func = whirlpool_parse_hash;
9184 sort_by_digest = sort_by_digest_4_16;
9185 opti_type = OPTI_TYPE_ZERO_BYTE;
9186 dgst_pos0 = 0;
9187 dgst_pos1 = 1;
9188 dgst_pos2 = 2;
9189 dgst_pos3 = 3;
9190 break;
9191
9192 case 6211: hash_type = HASH_TYPE_RIPEMD160;
9193 salt_type = SALT_TYPE_EMBEDDED;
9194 attack_exec = ATTACK_EXEC_ON_CPU;
9195 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9196 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
9197 dgst_size = DGST_SIZE_4_5;
9198 parse_func = truecrypt_parse_hash_2k;
9199 sort_by_digest = sort_by_digest_4_5;
9200 opti_type = OPTI_TYPE_ZERO_BYTE;
9201 dgst_pos0 = 0;
9202 dgst_pos1 = 1;
9203 dgst_pos2 = 2;
9204 dgst_pos3 = 3;
9205 break;
9206
9207 case 6212: hash_type = HASH_TYPE_RIPEMD160;
9208 salt_type = SALT_TYPE_EMBEDDED;
9209 attack_exec = ATTACK_EXEC_ON_CPU;
9210 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9211 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
9212 dgst_size = DGST_SIZE_4_5;
9213 parse_func = truecrypt_parse_hash_2k;
9214 sort_by_digest = sort_by_digest_4_5;
9215 opti_type = OPTI_TYPE_ZERO_BYTE;
9216 dgst_pos0 = 0;
9217 dgst_pos1 = 1;
9218 dgst_pos2 = 2;
9219 dgst_pos3 = 3;
9220 break;
9221
9222 case 6213: hash_type = HASH_TYPE_RIPEMD160;
9223 salt_type = SALT_TYPE_EMBEDDED;
9224 attack_exec = ATTACK_EXEC_ON_CPU;
9225 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9226 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
9227 dgst_size = DGST_SIZE_4_5;
9228 parse_func = truecrypt_parse_hash_2k;
9229 sort_by_digest = sort_by_digest_4_5;
9230 opti_type = OPTI_TYPE_ZERO_BYTE;
9231 dgst_pos0 = 0;
9232 dgst_pos1 = 1;
9233 dgst_pos2 = 2;
9234 dgst_pos3 = 3;
9235 break;
9236
9237 case 6221: hash_type = HASH_TYPE_SHA512;
9238 salt_type = SALT_TYPE_EMBEDDED;
9239 attack_exec = ATTACK_EXEC_ON_CPU;
9240 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9241 kern_type = KERN_TYPE_TCSHA512_XTS512;
9242 dgst_size = DGST_SIZE_8_8;
9243 parse_func = truecrypt_parse_hash_1k;
9244 sort_by_digest = sort_by_digest_8_8;
9245 opti_type = OPTI_TYPE_ZERO_BYTE;
9246 dgst_pos0 = 0;
9247 dgst_pos1 = 1;
9248 dgst_pos2 = 2;
9249 dgst_pos3 = 3;
9250 break;
9251
9252 case 6222: hash_type = HASH_TYPE_SHA512;
9253 salt_type = SALT_TYPE_EMBEDDED;
9254 attack_exec = ATTACK_EXEC_ON_CPU;
9255 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9256 kern_type = KERN_TYPE_TCSHA512_XTS1024;
9257 dgst_size = DGST_SIZE_8_8;
9258 parse_func = truecrypt_parse_hash_1k;
9259 sort_by_digest = sort_by_digest_8_8;
9260 opti_type = OPTI_TYPE_ZERO_BYTE;
9261 dgst_pos0 = 0;
9262 dgst_pos1 = 1;
9263 dgst_pos2 = 2;
9264 dgst_pos3 = 3;
9265 break;
9266
9267 case 6223: hash_type = HASH_TYPE_SHA512;
9268 salt_type = SALT_TYPE_EMBEDDED;
9269 attack_exec = ATTACK_EXEC_ON_CPU;
9270 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9271 kern_type = KERN_TYPE_TCSHA512_XTS1536;
9272 dgst_size = DGST_SIZE_8_8;
9273 parse_func = truecrypt_parse_hash_1k;
9274 sort_by_digest = sort_by_digest_8_8;
9275 opti_type = OPTI_TYPE_ZERO_BYTE;
9276 dgst_pos0 = 0;
9277 dgst_pos1 = 1;
9278 dgst_pos2 = 2;
9279 dgst_pos3 = 3;
9280 break;
9281
9282 case 6231: hash_type = HASH_TYPE_WHIRLPOOL;
9283 salt_type = SALT_TYPE_EMBEDDED;
9284 attack_exec = ATTACK_EXEC_ON_CPU;
9285 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9286 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS512;
9287 dgst_size = DGST_SIZE_4_8;
9288 parse_func = truecrypt_parse_hash_1k;
9289 sort_by_digest = sort_by_digest_4_8;
9290 opti_type = OPTI_TYPE_ZERO_BYTE;
9291 dgst_pos0 = 0;
9292 dgst_pos1 = 1;
9293 dgst_pos2 = 2;
9294 dgst_pos3 = 3;
9295 break;
9296
9297 case 6232: hash_type = HASH_TYPE_WHIRLPOOL;
9298 salt_type = SALT_TYPE_EMBEDDED;
9299 attack_exec = ATTACK_EXEC_ON_CPU;
9300 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9301 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1024;
9302 dgst_size = DGST_SIZE_4_8;
9303 parse_func = truecrypt_parse_hash_1k;
9304 sort_by_digest = sort_by_digest_4_8;
9305 opti_type = OPTI_TYPE_ZERO_BYTE;
9306 dgst_pos0 = 0;
9307 dgst_pos1 = 1;
9308 dgst_pos2 = 2;
9309 dgst_pos3 = 3;
9310 break;
9311
9312 case 6233: hash_type = HASH_TYPE_WHIRLPOOL;
9313 salt_type = SALT_TYPE_EMBEDDED;
9314 attack_exec = ATTACK_EXEC_ON_CPU;
9315 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9316 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1536;
9317 dgst_size = DGST_SIZE_4_8;
9318 parse_func = truecrypt_parse_hash_1k;
9319 sort_by_digest = sort_by_digest_4_8;
9320 opti_type = OPTI_TYPE_ZERO_BYTE;
9321 dgst_pos0 = 0;
9322 dgst_pos1 = 1;
9323 dgst_pos2 = 2;
9324 dgst_pos3 = 3;
9325 break;
9326
9327 case 6241: hash_type = HASH_TYPE_RIPEMD160;
9328 salt_type = SALT_TYPE_EMBEDDED;
9329 attack_exec = ATTACK_EXEC_ON_CPU;
9330 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9331 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
9332 dgst_size = DGST_SIZE_4_5;
9333 parse_func = truecrypt_parse_hash_1k;
9334 sort_by_digest = sort_by_digest_4_5;
9335 opti_type = OPTI_TYPE_ZERO_BYTE;
9336 dgst_pos0 = 0;
9337 dgst_pos1 = 1;
9338 dgst_pos2 = 2;
9339 dgst_pos3 = 3;
9340 break;
9341
9342 case 6242: hash_type = HASH_TYPE_RIPEMD160;
9343 salt_type = SALT_TYPE_EMBEDDED;
9344 attack_exec = ATTACK_EXEC_ON_CPU;
9345 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9346 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
9347 dgst_size = DGST_SIZE_4_5;
9348 parse_func = truecrypt_parse_hash_1k;
9349 sort_by_digest = sort_by_digest_4_5;
9350 opti_type = OPTI_TYPE_ZERO_BYTE;
9351 dgst_pos0 = 0;
9352 dgst_pos1 = 1;
9353 dgst_pos2 = 2;
9354 dgst_pos3 = 3;
9355 break;
9356
9357 case 6243: hash_type = HASH_TYPE_RIPEMD160;
9358 salt_type = SALT_TYPE_EMBEDDED;
9359 attack_exec = ATTACK_EXEC_ON_CPU;
9360 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9361 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
9362 dgst_size = DGST_SIZE_4_5;
9363 parse_func = truecrypt_parse_hash_1k;
9364 sort_by_digest = sort_by_digest_4_5;
9365 opti_type = OPTI_TYPE_ZERO_BYTE;
9366 dgst_pos0 = 0;
9367 dgst_pos1 = 1;
9368 dgst_pos2 = 2;
9369 dgst_pos3 = 3;
9370 break;
9371
9372 case 6300: hash_type = HASH_TYPE_MD5;
9373 salt_type = SALT_TYPE_EMBEDDED;
9374 attack_exec = ATTACK_EXEC_ON_CPU;
9375 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9376 kern_type = KERN_TYPE_MD5AIX;
9377 dgst_size = DGST_SIZE_4_4;
9378 parse_func = md5aix_parse_hash;
9379 sort_by_digest = sort_by_digest_4_4;
9380 opti_type = OPTI_TYPE_ZERO_BYTE;
9381 dgst_pos0 = 0;
9382 dgst_pos1 = 1;
9383 dgst_pos2 = 2;
9384 dgst_pos3 = 3;
9385 break;
9386
9387 case 6400: hash_type = HASH_TYPE_SHA256;
9388 salt_type = SALT_TYPE_EMBEDDED;
9389 attack_exec = ATTACK_EXEC_ON_CPU;
9390 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9391 kern_type = KERN_TYPE_SHA256AIX;
9392 dgst_size = DGST_SIZE_4_8;
9393 parse_func = sha256aix_parse_hash;
9394 sort_by_digest = sort_by_digest_4_8;
9395 opti_type = OPTI_TYPE_ZERO_BYTE;
9396 dgst_pos0 = 0;
9397 dgst_pos1 = 1;
9398 dgst_pos2 = 2;
9399 dgst_pos3 = 3;
9400 break;
9401
9402 case 6500: hash_type = HASH_TYPE_SHA512;
9403 salt_type = SALT_TYPE_EMBEDDED;
9404 attack_exec = ATTACK_EXEC_ON_CPU;
9405 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9406 kern_type = KERN_TYPE_SHA512AIX;
9407 dgst_size = DGST_SIZE_8_8;
9408 parse_func = sha512aix_parse_hash;
9409 sort_by_digest = sort_by_digest_8_8;
9410 opti_type = OPTI_TYPE_ZERO_BYTE;
9411 dgst_pos0 = 0;
9412 dgst_pos1 = 1;
9413 dgst_pos2 = 2;
9414 dgst_pos3 = 3;
9415 break;
9416
9417 case 6600: hash_type = HASH_TYPE_AES;
9418 salt_type = SALT_TYPE_EMBEDDED;
9419 attack_exec = ATTACK_EXEC_ON_CPU;
9420 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9421 kern_type = KERN_TYPE_AGILEKEY;
9422 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
9423 parse_func = agilekey_parse_hash;
9424 sort_by_digest = sort_by_digest_4_5;
9425 opti_type = OPTI_TYPE_ZERO_BYTE;
9426 dgst_pos0 = 0;
9427 dgst_pos1 = 1;
9428 dgst_pos2 = 2;
9429 dgst_pos3 = 3;
9430 break;
9431
9432 case 6700: hash_type = HASH_TYPE_SHA1;
9433 salt_type = SALT_TYPE_EMBEDDED;
9434 attack_exec = ATTACK_EXEC_ON_CPU;
9435 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9436 kern_type = KERN_TYPE_SHA1AIX;
9437 dgst_size = DGST_SIZE_4_5;
9438 parse_func = sha1aix_parse_hash;
9439 sort_by_digest = sort_by_digest_4_5;
9440 opti_type = OPTI_TYPE_ZERO_BYTE;
9441 dgst_pos0 = 0;
9442 dgst_pos1 = 1;
9443 dgst_pos2 = 2;
9444 dgst_pos3 = 3;
9445 break;
9446
9447 case 6800: hash_type = HASH_TYPE_AES;
9448 salt_type = SALT_TYPE_EMBEDDED;
9449 attack_exec = ATTACK_EXEC_ON_CPU;
9450 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9451 kern_type = KERN_TYPE_LASTPASS;
9452 dgst_size = DGST_SIZE_4_8; // because kernel uses _SHA256_
9453 parse_func = lastpass_parse_hash;
9454 sort_by_digest = sort_by_digest_4_8;
9455 opti_type = OPTI_TYPE_ZERO_BYTE;
9456 dgst_pos0 = 0;
9457 dgst_pos1 = 1;
9458 dgst_pos2 = 2;
9459 dgst_pos3 = 3;
9460 break;
9461
9462 case 6900: hash_type = HASH_TYPE_GOST;
9463 salt_type = SALT_TYPE_NONE;
9464 attack_exec = ATTACK_EXEC_ON_GPU;
9465 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9466 kern_type = KERN_TYPE_GOST;
9467 dgst_size = DGST_SIZE_4_8;
9468 parse_func = gost_parse_hash;
9469 sort_by_digest = sort_by_digest_4_8;
9470 opti_type = OPTI_TYPE_ZERO_BYTE;
9471 dgst_pos0 = 0;
9472 dgst_pos1 = 1;
9473 dgst_pos2 = 2;
9474 dgst_pos3 = 3;
9475 break;
9476
9477 case 7100: hash_type = HASH_TYPE_SHA512;
9478 salt_type = SALT_TYPE_EMBEDDED;
9479 attack_exec = ATTACK_EXEC_ON_CPU;
9480 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9481 kern_type = KERN_TYPE_PBKDF2_SHA512;
9482 dgst_size = DGST_SIZE_8_16;
9483 parse_func = sha512osx_parse_hash;
9484 sort_by_digest = sort_by_digest_8_16;
9485 opti_type = OPTI_TYPE_ZERO_BYTE;
9486 dgst_pos0 = 0;
9487 dgst_pos1 = 1;
9488 dgst_pos2 = 2;
9489 dgst_pos3 = 3;
9490 break;
9491
9492 case 7200: hash_type = HASH_TYPE_SHA512;
9493 salt_type = SALT_TYPE_EMBEDDED;
9494 attack_exec = ATTACK_EXEC_ON_CPU;
9495 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9496 kern_type = KERN_TYPE_PBKDF2_SHA512;
9497 dgst_size = DGST_SIZE_8_16;
9498 parse_func = sha512grub_parse_hash;
9499 sort_by_digest = sort_by_digest_8_16;
9500 opti_type = OPTI_TYPE_ZERO_BYTE;
9501 dgst_pos0 = 0;
9502 dgst_pos1 = 1;
9503 dgst_pos2 = 2;
9504 dgst_pos3 = 3;
9505 break;
9506
9507 case 7300: hash_type = HASH_TYPE_SHA1;
9508 salt_type = SALT_TYPE_EMBEDDED;
9509 attack_exec = ATTACK_EXEC_ON_GPU;
9510 opts_type = OPTS_TYPE_PT_GENERATE_BE
9511 | OPTS_TYPE_ST_ADD80
9512 | OPTS_TYPE_ST_ADDBITS15;
9513 kern_type = KERN_TYPE_RAKP;
9514 dgst_size = DGST_SIZE_4_5;
9515 parse_func = rakp_parse_hash;
9516 sort_by_digest = sort_by_digest_4_5;
9517 opti_type = OPTI_TYPE_ZERO_BYTE
9518 | OPTI_TYPE_NOT_ITERATED;
9519 dgst_pos0 = 3;
9520 dgst_pos1 = 4;
9521 dgst_pos2 = 2;
9522 dgst_pos3 = 1;
9523 break;
9524
9525 case 7400: hash_type = HASH_TYPE_SHA256;
9526 salt_type = SALT_TYPE_EMBEDDED;
9527 attack_exec = ATTACK_EXEC_ON_CPU;
9528 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9529 kern_type = KERN_TYPE_SHA256CRYPT;
9530 dgst_size = DGST_SIZE_4_8;
9531 parse_func = sha256crypt_parse_hash;
9532 sort_by_digest = sort_by_digest_4_8;
9533 opti_type = OPTI_TYPE_ZERO_BYTE;
9534 dgst_pos0 = 0;
9535 dgst_pos1 = 1;
9536 dgst_pos2 = 2;
9537 dgst_pos3 = 3;
9538 break;
9539
9540 case 7500: hash_type = HASH_TYPE_KRB5PA;
9541 salt_type = SALT_TYPE_EMBEDDED;
9542 attack_exec = ATTACK_EXEC_ON_GPU;
9543 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9544 kern_type = KERN_TYPE_KRB5PA;
9545 dgst_size = DGST_SIZE_4_4;
9546 parse_func = krb5pa_parse_hash;
9547 sort_by_digest = sort_by_digest_4_4;
9548 opti_type = OPTI_TYPE_ZERO_BYTE
9549 | OPTI_TYPE_NOT_ITERATED;
9550 dgst_pos0 = 3;
9551 dgst_pos1 = 7;
9552 dgst_pos2 = 2;
9553 dgst_pos3 = 6;
9554 break;
9555
9556 case 7600: hash_type = HASH_TYPE_SHA1;
9557 salt_type = SALT_TYPE_INTERN;
9558 attack_exec = ATTACK_EXEC_ON_GPU;
9559 opts_type = OPTS_TYPE_PT_GENERATE_BE
9560 | OPTS_TYPE_PT_ADD80
9561 | OPTS_TYPE_PT_ADDBITS15;
9562 kern_type = KERN_TYPE_SHA1_SLT_SHA1_PW;
9563 dgst_size = DGST_SIZE_4_5;
9564 parse_func = redmine_parse_hash;
9565 sort_by_digest = sort_by_digest_4_5;
9566 opti_type = OPTI_TYPE_ZERO_BYTE
9567 | OPTI_TYPE_PRECOMPUTE_INIT
9568 | OPTI_TYPE_EARLY_SKIP
9569 | OPTI_TYPE_NOT_ITERATED
9570 | OPTI_TYPE_PREPENDED_SALT;
9571 dgst_pos0 = 3;
9572 dgst_pos1 = 4;
9573 dgst_pos2 = 2;
9574 dgst_pos3 = 1;
9575 break;
9576
9577 case 7700: hash_type = HASH_TYPE_SAPB;
9578 salt_type = SALT_TYPE_EMBEDDED;
9579 attack_exec = ATTACK_EXEC_ON_GPU;
9580 opts_type = OPTS_TYPE_PT_GENERATE_LE
9581 | OPTS_TYPE_PT_UPPER
9582 | OPTS_TYPE_ST_UPPER;
9583 kern_type = KERN_TYPE_SAPB;
9584 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9585 parse_func = sapb_parse_hash;
9586 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9587 opti_type = OPTI_TYPE_ZERO_BYTE
9588 | OPTI_TYPE_PRECOMPUTE_INIT
9589 | OPTI_TYPE_NOT_ITERATED;
9590 dgst_pos0 = 0;
9591 dgst_pos1 = 1;
9592 dgst_pos2 = 2;
9593 dgst_pos3 = 3;
9594 break;
9595
9596 case 7800: hash_type = HASH_TYPE_SAPG;
9597 salt_type = SALT_TYPE_EMBEDDED;
9598 attack_exec = ATTACK_EXEC_ON_GPU;
9599 opts_type = OPTS_TYPE_PT_GENERATE_BE
9600 | OPTS_TYPE_ST_ADD80
9601 | OPTS_TYPE_ST_UPPER;
9602 kern_type = KERN_TYPE_SAPG;
9603 dgst_size = DGST_SIZE_4_5;
9604 parse_func = sapg_parse_hash;
9605 sort_by_digest = sort_by_digest_4_5;
9606 opti_type = OPTI_TYPE_ZERO_BYTE
9607 | OPTI_TYPE_PRECOMPUTE_INIT
9608 | OPTI_TYPE_NOT_ITERATED;
9609 dgst_pos0 = 3;
9610 dgst_pos1 = 4;
9611 dgst_pos2 = 2;
9612 dgst_pos3 = 1;
9613 break;
9614
9615 case 7900: hash_type = HASH_TYPE_SHA512;
9616 salt_type = SALT_TYPE_EMBEDDED;
9617 attack_exec = ATTACK_EXEC_ON_CPU;
9618 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9619 kern_type = KERN_TYPE_DRUPAL7;
9620 dgst_size = DGST_SIZE_8_8;
9621 parse_func = drupal7_parse_hash;
9622 sort_by_digest = sort_by_digest_8_8;
9623 opti_type = OPTI_TYPE_ZERO_BYTE;
9624 dgst_pos0 = 0;
9625 dgst_pos1 = 1;
9626 dgst_pos2 = 2;
9627 dgst_pos3 = 3;
9628 break;
9629
9630 case 8000: hash_type = HASH_TYPE_SHA256;
9631 salt_type = SALT_TYPE_EMBEDDED;
9632 attack_exec = ATTACK_EXEC_ON_GPU;
9633 opts_type = OPTS_TYPE_PT_GENERATE_BE
9634 | OPTS_TYPE_PT_UNICODE
9635 | OPTS_TYPE_ST_ADD80
9636 | OPTS_TYPE_ST_HEX;
9637 kern_type = KERN_TYPE_SYBASEASE;
9638 dgst_size = DGST_SIZE_4_8;
9639 parse_func = sybasease_parse_hash;
9640 sort_by_digest = sort_by_digest_4_8;
9641 opti_type = OPTI_TYPE_ZERO_BYTE
9642 | OPTI_TYPE_PRECOMPUTE_INIT
9643 | OPTI_TYPE_SCALAR_MODE
9644 | OPTI_TYPE_EARLY_SKIP
9645 | OPTI_TYPE_NOT_ITERATED
9646 | OPTI_TYPE_RAW_HASH;
9647 dgst_pos0 = 3;
9648 dgst_pos1 = 7;
9649 dgst_pos2 = 2;
9650 dgst_pos3 = 6;
9651 break;
9652
9653 case 8100: hash_type = HASH_TYPE_SHA1;
9654 salt_type = SALT_TYPE_EMBEDDED;
9655 attack_exec = ATTACK_EXEC_ON_GPU;
9656 opts_type = OPTS_TYPE_PT_GENERATE_BE;
9657 kern_type = KERN_TYPE_NETSCALER;
9658 dgst_size = DGST_SIZE_4_5;
9659 parse_func = netscaler_parse_hash;
9660 sort_by_digest = sort_by_digest_4_5;
9661 opti_type = OPTI_TYPE_ZERO_BYTE
9662 | OPTI_TYPE_PRECOMPUTE_INIT
9663 | OPTI_TYPE_PRECOMPUTE_MERKLE
9664 | OPTI_TYPE_EARLY_SKIP
9665 | OPTI_TYPE_NOT_ITERATED
9666 | OPTI_TYPE_PREPENDED_SALT
9667 | OPTI_TYPE_RAW_HASH;
9668 dgst_pos0 = 3;
9669 dgst_pos1 = 4;
9670 dgst_pos2 = 2;
9671 dgst_pos3 = 1;
9672 break;
9673
9674 case 8200: hash_type = HASH_TYPE_SHA256;
9675 salt_type = SALT_TYPE_EMBEDDED;
9676 attack_exec = ATTACK_EXEC_ON_CPU;
9677 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9678 kern_type = KERN_TYPE_CLOUDKEY;
9679 dgst_size = DGST_SIZE_4_8;
9680 parse_func = cloudkey_parse_hash;
9681 sort_by_digest = sort_by_digest_4_8;
9682 opti_type = OPTI_TYPE_ZERO_BYTE;
9683 dgst_pos0 = 0;
9684 dgst_pos1 = 1;
9685 dgst_pos2 = 2;
9686 dgst_pos3 = 3;
9687 break;
9688
9689 case 8300: hash_type = HASH_TYPE_SHA1;
9690 salt_type = SALT_TYPE_EMBEDDED;
9691 attack_exec = ATTACK_EXEC_ON_GPU;
9692 opts_type = OPTS_TYPE_PT_GENERATE_LE
9693 | OPTS_TYPE_ST_HEX
9694 | OPTS_TYPE_ST_ADD80;
9695 kern_type = KERN_TYPE_NSEC3;
9696 dgst_size = DGST_SIZE_4_5;
9697 parse_func = nsec3_parse_hash;
9698 sort_by_digest = sort_by_digest_4_5;
9699 opti_type = OPTI_TYPE_ZERO_BYTE;
9700 dgst_pos0 = 3;
9701 dgst_pos1 = 4;
9702 dgst_pos2 = 2;
9703 dgst_pos3 = 1;
9704 break;
9705
9706 case 8400: hash_type = HASH_TYPE_SHA1;
9707 salt_type = SALT_TYPE_INTERN;
9708 attack_exec = ATTACK_EXEC_ON_GPU;
9709 opts_type = OPTS_TYPE_PT_GENERATE_BE
9710 | OPTS_TYPE_PT_ADD80
9711 | OPTS_TYPE_PT_ADDBITS15;
9712 kern_type = KERN_TYPE_WBB3;
9713 dgst_size = DGST_SIZE_4_5;
9714 parse_func = wbb3_parse_hash;
9715 sort_by_digest = sort_by_digest_4_5;
9716 opti_type = OPTI_TYPE_ZERO_BYTE
9717 | OPTI_TYPE_PRECOMPUTE_INIT
9718 | OPTI_TYPE_NOT_ITERATED;
9719 dgst_pos0 = 3;
9720 dgst_pos1 = 4;
9721 dgst_pos2 = 2;
9722 dgst_pos3 = 1;
9723 break;
9724
9725 case 8500: hash_type = HASH_TYPE_DESRACF;
9726 salt_type = SALT_TYPE_EMBEDDED;
9727 attack_exec = ATTACK_EXEC_ON_GPU;
9728 opts_type = OPTS_TYPE_PT_GENERATE_LE
9729 | OPTS_TYPE_ST_UPPER;
9730 kern_type = KERN_TYPE_RACF;
9731 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9732 parse_func = racf_parse_hash;
9733 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9734 opti_type = OPTI_TYPE_ZERO_BYTE
9735 | OPTI_TYPE_SCALAR_MODE
9736 | OPTI_TYPE_PRECOMPUTE_PERMUT;
9737 dgst_pos0 = 0;
9738 dgst_pos1 = 1;
9739 dgst_pos2 = 2;
9740 dgst_pos3 = 3;
9741 break;
9742
9743 case 8600: hash_type = HASH_TYPE_LOTUS5;
9744 salt_type = SALT_TYPE_NONE;
9745 attack_exec = ATTACK_EXEC_ON_GPU;
9746 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9747 kern_type = KERN_TYPE_LOTUS5;
9748 dgst_size = DGST_SIZE_4_4;
9749 parse_func = lotus5_parse_hash;
9750 sort_by_digest = sort_by_digest_4_4;
9751 opti_type = OPTI_TYPE_SCALAR_MODE
9752 | OPTI_TYPE_EARLY_SKIP
9753 | OPTI_TYPE_NOT_ITERATED
9754 | OPTI_TYPE_NOT_SALTED
9755 | OPTI_TYPE_RAW_HASH;
9756 dgst_pos0 = 0;
9757 dgst_pos1 = 1;
9758 dgst_pos2 = 2;
9759 dgst_pos3 = 3;
9760 break;
9761
9762 case 8700: hash_type = HASH_TYPE_LOTUS6;
9763 salt_type = SALT_TYPE_EMBEDDED;
9764 attack_exec = ATTACK_EXEC_ON_GPU;
9765 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9766 kern_type = KERN_TYPE_LOTUS6;
9767 dgst_size = DGST_SIZE_4_4;
9768 parse_func = lotus6_parse_hash;
9769 sort_by_digest = sort_by_digest_4_4;
9770 opti_type = OPTI_TYPE_SCALAR_MODE
9771 | OPTI_TYPE_EARLY_SKIP
9772 | OPTI_TYPE_NOT_ITERATED
9773 | OPTI_TYPE_RAW_HASH;
9774 dgst_pos0 = 0;
9775 dgst_pos1 = 1;
9776 dgst_pos2 = 2;
9777 dgst_pos3 = 3;
9778 break;
9779
9780 case 8800: hash_type = HASH_TYPE_ANDROIDFDE;
9781 salt_type = SALT_TYPE_EMBEDDED;
9782 attack_exec = ATTACK_EXEC_ON_CPU;
9783 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9784 kern_type = KERN_TYPE_ANDROIDFDE;
9785 dgst_size = DGST_SIZE_4_4;
9786 parse_func = androidfde_parse_hash;
9787 sort_by_digest = sort_by_digest_4_4;
9788 opti_type = OPTI_TYPE_ZERO_BYTE;
9789 dgst_pos0 = 0;
9790 dgst_pos1 = 1;
9791 dgst_pos2 = 2;
9792 dgst_pos3 = 3;
9793 break;
9794
9795 case 8900: hash_type = HASH_TYPE_SCRYPT;
9796 salt_type = SALT_TYPE_EMBEDDED;
9797 attack_exec = ATTACK_EXEC_ON_CPU;
9798 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9799 kern_type = KERN_TYPE_SCRYPT;
9800 dgst_size = DGST_SIZE_4_8;
9801 parse_func = scrypt_parse_hash;
9802 sort_by_digest = sort_by_digest_4_8;
9803 opti_type = OPTI_TYPE_ZERO_BYTE;
9804 dgst_pos0 = 0;
9805 dgst_pos1 = 1;
9806 dgst_pos2 = 2;
9807 dgst_pos3 = 3;
9808 break;
9809
9810 case 9000: hash_type = HASH_TYPE_SHA1;
9811 salt_type = SALT_TYPE_EMBEDDED;
9812 attack_exec = ATTACK_EXEC_ON_CPU;
9813 opts_type = OPTS_TYPE_PT_GENERATE_LE
9814 | OPTS_TYPE_ST_GENERATE_LE;
9815 kern_type = KERN_TYPE_PSAFE2;
9816 dgst_size = DGST_SIZE_4_5;
9817 parse_func = psafe2_parse_hash;
9818 sort_by_digest = sort_by_digest_4_5;
9819 opti_type = OPTI_TYPE_ZERO_BYTE;
9820 dgst_pos0 = 0;
9821 dgst_pos1 = 1;
9822 dgst_pos2 = 2;
9823 dgst_pos3 = 3;
9824 break;
9825
9826 case 9100: hash_type = HASH_TYPE_LOTUS8;
9827 salt_type = SALT_TYPE_EMBEDDED;
9828 attack_exec = ATTACK_EXEC_ON_CPU;
9829 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9830 kern_type = KERN_TYPE_LOTUS8;
9831 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9832 parse_func = lotus8_parse_hash;
9833 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9834 opti_type = OPTI_TYPE_ZERO_BYTE;
9835 dgst_pos0 = 0;
9836 dgst_pos1 = 1;
9837 dgst_pos2 = 2;
9838 dgst_pos3 = 3;
9839 break;
9840
9841 case 9200: hash_type = HASH_TYPE_SHA256;
9842 salt_type = SALT_TYPE_EMBEDDED;
9843 attack_exec = ATTACK_EXEC_ON_CPU;
9844 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9845 kern_type = KERN_TYPE_PBKDF2_SHA256;
9846 dgst_size = DGST_SIZE_4_32;
9847 parse_func = cisco8_parse_hash;
9848 sort_by_digest = sort_by_digest_4_32;
9849 opti_type = OPTI_TYPE_ZERO_BYTE;
9850 dgst_pos0 = 0;
9851 dgst_pos1 = 1;
9852 dgst_pos2 = 2;
9853 dgst_pos3 = 3;
9854 break;
9855
9856 case 9300: hash_type = HASH_TYPE_SCRYPT;
9857 salt_type = SALT_TYPE_EMBEDDED;
9858 attack_exec = ATTACK_EXEC_ON_CPU;
9859 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9860 kern_type = KERN_TYPE_SCRYPT;
9861 dgst_size = DGST_SIZE_4_8;
9862 parse_func = cisco9_parse_hash;
9863 sort_by_digest = sort_by_digest_4_8;
9864 opti_type = OPTI_TYPE_ZERO_BYTE;
9865 dgst_pos0 = 0;
9866 dgst_pos1 = 1;
9867 dgst_pos2 = 2;
9868 dgst_pos3 = 3;
9869 break;
9870
9871 case 9400: hash_type = HASH_TYPE_OFFICE2007;
9872 salt_type = SALT_TYPE_EMBEDDED;
9873 attack_exec = ATTACK_EXEC_ON_CPU;
9874 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9875 kern_type = KERN_TYPE_OFFICE2007;
9876 dgst_size = DGST_SIZE_4_4;
9877 parse_func = office2007_parse_hash;
9878 sort_by_digest = sort_by_digest_4_4;
9879 opti_type = OPTI_TYPE_ZERO_BYTE;
9880 dgst_pos0 = 0;
9881 dgst_pos1 = 1;
9882 dgst_pos2 = 2;
9883 dgst_pos3 = 3;
9884 break;
9885
9886 case 9500: hash_type = HASH_TYPE_OFFICE2010;
9887 salt_type = SALT_TYPE_EMBEDDED;
9888 attack_exec = ATTACK_EXEC_ON_CPU;
9889 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9890 kern_type = KERN_TYPE_OFFICE2010;
9891 dgst_size = DGST_SIZE_4_4;
9892 parse_func = office2010_parse_hash;
9893 sort_by_digest = sort_by_digest_4_4;
9894 opti_type = OPTI_TYPE_ZERO_BYTE;
9895 dgst_pos0 = 0;
9896 dgst_pos1 = 1;
9897 dgst_pos2 = 2;
9898 dgst_pos3 = 3;
9899 break;
9900
9901 case 9600: hash_type = HASH_TYPE_OFFICE2013;
9902 salt_type = SALT_TYPE_EMBEDDED;
9903 attack_exec = ATTACK_EXEC_ON_CPU;
9904 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9905 kern_type = KERN_TYPE_OFFICE2013;
9906 dgst_size = DGST_SIZE_4_4;
9907 parse_func = office2013_parse_hash;
9908 sort_by_digest = sort_by_digest_4_4;
9909 opti_type = OPTI_TYPE_ZERO_BYTE;
9910 dgst_pos0 = 0;
9911 dgst_pos1 = 1;
9912 dgst_pos2 = 2;
9913 dgst_pos3 = 3;
9914 break;
9915
9916 case 9700: hash_type = HASH_TYPE_OLDOFFICE01;
9917 salt_type = SALT_TYPE_EMBEDDED;
9918 attack_exec = ATTACK_EXEC_ON_GPU;
9919 opts_type = OPTS_TYPE_PT_GENERATE_LE
9920 | OPTS_TYPE_PT_ADD80
9921 | OPTS_TYPE_PT_UNICODE;
9922 kern_type = KERN_TYPE_OLDOFFICE01;
9923 dgst_size = DGST_SIZE_4_4;
9924 parse_func = oldoffice01_parse_hash;
9925 sort_by_digest = sort_by_digest_4_4;
9926 opti_type = OPTI_TYPE_ZERO_BYTE
9927 | OPTI_TYPE_PRECOMPUTE_INIT
9928 | OPTI_TYPE_NOT_ITERATED;
9929 dgst_pos0 = 0;
9930 dgst_pos1 = 1;
9931 dgst_pos2 = 2;
9932 dgst_pos3 = 3;
9933 break;
9934
9935 case 9710: hash_type = HASH_TYPE_OLDOFFICE01;
9936 salt_type = SALT_TYPE_EMBEDDED;
9937 attack_exec = ATTACK_EXEC_ON_GPU;
9938 opts_type = OPTS_TYPE_PT_GENERATE_LE
9939 | OPTS_TYPE_PT_ADD80;
9940 kern_type = KERN_TYPE_OLDOFFICE01CM1;
9941 dgst_size = DGST_SIZE_4_4;
9942 parse_func = oldoffice01cm1_parse_hash;
9943 sort_by_digest = sort_by_digest_4_4;
9944 opti_type = OPTI_TYPE_ZERO_BYTE
9945 | OPTI_TYPE_PRECOMPUTE_INIT
9946 | OPTI_TYPE_NOT_ITERATED;
9947 dgst_pos0 = 0;
9948 dgst_pos1 = 1;
9949 dgst_pos2 = 2;
9950 dgst_pos3 = 3;
9951 break;
9952
9953 case 9720: hash_type = HASH_TYPE_OLDOFFICE01;
9954 salt_type = SALT_TYPE_EMBEDDED;
9955 attack_exec = ATTACK_EXEC_ON_GPU;
9956 opts_type = OPTS_TYPE_PT_GENERATE_LE
9957 | OPTS_TYPE_PT_ADD80
9958 | OPTS_TYPE_PT_UNICODE
9959 | OPTS_TYPE_PT_NEVERCRACK;
9960 kern_type = KERN_TYPE_OLDOFFICE01CM2;
9961 dgst_size = DGST_SIZE_4_4;
9962 parse_func = oldoffice01cm2_parse_hash;
9963 sort_by_digest = sort_by_digest_4_4;
9964 opti_type = OPTI_TYPE_ZERO_BYTE
9965 | OPTI_TYPE_PRECOMPUTE_INIT
9966 | OPTI_TYPE_NOT_ITERATED;
9967 dgst_pos0 = 0;
9968 dgst_pos1 = 1;
9969 dgst_pos2 = 2;
9970 dgst_pos3 = 3;
9971 break;
9972
9973 case 9800: hash_type = HASH_TYPE_OLDOFFICE34;
9974 salt_type = SALT_TYPE_EMBEDDED;
9975 attack_exec = ATTACK_EXEC_ON_GPU;
9976 opts_type = OPTS_TYPE_PT_GENERATE_BE
9977 | OPTS_TYPE_PT_ADD80
9978 | OPTS_TYPE_PT_UNICODE;
9979 kern_type = KERN_TYPE_OLDOFFICE34;
9980 dgst_size = DGST_SIZE_4_4;
9981 parse_func = oldoffice34_parse_hash;
9982 sort_by_digest = sort_by_digest_4_4;
9983 opti_type = OPTI_TYPE_ZERO_BYTE
9984 | OPTI_TYPE_PRECOMPUTE_INIT
9985 | OPTI_TYPE_NOT_ITERATED;
9986 dgst_pos0 = 0;
9987 dgst_pos1 = 1;
9988 dgst_pos2 = 2;
9989 dgst_pos3 = 3;
9990 break;
9991
9992 case 9810: hash_type = HASH_TYPE_OLDOFFICE34;
9993 salt_type = SALT_TYPE_EMBEDDED;
9994 attack_exec = ATTACK_EXEC_ON_GPU;
9995 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9996 kern_type = KERN_TYPE_OLDOFFICE34CM1;
9997 dgst_size = DGST_SIZE_4_4;
9998 parse_func = oldoffice34cm1_parse_hash;
9999 sort_by_digest = sort_by_digest_4_4;
10000 opti_type = OPTI_TYPE_ZERO_BYTE
10001 | OPTI_TYPE_PRECOMPUTE_INIT
10002 | OPTI_TYPE_NOT_ITERATED;
10003 dgst_pos0 = 0;
10004 dgst_pos1 = 1;
10005 dgst_pos2 = 2;
10006 dgst_pos3 = 3;
10007 break;
10008
10009 case 9820: hash_type = HASH_TYPE_OLDOFFICE34;
10010 salt_type = SALT_TYPE_EMBEDDED;
10011 attack_exec = ATTACK_EXEC_ON_GPU;
10012 opts_type = OPTS_TYPE_PT_GENERATE_BE
10013 | OPTS_TYPE_PT_ADD80
10014 | OPTS_TYPE_PT_UNICODE
10015 | OPTS_TYPE_PT_NEVERCRACK;
10016 kern_type = KERN_TYPE_OLDOFFICE34CM2;
10017 dgst_size = DGST_SIZE_4_4;
10018 parse_func = oldoffice34cm2_parse_hash;
10019 sort_by_digest = sort_by_digest_4_4;
10020 opti_type = OPTI_TYPE_ZERO_BYTE
10021 | OPTI_TYPE_PRECOMPUTE_INIT
10022 | OPTI_TYPE_NOT_ITERATED;
10023 dgst_pos0 = 0;
10024 dgst_pos1 = 1;
10025 dgst_pos2 = 2;
10026 dgst_pos3 = 3;
10027 break;
10028
10029 case 9900: hash_type = HASH_TYPE_MD5;
10030 salt_type = SALT_TYPE_NONE;
10031 attack_exec = ATTACK_EXEC_ON_GPU;
10032 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10033 kern_type = KERN_TYPE_RADMIN2;
10034 dgst_size = DGST_SIZE_4_4;
10035 parse_func = radmin2_parse_hash;
10036 sort_by_digest = sort_by_digest_4_4;
10037 opti_type = OPTI_TYPE_ZERO_BYTE
10038 | OPTI_TYPE_PRECOMPUTE_INIT
10039 | OPTI_TYPE_SCALAR_MODE
10040 | OPTI_TYPE_EARLY_SKIP
10041 | OPTI_TYPE_NOT_ITERATED
10042 | OPTI_TYPE_NOT_SALTED;
10043 dgst_pos0 = 0;
10044 dgst_pos1 = 3;
10045 dgst_pos2 = 2;
10046 dgst_pos3 = 1;
10047 break;
10048
10049 case 10000: hash_type = HASH_TYPE_SHA256;
10050 salt_type = SALT_TYPE_EMBEDDED;
10051 attack_exec = ATTACK_EXEC_ON_CPU;
10052 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
10053 kern_type = KERN_TYPE_PBKDF2_SHA256;
10054 dgst_size = DGST_SIZE_4_32;
10055 parse_func = djangopbkdf2_parse_hash;
10056 sort_by_digest = sort_by_digest_4_32;
10057 opti_type = OPTI_TYPE_ZERO_BYTE;
10058 dgst_pos0 = 0;
10059 dgst_pos1 = 1;
10060 dgst_pos2 = 2;
10061 dgst_pos3 = 3;
10062 break;
10063
10064 case 10100: hash_type = HASH_TYPE_SIPHASH;
10065 salt_type = SALT_TYPE_EMBEDDED;
10066 attack_exec = ATTACK_EXEC_ON_GPU;
10067 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10068 kern_type = KERN_TYPE_SIPHASH;
10069 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10070 parse_func = siphash_parse_hash;
10071 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10072 opti_type = OPTI_TYPE_ZERO_BYTE
10073 | OPTI_TYPE_SCALAR_MODE
10074 | OPTI_TYPE_NOT_ITERATED
10075 | OPTI_TYPE_RAW_HASH;
10076 dgst_pos0 = 0;
10077 dgst_pos1 = 1;
10078 dgst_pos2 = 2;
10079 dgst_pos3 = 3;
10080 break;
10081
10082 case 10200: hash_type = HASH_TYPE_MD5;
10083 salt_type = SALT_TYPE_EMBEDDED;
10084 attack_exec = ATTACK_EXEC_ON_GPU;
10085 opts_type = OPTS_TYPE_PT_GENERATE_LE
10086 | OPTS_TYPE_ST_ADD80
10087 | OPTS_TYPE_ST_ADDBITS14;
10088 kern_type = KERN_TYPE_HMACMD5_PW;
10089 dgst_size = DGST_SIZE_4_4;
10090 parse_func = crammd5_parse_hash;
10091 sort_by_digest = sort_by_digest_4_4;
10092 opti_type = OPTI_TYPE_ZERO_BYTE
10093 | OPTI_TYPE_NOT_ITERATED;
10094 dgst_pos0 = 0;
10095 dgst_pos1 = 3;
10096 dgst_pos2 = 2;
10097 dgst_pos3 = 1;
10098 break;
10099
10100 case 10300: hash_type = HASH_TYPE_SHA1;
10101 salt_type = SALT_TYPE_EMBEDDED;
10102 attack_exec = ATTACK_EXEC_ON_CPU;
10103 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
10104 kern_type = KERN_TYPE_SAPH_SHA1;
10105 dgst_size = DGST_SIZE_4_5;
10106 parse_func = saph_sha1_parse_hash;
10107 sort_by_digest = sort_by_digest_4_5;
10108 opti_type = OPTI_TYPE_ZERO_BYTE;
10109 dgst_pos0 = 0;
10110 dgst_pos1 = 1;
10111 dgst_pos2 = 2;
10112 dgst_pos3 = 3;
10113 break;
10114
10115 case 10400: hash_type = HASH_TYPE_PDFU16;
10116 salt_type = SALT_TYPE_EMBEDDED;
10117 attack_exec = ATTACK_EXEC_ON_GPU;
10118 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10119 kern_type = KERN_TYPE_PDF11;
10120 dgst_size = DGST_SIZE_4_4;
10121 parse_func = pdf11_parse_hash;
10122 sort_by_digest = sort_by_digest_4_4;
10123 opti_type = OPTI_TYPE_ZERO_BYTE
10124 | OPTI_TYPE_NOT_ITERATED;
10125 dgst_pos0 = 0;
10126 dgst_pos1 = 1;
10127 dgst_pos2 = 2;
10128 dgst_pos3 = 3;
10129 break;
10130
10131 case 10410: hash_type = HASH_TYPE_PDFU16;
10132 salt_type = SALT_TYPE_EMBEDDED;
10133 attack_exec = ATTACK_EXEC_ON_GPU;
10134 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10135 kern_type = KERN_TYPE_PDF11CM1;
10136 dgst_size = DGST_SIZE_4_4;
10137 parse_func = pdf11cm1_parse_hash;
10138 sort_by_digest = sort_by_digest_4_4;
10139 opti_type = OPTI_TYPE_ZERO_BYTE
10140 | OPTI_TYPE_NOT_ITERATED;
10141 dgst_pos0 = 0;
10142 dgst_pos1 = 1;
10143 dgst_pos2 = 2;
10144 dgst_pos3 = 3;
10145 break;
10146
10147 case 10420: hash_type = HASH_TYPE_PDFU16;
10148 salt_type = SALT_TYPE_EMBEDDED;
10149 attack_exec = ATTACK_EXEC_ON_GPU;
10150 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10151 kern_type = KERN_TYPE_PDF11CM2;
10152 dgst_size = DGST_SIZE_4_4;
10153 parse_func = pdf11cm2_parse_hash;
10154 sort_by_digest = sort_by_digest_4_4;
10155 opti_type = OPTI_TYPE_ZERO_BYTE
10156 | OPTI_TYPE_NOT_ITERATED;
10157 dgst_pos0 = 0;
10158 dgst_pos1 = 1;
10159 dgst_pos2 = 2;
10160 dgst_pos3 = 3;
10161 break;
10162
10163 case 10500: hash_type = HASH_TYPE_PDFU16;
10164 salt_type = SALT_TYPE_EMBEDDED;
10165 attack_exec = ATTACK_EXEC_ON_CPU;
10166 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10167 kern_type = KERN_TYPE_PDF14;
10168 dgst_size = DGST_SIZE_4_4;
10169 parse_func = pdf14_parse_hash;
10170 sort_by_digest = sort_by_digest_4_4;
10171 opti_type = OPTI_TYPE_ZERO_BYTE
10172 | OPTI_TYPE_NOT_ITERATED;
10173 dgst_pos0 = 0;
10174 dgst_pos1 = 1;
10175 dgst_pos2 = 2;
10176 dgst_pos3 = 3;
10177 break;
10178
10179 case 10600: hash_type = HASH_TYPE_SHA256;
10180 salt_type = SALT_TYPE_EMBEDDED;
10181 attack_exec = ATTACK_EXEC_ON_GPU;
10182 opts_type = OPTS_TYPE_PT_GENERATE_BE
10183 | OPTS_TYPE_ST_ADD80
10184 | OPTS_TYPE_ST_ADDBITS15
10185 | OPTS_TYPE_HASH_COPY;
10186 kern_type = KERN_TYPE_SHA256_PWSLT;
10187 dgst_size = DGST_SIZE_4_8;
10188 parse_func = pdf17l3_parse_hash;
10189 sort_by_digest = sort_by_digest_4_8;
10190 opti_type = OPTI_TYPE_ZERO_BYTE
10191 | OPTI_TYPE_PRECOMPUTE_INIT
10192 | OPTI_TYPE_PRECOMPUTE_MERKLE
10193 | OPTI_TYPE_SCALAR_MODE
10194 | OPTI_TYPE_EARLY_SKIP
10195 | OPTI_TYPE_NOT_ITERATED
10196 | OPTI_TYPE_APPENDED_SALT
10197 | OPTI_TYPE_RAW_HASH;
10198 dgst_pos0 = 3;
10199 dgst_pos1 = 7;
10200 dgst_pos2 = 2;
10201 dgst_pos3 = 6;
10202 break;
10203
10204 case 10700: hash_type = HASH_TYPE_PDFU32;
10205 salt_type = SALT_TYPE_EMBEDDED;
10206 attack_exec = ATTACK_EXEC_ON_CPU;
10207 opts_type = OPTS_TYPE_PT_GENERATE_LE
10208 | OPTS_TYPE_HASH_COPY;
10209 kern_type = KERN_TYPE_PDF17L8;
10210 dgst_size = DGST_SIZE_4_8;
10211 parse_func = pdf17l8_parse_hash;
10212 sort_by_digest = sort_by_digest_4_8;
10213 opti_type = OPTI_TYPE_ZERO_BYTE
10214 | OPTI_TYPE_NOT_ITERATED;
10215 dgst_pos0 = 0;
10216 dgst_pos1 = 1;
10217 dgst_pos2 = 2;
10218 dgst_pos3 = 3;
10219 break;
10220
10221 case 10800: hash_type = HASH_TYPE_SHA384;
10222 salt_type = SALT_TYPE_NONE;
10223 attack_exec = ATTACK_EXEC_ON_GPU;
10224 opts_type = OPTS_TYPE_PT_GENERATE_BE
10225 | OPTS_TYPE_PT_ADD80
10226 | OPTS_TYPE_PT_ADDBITS15;
10227 kern_type = KERN_TYPE_SHA384;
10228 dgst_size = DGST_SIZE_8_8;
10229 parse_func = sha384_parse_hash;
10230 sort_by_digest = sort_by_digest_8_8;
10231 opti_type = OPTI_TYPE_ZERO_BYTE
10232 | OPTI_TYPE_PRECOMPUTE_INIT
10233 | OPTI_TYPE_PRECOMPUTE_MERKLE
10234 | OPTI_TYPE_SCALAR_MODE
10235 | OPTI_TYPE_EARLY_SKIP
10236 | OPTI_TYPE_NOT_ITERATED
10237 | OPTI_TYPE_NOT_SALTED
10238 | OPTI_TYPE_RAW_HASH;
10239 dgst_pos0 = 6;
10240 dgst_pos1 = 7;
10241 dgst_pos2 = 4;
10242 dgst_pos3 = 5;
10243 break;
10244
10245 case 10900: hash_type = HASH_TYPE_PBKDF2_SHA256;
10246 salt_type = SALT_TYPE_EMBEDDED;
10247 attack_exec = ATTACK_EXEC_ON_CPU;
10248 opts_type = OPTS_TYPE_PT_GENERATE_LE
10249 | OPTS_TYPE_ST_BASE64
10250 | OPTS_TYPE_HASH_COPY;
10251 kern_type = KERN_TYPE_PBKDF2_SHA256;
10252 dgst_size = DGST_SIZE_4_32;
10253 parse_func = pbkdf2_sha256_parse_hash;
10254 sort_by_digest = sort_by_digest_4_32;
10255 opti_type = OPTI_TYPE_ZERO_BYTE;
10256 dgst_pos0 = 0;
10257 dgst_pos1 = 1;
10258 dgst_pos2 = 2;
10259 dgst_pos3 = 3;
10260 break;
10261
10262 case 11000: hash_type = HASH_TYPE_MD5;
10263 salt_type = SALT_TYPE_INTERN;
10264 attack_exec = ATTACK_EXEC_ON_GPU;
10265 opts_type = OPTS_TYPE_PT_GENERATE_LE
10266 | OPTS_TYPE_PT_ADD80;
10267 kern_type = KERN_TYPE_PRESTASHOP;
10268 dgst_size = DGST_SIZE_4_4;
10269 parse_func = prestashop_parse_hash;
10270 sort_by_digest = sort_by_digest_4_4;
10271 opti_type = OPTI_TYPE_ZERO_BYTE
10272 | OPTI_TYPE_PRECOMPUTE_INIT
10273 | OPTI_TYPE_NOT_ITERATED
10274 | OPTI_TYPE_PREPENDED_SALT;
10275 dgst_pos0 = 0;
10276 dgst_pos1 = 3;
10277 dgst_pos2 = 2;
10278 dgst_pos3 = 1;
10279 break;
10280
10281 case 11100: hash_type = HASH_TYPE_MD5;
10282 salt_type = SALT_TYPE_EMBEDDED;
10283 attack_exec = ATTACK_EXEC_ON_GPU;
10284 opts_type = OPTS_TYPE_PT_GENERATE_LE
10285 | OPTS_TYPE_ST_ADD80;
10286 kern_type = KERN_TYPE_POSTGRESQL_AUTH;
10287 dgst_size = DGST_SIZE_4_4;
10288 parse_func = postgresql_auth_parse_hash;
10289 sort_by_digest = sort_by_digest_4_4;
10290 opti_type = OPTI_TYPE_ZERO_BYTE
10291 | OPTI_TYPE_PRECOMPUTE_INIT
10292 | OPTI_TYPE_PRECOMPUTE_MERKLE
10293 | OPTI_TYPE_EARLY_SKIP;
10294 dgst_pos0 = 0;
10295 dgst_pos1 = 3;
10296 dgst_pos2 = 2;
10297 dgst_pos3 = 1;
10298 break;
10299
10300 case 11200: hash_type = HASH_TYPE_SHA1;
10301 salt_type = SALT_TYPE_EMBEDDED;
10302 attack_exec = ATTACK_EXEC_ON_GPU;
10303 opts_type = OPTS_TYPE_PT_GENERATE_BE
10304 | OPTS_TYPE_PT_ADD80
10305 | OPTS_TYPE_ST_HEX;
10306 kern_type = KERN_TYPE_MYSQL_AUTH;
10307 dgst_size = DGST_SIZE_4_5;
10308 parse_func = mysql_auth_parse_hash;
10309 sort_by_digest = sort_by_digest_4_5;
10310 opti_type = OPTI_TYPE_ZERO_BYTE
10311 | OPTI_TYPE_EARLY_SKIP;
10312 dgst_pos0 = 3;
10313 dgst_pos1 = 4;
10314 dgst_pos2 = 2;
10315 dgst_pos3 = 1;
10316 break;
10317
10318 case 11300: hash_type = HASH_TYPE_BITCOIN_WALLET;
10319 salt_type = SALT_TYPE_EMBEDDED;
10320 attack_exec = ATTACK_EXEC_ON_CPU;
10321 opts_type = OPTS_TYPE_PT_GENERATE_LE
10322 | OPTS_TYPE_ST_HEX
10323 | OPTS_TYPE_ST_ADD80;
10324 kern_type = KERN_TYPE_BITCOIN_WALLET;
10325 dgst_size = DGST_SIZE_4_4;
10326 parse_func = bitcoin_wallet_parse_hash;
10327 sort_by_digest = sort_by_digest_4_4;
10328 opti_type = OPTI_TYPE_ZERO_BYTE;
10329 dgst_pos0 = 0;
10330 dgst_pos1 = 1;
10331 dgst_pos2 = 2;
10332 dgst_pos3 = 3;
10333 break;
10334
10335 case 11400: hash_type = HASH_TYPE_MD5;
10336 salt_type = SALT_TYPE_EMBEDDED;
10337 attack_exec = ATTACK_EXEC_ON_GPU;
10338 opts_type = OPTS_TYPE_PT_GENERATE_LE
10339 | OPTS_TYPE_PT_ADD80
10340 | OPTS_TYPE_HASH_COPY;
10341 kern_type = KERN_TYPE_SIP_AUTH;
10342 dgst_size = DGST_SIZE_4_4;
10343 parse_func = sip_auth_parse_hash;
10344 sort_by_digest = sort_by_digest_4_4;
10345 opti_type = OPTI_TYPE_ZERO_BYTE;
10346 dgst_pos0 = 0;
10347 dgst_pos1 = 3;
10348 dgst_pos2 = 2;
10349 dgst_pos3 = 1;
10350 break;
10351
10352 case 11500: hash_type = HASH_TYPE_CRC32;
10353 salt_type = SALT_TYPE_INTERN;
10354 attack_exec = ATTACK_EXEC_ON_GPU;
10355 opts_type = OPTS_TYPE_PT_GENERATE_LE
10356 | OPTS_TYPE_ST_GENERATE_LE
10357 | OPTS_TYPE_ST_HEX;
10358 kern_type = KERN_TYPE_CRC32;
10359 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10360 parse_func = crc32_parse_hash;
10361 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10362 opti_type = OPTI_TYPE_ZERO_BYTE
10363 | OPTI_TYPE_SCALAR_MODE;
10364 dgst_pos0 = 0;
10365 dgst_pos1 = 1;
10366 dgst_pos2 = 2;
10367 dgst_pos3 = 3;
10368 break;
10369
10370 case 11600: hash_type = HASH_TYPE_AES;
10371 salt_type = SALT_TYPE_EMBEDDED;
10372 attack_exec = ATTACK_EXEC_ON_CPU;
10373 opts_type = OPTS_TYPE_PT_GENERATE_LE
10374 | OPTS_TYPE_PT_NEVERCRACK;
10375 kern_type = KERN_TYPE_SEVEN_ZIP;
10376 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10377 parse_func = seven_zip_parse_hash;
10378 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10379 opti_type = OPTI_TYPE_ZERO_BYTE;
10380 dgst_pos0 = 0;
10381 dgst_pos1 = 1;
10382 dgst_pos2 = 2;
10383 dgst_pos3 = 3;
10384 break;
10385
10386 case 11700: hash_type = HASH_TYPE_GOST_2012SBOG_256;
10387 salt_type = SALT_TYPE_NONE;
10388 attack_exec = ATTACK_EXEC_ON_GPU;
10389 opts_type = OPTS_TYPE_PT_GENERATE_LE
10390 | OPTS_TYPE_PT_ADD01;
10391 kern_type = KERN_TYPE_GOST_2012SBOG_256;
10392 dgst_size = DGST_SIZE_4_8;
10393 parse_func = gost2012sbog_256_parse_hash;
10394 sort_by_digest = sort_by_digest_4_8;
10395 opti_type = OPTI_TYPE_ZERO_BYTE;
10396 dgst_pos0 = 0;
10397 dgst_pos1 = 1;
10398 dgst_pos2 = 2;
10399 dgst_pos3 = 3;
10400 break;
10401
10402 case 11800: hash_type = HASH_TYPE_GOST_2012SBOG_512;
10403 salt_type = SALT_TYPE_NONE;
10404 attack_exec = ATTACK_EXEC_ON_GPU;
10405 opts_type = OPTS_TYPE_PT_GENERATE_LE
10406 | OPTS_TYPE_PT_ADD01;
10407 kern_type = KERN_TYPE_GOST_2012SBOG_512;
10408 dgst_size = DGST_SIZE_4_16;
10409 parse_func = gost2012sbog_512_parse_hash;
10410 sort_by_digest = sort_by_digest_4_16;
10411 opti_type = OPTI_TYPE_ZERO_BYTE;
10412 dgst_pos0 = 0;
10413 dgst_pos1 = 1;
10414 dgst_pos2 = 2;
10415 dgst_pos3 = 3;
10416 break;
10417
10418 case 11900: hash_type = HASH_TYPE_PBKDF2_MD5;
10419 salt_type = SALT_TYPE_EMBEDDED;
10420 attack_exec = ATTACK_EXEC_ON_CPU;
10421 opts_type = OPTS_TYPE_PT_GENERATE_LE
10422 | OPTS_TYPE_ST_BASE64
10423 | OPTS_TYPE_HASH_COPY;
10424 kern_type = KERN_TYPE_PBKDF2_MD5;
10425 dgst_size = DGST_SIZE_4_32;
10426 parse_func = pbkdf2_md5_parse_hash;
10427 sort_by_digest = sort_by_digest_4_32;
10428 opti_type = OPTI_TYPE_ZERO_BYTE;
10429 dgst_pos0 = 0;
10430 dgst_pos1 = 1;
10431 dgst_pos2 = 2;
10432 dgst_pos3 = 3;
10433 break;
10434
10435 case 12000: hash_type = HASH_TYPE_PBKDF2_SHA1;
10436 salt_type = SALT_TYPE_EMBEDDED;
10437 attack_exec = ATTACK_EXEC_ON_CPU;
10438 opts_type = OPTS_TYPE_PT_GENERATE_LE
10439 | OPTS_TYPE_ST_BASE64
10440 | OPTS_TYPE_HASH_COPY;
10441 kern_type = KERN_TYPE_PBKDF2_SHA1;
10442 dgst_size = DGST_SIZE_4_32;
10443 parse_func = pbkdf2_sha1_parse_hash;
10444 sort_by_digest = sort_by_digest_4_32;
10445 opti_type = OPTI_TYPE_ZERO_BYTE;
10446 dgst_pos0 = 0;
10447 dgst_pos1 = 1;
10448 dgst_pos2 = 2;
10449 dgst_pos3 = 3;
10450 break;
10451
10452 case 12100: hash_type = HASH_TYPE_PBKDF2_SHA512;
10453 salt_type = SALT_TYPE_EMBEDDED;
10454 attack_exec = ATTACK_EXEC_ON_CPU;
10455 opts_type = OPTS_TYPE_PT_GENERATE_LE
10456 | OPTS_TYPE_ST_BASE64
10457 | OPTS_TYPE_HASH_COPY;
10458 kern_type = KERN_TYPE_PBKDF2_SHA512;
10459 dgst_size = DGST_SIZE_8_16;
10460 parse_func = pbkdf2_sha512_parse_hash;
10461 sort_by_digest = sort_by_digest_8_16;
10462 opti_type = OPTI_TYPE_ZERO_BYTE;
10463 dgst_pos0 = 0;
10464 dgst_pos1 = 1;
10465 dgst_pos2 = 2;
10466 dgst_pos3 = 3;
10467 break;
10468
10469 case 12200: hash_type = HASH_TYPE_ECRYPTFS;
10470 salt_type = SALT_TYPE_EMBEDDED;
10471 attack_exec = ATTACK_EXEC_ON_CPU;
10472 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10473 kern_type = KERN_TYPE_ECRYPTFS;
10474 dgst_size = DGST_SIZE_8_8;
10475 parse_func = ecryptfs_parse_hash;
10476 sort_by_digest = sort_by_digest_8_8;
10477 opti_type = OPTI_TYPE_ZERO_BYTE;
10478 dgst_pos0 = 0;
10479 dgst_pos1 = 1;
10480 dgst_pos2 = 2;
10481 dgst_pos3 = 3;
10482 break;
10483
10484 case 12300: hash_type = HASH_TYPE_ORACLET;
10485 salt_type = SALT_TYPE_EMBEDDED;
10486 attack_exec = ATTACK_EXEC_ON_CPU;
10487 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10488 kern_type = KERN_TYPE_ORACLET;
10489 dgst_size = DGST_SIZE_8_16;
10490 parse_func = oraclet_parse_hash;
10491 sort_by_digest = sort_by_digest_8_16;
10492 opti_type = OPTI_TYPE_ZERO_BYTE;
10493 dgst_pos0 = 0;
10494 dgst_pos1 = 1;
10495 dgst_pos2 = 2;
10496 dgst_pos3 = 3;
10497 break;
10498
10499 case 12400: hash_type = HASH_TYPE_BSDICRYPT;
10500 salt_type = SALT_TYPE_EMBEDDED;
10501 attack_exec = ATTACK_EXEC_ON_CPU;
10502 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10503 kern_type = KERN_TYPE_BSDICRYPT;
10504 dgst_size = DGST_SIZE_4_4;
10505 parse_func = bsdicrypt_parse_hash;
10506 sort_by_digest = sort_by_digest_4_4;
10507 opti_type = OPTI_TYPE_ZERO_BYTE
10508 | OPTI_TYPE_PRECOMPUTE_PERMUT;
10509 dgst_pos0 = 0;
10510 dgst_pos1 = 1;
10511 dgst_pos2 = 2;
10512 dgst_pos3 = 3;
10513 break;
10514
10515 case 12500: hash_type = HASH_TYPE_RAR3HP;
10516 salt_type = SALT_TYPE_EMBEDDED;
10517 attack_exec = ATTACK_EXEC_ON_CPU;
10518 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10519 kern_type = KERN_TYPE_RAR3;
10520 dgst_size = DGST_SIZE_4_4;
10521 parse_func = rar3hp_parse_hash;
10522 sort_by_digest = sort_by_digest_4_4;
10523 opti_type = OPTI_TYPE_ZERO_BYTE;
10524 dgst_pos0 = 0;
10525 dgst_pos1 = 1;
10526 dgst_pos2 = 2;
10527 dgst_pos3 = 3;
10528 break;
10529
10530 case 12600: hash_type = HASH_TYPE_SHA256;
10531 salt_type = SALT_TYPE_INTERN;
10532 attack_exec = ATTACK_EXEC_ON_GPU;
10533 opts_type = OPTS_TYPE_PT_GENERATE_BE
10534 | OPTS_TYPE_PT_ADD80;
10535 kern_type = KERN_TYPE_CF10;
10536 dgst_size = DGST_SIZE_4_8;
10537 parse_func = cf10_parse_hash;
10538 sort_by_digest = sort_by_digest_4_8;
10539 opti_type = OPTI_TYPE_ZERO_BYTE
10540 | OPTI_TYPE_PRECOMPUTE_INIT
10541 | OPTI_TYPE_EARLY_SKIP
10542 | OPTI_TYPE_NOT_ITERATED;
10543 dgst_pos0 = 3;
10544 dgst_pos1 = 7;
10545 dgst_pos2 = 2;
10546 dgst_pos3 = 6;
10547 break;
10548
10549 case 12700: hash_type = HASH_TYPE_AES;
10550 salt_type = SALT_TYPE_EMBEDDED;
10551 attack_exec = ATTACK_EXEC_ON_CPU;
10552 opts_type = OPTS_TYPE_PT_GENERATE_LE
10553 | OPTS_TYPE_HASH_COPY;
10554 kern_type = KERN_TYPE_MYWALLET;
10555 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
10556 parse_func = mywallet_parse_hash;
10557 sort_by_digest = sort_by_digest_4_5;
10558 opti_type = OPTI_TYPE_ZERO_BYTE;
10559 dgst_pos0 = 0;
10560 dgst_pos1 = 1;
10561 dgst_pos2 = 2;
10562 dgst_pos3 = 3;
10563 break;
10564
10565 case 12800: hash_type = HASH_TYPE_PBKDF2_SHA256;
10566 salt_type = SALT_TYPE_EMBEDDED;
10567 attack_exec = ATTACK_EXEC_ON_CPU;
10568 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10569 kern_type = KERN_TYPE_MS_DRSR;
10570 dgst_size = DGST_SIZE_4_8;
10571 parse_func = ms_drsr_parse_hash;
10572 sort_by_digest = sort_by_digest_4_8;
10573 opti_type = OPTI_TYPE_ZERO_BYTE;
10574 dgst_pos0 = 0;
10575 dgst_pos1 = 1;
10576 dgst_pos2 = 2;
10577 dgst_pos3 = 3;
10578 break;
10579
10580 default: usage_mini_print (PROGNAME); return (-1);
10581 }
10582
10583 /**
10584 * transpose
10585 */
10586
10587 data.parse_func = parse_func;
10588
10589 /**
10590 * misc stuff
10591 */
10592
10593 if (hex_salt)
10594 {
10595 if (salt_type == SALT_TYPE_INTERN)
10596 {
10597 opts_type |= OPTS_TYPE_ST_HEX;
10598 }
10599 else
10600 {
10601 log_error ("ERROR: Parameter hex-salt not valid for hash-type %u", hash_mode);
10602
10603 return (-1);
10604 }
10605 }
10606
10607 uint isSalted = ((salt_type == SALT_TYPE_INTERN)
10608 | (salt_type == SALT_TYPE_EXTERN)
10609 | (salt_type == SALT_TYPE_EMBEDDED)
10610 | (salt_type == SALT_TYPE_VIRTUAL));
10611
10612 sort_by_digest = sort_by_digest_p0p1; // overruled by 64 bit digest
10613
10614 data.hash_type = hash_type;
10615 data.attack_mode = attack_mode;
10616 data.attack_kern = attack_kern;
10617 data.attack_exec = attack_exec;
10618 data.kern_type = kern_type;
10619 data.opts_type = opts_type;
10620 data.dgst_size = dgst_size;
10621 data.salt_type = salt_type;
10622 data.isSalted = isSalted;
10623 data.sort_by_digest = sort_by_digest;
10624 data.dgst_pos0 = dgst_pos0;
10625 data.dgst_pos1 = dgst_pos1;
10626 data.dgst_pos2 = dgst_pos2;
10627 data.dgst_pos3 = dgst_pos3;
10628
10629 esalt_size = 0;
10630
10631 switch (hash_mode)
10632 {
10633 case 2500: esalt_size = sizeof (wpa_t); break;
10634 case 5300: esalt_size = sizeof (ikepsk_t); break;
10635 case 5400: esalt_size = sizeof (ikepsk_t); break;
10636 case 5500: esalt_size = sizeof (netntlm_t); break;
10637 case 5600: esalt_size = sizeof (netntlm_t); break;
10638 case 6211:
10639 case 6212:
10640 case 6213:
10641 case 6221:
10642 case 6222:
10643 case 6223:
10644 case 6231:
10645 case 6232:
10646 case 6233:
10647 case 6241:
10648 case 6242:
10649 case 6243: esalt_size = sizeof (tc_t); break;
10650 case 6600: esalt_size = sizeof (agilekey_t); break;
10651 case 7100: esalt_size = sizeof (pbkdf2_sha512_t); break;
10652 case 7200: esalt_size = sizeof (pbkdf2_sha512_t); break;
10653 case 7300: esalt_size = sizeof (rakp_t); break;
10654 case 7500: esalt_size = sizeof (krb5pa_t); break;
10655 case 8200: esalt_size = sizeof (cloudkey_t); break;
10656 case 8800: esalt_size = sizeof (androidfde_t); break;
10657 case 9200: esalt_size = sizeof (pbkdf2_sha256_t); break;
10658 case 9400: esalt_size = sizeof (office2007_t); break;
10659 case 9500: esalt_size = sizeof (office2010_t); break;
10660 case 9600: esalt_size = sizeof (office2013_t); break;
10661 case 9700: esalt_size = sizeof (oldoffice01_t); break;
10662 case 9710: esalt_size = sizeof (oldoffice01_t); break;
10663 case 9720: esalt_size = sizeof (oldoffice01_t); break;
10664 case 9800: esalt_size = sizeof (oldoffice34_t); break;
10665 case 9810: esalt_size = sizeof (oldoffice34_t); break;
10666 case 9820: esalt_size = sizeof (oldoffice34_t); break;
10667 case 10000: esalt_size = sizeof (pbkdf2_sha256_t); break;
10668 case 10200: esalt_size = sizeof (cram_md5_t); break;
10669 case 10400: esalt_size = sizeof (pdf_t); break;
10670 case 10410: esalt_size = sizeof (pdf_t); break;
10671 case 10420: esalt_size = sizeof (pdf_t); break;
10672 case 10500: esalt_size = sizeof (pdf_t); break;
10673 case 10600: esalt_size = sizeof (pdf_t); break;
10674 case 10700: esalt_size = sizeof (pdf_t); break;
10675 case 10900: esalt_size = sizeof (pbkdf2_sha256_t); break;
10676 case 11300: esalt_size = sizeof (bitcoin_wallet_t); break;
10677 case 11400: esalt_size = sizeof (sip_t); break;
10678 case 11600: esalt_size = sizeof (seven_zip_t); break;
10679 case 11900: esalt_size = sizeof (pbkdf2_md5_t); break;
10680 case 12000: esalt_size = sizeof (pbkdf2_sha1_t); break;
10681 case 12100: esalt_size = sizeof (pbkdf2_sha512_t); break;
10682 }
10683
10684 data.esalt_size = esalt_size;
10685
10686 /**
10687 * choose dictionary parser
10688 */
10689
10690 if (hash_type == HASH_TYPE_LM)
10691 {
10692 get_next_word_func = get_next_word_lm;
10693 }
10694 else if (opts_type & OPTS_TYPE_PT_UPPER)
10695 {
10696 get_next_word_func = get_next_word_uc;
10697 }
10698 else
10699 {
10700 get_next_word_func = get_next_word_std;
10701 }
10702
10703 /**
10704 * dictstat
10705 */
10706
10707 dictstat_t *dictstat_base = (dictstat_t *) mycalloc (MAX_DICTSTAT, sizeof (dictstat_t));
10708
10709 #ifdef _POSIX
10710 size_t dictstat_nmemb = 0;
10711 #endif
10712
10713 #ifdef _WIN
10714 uint dictstat_nmemb = 0;
10715 #endif
10716
10717 char dictstat[256];
10718
10719 FILE *dictstat_fp = NULL;
10720
10721 if (keyspace == 0)
10722 {
10723 memset (dictstat, 0, sizeof (dictstat));
10724
10725 snprintf (dictstat, sizeof (dictstat) - 1, "%s/%s.dictstat", install_dir, PROGNAME);
10726
10727 dictstat_fp = fopen (dictstat, "rb");
10728
10729 if (dictstat_fp)
10730 {
10731 #ifdef _POSIX
10732 struct stat tmpstat;
10733
10734 fstat (fileno (dictstat_fp), &tmpstat);
10735 #endif
10736
10737 #ifdef _WIN
10738 struct stat64 tmpstat;
10739
10740 _fstat64 (fileno (dictstat_fp), &tmpstat);
10741 #endif
10742
10743 if (tmpstat.st_mtime < COMPTIME)
10744 {
10745 /* with v0.15 the format changed so we have to ensure user is using a good version
10746 since there is no version-header in the dictstat file */
10747
10748 fclose (dictstat_fp);
10749
10750 unlink (dictstat);
10751 }
10752 else
10753 {
10754 while (!feof (dictstat_fp))
10755 {
10756 dictstat_t d;
10757
10758 if (fread (&d, sizeof (dictstat_t), 1, dictstat_fp) == 0) continue;
10759
10760 lsearch (&d, dictstat_base, &dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
10761
10762 if (dictstat_nmemb == (MAX_DICTSTAT - 1000))
10763 {
10764 log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat);
10765
10766 return -1;
10767 }
10768 }
10769
10770 fclose (dictstat_fp);
10771 }
10772 }
10773 }
10774
10775 /**
10776 * potfile
10777 */
10778
10779 char potfile[256];
10780
10781 memset (potfile, 0, sizeof (potfile));
10782
10783 snprintf (potfile, sizeof (potfile) - 1, "%s.pot", session);
10784
10785 data.pot_fp = NULL;
10786
10787 FILE *out_fp = NULL;
10788 FILE *pot_fp = NULL;
10789
10790 if (show == 1 || left == 1)
10791 {
10792 pot_fp = fopen (potfile, "rb");
10793
10794 if (pot_fp == NULL)
10795 {
10796 log_error ("ERROR: %s: %s", potfile, strerror (errno));
10797
10798 return (-1);
10799 }
10800
10801 if (outfile != NULL)
10802 {
10803 if ((out_fp = fopen (outfile, "ab")) == NULL)
10804 {
10805 log_error ("ERROR: %s: %s", outfile, strerror (errno));
10806
10807 fclose (pot_fp);
10808
10809 return (-1);
10810 }
10811 }
10812 else
10813 {
10814 out_fp = stdout;
10815 }
10816 }
10817 else
10818 {
10819 if (potfile_disable == 0)
10820 {
10821 pot_fp = fopen (potfile, "ab");
10822
10823 if (pot_fp == NULL)
10824 {
10825 log_error ("ERROR: %s: %s", potfile, strerror (errno));
10826
10827 return (-1);
10828 }
10829
10830 data.pot_fp = pot_fp;
10831 }
10832 }
10833
10834 pot_t *pot = NULL;
10835
10836 uint pot_cnt = 0;
10837 uint pot_avail = 0;
10838
10839 if (show == 1 || left == 1)
10840 {
10841 SUPPRESS_OUTPUT = 1;
10842
10843 pot_avail = count_lines (pot_fp);
10844
10845 rewind (pot_fp);
10846
10847 pot = (pot_t *) mycalloc (pot_avail, sizeof (pot_t));
10848
10849 uint pot_hashes_avail = 0;
10850
10851 uint line_num = 0;
10852
10853 while (!feof (pot_fp))
10854 {
10855 line_num++;
10856
10857 char line_buf[BUFSIZ];
10858
10859 int line_len = fgetl (pot_fp, line_buf);
10860
10861 if (line_len == 0) continue;
10862
10863 char *plain_buf = line_buf + line_len;
10864
10865 pot_t *pot_ptr = &pot[pot_cnt];
10866
10867 hash_t *hashes_buf = &pot_ptr->hash;
10868
10869 // we do not initialize all hashes_buf->digest etc at the beginning, since many lines may not be
10870 // valid lines of this specific hash type (otherwise it would be more waste of memory than gain)
10871
10872 if (pot_cnt == pot_hashes_avail)
10873 {
10874 uint pos = 0;
10875
10876 for (pos = 0; pos < INCR_POT; pos++)
10877 {
10878 if ((pot_cnt + pos) >= pot_avail) break;
10879
10880 pot_t *tmp_pot = &pot[pot_cnt + pos];
10881
10882 hash_t *tmp_hash = &tmp_pot->hash;
10883
10884 tmp_hash->digest = mymalloc (dgst_size);
10885
10886 if (isSalted)
10887 {
10888 tmp_hash->salt = (salt_t *) mymalloc (sizeof (salt_t));
10889 }
10890
10891 if (esalt_size)
10892 {
10893 tmp_hash->esalt = mymalloc (esalt_size);
10894 }
10895
10896 pot_hashes_avail++;
10897 }
10898 }
10899
10900 int plain_len = 0;
10901
10902 int parser_status;
10903
10904 int iter = MAX_CUT_TRIES;
10905
10906 do
10907 {
10908 for (int i = line_len - 1; i; i--, plain_len++, plain_buf--, line_len--)
10909 {
10910 if (line_buf[i] == ':')
10911 {
10912 line_len--;
10913
10914 break;
10915 }
10916 }
10917
10918 if (data.hash_mode != 2500)
10919 {
10920 parser_status = parse_func (line_buf, line_len, hashes_buf);
10921 }
10922 else
10923 {
10924 int max_salt_size = sizeof (hashes_buf->salt->salt_buf);
10925
10926 if (line_len > max_salt_size)
10927 {
10928 parser_status = PARSER_GLOBAL_LENGTH;
10929 }
10930 else
10931 {
10932 memset (&hashes_buf->salt->salt_buf, 0, max_salt_size);
10933
10934 memcpy (&hashes_buf->salt->salt_buf, line_buf, line_len);
10935
10936 hashes_buf->salt->salt_len = line_len;
10937
10938 parser_status = PARSER_OK;
10939 }
10940 }
10941
10942 // if NOT parsed without error, we add the ":" to the plain
10943
10944 if (parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH)
10945 {
10946 plain_len++;
10947 plain_buf--;
10948 }
10949
10950 } while ((parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH) && --iter);
10951
10952 if (parser_status < PARSER_GLOBAL_ZERO)
10953 {
10954 // log_info ("WARNING: Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status));
10955
10956 continue;
10957 }
10958
10959 memcpy (pot_ptr->plain_buf, plain_buf, plain_len);
10960
10961 pot_ptr->plain_len = plain_len;
10962
10963 pot_cnt++;
10964 }
10965
10966 fclose (pot_fp);
10967
10968 SUPPRESS_OUTPUT = 0;
10969
10970 qsort (pot, pot_cnt, sizeof (pot_t), sort_by_pot);
10971 }
10972
10973 /**
10974 * gpu accel and loops auto adjustment
10975 */
10976
10977 if (gpu_accel_chgd == 0) gpu_accel = set_gpu_accel (hash_mode);
10978 if (gpu_loops_chgd == 0) gpu_loops = set_gpu_loops (hash_mode);
10979
10980 if (workload_profile == 1)
10981 {
10982 gpu_loops /= 8;
10983 gpu_accel /= 4;
10984
10985 if (gpu_loops == 0) gpu_loops = 8;
10986 if (gpu_accel == 0) gpu_accel = 2;
10987 }
10988 else if (workload_profile == 3)
10989 {
10990 gpu_loops *= 8;
10991 gpu_accel *= 4;
10992
10993 if (gpu_loops > 1024) gpu_loops = 1024;
10994 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
10995 }
10996
10997 // those hashes *must* run at a specific gpu_loops count because of some optimization inside the kernel
10998
10999 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
11000 {
11001 gpu_loops = 1024;
11002 }
11003
11004 if (hash_mode == 12500)
11005 {
11006 gpu_loops = ROUNDS_RAR3 / 16;
11007 }
11008
11009 data.gpu_accel = gpu_accel;
11010 data.gpu_loops = gpu_loops;
11011
11012 /**
11013 * word len
11014 */
11015
11016 uint pw_min = PW_MIN;
11017 uint pw_max = PW_MAX;
11018
11019 switch (hash_mode)
11020 {
11021 case 400: if (pw_max > 40) pw_max = 40;
11022 break;
11023 case 500: if (pw_max > 16) pw_max = 16;
11024 break;
11025 case 1500: if (pw_max > 8) pw_max = 8;
11026 break;
11027 case 1600: if (pw_max > 16) pw_max = 16;
11028 break;
11029 case 1800: if (pw_max > 16) pw_max = 16;
11030 break;
11031 case 2100: if (pw_max > 16) pw_max = 16;
11032 break;
11033 case 2500: if (pw_min < 8) pw_min = 8;
11034 break;
11035 case 3000: if (pw_max > 7) pw_max = 7;
11036 break;
11037 case 5200: if (pw_max > 24) pw_max = 24;
11038 break;
11039 case 5800: if (pw_max > 16) pw_max = 16;
11040 break;
11041 case 6300: if (pw_max > 16) pw_max = 16;
11042 break;
11043 case 7400: if (pw_max > 16) pw_max = 16;
11044 break;
11045 case 7900: if (pw_max > 48) pw_max = 48;
11046 break;
11047 case 8500: if (pw_max > 8) pw_max = 8;
11048 break;
11049 case 8600: if (pw_max > 16) pw_max = 16;
11050 break;
11051 case 9710: pw_min = 5;
11052 pw_max = 5;
11053 break;
11054 case 9810: pw_min = 5;
11055 pw_max = 5;
11056 break;
11057 case 10410: pw_min = 5;
11058 pw_max = 5;
11059 break;
11060 case 10300: if (pw_max < 3) pw_min = 3;
11061 if (pw_max > 40) pw_max = 40;
11062 break;
11063 case 10500: if (pw_max < 3) pw_min = 3;
11064 if (pw_max > 40) pw_max = 40;
11065 break;
11066 case 10700: if (pw_max > 16) pw_max = 16;
11067 break;
11068 case 11300: if (pw_max > 40) pw_max = 40;
11069 break;
11070 case 12500: if (pw_max > 20) pw_max = 20;
11071 break;
11072 case 12800: if (pw_max > 24) pw_max = 24;
11073 break;
11074 }
11075
11076 if (attack_exec == ATTACK_EXEC_ON_GPU)
11077 {
11078 switch (attack_kern)
11079 {
11080 case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
11081 break;
11082 case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
11083 break;
11084 }
11085 }
11086
11087 /**
11088 * charsets : keep them together for more easy maintainnce
11089 */
11090
11091 cs_t mp_sys[6];
11092 cs_t mp_usr[4];
11093
11094 memset (mp_sys, 0, sizeof (mp_sys));
11095 memset (mp_usr, 0, sizeof (mp_usr));
11096
11097 mp_setup_sys (mp_sys);
11098
11099 if (custom_charset_1) mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
11100 if (custom_charset_2) mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
11101 if (custom_charset_3) mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
11102 if (custom_charset_4) mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
11103
11104 /**
11105 * load hashes, part I: find input mode, count hashes
11106 */
11107
11108 uint hashlist_mode = 0;
11109 uint hashlist_format = HLFMT_HASHCAT;
11110
11111 uint hashes_avail = 0;
11112
11113 if (benchmark == 0)
11114 {
11115 struct stat f;
11116
11117 hashlist_mode = (stat (myargv[optind], &f) == 0) ? HL_MODE_FILE : HL_MODE_ARG;
11118
11119 if ((hash_mode == 2500) ||
11120 (hash_mode == 5200) ||
11121 ((hash_mode >= 6200) && (hash_mode <= 6299)) ||
11122 (hash_mode == 9000))
11123 {
11124 hashlist_mode = HL_MODE_ARG;
11125
11126 char *hashfile = myargv[optind];
11127
11128 data.hashfile = hashfile;
11129
11130 logfile_top_var_string ("target", hashfile);
11131 }
11132
11133 if (hashlist_mode == HL_MODE_ARG)
11134 {
11135 if (hash_mode == 2500)
11136 {
11137 struct stat st;
11138
11139 if (stat (data.hashfile, &st) == -1)
11140 {
11141 log_error ("ERROR: %s: %s", data.hashfile, strerror (errno));
11142
11143 return (-1);
11144 }
11145
11146 hashes_avail = st.st_size / sizeof (hccap_t);
11147 }
11148 else
11149 {
11150 hashes_avail = 1;
11151 }
11152 }
11153 else if (hashlist_mode == HL_MODE_FILE)
11154 {
11155 char *hashfile = myargv[optind];
11156
11157 data.hashfile = hashfile;
11158
11159 logfile_top_var_string ("target", hashfile);
11160
11161 FILE *fp = NULL;
11162
11163 if ((fp = fopen (hashfile, "rb")) == NULL)
11164 {
11165 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
11166
11167 return (-1);
11168 }
11169
11170 if (data.quiet == 0) log_info_nn ("Counting lines in %s", hashfile);
11171
11172 hashes_avail = count_lines (fp);
11173
11174 rewind (fp);
11175
11176 if (hashes_avail == 0)
11177 {
11178 log_error ("ERROR: hashfile is empty or corrupt");
11179
11180 fclose (fp);
11181
11182 return (-1);
11183 }
11184
11185 hashlist_format = hlfmt_detect (fp, 100); // 100 = max numbers to "scan". could be hashes_avail, too
11186
11187 if ((remove == 1) && (hashlist_format != HLFMT_HASHCAT))
11188 {
11189 log_error ("ERROR: remove not supported in native hashfile-format mode");
11190
11191 fclose (fp);
11192
11193 return (-1);
11194 }
11195
11196 fclose (fp);
11197 }
11198 }
11199 else
11200 {
11201 hashlist_mode = HL_MODE_ARG;
11202
11203 hashes_avail = 1;
11204 }
11205
11206 if (hash_mode == 3000) hashes_avail *= 2;
11207
11208 data.hashlist_mode = hashlist_mode;
11209 data.hashlist_format = hashlist_format;
11210
11211 logfile_top_uint (hashlist_mode);
11212 logfile_top_uint (hashlist_format);
11213
11214 /**
11215 * load hashes, part II: allocate required memory, set pointers
11216 */
11217
11218 hash_t *hashes_buf = NULL;
11219 void *digests_buf = NULL;
11220 salt_t *salts_buf = NULL;
11221 void *esalts_buf = NULL;
11222
11223 hashes_buf = (hash_t *) mycalloc (hashes_avail, sizeof (hash_t));
11224
11225 digests_buf = (void *) mycalloc (hashes_avail, dgst_size);
11226
11227 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11228 {
11229 uint32_t hash_pos;
11230
11231 for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
11232 {
11233 hashinfo_t *hash_info = (hashinfo_t *) mymalloc (sizeof (hashinfo_t));
11234
11235 hashes_buf[hash_pos].hash_info = hash_info;
11236
11237 if (username && (remove || show || left))
11238 {
11239 hash_info->user = (user_t*) mymalloc (sizeof (user_t));
11240 }
11241
11242 if (benchmark)
11243 {
11244 hash_info->orighash = (char *) mymalloc (256);
11245 }
11246 }
11247 }
11248
11249 if (isSalted)
11250 {
11251 salts_buf = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
11252
11253 if (esalt_size)
11254 {
11255 esalts_buf = (void *) mycalloc (hashes_avail, esalt_size);
11256 }
11257 }
11258 else
11259 {
11260 salts_buf = (salt_t *) mycalloc (1, sizeof (salt_t));
11261 }
11262
11263 for (uint hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
11264 {
11265 hashes_buf[hash_pos].digest = ((char *) digests_buf) + (hash_pos * dgst_size);
11266
11267 if (isSalted)
11268 {
11269 hashes_buf[hash_pos].salt = &salts_buf[hash_pos];
11270
11271 if (esalt_size)
11272 {
11273 hashes_buf[hash_pos].esalt = ((char *) esalts_buf) + (hash_pos * esalt_size);
11274 }
11275 }
11276 else
11277 {
11278 hashes_buf[hash_pos].salt = &salts_buf[0];
11279 }
11280 }
11281
11282 /**
11283 * load hashes, part III: parse hashes or generate them if benchmark
11284 */
11285
11286 uint hashes_cnt = 0;
11287
11288 if (benchmark == 0)
11289 {
11290 if (keyspace == 1)
11291 {
11292 // useless to read hash file for keyspace, cheat a little bit w/ optind
11293 }
11294 else if (hashes_avail == 0)
11295 {
11296 }
11297 else if (hashlist_mode == HL_MODE_ARG)
11298 {
11299 char *input_buf = myargv[optind];
11300
11301 uint input_len = strlen (input_buf);
11302
11303 logfile_top_var_string ("target", input_buf);
11304
11305 char *hash_buf = NULL;
11306 int hash_len = 0;
11307
11308 hlfmt_hash (hashlist_format, input_buf, input_len, &hash_buf, &hash_len);
11309
11310 if (hash_len)
11311 {
11312 if (opts_type & OPTS_TYPE_HASH_COPY)
11313 {
11314 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
11315
11316 hash_info_tmp->orighash = mystrdup (hash_buf);
11317 }
11318
11319 if (isSalted)
11320 {
11321 memset (hashes_buf[0].salt, 0, sizeof (salt_t));
11322 }
11323
11324 int parser_status = PARSER_OK;
11325
11326 if (hash_mode == 2500)
11327 {
11328 if (hash_len == 0)
11329 {
11330 log_error ("ERROR: hccap file not specified");
11331
11332 return (-1);
11333 }
11334
11335 hashlist_mode = HL_MODE_FILE;
11336
11337 data.hashlist_mode = hashlist_mode;
11338
11339 FILE *fp = fopen (hash_buf, "rb");
11340
11341 if (fp == NULL)
11342 {
11343 log_error ("ERROR: %s: %s", hash_buf, strerror (errno));
11344
11345 return (-1);
11346 }
11347
11348 if (hashes_avail < 1)
11349 {
11350 log_error ("ERROR: hccap file is empty or corrupt");
11351
11352 fclose (fp);
11353
11354 return (-1);
11355 }
11356
11357 uint hccap_size = sizeof (hccap_t);
11358
11359 char in[hccap_size];
11360
11361 while (!feof (fp))
11362 {
11363 int n = fread (&in, hccap_size, 1, fp);
11364
11365 if (n != 1)
11366 {
11367 if (hashes_cnt < 1) parser_status = PARSER_HCCAP_FILE_SIZE;
11368
11369 break;
11370 }
11371
11372 parser_status = parse_func (in, hccap_size, &hashes_buf[hashes_cnt]);
11373
11374 if (parser_status != PARSER_OK)
11375 {
11376 log_info ("WARNING: Hash '%s': %s", hash_buf, strparser (parser_status));
11377
11378 continue;
11379 }
11380
11381 // hack: append MAC1 and MAC2 s.t. in --show and --left the line matches with the .pot file format (i.e. ESSID:MAC1:MAC2)
11382
11383 if ((show == 1) || (left == 1))
11384 {
11385 salt_t *tmp_salt = hashes_buf[hashes_cnt].salt;
11386
11387 char *salt_ptr = (char *) tmp_salt->salt_buf;
11388
11389 int cur_pos = tmp_salt->salt_len;
11390 int rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
11391
11392 wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt;
11393
11394 unsigned char *pke_ptr = (unsigned char *) wpa->pke;
11395
11396 // do the appending task
11397
11398 snprintf (salt_ptr + cur_pos,
11399 rem_len,
11400 ":%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
11401 pke_ptr[20], pke_ptr[27], pke_ptr[26], pke_ptr[25], pke_ptr[24], pke_ptr[31], // MAC1
11402 pke_ptr[30], pke_ptr[29], pke_ptr[28], pke_ptr[35], pke_ptr[34], pke_ptr[33]); // MAC2
11403
11404
11405 // memset () the remaining part of the salt
11406
11407 cur_pos = tmp_salt->salt_len + 1 + 12 + 1 + 12;
11408 rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
11409
11410 if (rem_len > 0) memset (salt_ptr + cur_pos, 0, rem_len);
11411
11412 tmp_salt->salt_len += 1 + 12 + 1 + 12;
11413 }
11414
11415 if (show == 1) handle_show_request (pot, pot_cnt, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf, out_fp);
11416 if (left == 1) handle_left_request (pot, pot_cnt, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf, out_fp);
11417
11418 hashes_cnt++;
11419 }
11420
11421 fclose (fp);
11422 }
11423 else if (hash_mode == 3000)
11424 {
11425 if (hash_len == 32)
11426 {
11427 parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
11428
11429 hash_t *lm_hash_left = NULL;
11430
11431 if (parser_status == PARSER_OK)
11432 {
11433 lm_hash_left = &hashes_buf[hashes_cnt];
11434
11435 hashes_cnt++;
11436 }
11437 else
11438 {
11439 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11440 }
11441
11442
11443 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
11444
11445 hash_t *lm_hash_right = NULL;
11446
11447 if (parser_status == PARSER_OK)
11448 {
11449 lm_hash_right = &hashes_buf[hashes_cnt];
11450
11451 hashes_cnt++;
11452 }
11453 else
11454 {
11455 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11456 }
11457
11458 // show / left
11459
11460 if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
11461 {
11462 if (show == 1) handle_show_request_lm (pot, pot_cnt, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot, out_fp);
11463 if (left == 1) handle_left_request_lm (pot, pot_cnt, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot, out_fp);
11464 }
11465 }
11466 else
11467 {
11468 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11469
11470 if (parser_status == PARSER_OK)
11471 {
11472 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11473 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11474 }
11475
11476 if (parser_status == PARSER_OK)
11477 {
11478 hashes_cnt++;
11479 }
11480 else
11481 {
11482 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11483 }
11484 }
11485 }
11486 else
11487 {
11488 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11489
11490 if (parser_status == PARSER_OK)
11491 {
11492 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11493 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11494 }
11495
11496 if (parser_status == PARSER_OK)
11497 {
11498 hashes_cnt++;
11499 }
11500 else
11501 {
11502 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11503 }
11504 }
11505 }
11506 }
11507 else if (hashlist_mode == HL_MODE_FILE)
11508 {
11509 char *hashfile = data.hashfile;
11510
11511 FILE *fp;
11512
11513 if ((fp = fopen (hashfile, "rb")) == NULL)
11514 {
11515 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
11516
11517 return (-1);
11518 }
11519
11520 uint line_num = 0;
11521
11522 while (!feof (fp))
11523 {
11524 line_num++;
11525
11526 char line_buf[BUFSIZ];
11527
11528 int line_len = fgetl (fp, line_buf);
11529
11530 if (line_len == 0) continue;
11531
11532 char *hash_buf = NULL;
11533 int hash_len = 0;
11534
11535 hlfmt_hash (hashlist_format, line_buf, line_len, &hash_buf, &hash_len);
11536
11537 if (username)
11538 {
11539 char *user_buf = NULL;
11540 int user_len = 0;
11541
11542 hlfmt_user (hashlist_format, line_buf, line_len, &user_buf, &user_len);
11543
11544 if (remove || show)
11545 {
11546 user_t **user = &hashes_buf[hashes_cnt].hash_info->user;
11547
11548 *user = (user_t *) malloc (sizeof (user_t));
11549
11550 user_t *user_ptr = *user;
11551
11552 if (user_buf != NULL)
11553 {
11554 user_ptr->user_name = mystrdup (user_buf);
11555 }
11556 else
11557 {
11558 user_ptr->user_name = mystrdup ("");
11559 }
11560
11561 user_ptr->user_len = user_len;
11562 }
11563 }
11564
11565 if (opts_type & OPTS_TYPE_HASH_COPY)
11566 {
11567 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
11568
11569 hash_info_tmp->orighash = mystrdup (hash_buf);
11570 }
11571
11572 if (isSalted)
11573 {
11574 memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t));
11575 }
11576
11577 if (hash_mode == 3000)
11578 {
11579 if (hash_len == 32)
11580 {
11581 int parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
11582
11583 if (parser_status < PARSER_GLOBAL_ZERO)
11584 {
11585 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11586
11587 continue;
11588 }
11589
11590 hash_t *lm_hash_left = &hashes_buf[hashes_cnt];
11591
11592 hashes_cnt++;
11593
11594 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
11595
11596 if (parser_status < PARSER_GLOBAL_ZERO)
11597 {
11598 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11599
11600 continue;
11601 }
11602
11603 hash_t *lm_hash_right = &hashes_buf[hashes_cnt];
11604
11605 if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((float) hashes_cnt / hashes_avail) * 100);
11606
11607 hashes_cnt++;
11608
11609 // show / left
11610
11611 if (show == 1) handle_show_request_lm (pot, pot_cnt, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot, out_fp);
11612 if (left == 1) handle_left_request_lm (pot, pot_cnt, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot, out_fp);
11613 }
11614 else
11615 {
11616 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11617
11618 if (parser_status < PARSER_GLOBAL_ZERO)
11619 {
11620 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11621
11622 continue;
11623 }
11624
11625 if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((float) hashes_cnt / hashes_avail) * 100);
11626
11627 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11628 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11629
11630 hashes_cnt++;
11631 }
11632 }
11633 else
11634 {
11635 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11636
11637 if (parser_status < PARSER_GLOBAL_ZERO)
11638 {
11639 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11640
11641 continue;
11642 }
11643
11644 if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((float) hashes_cnt / hashes_avail) * 100);
11645
11646 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11647 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11648
11649 hashes_cnt++;
11650 }
11651 }
11652
11653 fclose (fp);
11654
11655 if (data.quiet == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
11656
11657 if ((out_fp != NULL) && (out_fp != stdout)) fclose (out_fp);
11658 }
11659 }
11660 else
11661 {
11662 if (isSalted)
11663 {
11664 hashes_buf[0].salt->salt_len = 8;
11665
11666 // special salt handling
11667
11668 switch (hash_mode)
11669 {
11670 case 1500: hashes_buf[0].salt->salt_len = 2;
11671 break;
11672 case 1731: hashes_buf[0].salt->salt_len = 4;
11673 break;
11674 case 2410: hashes_buf[0].salt->salt_len = 4;
11675 break;
11676 case 2500: memcpy (hashes_buf[0].salt->salt_buf, "hashcat.net", 11);
11677 break;
11678 case 3100: hashes_buf[0].salt->salt_len = 1;
11679 break;
11680 case 5000: hashes_buf[0].salt->keccak_mdlen = 32;
11681 break;
11682 case 5800: hashes_buf[0].salt->salt_len = 16;
11683 break;
11684 case 6800: hashes_buf[0].salt->salt_len = 32;
11685 break;
11686 case 8400: hashes_buf[0].salt->salt_len = 40;
11687 break;
11688 case 8800: hashes_buf[0].salt->salt_len = 16;
11689 break;
11690 case 8900: hashes_buf[0].salt->salt_len = 16;
11691 hashes_buf[0].salt->scrypt_N = 1024;
11692 hashes_buf[0].salt->scrypt_r = 1;
11693 hashes_buf[0].salt->scrypt_p = 1;
11694 break;
11695 case 9100: hashes_buf[0].salt->salt_len = 16;
11696 break;
11697 case 9300: hashes_buf[0].salt->salt_len = 14;
11698 hashes_buf[0].salt->scrypt_N = 16384;
11699 hashes_buf[0].salt->scrypt_r = 1;
11700 hashes_buf[0].salt->scrypt_p = 1;
11701 break;
11702 case 9400: hashes_buf[0].salt->salt_len = 16;
11703 break;
11704 case 9500: hashes_buf[0].salt->salt_len = 16;
11705 break;
11706 case 9600: hashes_buf[0].salt->salt_len = 16;
11707 break;
11708 case 9700: hashes_buf[0].salt->salt_len = 16;
11709 break;
11710 case 9710: hashes_buf[0].salt->salt_len = 16;
11711 break;
11712 case 9720: hashes_buf[0].salt->salt_len = 16;
11713 break;
11714 case 9800: hashes_buf[0].salt->salt_len = 16;
11715 break;
11716 case 9810: hashes_buf[0].salt->salt_len = 16;
11717 break;
11718 case 9820: hashes_buf[0].salt->salt_len = 16;
11719 break;
11720 case 10300: hashes_buf[0].salt->salt_len = 12;
11721 break;
11722 case 11500: hashes_buf[0].salt->salt_len = 4;
11723 break;
11724 case 11600: hashes_buf[0].salt->salt_len = 4;
11725 break;
11726 case 12400: hashes_buf[0].salt->salt_len = 4;
11727 break;
11728 case 12500: hashes_buf[0].salt->salt_len = 8;
11729 break;
11730 case 12600: hashes_buf[0].salt->salt_len = 64;
11731 break;
11732 }
11733
11734 // special esalt handling
11735
11736 switch (hash_mode)
11737 {
11738 case 2500: ((wpa_t *) hashes_buf[0].esalt)->eapol_size = 128;
11739 break;
11740 case 5300: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
11741 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
11742 break;
11743 case 5400: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
11744 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
11745 break;
11746 case 5500: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
11747 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
11748 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
11749 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
11750 break;
11751 case 5600: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
11752 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
11753 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
11754 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
11755 break;
11756 case 7300: ((rakp_t *) hashes_buf[0].esalt)->salt_len = 32;
11757 break;
11758 case 10400: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11759 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11760 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11761 break;
11762 case 10410: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11763 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11764 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11765 break;
11766 case 10420: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11767 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11768 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11769 break;
11770 case 10500: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11771 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11772 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11773 break;
11774 case 10600: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11775 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
11776 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
11777 break;
11778 case 10700: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11779 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
11780 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
11781 break;
11782 case 11600: ((seven_zip_t *) hashes_buf[0].esalt)->iv_len = 16;
11783 ((seven_zip_t *) hashes_buf[0].esalt)->data_len = 112;
11784 ((seven_zip_t *) hashes_buf[0].esalt)->unpack_size = 112;
11785 break;
11786 }
11787 }
11788
11789 // set hashfile
11790
11791 switch (hash_mode)
11792 {
11793 case 5200: data.hashfile = mystrdup ("hashcat.psafe3");
11794 break;
11795 case 5300: data.hashfile = mystrdup ("hashcat.ikemd5");
11796 break;
11797 case 5400: data.hashfile = mystrdup ("hashcat.ikesha1");
11798 break;
11799 case 6211:
11800 case 6212:
11801 case 6213:
11802 case 6221:
11803 case 6222:
11804 case 6223:
11805 case 6231:
11806 case 6232:
11807 case 6233:
11808 case 6241:
11809 case 6242:
11810 case 6243: data.hashfile = mystrdup ("hashcat.tc");
11811 break;
11812 case 6600: data.hashfile = mystrdup ("hashcat.agilekey");
11813 break;
11814 case 8200: data.hashfile = mystrdup ("hashcat.cloudkey");
11815 break;
11816 case 9000: data.hashfile = mystrdup ("hashcat.psafe2");
11817 break;
11818 }
11819
11820 // set default iterations
11821
11822 switch (hash_mode)
11823 {
11824 case 400: hashes_buf[0].salt->salt_iter = ROUNDS_PHPASS;
11825 break;
11826 case 500: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11827 break;
11828 case 501: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11829 break;
11830 case 1600: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11831 break;
11832 case 1800: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512CRYPT;
11833 break;
11834 case 2100: hashes_buf[0].salt->salt_iter = ROUNDS_DCC2;
11835 break;
11836 case 2500: hashes_buf[0].salt->salt_iter = ROUNDS_WPA2;
11837 break;
11838 case 3200: hashes_buf[0].salt->salt_iter = ROUNDS_BCRYPT;
11839 break;
11840 case 5200: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE3;
11841 break;
11842 case 5800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDPIN - 1;
11843 break;
11844 case 6211:
11845 case 6212:
11846 case 6213: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_2K;
11847 break;
11848 case 6221:
11849 case 6222:
11850 case 6223: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11851 break;
11852 case 6231:
11853 case 6232:
11854 case 6233: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11855 break;
11856 case 6241:
11857 case 6242:
11858 case 6243: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11859 break;
11860 case 6300: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11861 break;
11862 case 6400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256AIX;
11863 break;
11864 case 6500: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512AIX;
11865 break;
11866 case 6700: hashes_buf[0].salt->salt_iter = ROUNDS_SHA1AIX;
11867 break;
11868 case 6600: hashes_buf[0].salt->salt_iter = ROUNDS_AGILEKEY;
11869 break;
11870 case 6800: hashes_buf[0].salt->salt_iter = ROUNDS_LASTPASS;
11871 break;
11872 case 7100: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512OSX;
11873 break;
11874 case 7200: hashes_buf[0].salt->salt_iter = ROUNDS_GRUB;
11875 break;
11876 case 7400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256CRYPT;
11877 break;
11878 case 7900: hashes_buf[0].salt->salt_iter = ROUNDS_DRUPAL7;
11879 break;
11880 case 8200: hashes_buf[0].salt->salt_iter = ROUNDS_CLOUDKEY;
11881 break;
11882 case 8300: hashes_buf[0].salt->salt_iter = ROUNDS_NSEC3;
11883 break;
11884 case 8800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDFDE;
11885 break;
11886 case 8900: hashes_buf[0].salt->salt_iter = 1;
11887 break;
11888 case 9000: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE2;
11889 break;
11890 case 9100: hashes_buf[0].salt->salt_iter = ROUNDS_LOTUS8;
11891 break;
11892 case 9200: hashes_buf[0].salt->salt_iter = ROUNDS_CISCO8;
11893 break;
11894 case 9300: hashes_buf[0].salt->salt_iter = 1;
11895 break;
11896 case 9400: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2007;
11897 break;
11898 case 9500: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2010;
11899 break;
11900 case 9600: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2013;
11901 break;
11902 case 10000: hashes_buf[0].salt->salt_iter = ROUNDS_DJANGOPBKDF2;
11903 break;
11904 case 10300: hashes_buf[0].salt->salt_iter = ROUNDS_SAPH_SHA1 - 1;
11905 break;
11906 case 10500: hashes_buf[0].salt->salt_iter = ROUNDS_PDF14;
11907 break;
11908 case 10700: hashes_buf[0].salt->salt_iter = ROUNDS_PDF17L8;
11909 break;
11910 case 10900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA256 - 1;
11911 break;
11912 case 11300: hashes_buf[0].salt->salt_iter = ROUNDS_BITCOIN_WALLET - 1;
11913 break;
11914 case 11600: hashes_buf[0].salt->salt_iter = ROUNDS_SEVEN_ZIP;
11915 break;
11916 case 11900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_MD5 - 1;
11917 break;
11918 case 12000: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA1 - 1;
11919 break;
11920 case 12100: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA512 - 1;
11921 break;
11922 case 12200: hashes_buf[0].salt->salt_iter = ROUNDS_ECRYPTFS - 1;
11923 break;
11924 case 12300: hashes_buf[0].salt->salt_iter = ROUNDS_ORACLET - 1;
11925 break;
11926 case 12400: hashes_buf[0].salt->salt_iter = ROUNDS_BSDICRYPT - 1;
11927 break;
11928 case 12500: hashes_buf[0].salt->salt_iter = ROUNDS_RAR3;
11929 break;
11930 case 12700: hashes_buf[0].salt->salt_iter = ROUNDS_MYWALLET;
11931 break;
11932 case 12800: hashes_buf[0].salt->salt_iter = ROUNDS_MS_DRSR - 1;
11933 break;
11934 }
11935
11936 // set special tuning for benchmark-mode 1
11937
11938 if (benchmark_mode == 1)
11939 {
11940 gpu_loops *= 8;
11941 gpu_accel *= 4;
11942
11943 switch (hash_mode)
11944 {
11945 case 400: gpu_loops = ROUNDS_PHPASS;
11946 gpu_accel = 32;
11947 break;
11948 case 500: gpu_loops = ROUNDS_MD5CRYPT;
11949 gpu_accel = 32;
11950 break;
11951 case 501: gpu_loops = ROUNDS_MD5CRYPT;
11952 gpu_accel = 32;
11953 break;
11954 case 1600: gpu_loops = ROUNDS_MD5CRYPT;
11955 gpu_accel = 32;
11956 break;
11957 case 1800: gpu_loops = ROUNDS_SHA512CRYPT;
11958 gpu_accel = 8;
11959 break;
11960 case 2100: gpu_loops = ROUNDS_DCC2;
11961 gpu_accel = 16;
11962 break;
11963 case 2500: gpu_loops = ROUNDS_WPA2;
11964 gpu_accel = 32;
11965 break;
11966 case 3200: gpu_loops = ROUNDS_BCRYPT;
11967 gpu_accel = 2;
11968 break;
11969 case 5200: gpu_loops = ROUNDS_PSAFE3;
11970 gpu_accel = 16;
11971 break;
11972 case 5800: gpu_loops = ROUNDS_ANDROIDPIN;
11973 gpu_accel = 16;
11974 break;
11975 case 6211: gpu_loops = ROUNDS_TRUECRYPT_2K;
11976 gpu_accel = 64;
11977 break;
11978 case 6212: gpu_loops = ROUNDS_TRUECRYPT_2K;
11979 gpu_accel = 32;
11980 break;
11981 case 6213: gpu_loops = ROUNDS_TRUECRYPT_2K;
11982 gpu_accel = 32;
11983 break;
11984 case 6221: gpu_loops = ROUNDS_TRUECRYPT_1K;
11985 gpu_accel = 8;
11986 break;
11987 case 6222: gpu_loops = ROUNDS_TRUECRYPT_1K;
11988 gpu_accel = 8;
11989 break;
11990 case 6223: gpu_loops = ROUNDS_TRUECRYPT_1K;
11991 gpu_accel = 8;
11992 break;
11993 case 6231: gpu_loops = ROUNDS_TRUECRYPT_1K;
11994 gpu_accel = 8;
11995 break;
11996 case 6232: gpu_loops = ROUNDS_TRUECRYPT_1K;
11997 gpu_accel = 8;
11998 break;
11999 case 6233: gpu_loops = ROUNDS_TRUECRYPT_1K;
12000 gpu_accel = 8;
12001 break;
12002 case 6241: gpu_loops = ROUNDS_TRUECRYPT_1K;
12003 gpu_accel = 128;
12004 break;
12005 case 6242: gpu_loops = ROUNDS_TRUECRYPT_1K;
12006 gpu_accel = 64;
12007 break;
12008 case 6243: gpu_loops = ROUNDS_TRUECRYPT_1K;
12009 gpu_accel = 64;
12010 break;
12011 case 6300: gpu_loops = ROUNDS_MD5CRYPT;
12012 gpu_accel = 32;
12013 break;
12014 case 6700: gpu_loops = ROUNDS_SHA1AIX;
12015 gpu_accel = 128;
12016 break;
12017 case 6400: gpu_loops = ROUNDS_SHA256AIX;
12018 gpu_accel = 128;
12019 break;
12020 case 6500: gpu_loops = ROUNDS_SHA512AIX;
12021 gpu_accel = 32;
12022 break;
12023 case 6600: gpu_loops = ROUNDS_AGILEKEY;
12024 gpu_accel = 64;
12025 break;
12026 case 6800: gpu_loops = ROUNDS_LASTPASS;
12027 gpu_accel = 64;
12028 break;
12029 case 7100: gpu_loops = ROUNDS_SHA512OSX;
12030 gpu_accel = 2;
12031 break;
12032 case 7200: gpu_loops = ROUNDS_GRUB;
12033 gpu_accel = 2;
12034 break;
12035 case 7400: gpu_loops = ROUNDS_SHA256CRYPT;
12036 gpu_accel = 4;
12037 break;
12038 case 7900: gpu_loops = ROUNDS_DRUPAL7;
12039 gpu_accel = 8;
12040 break;
12041 case 8200: gpu_loops = ROUNDS_CLOUDKEY;
12042 gpu_accel = 2;
12043 break;
12044 case 8800: gpu_loops = ROUNDS_ANDROIDFDE;
12045 gpu_accel = 32;
12046 break;
12047 case 8900: gpu_loops = 1;
12048 gpu_accel = 64;
12049 break;
12050 case 9000: gpu_loops = ROUNDS_PSAFE2;
12051 gpu_accel = 16;
12052 break;
12053 case 9100: gpu_loops = ROUNDS_LOTUS8;
12054 gpu_accel = 64;
12055 break;
12056 case 9200: gpu_loops = ROUNDS_CISCO8;
12057 gpu_accel = 8;
12058 break;
12059 case 9300: gpu_loops = 1;
12060 gpu_accel = 4;
12061 break;
12062 case 9400: gpu_loops = ROUNDS_OFFICE2007;
12063 gpu_accel = 32;
12064 break;
12065 case 9500: gpu_loops = ROUNDS_OFFICE2010;
12066 gpu_accel = 32;
12067 break;
12068 case 9600: gpu_loops = ROUNDS_OFFICE2013;
12069 gpu_accel = 4;
12070 break;
12071 case 10000: gpu_loops = ROUNDS_DJANGOPBKDF2;
12072 gpu_accel = 8;
12073 break;
12074 case 10300: gpu_loops = ROUNDS_SAPH_SHA1;
12075 gpu_accel = 16;
12076 break;
12077 case 10500: gpu_loops = ROUNDS_PDF14;
12078 gpu_accel = 256;
12079 break;
12080 case 10700: gpu_loops = ROUNDS_PDF17L8;
12081 gpu_accel = 8;
12082 break;
12083 case 10900: gpu_loops = ROUNDS_PBKDF2_SHA256;
12084 gpu_accel = 8;
12085 break;
12086 case 11300: gpu_loops = ROUNDS_BITCOIN_WALLET;
12087 gpu_accel = 2;
12088 break;
12089 case 11600: gpu_loops = ROUNDS_SEVEN_ZIP;
12090 gpu_accel = 4;
12091 break;
12092 case 11900: gpu_loops = ROUNDS_PBKDF2_MD5;
12093 gpu_accel = 8;
12094 break;
12095 case 12000: gpu_loops = ROUNDS_PBKDF2_SHA1;
12096 gpu_accel = 8;
12097 break;
12098 case 12100: gpu_loops = ROUNDS_PBKDF2_SHA512;
12099 gpu_accel = 8;
12100 break;
12101 case 12200: gpu_loops = ROUNDS_ECRYPTFS;
12102 gpu_accel = 8;
12103 break;
12104 case 12300: gpu_loops = ROUNDS_ORACLET;
12105 gpu_accel = 8;
12106 break;
12107 case 12500: gpu_loops = ROUNDS_RAR3;
12108 gpu_accel = 32;
12109 break;
12110 case 12700: gpu_loops = ROUNDS_MYWALLET;
12111 gpu_accel = 512;
12112 break;
12113 case 12800: gpu_loops = ROUNDS_MS_DRSR;
12114 gpu_accel = 512;
12115 break;
12116 }
12117
12118 // some algorithm collide too fast, make that impossible
12119
12120 switch (hash_mode)
12121 {
12122 case 11500: ((uint *) digests_buf)[1] = 1;
12123 break;
12124 }
12125
12126 if (gpu_loops > 1024) gpu_loops = 1024;
12127 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
12128 }
12129
12130 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
12131 {
12132 gpu_loops = 1024;
12133 }
12134
12135 if (hash_mode == 12500)
12136 {
12137 gpu_loops = ROUNDS_RAR3 / 16;
12138 }
12139
12140 data.gpu_accel = gpu_accel;
12141 data.gpu_loops = gpu_loops;
12142
12143 hashes_cnt = 1;
12144 }
12145
12146 if (show == 1 || left == 1)
12147 {
12148 for (uint i = 0; i < pot_cnt; i++)
12149 {
12150 pot_t *pot_ptr = &pot[i];
12151
12152 hash_t *hashes_buf = &pot_ptr->hash;
12153
12154 local_free (hashes_buf->digest);
12155
12156 if (isSalted)
12157 {
12158 local_free (hashes_buf->salt);
12159 }
12160 }
12161
12162 local_free (pot);
12163
12164 if (data.quiet == 0) log_info_nn ("");
12165
12166 return (0);
12167 }
12168
12169 if (keyspace == 0)
12170 {
12171 if (hashes_cnt == 0)
12172 {
12173 log_error ("ERROR: No hashes loaded");
12174
12175 return (-1);
12176 }
12177 }
12178
12179 /**
12180 * Sanity check for hashfile vs outfile (should not point to the same physical file)
12181 */
12182
12183 if (data.outfile != NULL)
12184 {
12185 if (data.hashfile != NULL)
12186 {
12187 #ifdef _POSIX
12188 struct stat tmpstat_outfile;
12189 struct stat tmpstat_hashfile;
12190 #endif
12191
12192 #ifdef _WIN
12193 struct stat64 tmpstat_outfile;
12194 struct stat64 tmpstat_hashfile;
12195 #endif
12196
12197 FILE *tmp_outfile_fp = fopen (data.outfile, "r");
12198
12199 if (tmp_outfile_fp)
12200 {
12201 #ifdef _POSIX
12202 fstat (fileno (tmp_outfile_fp), &tmpstat_outfile);
12203 #endif
12204
12205 #ifdef _WIN
12206 _fstat64 (fileno (tmp_outfile_fp), &tmpstat_outfile);
12207 #endif
12208
12209 fclose (tmp_outfile_fp);
12210 }
12211
12212 FILE *tmp_hashfile_fp = fopen (data.hashfile, "r");
12213
12214 if (tmp_hashfile_fp)
12215 {
12216 #ifdef _POSIX
12217 fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
12218 #endif
12219
12220 #ifdef _WIN
12221 _fstat64 (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
12222 #endif
12223
12224 fclose (tmp_hashfile_fp);
12225 }
12226
12227 if (tmp_outfile_fp && tmp_outfile_fp)
12228 {
12229 tmpstat_outfile.st_mode = 0;
12230 tmpstat_outfile.st_nlink = 0;
12231 tmpstat_outfile.st_uid = 0;
12232 tmpstat_outfile.st_gid = 0;
12233 tmpstat_outfile.st_rdev = 0;
12234 tmpstat_outfile.st_atime = 0;
12235
12236 tmpstat_hashfile.st_mode = 0;
12237 tmpstat_hashfile.st_nlink = 0;
12238 tmpstat_hashfile.st_uid = 0;
12239 tmpstat_hashfile.st_gid = 0;
12240 tmpstat_hashfile.st_rdev = 0;
12241 tmpstat_hashfile.st_atime = 0;
12242
12243 #ifdef _POSIX
12244 tmpstat_outfile.st_blksize = 0;
12245 tmpstat_outfile.st_blocks = 0;
12246
12247 tmpstat_hashfile.st_blksize = 0;
12248 tmpstat_hashfile.st_blocks = 0;
12249 #endif
12250
12251 #ifdef _POSIX
12252 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat)) == 0)
12253 {
12254 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
12255
12256 return (-1);
12257 }
12258 #endif
12259
12260 #ifdef _WIN
12261 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat64)) == 0)
12262 {
12263 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
12264
12265 return (-1);
12266 }
12267 #endif
12268 }
12269 }
12270 }
12271
12272 /**
12273 * Remove duplicates
12274 */
12275
12276 if (data.quiet == 0) log_info_nn ("Removing duplicate hashes...");
12277
12278 if (isSalted)
12279 {
12280 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
12281 }
12282 else
12283 {
12284 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
12285 }
12286
12287 uint hashes_cnt_orig = hashes_cnt;
12288
12289 hashes_cnt = 1;
12290
12291 for (uint hashes_pos = 1; hashes_pos < hashes_cnt_orig; hashes_pos++)
12292 {
12293 if (isSalted)
12294 {
12295 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) == 0)
12296 {
12297 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
12298 }
12299 }
12300 else
12301 {
12302 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
12303 }
12304
12305 if (hashes_pos > hashes_cnt)
12306 {
12307 memcpy (&hashes_buf[hashes_cnt], &hashes_buf[hashes_pos], sizeof (hash_t));
12308 }
12309
12310 hashes_cnt++;
12311 }
12312
12313 /**
12314 * Potfile removes
12315 */
12316
12317 uint potfile_remove_cracks = 0;
12318
12319 if (potfile_disable == 0)
12320 {
12321 hash_t hash_buf;
12322
12323 hash_buf.digest = mymalloc (dgst_size);
12324 hash_buf.salt = NULL;
12325 hash_buf.esalt = NULL;
12326 hash_buf.hash_info = NULL;
12327 hash_buf.cracked = 0;
12328
12329 if (isSalted)
12330 {
12331 hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
12332 }
12333
12334 if (esalt_size)
12335 {
12336 hash_buf.esalt = mymalloc (esalt_size);
12337 }
12338
12339 if (quiet == 0) log_info_nn ("Comparing hashes with potfile entries...");
12340
12341 // no solution for these special hash types (for instane because they use hashfile in output etc)
12342 if ((hash_mode != 5200) &&
12343 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
12344 (hash_mode != 9000))
12345 {
12346 FILE *fp = fopen (potfile, "rb");
12347
12348 if (fp != NULL)
12349 {
12350 while (!feof (fp))
12351 {
12352 char line_buf[BUFSIZ];
12353
12354 memset (line_buf, 0, BUFSIZ);
12355
12356 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
12357
12358 if (ptr == NULL) break;
12359
12360 int line_len = strlen (line_buf);
12361
12362 if (line_len == 0) continue;
12363
12364 int iter = MAX_CUT_TRIES;
12365
12366 for (int i = line_len - 1; i && iter; i--, line_len--)
12367 {
12368 if (line_buf[i] != ':') continue;
12369
12370 if (isSalted)
12371 {
12372 memset (hash_buf.salt, 0, sizeof (salt_t));
12373 }
12374
12375 hash_t *found = NULL;
12376
12377 if (hash_mode == 6800)
12378 {
12379 if (i < 48) // 48 = 12 * uint in salt_buf[]
12380 {
12381 // manipulate salt_buf
12382 memcpy (hash_buf.salt->salt_buf, line_buf, i);
12383
12384 hash_buf.salt->salt_len = i;
12385
12386 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt);
12387 }
12388 }
12389 else if (hash_mode == 2500)
12390 {
12391 if (i < 48) // 48 = 12 * uint in salt_buf[]
12392 {
12393 // here we have in line_buf: ESSID:MAC1:MAC2 (without the plain)
12394 // manipulate salt_buf
12395
12396 // to be safe work with a copy (because of line_len loop, i etc)
12397
12398 char line_buf_cpy[BUFSIZ];
12399 memset (line_buf_cpy, 0, BUFSIZ);
12400
12401 memset (line_buf_cpy, 0, sizeof (line_buf_cpy));
12402
12403 memcpy (line_buf_cpy, line_buf, i);
12404
12405 char *mac2_pos = strrchr (line_buf_cpy, ':');
12406
12407 if (mac2_pos == NULL) continue;
12408
12409 mac2_pos[0] = 0;
12410 mac2_pos++;
12411
12412 if (strlen (mac2_pos) != 12) continue;
12413
12414 char *mac1_pos = strrchr (line_buf_cpy, ':');
12415
12416 if (mac1_pos == NULL) continue;
12417
12418 mac1_pos[0] = 0;
12419 mac1_pos++;
12420
12421 if (strlen (mac1_pos) != 12) continue;
12422
12423 uint essid_length = mac1_pos - line_buf_cpy - 1;
12424
12425 // here we need the ESSID
12426 memcpy (hash_buf.salt->salt_buf, line_buf_cpy, essid_length);
12427
12428 hash_buf.salt->salt_len = essid_length;
12429
12430 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt_hccap);
12431
12432 if (found)
12433 {
12434 wpa_t *wpa = (wpa_t *) found->esalt;
12435
12436 uint pke[25];
12437
12438 char *pke_ptr = (char *) pke;
12439
12440 for (uint i = 0; i < 25; i++)
12441 {
12442 pke[i] = byte_swap_32 (wpa->pke[i]);
12443 }
12444
12445 unsigned char mac1[6];
12446 unsigned char mac2[6];
12447
12448 memcpy (mac1, pke_ptr + 23, 6);
12449 memcpy (mac2, pke_ptr + 29, 6);
12450
12451 // compare hex string(s) vs binary MAC address(es)
12452
12453 for (uint i = 0, j = 0; i < 6; i++, j += 2)
12454 {
12455 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
12456 {
12457 found = NULL;
12458 break;
12459 }
12460 }
12461
12462 // early skip ;)
12463 if (!found) continue;
12464
12465 for (uint i = 0, j = 0; i < 6; i++, j += 2)
12466 {
12467 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
12468 {
12469 found = NULL;
12470 break;
12471 }
12472 }
12473 }
12474 }
12475 }
12476 else
12477 {
12478 int parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
12479
12480 if (parser_status == PARSER_OK)
12481 {
12482 if (isSalted)
12483 {
12484 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
12485 }
12486 else
12487 {
12488 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
12489 }
12490 }
12491 }
12492
12493 if (found == NULL) continue;
12494
12495 if (!found->cracked) potfile_remove_cracks++;
12496
12497 found->cracked = 1;
12498
12499 if (found) break;
12500
12501 iter--;
12502 }
12503 }
12504
12505 fclose (fp);
12506 }
12507 }
12508
12509 if (esalt_size)
12510 {
12511 local_free (hash_buf.esalt);
12512 }
12513
12514 if (isSalted)
12515 {
12516 local_free (hash_buf.salt);
12517 }
12518
12519 local_free (hash_buf.digest);
12520 }
12521
12522 /**
12523 * Now generate all the buffers required for later
12524 */
12525
12526 void *digests_buf_new = (void *) mycalloc (hashes_avail, dgst_size);
12527
12528 salt_t *salts_buf_new = NULL;
12529 void *esalts_buf_new = NULL;
12530
12531 if (isSalted)
12532 {
12533 salts_buf_new = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
12534
12535 if (esalt_size)
12536 {
12537 esalts_buf_new = (void *) mycalloc (hashes_avail, esalt_size);
12538 }
12539 }
12540 else
12541 {
12542 salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t));
12543 }
12544
12545 if (data.quiet == 0) log_info_nn ("Structuring salts for cracking task...");
12546
12547 uint digests_cnt = hashes_cnt;
12548 uint digests_done = 0;
12549
12550 uint size_digests = digests_cnt * dgst_size;
12551 uint size_shown = digests_cnt * sizeof (uint);
12552
12553 uint *digests_shown = (uint *) mymalloc (size_shown);
12554 uint *digests_shown_tmp = (uint *) mymalloc (size_shown);
12555
12556 uint salts_cnt = 0;
12557 uint salts_done = 0;
12558
12559 hashinfo_t **hash_info = NULL;
12560
12561 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12562 {
12563 hash_info = (hashinfo_t**) mymalloc (hashes_cnt * sizeof (hashinfo_t *));
12564
12565 if (username && (remove || show))
12566 {
12567 uint user_pos;
12568
12569 for (user_pos = 0; user_pos < hashes_cnt; user_pos++)
12570 {
12571 hash_info[user_pos] = (hashinfo_t*) mycalloc (hashes_cnt, sizeof (hashinfo_t));
12572
12573 hash_info[user_pos]->user = (user_t*) mymalloc (sizeof (user_t));
12574 }
12575 }
12576 }
12577
12578 uint *salts_shown = (uint *) mymalloc (size_shown);
12579
12580 salt_t *salt_buf;
12581
12582 {
12583 // copied from inner loop
12584
12585 salt_buf = &salts_buf_new[salts_cnt];
12586
12587 memcpy (salt_buf, hashes_buf[0].salt, sizeof (salt_t));
12588
12589 if (esalt_size)
12590 {
12591 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[0].esalt, esalt_size);
12592 }
12593
12594 salt_buf->digests_cnt = 0;
12595 salt_buf->digests_done = 0;
12596 salt_buf->digests_offset = 0;
12597
12598 salts_cnt++;
12599 }
12600
12601 if (hashes_buf[0].cracked == 1)
12602 {
12603 digests_shown[0] = 1;
12604
12605 digests_done++;
12606
12607 salt_buf->digests_done++;
12608 }
12609
12610 salt_buf->digests_cnt++;
12611
12612 memcpy (((char *) digests_buf_new) + (0 * dgst_size), hashes_buf[0].digest, dgst_size);
12613
12614 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12615 {
12616 hash_info[0] = hashes_buf[0].hash_info;
12617 }
12618
12619 // copy from inner loop
12620
12621 for (uint hashes_pos = 1; hashes_pos < hashes_cnt; hashes_pos++)
12622 {
12623 if (isSalted)
12624 {
12625 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) != 0)
12626 {
12627 salt_buf = &salts_buf_new[salts_cnt];
12628
12629 memcpy (salt_buf, hashes_buf[hashes_pos].salt, sizeof (salt_t));
12630
12631 if (esalt_size)
12632 {
12633 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[hashes_pos].esalt, esalt_size);
12634 }
12635
12636 salt_buf->digests_cnt = 0;
12637 salt_buf->digests_done = 0;
12638 salt_buf->digests_offset = hashes_pos;
12639
12640 salts_cnt++;
12641 }
12642 }
12643
12644 if (hashes_buf[hashes_pos].cracked == 1)
12645 {
12646 digests_shown[hashes_pos] = 1;
12647
12648 digests_done++;
12649
12650 salt_buf->digests_done++;
12651 }
12652
12653 salt_buf->digests_cnt++;
12654
12655 memcpy (((char *) digests_buf_new) + (hashes_pos * dgst_size), hashes_buf[hashes_pos].digest, dgst_size);
12656
12657 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12658 {
12659 hash_info[hashes_pos] = hashes_buf[hashes_pos].hash_info;
12660 }
12661 }
12662
12663 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
12664 {
12665 salt_t *salt_buf = &salts_buf_new[salt_pos];
12666
12667 if (salt_buf->digests_done == salt_buf->digests_cnt)
12668 {
12669 salts_shown[salt_pos] = 1;
12670
12671 salts_done++;
12672 }
12673
12674 if (salts_done == salts_cnt) data.devices_status = STATUS_CRACKED;
12675 }
12676
12677 local_free (digests_buf);
12678 local_free (salts_buf);
12679 local_free (esalts_buf);
12680
12681 digests_buf = digests_buf_new;
12682 salts_buf = salts_buf_new;
12683 esalts_buf = esalts_buf_new;
12684
12685 local_free (hashes_buf);
12686
12687 /**
12688 * special modification not set from parser
12689 */
12690
12691 switch (hash_mode)
12692 {
12693 case 6211: salts_buf->truecrypt_mdlen = 1 * 512; break;
12694 case 6212: salts_buf->truecrypt_mdlen = 2 * 512; break;
12695 case 6213: salts_buf->truecrypt_mdlen = 3 * 512; break;
12696 case 6221: salts_buf->truecrypt_mdlen = 1 * 512; break;
12697 case 6222: salts_buf->truecrypt_mdlen = 2 * 512; break;
12698 case 6223: salts_buf->truecrypt_mdlen = 3 * 512; break;
12699 case 6231: salts_buf->truecrypt_mdlen = 1 * 512; break;
12700 case 6232: salts_buf->truecrypt_mdlen = 2 * 512; break;
12701 case 6233: salts_buf->truecrypt_mdlen = 3 * 512; break;
12702 case 6241: salts_buf->truecrypt_mdlen = 1 * 512; break;
12703 case 6242: salts_buf->truecrypt_mdlen = 2 * 512; break;
12704 case 6243: salts_buf->truecrypt_mdlen = 3 * 512; break;
12705 }
12706
12707 if (truecrypt_keyfiles)
12708 {
12709 uint *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf;
12710
12711 char *keyfiles = strdup (truecrypt_keyfiles);
12712
12713 char *keyfile = strtok (keyfiles, ",");
12714
12715 do
12716 {
12717 truecrypt_crc32 (keyfile, (unsigned char *) keyfile_buf);
12718
12719 } while ((keyfile = strtok (NULL, ",")) != NULL);
12720
12721 free (keyfiles);
12722 }
12723
12724 data.digests_cnt = digests_cnt;
12725 data.digests_done = digests_done;
12726 data.digests_buf = digests_buf;
12727 data.digests_shown = digests_shown;
12728 data.digests_shown_tmp = digests_shown_tmp;
12729
12730 data.salts_cnt = salts_cnt;
12731 data.salts_done = salts_done;
12732 data.salts_buf = salts_buf;
12733 data.salts_shown = salts_shown;
12734
12735 data.esalts_buf = esalts_buf;
12736 data.hash_info = hash_info;
12737
12738 /**
12739 * Automatic Optimizers
12740 */
12741
12742 if (salts_cnt == 1)
12743 opti_type |= OPTI_TYPE_SINGLE_SALT;
12744
12745 if (digests_cnt == 1)
12746 opti_type |= OPTI_TYPE_SINGLE_HASH;
12747
12748 if (attack_exec == ATTACK_EXEC_ON_GPU)
12749 opti_type |= OPTI_TYPE_NOT_ITERATED;
12750
12751 if (attack_mode == ATTACK_MODE_BF)
12752 opti_type |= OPTI_TYPE_BRUTE_FORCE;
12753
12754 data.opti_type = opti_type;
12755
12756 if (opti_type & OPTI_TYPE_BRUTE_FORCE)
12757 {
12758 if (opti_type & OPTI_TYPE_SINGLE_HASH)
12759 {
12760 if (opti_type & OPTI_TYPE_APPENDED_SALT)
12761 {
12762 if (opts_type & OPTS_TYPE_ST_ADD80)
12763 {
12764 opts_type &= ~OPTS_TYPE_ST_ADD80;
12765 opts_type |= OPTS_TYPE_PT_ADD80;
12766 }
12767
12768 if (opts_type & OPTS_TYPE_ST_ADDBITS14)
12769 {
12770 opts_type &= ~OPTS_TYPE_ST_ADDBITS14;
12771 opts_type |= OPTS_TYPE_PT_ADDBITS14;
12772 }
12773
12774 if (opts_type & OPTS_TYPE_ST_ADDBITS15)
12775 {
12776 opts_type &= ~OPTS_TYPE_ST_ADDBITS15;
12777 opts_type |= OPTS_TYPE_PT_ADDBITS15;
12778 }
12779 }
12780 }
12781 }
12782
12783 /**
12784 * generate bitmap tables
12785 */
12786
12787 const uint bitmap_shift1 = 5;
12788 const uint bitmap_shift2 = 13;
12789
12790 if (bitmap_max < bitmap_min) bitmap_max = bitmap_min;
12791
12792 uint *bitmap_s1_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12793 uint *bitmap_s1_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12794 uint *bitmap_s1_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12795 uint *bitmap_s1_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12796 uint *bitmap_s2_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12797 uint *bitmap_s2_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12798 uint *bitmap_s2_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12799 uint *bitmap_s2_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12800
12801 uint bitmap_bits;
12802 uint bitmap_nums;
12803 uint bitmap_mask;
12804 uint bitmap_size;
12805
12806 for (bitmap_bits = bitmap_min; bitmap_bits < bitmap_max; bitmap_bits++)
12807 {
12808 if (data.quiet == 0) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits);
12809
12810 bitmap_nums = 1 << bitmap_bits;
12811
12812 bitmap_mask = bitmap_nums - 1;
12813
12814 bitmap_size = bitmap_nums * sizeof (uint);
12815
12816 if ((hashes_cnt & bitmap_mask) == hashes_cnt) break;
12817
12818 if (generate_bitmaps (digests_cnt, dgst_size, bitmap_shift1, (char *) data.digests_buf, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, digests_cnt / 2) == 0x7fffffff) continue;
12819 if (generate_bitmaps (digests_cnt, dgst_size, bitmap_shift2, (char *) data.digests_buf, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, digests_cnt / 2) == 0x7fffffff) continue;
12820
12821 break;
12822 }
12823
12824 bitmap_nums = 1 << bitmap_bits;
12825
12826 bitmap_mask = bitmap_nums - 1;
12827
12828 bitmap_size = bitmap_nums * sizeof (uint);
12829
12830 generate_bitmaps (digests_cnt, dgst_size, bitmap_shift1, (char *) data.digests_buf, bitmap_mask, bitmap_size, bitmap_s1_a, bitmap_s1_b, bitmap_s1_c, bitmap_s1_d, -1);
12831 generate_bitmaps (digests_cnt, dgst_size, bitmap_shift2, (char *) data.digests_buf, bitmap_mask, bitmap_size, bitmap_s2_a, bitmap_s2_b, bitmap_s2_c, bitmap_s2_d, -1);
12832
12833 /**
12834 * prepare quick rule
12835 */
12836
12837 data.rule_buf_l = rule_buf_l;
12838 data.rule_buf_r = rule_buf_r;
12839
12840 int rule_len_l = (int) strlen (rule_buf_l);
12841 int rule_len_r = (int) strlen (rule_buf_r);
12842
12843 data.rule_len_l = rule_len_l;
12844 data.rule_len_r = rule_len_r;
12845
12846 /**
12847 * load rules
12848 */
12849
12850 uint *all_gpu_rules_cnt = NULL;
12851
12852 gpu_rule_t **all_gpu_rules_buf = NULL;
12853
12854 if (rp_files_cnt)
12855 {
12856 all_gpu_rules_cnt = (uint *) mycalloc (rp_files_cnt, sizeof (uint));
12857
12858 all_gpu_rules_buf = (gpu_rule_t **) mycalloc (rp_files_cnt, sizeof (gpu_rule_t *));
12859 }
12860
12861 char rule_buf[BUFSIZ];
12862
12863 int rule_len = 0;
12864
12865 for (uint i = 0; i < rp_files_cnt; i++)
12866 {
12867 uint gpu_rules_avail = 0;
12868
12869 uint gpu_rules_cnt = 0;
12870
12871 gpu_rule_t *gpu_rules_buf = NULL;
12872
12873 char *rp_file = rp_files[i];
12874
12875 char in[BLOCK_SIZE];
12876 char out[BLOCK_SIZE];
12877
12878 FILE *fp = NULL;
12879
12880 uint rule_line = 0;
12881
12882 if ((fp = fopen (rp_file, "rb")) == NULL)
12883 {
12884 log_error ("ERROR: %s: %s", rp_file, strerror (errno));
12885
12886 return (-1);
12887 }
12888
12889 while (!feof (fp))
12890 {
12891 memset (rule_buf, 0, BUFSIZ);
12892
12893 rule_len = fgetl (fp, rule_buf);
12894
12895 rule_line++;
12896
12897 if (rule_len == 0) continue;
12898
12899 if (rule_buf[0] == '#') continue;
12900
12901 if (gpu_rules_avail == gpu_rules_cnt)
12902 {
12903 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12904
12905 gpu_rules_avail += INCR_RULES;
12906 }
12907
12908 memset (in, 0, BLOCK_SIZE);
12909 memset (out, 0, BLOCK_SIZE);
12910
12911 int result = _old_apply_rule (rule_buf, rule_len, in, 1, out);
12912
12913 if (result == -1)
12914 {
12915 log_info ("WARNING: Skipping invalid or unsupported rule in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12916
12917 continue;
12918 }
12919
12920 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1)
12921 {
12922 log_info ("WARNING: Cannot convert rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12923
12924 memset (&gpu_rules_buf[gpu_rules_cnt], 0, sizeof (gpu_rule_t)); // needs to be cleared otherwise we could have some remaining data
12925
12926 continue;
12927 }
12928
12929 /* its so slow
12930 if (rulefind (&gpu_rules_buf[gpu_rules_cnt], gpu_rules_buf, gpu_rules_cnt, sizeof (gpu_rule_t), sort_by_gpu_rule))
12931 {
12932 log_info ("Duplicate rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12933
12934 continue;
12935 }
12936 */
12937
12938 gpu_rules_cnt++;
12939 }
12940
12941 fclose (fp);
12942
12943 all_gpu_rules_cnt[i] = gpu_rules_cnt;
12944
12945 all_gpu_rules_buf[i] = gpu_rules_buf;
12946 }
12947
12948 /**
12949 * merge rules or automatic rule generator
12950 */
12951
12952 uint gpu_rules_cnt = 0;
12953
12954 gpu_rule_t *gpu_rules_buf = NULL;
12955
12956 if (attack_mode == ATTACK_MODE_STRAIGHT)
12957 {
12958 if (rp_files_cnt)
12959 {
12960 gpu_rules_cnt = 1;
12961
12962 uint *repeats = (uint *) mycalloc (rp_files_cnt + 1, sizeof (uint));
12963
12964 repeats[0] = gpu_rules_cnt;
12965
12966 for (uint i = 0; i < rp_files_cnt; i++)
12967 {
12968 gpu_rules_cnt *= all_gpu_rules_cnt[i];
12969
12970 repeats[i + 1] = gpu_rules_cnt;
12971 }
12972
12973 gpu_rules_buf = (gpu_rule_t *) mycalloc (gpu_rules_cnt, sizeof (gpu_rule_t));
12974
12975 memset (gpu_rules_buf, 0, gpu_rules_cnt * sizeof (gpu_rule_t));
12976
12977 for (uint i = 0; i < gpu_rules_cnt; i++)
12978 {
12979 uint out_pos = 0;
12980
12981 gpu_rule_t *out = &gpu_rules_buf[i];
12982
12983 for (uint j = 0; j < rp_files_cnt; j++)
12984 {
12985 uint in_off = (i / repeats[j]) % all_gpu_rules_cnt[j];
12986 uint in_pos;
12987
12988 gpu_rule_t *in = &all_gpu_rules_buf[j][in_off];
12989
12990 for (in_pos = 0; in->cmds[in_pos]; in_pos++, out_pos++)
12991 {
12992 if (out_pos == RULES_MAX - 1)
12993 {
12994 // log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
12995
12996 break;
12997 }
12998
12999 out->cmds[out_pos] = in->cmds[in_pos];
13000 }
13001 }
13002 }
13003
13004 local_free (repeats);
13005 }
13006 else if (rp_gen)
13007 {
13008 uint gpu_rules_avail = 0;
13009
13010 while (gpu_rules_cnt < rp_gen)
13011 {
13012 if (gpu_rules_avail == gpu_rules_cnt)
13013 {
13014 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
13015
13016 gpu_rules_avail += INCR_RULES;
13017 }
13018
13019 memset (rule_buf, 0, BLOCK_SIZE);
13020
13021 rule_len = (int) generate_random_rule (rule_buf, rp_gen_func_min, rp_gen_func_max);
13022
13023 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1) continue;
13024
13025 gpu_rules_cnt++;
13026 }
13027 }
13028 }
13029
13030 /**
13031 * generate NOP rules
13032 */
13033
13034 if (gpu_rules_cnt == 0)
13035 {
13036 gpu_rules_buf = (gpu_rule_t *) mymalloc (sizeof (gpu_rule_t));
13037
13038 gpu_rules_buf[gpu_rules_cnt].cmds[0] = RULE_OP_MANGLE_NOOP;
13039
13040 gpu_rules_cnt++;
13041 }
13042
13043 data.gpu_rules_cnt = gpu_rules_cnt;
13044 data.gpu_rules_buf = gpu_rules_buf;
13045
13046 /**
13047 * platform
13048 */
13049
13050 #ifdef _CUDA
13051 if (cuInit (0) != CUDA_SUCCESS)
13052 {
13053 log_error ("ERROR: No NVidia compatible platform found");
13054
13055 return (-1);
13056 }
13057 #endif
13058
13059 /**
13060 * devices get
13061 */
13062
13063 uint devices_all_cnt = 0;
13064
13065 #ifdef _CUDA
13066 CUdevice devices_all[DEVICES_MAX];
13067 CUdevice devices[DEVICES_MAX];
13068
13069 hc_cuDeviceGetCount ((int *) &devices_all_cnt);
13070
13071 for (uint i = 0; i < devices_all_cnt; i++)
13072 {
13073 hc_cuDeviceGet (&devices_all[i], i);
13074 }
13075
13076 #elif _OCL
13077 cl_platform_id CL_platform = NULL;
13078
13079 cl_platform_id CL_platforms[CL_PLATFORMS_MAX];
13080
13081 uint CL_platforms_cnt = 0;
13082
13083 hc_clGetPlatformIDs (CL_PLATFORMS_MAX, CL_platforms, &CL_platforms_cnt);
13084
13085 for (uint i = 0; i < CL_platforms_cnt; i++)
13086 {
13087 char CL_platform_vendor[INFOSZ];
13088
13089 memset (CL_platform_vendor, 0, sizeof (CL_platform_vendor));
13090
13091 hc_clGetPlatformInfo (CL_platforms[i], CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
13092
13093 if ((strcmp (CL_platform_vendor, CL_VENDOR_AMD) != 0)
13094 && (strcmp (CL_platform_vendor, CL_VENDOR_SDS) != 0)
13095 && (strcmp (CL_platform_vendor, CL_VENDOR_APPLE) != 0)) continue;
13096
13097 if (strcmp (CL_platform_vendor, CL_VENDOR_SDS) == 0) gpu_temp_disable = 1;
13098
13099 CL_platform = CL_platforms[i];
13100 }
13101
13102 if (CL_platform == NULL)
13103 {
13104 log_error ("ERROR: No AMD/SDS compatible platform found");
13105
13106 return (-1);
13107 }
13108
13109 cl_device_id devices_all[DEVICES_MAX];
13110 cl_device_id devices[DEVICES_MAX];
13111
13112 hc_clGetDeviceIDs (CL_platform, CL_DEVICE_TYPE_GPU, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
13113
13114 #endif
13115
13116 int hm_adapters_all = devices_all_cnt;
13117
13118 hm_attrs_t hm_adapter_all[DEVICES_MAX];
13119
13120 memset (hm_adapter_all, 0, sizeof (hm_adapter_all));
13121
13122 if (gpu_temp_disable == 0)
13123 {
13124 #ifdef _CUDA
13125 #ifdef LINUX
13126 if (hc_NVML_nvmlInit () == NVML_SUCCESS)
13127 {
13128 HM_ADAPTER nvGPUHandle[DEVICES_MAX];
13129
13130 int tmp_in = hm_get_adapter_index (nvGPUHandle);
13131
13132 int tmp_out = 0;
13133
13134 for (int i = 0; i < tmp_in; i++)
13135 {
13136 hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i];
13137 }
13138
13139 hm_adapters_all = tmp_out;
13140
13141 for (int i = 0; i < tmp_out; i++)
13142 {
13143 unsigned int speed;
13144
13145 if (nvmlDeviceGetFanSpeed (hm_adapter_all[i].adapter_index, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
13146 }
13147 }
13148 #endif
13149
13150 #ifdef WIN
13151 if (NvAPI_Initialize () == NVAPI_OK)
13152 {
13153 HM_ADAPTER nvGPUHandle[DEVICES_MAX];
13154
13155 int tmp_in = hm_get_adapter_index (nvGPUHandle);
13156
13157 int tmp_out = 0;
13158
13159 for (int i = 0; i < tmp_in; i++)
13160 {
13161 hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i];
13162 }
13163
13164 hm_adapters_all = tmp_out;
13165
13166 for (int i = 0; i < tmp_out; i++)
13167 {
13168 NvU32 speed;
13169
13170 if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
13171 }
13172 }
13173 #endif
13174 #endif
13175
13176 #ifdef _OCL
13177 #ifndef OSX
13178 HM_LIB hm_dll = hm_init ();
13179
13180 data.hm_dll = hm_dll;
13181
13182 if (hc_ADL_Main_Control_Create (hm_dll, ADL_Main_Memory_Alloc, 0) == ADL_OK)
13183 {
13184 // total number of adapters
13185
13186 int hm_adapters_num;
13187
13188 if (get_adapters_num (hm_dll, &hm_adapters_num) != 0) return (-1);
13189
13190 // adapter info
13191
13192 LPAdapterInfo lpAdapterInfo = hm_get_adapter_info (hm_dll, hm_adapters_num);
13193
13194 if (lpAdapterInfo == NULL) return (-1);
13195
13196 // get a list (of ids of) valid/usable adapters
13197
13198 int num_adl_adapters = 0;
13199
13200 uint32_t *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo);
13201
13202 if (num_adl_adapters > 0)
13203 {
13204 hc_thread_mutex_lock (mux_adl);
13205
13206 // hm_get_opencl_busid_devid (hm_adapter_all, devices_all_cnt, devices_all);
13207
13208 hm_get_adapter_index (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13209
13210 hm_get_overdrive_version (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13211 hm_check_fanspeed_control (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13212
13213 hc_thread_mutex_unlock (mux_adl);
13214 }
13215
13216 hm_adapters_all = num_adl_adapters;
13217
13218 myfree (valid_adl_device_list);
13219 myfree (lpAdapterInfo);
13220 }
13221 #endif
13222 #endif
13223 }
13224
13225 if (hm_adapters_all == 0)
13226 {
13227 gpu_temp_disable = 1;
13228 }
13229
13230 if (gpu_temp_disable == 1)
13231 {
13232 gpu_temp_abort = 0;
13233 gpu_temp_retain = 0;
13234 }
13235
13236 /**
13237 * enable custom signal handler(s)
13238 */
13239
13240 if (benchmark == 0)
13241 {
13242 hc_signal (sigHandler_default);
13243 }
13244 else
13245 {
13246 hc_signal (sigHandler_benchmark);
13247 }
13248
13249 /**
13250 * devices mask and properties
13251 */
13252
13253 uint devices_cnt = 0;
13254
13255 for (uint device_all_id = 0; device_all_id < devices_all_cnt; device_all_id++)
13256 {
13257 if (gpu_devicemask)
13258 {
13259 uint device_all_id_mask = 1 << device_all_id;
13260
13261 if ((device_all_id_mask & gpu_devicemask) != device_all_id_mask)
13262 {
13263 if (quiet == 0 && algorithm_pos == 0) log_info ("Device #%d: skipped by user", device_all_id_mask + 1);
13264
13265 continue;
13266 }
13267 }
13268
13269 const uint device_id = devices_cnt;
13270
13271 devices[device_id] = devices_all[device_all_id];
13272
13273 memcpy (&data.hm_device[device_id], &hm_adapter_all[device_all_id], sizeof (hm_attrs_t));
13274
13275 char device_name[INFOSZ];
13276
13277 memset (device_name, 0, sizeof (device_name));
13278
13279 #ifdef _CUDA
13280 size_t global_mem_size;
13281 int max_clock_frequency;
13282 int max_compute_units;
13283 int kernel_exec_timeout;
13284
13285 hc_cuDeviceGetName (device_name, sizeof (device_name), devices[device_id]);
13286 hc_cuDeviceTotalMem (&global_mem_size, devices[device_id]);
13287 hc_cuDeviceGetAttribute (&max_clock_frequency, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, devices[device_id]); max_clock_frequency /= 1000;
13288 hc_cuDeviceGetAttribute (&max_compute_units, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, devices[device_id]);
13289 hc_cuDeviceGetAttribute (&kernel_exec_timeout, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, devices[device_id]);
13290
13291 #elif _OCL
13292 cl_ulong global_mem_size;
13293 cl_uint max_clock_frequency;
13294 cl_uint max_compute_units;
13295
13296 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_NAME, sizeof (device_name), &device_name, NULL);
13297 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (global_mem_size), &global_mem_size, NULL);
13298 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (max_clock_frequency), &max_clock_frequency, NULL);
13299 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
13300
13301 #endif
13302
13303 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
13304 {
13305 log_info ("Device #%u: %s, %luMB, %dMhz, %uMCU",
13306 device_all_id + 1,
13307 device_name,
13308 (unsigned int) (global_mem_size / 1024 / 1024),
13309 (unsigned int) (max_clock_frequency),
13310 (unsigned int) max_compute_units);
13311 }
13312
13313 #ifdef _CUDA
13314 if (quiet == 0 && kernel_exec_timeout != 0 && algorithm_pos == 0)
13315 {
13316 log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1);
13317 #if _WIN
13318 log_info (" You can disable it with a regpatch, see here: http://hashcat.net/wiki/doku.php?id=timeout_patch");
13319 #endif
13320 }
13321 #endif
13322
13323 devices_cnt++;
13324 }
13325
13326 if (devices_cnt == 0)
13327 {
13328 log_error ("ERROR: No devices left that matches your specification.");
13329
13330 return (-1);
13331 }
13332
13333 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
13334 {
13335 log_info ("");
13336 }
13337
13338 /**
13339 * inform the user
13340 */
13341
13342 // gpu temp sanity check
13343
13344 if ((gpu_temp_abort != 0) && (gpu_temp_retain != 0))
13345 {
13346 if (gpu_temp_abort < gpu_temp_retain)
13347 {
13348 log_error ("ERROR: invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain.");
13349
13350 return (-1);
13351 }
13352 }
13353
13354 if (data.quiet == 0)
13355 {
13356 log_info ("Hashes: %u hashes; %u unique digests, %u unique salts", hashes_cnt_orig, digests_cnt, salts_cnt);
13357
13358 log_info ("Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_bits, bitmap_nums, bitmap_mask, bitmap_size, bitmap_shift1, bitmap_shift2);
13359
13360 if (attack_mode == ATTACK_MODE_STRAIGHT)
13361 {
13362 log_info ("Rules: %u", gpu_rules_cnt);
13363 }
13364
13365 if (opti_type)
13366 {
13367 log_info ("Applicable Optimizers:");
13368
13369 for (uint i = 0; i < 32; i++)
13370 {
13371 const uint opti_bit = 1 << i;
13372
13373 if (opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit));
13374 }
13375 }
13376
13377 /**
13378 * Watchdog and Temperature balance
13379 */
13380
13381 if (gpu_temp_abort == 0)
13382 {
13383 log_info ("Watchdog: Temperature abort trigger disabled");
13384 }
13385 else
13386 {
13387 log_info ("Watchdog: Temperature abort trigger set to %uc", gpu_temp_abort);
13388 }
13389
13390 if (gpu_temp_retain == 0)
13391 {
13392 log_info ("Watchdog: Temperature retain trigger disabled");
13393 }
13394 else
13395 {
13396 log_info ("Watchdog: Temperature retain trigger set to %uc", gpu_temp_retain);
13397 }
13398 }
13399
13400 /**
13401 * store all the preparation, not hash_mode dependant
13402 */
13403
13404 data.gpu_temp_disable = gpu_temp_disable;
13405 data.gpu_temp_abort = gpu_temp_abort;
13406 data.gpu_temp_retain = gpu_temp_retain;
13407
13408 data.devices_cnt = devices_cnt;
13409
13410 #ifdef _OCL
13411 /**
13412 * catalyst driver check
13413 */
13414
13415 int catalyst_check = (force == 1) ? 0 : 1;
13416
13417 int catalyst_warn = 0;
13418
13419 int catalyst_broken = 0;
13420 #endif
13421
13422 /**
13423 * devices init
13424 */
13425
13426 #ifdef _OCL
13427 #ifndef OSX
13428 int gpu_temp_retain_set = 0;
13429
13430 int *temp_retain_fanspeed_value = (int *) mycalloc (devices_cnt, sizeof (int));
13431
13432 ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (devices_cnt, sizeof (ADLOD6MemClockState));
13433
13434 int *od_power_control_status = (int *) mycalloc (devices_cnt, sizeof (int));
13435 #endif
13436 #endif
13437
13438 hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (devices_cnt, sizeof (hc_device_param_t));
13439
13440 data.devices_param = devices_param;
13441
13442 for (uint device_id = 0; device_id < devices_cnt; device_id++)
13443 {
13444 hc_device_param_t *device_param = &data.devices_param[device_id];
13445
13446 #ifdef _CUDA
13447 CUdevice device = devices[device_id];
13448
13449 device_param->device = device;
13450
13451 size_t bytes;
13452
13453 hc_cuDeviceTotalMem (&bytes, device);
13454
13455 device_param->gpu_maxmem_alloc = bytes;
13456
13457 int sm_major = 0;
13458 int sm_minor = 0;
13459 int max_compute_units = 0;
13460
13461 hc_cuDeviceComputeCapability (&sm_major, &sm_minor, device);
13462
13463 if (sm_major == 1)
13464 {
13465 log_error ("ERROR: Shader Model 1.0 - 1.3 based GPU detected. Support for CUDA was dropped by NVidia.");
13466 log_error (" Remove it from your system or use -d and select only supported cards.");
13467
13468 return (-1);
13469 }
13470
13471 device_param->sm_major = sm_major;
13472 device_param->sm_minor = sm_minor;
13473
13474 hc_cuDeviceGetAttribute (&max_compute_units, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, device);
13475
13476 if (sm_major >= 5)
13477 {
13478 // those maxwell and newer are so good compared to older chipsets we need to equalize
13479 // their power to older chipsets, otherwise workload distribution which is based on the compute_units
13480 // gets out of control
13481
13482 max_compute_units *= 3;
13483 }
13484
13485 device_param->gpu_processors = max_compute_units;
13486
13487 /**
13488 * calculate vector size
13489 */
13490
13491 uint vliw = get_vliw_by_compute_capability (sm_major, sm_minor);
13492
13493 device_param->gpu_vector_width = get_gpu_vector_width (hash_mode, attack_kern, attack_exec, opti_type, vliw);
13494
13495 #elif _OCL
13496 cl_device_id device = devices[device_id];
13497
13498 device_param->device = device;
13499
13500 cl_uint max_compute_units = 0;
13501
13502 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
13503
13504 device_param->gpu_processors = max_compute_units;
13505
13506 cl_ulong max_mem_alloc_size = 0;
13507
13508 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL);
13509
13510 device_param->gpu_maxmem_alloc = max_mem_alloc_size;
13511
13512 char tmp[INFOSZ], t1[64];
13513
13514 memset (tmp, 0, sizeof (tmp));
13515
13516 hc_clGetDeviceInfo (device, CL_DEVICE_NAME, sizeof (tmp), &tmp, NULL);
13517
13518 device_param->device_name = mystrdup (tmp);
13519
13520 memset (tmp, 0, sizeof (tmp));
13521
13522 hc_clGetDeviceInfo (device, CL_DEVICE_VERSION, sizeof (tmp), &tmp, NULL);
13523
13524 memset (t1, 0, sizeof (t1));
13525
13526 sscanf (tmp, "%*16s %*16s %*16s (%[^)]16s)", t1);
13527
13528 device_param->device_version = mystrdup (t1);
13529
13530 memset (tmp, 0, sizeof (tmp));
13531
13532 hc_clGetDeviceInfo (device, CL_DRIVER_VERSION, sizeof (tmp), &tmp, NULL);
13533
13534 device_param->driver_version = mystrdup (tmp);
13535
13536 /**
13537 * calculate vector size
13538 */
13539
13540 uint vliw = get_vliw_by_device_name (device_param->device_name);
13541
13542 device_param->gpu_vector_width = get_gpu_vector_width (hash_mode, attack_kern, attack_exec, opti_type, vliw);
13543
13544 /**
13545 * catalyst driver check
13546 */
13547
13548 if (catalyst_check == 1)
13549 {
13550 catalyst_warn = 1;
13551
13552 // v14.9 and higher
13553 if ((atoi (device_param->device_version) >= 1573)
13554 && (atoi (device_param->driver_version) >= 1573))
13555 {
13556 catalyst_warn = 0;
13557 }
13558
13559 /*
13560 // v14.9
13561 if ((strstr (device_param->device_version, "1573.") != NULL)
13562 && (strstr (device_param->driver_version, "1573.") != NULL))
13563 {
13564 catalyst_warn = 0;
13565 }
13566
13567 // v14.12 -- version overlaps with v15.4 beta
13568 if ((strstr (device_param->device_version, "1642.") != NULL)
13569 && (strstr (device_param->driver_version, "1642.") != NULL))
13570 {
13571 catalyst_broken = 1;
13572 }
13573
13574 // v15.4 (Beta, Windows only release)
13575 if ((strstr (device_param->device_version, "1642.") != NULL)
13576 && (strstr (device_param->driver_version, "1642.") != NULL))
13577 {
13578 catalyst_warn = 0;
13579 }
13580
13581 // v15.5 (Release, Linux)
13582 if ((strstr (device_param->device_version, "1702.") != NULL)
13583 && (strstr (device_param->driver_version, "1702.") != NULL))
13584 {
13585 catalyst_warn = 0;
13586 }
13587
13588 // v15.3 (Beta, Ubuntu repository release)
13589 if ((strstr (device_param->device_version, "1729.") != NULL)
13590 && (strstr (device_param->driver_version, "1729.") != NULL))
13591 {
13592 catalyst_warn = 0;
13593 }
13594 */
13595
13596 catalyst_check = 0;
13597 }
13598 #endif
13599 }
13600
13601 #ifdef _OCL
13602 if (catalyst_broken == 1)
13603 {
13604 log_error ("");
13605 log_error ("ATTENTION! The installed GPU driver in your system is known to be broken!");
13606 log_error ("It will pass over cracked hashes and does not report them as cracked");
13607 log_error ("You are STRONGLY encouraged not to use it");
13608 log_error ("You can use --force to override this but do not post error reports if you do so");
13609
13610 return (-1);
13611 }
13612
13613 if (catalyst_warn == 1)
13614 {
13615 log_error ("");
13616 log_error ("ATTENTION! Unsupported or incorrect installed GPU driver detected!");
13617 log_error ("You are STRONGLY encouraged to use the official supported GPU driver for good reasons");
13618 log_error ("See oclHashcat's homepage for official supported GPU drivers");
13619 #ifdef _WIN
13620 log_error ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
13621 #endif
13622 log_error ("You can use --force to override this but do not post error reports if you do so");
13623
13624 return (-1);
13625 }
13626 #endif
13627
13628 uint gpu_blocks_all = 0;
13629
13630 #ifdef _CUDA
13631 for (uint device_id = 0; device_id < devices_cnt; device_id++)
13632 {
13633 /**
13634 * host buffer
13635 */
13636
13637 hc_device_param_t *device_param = &data.devices_param[device_id];
13638
13639 /**
13640 * device properties
13641 */
13642
13643 int sm_minor = device_param->sm_minor;
13644 int sm_major = device_param->sm_major;
13645
13646 uint gpu_processors = device_param->gpu_processors;
13647 uint gpu_vector_width = device_param->gpu_vector_width;
13648
13649 /**
13650 * create context for each device
13651 */
13652
13653 uint flags = 0;
13654
13655 if (gpu_async == 0) flags |= CU_CTX_SCHED_BLOCKING_SYNC;
13656 else flags |= CU_CTX_SCHED_SPIN;
13657
13658 hc_cuCtxCreate (&device_param->context, flags, device_param->device);
13659
13660 // does bad things hc_cuCtxSetCacheConfig (CU_FUNC_CACHE_PREFER_L1);
13661
13662 /**
13663 * create input buffers on device
13664 */
13665
13666 uint gpu_threads = GPU_THREADS_NV;
13667
13668 if (hash_mode == 1500) gpu_threads = 64;
13669 if (hash_mode == 3000) gpu_threads = 64;
13670 if (hash_mode == 3200) gpu_threads = 8;
13671 if (hash_mode == 7500) gpu_threads = 64;
13672 if (hash_mode == 8900) gpu_threads = 64;
13673 if (hash_mode == 9000) gpu_threads = 8;
13674 if (hash_mode == 9300) gpu_threads = 64;
13675 if (hash_mode == 9700) gpu_threads = 64;
13676 if (hash_mode == 9710) gpu_threads = 64;
13677 if (hash_mode == 9800) gpu_threads = 64;
13678 if (hash_mode == 9810) gpu_threads = 64;
13679 if (hash_mode == 10400) gpu_threads = 64;
13680 if (hash_mode == 10410) gpu_threads = 64;
13681 if (hash_mode == 10500) gpu_threads = 64;
13682
13683 uint gpu_power = gpu_processors * gpu_threads * gpu_accel;
13684 uint gpu_blocks = gpu_power * gpu_vector_width;
13685
13686 device_param->gpu_threads = gpu_threads;
13687 device_param->gpu_power_user = gpu_power;
13688 device_param->gpu_blocks_user = gpu_blocks;
13689
13690 gpu_blocks_all += gpu_blocks;
13691
13692 uint size_pws = gpu_power * sizeof (pw_t);
13693
13694 uint size_tmps = 4;
13695
13696 switch (hash_mode)
13697 {
13698 case 400: size_tmps = gpu_blocks * sizeof (phpass_tmp_t); break;
13699 case 500: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13700 case 501: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13701 case 1600: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13702 case 1800: size_tmps = gpu_blocks * sizeof (sha512crypt_tmp_t); break;
13703 case 2100: size_tmps = gpu_blocks * sizeof (dcc2_tmp_t); break;
13704 case 2500: size_tmps = gpu_blocks * sizeof (wpa_tmp_t); break;
13705 case 3200: size_tmps = gpu_blocks * sizeof (bcrypt_tmp_t); break;
13706 case 5200: size_tmps = gpu_blocks * sizeof (pwsafe3_tmp_t); break;
13707 case 5800: size_tmps = gpu_blocks * sizeof (androidpin_tmp_t); break;
13708 case 6211:
13709 case 6212:
13710 case 6213: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13711 case 6221:
13712 case 6222:
13713 case 6223: size_tmps = gpu_blocks * sizeof (tc64_tmp_t); break;
13714 case 6231:
13715 case 6232:
13716 case 6233: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13717 case 6241:
13718 case 6242:
13719 case 6243: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13720 case 6300: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13721 case 6400: size_tmps = gpu_blocks * sizeof (sha256aix_tmp_t); break;
13722 case 6500: size_tmps = gpu_blocks * sizeof (sha512aix_tmp_t); break;
13723 case 6600: size_tmps = gpu_blocks * sizeof (agilekey_tmp_t); break;
13724 case 6700: size_tmps = gpu_blocks * sizeof (sha1aix_tmp_t); break;
13725 case 6800: size_tmps = gpu_blocks * sizeof (lastpass_tmp_t); break;
13726 case 7100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13727 case 7200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13728 case 7400: size_tmps = gpu_blocks * sizeof (sha256crypt_tmp_t); break;
13729 case 7900: size_tmps = gpu_blocks * sizeof (drupal7_tmp_t); break;
13730 case 8200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13731 case 8800: size_tmps = gpu_blocks * sizeof (androidfde_tmp_t); break;
13732 case 8900: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
13733 case 9000: size_tmps = gpu_blocks * sizeof (pwsafe2_tmp_t); break;
13734 case 9100: size_tmps = gpu_blocks * sizeof (lotus8_tmp_t); break;
13735 case 9200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13736 case 9300: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
13737 case 9400: size_tmps = gpu_blocks * sizeof (office2007_tmp_t); break;
13738 case 9500: size_tmps = gpu_blocks * sizeof (office2010_tmp_t); break;
13739 case 9600: size_tmps = gpu_blocks * sizeof (office2013_tmp_t); break;
13740 case 10000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13741 case 10200: size_tmps = gpu_blocks * sizeof (cram_md5_t); break;
13742 case 10300: size_tmps = gpu_blocks * sizeof (saph_sha1_tmp_t); break;
13743 case 10500: size_tmps = gpu_blocks * sizeof (pdf14_tmp_t); break;
13744 case 10700: size_tmps = gpu_blocks * sizeof (pdf17l8_tmp_t); break;
13745 case 10900: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13746 case 11300: size_tmps = gpu_blocks * sizeof (bitcoin_wallet_tmp_t); break;
13747 case 11600: size_tmps = gpu_blocks * sizeof (seven_zip_tmp_t); break;
13748 case 11900: size_tmps = gpu_blocks * sizeof (pbkdf2_md5_tmp_t); break;
13749 case 12000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha1_tmp_t); break;
13750 case 12100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13751 case 12200: size_tmps = gpu_blocks * sizeof (ecryptfs_tmp_t); break;
13752 case 12300: size_tmps = gpu_blocks * sizeof (oraclet_tmp_t); break;
13753 case 12400: size_tmps = gpu_blocks * sizeof (bsdicrypt_tmp_t); break;
13754 case 12500: size_tmps = gpu_blocks * sizeof (rar3_tmp_t); break;
13755 case 12700: size_tmps = gpu_blocks * sizeof (mywallet_tmp_t); break;
13756 case 12800: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13757 };
13758
13759 uint size_hooks = 4;
13760
13761 if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23))
13762 {
13763 // fill size_hook with correct size
13764 }
13765
13766 // we can optimize some stuff here...
13767
13768 device_param->size_pws = size_pws;
13769 device_param->size_tmps = size_tmps;
13770 device_param->size_hooks = size_hooks;
13771
13772 uint size_root_css = SP_PW_MAX * sizeof (cs_t);
13773 uint size_markov_css = SP_PW_MAX * CHARSIZ * sizeof (cs_t);
13774
13775 device_param->size_root_css = size_root_css;
13776 device_param->size_markov_css = size_markov_css;
13777
13778 uint size_results = GPU_THREADS_NV * sizeof (uint);
13779
13780 device_param->size_results = size_results;
13781
13782 uint size_rules = gpu_rules_cnt * sizeof (gpu_rule_t);
13783 uint size_plains = digests_cnt * sizeof (plain_t);
13784 uint size_salts = salts_cnt * sizeof (salt_t);
13785 uint size_esalts = salts_cnt * esalt_size;
13786
13787 device_param->size_plains = size_plains;
13788 device_param->size_digests = size_digests;
13789 device_param->size_shown = size_shown;
13790 device_param->size_salts = size_salts;
13791
13792 uint size_combs = GPU_COMBS * sizeof (comb_t);
13793 uint size_bfs = GPU_BFS * sizeof (bf_t);
13794 uint size_tm = 32 * sizeof (bs_word_t);
13795
13796 uint64_t size_scryptV = 1;
13797
13798 if ((hash_mode == 8900) || (hash_mode == 9300))
13799 {
13800 #define SHADER_PER_MP 32
13801 #define WARPS 32
13802
13803 uint tmto_start = 2;
13804 uint tmto_stop = 1024;
13805
13806 if (scrypt_tmto)
13807 {
13808 tmto_start = 1 << scrypt_tmto;
13809 tmto_stop = tmto_start + 1;
13810 }
13811
13812 for (uint tmto = tmto_start; tmto < tmto_stop; tmto <<= 1)
13813 {
13814 // todo -- make sure all salts get the new tmto value
13815
13816 size_scryptV = (128 * data.salts_buf[0].scrypt_r) * data.salts_buf[0].scrypt_N;
13817
13818 size_scryptV /= tmto;
13819
13820 size_scryptV *= gpu_processors * WARPS * SHADER_PER_MP;
13821
13822 if (size_scryptV > (device_param->gpu_maxmem_alloc / 2)) continue;
13823
13824 for (uint salts_pos = 0; salts_pos < data.salts_cnt; salts_pos++)
13825 {
13826 data.salts_buf[salts_pos].scrypt_tmto = tmto;
13827 data.salts_buf[salts_pos].scrypt_phy = gpu_processors * WARPS * SHADER_PER_MP;
13828 }
13829
13830 break;
13831 }
13832
13833 if (data.salts_buf[0].scrypt_tmto == 0)
13834 {
13835 log_error ("ERROR: can't allocate enough GPU memory");
13836
13837 return -1;
13838 }
13839
13840 if (quiet == 0) log_info ("");
13841 if (quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u\n", data.salts_buf[0].scrypt_tmto);
13842 }
13843
13844 /**
13845 * stream
13846 */
13847
13848 hc_cuStreamCreate (&device_param->stream, 0);
13849
13850 /**
13851 * module find
13852 */
13853
13854 char module_file[256];
13855
13856 memset (module_file, 0, sizeof (module_file));
13857
13858 #ifdef __x86_64__
13859 if (attack_exec == ATTACK_EXEC_ON_GPU)
13860 {
13861 if (attack_kern == ATTACK_KERN_STRAIGHT)
13862 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a0.sm_%d%d.64.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13863 else if (attack_kern == ATTACK_KERN_COMBI)
13864 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a1.sm_%d%d.64.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13865 else if (attack_kern == ATTACK_KERN_BF)
13866 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a3.sm_%d%d.64.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13867 }
13868 else
13869 {
13870 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d.sm_%d%d.64.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13871
13872 if ((hash_mode == 8900) || (hash_mode == 9300))
13873 {
13874 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_%d_%d_%d_%d.sm_%d%d.64.cubin", install_dir, (int) kern_type, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto, sm_major, sm_minor);
13875 }
13876 }
13877
13878 #else
13879 if (attack_exec == ATTACK_EXEC_ON_GPU)
13880 {
13881 if (attack_kern == ATTACK_KERN_STRAIGHT)
13882 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a0.sm_%d%d.32.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13883 else if (attack_kern == ATTACK_KERN_COMBI)
13884 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a1.sm_%d%d.32.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13885 else if (attack_kern == ATTACK_KERN_BF)
13886 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a3.sm_%d%d.32.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13887 }
13888 else
13889 {
13890 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d.sm_%d%d.32.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13891
13892 if ((hash_mode == 8900) || (hash_mode == 9300))
13893 {
13894 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_%d_%d_%d_%d.sm_%d%d.32.cubin", install_dir, (int) kern_type, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto, sm_major, sm_minor);
13895 }
13896 }
13897
13898 #endif
13899
13900 char module_mp_file[256];
13901
13902 memset (module_mp_file, 0, sizeof (module_mp_file));
13903
13904 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
13905 {
13906 #ifdef __x86_64__
13907 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4318/markov_be_v%d.sm_%d%d.64.cubin", install_dir, gpu_vector_width, sm_major, sm_minor);
13908 #else
13909 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4318/markov_be_v%d.sm_%d%d.32.cubin", install_dir, gpu_vector_width, sm_major, sm_minor);
13910 #endif
13911 }
13912 else
13913 {
13914 #ifdef __x86_64__
13915 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4318/markov_le_v%d.sm_%d%d.64.cubin", install_dir, gpu_vector_width, sm_major, sm_minor);
13916 #else
13917 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4318/markov_le_v%d.sm_%d%d.32.cubin", install_dir, gpu_vector_width, sm_major, sm_minor);
13918 #endif
13919 }
13920
13921 char module_amp_file[256];
13922
13923 memset (module_amp_file, 0, sizeof (module_amp_file));
13924
13925 #ifdef __x86_64__
13926 snprintf (module_amp_file, sizeof (module_amp_file) - 1, "%s/kernels/4318/amp_a%d_v%d.sm_%d%d.64.cubin", install_dir, attack_kern, gpu_vector_width, sm_major, sm_minor);
13927 #else
13928 snprintf (module_amp_file, sizeof (module_amp_file) - 1, "%s/kernels/4318/amp_a%d_v%d.sm_%d%d.32.cubin", install_dir, attack_kern, gpu_vector_width, sm_major, sm_minor);
13929 #endif
13930
13931 /**
13932 * module load
13933 */
13934
13935 hc_cuModuleLoad (&device_param->module, module_file);
13936
13937 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_file);
13938
13939 if (attack_mode != ATTACK_MODE_STRAIGHT)
13940 {
13941 hc_cuModuleLoad (&device_param->module_mp, module_mp_file);
13942
13943 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_mp_file);
13944 }
13945
13946 if (attack_exec == ATTACK_EXEC_ON_GPU)
13947 {
13948 // nothing to do
13949 }
13950 else
13951 {
13952 hc_cuModuleLoad (&device_param->module_amp, module_amp_file);
13953
13954 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_amp_file);
13955 }
13956
13957 /**
13958 * module functions
13959 */
13960
13961 char module_name[64];
13962
13963 memset (module_name, 0, sizeof (module_name));
13964
13965 if (attack_exec == ATTACK_EXEC_ON_GPU)
13966 {
13967 if (opti_type & OPTI_TYPE_SINGLE_HASH)
13968 {
13969 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 4);
13970
13971 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
13972
13973 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 8);
13974
13975 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
13976
13977 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 16);
13978
13979 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
13980 }
13981 else
13982 {
13983 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 4);
13984
13985 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
13986
13987 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 8);
13988
13989 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
13990
13991 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 16);
13992
13993 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
13994 }
13995
13996 if (attack_mode == ATTACK_MODE_BF)
13997 {
13998 if (opts_type & OPTS_TYPE_PT_BITSLICE)
13999 {
14000 snprintf (module_name, sizeof (module_name) - 1, "m%05d_tb", kern_type);
14001
14002 hc_cuModuleGetFunction (&device_param->function_tb, device_param->module, module_name);
14003
14004 snprintf (module_name, sizeof (module_name) - 1, "m%05d_tm", kern_type);
14005
14006 hc_cuModuleGetFunction (&device_param->function_tm, device_param->module, module_name);
14007 }
14008 }
14009 }
14010 else
14011 {
14012 snprintf (module_name, sizeof (module_name) - 1, "m%05d_init", kern_type);
14013
14014 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
14015
14016 snprintf (module_name, sizeof (module_name) - 1, "m%05d_loop", kern_type);
14017
14018 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
14019
14020 snprintf (module_name, sizeof (module_name) - 1, "m%05d_comp", kern_type);
14021
14022 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
14023
14024 if (opts_type & OPTS_TYPE_HOOK12)
14025 {
14026 snprintf (module_name, sizeof (module_name) - 1, "m%05d_hook12", kern_type);
14027
14028 hc_cuModuleGetFunction (&device_param->function12, device_param->module, module_name);
14029 }
14030
14031 if (opts_type & OPTS_TYPE_HOOK23)
14032 {
14033 snprintf (module_name, sizeof (module_name) - 1, "m%05d_hook23", kern_type);
14034
14035 hc_cuModuleGetFunction (&device_param->function23, device_param->module, module_name);
14036 }
14037 }
14038
14039 if (attack_mode == ATTACK_MODE_BF)
14040 {
14041 hc_cuModuleGetFunction (&device_param->function_mp_l, device_param->module_mp, "l_markov");
14042 hc_cuModuleGetFunction (&device_param->function_mp_r, device_param->module_mp, "r_markov");
14043 }
14044 else if (attack_mode == ATTACK_MODE_HYBRID1)
14045 {
14046 hc_cuModuleGetFunction (&device_param->function_mp, device_param->module_mp, "C_markov");
14047 }
14048 else if (attack_mode == ATTACK_MODE_HYBRID2)
14049 {
14050 hc_cuModuleGetFunction (&device_param->function_mp, device_param->module_mp, "C_markov");
14051 }
14052
14053 /**
14054 * amplifiers are not independant
14055 */
14056
14057 if (attack_exec == ATTACK_EXEC_ON_GPU)
14058 {
14059 // nothing to do
14060 }
14061 else
14062 {
14063 hc_cuModuleGetFunction (&device_param->function_amp, device_param->module_amp, "amp");
14064 }
14065
14066 /**
14067 * global buffers
14068 */
14069
14070 hc_cuMemAlloc (&device_param->d_pws_buf, size_pws);
14071 hc_cuMemAlloc (&device_param->d_pws_amp_buf, size_pws);
14072 hc_cuMemAlloc (&device_param->d_tmps, size_tmps);
14073 hc_cuMemAlloc (&device_param->d_hooks, size_hooks);
14074 hc_cuMemAlloc (&device_param->d_bitmap_s1_a, bitmap_size);
14075 hc_cuMemAlloc (&device_param->d_bitmap_s1_b, bitmap_size);
14076 hc_cuMemAlloc (&device_param->d_bitmap_s1_c, bitmap_size);
14077 hc_cuMemAlloc (&device_param->d_bitmap_s1_d, bitmap_size);
14078 hc_cuMemAlloc (&device_param->d_bitmap_s2_a, bitmap_size);
14079 hc_cuMemAlloc (&device_param->d_bitmap_s2_b, bitmap_size);
14080 hc_cuMemAlloc (&device_param->d_bitmap_s2_c, bitmap_size);
14081 hc_cuMemAlloc (&device_param->d_bitmap_s2_d, bitmap_size);
14082 hc_cuMemAlloc (&device_param->d_plain_bufs, size_plains);
14083 hc_cuMemAlloc (&device_param->d_digests_buf, size_digests);
14084 hc_cuMemAlloc (&device_param->d_digests_shown, size_shown);
14085 hc_cuMemAlloc (&device_param->d_salt_bufs, size_salts);
14086 hc_cuMemAlloc (&device_param->d_result, size_results);
14087 hc_cuMemAlloc (&device_param->d_scryptV_buf, size_scryptV);
14088
14089 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_a, bitmap_s1_a, bitmap_size);
14090 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_b, bitmap_s1_b, bitmap_size);
14091 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_c, bitmap_s1_c, bitmap_size);
14092 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_d, bitmap_s1_d, bitmap_size);
14093 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_a, bitmap_s2_a, bitmap_size);
14094 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_b, bitmap_s2_b, bitmap_size);
14095 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_c, bitmap_s2_c, bitmap_size);
14096 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_d, bitmap_s2_d, bitmap_size);
14097 hc_cuMemcpyHtoD (device_param->d_digests_buf, data.digests_buf, size_digests);
14098 hc_cuMemcpyHtoD (device_param->d_digests_shown, data.digests_shown, size_shown);
14099 hc_cuMemcpyHtoD (device_param->d_salt_bufs, data.salts_buf, size_salts);
14100
14101 run_kernel_bzero (device_param, device_param->d_pws_buf, size_pws);
14102 run_kernel_bzero (device_param, device_param->d_pws_amp_buf, size_pws);
14103 run_kernel_bzero (device_param, device_param->d_tmps, size_tmps);
14104 run_kernel_bzero (device_param, device_param->d_hooks, size_hooks);
14105 run_kernel_bzero (device_param, device_param->d_plain_bufs, size_plains);
14106 run_kernel_bzero (device_param, device_param->d_result, size_results);
14107
14108 /**
14109 * special buffers
14110 */
14111
14112 if (attack_kern == ATTACK_KERN_STRAIGHT)
14113 {
14114 hc_cuMemAlloc (&device_param->d_rules, size_rules);
14115
14116 hc_cuMemcpyHtoD (device_param->d_rules, gpu_rules_buf, size_rules);
14117 }
14118 else if (attack_kern == ATTACK_KERN_COMBI)
14119 {
14120 hc_cuMemAlloc (&device_param->d_combs, size_combs);
14121 hc_cuMemAlloc (&device_param->d_root_css_buf, size_root_css);
14122 hc_cuMemAlloc (&device_param->d_markov_css_buf, size_markov_css);
14123
14124 run_kernel_bzero (device_param, device_param->d_combs, size_combs);
14125 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
14126 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
14127 }
14128 else if (attack_kern == ATTACK_KERN_BF)
14129 {
14130 hc_cuMemAlloc (&device_param->d_bfs, size_bfs);
14131 hc_cuMemAlloc (&device_param->d_tm, size_tm);
14132 hc_cuMemAlloc (&device_param->d_root_css_buf, size_root_css);
14133 hc_cuMemAlloc (&device_param->d_markov_css_buf, size_markov_css);
14134
14135 run_kernel_bzero (device_param, device_param->d_bfs, size_bfs);
14136 run_kernel_bzero (device_param, device_param->d_tm, size_tm);
14137 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
14138 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
14139 }
14140
14141 if (size_esalts)
14142 {
14143 hc_cuMemAlloc (&device_param->d_esalt_bufs, size_esalts);
14144
14145 hc_cuMemcpyHtoD (device_param->d_esalt_bufs, data.esalts_buf, size_esalts);
14146 }
14147
14148 /**
14149 * main host data
14150 */
14151
14152 uint *result = (uint *) mymalloc (size_results);
14153
14154 memset (result, 0, size_results);
14155
14156 device_param->result = result;
14157
14158 pw_t *pws_buf = (pw_t *) mymalloc (size_pws);
14159
14160 memset (pws_buf, 0, size_pws);
14161
14162 device_param->pws_buf = pws_buf;
14163
14164 pw_cache_t *pw_caches = (pw_cache_t *) mycalloc (64, sizeof (pw_cache_t));
14165
14166 for (int i = 0; i < 64; i++)
14167 {
14168 pw_caches[i].pw_buf.pw_len = i;
14169 pw_caches[i].cnt = 0;
14170 }
14171
14172 device_param->pw_caches = pw_caches;
14173
14174 comb_t *combs_buf = (comb_t *) mycalloc (GPU_COMBS, sizeof (comb_t));
14175
14176 device_param->combs_buf = combs_buf;
14177
14178 void *hooks_buf = mymalloc (size_hooks);
14179
14180 device_param->hooks_buf = hooks_buf;
14181
14182 switch (device_param->gpu_vector_width)
14183 {
14184 case 1: device_param->pw_transpose = pw_transpose_to_hi1;
14185 device_param->pw_add = pw_add_to_hc1;
14186 break;
14187 case 2: device_param->pw_transpose = pw_transpose_to_hi2;
14188 device_param->pw_add = pw_add_to_hc2;
14189 break;
14190 case 4: device_param->pw_transpose = pw_transpose_to_hi4;
14191 device_param->pw_add = pw_add_to_hc4;
14192 break;
14193 }
14194
14195 /**
14196 * module args
14197 */
14198
14199 device_param->kernel_params_buf32[21] = bitmap_mask;
14200 device_param->kernel_params_buf32[22] = bitmap_shift1;
14201 device_param->kernel_params_buf32[23] = bitmap_shift2;
14202 device_param->kernel_params_buf32[24] = 0; // salt_pos
14203 device_param->kernel_params_buf32[25] = 0; // loop_pos
14204 device_param->kernel_params_buf32[26] = 0; // loop_cnt
14205 device_param->kernel_params_buf32[27] = 0; // gpu_rules_cnt
14206 device_param->kernel_params_buf32[28] = 0; // digests_cnt
14207 device_param->kernel_params_buf32[29] = 0; // digests_offset
14208 device_param->kernel_params_buf32[30] = 0; // combs_mode
14209 device_param->kernel_params_buf32[31] = 0; // gid_max
14210
14211 device_param->kernel_params[ 0] = (attack_exec == ATTACK_EXEC_ON_GPU)
14212 ? &device_param->d_pws_buf
14213 : &device_param->d_pws_amp_buf;
14214 device_param->kernel_params[ 1] = &device_param->d_rules;
14215 device_param->kernel_params[ 2] = &device_param->d_combs;
14216 device_param->kernel_params[ 3] = &device_param->d_bfs;
14217 device_param->kernel_params[ 4] = &device_param->d_tmps;
14218 device_param->kernel_params[ 5] = &device_param->d_hooks;
14219 device_param->kernel_params[ 6] = &device_param->d_bitmap_s1_a;
14220 device_param->kernel_params[ 7] = &device_param->d_bitmap_s1_b;
14221 device_param->kernel_params[ 8] = &device_param->d_bitmap_s1_c;
14222 device_param->kernel_params[ 9] = &device_param->d_bitmap_s1_d;
14223 device_param->kernel_params[10] = &device_param->d_bitmap_s2_a;
14224 device_param->kernel_params[11] = &device_param->d_bitmap_s2_b;
14225 device_param->kernel_params[12] = &device_param->d_bitmap_s2_c;
14226 device_param->kernel_params[13] = &device_param->d_bitmap_s2_d;
14227 device_param->kernel_params[14] = &device_param->d_plain_bufs;
14228 device_param->kernel_params[15] = &device_param->d_digests_buf;
14229 device_param->kernel_params[16] = &device_param->d_digests_shown;
14230 device_param->kernel_params[17] = &device_param->d_salt_bufs;
14231 device_param->kernel_params[18] = &device_param->d_esalt_bufs;
14232 device_param->kernel_params[19] = &device_param->d_result;
14233 device_param->kernel_params[20] = &device_param->d_scryptV_buf;
14234 device_param->kernel_params[21] = &device_param->kernel_params_buf32[21];
14235 device_param->kernel_params[22] = &device_param->kernel_params_buf32[22];
14236 device_param->kernel_params[23] = &device_param->kernel_params_buf32[23];
14237 device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
14238 device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
14239 device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
14240 device_param->kernel_params[27] = &device_param->kernel_params_buf32[27];
14241 device_param->kernel_params[28] = &device_param->kernel_params_buf32[28];
14242 device_param->kernel_params[29] = &device_param->kernel_params_buf32[29];
14243 device_param->kernel_params[30] = &device_param->kernel_params_buf32[30];
14244 device_param->kernel_params[31] = &device_param->kernel_params_buf32[31];
14245
14246 device_param->kernel_params_mp_buf64[3] = 0;
14247 device_param->kernel_params_mp_buf32[4] = 0;
14248 device_param->kernel_params_mp_buf32[5] = 0;
14249 device_param->kernel_params_mp_buf32[6] = 0;
14250 device_param->kernel_params_mp_buf32[7] = 0;
14251 device_param->kernel_params_mp_buf32[8] = 0;
14252
14253 device_param->kernel_params_mp[0] = NULL;
14254 device_param->kernel_params_mp[1] = NULL;
14255 device_param->kernel_params_mp[2] = NULL;
14256 device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];
14257 device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4];
14258 device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5];
14259 device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6];
14260 device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7];
14261 device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf32[8];
14262
14263 device_param->kernel_params_mp_l_buf64[3] = 0;
14264 device_param->kernel_params_mp_l_buf32[4] = 0;
14265 device_param->kernel_params_mp_l_buf32[5] = 0;
14266 device_param->kernel_params_mp_l_buf32[6] = 0;
14267 device_param->kernel_params_mp_l_buf32[7] = 0;
14268 device_param->kernel_params_mp_l_buf32[8] = 0;
14269 device_param->kernel_params_mp_l_buf32[9] = 0;
14270
14271 device_param->kernel_params_mp_l[0] = NULL;
14272 device_param->kernel_params_mp_l[1] = NULL;
14273 device_param->kernel_params_mp_l[2] = NULL;
14274 device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3];
14275 device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4];
14276 device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5];
14277 device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6];
14278 device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7];
14279 device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8];
14280 device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf32[9];
14281
14282 device_param->kernel_params_mp_r_buf64[3] = 0;
14283 device_param->kernel_params_mp_r_buf32[4] = 0;
14284 device_param->kernel_params_mp_r_buf32[5] = 0;
14285 device_param->kernel_params_mp_r_buf32[6] = 0;
14286 device_param->kernel_params_mp_r_buf32[7] = 0;
14287 device_param->kernel_params_mp_r_buf32[8] = 0;
14288
14289 device_param->kernel_params_mp_r[0] = NULL;
14290 device_param->kernel_params_mp_r[1] = NULL;
14291 device_param->kernel_params_mp_r[2] = NULL;
14292 device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3];
14293 device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4];
14294 device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5];
14295 device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6];
14296 device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7];
14297 device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf32[8];
14298
14299 device_param->kernel_params_amp_buf32[5] = 0; // combs_mode
14300 device_param->kernel_params_amp_buf32[6] = 0; // gid_max
14301
14302 device_param->kernel_params_amp[0] = &device_param->d_pws_buf;
14303 device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf;
14304 device_param->kernel_params_amp[2] = &device_param->d_rules;
14305 device_param->kernel_params_amp[3] = &device_param->d_combs;
14306 device_param->kernel_params_amp[4] = &device_param->d_bfs;
14307 device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5];
14308 device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf32[6];
14309
14310 device_param->kernel_params_tb[0] = &device_param->d_pws_buf;
14311
14312 device_param->kernel_params_tm[0] = &device_param->d_bfs;
14313 device_param->kernel_params_tm[1] = &device_param->d_tm;
14314
14315 /* constant memory init */
14316
14317 CUmodule c_module;
14318
14319 if (attack_exec == ATTACK_EXEC_ON_GPU)
14320 {
14321 c_module = device_param->module;
14322 }
14323 else
14324 {
14325 c_module = device_param->module_amp;
14326 }
14327
14328 size_t c_bytes;
14329
14330 if (attack_kern == ATTACK_KERN_STRAIGHT)
14331 {
14332 CUdeviceptr c_rules;
14333
14334 hc_cuModuleGetGlobal (&c_rules, &c_bytes, c_module, "c_rules");
14335
14336 device_param->c_rules = c_rules;
14337 device_param->c_bytes = c_bytes;
14338
14339 hc_cuMemsetD8 (c_rules, 0, c_bytes);
14340 }
14341 else if (attack_kern == ATTACK_KERN_COMBI)
14342 {
14343 CUdeviceptr c_combs;
14344
14345 hc_cuModuleGetGlobal (&c_combs, &c_bytes, c_module, "c_combs");
14346
14347 device_param->c_combs = c_combs;
14348 device_param->c_bytes = c_bytes;
14349
14350 hc_cuMemsetD8 (c_combs, 0, c_bytes);
14351 }
14352 else if (attack_kern == ATTACK_KERN_BF)
14353 {
14354 CUdeviceptr c_bfs;
14355
14356 hc_cuModuleGetGlobal (&c_bfs, &c_bytes, c_module, "c_bfs");
14357
14358 device_param->c_bfs = c_bfs;
14359 device_param->c_bytes = c_bytes;
14360
14361 hc_cuMemsetD8 (c_bfs, 0, c_bytes);
14362
14363 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
14364 {
14365 size_t bytes;
14366
14367 CUdeviceptr c_tm;
14368
14369 hc_cuModuleGetGlobal (&c_tm, &bytes, c_module, "c_tm");
14370
14371 device_param->c_tm = c_tm;
14372
14373 hc_cuMemsetD8 (c_tm, 0, bytes);
14374 }
14375 }
14376
14377 hc_cuCtxPopCurrent (NULL);
14378 }
14379
14380 #elif _OCL
14381 for (uint device_id = 0; device_id < devices_cnt; device_id++)
14382 {
14383 /**
14384 * host buffer
14385 */
14386
14387 hc_device_param_t *device_param = &data.devices_param[device_id];
14388
14389 /**
14390 * device properties
14391 */
14392
14393 char *device_name = device_param->device_name;
14394 char *device_version = device_param->device_version;
14395 char *driver_version = device_param->driver_version;
14396
14397 uint gpu_processors = device_param->gpu_processors;
14398 uint gpu_vector_width = device_param->gpu_vector_width;
14399
14400 /**
14401 * create context for each device
14402 */
14403
14404 device_param->context = hc_clCreateContext (NULL, 1, &device_param->device, NULL, NULL);
14405
14406 /**
14407 * create command-queue
14408 */
14409
14410 device_param->command_queue = hc_clCreateCommandQueueWithProperties (device_param->context, device_param->device, NULL);
14411
14412 /**
14413 * create input buffers on device
14414 */
14415
14416 uint gpu_threads = GPU_THREADS_AMD;
14417
14418 if (hash_mode == 3200) gpu_threads = 8;
14419 if (hash_mode == 9000) gpu_threads = 8;
14420
14421 uint gpu_power = gpu_processors * gpu_threads * gpu_accel;
14422
14423 uint gpu_blocks = gpu_power * gpu_vector_width;
14424
14425 device_param->gpu_threads = gpu_threads;
14426 device_param->gpu_power_user = gpu_power;
14427 device_param->gpu_blocks_user = gpu_blocks;
14428
14429 gpu_blocks_all += gpu_blocks;
14430
14431 uint size_pws = gpu_power * sizeof (pw_t);
14432
14433 uint size_tmps = 4;
14434
14435 switch (hash_mode)
14436 {
14437 case 400: size_tmps = gpu_blocks * sizeof (phpass_tmp_t); break;
14438 case 500: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14439 case 501: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14440 case 1600: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14441 case 1800: size_tmps = gpu_blocks * sizeof (sha512crypt_tmp_t); break;
14442 case 2100: size_tmps = gpu_blocks * sizeof (dcc2_tmp_t); break;
14443 case 2500: size_tmps = gpu_blocks * sizeof (wpa_tmp_t); break;
14444 case 3200: size_tmps = gpu_blocks * sizeof (bcrypt_tmp_t); break;
14445 case 5200: size_tmps = gpu_blocks * sizeof (pwsafe3_tmp_t); break;
14446 case 5800: size_tmps = gpu_blocks * sizeof (androidpin_tmp_t); break;
14447 case 6211:
14448 case 6212:
14449 case 6213: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14450 case 6221:
14451 case 6222:
14452 case 6223: size_tmps = gpu_blocks * sizeof (tc64_tmp_t); break;
14453 case 6231:
14454 case 6232:
14455 case 6233: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14456 case 6241:
14457 case 6242:
14458 case 6243: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14459 case 6300: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14460 case 6400: size_tmps = gpu_blocks * sizeof (sha256aix_tmp_t); break;
14461 case 6500: size_tmps = gpu_blocks * sizeof (sha512aix_tmp_t); break;
14462 case 6600: size_tmps = gpu_blocks * sizeof (agilekey_tmp_t); break;
14463 case 6700: size_tmps = gpu_blocks * sizeof (sha1aix_tmp_t); break;
14464 case 6800: size_tmps = gpu_blocks * sizeof (lastpass_tmp_t); break;
14465 case 7100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14466 case 7200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14467 case 7400: size_tmps = gpu_blocks * sizeof (sha256crypt_tmp_t); break;
14468 case 7900: size_tmps = gpu_blocks * sizeof (drupal7_tmp_t); break;
14469 case 8200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14470 case 8800: size_tmps = gpu_blocks * sizeof (androidfde_tmp_t); break;
14471 case 8900: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
14472 case 9000: size_tmps = gpu_blocks * sizeof (pwsafe2_tmp_t); break;
14473 case 9100: size_tmps = gpu_blocks * sizeof (lotus8_tmp_t); break;
14474 case 9200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14475 case 9300: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
14476 case 9400: size_tmps = gpu_blocks * sizeof (office2007_tmp_t); break;
14477 case 9500: size_tmps = gpu_blocks * sizeof (office2010_tmp_t); break;
14478 case 9600: size_tmps = gpu_blocks * sizeof (office2013_tmp_t); break;
14479 case 10000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14480 case 10200: size_tmps = gpu_blocks * sizeof (cram_md5_t); break;
14481 case 10300: size_tmps = gpu_blocks * sizeof (saph_sha1_tmp_t); break;
14482 case 10500: size_tmps = gpu_blocks * sizeof (pdf14_tmp_t); break;
14483 case 10700: size_tmps = gpu_blocks * sizeof (pdf17l8_tmp_t); break;
14484 case 10900: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14485 case 11300: size_tmps = gpu_blocks * sizeof (bitcoin_wallet_tmp_t); break;
14486 case 11600: size_tmps = gpu_blocks * sizeof (seven_zip_tmp_t); break;
14487 case 11900: size_tmps = gpu_blocks * sizeof (pbkdf2_md5_tmp_t); break;
14488 case 12000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha1_tmp_t); break;
14489 case 12100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14490 case 12200: size_tmps = gpu_blocks * sizeof (ecryptfs_tmp_t); break;
14491 case 12300: size_tmps = gpu_blocks * sizeof (oraclet_tmp_t); break;
14492 case 12400: size_tmps = gpu_blocks * sizeof (bsdicrypt_tmp_t); break;
14493 case 12500: size_tmps = gpu_blocks * sizeof (rar3_tmp_t); break;
14494 case 12700: size_tmps = gpu_blocks * sizeof (mywallet_tmp_t); break;
14495 case 12800: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14496 };
14497
14498 uint size_hooks = 4;
14499
14500 if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23))
14501 {
14502 // insert correct hook size
14503 }
14504
14505 // we can optimize some stuff here...
14506
14507 device_param->size_pws = size_pws;
14508 device_param->size_tmps = size_tmps;
14509 device_param->size_hooks = size_hooks;
14510
14511 uint size_root_css = SP_PW_MAX * sizeof (cs_t);
14512 uint size_markov_css = SP_PW_MAX * CHARSIZ * sizeof (cs_t);
14513
14514 device_param->size_root_css = size_root_css;
14515 device_param->size_markov_css = size_markov_css;
14516
14517 uint size_results = GPU_THREADS_AMD * sizeof (uint);
14518
14519 device_param->size_results = size_results;
14520
14521 uint size_rules = gpu_rules_cnt * sizeof (gpu_rule_t);
14522 uint size_rules_c = GPU_RULES * sizeof (gpu_rule_t);
14523 uint size_plains = digests_cnt * sizeof (plain_t);
14524 uint size_salts = salts_cnt * sizeof (salt_t);
14525 uint size_esalts = salts_cnt * esalt_size;
14526
14527 device_param->size_plains = size_plains;
14528 device_param->size_digests = size_digests;
14529 device_param->size_shown = size_shown;
14530 device_param->size_salts = size_salts;
14531
14532 uint size_combs = GPU_COMBS * sizeof (comb_t);
14533 uint size_bfs = GPU_BFS * sizeof (bf_t);
14534 uint size_tm = 32 * sizeof (bs_word_t);
14535
14536 uint64_t size_scryptV = 1;
14537
14538 if ((hash_mode == 8900) || (hash_mode == 9300))
14539 {
14540 #define SHADER_PER_MP 8
14541 #define WAVEFRONTS 64
14542
14543 uint tmto_start = 2;
14544 uint tmto_stop = 1024;
14545
14546 if (scrypt_tmto)
14547 {
14548 tmto_start = 1 << scrypt_tmto;
14549 tmto_stop = tmto_start + 1;
14550 }
14551
14552 for (uint tmto = tmto_start; tmto < tmto_stop; tmto <<= 1)
14553 {
14554 // todo -- make sure all salts get the new tmto value
14555
14556 size_scryptV = (128 * data.salts_buf[0].scrypt_r) * data.salts_buf[0].scrypt_N;
14557
14558 size_scryptV /= tmto;
14559
14560 size_scryptV *= gpu_processors * WAVEFRONTS * SHADER_PER_MP;
14561
14562 if (size_scryptV > (device_param->gpu_maxmem_alloc / 2)) continue;
14563
14564 for (uint salts_pos = 0; salts_pos < data.salts_cnt; salts_pos++)
14565 {
14566 data.salts_buf[salts_pos].scrypt_tmto = tmto;
14567 data.salts_buf[salts_pos].scrypt_phy = gpu_processors * WAVEFRONTS * SHADER_PER_MP;
14568 }
14569
14570 break;
14571 }
14572
14573 if (data.salts_buf[0].scrypt_tmto == 0)
14574 {
14575 log_error ("ERROR: can't allocate enough GPU memory");
14576
14577 return -1;
14578 }
14579
14580 if (quiet == 0) log_info ("");
14581 if (quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u\n", data.salts_buf[0].scrypt_tmto);
14582 }
14583
14584 /**
14585 * kernel find
14586 */
14587
14588 uint vliw = get_vliw_by_device_name (device_name);
14589
14590 struct stat st;
14591
14592 char kernel_file[256];
14593
14594 memset (kernel_file, 0, sizeof (kernel_file));
14595
14596 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
14597
14598 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14599
14600 #ifdef BINARY_KERNEL
14601 if (attack_exec == ATTACK_EXEC_ON_GPU)
14602 {
14603 if (attack_kern == ATTACK_KERN_STRAIGHT)
14604 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d_a0.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
14605 else if (attack_kern == ATTACK_KERN_COMBI)
14606 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d_a1.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
14607 else if (attack_kern == ATTACK_KERN_BF)
14608 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d_a3.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
14609 }
14610 else
14611 {
14612 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
14613
14614 if ((hash_mode == 8900) || (hash_mode == 9300))
14615 {
14616 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d_%d_%d_%d_%d.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto, device_name, device_version, driver_version, COMPTIME);
14617 }
14618 }
14619
14620 if (stat (kernel_file, &st) == -1)
14621 {
14622 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_file);
14623
14624 char module_file[256];
14625
14626 memset (module_file, 0, sizeof (module_file));
14627
14628 if (attack_exec == ATTACK_EXEC_ON_GPU)
14629 {
14630 if (attack_kern == ATTACK_KERN_STRAIGHT)
14631 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a0.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14632 else if (attack_kern == ATTACK_KERN_COMBI)
14633 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a1.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14634 else if (attack_kern == ATTACK_KERN_BF)
14635 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a3.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14636 }
14637 else
14638 {
14639 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14640
14641 if ((hash_mode == 8900) || (hash_mode == 9300))
14642 {
14643 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_%d_%d_%d_%d.VLIW%d.llvmir", install_dir, (int) kern_type, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto, vliw);
14644 }
14645 }
14646
14647 load_kernel (module_file, 1, kernel_lengths, kernel_sources);
14648
14649 cl_program program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
14650
14651 local_free (kernel_sources[0]);
14652
14653 hc_clBuildProgram (program, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14654
14655 size_t binary_size;
14656
14657 clGetProgramInfo (program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
14658
14659 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
14660
14661 clGetProgramInfo (program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
14662
14663 writeProgramBin (kernel_file, binary, binary_size);
14664
14665 local_free (binary);
14666
14667 stat (kernel_file, &st); // to reload filesize
14668 }
14669
14670 #else
14671 if (attack_exec == ATTACK_EXEC_ON_GPU)
14672 {
14673 if (attack_kern == ATTACK_KERN_STRAIGHT)
14674 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a0.cl", install_dir, (int) kern_type);
14675 else if (attack_kern == ATTACK_KERN_COMBI)
14676 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a1.cl", install_dir, (int) kern_type);
14677 else if (attack_kern == ATTACK_KERN_BF)
14678 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a3.cl", install_dir, (int) kern_type);
14679 }
14680 else
14681 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d.cl", install_dir, (int) kern_type);
14682
14683 if (stat (kernel_file, &st) == -1)
14684 {
14685 log_error ("ERROR: %s: %s", kernel_file, strerror (errno));
14686
14687 return -1;
14688 }
14689
14690 #endif
14691
14692 load_kernel (kernel_file, 1, kernel_lengths, kernel_sources);
14693
14694 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_file, st.st_size);
14695
14696 #ifdef BINARY_KERNEL
14697 device_param->program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
14698 #else
14699 device_param->program = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
14700 #endif
14701
14702 local_free (kernel_lengths);
14703
14704 local_free (kernel_sources[0]);
14705
14706 local_free (kernel_sources)
14707
14708 /**
14709 * kernel mp find
14710 */
14711
14712 if (attack_mode != ATTACK_MODE_STRAIGHT)
14713 {
14714 char kernel_mp_file[256];
14715
14716 memset (kernel_mp_file, 0, sizeof (kernel_mp_file));
14717
14718 size_t *kernel_mp_lengths = (size_t *) mymalloc (sizeof (size_t));
14719
14720 const unsigned char **kernel_mp_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14721
14722 #ifdef BINARY_KERNEL
14723 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14724 {
14725 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/kernels/4098/markov_be_v%d.%s_%s_%s_%d.kernel", install_dir, gpu_vector_width, device_name, device_version, driver_version, COMPTIME);
14726 }
14727 else
14728 {
14729 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/kernels/4098/markov_le_v%d.%s_%s_%s_%d.kernel", install_dir, gpu_vector_width, device_name, device_version, driver_version, COMPTIME);
14730 }
14731
14732 if (stat (kernel_mp_file, &st) == -1)
14733 {
14734 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_mp_file);
14735
14736 char module_mp_file[256];
14737
14738 memset (module_mp_file, 0, sizeof (module_mp_file));
14739
14740 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14741 {
14742 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4098/markov_be_v%d.llvmir", install_dir, gpu_vector_width);
14743 }
14744 else
14745 {
14746 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4098/markov_le_v%d.llvmir", install_dir, gpu_vector_width);
14747 }
14748
14749 load_kernel (module_mp_file, 1, kernel_mp_lengths, kernel_mp_sources);
14750
14751 cl_program program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_mp_lengths, (const unsigned char **) kernel_mp_sources, NULL);
14752
14753 local_free (kernel_mp_sources[0]);
14754
14755 hc_clBuildProgram (program_mp, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14756
14757 size_t binary_mp_size;
14758
14759 clGetProgramInfo (program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_mp_size, NULL);
14760
14761 unsigned char *binary_mp = (unsigned char *) mymalloc (binary_mp_size);
14762
14763 clGetProgramInfo (program_mp, CL_PROGRAM_BINARIES, sizeof (binary_mp), &binary_mp, NULL);
14764
14765 writeProgramBin (kernel_mp_file, binary_mp, binary_mp_size);
14766
14767 local_free (binary_mp);
14768
14769 stat (kernel_mp_file, &st); // to reload filesize
14770 }
14771
14772 #else
14773 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14774 {
14775 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/amd/markov_be_v%d.cl", install_dir, gpu_vector_width);
14776 }
14777 else
14778 {
14779 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/amd/markov_le_v%d.cl", install_dir, gpu_vector_width);
14780 }
14781
14782 if (stat (kernel_mp_file, &st) == -1)
14783 {
14784 log_error ("ERROR: %s: %s", kernel_mp_file, strerror (errno));
14785
14786 return -1;
14787 }
14788
14789 #endif
14790
14791 load_kernel (kernel_mp_file, 1, kernel_mp_lengths, kernel_mp_sources);
14792
14793 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_mp_file, st.st_size);
14794
14795 #ifdef BINARY_KERNEL
14796 device_param->program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_mp_lengths, (const unsigned char **) kernel_mp_sources, NULL);
14797 #else
14798 device_param->program_mp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_mp_sources, NULL);
14799 #endif
14800
14801 local_free (kernel_mp_lengths);
14802
14803 local_free (kernel_mp_sources[0]);
14804
14805 local_free (kernel_mp_sources);
14806 }
14807
14808 /**
14809 * kernel amp find
14810 */
14811
14812 if (attack_exec == ATTACK_EXEC_ON_GPU)
14813 {
14814 // nothing to do
14815 }
14816 else
14817 {
14818 char kernel_amp_file[256];
14819
14820 memset (kernel_amp_file, 0, sizeof (kernel_amp_file));
14821
14822 size_t *kernel_amp_lengths = (size_t *) mymalloc (sizeof (size_t));
14823
14824 const unsigned char **kernel_amp_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14825
14826 #ifdef BINARY_KERNEL
14827 snprintf (kernel_amp_file, sizeof (kernel_amp_file) - 1, "%s/kernels/4098/amp_a%d_v%d.%s_%s_%s_%d.kernel", install_dir, attack_kern, gpu_vector_width, device_name, device_version, driver_version, COMPTIME);
14828
14829 if (stat (kernel_amp_file, &st) == -1)
14830 {
14831 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_amp_file);
14832
14833 char module_amp_file[256];
14834
14835 memset (module_amp_file, 0, sizeof (module_amp_file));
14836
14837 snprintf (module_amp_file, sizeof (module_amp_file) - 1, "%s/kernels/4098/amp_a%d_v%d.llvmir", install_dir, attack_kern, gpu_vector_width);
14838
14839 load_kernel (module_amp_file, 1, kernel_amp_lengths, kernel_amp_sources);
14840
14841 cl_program program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_amp_lengths, (const unsigned char **) kernel_amp_sources, NULL);
14842
14843 local_free (kernel_amp_sources[0]);
14844
14845 hc_clBuildProgram (program_amp, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14846
14847 size_t binary_amp_size;
14848
14849 clGetProgramInfo (program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_amp_size, NULL);
14850
14851 unsigned char *binary_amp = (unsigned char *) mymalloc (binary_amp_size);
14852
14853 clGetProgramInfo (program_amp, CL_PROGRAM_BINARIES, sizeof (binary_amp), &binary_amp, NULL);
14854
14855 writeProgramBin (kernel_amp_file, binary_amp, binary_amp_size);
14856
14857 local_free (binary_amp);
14858
14859 stat (kernel_amp_file, &st); // to reload filesize
14860 }
14861 #else
14862 snprintf (kernel_amp_file, sizeof (kernel_amp_file) - 1, "%s/amd/amp_a%d_v%d.cl", install_dir, attack_kern, gpu_vector_width);
14863
14864 if (stat (kernel_amp_file, &st) == -1)
14865 {
14866 log_error ("ERROR: %s: %s", kernel_amp_file, strerror (errno));
14867
14868 return -1;
14869 }
14870 #endif
14871
14872 load_kernel (kernel_amp_file, 1, kernel_amp_lengths, kernel_amp_sources);
14873
14874 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_amp_file, st.st_size);
14875
14876 #ifdef BINARY_KERNEL
14877 device_param->program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_amp_lengths, (const unsigned char **) kernel_amp_sources, NULL);
14878 #else
14879 device_param->program_amp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_amp_sources, NULL);
14880 #endif
14881
14882 local_free (kernel_amp_lengths);
14883
14884 local_free (kernel_amp_sources[0]);
14885
14886 local_free (kernel_amp_sources);
14887 }
14888
14889 /**
14890 * kernel compile
14891 */
14892
14893 char *build_opts = NULL;
14894
14895 #ifndef BINARY_KERNEL
14896 build_opts = (char *) mymalloc (256);
14897
14898 sprintf (build_opts, "-I . -I amd/ -D VLIW%d -x clc++ -cl-std=CL1.2", vliw);
14899
14900 if ((hash_mode == 8900) || (hash_mode == 9300))
14901 {
14902 sprintf (build_opts, "-I . -I amd/ -D VLIW%d -x clc++ -cl-std=CL1.2 -DSCRYPT_N=%d -DSCRYPT_R=%d -DSCRYPT_P=%d -DSCRYPT_TMTO=%d", vliw, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto);
14903 }
14904 #endif
14905
14906 clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
14907
14908 size_t ret_val_size = 0;
14909
14910 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
14911
14912 if (ret_val_size > 1)
14913 {
14914 char *build_log = (char *) malloc (ret_val_size + 1);
14915
14916 memset (build_log, 0, ret_val_size + 1);
14917
14918 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
14919
14920 puts (build_log);
14921
14922 free (build_log);
14923 }
14924
14925 if (attack_mode != ATTACK_MODE_STRAIGHT)
14926 {
14927 hc_clBuildProgram (device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL);
14928 }
14929
14930 if (attack_exec == ATTACK_EXEC_ON_GPU)
14931 {
14932 // nothing to do
14933 }
14934 else
14935 {
14936 hc_clBuildProgram (device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL);
14937 }
14938
14939 /**
14940 * amp is not independent
14941 */
14942
14943 if (attack_exec == ATTACK_EXEC_ON_GPU)
14944 {
14945 // nothing to do
14946 }
14947 else
14948 {
14949 device_param->kernel_amp = hc_clCreateKernel (device_param->program_amp, "amp");
14950 }
14951
14952 /**
14953 * global buffers
14954 */
14955
14956 device_param->d_pws_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
14957 device_param->d_pws_amp_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
14958 device_param->d_tmps = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL);
14959 device_param->d_hooks = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL);
14960 device_param->d_bitmap_s1_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14961 device_param->d_bitmap_s1_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14962 device_param->d_bitmap_s1_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14963 device_param->d_bitmap_s1_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14964 device_param->d_bitmap_s2_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14965 device_param->d_bitmap_s2_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14966 device_param->d_bitmap_s2_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14967 device_param->d_bitmap_s2_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14968 device_param->d_plain_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_plains, NULL);
14969 device_param->d_digests_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_digests, NULL);
14970 device_param->d_digests_shown = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_shown, NULL);
14971 device_param->d_salt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_salts, NULL);
14972 device_param->d_result = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_results, NULL);
14973 device_param->d_scryptV_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_scryptV, NULL);
14974
14975 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_size, bitmap_s1_a, 0, NULL, NULL);
14976 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_size, bitmap_s1_b, 0, NULL, NULL);
14977 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_size, bitmap_s1_c, 0, NULL, NULL);
14978 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_size, bitmap_s1_d, 0, NULL, NULL);
14979 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_size, bitmap_s2_a, 0, NULL, NULL);
14980 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_size, bitmap_s2_b, 0, NULL, NULL);
14981 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_size, bitmap_s2_c, 0, NULL, NULL);
14982 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_size, bitmap_s2_d, 0, NULL, NULL);
14983 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, data.digests_buf, 0, NULL, NULL);
14984 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, data.digests_shown, 0, NULL, NULL);
14985 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, data.salts_buf, 0, NULL, NULL);
14986
14987 run_kernel_bzero (device_param, device_param->d_pws_buf, size_pws);
14988 run_kernel_bzero (device_param, device_param->d_pws_amp_buf, size_pws);
14989 run_kernel_bzero (device_param, device_param->d_tmps, size_tmps);
14990 run_kernel_bzero (device_param, device_param->d_hooks, size_hooks);
14991 run_kernel_bzero (device_param, device_param->d_plain_bufs, size_plains);
14992 run_kernel_bzero (device_param, device_param->d_result, size_results);
14993
14994 /**
14995 * special buffers
14996 */
14997
14998 if (attack_kern == ATTACK_KERN_STRAIGHT)
14999 {
15000 device_param->d_rules = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules, NULL);
15001 device_param->d_rules_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL);
15002
15003 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, gpu_rules_buf, 0, NULL, NULL);
15004
15005 run_kernel_bzero (device_param, device_param->d_rules_c, size_rules_c);
15006 }
15007 else if (attack_kern == ATTACK_KERN_COMBI)
15008 {
15009 device_param->d_combs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
15010 device_param->d_combs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
15011 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
15012 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
15013
15014 run_kernel_bzero (device_param, device_param->d_combs, size_combs);
15015 run_kernel_bzero (device_param, device_param->d_combs_c, size_combs);
15016 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
15017 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
15018 }
15019 else if (attack_kern == ATTACK_KERN_BF)
15020 {
15021 device_param->d_bfs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
15022 device_param->d_bfs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
15023 device_param->d_tm_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_tm, NULL);
15024 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
15025 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
15026
15027 run_kernel_bzero (device_param, device_param->d_bfs, size_bfs);
15028 run_kernel_bzero (device_param, device_param->d_bfs_c, size_bfs);
15029 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
15030 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
15031 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
15032 }
15033
15034 if (size_esalts)
15035 {
15036 device_param->d_esalt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL);
15037
15038 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, data.esalts_buf, 0, NULL, NULL);
15039 }
15040
15041 /**
15042 * main host data
15043 */
15044
15045 uint *result = (uint *) mymalloc (size_results);
15046
15047 memset (result, 0, size_results);
15048
15049 device_param->result = result;
15050
15051 pw_t *pws_buf = (pw_t *) mymalloc (size_pws);
15052
15053 memset (pws_buf, 0, size_pws);
15054
15055 device_param->pws_buf = pws_buf;
15056
15057 pw_cache_t *pw_caches = (pw_cache_t *) mycalloc (64, sizeof (pw_cache_t));
15058
15059 for (int i = 0; i < 64; i++)
15060 {
15061 pw_caches[i].pw_buf.pw_len = i;
15062 pw_caches[i].cnt = 0;
15063 }
15064
15065 device_param->pw_caches = pw_caches;
15066
15067 comb_t *combs_buf = (comb_t *) mycalloc (GPU_COMBS, sizeof (comb_t));
15068
15069 device_param->combs_buf = combs_buf;
15070
15071 void *hooks_buf = mymalloc (size_hooks);
15072
15073 device_param->hooks_buf = hooks_buf;
15074
15075 switch (device_param->gpu_vector_width)
15076 {
15077 case 1: device_param->pw_transpose = pw_transpose_to_hi1;
15078 device_param->pw_add = pw_add_to_hc1;
15079 break;
15080 case 2: device_param->pw_transpose = pw_transpose_to_hi2;
15081 device_param->pw_add = pw_add_to_hc2;
15082 break;
15083 case 4: device_param->pw_transpose = pw_transpose_to_hi4;
15084 device_param->pw_add = pw_add_to_hc4;
15085 break;
15086 }
15087
15088 /**
15089 * kernel args
15090 */
15091
15092 device_param->kernel_params_buf32[21] = bitmap_mask;
15093 device_param->kernel_params_buf32[22] = bitmap_shift1;
15094 device_param->kernel_params_buf32[23] = bitmap_shift2;
15095 device_param->kernel_params_buf32[24] = 0; // salt_pos
15096 device_param->kernel_params_buf32[25] = 0; // loop_pos
15097 device_param->kernel_params_buf32[26] = 0; // loop_cnt
15098 device_param->kernel_params_buf32[27] = 0; // gpu_rules_cnt
15099 device_param->kernel_params_buf32[28] = 0; // digests_cnt
15100 device_param->kernel_params_buf32[29] = 0; // digests_offset
15101 device_param->kernel_params_buf32[30] = 0; // combs_mode
15102 device_param->kernel_params_buf32[31] = 0; // gid_max
15103
15104 device_param->kernel_params[ 0] = (attack_exec == ATTACK_EXEC_ON_GPU)
15105 ? &device_param->d_pws_buf
15106 : &device_param->d_pws_amp_buf;
15107 device_param->kernel_params[ 1] = &device_param->d_rules_c;
15108 device_param->kernel_params[ 2] = &device_param->d_combs_c;
15109 device_param->kernel_params[ 3] = &device_param->d_bfs_c;
15110 device_param->kernel_params[ 4] = &device_param->d_tmps;
15111 device_param->kernel_params[ 5] = &device_param->d_hooks;
15112 device_param->kernel_params[ 6] = &device_param->d_bitmap_s1_a;
15113 device_param->kernel_params[ 7] = &device_param->d_bitmap_s1_b;
15114 device_param->kernel_params[ 8] = &device_param->d_bitmap_s1_c;
15115 device_param->kernel_params[ 9] = &device_param->d_bitmap_s1_d;
15116 device_param->kernel_params[10] = &device_param->d_bitmap_s2_a;
15117 device_param->kernel_params[11] = &device_param->d_bitmap_s2_b;
15118 device_param->kernel_params[12] = &device_param->d_bitmap_s2_c;
15119 device_param->kernel_params[13] = &device_param->d_bitmap_s2_d;
15120 device_param->kernel_params[14] = &device_param->d_plain_bufs;
15121 device_param->kernel_params[15] = &device_param->d_digests_buf;
15122 device_param->kernel_params[16] = &device_param->d_digests_shown;
15123 device_param->kernel_params[17] = &device_param->d_salt_bufs;
15124 device_param->kernel_params[18] = &device_param->d_esalt_bufs;
15125 device_param->kernel_params[19] = &device_param->d_result;
15126 device_param->kernel_params[20] = &device_param->d_scryptV_buf;
15127 device_param->kernel_params[21] = &device_param->kernel_params_buf32[21];
15128 device_param->kernel_params[22] = &device_param->kernel_params_buf32[22];
15129 device_param->kernel_params[23] = &device_param->kernel_params_buf32[23];
15130 device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
15131 device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
15132 device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
15133 device_param->kernel_params[27] = &device_param->kernel_params_buf32[27];
15134 device_param->kernel_params[28] = &device_param->kernel_params_buf32[28];
15135 device_param->kernel_params[29] = &device_param->kernel_params_buf32[29];
15136 device_param->kernel_params[30] = &device_param->kernel_params_buf32[30];
15137 device_param->kernel_params[31] = &device_param->kernel_params_buf32[31];
15138
15139 device_param->kernel_params_mp_buf64[3] = 0;
15140 device_param->kernel_params_mp_buf32[4] = 0;
15141 device_param->kernel_params_mp_buf32[5] = 0;
15142 device_param->kernel_params_mp_buf32[6] = 0;
15143 device_param->kernel_params_mp_buf32[7] = 0;
15144 device_param->kernel_params_mp_buf32[8] = 0;
15145
15146 device_param->kernel_params_mp[0] = NULL;
15147 device_param->kernel_params_mp[1] = NULL;
15148 device_param->kernel_params_mp[2] = NULL;
15149 device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];
15150 device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4];
15151 device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5];
15152 device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6];
15153 device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7];
15154 device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf32[8];
15155
15156 device_param->kernel_params_mp_l_buf64[3] = 0;
15157 device_param->kernel_params_mp_l_buf32[4] = 0;
15158 device_param->kernel_params_mp_l_buf32[5] = 0;
15159 device_param->kernel_params_mp_l_buf32[6] = 0;
15160 device_param->kernel_params_mp_l_buf32[7] = 0;
15161 device_param->kernel_params_mp_l_buf32[8] = 0;
15162 device_param->kernel_params_mp_l_buf32[9] = 0;
15163
15164 device_param->kernel_params_mp_l[0] = NULL;
15165 device_param->kernel_params_mp_l[1] = NULL;
15166 device_param->kernel_params_mp_l[2] = NULL;
15167 device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3];
15168 device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4];
15169 device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5];
15170 device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6];
15171 device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7];
15172 device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8];
15173 device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf32[9];
15174
15175 device_param->kernel_params_mp_r_buf64[3] = 0;
15176 device_param->kernel_params_mp_r_buf32[4] = 0;
15177 device_param->kernel_params_mp_r_buf32[5] = 0;
15178 device_param->kernel_params_mp_r_buf32[6] = 0;
15179 device_param->kernel_params_mp_r_buf32[7] = 0;
15180 device_param->kernel_params_mp_r_buf32[8] = 0;
15181
15182 device_param->kernel_params_mp_r[0] = NULL;
15183 device_param->kernel_params_mp_r[1] = NULL;
15184 device_param->kernel_params_mp_r[2] = NULL;
15185 device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3];
15186 device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4];
15187 device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5];
15188 device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6];
15189 device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7];
15190 device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf32[8];
15191
15192 device_param->kernel_params_amp_buf32[5] = 0; // combs_mode
15193 device_param->kernel_params_amp_buf32[6] = 0; // gid_max
15194
15195 device_param->kernel_params_amp[0] = &device_param->d_pws_buf;
15196 device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf;
15197 device_param->kernel_params_amp[2] = &device_param->d_rules_c;
15198 device_param->kernel_params_amp[3] = &device_param->d_combs_c;
15199 device_param->kernel_params_amp[4] = &device_param->d_bfs_c;
15200 device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5];
15201 device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf32[6];
15202
15203 device_param->kernel_params_tb[0] = &device_param->d_pws_buf;
15204
15205 device_param->kernel_params_tm[0] = &device_param->d_bfs_c;
15206 device_param->kernel_params_tm[1] = &device_param->d_tm_c;
15207
15208 /**
15209 * kernel name
15210 */
15211
15212 char kernel_name[64];
15213
15214 memset (kernel_name, 0, sizeof (kernel_name));
15215
15216 if (attack_exec == ATTACK_EXEC_ON_GPU)
15217 {
15218 if (opti_type & OPTI_TYPE_SINGLE_HASH)
15219 {
15220 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 4);
15221
15222 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15223
15224 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 8);
15225
15226 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15227
15228 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 16);
15229
15230 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15231 }
15232 else
15233 {
15234 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 4);
15235
15236 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15237
15238 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 8);
15239
15240 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15241
15242 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 16);
15243
15244 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15245 }
15246
15247 if (data.attack_mode == ATTACK_MODE_BF)
15248 {
15249 if (opts_type & OPTS_TYPE_PT_BITSLICE)
15250 {
15251 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tb", kern_type);
15252
15253 device_param->kernel_tb = hc_clCreateKernel (device_param->program, kernel_name);
15254
15255 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tm", kern_type);
15256
15257 device_param->kernel_tm = hc_clCreateKernel (device_param->program, kernel_name);
15258 }
15259 }
15260 }
15261 else
15262 {
15263 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_init", kern_type);
15264
15265 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15266
15267 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_loop", kern_type);
15268
15269 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15270
15271 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_comp", kern_type);
15272
15273 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15274
15275 if (opts_type & OPTS_TYPE_HOOK12)
15276 {
15277 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook12", kern_type);
15278
15279 device_param->kernel12 = hc_clCreateKernel (device_param->program, kernel_name);
15280 }
15281
15282 if (opts_type & OPTS_TYPE_HOOK23)
15283 {
15284 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook23", kern_type);
15285
15286 device_param->kernel23 = hc_clCreateKernel (device_param->program, kernel_name);
15287 }
15288 }
15289
15290 for (uint i = 0; i <= 20; i++)
15291 {
15292 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]);
15293 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]);
15294 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]);
15295
15296 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]);
15297 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]);
15298 }
15299
15300 for (uint i = 21; i <= 31; i++)
15301 {
15302 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]);
15303 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]);
15304 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]);
15305
15306 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]);
15307 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]);
15308 }
15309
15310 if (attack_mode == ATTACK_MODE_BF)
15311 {
15312 device_param->kernel_mp_l = hc_clCreateKernel (device_param->program_mp, "l_markov");
15313 device_param->kernel_mp_r = hc_clCreateKernel (device_param->program_mp, "r_markov");
15314
15315 if (opts_type & OPTS_TYPE_PT_BITSLICE)
15316 {
15317 hc_clSetKernelArg (device_param->kernel_tb, 0, sizeof (cl_mem), device_param->kernel_params_tb[0]);
15318
15319 hc_clSetKernelArg (device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]);
15320 hc_clSetKernelArg (device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]);
15321 }
15322 }
15323 else if (attack_mode == ATTACK_MODE_HYBRID1)
15324 {
15325 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
15326 }
15327 else if (attack_mode == ATTACK_MODE_HYBRID2)
15328 {
15329 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
15330 }
15331
15332 if (attack_exec == ATTACK_EXEC_ON_GPU)
15333 {
15334 // nothing to do
15335 }
15336 else
15337 {
15338 for (uint i = 0; i < 5; i++)
15339 {
15340 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]);
15341 }
15342
15343 for (uint i = 5; i < 7; i++)
15344 {
15345 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]);
15346 }
15347 }
15348
15349 /**
15350 * Store initial fanspeed if gpu_temp_retain is enabled
15351 */
15352
15353 if (gpu_temp_disable == 0)
15354 {
15355 if (gpu_temp_retain != 0)
15356 {
15357 hc_thread_mutex_lock (mux_adl);
15358
15359 if (data.hm_device[device_id].fan_supported == 1)
15360 {
15361 if (gpu_temp_retain_chgd == 0)
15362 {
15363 uint cur_temp = 0;
15364 uint default_temp = 0;
15365
15366 int ADL_rc = hc_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_dll, data.hm_device[device_id].adapter_index, (int *) &cur_temp, (int *) &default_temp);
15367
15368 if (ADL_rc == ADL_OK)
15369 {
15370 #define GPU_TEMP_RETAIN_ABORT_DIFF 15
15371
15372 const uint gpu_temp_retain_target = default_temp - GPU_TEMP_RETAIN_ABORT_DIFF;
15373
15374 // special case with multi gpu setups: always use minimum retain
15375
15376 if (gpu_temp_retain_set == 0)
15377 {
15378 gpu_temp_retain = gpu_temp_retain_target;
15379 gpu_temp_retain_set = 1;
15380 }
15381 else
15382 {
15383 gpu_temp_retain = MIN (gpu_temp_retain, gpu_temp_retain_target);
15384 }
15385
15386 if (gpu_temp_abort_chgd == 0) gpu_temp_abort = gpu_temp_retain + GPU_TEMP_RETAIN_ABORT_DIFF;
15387 }
15388 }
15389
15390 const int fan_speed = hm_get_fanspeed_with_device_id (device_id);
15391
15392 temp_retain_fanspeed_value[device_id] = fan_speed;
15393
15394 if (fan_speed == -1)
15395 {
15396 log_info ("WARNING: Failed to get current fan speed settings for gpu number: %i:", device_id + 1);
15397
15398 temp_retain_fanspeed_value[device_id] = 0;
15399 }
15400 }
15401
15402 hc_thread_mutex_unlock (mux_adl);
15403 }
15404 }
15405
15406 /**
15407 * Store original powercontrol/clocks settings, set overdrive 6 performance tuning settings
15408 */
15409
15410 if (powertune_enable == 1)
15411 {
15412 hc_thread_mutex_lock (mux_adl);
15413
15414 if (data.hm_device[device_id].od_version == 6)
15415 {
15416 int ADL_rc;
15417
15418 // check powertune capabilities first, if not available then skip device
15419
15420 int powertune_supported = 0;
15421
15422 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune_supported)) != ADL_OK)
15423 {
15424 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
15425
15426 return (-1);
15427 }
15428
15429 if (powertune_supported != 0)
15430 {
15431 // powercontrol settings
15432
15433 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
15434
15435 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune)) == ADL_OK)
15436 {
15437 ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &od_power_control_status[device_id]);
15438 }
15439
15440 if (ADL_rc != ADL_OK)
15441 {
15442 log_error ("ERROR: Failed to get current ADL PowerControl settings");
15443
15444 return (-1);
15445 }
15446
15447 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index, powertune.iMaxValue)) != ADL_OK)
15448 {
15449 log_error ("ERROR: Failed to set new ADL PowerControl values");
15450
15451 return (-1);
15452 }
15453
15454 // clocks
15455
15456 memset (&od_clock_mem_status[device_id], 0, sizeof (ADLOD6MemClockState));
15457
15458 od_clock_mem_status[device_id].state.iNumberOfPerformanceLevels = 2;
15459
15460 if ((ADL_rc = hc_ADL_Overdrive_StateInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &od_clock_mem_status[device_id])) != ADL_OK)
15461 {
15462 log_error ("ERROR: Failed to get ADL memory and engine clock frequency");
15463
15464 return (-1);
15465 }
15466
15467 // Query capabilities only to see if profiles were not "damaged", if so output a warning but do accept the users profile settings
15468
15469 ADLOD6Capabilities caps = {0, 0, 0, {0, 0, 0}, {0, 0, 0}, 0, 0};
15470
15471 if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &caps)) != ADL_OK)
15472 {
15473 log_error ("ERROR: Failed to get ADL device capabilities");
15474
15475 return (-1);
15476 }
15477
15478 int engine_clock_max = caps.sEngineClockRange.iMax * 0.6666;
15479 int memory_clock_max = caps.sMemoryClockRange.iMax * 0.6250;
15480
15481 int warning_trigger_engine = (int) (0.25 * (float) engine_clock_max);
15482 int warning_trigger_memory = (int) (0.25 * (float) memory_clock_max);
15483
15484 int engine_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iEngineClock;
15485 int memory_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock;
15486
15487 // warning if profile has to low max values
15488
15489 if ((engine_clock_max - engine_clock_profile_max) > warning_trigger_engine)
15490 {
15491 log_info ("WARN: the custom profile seems to have too low maximum engine clock values. You therefore may not reach full performance");
15492 }
15493
15494 if ((memory_clock_max - memory_clock_profile_max) > warning_trigger_memory)
15495 {
15496 log_info ("WARN: the custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance");
15497 }
15498
15499 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
15500
15501 performance_state->iNumberOfPerformanceLevels = 2;
15502
15503 performance_state->aLevels[0].iEngineClock = engine_clock_profile_max;
15504 performance_state->aLevels[1].iEngineClock = engine_clock_profile_max;
15505 performance_state->aLevels[0].iMemoryClock = memory_clock_profile_max;
15506 performance_state->aLevels[1].iMemoryClock = memory_clock_profile_max;
15507
15508 if ((ADL_rc = hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[device_id].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
15509 {
15510 log_info ("ERROR: Failed to set ADL performance state");
15511
15512 return (-1);
15513 }
15514
15515 local_free (performance_state);
15516 }
15517 }
15518
15519 hc_thread_mutex_unlock (mux_adl);
15520 }
15521 }
15522
15523 /* Temporary fix:
15524 * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
15525 * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
15526 * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem)
15527 * Driver / ADL bug?
15528 */
15529
15530 if (powertune_enable == 1)
15531 {
15532 hc_thread_mutex_lock (mux_adl);
15533
15534 for (uint i = 0; i < devices_cnt; i++)
15535 {
15536 if (data.hm_device[i].od_version == 6)
15537 {
15538 // set powertune value only
15539
15540 int powertune_supported = 0;
15541
15542 int ADL_rc = 0;
15543
15544 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK)
15545 {
15546 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
15547
15548 return (-1);
15549 }
15550
15551 if (powertune_supported != 0)
15552 {
15553 // powertune set
15554 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
15555
15556 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index, &powertune)) != ADL_OK)
15557 {
15558 log_error ("ERROR: Failed to get current ADL PowerControl settings");
15559
15560 return (-1);
15561 }
15562
15563 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, powertune.iMaxValue)) != ADL_OK)
15564 {
15565 log_error ("ERROR: Failed to set new ADL PowerControl values");
15566
15567 return (-1);
15568 }
15569 }
15570 }
15571 }
15572
15573 hc_thread_mutex_unlock (mux_adl);
15574 }
15575 #endif
15576
15577 data.gpu_blocks_all = gpu_blocks_all;
15578
15579 #ifdef _OCL
15580 if (gpu_async == 0) gpu_async = 1; // get rid of the warning
15581 #endif
15582
15583 if (data.quiet == 0) log_info ("");
15584
15585 /**
15586 * Inform user which algorithm is checked and at which workload setting
15587 */
15588
15589 if (benchmark == 1)
15590 {
15591 quiet = 0;
15592
15593 data.quiet = quiet;
15594
15595 char *hash_type = strhashtype (data.hash_mode); // not a bug
15596
15597 log_info ("Hashtype: %s", hash_type);
15598 log_info ("Workload: %u loops, %u accel", gpu_loops, gpu_accel);
15599 log_info ("");
15600 }
15601
15602 /**
15603 * keep track of the progress
15604 */
15605
15606 data.words_progress_done = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15607 data.words_progress_rejected = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15608 data.words_progress_restored = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15609
15610 /**
15611 * open filehandles
15612 */
15613
15614 #if _WIN
15615 if (_setmode (_fileno (stdin), _O_BINARY) == -1)
15616 {
15617 log_error ("ERROR: %s: %s", "stdin", strerror (errno));
15618
15619 return (-1);
15620 }
15621
15622 if (_setmode (_fileno (stdout), _O_BINARY) == -1)
15623 {
15624 log_error ("ERROR: %s: %s", "stdout", strerror (errno));
15625
15626 return (-1);
15627 }
15628
15629 if (_setmode (_fileno (stderr), _O_BINARY) == -1)
15630 {
15631 log_error ("ERROR: %s: %s", "stderr", strerror (errno));
15632
15633 return (-1);
15634 }
15635 #endif
15636
15637 /**
15638 * dictionary pad
15639 */
15640
15641 segment_size *= (1024 * 1024);
15642
15643 data.segment_size = segment_size;
15644
15645 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
15646
15647 wl_data->buf = (char *) mymalloc (segment_size);
15648 wl_data->avail = segment_size;
15649 wl_data->incr = segment_size;
15650 wl_data->cnt = 0;
15651 wl_data->pos = 0;
15652
15653 uint wordlist_mode = ((optind + 1) < myargc) ? WL_MODE_FILE : WL_MODE_STDIN;
15654
15655 data.wordlist_mode = wordlist_mode;
15656
15657 cs_t *css_buf = NULL;
15658 uint css_cnt = 0;
15659 uint dictcnt = 0;
15660 uint maskcnt = 1;
15661 char **masks = NULL;
15662 char **dictfiles = NULL;
15663
15664 uint mask_from_file = 0;
15665
15666 if (attack_mode == ATTACK_MODE_STRAIGHT)
15667 {
15668 if (wordlist_mode == WL_MODE_FILE)
15669 {
15670 int wls_left = myargc - (optind + 1);
15671
15672 for (int i = 0; i < wls_left; i++)
15673 {
15674 char *l0_filename = myargv[optind + 1 + i];
15675
15676 struct stat l0_stat;
15677
15678 if (stat (l0_filename, &l0_stat) == -1)
15679 {
15680 log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
15681
15682 return (-1);
15683 }
15684
15685 uint is_dir = S_ISDIR (l0_stat.st_mode);
15686
15687 if (is_dir == 0)
15688 {
15689 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
15690
15691 dictcnt++;
15692
15693 dictfiles[dictcnt - 1] = l0_filename;
15694 }
15695 else
15696 {
15697 // do not allow --keyspace w/ a directory
15698
15699 if (keyspace == 1)
15700 {
15701 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
15702
15703 return (-1);
15704 }
15705
15706 char **dictionary_files = NULL;
15707
15708 dictionary_files = scan_directory (l0_filename);
15709
15710 if (dictionary_files != NULL)
15711 {
15712 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
15713
15714 for (int d = 0; dictionary_files[d] != NULL; d++)
15715 {
15716 char *l1_filename = dictionary_files[d];
15717
15718 struct stat l1_stat;
15719
15720 if (stat (l1_filename, &l1_stat) == -1)
15721 {
15722 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
15723
15724 return (-1);
15725 }
15726
15727 if (S_ISREG (l1_stat.st_mode))
15728 {
15729 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
15730
15731 dictcnt++;
15732
15733 dictfiles[dictcnt - 1] = strdup (l1_filename);
15734 }
15735 }
15736 }
15737
15738 local_free (dictionary_files);
15739 }
15740 }
15741
15742 if (dictcnt < 1)
15743 {
15744 log_error ("ERROR: No usable dictionary file found.");
15745
15746 return (-1);
15747 }
15748 }
15749 else if (wordlist_mode == WL_MODE_STDIN)
15750 {
15751 dictcnt = 1;
15752 }
15753 }
15754 else if (attack_mode == ATTACK_MODE_COMBI)
15755 {
15756 // display
15757
15758 char *dictfile1 = myargv[optind + 1 + 0];
15759 char *dictfile2 = myargv[optind + 1 + 1];
15760
15761 // find the bigger dictionary and use as base
15762
15763 FILE *fp1;
15764 FILE *fp2;
15765
15766 struct stat tmp_stat;
15767
15768 if ((fp1 = fopen (dictfile1, "rb")) == NULL)
15769 {
15770 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
15771
15772 return (-1);
15773 }
15774
15775 if (stat (dictfile1, &tmp_stat) == -1)
15776 {
15777 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
15778
15779 fclose (fp1);
15780
15781 return (-1);
15782 }
15783
15784 if (S_ISDIR (tmp_stat.st_mode))
15785 {
15786 log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno));
15787
15788 fclose (fp1);
15789
15790 return (-1);
15791 }
15792
15793 if ((fp2 = fopen (dictfile2, "rb")) == NULL)
15794 {
15795 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
15796
15797 fclose (fp1);
15798
15799 return (-1);
15800 }
15801
15802 if (stat (dictfile2, &tmp_stat) == -1)
15803 {
15804 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
15805
15806 fclose (fp1);
15807 fclose (fp2);
15808
15809 return (-1);
15810 }
15811
15812 if (S_ISDIR (tmp_stat.st_mode))
15813 {
15814 log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno));
15815
15816 fclose (fp1);
15817 fclose (fp2);
15818
15819 return (-1);
15820 }
15821
15822 data.combs_cnt = 1;
15823
15824 data.quiet = 1;
15825
15826 const uint64_t words1_cnt = count_words (wl_data, fp1, dictfile1, dictstat_base, &dictstat_nmemb);
15827
15828 data.quiet = quiet;
15829
15830 if (words1_cnt == 0)
15831 {
15832 log_error ("ERROR: %s: empty file", dictfile1);
15833
15834 fclose (fp1);
15835 fclose (fp2);
15836
15837 return (-1);
15838 }
15839
15840 data.combs_cnt = 1;
15841
15842 data.quiet = 1;
15843
15844 const uint64_t words2_cnt = count_words (wl_data, fp2, dictfile2, dictstat_base, &dictstat_nmemb);
15845
15846 data.quiet = quiet;
15847
15848 if (words2_cnt == 0)
15849 {
15850 log_error ("ERROR: %s: empty file", dictfile2);
15851
15852 fclose (fp1);
15853 fclose (fp2);
15854
15855 return (-1);
15856 }
15857
15858 fclose (fp1);
15859 fclose (fp2);
15860
15861 data.dictfile = dictfile1;
15862 data.dictfile2 = dictfile2;
15863
15864 if (words1_cnt >= words2_cnt)
15865 {
15866 data.combs_cnt = words2_cnt;
15867 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
15868
15869 dictfiles = &data.dictfile;
15870
15871 dictcnt = 1;
15872 }
15873 else
15874 {
15875 data.combs_cnt = words1_cnt;
15876 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
15877
15878 dictfiles = &data.dictfile2;
15879
15880 dictcnt = 1;
15881
15882 // we also have to switch wordlist related rules!
15883
15884 char *tmpc = data.rule_buf_l;
15885
15886 data.rule_buf_l = data.rule_buf_r;
15887 data.rule_buf_r = tmpc;
15888
15889 int tmpi = data.rule_len_l;
15890
15891 data.rule_len_l = data.rule_len_r;
15892 data.rule_len_r = tmpi;
15893 }
15894 }
15895 else if (attack_mode == ATTACK_MODE_BF)
15896 {
15897 char *mask = NULL;
15898
15899 maskcnt = 0;
15900
15901 if (benchmark == 0)
15902 {
15903 mask = myargv[optind + 1];
15904
15905 masks = (char **) mymalloc (INCR_MASKS * sizeof (char *));
15906
15907 if ((optind + 2) <= myargc)
15908 {
15909 struct stat file_stat;
15910
15911 if (stat (mask, &file_stat) == -1)
15912 {
15913 maskcnt = 1;
15914
15915 masks[maskcnt - 1] = mystrdup (mask);
15916 }
15917 else
15918 {
15919 int wls_left = myargc - (optind + 1);
15920
15921 uint masks_avail = INCR_MASKS;
15922
15923 for (int i = 0; i < wls_left; i++)
15924 {
15925 if (i != 0)
15926 {
15927 mask = myargv[optind + 1 + i];
15928
15929 if (stat (mask, &file_stat) == -1)
15930 {
15931 log_error ("ERROR: %s: %s", mask, strerror (errno));
15932
15933 return (-1);
15934 }
15935 }
15936
15937 uint is_file = S_ISREG (file_stat.st_mode);
15938
15939 if (is_file == 1)
15940 {
15941 FILE *mask_fp;
15942
15943 if ((mask_fp = fopen (mask, "r")) == NULL)
15944 {
15945 log_error ("ERROR: %s: %s", mask, strerror (errno));
15946
15947 return (-1);
15948 }
15949
15950 char line_buf[BUFSIZ];
15951
15952 while (!feof (mask_fp))
15953 {
15954 memset (line_buf, 0, BUFSIZ);
15955
15956 int line_len = fgetl (mask_fp, line_buf);
15957
15958 if (line_len == 0) continue;
15959
15960 if (line_buf[0] == '#') continue;
15961
15962 if (masks_avail == maskcnt)
15963 {
15964 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
15965
15966 masks_avail += INCR_MASKS;
15967 }
15968
15969 masks[maskcnt] = mystrdup (line_buf);
15970
15971 maskcnt++;
15972 }
15973
15974 fclose (mask_fp);
15975 }
15976 else
15977 {
15978 log_error ("ERROR: %s: unsupported file-type", mask);
15979
15980 return (-1);
15981 }
15982 }
15983
15984 mask_from_file = 1;
15985 }
15986 }
15987 else
15988 {
15989 custom_charset_1 = (char *) "?l?d?u";
15990 custom_charset_2 = (char *) "?l?d";
15991 custom_charset_3 = (char *) "?l?d*!$@_";
15992
15993 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
15994 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
15995 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
15996
15997 masks[maskcnt] = mystrdup ("?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d");
15998
15999 wordlist_mode = WL_MODE_MASK;
16000
16001 data.wordlist_mode = wordlist_mode;
16002
16003 increment = 1;
16004
16005 maskcnt = 1;
16006 }
16007 }
16008 else
16009 {
16010 /**
16011 * generate full masks and charsets
16012 */
16013
16014 masks = (char **) mymalloc (sizeof (char *));
16015
16016 switch (hash_mode)
16017 {
16018 case 1731: pw_min = 5;
16019 pw_max = 5;
16020 mask = mystrdup ("?b?b?b?b?b");
16021 break;
16022 case 12500: pw_min = 5;
16023 pw_max = 5;
16024 mask = mystrdup ("?b?b?b?b?b");
16025 break;
16026 default: pw_min = 7;
16027 pw_max = 7;
16028 mask = mystrdup ("?b?b?b?b?b?b?b");
16029 break;
16030 }
16031
16032 maskcnt = 1;
16033
16034 masks[maskcnt - 1] = mystrdup (mask);
16035
16036 wordlist_mode = WL_MODE_MASK;
16037
16038 data.wordlist_mode = wordlist_mode;
16039
16040 increment = 1;
16041 }
16042
16043 dictfiles = (char **) mycalloc (pw_max, sizeof (char *));
16044
16045 if (increment)
16046 {
16047 if (increment_min > pw_min) pw_min = increment_min;
16048
16049 if (increment_max < pw_max) pw_max = increment_max;
16050 }
16051 }
16052 else if (attack_mode == ATTACK_MODE_HYBRID1)
16053 {
16054 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
16055
16056 // display
16057
16058 char *mask = myargv[myargc - 1];
16059
16060 maskcnt = 0;
16061
16062 masks = (char **) mymalloc (1 * sizeof (char *));
16063
16064 // mod
16065
16066 struct stat file_stat;
16067
16068 if (stat (mask, &file_stat) == -1)
16069 {
16070 maskcnt = 1;
16071
16072 masks[maskcnt - 1] = mystrdup (mask);
16073 }
16074 else
16075 {
16076 uint is_file = S_ISREG (file_stat.st_mode);
16077
16078 if (is_file == 1)
16079 {
16080 FILE *mask_fp;
16081
16082 if ((mask_fp = fopen (mask, "r")) == NULL)
16083 {
16084 log_error ("ERROR: %s: %s", mask, strerror (errno));
16085
16086 return (-1);
16087 }
16088
16089 char line_buf[BUFSIZ];
16090
16091 uint masks_avail = 1;
16092
16093 while (!feof (mask_fp))
16094 {
16095 memset (line_buf, 0, BUFSIZ);
16096
16097 int line_len = fgetl (mask_fp, line_buf);
16098
16099 if (line_len == 0) continue;
16100
16101 if (line_buf[0] == '#') continue;
16102
16103 if (masks_avail == maskcnt)
16104 {
16105 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
16106
16107 masks_avail += INCR_MASKS;
16108 }
16109
16110 masks[maskcnt] = mystrdup (line_buf);
16111
16112 maskcnt++;
16113 }
16114
16115 fclose (mask_fp);
16116
16117 mask_from_file = 1;
16118 }
16119 else
16120 {
16121 maskcnt = 1;
16122
16123 masks[maskcnt - 1] = mystrdup (mask);
16124 }
16125 }
16126
16127 // base
16128
16129 int wls_left = myargc - (optind + 2);
16130
16131 for (int i = 0; i < wls_left; i++)
16132 {
16133 char *filename = myargv[optind + 1 + i];
16134
16135 struct stat file_stat;
16136
16137 if (stat (filename, &file_stat) == -1)
16138 {
16139 log_error ("ERROR: %s: %s", filename, strerror (errno));
16140
16141 return (-1);
16142 }
16143
16144 uint is_dir = S_ISDIR (file_stat.st_mode);
16145
16146 if (is_dir == 0)
16147 {
16148 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16149
16150 dictcnt++;
16151
16152 dictfiles[dictcnt - 1] = filename;
16153 }
16154 else
16155 {
16156 // do not allow --keyspace w/ a directory
16157
16158 if (keyspace == 1)
16159 {
16160 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
16161
16162 return (-1);
16163 }
16164
16165 char **dictionary_files = NULL;
16166
16167 dictionary_files = scan_directory (filename);
16168
16169 if (dictionary_files != NULL)
16170 {
16171 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
16172
16173 for (int d = 0; dictionary_files[d] != NULL; d++)
16174 {
16175 char *l1_filename = dictionary_files[d];
16176
16177 struct stat l1_stat;
16178
16179 if (stat (l1_filename, &l1_stat) == -1)
16180 {
16181 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
16182
16183 return (-1);
16184 }
16185
16186 if (S_ISREG (l1_stat.st_mode))
16187 {
16188 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16189
16190 dictcnt++;
16191
16192 dictfiles[dictcnt - 1] = strdup (l1_filename);
16193 }
16194 }
16195 }
16196
16197 local_free (dictionary_files);
16198 }
16199 }
16200
16201 if (dictcnt < 1)
16202 {
16203 log_error ("ERROR: No usable dictionary file found.");
16204
16205 return (-1);
16206 }
16207
16208 if (increment)
16209 {
16210 maskcnt = 0;
16211
16212 uint mask_min = increment_min; // we can't reject smaller masks here
16213 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
16214
16215 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
16216 {
16217 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
16218
16219 if (cur_mask == NULL) break;
16220
16221 masks[maskcnt] = cur_mask;
16222
16223 maskcnt++;
16224
16225 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
16226 }
16227 }
16228 }
16229 else if (attack_mode == ATTACK_MODE_HYBRID2)
16230 {
16231 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
16232
16233 // display
16234
16235 char *mask = myargv[optind + 1 + 0];
16236
16237 maskcnt = 0;
16238
16239 masks = (char **) mymalloc (1 * sizeof (char *));
16240
16241 // mod
16242
16243 struct stat file_stat;
16244
16245 if (stat (mask, &file_stat) == -1)
16246 {
16247 maskcnt = 1;
16248
16249 masks[maskcnt - 1] = mystrdup (mask);
16250 }
16251 else
16252 {
16253 uint is_file = S_ISREG (file_stat.st_mode);
16254
16255 if (is_file == 1)
16256 {
16257 FILE *mask_fp;
16258
16259 if ((mask_fp = fopen (mask, "r")) == NULL)
16260 {
16261 log_error ("ERROR: %s: %s", mask, strerror (errno));
16262
16263 return (-1);
16264 }
16265
16266 char line_buf[BUFSIZ];
16267
16268 uint masks_avail = 1;
16269
16270 while (!feof (mask_fp))
16271 {
16272 memset (line_buf, 0, BUFSIZ);
16273
16274 int line_len = fgetl (mask_fp, line_buf);
16275
16276 if (line_len == 0) continue;
16277
16278 if (line_buf[0] == '#') continue;
16279
16280 if (masks_avail == maskcnt)
16281 {
16282 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
16283
16284 masks_avail += INCR_MASKS;
16285 }
16286
16287 masks[maskcnt] = mystrdup (line_buf);
16288
16289 maskcnt++;
16290 }
16291
16292 fclose (mask_fp);
16293
16294 mask_from_file = 1;
16295 }
16296 else
16297 {
16298 maskcnt = 1;
16299
16300 masks[maskcnt - 1] = mystrdup (mask);
16301 }
16302 }
16303
16304 // base
16305
16306 int wls_left = myargc - (optind + 2);
16307
16308 for (int i = 0; i < wls_left; i++)
16309 {
16310 char *filename = myargv[optind + 2 + i];
16311
16312 struct stat file_stat;
16313
16314 if (stat (filename, &file_stat) == -1)
16315 {
16316 log_error ("ERROR: %s: %s", filename, strerror (errno));
16317
16318 return (-1);
16319 }
16320
16321 uint is_dir = S_ISDIR (file_stat.st_mode);
16322
16323 if (is_dir == 0)
16324 {
16325 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16326
16327 dictcnt++;
16328
16329 dictfiles[dictcnt - 1] = filename;
16330 }
16331 else
16332 {
16333 // do not allow --keyspace w/ a directory
16334
16335 if (keyspace == 1)
16336 {
16337 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
16338
16339 return (-1);
16340 }
16341
16342 char **dictionary_files = NULL;
16343
16344 dictionary_files = scan_directory (filename);
16345
16346 if (dictionary_files != NULL)
16347 {
16348 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
16349
16350 for (int d = 0; dictionary_files[d] != NULL; d++)
16351 {
16352 char *l1_filename = dictionary_files[d];
16353
16354 struct stat l1_stat;
16355
16356 if (stat (l1_filename, &l1_stat) == -1)
16357 {
16358 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
16359
16360 return (-1);
16361 }
16362
16363 if (S_ISREG (l1_stat.st_mode))
16364 {
16365 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16366
16367 dictcnt++;
16368
16369 dictfiles[dictcnt - 1] = strdup (l1_filename);
16370 }
16371 }
16372 }
16373
16374 local_free (dictionary_files);
16375 }
16376 }
16377
16378 if (dictcnt < 1)
16379 {
16380 log_error ("ERROR: No usable dictionary file found.");
16381
16382 return (-1);
16383 }
16384
16385 if (increment)
16386 {
16387 maskcnt = 0;
16388
16389 uint mask_min = increment_min; // we can't reject smaller masks here
16390 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
16391
16392 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
16393 {
16394 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
16395
16396 if (cur_mask == NULL) break;
16397
16398 masks[maskcnt] = cur_mask;
16399
16400 maskcnt++;
16401
16402 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
16403 }
16404 }
16405 }
16406
16407 data.pw_min = pw_min;
16408 data.pw_max = pw_max;
16409
16410 /**
16411 * weak hash check
16412 */
16413
16414 if (weak_hash_threshold >= salts_cnt)
16415 {
16416 if (data.quiet == 0) log_info_nn ("Checking for weak hashes...");
16417
16418 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
16419 {
16420 weak_hash_check (&data.devices_param[0], salt_pos, gpu_loops);
16421 }
16422 }
16423
16424 // Display hack, guarantee that there is at least one \r before real start
16425
16426 if (data.quiet == 0) log_info_nn ("");
16427
16428 /**
16429 * status and monitor threads
16430 */
16431
16432 if (data.devices_status != STATUS_CRACKED) data.devices_status = STATUS_STARTING;
16433
16434 hc_thread_t i_thread = 0;
16435
16436 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
16437 {
16438 hc_thread_create (i_thread, thread_keypress, &benchmark);
16439 }
16440
16441 if (wordlist_mode == WL_MODE_STDIN) data.status = 1;
16442
16443 uint ni_threads_cnt = 0;
16444
16445 hc_thread_t *ni_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
16446
16447 hc_thread_create (ni_threads[ni_threads_cnt], thread_monitor, NULL);
16448
16449 ni_threads_cnt++;
16450
16451 /**
16452 * Outfile remove
16453 */
16454
16455 if (keyspace == 0)
16456 {
16457 if (outfile_check_timer != 0)
16458 {
16459 if (data.outfile_check_directory != NULL)
16460 {
16461 if ((hash_mode != 5200) &&
16462 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
16463 (hash_mode != 9000))
16464 {
16465 hc_thread_create (ni_threads[ni_threads_cnt], thread_outfile_remove, NULL);
16466
16467 ni_threads_cnt++;
16468 }
16469 else
16470 {
16471 outfile_check_timer = 0;
16472 }
16473 }
16474 else
16475 {
16476 outfile_check_timer = 0;
16477 }
16478 }
16479 }
16480
16481 /**
16482 * Inform the user if we got some hashes remove because of the pot file remove feature
16483 */
16484
16485 if (data.quiet == 0)
16486 {
16487 if (potfile_remove_cracks > 0)
16488 {
16489 if (potfile_remove_cracks == 1) log_info ("INFO: removed 1 hash found in pot file\n");
16490 else log_info ("INFO: removed %u hashes found in pot file\n", potfile_remove_cracks);
16491 }
16492 }
16493
16494 data.outfile_check_timer = outfile_check_timer;
16495
16496 /**
16497 * main loop
16498 */
16499
16500 char **induction_dictionaries = NULL;
16501
16502 int induction_dictionaries_cnt = 0;
16503
16504 hcstat_table_t *root_table_buf = NULL;
16505 hcstat_table_t *markov_table_buf = NULL;
16506
16507 uint initial_restore_done = 0;
16508
16509 data.maskcnt = maskcnt;
16510
16511 for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
16512 {
16513 if (data.devices_status == STATUS_CRACKED) break;
16514
16515 data.devices_status = STATUS_INIT;
16516
16517 if (maskpos > rd->maskpos)
16518 {
16519 rd->dictpos = 0;
16520 }
16521
16522 rd->maskpos = maskpos;
16523 data.maskpos = maskpos;
16524
16525 if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2 || attack_mode == ATTACK_MODE_BF)
16526 {
16527 char *mask = masks[maskpos];
16528
16529 if (mask_from_file == 1)
16530 {
16531 if (mask[0] == '\\' && mask[1] == '#') mask++; // escaped comment sign (sharp) "\#"
16532
16533 char *str_ptr;
16534 uint str_pos;
16535
16536 uint mask_offset = 0;
16537
16538 uint separator_cnt;
16539
16540 for (separator_cnt = 0; separator_cnt < 4; separator_cnt++)
16541 {
16542 str_ptr = strstr (mask + mask_offset, ",");
16543
16544 if (str_ptr == NULL) break;
16545
16546 str_pos = str_ptr - mask;
16547
16548 // escaped separator, i.e. "\,"
16549
16550 if (str_pos > 0)
16551 {
16552 if (mask[str_pos - 1] == '\\')
16553 {
16554 separator_cnt --;
16555
16556 mask_offset = str_pos + 1;
16557
16558 continue;
16559 }
16560 }
16561
16562 // reset the offset
16563
16564 mask_offset = 0;
16565
16566 mask[str_pos] = '\0';
16567
16568 switch (separator_cnt)
16569 {
16570 case 0:
16571 mp_reset_usr (mp_usr, 0);
16572
16573 custom_charset_1 = mask;
16574 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
16575 break;
16576
16577 case 1:
16578 mp_reset_usr (mp_usr, 1);
16579
16580 custom_charset_2 = mask;
16581 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
16582 break;
16583
16584 case 2:
16585 mp_reset_usr (mp_usr, 2);
16586
16587 custom_charset_3 = mask;
16588 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
16589 break;
16590
16591 case 3:
16592 mp_reset_usr (mp_usr, 3);
16593
16594 custom_charset_4 = mask;
16595 mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
16596 break;
16597 }
16598
16599 mask = mask + str_pos + 1;
16600 }
16601 }
16602
16603 if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
16604 {
16605 if (maskpos > 0)
16606 {
16607 local_free (css_buf);
16608 local_free (data.root_css_buf);
16609 local_free (data.markov_css_buf);
16610
16611 local_free (masks[maskpos - 1]);
16612 }
16613
16614 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
16615
16616 data.mask = mask;
16617 data.css_cnt = css_cnt;
16618 data.css_buf = css_buf;
16619
16620 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
16621
16622 memset (uniq_tbls, 0, sizeof (uniq_tbls));
16623
16624 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
16625
16626 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
16627 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
16628
16629 sp_setup_tbl (install_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
16630
16631 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
16632
16633 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
16634 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
16635
16636 data.root_css_buf = root_css_buf;
16637 data.markov_css_buf = markov_css_buf;
16638
16639 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
16640
16641 data.combs_cnt = sp_get_sum (0, css_cnt, root_css_buf);
16642
16643 local_free (root_table_buf);
16644 local_free (markov_table_buf);
16645
16646 // args
16647
16648 for (uint device_id = 0; device_id < devices_cnt; device_id++)
16649 {
16650 hc_device_param_t *device_param = &data.devices_param[device_id];
16651
16652 device_param->kernel_params_mp[0] = &device_param->d_combs;
16653 device_param->kernel_params_mp[1] = &device_param->d_root_css_buf;
16654 device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf;
16655
16656 device_param->kernel_params_mp_buf64[3] = 0;
16657 device_param->kernel_params_mp_buf32[4] = css_cnt;
16658 device_param->kernel_params_mp_buf32[5] = 0;
16659 device_param->kernel_params_mp_buf32[6] = 0;
16660 device_param->kernel_params_mp_buf32[7] = 0;
16661
16662 if (attack_mode == ATTACK_MODE_HYBRID1)
16663 {
16664 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_buf32[5] = full01;
16665 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_buf32[5] = full80;
16666 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_buf32[6] = 1;
16667 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_buf32[7] = 1;
16668 }
16669 else if (attack_mode == ATTACK_MODE_HYBRID2)
16670 {
16671 device_param->kernel_params_mp_buf32[5] = 0;
16672 device_param->kernel_params_mp_buf32[6] = 0;
16673 device_param->kernel_params_mp_buf32[7] = 0;
16674 }
16675
16676 #ifdef _CUDA
16677 hc_cuCtxPushCurrent (device_param->context);
16678
16679 hc_cuMemcpyHtoD (device_param->d_root_css_buf, root_css_buf, device_param->size_root_css);
16680 hc_cuMemcpyHtoD (device_param->d_markov_css_buf, markov_css_buf, device_param->size_markov_css);
16681
16682 hc_cuCtxPopCurrent (&device_param->context);
16683 #elif _OCL
16684 for (uint i = 0; i < 3; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]);
16685 for (uint i = 3; i < 4; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]);
16686 for (uint i = 4; i < 8; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]);
16687
16688 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, root_css_buf, 0, NULL, NULL);
16689 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, markov_css_buf, 0, NULL, NULL);
16690 #endif
16691 }
16692 }
16693 else if (attack_mode == ATTACK_MODE_BF)
16694 {
16695 dictcnt = 0; // number of "sub-masks", i.e. when using incremental mode
16696
16697 if (increment)
16698 {
16699 for (uint i = 0; i < dictcnt; i++)
16700 {
16701 local_free (dictfiles[i]);
16702 }
16703
16704 for (uint pw_len = MAX (1, pw_min); pw_len <= pw_max; pw_len++)
16705 {
16706 char *l1_filename = mp_get_truncated_mask (mask, strlen (mask), pw_len);
16707
16708 if (l1_filename == NULL) break;
16709
16710 dictcnt++;
16711
16712 dictfiles[dictcnt - 1] = l1_filename;
16713 }
16714 }
16715 else
16716 {
16717 dictcnt++;
16718
16719 dictfiles[dictcnt - 1] = mask;
16720 }
16721
16722 if (dictcnt == 0)
16723 {
16724 log_error ("ERROR: Mask is too small");
16725
16726 return (-1);
16727 }
16728 }
16729 }
16730
16731 free (induction_dictionaries);
16732
16733 // induction_dictionaries_cnt = 0; // implied
16734
16735 if (attack_mode != ATTACK_MODE_BF)
16736 {
16737 if (keyspace == 0)
16738 {
16739 induction_dictionaries = scan_directory (induction_directory);
16740
16741 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
16742 }
16743 }
16744
16745 if (induction_dictionaries_cnt)
16746 {
16747 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
16748 }
16749
16750 /**
16751 * prevent the user from using --keyspace together w/ maskfile and or dictfile
16752 */
16753 if (keyspace == 1)
16754 {
16755 if ((maskcnt > 1) || (dictcnt > 1))
16756 {
16757 log_error ("ERROR: --keyspace is not supported with --increment or mask files");
16758
16759 return (-1);
16760 }
16761 }
16762
16763 for (uint dictpos = rd->dictpos; dictpos < dictcnt; )
16764 {
16765 char *subid = logfile_generate_subid ();
16766
16767 data.subid = subid;
16768
16769 logfile_sub_msg ("START");
16770
16771 data.devices_status = STATUS_INIT;
16772
16773 memset (data.words_progress_done, 0, data.salts_cnt * sizeof (uint64_t));
16774 memset (data.words_progress_rejected, 0, data.salts_cnt * sizeof (uint64_t));
16775 memset (data.words_progress_restored, 0, data.salts_cnt * sizeof (uint64_t));
16776
16777 memset (data.cpt_buf, 0, CPT_BUF * sizeof (cpt_t));
16778
16779 data.cpt_pos = 0;
16780
16781 data.cpt_start = time (NULL);
16782
16783 data.cpt_total = 0;
16784
16785 if (data.restore == 0)
16786 {
16787 rd->words_cur = skip;
16788
16789 skip = 0;
16790
16791 data.skip = 0;
16792 }
16793
16794 data.ms_paused = 0;
16795
16796 data.words_cur = rd->words_cur;
16797
16798 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
16799 {
16800 hc_device_param_t *device_param = &data.devices_param[device_id];
16801
16802 device_param->speed_pos = 0;
16803
16804 memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (uint64_t));
16805 memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float));
16806 memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
16807
16808 device_param->gpu_power = device_param->gpu_power_user;
16809 device_param->gpu_blocks = device_param->gpu_blocks_user;
16810
16811 device_param->outerloop_pos = 0;
16812 device_param->outerloop_left = 0;
16813 device_param->innerloop_pos = 0;
16814 device_param->innerloop_left = 0;
16815
16816 // some more resets:
16817
16818 memset (device_param->pw_caches, 0, 64 * sizeof (pw_cache_t));
16819
16820 memset (device_param->pws_buf, 0, device_param->size_pws);
16821
16822 device_param->pw_cnt = 0;
16823 device_param->pws_cnt = 0;
16824
16825 device_param->words_off = 0;
16826 device_param->words_done = 0;
16827 }
16828
16829 data.gpu_blocks_div = 0;
16830
16831 // figure out some workload
16832
16833 if (attack_mode == ATTACK_MODE_STRAIGHT)
16834 {
16835 if (data.wordlist_mode == WL_MODE_FILE)
16836 {
16837 char *dictfile = NULL;
16838
16839 if (induction_dictionaries_cnt)
16840 {
16841 dictfile = induction_dictionaries[0];
16842 }
16843 else
16844 {
16845 dictfile = dictfiles[dictpos];
16846 }
16847
16848 data.dictfile = dictfile;
16849
16850 logfile_sub_string (dictfile);
16851
16852 for (uint i = 0; i < rp_files_cnt; i++)
16853 {
16854 logfile_sub_var_string ("rulefile", rp_files[i]);
16855 }
16856
16857 FILE *fd2 = fopen (dictfile, "rb");
16858
16859 if (fd2 == NULL)
16860 {
16861 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16862
16863 return (-1);
16864 }
16865
16866 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16867
16868 fclose (fd2);
16869
16870 if (data.words_cnt == 0)
16871 {
16872 if (data.devices_status == STATUS_CRACKED) break;
16873 if (data.devices_status == STATUS_ABORTED) break;
16874
16875 dictpos++;
16876
16877 continue;
16878 }
16879 }
16880 }
16881 else if (attack_mode == ATTACK_MODE_COMBI)
16882 {
16883 char *dictfile = data.dictfile;
16884 char *dictfile2 = data.dictfile2;
16885
16886 logfile_sub_string (dictfile);
16887 logfile_sub_string (dictfile2);
16888
16889 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
16890 {
16891 FILE *fd2 = fopen (dictfile, "rb");
16892
16893 if (fd2 == NULL)
16894 {
16895 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16896
16897 return (-1);
16898 }
16899
16900 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16901
16902 fclose (fd2);
16903 }
16904 else if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
16905 {
16906 FILE *fd2 = fopen (dictfile2, "rb");
16907
16908 if (fd2 == NULL)
16909 {
16910 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
16911
16912 return (-1);
16913 }
16914
16915 data.words_cnt = count_words (wl_data, fd2, dictfile2, dictstat_base, &dictstat_nmemb);
16916
16917 fclose (fd2);
16918 }
16919
16920 if (data.words_cnt == 0)
16921 {
16922 if (data.devices_status == STATUS_CRACKED) break;
16923 if (data.devices_status == STATUS_ABORTED) break;
16924
16925 dictpos++;
16926
16927 continue;
16928 }
16929 }
16930 else if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
16931 {
16932 char *dictfile = NULL;
16933
16934 if (induction_dictionaries_cnt)
16935 {
16936 dictfile = induction_dictionaries[0];
16937 }
16938 else
16939 {
16940 dictfile = dictfiles[dictpos];
16941 }
16942
16943 data.dictfile = dictfile;
16944
16945 char *mask = data.mask;
16946
16947 logfile_sub_string (dictfile);
16948 logfile_sub_string (mask);
16949
16950 FILE *fd2 = fopen (dictfile, "rb");
16951
16952 if (fd2 == NULL)
16953 {
16954 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16955
16956 return (-1);
16957 }
16958
16959 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16960
16961 fclose (fd2);
16962
16963 if (data.words_cnt == 0)
16964 {
16965 if (data.devices_status == STATUS_CRACKED) break;
16966 if (data.devices_status == STATUS_ABORTED) break;
16967
16968 dictpos++;
16969
16970 continue;
16971 }
16972 }
16973 else if (attack_mode == ATTACK_MODE_BF)
16974 {
16975 local_free (css_buf);
16976 local_free (data.root_css_buf);
16977 local_free (data.markov_css_buf);
16978
16979 char *mask = dictfiles[dictpos];
16980
16981 logfile_sub_string (mask);
16982
16983 // base
16984
16985 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
16986
16987 if (opts_type & OPTS_TYPE_PT_UNICODE)
16988 {
16989 uint css_cnt_unicode = css_cnt * 2;
16990
16991 cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t));
16992
16993 for (uint i = 0, j = 0; i < css_cnt; i += 1, j += 2)
16994 {
16995 memcpy (&css_buf_unicode[j + 0], &css_buf[i], sizeof (cs_t));
16996
16997 css_buf_unicode[j + 1].cs_buf[0] = 0;
16998 css_buf_unicode[j + 1].cs_len = 1;
16999 }
17000
17001 free (css_buf);
17002
17003 css_buf = css_buf_unicode;
17004 css_cnt = css_cnt_unicode;
17005 }
17006
17007 // check if mask is not too large or too small for pw_min/pw_max (*2 if unicode)
17008
17009 uint mask_min = pw_min;
17010 uint mask_max = pw_max;
17011
17012 if (opts_type & OPTS_TYPE_PT_UNICODE)
17013 {
17014 mask_min *= 2;
17015 mask_max *= 2;
17016 }
17017
17018 if ((css_cnt < mask_min) || (css_cnt > mask_max))
17019 {
17020 if (css_cnt < mask_min)
17021 {
17022 log_info ("WARNING: skipping mask '%s' because it is smaller than the minimum password length", mask);
17023 }
17024
17025 if (css_cnt > mask_max)
17026 {
17027 log_info ("WARNING: skipping mask '%s' because it is larger than the maximum password length", mask);
17028 }
17029
17030 // skip to next mask
17031
17032 dictpos++;
17033
17034 rd->dictpos = dictpos;
17035
17036 logfile_sub_msg ("STOP");
17037
17038 continue;
17039 }
17040
17041 uint save_css_cnt = css_cnt;
17042
17043 if (opti_type & OPTI_TYPE_SINGLE_HASH)
17044 {
17045 if (opti_type & OPTI_TYPE_APPENDED_SALT)
17046 {
17047 uint salt_len = (uint) data.salts_buf[0].salt_len;
17048 char *salt_buf = (char *) data.salts_buf[0].salt_buf;
17049
17050 uint css_cnt_salt = css_cnt + salt_len;
17051
17052 cs_t *css_buf_salt = (cs_t *) mycalloc (css_cnt_salt, sizeof (cs_t));
17053
17054 memcpy (css_buf_salt, css_buf, css_cnt * sizeof (cs_t));
17055
17056 for (uint i = 0, j = css_cnt; i < salt_len; i++, j++)
17057 {
17058 css_buf_salt[j].cs_buf[0] = salt_buf[i];
17059 css_buf_salt[j].cs_len = 1;
17060 }
17061
17062 free (css_buf);
17063
17064 css_buf = css_buf_salt;
17065 css_cnt = css_cnt_salt;
17066 }
17067 }
17068
17069 data.mask = mask;
17070 data.css_cnt = css_cnt;
17071 data.css_buf = css_buf;
17072
17073 if (maskpos > 0 && dictpos == 0) free (masks[maskpos - 1]);
17074
17075 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
17076
17077 memset (uniq_tbls, 0, sizeof (uniq_tbls));
17078
17079 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
17080
17081 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
17082 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
17083
17084 sp_setup_tbl (install_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
17085
17086 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
17087
17088 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
17089 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
17090
17091 data.root_css_buf = root_css_buf;
17092 data.markov_css_buf = markov_css_buf;
17093
17094 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
17095
17096 data.words_cnt = sp_get_sum (0, css_cnt, root_css_buf);
17097
17098 local_free (root_table_buf);
17099 local_free (markov_table_buf);
17100
17101 // copy + args
17102
17103 uint css_cnt_l = css_cnt;
17104 uint css_cnt_r;
17105
17106 if (attack_exec == ATTACK_EXEC_ON_GPU)
17107 {
17108 if (save_css_cnt < 6)
17109 {
17110 css_cnt_r = 1;
17111 }
17112 else if (save_css_cnt == 6)
17113 {
17114 css_cnt_r = 2;
17115 }
17116 else
17117 {
17118 if (opts_type & OPTS_TYPE_PT_UNICODE)
17119 {
17120 if (save_css_cnt == 8 || save_css_cnt == 10)
17121 {
17122 css_cnt_r = 2;
17123 }
17124 else
17125 {
17126 css_cnt_r = 4;
17127 }
17128 }
17129 else
17130 {
17131 if ((css_buf[0].cs_len * css_buf[1].cs_len * css_buf[2].cs_len) > 256)
17132 {
17133 css_cnt_r = 3;
17134 }
17135 else
17136 {
17137 css_cnt_r = 4;
17138 }
17139 }
17140 }
17141 }
17142 else
17143 {
17144 css_cnt_r = 1;
17145
17146 /* unfinished code?
17147 int sum = css_buf[css_cnt_r - 1].cs_len;
17148
17149 for (uint i = 1; i < 4 && i < css_cnt; i++)
17150 {
17151 if (sum > 1) break; // we really don't need alot of amplifier them for slow hashes
17152
17153 css_cnt_r++;
17154
17155 sum *= css_buf[css_cnt_r - 1].cs_len;
17156 }
17157 */
17158 }
17159
17160 css_cnt_l -= css_cnt_r;
17161
17162 data.bfs_cnt = sp_get_sum (0, css_cnt_r, root_css_buf);
17163
17164 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17165 {
17166 hc_device_param_t *device_param = &data.devices_param[device_id];
17167
17168 device_param->kernel_params_mp_l[0] = &device_param->d_pws_buf;
17169 device_param->kernel_params_mp_l[1] = &device_param->d_root_css_buf;
17170 device_param->kernel_params_mp_l[2] = &device_param->d_markov_css_buf;
17171
17172 device_param->kernel_params_mp_l_buf64[3] = 0;
17173 device_param->kernel_params_mp_l_buf32[4] = css_cnt_l;
17174 device_param->kernel_params_mp_l_buf32[5] = css_cnt_r;
17175 device_param->kernel_params_mp_l_buf32[6] = 0;
17176 device_param->kernel_params_mp_l_buf32[7] = 0;
17177 device_param->kernel_params_mp_l_buf32[8] = 0;
17178
17179 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_l_buf32[6] = full01;
17180 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_l_buf32[6] = full80;
17181 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1;
17182 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1;
17183
17184 device_param->kernel_params_mp_r[0] = &device_param->d_bfs;
17185 device_param->kernel_params_mp_r[1] = &device_param->d_root_css_buf;
17186 device_param->kernel_params_mp_r[2] = &device_param->d_markov_css_buf;
17187
17188 device_param->kernel_params_mp_r_buf64[3] = 0;
17189 device_param->kernel_params_mp_r_buf32[4] = css_cnt_r;
17190 device_param->kernel_params_mp_r_buf32[5] = 0;
17191 device_param->kernel_params_mp_r_buf32[6] = 0;
17192 device_param->kernel_params_mp_r_buf32[7] = 0;
17193
17194 #ifdef _CUDA
17195 hc_cuCtxPushCurrent (device_param->context);
17196
17197 hc_cuMemcpyHtoD (device_param->d_root_css_buf, root_css_buf, device_param->size_root_css);
17198 hc_cuMemcpyHtoD (device_param->d_markov_css_buf, markov_css_buf, device_param->size_markov_css);
17199
17200 hc_cuCtxPopCurrent (&device_param->context);
17201 #elif _OCL
17202 for (uint i = 0; i < 3; i++) hc_clSetKernelArg (device_param->kernel_mp_l, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_l[i]);
17203 for (uint i = 3; i < 4; i++) hc_clSetKernelArg (device_param->kernel_mp_l, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_l[i]);
17204 for (uint i = 4; i < 9; i++) hc_clSetKernelArg (device_param->kernel_mp_l, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_l[i]);
17205
17206 for (uint i = 0; i < 3; i++) hc_clSetKernelArg (device_param->kernel_mp_r, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp_r[i]);
17207 for (uint i = 3; i < 4; i++) hc_clSetKernelArg (device_param->kernel_mp_r, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp_r[i]);
17208 for (uint i = 4; i < 8; i++) hc_clSetKernelArg (device_param->kernel_mp_r, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp_r[i]);
17209
17210 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_root_css_buf, CL_TRUE, 0, device_param->size_root_css, root_css_buf, 0, NULL, NULL);
17211 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_markov_css_buf, CL_TRUE, 0, device_param->size_markov_css, markov_css_buf, 0, NULL, NULL);
17212 #endif
17213 }
17214 }
17215
17216 uint64_t words_base = data.words_cnt;
17217
17218 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
17219 {
17220 if (data.gpu_rules_cnt)
17221 {
17222 words_base /= data.gpu_rules_cnt;
17223 }
17224 }
17225 else if (data.attack_kern == ATTACK_KERN_COMBI)
17226 {
17227 if (data.combs_cnt)
17228 {
17229 words_base /= data.combs_cnt;
17230 }
17231 }
17232 else if (data.attack_kern == ATTACK_KERN_BF)
17233 {
17234 if (data.bfs_cnt)
17235 {
17236 words_base /= data.bfs_cnt;
17237 }
17238 }
17239
17240 data.words_base = words_base;
17241
17242 if (keyspace == 1)
17243 {
17244 log_info ("%llu", (unsigned long long int) words_base);
17245
17246 return (0);
17247 }
17248
17249 if (data.words_cur > data.words_base)
17250 {
17251 log_error ("ERROR: restore value greater keyspace");
17252
17253 return (-1);
17254 }
17255
17256 if (data.words_cur)
17257 {
17258 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
17259 {
17260 for (uint i = 0; i < data.salts_cnt; i++)
17261 {
17262 data.words_progress_restored[i] = data.words_cur * data.gpu_rules_cnt;
17263 }
17264 }
17265 else if (data.attack_kern == ATTACK_KERN_COMBI)
17266 {
17267 for (uint i = 0; i < data.salts_cnt; i++)
17268 {
17269 data.words_progress_restored[i] = data.words_cur * data.combs_cnt;
17270 }
17271 }
17272 else if (data.attack_kern == ATTACK_KERN_BF)
17273 {
17274 for (uint i = 0; i < data.salts_cnt; i++)
17275 {
17276 data.words_progress_restored[i] = data.words_cur * data.bfs_cnt;
17277 }
17278 }
17279 }
17280
17281 /*
17282 * Inform user about possible slow speeds
17283 */
17284
17285 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
17286 {
17287 if (data.words_base < gpu_blocks_all)
17288 {
17289 if (quiet == 0)
17290 {
17291 log_info ("");
17292 log_info ("ATTENTION!");
17293 log_info (" The wordlist or mask you are using is too small.");
17294 log_info (" Therefore, oclHashcat is unable to utilize the full parallelization power of your GPU(s).");
17295 log_info (" The cracking speed will drop.");
17296 log_info (" Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
17297 log_info ("");
17298 }
17299 }
17300 }
17301
17302 /*
17303 * Update loopback file
17304 */
17305
17306 if (loopback == 1)
17307 {
17308 time_t now;
17309
17310 time (&now);
17311
17312 uint random_num = get_random_num (0, 9999);
17313
17314 snprintf (loopback_file, loopback_size - 1, "%s/%s.%d_%i", induction_directory, LOOPBACK_FILE, (int) now, random_num);
17315
17316 data.loopback_file = loopback_file;
17317 }
17318
17319 /*
17320 * Update dictionary statistic
17321 */
17322
17323 if (keyspace == 0)
17324 {
17325 dictstat_fp = fopen (dictstat, "wb");
17326
17327 if (dictstat_fp)
17328 {
17329 fwrite (dictstat_base, sizeof (dictstat_t), dictstat_nmemb, dictstat_fp);
17330
17331 fclose (dictstat_fp);
17332 }
17333 }
17334
17335 data.devices_status = STATUS_RUNNING;
17336
17337 if (initial_restore_done == 0)
17338 {
17339 if (data.restore_disable == 0) cycle_restore ();
17340
17341 initial_restore_done = 1;
17342 }
17343
17344 hc_timer_set (&data.timer_running);
17345
17346 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
17347 {
17348 if ((quiet == 0) && (status == 0) && (benchmark == 0))
17349 {
17350 if (quiet == 0) fprintf (stdout, "%s", PROMPT);
17351 if (quiet == 0) fflush (stdout);
17352 }
17353 }
17354 else if (wordlist_mode == WL_MODE_STDIN)
17355 {
17356 if (data.quiet == 0) log_info ("Starting attack in stdin mode...");
17357 if (data.quiet == 0) log_info ("");
17358 }
17359
17360 time_t runtime_start;
17361
17362 time (&runtime_start);
17363
17364 data.runtime_start = runtime_start;
17365
17366 /**
17367 * create cracker threads
17368 */
17369
17370 hc_thread_t *c_threads = (hc_thread_t *) mycalloc (devices_cnt, sizeof (hc_thread_t));
17371
17372 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17373 {
17374 hc_device_param_t *device_param = &devices_param[device_id];
17375
17376 device_param->device_id = device_id;
17377
17378 if (wordlist_mode == WL_MODE_STDIN)
17379 {
17380 hc_thread_create (c_threads[device_id], thread_calc_stdin, device_param);
17381 }
17382 else
17383 {
17384 hc_thread_create (c_threads[device_id], thread_calc, device_param);
17385 }
17386 }
17387
17388 // wait for crack threads to exit
17389
17390 hc_thread_wait (devices_cnt, c_threads);
17391
17392
17393 local_free (c_threads);
17394
17395 data.restore = 0;
17396
17397 // finalize task
17398
17399 logfile_sub_var_uint ("status-after-work", data.devices_status);
17400
17401 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
17402
17403 if (data.devices_status == STATUS_CRACKED) break;
17404 if (data.devices_status == STATUS_ABORTED) break;
17405
17406 if (data.devices_status == STATUS_BYPASS)
17407 {
17408 data.devices_status = STATUS_RUNNING;
17409 }
17410
17411 if (induction_dictionaries_cnt)
17412 {
17413 unlink (induction_dictionaries[0]);
17414 }
17415
17416 free (induction_dictionaries);
17417
17418 if (attack_mode != ATTACK_MODE_BF)
17419 {
17420 induction_dictionaries = scan_directory (induction_directory);
17421
17422 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
17423 }
17424
17425 if (benchmark == 0)
17426 {
17427 if (((dictpos + 1) < dictcnt) || ((maskpos + 1) < maskcnt) || induction_dictionaries_cnt)
17428 {
17429 if (quiet == 0) clear_prompt ();
17430
17431 if (quiet == 0) log_info ("");
17432
17433 if (status == 1)
17434 {
17435 status_display ();
17436 }
17437 else
17438 {
17439 if (quiet == 0) status_display ();
17440 }
17441
17442 if (quiet == 0) log_info ("");
17443 }
17444 }
17445
17446 if (attack_mode == ATTACK_MODE_BF)
17447 {
17448 dictpos++;
17449
17450 rd->dictpos = dictpos;
17451 }
17452 else
17453 {
17454 if (induction_dictionaries_cnt)
17455 {
17456 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
17457 }
17458 else
17459 {
17460 dictpos++;
17461
17462 rd->dictpos = dictpos;
17463 }
17464 }
17465
17466 time_t runtime_stop;
17467
17468 time (&runtime_stop);
17469
17470 data.runtime_stop = runtime_stop;
17471
17472 logfile_sub_uint (runtime_start);
17473 logfile_sub_uint (runtime_stop);
17474
17475 logfile_sub_msg ("STOP");
17476
17477 global_free (subid);
17478 }
17479
17480 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
17481
17482 if (data.devices_status == STATUS_CRACKED) break;
17483 if (data.devices_status == STATUS_ABORTED) break;
17484 if (data.devices_status == STATUS_QUIT) break;
17485
17486 if (data.devices_status == STATUS_BYPASS)
17487 {
17488 data.devices_status = STATUS_RUNNING;
17489 }
17490 }
17491
17492 // problems could occur if already at startup everything was cracked (because of .pot file reading etc), we must set some variables here to avoid NULL pointers
17493
17494 if (attack_mode == ATTACK_MODE_STRAIGHT)
17495 {
17496 if (data.wordlist_mode == WL_MODE_FILE)
17497 {
17498 if (data.dictfile == NULL)
17499 {
17500 if (dictfiles != NULL)
17501 {
17502 data.dictfile = dictfiles[0];
17503
17504 hc_timer_set (&data.timer_running);
17505 }
17506 }
17507 }
17508 }
17509 // NOTE: combi is okay because it is already set beforehand
17510 else if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2)
17511 {
17512 if (data.dictfile == NULL)
17513 {
17514 if (dictfiles != NULL)
17515 {
17516 hc_timer_set (&data.timer_running);
17517
17518 data.dictfile = dictfiles[0];
17519 }
17520 }
17521 }
17522 else if (attack_mode == ATTACK_MODE_BF)
17523 {
17524 if (data.mask == NULL)
17525 {
17526 hc_timer_set (&data.timer_running);
17527
17528 data.mask = masks[0];
17529 }
17530 }
17531
17532 if ((data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
17533 {
17534 data.devices_status = STATUS_EXHAUSTED;
17535 }
17536
17537 // if cracked / aborted remove last induction dictionary
17538
17539 for (int file_pos = 0; file_pos < induction_dictionaries_cnt; file_pos++)
17540 {
17541 struct stat induct_stat;
17542
17543 if (stat (induction_dictionaries[file_pos], &induct_stat) == 0)
17544 {
17545 unlink (induction_dictionaries[file_pos]);
17546 }
17547 }
17548
17549 // wait for non-interactive threads
17550
17551 for (uint thread_idx = 0; thread_idx < ni_threads_cnt; thread_idx++)
17552 {
17553 hc_thread_wait (1, &ni_threads[thread_idx]);
17554 }
17555
17556 local_free (ni_threads);
17557
17558 // wait for interactive threads
17559
17560 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
17561 {
17562 hc_thread_wait (1, &i_thread);
17563 }
17564
17565 // we dont need restore file anymore
17566 if (data.restore_disable == 0)
17567 {
17568 if ((data.devices_status == STATUS_EXHAUSTED) || (data.devices_status == STATUS_CRACKED))
17569 {
17570 unlink (eff_restore_file);
17571 unlink (new_restore_file);
17572 }
17573 else
17574 {
17575 cycle_restore ();
17576 }
17577 }
17578
17579 // finally save left hashes
17580
17581 if ((hashlist_mode == HL_MODE_FILE) && (remove == 1) && (data.digests_saved != data.digests_done))
17582 {
17583 save_hash ();
17584 }
17585
17586 /**
17587 * Clean up
17588 */
17589
17590 if (benchmark == 1)
17591 {
17592 status_benchmark ();
17593
17594 log_info ("");
17595 }
17596 else
17597 {
17598 if (quiet == 0) clear_prompt ();
17599
17600 if (quiet == 0) log_info ("");
17601
17602 if (status == 1)
17603 {
17604 status_display ();
17605 }
17606 else
17607 {
17608 if (quiet == 0) status_display ();
17609 }
17610
17611 if (quiet == 0) log_info ("");
17612 }
17613
17614 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17615 {
17616 hc_device_param_t *device_param = &data.devices_param[device_id];
17617
17618 local_free (device_param->result);
17619
17620 local_free (device_param->pw_caches);
17621
17622 local_free (device_param->combs_buf);
17623
17624 local_free (device_param->hooks_buf);
17625
17626 #ifdef _CUDA
17627 hc_cuCtxPushCurrent (device_param->context);
17628
17629 if (device_param->pws_buf) myfree (device_param->pws_buf);
17630 if (device_param->d_pws_buf) hc_cuMemFree (device_param->d_pws_buf);
17631 if (device_param->d_pws_amp_buf) hc_cuMemFree (device_param->d_pws_amp_buf);
17632 if (device_param->d_rules) hc_cuMemFree (device_param->d_rules);
17633 if (device_param->d_combs) hc_cuMemFree (device_param->d_combs);
17634 if (device_param->d_bfs) hc_cuMemFree (device_param->d_bfs);
17635 if (device_param->d_bitmap_s1_a) hc_cuMemFree (device_param->d_bitmap_s1_a);
17636 if (device_param->d_bitmap_s1_b) hc_cuMemFree (device_param->d_bitmap_s1_b);
17637 if (device_param->d_bitmap_s1_c) hc_cuMemFree (device_param->d_bitmap_s1_c);
17638 if (device_param->d_bitmap_s1_d) hc_cuMemFree (device_param->d_bitmap_s1_d);
17639 if (device_param->d_bitmap_s2_a) hc_cuMemFree (device_param->d_bitmap_s2_a);
17640 if (device_param->d_bitmap_s2_b) hc_cuMemFree (device_param->d_bitmap_s2_b);
17641 if (device_param->d_bitmap_s2_c) hc_cuMemFree (device_param->d_bitmap_s2_c);
17642 if (device_param->d_bitmap_s2_d) hc_cuMemFree (device_param->d_bitmap_s2_d);
17643 if (device_param->d_plain_bufs) hc_cuMemFree (device_param->d_plain_bufs);
17644 if (device_param->d_digests_buf) hc_cuMemFree (device_param->d_digests_buf);
17645 if (device_param->d_digests_shown) hc_cuMemFree (device_param->d_digests_shown);
17646 if (device_param->d_salt_bufs) hc_cuMemFree (device_param->d_salt_bufs);
17647 if (device_param->d_esalt_bufs) hc_cuMemFree (device_param->d_esalt_bufs);
17648 if (device_param->d_tmps) hc_cuMemFree (device_param->d_tmps);
17649 if (device_param->d_hooks) hc_cuMemFree (device_param->d_hooks);
17650 if (device_param->d_result) hc_cuMemFree (device_param->d_result);
17651 if (device_param->d_scryptV_buf) hc_cuMemFree (device_param->d_scryptV_buf);
17652 if (device_param->d_root_css_buf) hc_cuMemFree (device_param->d_root_css_buf);
17653 if (device_param->d_markov_css_buf) hc_cuMemFree (device_param->d_markov_css_buf);
17654
17655 if (device_param->stream) hc_cuStreamDestroy (device_param->stream);
17656 if (device_param->module) hc_cuModuleUnload (device_param->module);
17657
17658 hc_cuCtxPopCurrent (&device_param->context);
17659
17660 if (device_param->context) hc_cuCtxDestroy (device_param->context);
17661
17662 #elif _OCL
17663 local_free (device_param->device_name);
17664
17665 local_free (device_param->device_version);
17666
17667 local_free (device_param->driver_version);
17668
17669 if (device_param->pws_buf) myfree (device_param->pws_buf);
17670 if (device_param->d_pws_buf) hc_clReleaseMemObject (device_param->d_pws_buf);
17671 if (device_param->d_pws_amp_buf) hc_clReleaseMemObject (device_param->d_pws_amp_buf);
17672 if (device_param->d_rules) hc_clReleaseMemObject (device_param->d_rules);
17673 if (device_param->d_rules_c) hc_clReleaseMemObject (device_param->d_rules_c);
17674 if (device_param->d_combs) hc_clReleaseMemObject (device_param->d_combs);
17675 if (device_param->d_combs_c) hc_clReleaseMemObject (device_param->d_combs_c);
17676 if (device_param->d_bfs) hc_clReleaseMemObject (device_param->d_bfs);
17677 if (device_param->d_bfs_c) hc_clReleaseMemObject (device_param->d_bfs_c);
17678 if (device_param->d_bitmap_s1_a) hc_clReleaseMemObject (device_param->d_bitmap_s1_a);
17679 if (device_param->d_bitmap_s1_b) hc_clReleaseMemObject (device_param->d_bitmap_s1_b);
17680 if (device_param->d_bitmap_s1_c) hc_clReleaseMemObject (device_param->d_bitmap_s1_c);
17681 if (device_param->d_bitmap_s1_d) hc_clReleaseMemObject (device_param->d_bitmap_s1_d);
17682 if (device_param->d_bitmap_s2_a) hc_clReleaseMemObject (device_param->d_bitmap_s2_a);
17683 if (device_param->d_bitmap_s2_b) hc_clReleaseMemObject (device_param->d_bitmap_s2_b);
17684 if (device_param->d_bitmap_s2_c) hc_clReleaseMemObject (device_param->d_bitmap_s2_c);
17685 if (device_param->d_bitmap_s2_d) hc_clReleaseMemObject (device_param->d_bitmap_s2_d);
17686 if (device_param->d_plain_bufs) hc_clReleaseMemObject (device_param->d_plain_bufs);
17687 if (device_param->d_digests_buf) hc_clReleaseMemObject (device_param->d_digests_buf);
17688 if (device_param->d_digests_shown) hc_clReleaseMemObject (device_param->d_digests_shown);
17689 if (device_param->d_salt_bufs) hc_clReleaseMemObject (device_param->d_salt_bufs);
17690 if (device_param->d_esalt_bufs) hc_clReleaseMemObject (device_param->d_esalt_bufs);
17691 if (device_param->d_tmps) hc_clReleaseMemObject (device_param->d_tmps);
17692 if (device_param->d_hooks) hc_clReleaseMemObject (device_param->d_hooks);
17693 if (device_param->d_result) hc_clReleaseMemObject (device_param->d_result);
17694 if (device_param->d_scryptV_buf) hc_clReleaseMemObject (device_param->d_scryptV_buf);
17695 if (device_param->d_root_css_buf) hc_clReleaseMemObject (device_param->d_root_css_buf);
17696 if (device_param->d_markov_css_buf) hc_clReleaseMemObject (device_param->d_markov_css_buf);
17697
17698 if (device_param->kernel1) hc_clReleaseKernel (device_param->kernel1);
17699 if (device_param->kernel12) hc_clReleaseKernel (device_param->kernel12);
17700 if (device_param->kernel2) hc_clReleaseKernel (device_param->kernel2);
17701 if (device_param->kernel23) hc_clReleaseKernel (device_param->kernel23);
17702 if (device_param->kernel3) hc_clReleaseKernel (device_param->kernel3);
17703 if (device_param->kernel_mp) hc_clReleaseKernel (device_param->kernel_mp);
17704 if (device_param->kernel_mp_l) hc_clReleaseKernel (device_param->kernel_mp_l);
17705 if (device_param->kernel_mp_r) hc_clReleaseKernel (device_param->kernel_mp_r);
17706
17707 if (device_param->program) hc_clReleaseProgram (device_param->program);
17708 if (device_param->program_mp) hc_clReleaseProgram (device_param->program_mp);
17709 if (device_param->command_queue) hc_clReleaseCommandQueue (device_param->command_queue);
17710 if (device_param->context) hc_clReleaseContext (device_param->context);
17711 #endif
17712 }
17713
17714 #ifdef _OCL
17715 #ifndef OSX
17716
17717 // reset default fan speed
17718
17719 if (gpu_temp_disable == 0)
17720 {
17721 if (gpu_temp_retain != 0)
17722 {
17723 hc_thread_mutex_lock (mux_adl);
17724
17725 for (uint i = 0; i < data.devices_cnt; i++)
17726 {
17727 if (data.hm_device[i].fan_supported == 1)
17728 {
17729 int fanspeed = temp_retain_fanspeed_value[i];
17730
17731 if (fanspeed == -1) continue;
17732
17733 int rc = hm_set_fanspeed_with_device_id (i, fanspeed);
17734
17735 if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", i);
17736 }
17737 }
17738
17739 hc_thread_mutex_unlock (mux_adl);
17740 }
17741 }
17742
17743 // reset power tuning
17744
17745 if (powertune_enable == 1)
17746 {
17747 hc_thread_mutex_lock (mux_adl);
17748
17749 for (uint i = 0; i < data.devices_cnt; i++)
17750 {
17751 if (data.hm_device[i].od_version == 6)
17752 {
17753 // check powertune capabilities first, if not available then skip device
17754
17755 int powertune_supported = 0;
17756
17757 if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK)
17758 {
17759 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
17760
17761 return (-1);
17762 }
17763
17764 if (powertune_supported != 0)
17765 {
17766 // powercontrol settings
17767
17768 if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, od_power_control_status[i])) != ADL_OK)
17769 {
17770 log_info ("ERROR: Failed to restore the ADL PowerControl values");
17771
17772 return (-1);
17773 }
17774
17775 // clocks
17776
17777 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
17778
17779 performance_state->iNumberOfPerformanceLevels = 2;
17780
17781 performance_state->aLevels[0].iEngineClock = od_clock_mem_status[i].state.aLevels[0].iEngineClock;
17782 performance_state->aLevels[1].iEngineClock = od_clock_mem_status[i].state.aLevels[1].iEngineClock;
17783 performance_state->aLevels[0].iMemoryClock = od_clock_mem_status[i].state.aLevels[0].iMemoryClock;
17784 performance_state->aLevels[1].iMemoryClock = od_clock_mem_status[i].state.aLevels[1].iMemoryClock;
17785
17786 if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
17787 {
17788 log_info ("ERROR: Failed to restore ADL performance state");
17789
17790 return (-1);
17791 }
17792
17793 local_free (performance_state);
17794 }
17795 }
17796 }
17797
17798 hc_thread_mutex_unlock (mux_adl);
17799 }
17800
17801 #endif
17802 #endif
17803
17804 if (gpu_temp_disable == 0)
17805 {
17806 #ifdef _CUDA
17807 #ifdef LINUX
17808 hc_NVML_nvmlShutdown ();
17809 #endif
17810
17811 #ifdef WIN
17812 NvAPI_Unload ();
17813 #endif
17814 #endif
17815
17816 #ifdef _OCL
17817 #ifndef OSX
17818 hc_ADL_Main_Control_Destroy (data.hm_dll);
17819
17820 hm_close (data.hm_dll);
17821 #endif
17822 #endif
17823 }
17824
17825 // free memory
17826
17827 local_free (masks);
17828
17829 local_free (dictstat_base);
17830
17831 for (uint pot_pos = 0; pot_pos < pot_cnt; pot_pos++)
17832 {
17833 pot_t *pot_ptr = &pot[pot_pos];
17834
17835 hash_t *hash = &pot_ptr->hash;
17836
17837 local_free (hash->digest);
17838
17839 if (isSalted)
17840 {
17841 local_free (hash->salt);
17842 }
17843 }
17844
17845 local_free (pot);
17846
17847 local_free (all_gpu_rules_cnt);
17848 local_free (all_gpu_rules_buf);
17849
17850 local_free (wl_data->buf);
17851 local_free (wl_data);
17852
17853 local_free (bitmap_s1_a);
17854 local_free (bitmap_s1_b);
17855 local_free (bitmap_s1_c);
17856 local_free (bitmap_s1_d);
17857 local_free (bitmap_s2_a);
17858 local_free (bitmap_s2_b);
17859 local_free (bitmap_s2_c);
17860 local_free (bitmap_s2_d);
17861
17862 #ifdef _OCL
17863 #ifndef OSX
17864 local_free (temp_retain_fanspeed_value);
17865 local_free (od_clock_mem_status);
17866 local_free (od_power_control_status);
17867 #endif
17868 #endif
17869
17870 global_free (devices_param);
17871
17872 global_free (gpu_rules_buf);
17873
17874 global_free (root_css_buf);
17875 global_free (markov_css_buf);
17876
17877 global_free (digests_buf);
17878 global_free (digests_shown);
17879 global_free (digests_shown_tmp);
17880
17881 global_free (salts_buf);
17882 global_free (salts_shown);
17883
17884 global_free (esalts_buf);
17885
17886 global_free (words_progress_done);
17887 global_free (words_progress_rejected);
17888 global_free (words_progress_restored);
17889
17890 if (pot_fp) fclose (pot_fp);
17891
17892 if (data.devices_status == STATUS_QUIT) break;
17893 }
17894
17895 // destroy others mutex
17896
17897 hc_thread_mutex_delete (mux_dispatcher);
17898 hc_thread_mutex_delete (mux_counter);
17899 hc_thread_mutex_delete (mux_display);
17900 hc_thread_mutex_delete (mux_adl);
17901
17902 // free memory
17903
17904 local_free (eff_restore_file);
17905 local_free (new_restore_file);
17906
17907 local_free (rd);
17908
17909 // loopback
17910
17911 local_free (loopback_file);
17912
17913 if (loopback == 1) unlink (loopback_file);
17914
17915 // induction directory
17916
17917 if (induction_dir == NULL)
17918 {
17919 if (attack_mode != ATTACK_MODE_BF)
17920 {
17921 if (rmdir (induction_directory) == -1)
17922 {
17923 if (errno == ENOENT)
17924 {
17925 // good, we can ignore
17926 }
17927 else if (errno == ENOTEMPTY)
17928 {
17929 // good, we can ignore
17930 }
17931 else
17932 {
17933 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
17934
17935 return (-1);
17936 }
17937 }
17938
17939 local_free (induction_directory);
17940 }
17941 }
17942
17943 // outfile-check directory
17944
17945 if (outfile_check_dir == NULL)
17946 {
17947 if (rmdir (outfile_check_directory) == -1)
17948 {
17949 if (errno == ENOENT)
17950 {
17951 // good, we can ignore
17952 }
17953 else if (errno == ENOTEMPTY)
17954 {
17955 // good, we can ignore
17956 }
17957 else
17958 {
17959 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
17960
17961 return (-1);
17962 }
17963 }
17964
17965 local_free (outfile_check_directory);
17966 }
17967
17968 time_t proc_stop;
17969
17970 time (&proc_stop);
17971
17972 logfile_top_uint (proc_start);
17973 logfile_top_uint (proc_stop);
17974
17975 logfile_top_msg ("STOP");
17976
17977 if (quiet == 0) log_info_nn ("Started: %s", ctime (&proc_start));
17978 if (quiet == 0) log_info_nn ("Stopped: %s", ctime (&proc_stop));
17979
17980 if (data.devices_status == STATUS_ABORTED) return 2;
17981 if (data.devices_status == STATUS_QUIT) return 2;
17982 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) return 2;
17983 if (data.devices_status == STATUS_EXHAUSTED) return 1;
17984 if (data.devices_status == STATUS_CRACKED) return 0;
17985
17986 return -1;
17987 }