Initial commit
[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.00";
19 const uint VERSION_BIN = 200;
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 [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 hc_cuMemsetD8 (device_param->c_bfs, 0, device_param->c_bytes);
2699 #endif
2700
2701 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
2702 {
2703 #ifdef _CUDA
2704 hc_cuMemcpyHtoD (device_param->d_pws_buf, device_param->pws_buf, pws_cnt * sizeof (pw_t));
2705 #elif _OCL
2706 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);
2707 #endif
2708 }
2709 else if (data.attack_kern == ATTACK_KERN_COMBI)
2710 {
2711 #ifdef _CUDA
2712 hc_cuMemcpyHtoD (device_param->d_pws_buf, device_param->pws_buf, pws_cnt * sizeof (pw_t));
2713 #elif _OCL
2714 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);
2715 #endif
2716 }
2717 else if (data.attack_kern == ATTACK_KERN_BF)
2718 {
2719 const uint64_t off = device_param->words_off;
2720
2721 device_param->kernel_params_mp_l_buf64[3] = off;
2722
2723 run_kernel_mp (KERN_RUN_MP_L, device_param, pws_cnt);
2724 }
2725
2726 #ifdef _CUDA
2727 hc_cuCtxPopCurrent (&device_param->context);
2728 #endif
2729 }
2730
2731 static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, const uint pws_cnt)
2732 {
2733 const uint gpu_loops = data.gpu_loops;
2734
2735 // init speed timer
2736
2737 uint speed_pos = device_param->speed_pos;
2738
2739 #ifdef _POSIX
2740 if (device_param->timer_speed.tv_sec == 0)
2741 {
2742 hc_timer_set (&device_param->timer_speed);
2743 }
2744 #endif
2745
2746 #ifdef _WIN
2747 if (device_param->timer_speed.QuadPart == 0)
2748 {
2749 hc_timer_set (&device_param->timer_speed);
2750 }
2751 #endif
2752
2753 // find higest password length, this is for optimization stuff
2754
2755 uint highest_pw_len = 0;
2756
2757 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
2758 {
2759 }
2760 else if (data.attack_kern == ATTACK_KERN_COMBI)
2761 {
2762 }
2763 else if (data.attack_kern == ATTACK_KERN_BF)
2764 {
2765 highest_pw_len = device_param->kernel_params_mp_l_buf32[4]
2766 + device_param->kernel_params_mp_l_buf32[5];
2767 }
2768
2769 // bitslice optimization stuff
2770
2771 if (data.attack_mode == ATTACK_MODE_BF)
2772 {
2773 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
2774 {
2775 run_kernel_tb (device_param, pws_cnt);
2776 }
2777 }
2778
2779 // iteration type
2780
2781 uint innerloop_step = 0;
2782 uint innerloop_cnt = 0;
2783
2784 if (data.attack_exec == ATTACK_EXEC_ON_GPU) innerloop_step = gpu_loops;
2785 else innerloop_step = 1;
2786
2787 if (data.attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = data.gpu_rules_cnt;
2788 else if (data.attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = data.combs_cnt;
2789 else if (data.attack_kern == ATTACK_KERN_BF) innerloop_cnt = data.bfs_cnt;
2790
2791 // loop start: most outer loop = salt iteration, then innerloops (if multi)
2792
2793 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
2794 {
2795 while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
2796
2797 if (data.devices_status == STATUS_CRACKED) break;
2798 if (data.devices_status == STATUS_ABORTED) break;
2799 if (data.devices_status == STATUS_QUIT) break;
2800 if (data.devices_status == STATUS_BYPASS) break;
2801
2802 if (data.salts_shown[salt_pos] == 1) continue;
2803
2804 salt_t *salt_buf = &data.salts_buf[salt_pos];
2805
2806 device_param->kernel_params_buf32[24] = salt_pos;
2807 device_param->kernel_params_buf32[28] = salt_buf->digests_cnt;
2808 device_param->kernel_params_buf32[29] = salt_buf->digests_offset;
2809
2810 FILE *combs_fp = device_param->combs_fp;
2811
2812 if (data.attack_mode == ATTACK_MODE_COMBI)
2813 {
2814 rewind (combs_fp);
2815 }
2816
2817 // innerloops
2818
2819 for (uint innerloop_pos = 0; innerloop_pos < innerloop_cnt; innerloop_pos += innerloop_step)
2820 {
2821 while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
2822
2823 if (data.devices_status == STATUS_CRACKED) break;
2824 if (data.devices_status == STATUS_ABORTED) break;
2825 if (data.devices_status == STATUS_QUIT) break;
2826 if (data.devices_status == STATUS_BYPASS) break;
2827
2828 uint innerloop_left = innerloop_cnt - innerloop_pos;
2829
2830 if (innerloop_left > innerloop_step) innerloop_left = innerloop_step;
2831
2832 device_param->innerloop_pos = innerloop_pos;
2833 device_param->innerloop_left = innerloop_left;
2834
2835 device_param->kernel_params_buf32[27] = innerloop_left;
2836
2837 if (innerloop_left == 0) continue;
2838
2839 // initialize amplifiers
2840
2841 if (data.attack_mode == ATTACK_MODE_COMBI)
2842 {
2843 char line_buf[BUFSIZ];
2844
2845 uint i = 0;
2846
2847 while (i < innerloop_left)
2848 {
2849 if (feof (combs_fp)) break;
2850
2851 int line_len = fgetl (combs_fp, line_buf);
2852
2853 if (line_len >= PW_MAX1) continue;
2854
2855 line_len = convert_from_hex (line_buf, line_len);
2856
2857 char *line_buf_new = line_buf;
2858
2859 if (run_rule_engine (data.rule_len_r, data.rule_buf_r))
2860 {
2861 char rule_buf_out[BLOCK_SIZE];
2862
2863 memset (rule_buf_out, 0, sizeof (rule_buf_out));
2864
2865 int rule_len_out = _old_apply_rule (data.rule_buf_r, data.rule_len_r, line_buf, line_len, rule_buf_out);
2866
2867 if (rule_len_out < 0)
2868 {
2869 data.words_progress_rejected[salt_pos] += pw_cnt;
2870
2871 continue;
2872 }
2873
2874 line_len = rule_len_out;
2875
2876 line_buf_new = rule_buf_out;
2877 }
2878
2879 line_len = MIN (line_len, PW_DICTMAX);
2880
2881 char *ptr = (char *) device_param->combs_buf[i].i;
2882
2883 memcpy (ptr, line_buf_new, line_len);
2884
2885 memset (ptr + line_len, 0, PW_DICTMAX1 - line_len);
2886
2887 if (data.opts_type & OPTS_TYPE_PT_UPPER)
2888 {
2889 uppercase (ptr, line_len);
2890 }
2891
2892 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
2893 {
2894 if (data.opts_type & OPTS_TYPE_PT_ADD80)
2895 {
2896 ptr[line_len] = 0x80;
2897 }
2898
2899 if (data.opts_type & OPTS_TYPE_PT_ADD01)
2900 {
2901 ptr[line_len] = 0x01;
2902 }
2903 }
2904
2905 device_param->combs_buf[i].pw_len = line_len;
2906
2907 i++;
2908 }
2909
2910 for (uint j = i; j < innerloop_left; j++)
2911 {
2912 device_param->combs_buf[j].i[0] = 0;
2913 device_param->combs_buf[j].i[1] = 0;
2914 device_param->combs_buf[j].i[2] = 0;
2915 device_param->combs_buf[j].i[3] = 0;
2916 device_param->combs_buf[j].i[4] = 0;
2917 device_param->combs_buf[j].i[5] = 0;
2918 device_param->combs_buf[j].i[6] = 0;
2919 device_param->combs_buf[j].i[7] = 0;
2920
2921 device_param->combs_buf[j].pw_len = 0;
2922 }
2923
2924 innerloop_left = i;
2925 }
2926 else if (data.attack_mode == ATTACK_MODE_BF)
2927 {
2928 uint64_t off = innerloop_pos;
2929
2930 device_param->kernel_params_mp_r_buf64[3] = off;
2931
2932 const uint gpu_vector_width = device_param->gpu_vector_width;
2933
2934 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2935
2936 run_kernel_mp (KERN_RUN_MP_R, device_param, innerloop_left_d);
2937 }
2938 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
2939 {
2940 uint64_t off = innerloop_pos;
2941
2942 device_param->kernel_params_mp_buf64[3] = off;
2943
2944 const uint gpu_vector_width = device_param->gpu_vector_width;
2945
2946 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2947
2948 run_kernel_mp (KERN_RUN_MP, device_param, innerloop_left_d);
2949 }
2950 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
2951 {
2952 uint64_t off = innerloop_pos;
2953
2954 device_param->kernel_params_mp_buf64[3] = off;
2955
2956 const uint gpu_vector_width = device_param->gpu_vector_width;
2957
2958 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2959
2960 run_kernel_mp (KERN_RUN_MP, device_param, innerloop_left_d);
2961 }
2962
2963 // copy amplifiers
2964
2965 #ifdef _CUDA
2966 hc_cuCtxPushCurrent (device_param->context);
2967
2968 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
2969 {
2970 hc_cuMemcpyDtoD (device_param->c_rules, device_param->d_rules + (innerloop_pos * sizeof (gpu_rule_t)), innerloop_left * sizeof (gpu_rule_t));
2971 }
2972 else if (data.attack_mode == ATTACK_MODE_COMBI)
2973 {
2974 hc_cuMemcpyHtoD (device_param->c_combs, device_param->combs_buf, innerloop_left * sizeof (comb_t));
2975 }
2976 else if (data.attack_mode == ATTACK_MODE_BF)
2977 {
2978 hc_cuMemcpyDtoD (device_param->c_bfs, device_param->d_bfs, innerloop_left * sizeof (bf_t));
2979 }
2980 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
2981 {
2982 hc_cuMemcpyDtoD (device_param->c_combs, device_param->d_combs, innerloop_left * sizeof (comb_t));
2983 }
2984 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
2985 {
2986 hc_cuMemcpyDtoD (device_param->c_combs, device_param->d_combs, innerloop_left * sizeof (comb_t));
2987 }
2988
2989 hc_cuCtxPopCurrent (&device_param->context);
2990
2991 #elif _OCL
2992 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
2993 {
2994 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);
2995 }
2996 else if (data.attack_mode == ATTACK_MODE_COMBI)
2997 {
2998 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);
2999 }
3000 else if (data.attack_mode == ATTACK_MODE_BF)
3001 {
3002 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);
3003 }
3004 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
3005 {
3006 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);
3007 }
3008 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
3009 {
3010 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);
3011 }
3012
3013 #endif
3014
3015 if (data.attack_exec == ATTACK_EXEC_ON_GPU)
3016 {
3017 if (data.attack_mode == ATTACK_MODE_BF)
3018 {
3019 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
3020 {
3021 const uint size_tm = 32 * sizeof (bs_word_t);
3022
3023 #ifdef _CUDA
3024 run_kernel_bzero (device_param, device_param->d_tm, size_tm);
3025 #elif _OCL
3026 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
3027 #endif
3028
3029 run_kernel_tm (device_param);
3030
3031 #ifdef _CUDA
3032 hc_cuCtxPushCurrent (device_param->context);
3033
3034 hc_cuMemcpyDtoD (device_param->c_tm, device_param->d_tm, size_tm);
3035
3036 hc_cuCtxPopCurrent (&device_param->context);
3037 #elif _OCL
3038 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL);
3039 #endif
3040 }
3041 }
3042
3043 if (highest_pw_len < 16)
3044 {
3045 run_kernel (KERN_RUN_1, device_param, pws_cnt);
3046 }
3047 else if (highest_pw_len < 32)
3048 {
3049 run_kernel (KERN_RUN_2, device_param, pws_cnt);
3050 }
3051 else
3052 {
3053 run_kernel (KERN_RUN_3, device_param, pws_cnt);
3054 }
3055 }
3056 else
3057 {
3058 run_kernel_amp (device_param, pws_cnt);
3059
3060 run_kernel (KERN_RUN_1, device_param, pws_cnt);
3061
3062 if (data.opts_type & OPTS_TYPE_HOOK12)
3063 {
3064 run_kernel (KERN_RUN_12, device_param, pws_cnt);
3065 }
3066
3067 uint iter = salt_buf->salt_iter;
3068
3069 for (uint loop_pos = 0; loop_pos < iter; loop_pos += gpu_loops)
3070 {
3071 uint loop_left = iter - loop_pos;
3072
3073 loop_left = MIN (loop_left, gpu_loops);
3074
3075 device_param->kernel_params_buf32[25] = loop_pos;
3076 device_param->kernel_params_buf32[26] = loop_left;
3077
3078 run_kernel (KERN_RUN_2, device_param, pws_cnt);
3079
3080 if (data.devices_status == STATUS_CRACKED) break;
3081 if (data.devices_status == STATUS_ABORTED) break;
3082 if (data.devices_status == STATUS_QUIT) break;
3083 }
3084
3085 if (data.opts_type & OPTS_TYPE_HOOK23)
3086 {
3087 run_kernel (KERN_RUN_23, device_param, pws_cnt);
3088
3089 #ifdef _CUDA
3090 hc_cuCtxPushCurrent (device_param->context);
3091
3092 hc_cuMemcpyDtoH (device_param->hooks_buf, device_param->d_hooks, device_param->size_hooks);
3093
3094 hc_cuCtxPopCurrent (&device_param->context);
3095 #elif _OCL
3096 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL);
3097 #endif
3098
3099 // do something with data
3100
3101
3102 #ifdef _CUDA
3103 hc_cuCtxPushCurrent (device_param->context);
3104
3105 hc_cuMemcpyHtoD (device_param->d_hooks, device_param->hooks_buf, device_param->size_hooks);
3106
3107 hc_cuCtxPopCurrent (&device_param->context);
3108 #elif _OCL
3109 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL);
3110 #endif
3111 }
3112
3113 run_kernel (KERN_RUN_3, device_param, pws_cnt);
3114 }
3115
3116 if (data.devices_status == STATUS_CRACKED) break;
3117 if (data.devices_status == STATUS_ABORTED) break;
3118 if (data.devices_status == STATUS_QUIT) break;
3119
3120 /**
3121 * result
3122 */
3123
3124 hc_thread_mutex_lock (mux_display);
3125
3126 check_cracked (device_param, salt_pos);
3127
3128 hc_thread_mutex_unlock (mux_display);
3129
3130 /**
3131 * progress
3132 */
3133
3134 uint64_t perf_sum_all = (uint64_t) pw_cnt * (uint64_t) innerloop_left;
3135
3136 hc_thread_mutex_lock (mux_counter);
3137
3138 data.words_progress_done[salt_pos] += perf_sum_all;
3139
3140 hc_thread_mutex_unlock (mux_counter);
3141
3142 /**
3143 * speed
3144 */
3145
3146 float speed_ms;
3147
3148 hc_timer_get (device_param->timer_speed, speed_ms);
3149
3150 hc_timer_set (&device_param->timer_speed);
3151
3152 hc_thread_mutex_lock (mux_display);
3153
3154 device_param->speed_cnt[speed_pos] = perf_sum_all;
3155
3156 device_param->speed_ms[speed_pos] = speed_ms;
3157
3158 device_param->speed_rec[speed_pos] = device_param->timer_speed;
3159
3160 hc_thread_mutex_unlock (mux_display);
3161
3162 speed_pos++;
3163
3164 if (speed_pos == SPEED_CACHE)
3165 {
3166 speed_pos = 0;
3167 }
3168 }
3169 }
3170
3171 device_param->speed_pos = speed_pos;
3172 }
3173
3174 static void load_segment (wl_data_t *wl_data, FILE *fd)
3175 {
3176 // NOTE: use (never changing) ->incr here instead of ->avail otherwise the buffer gets bigger and bigger
3177
3178 wl_data->pos = 0;
3179
3180 wl_data->cnt = fread (wl_data->buf, 1, wl_data->incr - 1000, fd);
3181
3182 wl_data->buf[wl_data->cnt] = 0;
3183
3184 if (wl_data->cnt == 0) return;
3185
3186 if (wl_data->buf[wl_data->cnt - 1] == '\n') return;
3187
3188 while (!feof (fd))
3189 {
3190 if (wl_data->cnt == wl_data->avail)
3191 {
3192 wl_data->buf = (char *) myrealloc (wl_data->buf, wl_data->avail, wl_data->incr);
3193
3194 wl_data->avail += wl_data->incr;
3195 }
3196
3197 const int c = fgetc (fd);
3198
3199 if (c == EOF) break;
3200
3201 wl_data->buf[wl_data->cnt] = (char) c;
3202
3203 wl_data->cnt++;
3204
3205 if (c == '\n') break;
3206 }
3207
3208 // ensure stream ends with a newline
3209
3210 if (wl_data->buf[wl_data->cnt - 1] != '\n')
3211 {
3212 wl_data->cnt++;
3213
3214 wl_data->buf[wl_data->cnt - 1] = '\n';
3215 }
3216
3217 return;
3218 }
3219
3220 static void get_next_word_lm (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3221 {
3222 char *ptr = buf;
3223
3224 for (uint32_t i = 0; i < sz; i++, ptr++)
3225 {
3226 if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
3227
3228 if (i == 7)
3229 {
3230 *off = i;
3231 *len = i;
3232
3233 return;
3234 }
3235
3236 if (*ptr != '\n') continue;
3237
3238 *off = i + 1;
3239
3240 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3241
3242 *len = i;
3243
3244 return;
3245 }
3246
3247 *off = sz;
3248 *len = sz;
3249 }
3250
3251 static void get_next_word_uc (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3252 {
3253 char *ptr = buf;
3254
3255 for (uint32_t i = 0; i < sz; i++, ptr++)
3256 {
3257 if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
3258
3259 if (*ptr != '\n') continue;
3260
3261 *off = i + 1;
3262
3263 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3264
3265 *len = i;
3266
3267 return;
3268 }
3269
3270 *off = sz;
3271 *len = sz;
3272 }
3273
3274 static void get_next_word_std (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3275 {
3276 char *ptr = buf;
3277
3278 for (uint32_t i = 0; i < sz; i++, ptr++)
3279 {
3280 if (*ptr != '\n') continue;
3281
3282 *off = i + 1;
3283
3284 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3285
3286 *len = i;
3287
3288 return;
3289 }
3290
3291 *off = sz;
3292 *len = sz;
3293 }
3294
3295 static void get_next_word (wl_data_t *wl_data, FILE *fd, char **out_buf, uint *out_len)
3296 {
3297 while (wl_data->pos < wl_data->cnt)
3298 {
3299 uint off;
3300 uint len;
3301
3302 char *ptr = wl_data->buf + wl_data->pos;
3303
3304 get_next_word_func (ptr, wl_data->cnt - wl_data->pos, &len, &off);
3305
3306 wl_data->pos += off;
3307
3308 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3309 {
3310 char rule_buf_out[BLOCK_SIZE];
3311
3312 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3313
3314 int rule_len_out = -1;
3315
3316 if (len < BLOCK_SIZE)
3317 {
3318 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, ptr, len, rule_buf_out);
3319 }
3320
3321 if (rule_len_out < 0)
3322 {
3323 continue;
3324 }
3325
3326 if (rule_len_out > PW_MAX)
3327 {
3328 continue;
3329 }
3330 }
3331 else
3332 {
3333 if (len > PW_MAX)
3334 {
3335 continue;
3336 }
3337 }
3338
3339 *out_buf = ptr;
3340 *out_len = len;
3341
3342 return;
3343 }
3344
3345 if (feof (fd))
3346 {
3347 fprintf (stderr, "bug!!\n");
3348
3349 return;
3350 }
3351
3352 load_segment (wl_data, fd);
3353
3354 get_next_word (wl_data, fd, out_buf, out_len);
3355 }
3356
3357 #ifdef _POSIX
3358 static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, size_t *dictstat_nmemb)
3359 #endif
3360
3361 #ifdef _WIN
3362 static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, uint *dictstat_nmemb)
3363 #endif
3364 {
3365 hc_signal (NULL);
3366
3367 dictstat_t d;
3368
3369 d.cnt = 0;
3370
3371 #ifdef _POSIX
3372 fstat (fileno (fd), &d.stat);
3373 #endif
3374
3375 #ifdef _WIN
3376 _fstat64 (fileno (fd), &d.stat);
3377 #endif
3378
3379 d.stat.st_mode = 0;
3380 d.stat.st_nlink = 0;
3381 d.stat.st_uid = 0;
3382 d.stat.st_gid = 0;
3383 d.stat.st_rdev = 0;
3384 d.stat.st_atime = 0;
3385
3386 #ifdef _POSIX
3387 d.stat.st_blksize = 0;
3388 d.stat.st_blocks = 0;
3389 #endif
3390
3391 if (d.stat.st_size == 0) return 0;
3392
3393 dictstat_t *d_cache = (dictstat_t *) lfind (&d, dictstat_base, dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
3394
3395 if (run_rule_engine (data.rule_len_l, data.rule_buf_l) == 0)
3396 {
3397 if (d_cache)
3398 {
3399 uint64_t cnt = d_cache->cnt;
3400
3401 uint64_t keyspace = cnt;
3402
3403 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
3404 {
3405 keyspace *= data.gpu_rules_cnt;
3406 }
3407 else if (data.attack_kern == ATTACK_KERN_COMBI)
3408 {
3409 keyspace *= data.combs_cnt;
3410 }
3411
3412 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);
3413 if (data.quiet == 0) log_info ("");
3414
3415 hc_signal (sigHandler_default);
3416
3417 return (keyspace);
3418 }
3419 }
3420
3421 time_t now = 0;
3422 time_t prev = 0;
3423
3424 uint64_t comp = 0;
3425 uint64_t cnt = 0;
3426 uint64_t cnt2 = 0;
3427
3428 while (!feof (fd))
3429 {
3430 load_segment (wl_data, fd);
3431
3432 comp += wl_data->cnt;
3433
3434 uint32_t i = 0;
3435
3436 while (i < wl_data->cnt)
3437 {
3438 uint32_t len;
3439 uint32_t off;
3440
3441 get_next_word_func (wl_data->buf + i, wl_data->cnt - i, &len, &off);
3442
3443 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3444 {
3445 char rule_buf_out[BLOCK_SIZE];
3446
3447 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3448
3449 int rule_len_out = -1;
3450
3451 if (len < BLOCK_SIZE)
3452 {
3453 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, wl_data->buf + i, len, rule_buf_out);
3454 }
3455
3456 if (rule_len_out < 0)
3457 {
3458 len = PW_MAX1;
3459 }
3460 else
3461 {
3462 len = rule_len_out;
3463 }
3464 }
3465
3466 if (len < PW_MAX1)
3467 {
3468 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
3469 {
3470 cnt += data.gpu_rules_cnt;
3471 }
3472 else if (data.attack_kern == ATTACK_KERN_COMBI)
3473 {
3474 cnt += data.combs_cnt;
3475 }
3476
3477 d.cnt++;
3478 }
3479
3480 i += off;
3481
3482 cnt2++;
3483 }
3484
3485 time (&now);
3486
3487 if ((now - prev) == 0) continue;
3488
3489 float percent = (float) comp / (float) d.stat.st_size;
3490
3491 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);
3492
3493 time (&prev);
3494 }
3495
3496 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);
3497 if (data.quiet == 0) log_info ("");
3498
3499 lsearch (&d, dictstat_base, dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
3500
3501 hc_signal (sigHandler_default);
3502
3503 return (cnt);
3504 }
3505
3506 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)
3507 {
3508 uint gpu_vector_width = 0;
3509
3510 if ((attack_mode == ATTACK_MODE_BF) && (attack_exec == ATTACK_EXEC_ON_GPU) && (opti_type & OPTI_TYPE_SCALAR_MODE))
3511 {
3512 return VECT_SIZE_1;
3513 }
3514
3515 #ifdef _CUDA
3516 if ((attack_mode == ATTACK_MODE_STRAIGHT) && (attack_exec == ATTACK_EXEC_ON_GPU))
3517 {
3518 return VECT_SIZE_1;
3519 }
3520
3521 if (vliw == 1)
3522 {
3523 switch (hash_mode)
3524 {
3525 default: gpu_vector_width = VECT_SIZE_1; break;
3526 }
3527 }
3528 else if (vliw == 2)
3529 {
3530 switch (hash_mode)
3531 {
3532 case 0: gpu_vector_width = VECT_SIZE_4; break;
3533 case 10: gpu_vector_width = VECT_SIZE_4; break;
3534 case 11: gpu_vector_width = VECT_SIZE_4; break;
3535 case 12: gpu_vector_width = VECT_SIZE_4; break;
3536 case 20: gpu_vector_width = VECT_SIZE_4; break;
3537 case 21: gpu_vector_width = VECT_SIZE_4; break;
3538 case 22: gpu_vector_width = VECT_SIZE_4; break;
3539 case 23: gpu_vector_width = VECT_SIZE_4; break;
3540 case 30: gpu_vector_width = VECT_SIZE_4; break;
3541 case 40: gpu_vector_width = VECT_SIZE_4; break;
3542 case 50: gpu_vector_width = VECT_SIZE_4; break;
3543 case 60: gpu_vector_width = VECT_SIZE_4; break;
3544 case 100: gpu_vector_width = VECT_SIZE_4; break;
3545 case 101: gpu_vector_width = VECT_SIZE_4; break;
3546 case 110: gpu_vector_width = VECT_SIZE_4; break;
3547 case 111: gpu_vector_width = VECT_SIZE_4; break;
3548 case 112: gpu_vector_width = VECT_SIZE_4; break;
3549 case 120: gpu_vector_width = VECT_SIZE_4; break;
3550 case 121: gpu_vector_width = VECT_SIZE_4; break;
3551 case 122: gpu_vector_width = VECT_SIZE_4; break;
3552 case 124: gpu_vector_width = VECT_SIZE_4; break;
3553 case 130: gpu_vector_width = VECT_SIZE_4; break;
3554 case 131: gpu_vector_width = VECT_SIZE_4; break;
3555 case 132: gpu_vector_width = VECT_SIZE_4; break;
3556 case 133: gpu_vector_width = VECT_SIZE_4; break;
3557 case 140: gpu_vector_width = VECT_SIZE_4; break;
3558 case 141: gpu_vector_width = VECT_SIZE_4; break;
3559 case 150: gpu_vector_width = VECT_SIZE_4; break;
3560 case 160: gpu_vector_width = VECT_SIZE_4; break;
3561 case 190: gpu_vector_width = VECT_SIZE_4; break;
3562 case 200: gpu_vector_width = VECT_SIZE_4; break;
3563 case 400: gpu_vector_width = VECT_SIZE_2; break;
3564 case 500: gpu_vector_width = VECT_SIZE_2; break;
3565 case 501: gpu_vector_width = VECT_SIZE_2; break;
3566 case 900: gpu_vector_width = VECT_SIZE_4; break;
3567 case 1000: gpu_vector_width = VECT_SIZE_4; break;
3568 case 1100: gpu_vector_width = VECT_SIZE_4; break;
3569 case 2400: gpu_vector_width = VECT_SIZE_4; break;
3570 case 2410: gpu_vector_width = VECT_SIZE_4; break;
3571 case 2600: gpu_vector_width = VECT_SIZE_4; break;
3572 case 2611: gpu_vector_width = VECT_SIZE_4; break;
3573 case 2612: gpu_vector_width = VECT_SIZE_4; break;
3574 case 2711: gpu_vector_width = VECT_SIZE_4; break;
3575 case 2811: gpu_vector_width = VECT_SIZE_4; break;
3576 case 3710: gpu_vector_width = VECT_SIZE_4; break;
3577 case 3800: gpu_vector_width = VECT_SIZE_4; break;
3578 case 3711: gpu_vector_width = VECT_SIZE_4; break;
3579 case 4300: gpu_vector_width = VECT_SIZE_4; break;
3580 case 4800: gpu_vector_width = VECT_SIZE_4; break;
3581 case 4900: gpu_vector_width = VECT_SIZE_4; break;
3582 case 5100: gpu_vector_width = VECT_SIZE_4; break;
3583 case 9900: gpu_vector_width = VECT_SIZE_4; break;
3584 case 10200: gpu_vector_width = VECT_SIZE_4; break;
3585 case 11000: gpu_vector_width = VECT_SIZE_4; break;
3586 case 11500: gpu_vector_width = VECT_SIZE_4; break;
3587
3588 default: gpu_vector_width = VECT_SIZE_1; break;
3589 }
3590 }
3591 #endif
3592
3593 #ifdef _OCL
3594 if (vliw == 1)
3595 {
3596 switch (hash_mode)
3597 {
3598 default: gpu_vector_width = VECT_SIZE_1; break;
3599 }
3600 }
3601 else if (vliw == 4)
3602 {
3603 switch (hash_mode)
3604 {
3605 case 150: gpu_vector_width = VECT_SIZE_2; break;
3606 case 160: gpu_vector_width = VECT_SIZE_2; break;
3607 case 300: gpu_vector_width = VECT_SIZE_2; break;
3608 case 1400: gpu_vector_width = VECT_SIZE_2; break;
3609 case 1410: gpu_vector_width = VECT_SIZE_2; break;
3610 case 1420: gpu_vector_width = VECT_SIZE_2; break;
3611 case 1421: gpu_vector_width = VECT_SIZE_2; break;
3612 case 1430: gpu_vector_width = VECT_SIZE_2; break;
3613 case 1440: gpu_vector_width = VECT_SIZE_2; break;
3614 case 1441: gpu_vector_width = VECT_SIZE_2; break;
3615 case 1450: gpu_vector_width = VECT_SIZE_1; break;
3616 case 1460: gpu_vector_width = VECT_SIZE_2; break;
3617 case 1500: gpu_vector_width = VECT_SIZE_1; break;
3618 case 1700: gpu_vector_width = VECT_SIZE_1; break;
3619 case 1710: gpu_vector_width = VECT_SIZE_1; break;
3620 case 1711: gpu_vector_width = VECT_SIZE_1; break;
3621 case 1720: gpu_vector_width = VECT_SIZE_1; break;
3622 case 1722: gpu_vector_width = VECT_SIZE_1; break;
3623 case 1730: gpu_vector_width = VECT_SIZE_1; break;
3624 case 1731: gpu_vector_width = VECT_SIZE_1; break;
3625 case 1740: gpu_vector_width = VECT_SIZE_1; break;
3626 case 1750: gpu_vector_width = VECT_SIZE_1; break;
3627 case 1760: gpu_vector_width = VECT_SIZE_1; break;
3628 case 1800: gpu_vector_width = VECT_SIZE_1; break;
3629 case 2100: gpu_vector_width = VECT_SIZE_2; break;
3630 case 2500: gpu_vector_width = VECT_SIZE_2; break;
3631 case 3000: gpu_vector_width = VECT_SIZE_1; break;
3632 case 3100: gpu_vector_width = VECT_SIZE_2; break;
3633 case 3200: gpu_vector_width = VECT_SIZE_1; break;
3634 case 5000: gpu_vector_width = VECT_SIZE_1; break;
3635 case 5200: gpu_vector_width = VECT_SIZE_2; break;
3636 case 5600: gpu_vector_width = VECT_SIZE_2; break;
3637 case 5700: gpu_vector_width = VECT_SIZE_2; break;
3638 case 6100: gpu_vector_width = VECT_SIZE_2; break;
3639 case 6211:
3640 case 6212:
3641 case 6213:
3642 case 6221:
3643 case 6222:
3644 case 6223:
3645 case 6231:
3646 case 6232:
3647 case 6233:
3648 case 6241:
3649 case 6242:
3650 case 6243: gpu_vector_width = VECT_SIZE_1; break;
3651 case 6400: gpu_vector_width = VECT_SIZE_1; break;
3652 case 6500: gpu_vector_width = VECT_SIZE_1; break;
3653 case 6600: gpu_vector_width = VECT_SIZE_1; break;
3654 case 6700: gpu_vector_width = VECT_SIZE_2; break;
3655 case 6800: gpu_vector_width = VECT_SIZE_1; break;
3656 case 6900: gpu_vector_width = VECT_SIZE_1; break;
3657 case 7100: gpu_vector_width = VECT_SIZE_1; break;
3658 case 7200: gpu_vector_width = VECT_SIZE_1; break;
3659 case 7300: gpu_vector_width = VECT_SIZE_1; break;
3660 case 7400: gpu_vector_width = VECT_SIZE_1; break;
3661 case 7500: gpu_vector_width = VECT_SIZE_1; break;
3662 case 7700: gpu_vector_width = VECT_SIZE_1; break;
3663 case 7800: gpu_vector_width = VECT_SIZE_1; break;
3664 case 7900: gpu_vector_width = VECT_SIZE_1; break;
3665 case 8000: gpu_vector_width = VECT_SIZE_2; break;
3666 case 8200: gpu_vector_width = VECT_SIZE_1; break;
3667 case 8500: gpu_vector_width = VECT_SIZE_2; break;
3668 case 8700: gpu_vector_width = VECT_SIZE_2; break;
3669 case 8800: gpu_vector_width = VECT_SIZE_1; break;
3670 case 8900: gpu_vector_width = VECT_SIZE_1; break;
3671 case 9000: gpu_vector_width = VECT_SIZE_1; break;
3672 case 9100: gpu_vector_width = VECT_SIZE_1; break;
3673 case 9200: gpu_vector_width = VECT_SIZE_1; break;
3674 case 9300: gpu_vector_width = VECT_SIZE_1; break;
3675 case 9400: gpu_vector_width = VECT_SIZE_1; break;
3676 case 9500: gpu_vector_width = VECT_SIZE_1; break;
3677 case 9600: gpu_vector_width = VECT_SIZE_1; break;
3678 case 9700: gpu_vector_width = VECT_SIZE_1; break;
3679 case 9710: gpu_vector_width = VECT_SIZE_1; break;
3680 case 9720: gpu_vector_width = VECT_SIZE_2; break;
3681 case 9800: gpu_vector_width = VECT_SIZE_1; break;
3682 case 9810: gpu_vector_width = VECT_SIZE_1; break;
3683 case 9820: gpu_vector_width = VECT_SIZE_2; break;
3684 case 10000: gpu_vector_width = VECT_SIZE_1; break;
3685 case 10100: gpu_vector_width = VECT_SIZE_1; break;
3686 case 10400: gpu_vector_width = VECT_SIZE_1; break;
3687 case 10410: gpu_vector_width = VECT_SIZE_1; break;
3688 case 10420: gpu_vector_width = VECT_SIZE_2; break;
3689 case 10500: gpu_vector_width = VECT_SIZE_1; break;
3690 case 10600: gpu_vector_width = VECT_SIZE_2; break;
3691 case 10700: gpu_vector_width = VECT_SIZE_1; break;
3692 case 10800: gpu_vector_width = VECT_SIZE_1; break;
3693 case 10900: gpu_vector_width = VECT_SIZE_1; break;
3694 case 11100: gpu_vector_width = VECT_SIZE_2; break;
3695 case 11200: gpu_vector_width = VECT_SIZE_2; break;
3696 case 11300: gpu_vector_width = VECT_SIZE_1; break;
3697 case 11400: gpu_vector_width = VECT_SIZE_1; break;
3698 case 11600: gpu_vector_width = VECT_SIZE_1; break;
3699 case 11700: gpu_vector_width = VECT_SIZE_1; break;
3700 case 11800: gpu_vector_width = VECT_SIZE_1; break;
3701 case 11900: gpu_vector_width = VECT_SIZE_1; break;
3702 case 12000: gpu_vector_width = VECT_SIZE_1; break;
3703 case 12100: gpu_vector_width = VECT_SIZE_1; break;
3704 case 12200: gpu_vector_width = VECT_SIZE_1; break;
3705 case 12300: gpu_vector_width = VECT_SIZE_1; break;
3706 case 12500: gpu_vector_width = VECT_SIZE_1; break;
3707 case 12700: gpu_vector_width = VECT_SIZE_1; break;
3708 case 12800: gpu_vector_width = VECT_SIZE_1; break;
3709
3710 default: gpu_vector_width = VECT_SIZE_4; break;
3711 }
3712 }
3713 else if (vliw == 5)
3714 {
3715 switch (hash_mode)
3716 {
3717 case 150: gpu_vector_width = VECT_SIZE_2; break;
3718 case 160: gpu_vector_width = VECT_SIZE_2; break;
3719 case 300: gpu_vector_width = VECT_SIZE_2; break;
3720 case 1400: gpu_vector_width = VECT_SIZE_2; break;
3721 case 1410: gpu_vector_width = VECT_SIZE_2; break;
3722 case 1420: gpu_vector_width = VECT_SIZE_2; break;
3723 case 1421: gpu_vector_width = VECT_SIZE_2; break;
3724 case 1430: gpu_vector_width = VECT_SIZE_2; break;
3725 case 1440: gpu_vector_width = VECT_SIZE_2; break;
3726 case 1441: gpu_vector_width = VECT_SIZE_2; break;
3727 case 1450: gpu_vector_width = VECT_SIZE_1; break;
3728 case 1460: gpu_vector_width = VECT_SIZE_2; break;
3729 case 1500: gpu_vector_width = VECT_SIZE_1; break;
3730 case 1700: gpu_vector_width = VECT_SIZE_1; break;
3731 case 1710: gpu_vector_width = VECT_SIZE_1; break;
3732 case 1711: gpu_vector_width = VECT_SIZE_1; break;
3733 case 1720: gpu_vector_width = VECT_SIZE_1; break;
3734 case 1722: gpu_vector_width = VECT_SIZE_1; break;
3735 case 1730: gpu_vector_width = VECT_SIZE_1; break;
3736 case 1731: gpu_vector_width = VECT_SIZE_1; break;
3737 case 1740: gpu_vector_width = VECT_SIZE_1; break;
3738 case 1750: gpu_vector_width = VECT_SIZE_1; break;
3739 case 1760: gpu_vector_width = VECT_SIZE_1; break;
3740 case 1800: gpu_vector_width = VECT_SIZE_1; break;
3741 case 2100: gpu_vector_width = VECT_SIZE_2; break;
3742 case 2500: gpu_vector_width = VECT_SIZE_2; break;
3743 case 3000: gpu_vector_width = VECT_SIZE_1; break;
3744 case 3100: gpu_vector_width = VECT_SIZE_2; break;
3745 case 3200: gpu_vector_width = VECT_SIZE_1; break;
3746 case 5000: gpu_vector_width = VECT_SIZE_1; break;
3747 case 5200: gpu_vector_width = VECT_SIZE_2; break;
3748 case 5400: gpu_vector_width = VECT_SIZE_2; break;
3749 case 5600: gpu_vector_width = VECT_SIZE_2; break;
3750 case 5700: gpu_vector_width = VECT_SIZE_2; break;
3751 case 6100: gpu_vector_width = VECT_SIZE_2; break;
3752 case 6211:
3753 case 6212:
3754 case 6213:
3755 case 6221:
3756 case 6222:
3757 case 6223:
3758 case 6231:
3759 case 6232:
3760 case 6233:
3761 case 6241:
3762 case 6242:
3763 case 6243: gpu_vector_width = VECT_SIZE_1; break;
3764 case 6400: gpu_vector_width = VECT_SIZE_1; break;
3765 case 6500: gpu_vector_width = VECT_SIZE_1; break;
3766 case 6600: gpu_vector_width = VECT_SIZE_1; break;
3767 case 6700: gpu_vector_width = VECT_SIZE_2; break;
3768 case 6800: gpu_vector_width = VECT_SIZE_1; break;
3769 case 6900: gpu_vector_width = VECT_SIZE_1; break;
3770 case 7100: gpu_vector_width = VECT_SIZE_1; break;
3771 case 7200: gpu_vector_width = VECT_SIZE_1; break;
3772 case 7300: gpu_vector_width = VECT_SIZE_1; break;
3773 case 7400: gpu_vector_width = VECT_SIZE_1; break;
3774 case 7500: gpu_vector_width = VECT_SIZE_1; break;
3775 case 7700: gpu_vector_width = VECT_SIZE_1; break;
3776 case 7800: gpu_vector_width = VECT_SIZE_1; break;
3777 case 7900: gpu_vector_width = VECT_SIZE_1; break;
3778 case 8000: gpu_vector_width = VECT_SIZE_2; break;
3779 case 8200: gpu_vector_width = VECT_SIZE_1; break;
3780 case 8300: gpu_vector_width = VECT_SIZE_2; break;
3781 case 8400: gpu_vector_width = VECT_SIZE_2; break;
3782 case 8500: gpu_vector_width = VECT_SIZE_2; break;
3783 case 8700: gpu_vector_width = VECT_SIZE_2; break;
3784 case 8800: gpu_vector_width = VECT_SIZE_1; break;
3785 case 8900: gpu_vector_width = VECT_SIZE_1; break;
3786 case 9000: gpu_vector_width = VECT_SIZE_1; break;
3787 case 9100: gpu_vector_width = VECT_SIZE_1; break;
3788 case 9200: gpu_vector_width = VECT_SIZE_1; break;
3789 case 9300: gpu_vector_width = VECT_SIZE_1; break;
3790 case 9400: gpu_vector_width = VECT_SIZE_1; break;
3791 case 9500: gpu_vector_width = VECT_SIZE_1; break;
3792 case 9600: gpu_vector_width = VECT_SIZE_1; break;
3793 case 9700: gpu_vector_width = VECT_SIZE_1; break;
3794 case 9710: gpu_vector_width = VECT_SIZE_1; break;
3795 case 9720: gpu_vector_width = VECT_SIZE_2; break;
3796 case 9800: gpu_vector_width = VECT_SIZE_1; break;
3797 case 9810: gpu_vector_width = VECT_SIZE_1; break;
3798 case 9820: gpu_vector_width = VECT_SIZE_2; break;
3799 case 10000: gpu_vector_width = VECT_SIZE_1; break;
3800 case 10100: gpu_vector_width = VECT_SIZE_1; break;
3801 case 10400: gpu_vector_width = VECT_SIZE_1; break;
3802 case 10410: gpu_vector_width = VECT_SIZE_1; break;
3803 case 10420: gpu_vector_width = VECT_SIZE_2; break;
3804 case 10500: gpu_vector_width = VECT_SIZE_1; break;
3805 case 10600: gpu_vector_width = VECT_SIZE_2; break;
3806 case 10700: gpu_vector_width = VECT_SIZE_1; break;
3807 case 10800: gpu_vector_width = VECT_SIZE_1; break;
3808 case 10900: gpu_vector_width = VECT_SIZE_1; break;
3809 case 11100: gpu_vector_width = VECT_SIZE_2; break;
3810 case 11200: gpu_vector_width = VECT_SIZE_2; break;
3811 case 11300: gpu_vector_width = VECT_SIZE_1; break;
3812 case 11400: gpu_vector_width = VECT_SIZE_1; break;
3813 case 11600: gpu_vector_width = VECT_SIZE_1; break;
3814 case 11700: gpu_vector_width = VECT_SIZE_1; break;
3815 case 11800: gpu_vector_width = VECT_SIZE_1; break;
3816 case 11900: gpu_vector_width = VECT_SIZE_1; break;
3817 case 12000: gpu_vector_width = VECT_SIZE_1; break;
3818 case 12100: gpu_vector_width = VECT_SIZE_1; break;
3819 case 12200: gpu_vector_width = VECT_SIZE_1; break;
3820 case 12300: gpu_vector_width = VECT_SIZE_1; break;
3821 case 12500: gpu_vector_width = VECT_SIZE_1; break;
3822 case 12700: gpu_vector_width = VECT_SIZE_1; break;
3823 case 12800: gpu_vector_width = VECT_SIZE_1; break;
3824
3825 default: gpu_vector_width = VECT_SIZE_4; break;
3826 }
3827 }
3828 #endif
3829
3830 return gpu_vector_width;
3831 }
3832
3833 static void pw_transpose_to_hi1 (const pw_t *p1, pw_t *p2)
3834 {
3835 memcpy (p2->hi1, p1->hi1, 64 * sizeof (uint));
3836 }
3837
3838 static void pw_transpose_to_hi2 (const pw_t *p1, pw_t *p2)
3839 {
3840 p2->hi2[0][ 0] = p1->hi2[0][ 0];
3841 p2->hi2[0][ 2] = p1->hi2[0][ 1];
3842 p2->hi2[0][ 4] = p1->hi2[0][ 2];
3843 p2->hi2[0][ 6] = p1->hi2[0][ 3];
3844 p2->hi2[0][ 8] = p1->hi2[0][ 4];
3845 p2->hi2[0][10] = p1->hi2[0][ 5];
3846 p2->hi2[0][12] = p1->hi2[0][ 6];
3847 p2->hi2[0][14] = p1->hi2[0][ 7];
3848 p2->hi2[0][16] = p1->hi2[0][ 8];
3849 p2->hi2[0][18] = p1->hi2[0][ 9];
3850 p2->hi2[0][20] = p1->hi2[0][10];
3851 p2->hi2[0][22] = p1->hi2[0][11];
3852 p2->hi2[0][24] = p1->hi2[0][12];
3853 p2->hi2[0][26] = p1->hi2[0][13];
3854 p2->hi2[0][28] = p1->hi2[0][14];
3855 p2->hi2[0][30] = p1->hi2[0][15];
3856 p2->hi2[1][ 0] = p1->hi2[0][16];
3857 p2->hi2[1][ 2] = p1->hi2[0][17];
3858 p2->hi2[1][ 4] = p1->hi2[0][18];
3859 p2->hi2[1][ 6] = p1->hi2[0][19];
3860 p2->hi2[1][ 8] = p1->hi2[0][20];
3861 p2->hi2[1][10] = p1->hi2[0][21];
3862 p2->hi2[1][12] = p1->hi2[0][22];
3863 p2->hi2[1][14] = p1->hi2[0][23];
3864 p2->hi2[1][16] = p1->hi2[0][24];
3865 p2->hi2[1][18] = p1->hi2[0][25];
3866 p2->hi2[1][20] = p1->hi2[0][26];
3867 p2->hi2[1][22] = p1->hi2[0][27];
3868 p2->hi2[1][24] = p1->hi2[0][28];
3869 p2->hi2[1][26] = p1->hi2[0][29];
3870 p2->hi2[1][28] = p1->hi2[0][30];
3871 p2->hi2[1][30] = p1->hi2[0][31];
3872
3873 p2->hi2[0][ 1] = p1->hi2[1][ 0];
3874 p2->hi2[0][ 3] = p1->hi2[1][ 1];
3875 p2->hi2[0][ 5] = p1->hi2[1][ 2];
3876 p2->hi2[0][ 7] = p1->hi2[1][ 3];
3877 p2->hi2[0][ 9] = p1->hi2[1][ 4];
3878 p2->hi2[0][11] = p1->hi2[1][ 5];
3879 p2->hi2[0][13] = p1->hi2[1][ 6];
3880 p2->hi2[0][15] = p1->hi2[1][ 7];
3881 p2->hi2[0][17] = p1->hi2[1][ 8];
3882 p2->hi2[0][19] = p1->hi2[1][ 9];
3883 p2->hi2[0][21] = p1->hi2[1][10];
3884 p2->hi2[0][23] = p1->hi2[1][11];
3885 p2->hi2[0][25] = p1->hi2[1][12];
3886 p2->hi2[0][27] = p1->hi2[1][13];
3887 p2->hi2[0][29] = p1->hi2[1][14];
3888 p2->hi2[0][31] = p1->hi2[1][15];
3889 p2->hi2[1][ 1] = p1->hi2[1][16];
3890 p2->hi2[1][ 3] = p1->hi2[1][17];
3891 p2->hi2[1][ 5] = p1->hi2[1][18];
3892 p2->hi2[1][ 7] = p1->hi2[1][19];
3893 p2->hi2[1][ 9] = p1->hi2[1][20];
3894 p2->hi2[1][11] = p1->hi2[1][21];
3895 p2->hi2[1][13] = p1->hi2[1][22];
3896 p2->hi2[1][15] = p1->hi2[1][23];
3897 p2->hi2[1][17] = p1->hi2[1][24];
3898 p2->hi2[1][19] = p1->hi2[1][25];
3899 p2->hi2[1][21] = p1->hi2[1][26];
3900 p2->hi2[1][23] = p1->hi2[1][27];
3901 p2->hi2[1][25] = p1->hi2[1][28];
3902 p2->hi2[1][27] = p1->hi2[1][29];
3903 p2->hi2[1][29] = p1->hi2[1][30];
3904 p2->hi2[1][31] = p1->hi2[1][31];
3905 }
3906
3907 static void pw_transpose_to_hi4 (const pw_t *p1, pw_t *p2)
3908 {
3909 p2->hi4[0][ 0] = p1->hi4[0][ 0];
3910 p2->hi4[0][ 4] = p1->hi4[0][ 1];
3911 p2->hi4[0][ 8] = p1->hi4[0][ 2];
3912 p2->hi4[0][12] = p1->hi4[0][ 3];
3913 p2->hi4[1][ 0] = p1->hi4[0][ 4];
3914 p2->hi4[1][ 4] = p1->hi4[0][ 5];
3915 p2->hi4[1][ 8] = p1->hi4[0][ 6];
3916 p2->hi4[1][12] = p1->hi4[0][ 7];
3917 p2->hi4[2][ 0] = p1->hi4[0][ 8];
3918 p2->hi4[2][ 4] = p1->hi4[0][ 9];
3919 p2->hi4[2][ 8] = p1->hi4[0][10];
3920 p2->hi4[2][12] = p1->hi4[0][11];
3921 p2->hi4[3][ 0] = p1->hi4[0][12];
3922 p2->hi4[3][ 4] = p1->hi4[0][13];
3923 p2->hi4[3][ 8] = p1->hi4[0][14];
3924 p2->hi4[3][12] = p1->hi4[0][15];
3925
3926 p2->hi4[0][ 1] = p1->hi4[1][ 0];
3927 p2->hi4[0][ 5] = p1->hi4[1][ 1];
3928 p2->hi4[0][ 9] = p1->hi4[1][ 2];
3929 p2->hi4[0][13] = p1->hi4[1][ 3];
3930 p2->hi4[1][ 1] = p1->hi4[1][ 4];
3931 p2->hi4[1][ 5] = p1->hi4[1][ 5];
3932 p2->hi4[1][ 9] = p1->hi4[1][ 6];
3933 p2->hi4[1][13] = p1->hi4[1][ 7];
3934 p2->hi4[2][ 1] = p1->hi4[1][ 8];
3935 p2->hi4[2][ 5] = p1->hi4[1][ 9];
3936 p2->hi4[2][ 9] = p1->hi4[1][10];
3937 p2->hi4[2][13] = p1->hi4[1][11];
3938 p2->hi4[3][ 1] = p1->hi4[1][12];
3939 p2->hi4[3][ 5] = p1->hi4[1][13];
3940 p2->hi4[3][ 9] = p1->hi4[1][14];
3941 p2->hi4[3][13] = p1->hi4[1][15];
3942
3943 p2->hi4[0][ 2] = p1->hi4[2][ 0];
3944 p2->hi4[0][ 6] = p1->hi4[2][ 1];
3945 p2->hi4[0][10] = p1->hi4[2][ 2];
3946 p2->hi4[0][14] = p1->hi4[2][ 3];
3947 p2->hi4[1][ 2] = p1->hi4[2][ 4];
3948 p2->hi4[1][ 6] = p1->hi4[2][ 5];
3949 p2->hi4[1][10] = p1->hi4[2][ 6];
3950 p2->hi4[1][14] = p1->hi4[2][ 7];
3951 p2->hi4[2][ 2] = p1->hi4[2][ 8];
3952 p2->hi4[2][ 6] = p1->hi4[2][ 9];
3953 p2->hi4[2][10] = p1->hi4[2][10];
3954 p2->hi4[2][14] = p1->hi4[2][11];
3955 p2->hi4[3][ 2] = p1->hi4[2][12];
3956 p2->hi4[3][ 6] = p1->hi4[2][13];
3957 p2->hi4[3][10] = p1->hi4[2][14];
3958 p2->hi4[3][14] = p1->hi4[2][15];
3959
3960 p2->hi4[0][ 3] = p1->hi4[3][ 0];
3961 p2->hi4[0][ 7] = p1->hi4[3][ 1];
3962 p2->hi4[0][11] = p1->hi4[3][ 2];
3963 p2->hi4[0][15] = p1->hi4[3][ 3];
3964 p2->hi4[1][ 3] = p1->hi4[3][ 4];
3965 p2->hi4[1][ 7] = p1->hi4[3][ 5];
3966 p2->hi4[1][11] = p1->hi4[3][ 6];
3967 p2->hi4[1][15] = p1->hi4[3][ 7];
3968 p2->hi4[2][ 3] = p1->hi4[3][ 8];
3969 p2->hi4[2][ 7] = p1->hi4[3][ 9];
3970 p2->hi4[2][11] = p1->hi4[3][10];
3971 p2->hi4[2][15] = p1->hi4[3][11];
3972 p2->hi4[3][ 3] = p1->hi4[3][12];
3973 p2->hi4[3][ 7] = p1->hi4[3][13];
3974 p2->hi4[3][11] = p1->hi4[3][14];
3975 p2->hi4[3][15] = p1->hi4[3][15];
3976 }
3977
3978 static uint pw_add_to_hc1 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
3979 {
3980 if (data.devices_status == STATUS_BYPASS) return 0;
3981
3982 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
3983
3984 uint cache_cnt = pw_cache->cnt;
3985
3986 uint8_t *pw_hc1 = pw_cache->pw_buf.hc1[cache_cnt];
3987
3988 memcpy (pw_hc1, pw_buf, pw_len);
3989
3990 memset (pw_hc1 + pw_len, 0, 256 - pw_len);
3991
3992 uint pws_cnt = device_param->pws_cnt;
3993
3994 cache_cnt++;
3995
3996 if (cache_cnt == VECT_SIZE_1)
3997 {
3998 pw_t *pw = device_param->pws_buf + pws_cnt;
3999
4000 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4001
4002 pw->pw_len = pw_len;
4003
4004 pws_cnt++;
4005
4006 device_param->pws_cnt = pws_cnt;
4007 device_param->pw_cnt = pws_cnt * 1;
4008
4009 cache_cnt = 0;
4010 }
4011
4012 pw_cache->cnt = cache_cnt;
4013
4014 return pws_cnt;
4015 }
4016
4017 static uint pw_add_to_hc2 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
4018 {
4019 if (data.devices_status == STATUS_BYPASS) return 0;
4020
4021 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
4022
4023 uint cache_cnt = pw_cache->cnt;
4024
4025 uint8_t *pw_hc2 = pw_cache->pw_buf.hc2[cache_cnt];
4026
4027 memcpy (pw_hc2, pw_buf, pw_len);
4028
4029 memset (pw_hc2 + pw_len, 0, 128 - pw_len);
4030
4031 uint pws_cnt = device_param->pws_cnt;
4032
4033 cache_cnt++;
4034
4035 if (cache_cnt == VECT_SIZE_2)
4036 {
4037 pw_t *pw = device_param->pws_buf + pws_cnt;
4038
4039 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4040
4041 pw->pw_len = pw_len;
4042
4043 pws_cnt++;
4044
4045 device_param->pws_cnt = pws_cnt;
4046 device_param->pw_cnt = pws_cnt * 2;
4047
4048 cache_cnt = 0;
4049 }
4050
4051 pw_cache->cnt = cache_cnt;
4052
4053 return pws_cnt;
4054 }
4055
4056 static uint pw_add_to_hc4 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
4057 {
4058 if (data.devices_status == STATUS_BYPASS) return 0;
4059
4060 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
4061
4062 uint cache_cnt = pw_cache->cnt;
4063
4064 uint8_t *pw_hc4 = pw_cache->pw_buf.hc4[cache_cnt];
4065
4066 memcpy (pw_hc4, pw_buf, pw_len);
4067
4068 memset (pw_hc4 + pw_len, 0, 64 - pw_len);
4069
4070 uint pws_cnt = device_param->pws_cnt;
4071
4072 cache_cnt++;
4073
4074 if (cache_cnt == VECT_SIZE_4)
4075 {
4076 pw_t *pw = device_param->pws_buf + pws_cnt;
4077
4078 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4079
4080 pw->pw_len = pw_len;
4081
4082 pws_cnt++;
4083
4084 device_param->pws_cnt = pws_cnt;
4085 device_param->pw_cnt = pws_cnt * 4;
4086
4087 cache_cnt = 0;
4088 }
4089
4090 pw_cache->cnt = cache_cnt;
4091
4092 return pws_cnt;
4093 }
4094
4095 static void *thread_monitor (void *p)
4096 {
4097 uint runtime_check = 0;
4098 uint remove_check = 0;
4099 uint status_check = 0;
4100 uint hwmon_check = 0;
4101 uint restore_check = 0;
4102
4103 uint restore_left = data.restore_timer;
4104 uint remove_left = data.remove_timer;
4105 uint status_left = data.status_timer;
4106
4107 #ifdef _OCL
4108 #ifndef OSX
4109
4110 int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
4111
4112 // temperature controller "loopback" values
4113
4114 int *temp_diff_old = (int *) mycalloc (data.devices_cnt, sizeof (int));
4115 int *temp_diff_sum = (int *) mycalloc (data.devices_cnt, sizeof (int));
4116
4117 int temp_threshold = 1; // degrees celcius
4118
4119 int fan_speed_min = 15; // in percentage
4120 int fan_speed_max = 100;
4121
4122 time_t last_temp_check_time;
4123
4124 #endif
4125 #endif
4126
4127 uint sleep_time = 1;
4128
4129 if (data.runtime)
4130 runtime_check = 1;
4131
4132 if (data.restore_timer)
4133 restore_check = 1;
4134
4135 if ((data.remove == 1) && (data.hashlist_mode == HL_MODE_FILE))
4136 remove_check = 1;
4137
4138 if (data.status == 1)
4139 status_check = 1;
4140
4141 if (data.gpu_temp_disable == 0)
4142 {
4143 #ifdef _OCL
4144 #ifndef OSX
4145 time (&last_temp_check_time);
4146 #endif
4147 #endif
4148
4149 hwmon_check = 1;
4150 }
4151
4152 if ((runtime_check == 0) && (remove_check == 0) && (status_check == 0) && (hwmon_check == 0) && (restore_check == 0))
4153 {
4154 return (p);
4155 }
4156
4157 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4158 {
4159 hc_sleep (sleep_time);
4160
4161 if (data.devices_status != STATUS_RUNNING) continue;
4162
4163 if (hwmon_check == 1)
4164 {
4165 hc_thread_mutex_lock (mux_adl);
4166
4167 #ifdef _OCL
4168 #ifndef OSX
4169
4170 time_t temp_check_time;
4171
4172 time (&temp_check_time);
4173
4174 uint Ta = temp_check_time - last_temp_check_time; // set Ta = sleep_time; is not good enough (see --remove etc)
4175
4176 if (Ta == 0) Ta = 1;
4177
4178 #endif
4179 #endif
4180
4181 for (uint i = 0; i < data.devices_cnt; i++)
4182 {
4183 const int temperature = hm_get_temperature_with_device_id (i);
4184
4185 if (temperature > (int) data.gpu_temp_abort)
4186 {
4187 log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", i + 1);
4188
4189 if (data.devices_status != STATUS_QUIT) myabort ();
4190
4191 break;
4192 }
4193
4194 #ifdef _OCL
4195 #ifndef OSX
4196
4197 const int gpu_temp_retain = data.gpu_temp_retain;
4198
4199 if (gpu_temp_retain)
4200 {
4201 if (data.hm_device[i].fan_supported == 1)
4202 {
4203 int temp_cur = temperature;
4204
4205 int temp_diff_new = gpu_temp_retain - temp_cur;
4206
4207 temp_diff_sum[i] = temp_diff_sum[i] + temp_diff_new;
4208
4209 // calculate Ta value (time difference in seconds between the last check and this check)
4210
4211 last_temp_check_time = temp_check_time;
4212
4213 float Kp = 1.8;
4214 float Ki = 0.005;
4215 float Kd = 6;
4216
4217 // PID controller (3-term controller: proportional - Kp, integral - Ki, derivative - Kd)
4218
4219 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);
4220
4221 if (abs (fan_diff_required) >= temp_threshold)
4222 {
4223 const int fan_speed_cur = hm_get_fanspeed_with_device_id (i);
4224
4225 int fan_speed_level = fan_speed_cur;
4226
4227 if (fan_speed_chgd[i] == 0) fan_speed_level = temp_cur;
4228
4229 int fan_speed_new = fan_speed_level - fan_diff_required;
4230
4231 if (fan_speed_new > fan_speed_max) fan_speed_new = fan_speed_max;
4232 if (fan_speed_new < fan_speed_min) fan_speed_new = fan_speed_min;
4233
4234 if (fan_speed_new != fan_speed_cur)
4235 {
4236 int freely_change_fan_speed = (fan_speed_chgd[i] == 1);
4237 int fan_speed_must_change = (fan_speed_new > fan_speed_cur);
4238
4239 if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1))
4240 {
4241 hm_set_fanspeed_with_device_id (i, fan_speed_new);
4242
4243 fan_speed_chgd[i] = 1;
4244 }
4245
4246 temp_diff_old[i] = temp_diff_new;
4247 }
4248 }
4249 }
4250 }
4251
4252 #endif
4253 #endif
4254 }
4255
4256 hc_thread_mutex_unlock (mux_adl);
4257 }
4258
4259 if (restore_check == 1)
4260 {
4261 restore_left--;
4262
4263 if (restore_left == 0)
4264 {
4265 if (data.restore_disable == 0) cycle_restore ();
4266
4267 restore_left = data.restore_timer;
4268 }
4269 }
4270
4271 if ((runtime_check == 1) && (data.runtime_start > 0))
4272 {
4273 time_t runtime_cur;
4274
4275 time (&runtime_cur);
4276
4277 int runtime_left = data.runtime_start + data.runtime - runtime_cur;
4278
4279 if (runtime_left <= 0)
4280 {
4281 if (data.benchmark == 0)
4282 {
4283 if (data.quiet == 0) log_info ("\nNOTE: Runtime limit reached, aborting...\n");
4284 }
4285
4286 if (data.devices_status != STATUS_QUIT) myabort ();
4287 }
4288 }
4289
4290 if (remove_check == 1)
4291 {
4292 remove_left--;
4293
4294 if (remove_left == 0)
4295 {
4296 if (data.digests_saved != data.digests_done)
4297 {
4298 data.digests_saved = data.digests_done;
4299
4300 save_hash ();
4301 }
4302
4303 remove_left = data.remove_timer;
4304 }
4305 }
4306
4307 if (status_check == 1)
4308 {
4309 status_left--;
4310
4311 if (status_left == 0)
4312 {
4313 hc_thread_mutex_lock (mux_display);
4314
4315 if (data.quiet == 0) clear_prompt ();
4316
4317 if (data.quiet == 0) log_info ("");
4318
4319 status_display ();
4320
4321 if (data.quiet == 0) log_info ("");
4322
4323 hc_thread_mutex_unlock (mux_display);
4324
4325 status_left = data.status_timer;
4326 }
4327 }
4328 }
4329
4330 #ifdef _OCL
4331 #ifndef OSX
4332 myfree (fan_speed_chgd);
4333
4334 myfree (temp_diff_old);
4335 myfree (temp_diff_sum);
4336 #endif
4337 #endif
4338
4339 p = NULL;
4340
4341 return (p);
4342 }
4343
4344 static void *thread_outfile_remove (void *p)
4345 {
4346 // some hash-dependent constants
4347 char *outfile_dir = data.outfile_check_directory;
4348 uint dgst_size = data.dgst_size;
4349 uint isSalted = data.isSalted;
4350 uint esalt_size = data.esalt_size;
4351 uint hash_mode = data.hash_mode;
4352
4353 uint outfile_check_timer = data.outfile_check_timer;
4354
4355 char separator = data.separator;
4356
4357 // some hash-dependent functions
4358 int (*sort_by_digest) (const void *, const void *) = data.sort_by_digest;
4359 int (*parse_func) (char *, uint, hash_t *) = data.parse_func;
4360
4361 // buffers
4362 hash_t hash_buf;
4363
4364 memset (&hash_buf, 0, sizeof (hash_buf));
4365
4366 hash_buf.digest = mymalloc (dgst_size);
4367
4368 if (isSalted) hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
4369
4370 if (esalt_size) hash_buf.esalt = (void *) mymalloc (esalt_size);
4371
4372 uint digest_buf[64];
4373
4374 outfile_data_t *out_info = NULL;
4375
4376 char **out_files = NULL;
4377
4378 time_t folder_mtime = 0;
4379
4380 int out_cnt = 0;
4381
4382 uint check_left = outfile_check_timer; // or 1 if we want to check it at startup
4383
4384 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4385 {
4386 hc_sleep (1);
4387
4388 if (data.devices_status != STATUS_RUNNING) continue;
4389
4390 check_left--;
4391
4392 if (check_left == 0)
4393 {
4394 struct stat outfile_check_stat;
4395
4396 if (stat (outfile_dir, &outfile_check_stat) == 0)
4397 {
4398 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
4399
4400 if (is_dir == 1)
4401 {
4402 if (outfile_check_stat.st_mtime > folder_mtime)
4403 {
4404 char **out_files_new = scan_directory (outfile_dir);
4405
4406 int out_cnt_new = count_dictionaries (out_files_new);
4407
4408 outfile_data_t *out_info_new = NULL;
4409
4410 if (out_cnt_new > 0)
4411 {
4412 out_info_new = (outfile_data_t *) mycalloc (out_cnt_new, sizeof (outfile_data_t));
4413
4414 for (int i = 0; i < out_cnt_new; i++)
4415 {
4416 out_info_new[i].file_name = out_files_new[i];
4417
4418 // check if there are files that we have seen/checked before (and not changed)
4419
4420 for (int j = 0; j < out_cnt; j++)
4421 {
4422 if (strcmp (out_info[j].file_name, out_info_new[i].file_name) == 0)
4423 {
4424 struct stat outfile_stat;
4425
4426 if (stat (out_info_new[i].file_name, &outfile_stat) == 0)
4427 {
4428 if (outfile_stat.st_ctime == out_info[j].ctime)
4429 {
4430 out_info_new[i].ctime = out_info[j].ctime;
4431 out_info_new[i].seek = out_info[j].seek;
4432 }
4433 }
4434 }
4435 }
4436 }
4437 }
4438
4439 local_free (out_info);
4440 local_free (out_files);
4441
4442 out_files = out_files_new;
4443 out_cnt = out_cnt_new;
4444 out_info = out_info_new;
4445
4446 folder_mtime = outfile_check_stat.st_mtime;
4447 }
4448
4449 for (int j = 0; j < out_cnt; j++)
4450 {
4451 FILE *fp = fopen (out_info[j].file_name, "rb");
4452
4453 if (fp != NULL)
4454 {
4455 //hc_thread_mutex_lock (mux_display);
4456
4457 #ifdef _POSIX
4458 struct stat outfile_stat;
4459
4460 fstat (fileno (fp), &outfile_stat);
4461 #endif
4462
4463 #ifdef _WIN
4464 struct stat64 outfile_stat;
4465
4466 _fstat64 (fileno (fp), &outfile_stat);
4467 #endif
4468
4469 if (outfile_stat.st_ctime > out_info[j].ctime)
4470 {
4471 out_info[j].ctime = outfile_stat.st_ctime;
4472 out_info[j].seek = 0;
4473 }
4474
4475 fseek (fp, out_info[j].seek, SEEK_SET);
4476
4477 while (!feof (fp))
4478 {
4479 char line_buf[BUFSIZ];
4480
4481 memset (line_buf, 0, BUFSIZ);
4482
4483 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
4484
4485 if (ptr == NULL) break;
4486
4487 int line_len = strlen (line_buf);
4488
4489 if (line_len <= 0) continue;
4490
4491 int iter = MAX_CUT_TRIES;
4492
4493 for (uint i = line_len - 1; i && iter; i--, line_len--)
4494 {
4495 if (line_buf[i] != separator) continue;
4496
4497 int parser_status = PARSER_OK;
4498
4499 if ((hash_mode != 2500) && (hash_mode != 6800))
4500 {
4501 parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
4502 }
4503
4504 uint found = 0;
4505
4506 if (parser_status == PARSER_OK)
4507 {
4508 for (uint salt_pos = 0; (found == 0) && (salt_pos < data.salts_cnt); salt_pos++)
4509 {
4510 if (data.salts_shown[salt_pos] == 1) continue;
4511
4512 salt_t *salt_buf = &data.salts_buf[salt_pos];
4513
4514 for (uint digest_pos = 0; (found == 0) && (digest_pos < salt_buf->digests_cnt); digest_pos++)
4515 {
4516 uint idx = salt_buf->digests_offset + digest_pos;
4517
4518 if (data.digests_shown[idx] == 1) continue;
4519
4520 uint cracked = 0;
4521
4522 if (hash_mode == 6800)
4523 {
4524 if (i == salt_buf->salt_len)
4525 {
4526 cracked = (memcmp (line_buf, salt_buf->salt_buf, salt_buf->salt_len) == 0);
4527 }
4528 }
4529 else if (hash_mode == 2500)
4530 {
4531 // BSSID : MAC1 : MAC2 (:plain)
4532 if (i == (salt_buf->salt_len + 1 + 12 + 1 + 12))
4533 {
4534 cracked = (memcmp (line_buf, salt_buf->salt_buf, salt_buf->salt_len) == 0);
4535
4536 if (!cracked) continue;
4537
4538 // now compare MAC1 and MAC2 too, since we have this additional info
4539 char *mac1_pos = line_buf + salt_buf->salt_len + 1;
4540 char *mac2_pos = mac1_pos + 12 + 1;
4541
4542 wpa_t *wpas = (wpa_t *) data.esalts_buf;
4543 wpa_t *wpa = &wpas[salt_pos];
4544
4545 uint pke[25];
4546
4547 char *pke_ptr = (char *) pke;
4548
4549 for (uint i = 0; i < 25; i++)
4550 {
4551 pke[i] = byte_swap_32 (wpa->pke[i]);
4552 }
4553
4554 unsigned char mac1[6];
4555 unsigned char mac2[6];
4556
4557 memcpy (mac1, pke_ptr + 23, 6);
4558 memcpy (mac2, pke_ptr + 29, 6);
4559
4560 // compare hex string(s) vs binary MAC address(es)
4561
4562 for (uint i = 0, j = 0; i < 6; i++, j += 2)
4563 {
4564 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
4565 {
4566 cracked = 0;
4567 break;
4568 }
4569 }
4570
4571 // early skip ;)
4572 if (!cracked) continue;
4573
4574 for (uint i = 0, j = 0; i < 6; i++, j += 2)
4575 {
4576 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
4577 {
4578 cracked = 0;
4579 break;
4580 }
4581 }
4582 }
4583 }
4584 else
4585 {
4586 char *digests_buf_ptr = (char *) data.digests_buf;
4587
4588 memcpy (digest_buf, digests_buf_ptr + (data.salts_buf[salt_pos].digests_offset * dgst_size) + (digest_pos * dgst_size), dgst_size);
4589
4590 cracked = (sort_by_digest (digest_buf, hash_buf.digest) == 0);
4591 }
4592
4593 if (cracked == 1)
4594 {
4595 found = 1;
4596
4597 data.digests_shown[idx] = 1;
4598
4599 data.digests_done++;
4600
4601 salt_buf->digests_done++;
4602
4603 if (salt_buf->digests_done == salt_buf->digests_cnt)
4604 {
4605 data.salts_shown[salt_pos] = 1;
4606
4607 data.salts_done++;
4608
4609 if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
4610 }
4611 }
4612 }
4613
4614 if (data.devices_status == STATUS_CRACKED) break;
4615 }
4616 }
4617
4618 if (found) break;
4619
4620 if (data.devices_status == STATUS_CRACKED) break;
4621
4622 iter--;
4623 }
4624
4625 if (data.devices_status == STATUS_CRACKED) break;
4626 }
4627
4628 out_info[j].seek = ftell (fp);
4629
4630 //hc_thread_mutex_unlock (mux_display);
4631
4632 fclose (fp);
4633 }
4634 }
4635 }
4636 }
4637
4638 check_left = outfile_check_timer;
4639 }
4640 }
4641
4642 if (esalt_size) local_free (hash_buf.esalt);
4643
4644 if (isSalted) local_free (hash_buf.salt);
4645
4646 local_free (hash_buf.digest);
4647
4648 local_free (out_info);
4649
4650 local_free (out_files);
4651
4652 p = NULL;
4653
4654 return (p);
4655 }
4656
4657 static uint get_work (hc_device_param_t *device_param, const uint64_t max)
4658 {
4659 hc_thread_mutex_lock (mux_dispatcher);
4660
4661 const uint64_t words_cur = data.words_cur;
4662 const uint64_t words_base = (data.limit == 0) ? data.words_base : data.limit;
4663
4664 device_param->words_off = words_cur;
4665
4666 const uint64_t words_left = words_base - words_cur;
4667
4668 if (data.gpu_blocks_all > words_left)
4669 {
4670 if (data.gpu_blocks_div == 0)
4671 {
4672 data.gpu_blocks_div = find_gpu_blocks_div (words_left, data.gpu_blocks_all);
4673 }
4674 }
4675
4676 if (data.gpu_blocks_div)
4677 {
4678 if (device_param->gpu_blocks == device_param->gpu_blocks_user)
4679 {
4680 const uint32_t gpu_blocks_new = (float) device_param->gpu_blocks * data.gpu_blocks_div;
4681 const uint32_t gpu_power_new = gpu_blocks_new / device_param->gpu_vector_width;
4682
4683 if (gpu_blocks_new < device_param->gpu_blocks)
4684 {
4685 device_param->gpu_blocks = gpu_blocks_new;
4686 device_param->gpu_power = gpu_power_new;
4687 }
4688 }
4689 }
4690
4691 const uint gpu_blocks = device_param->gpu_blocks;
4692
4693 uint work = MIN (words_left, gpu_blocks);
4694
4695 work = MIN (work, max);
4696
4697 data.words_cur += work;
4698
4699 hc_thread_mutex_unlock (mux_dispatcher);
4700
4701 return work;
4702 }
4703
4704 static void *thread_calc_stdin (void *p)
4705 {
4706 hc_device_param_t *device_param = (hc_device_param_t *) p;
4707
4708 const uint attack_kern = data.attack_kern;
4709
4710 const uint gpu_blocks = device_param->gpu_blocks;
4711
4712 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4713 {
4714 hc_thread_mutex_lock (mux_dispatcher);
4715
4716 if (feof (stdin) != 0)
4717 {
4718 hc_thread_mutex_unlock (mux_dispatcher);
4719
4720 break;
4721 }
4722
4723 uint words_cur = 0;
4724
4725 while (words_cur < gpu_blocks)
4726 {
4727 char buf[BUFSIZ];
4728
4729 char *line_buf = fgets (buf, sizeof (buf), stdin);
4730
4731 if (line_buf == NULL) break;
4732
4733 uint line_len = in_superchop (line_buf);
4734
4735 line_len = convert_from_hex (line_buf, line_len);
4736
4737 // post-process rule engine
4738
4739 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
4740 {
4741 char rule_buf_out[BLOCK_SIZE];
4742
4743 memset (rule_buf_out, 0, sizeof (rule_buf_out));
4744
4745 int rule_len_out = -1;
4746
4747 if (line_len < BLOCK_SIZE)
4748 {
4749 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, line_buf, line_len, rule_buf_out);
4750 }
4751
4752 if (rule_len_out < 0) continue;
4753
4754 line_buf = rule_buf_out;
4755 line_len = rule_len_out;
4756 }
4757
4758 if (line_len > PW_MAX)
4759 {
4760 continue;
4761 }
4762
4763 if (attack_kern == ATTACK_KERN_STRAIGHT)
4764 {
4765 if ((line_len < data.pw_min) || (line_len > data.pw_max))
4766 {
4767 hc_thread_mutex_lock (mux_counter);
4768
4769 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4770 {
4771 data.words_progress_rejected[salt_pos] += data.gpu_rules_cnt;
4772 }
4773
4774 hc_thread_mutex_unlock (mux_counter);
4775
4776 continue;
4777 }
4778 }
4779 else if (attack_kern == ATTACK_KERN_COMBI)
4780 {
4781 // do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
4782 // since we still need to combine the plains
4783
4784 if (line_len > data.pw_max)
4785 {
4786 hc_thread_mutex_lock (mux_counter);
4787
4788 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4789 {
4790 data.words_progress_rejected[salt_pos] += data.combs_cnt;
4791 }
4792
4793 hc_thread_mutex_unlock (mux_counter);
4794
4795 continue;
4796 }
4797 }
4798
4799 device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
4800
4801 words_cur++;
4802
4803 if (data.devices_status == STATUS_CRACKED) break;
4804 if (data.devices_status == STATUS_ABORTED) break;
4805 if (data.devices_status == STATUS_QUIT) break;
4806 if (data.devices_status == STATUS_BYPASS) break;
4807 }
4808
4809 hc_thread_mutex_unlock (mux_dispatcher);
4810
4811 if (data.devices_status == STATUS_CRACKED) break;
4812 if (data.devices_status == STATUS_ABORTED) break;
4813 if (data.devices_status == STATUS_QUIT) break;
4814 if (data.devices_status == STATUS_BYPASS) break;
4815
4816 // we need 2 flushing because we have two independant caches and it can occur
4817 // that one buffer is already at threshold plus for that length also exists
4818 // more data in the 2nd buffer so it would overflow
4819
4820 // flush session 1
4821
4822 {
4823 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4824 {
4825 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4826
4827 const uint pw_cache_cnt = pw_cache->cnt;
4828
4829 if (pw_cache_cnt == 0) continue;
4830
4831 pw_cache->cnt = 0;
4832
4833 uint pws_cnt = device_param->pws_cnt;
4834
4835 pw_t *pw = device_param->pws_buf + pws_cnt;
4836
4837 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4838
4839 pw->pw_len = pw_len;
4840
4841 uint pw_cnt = device_param->pw_cnt;
4842
4843 pw_cnt += pw_cache_cnt;
4844
4845 device_param->pw_cnt = pw_cnt;
4846
4847 pws_cnt++;
4848
4849 device_param->pws_cnt = pws_cnt;
4850
4851 if (pws_cnt == device_param->gpu_power_user) break;
4852 }
4853
4854 const uint pw_cnt = device_param->pw_cnt;
4855 const uint pws_cnt = device_param->pws_cnt;
4856
4857 if (pws_cnt)
4858 {
4859 run_copy (device_param, pws_cnt);
4860
4861 run_cracker (device_param, pw_cnt, pws_cnt);
4862
4863 device_param->pw_cnt = 0;
4864 device_param->pws_cnt = 0;
4865 }
4866 }
4867
4868 // flush session 2
4869
4870 {
4871 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4872 {
4873 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4874
4875 const uint pw_cache_cnt = pw_cache->cnt;
4876
4877 if (pw_cache_cnt == 0) continue;
4878
4879 pw_cache->cnt = 0;
4880
4881 uint pws_cnt = device_param->pws_cnt;
4882
4883 pw_t *pw = device_param->pws_buf + pws_cnt;
4884
4885 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4886
4887 pw->pw_len = pw_len;
4888
4889 uint pw_cnt = device_param->pw_cnt;
4890
4891 pw_cnt += pw_cache_cnt;
4892
4893 device_param->pw_cnt = pw_cnt;
4894
4895 pws_cnt++;
4896
4897 device_param->pws_cnt = pws_cnt;
4898 }
4899
4900 const uint pw_cnt = device_param->pw_cnt;
4901 const uint pws_cnt = device_param->pws_cnt;
4902
4903 if (pws_cnt)
4904 {
4905 run_copy (device_param, pws_cnt);
4906
4907 run_cracker (device_param, pw_cnt, pws_cnt);
4908
4909 device_param->pw_cnt = 0;
4910 device_param->pws_cnt = 0;
4911 }
4912 }
4913 }
4914
4915 return NULL;
4916 }
4917
4918 static void *thread_calc (void *p)
4919 {
4920 hc_device_param_t *device_param = (hc_device_param_t *) p;
4921
4922 const uint attack_mode = data.attack_mode;
4923 const uint attack_kern = data.attack_kern;
4924
4925 if (attack_mode == ATTACK_MODE_BF)
4926 {
4927 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4928 {
4929 const uint work = get_work (device_param, -1);
4930
4931 if (work == 0) break;
4932
4933 const uint64_t words_off = device_param->words_off;
4934 const uint64_t words_fin = words_off + work;
4935
4936 const uint gpu_vector_width = device_param->gpu_vector_width;
4937
4938 const uint pw_cnt = work;
4939 const uint pws_cnt = mydivc32 (work, gpu_vector_width);
4940
4941 device_param->pw_cnt = pw_cnt;
4942 device_param->pws_cnt = pws_cnt;
4943
4944 if (pws_cnt)
4945 {
4946 run_copy (device_param, pws_cnt);
4947
4948 run_cracker (device_param, pw_cnt, pws_cnt);
4949
4950 device_param->pw_cnt = 0;
4951 device_param->pws_cnt = 0;
4952 }
4953
4954 if (data.devices_status == STATUS_CRACKED) break;
4955 if (data.devices_status == STATUS_ABORTED) break;
4956 if (data.devices_status == STATUS_QUIT) break;
4957 if (data.devices_status == STATUS_BYPASS) break;
4958
4959 device_param->words_done = words_fin;
4960 }
4961 }
4962 else
4963 {
4964 const uint segment_size = data.segment_size;
4965
4966 char *dictfile = data.dictfile;
4967
4968 if (attack_mode == ATTACK_MODE_COMBI)
4969 {
4970 if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
4971 {
4972 dictfile = data.dictfile2;
4973 }
4974 }
4975
4976 FILE *fd = fopen (dictfile, "rb");
4977
4978 if (fd == NULL)
4979 {
4980 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
4981
4982 return NULL;
4983 }
4984
4985 if (attack_mode == ATTACK_MODE_COMBI)
4986 {
4987 const uint combs_mode = data.combs_mode;
4988
4989 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
4990 {
4991 const char *dictfilec = data.dictfile2;
4992
4993 FILE *combs_fp = fopen (dictfilec, "rb");
4994
4995 if (combs_fp == NULL)
4996 {
4997 log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
4998
4999 fclose (fd);
5000
5001 return NULL;
5002 }
5003
5004 device_param->combs_fp = combs_fp;
5005 }
5006 else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
5007 {
5008 const char *dictfilec = data.dictfile;
5009
5010 FILE *combs_fp = fopen (dictfilec, "rb");
5011
5012 if (combs_fp == NULL)
5013 {
5014 log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
5015
5016 fclose (fd);
5017
5018 return NULL;
5019 }
5020
5021 device_param->combs_fp = combs_fp;
5022 }
5023 }
5024
5025 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
5026
5027 wl_data->buf = (char *) mymalloc (segment_size);
5028 wl_data->avail = segment_size;
5029 wl_data->incr = segment_size;
5030 wl_data->cnt = 0;
5031 wl_data->pos = 0;
5032
5033 uint64_t words_cur = 0;
5034
5035 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
5036 {
5037 uint64_t words_off = 0;
5038 uint64_t words_fin = 0;
5039
5040 uint64_t max = -1;
5041
5042 while (max)
5043 {
5044 const uint work = get_work (device_param, max);
5045
5046 if (work == 0) break;
5047
5048 words_off = device_param->words_off;
5049 words_fin = words_off + work;
5050
5051 char *line_buf;
5052 uint line_len;
5053
5054 for ( ; words_cur < words_off; words_cur++) get_next_word (wl_data, fd, &line_buf, &line_len);
5055
5056 max = 0;
5057
5058 for ( ; words_cur < words_fin; words_cur++)
5059 {
5060 get_next_word (wl_data, fd, &line_buf, &line_len);
5061
5062 line_len = convert_from_hex (line_buf, line_len);
5063
5064 // post-process rule engine
5065
5066 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
5067 {
5068 char rule_buf_out[BLOCK_SIZE];
5069
5070 memset (rule_buf_out, 0, sizeof (rule_buf_out));
5071
5072 int rule_len_out = -1;
5073
5074 if (line_len < BLOCK_SIZE)
5075 {
5076 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, line_buf, line_len, rule_buf_out);
5077 }
5078
5079 if (rule_len_out < 0) continue;
5080
5081 line_buf = rule_buf_out;
5082 line_len = rule_len_out;
5083 }
5084
5085 if (attack_kern == ATTACK_KERN_STRAIGHT)
5086 {
5087 if ((line_len < data.pw_min) || (line_len > data.pw_max))
5088 {
5089 max++;
5090
5091 hc_thread_mutex_lock (mux_counter);
5092
5093 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
5094 {
5095 data.words_progress_rejected[salt_pos] += data.gpu_rules_cnt;
5096 }
5097
5098 hc_thread_mutex_unlock (mux_counter);
5099
5100 continue;
5101 }
5102 }
5103 else if (attack_kern == ATTACK_KERN_COMBI)
5104 {
5105 // do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
5106 // since we still need to combine the plains
5107
5108 if (line_len > data.pw_max)
5109 {
5110 max++;
5111
5112 hc_thread_mutex_lock (mux_counter);
5113
5114 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
5115 {
5116 data.words_progress_rejected[salt_pos] += data.combs_cnt;
5117 }
5118
5119 hc_thread_mutex_unlock (mux_counter);
5120
5121 continue;
5122 }
5123 }
5124
5125 device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
5126
5127 if (data.devices_status == STATUS_CRACKED) break;
5128 if (data.devices_status == STATUS_ABORTED) break;
5129 if (data.devices_status == STATUS_QUIT) break;
5130 if (data.devices_status == STATUS_BYPASS) break;
5131 }
5132
5133 if (data.devices_status == STATUS_CRACKED) break;
5134 if (data.devices_status == STATUS_ABORTED) break;
5135 if (data.devices_status == STATUS_QUIT) break;
5136 if (data.devices_status == STATUS_BYPASS) break;
5137 }
5138
5139 if (data.devices_status == STATUS_CRACKED) break;
5140 if (data.devices_status == STATUS_ABORTED) break;
5141 if (data.devices_status == STATUS_QUIT) break;
5142 if (data.devices_status == STATUS_BYPASS) break;
5143
5144 // we need 2 flushing because we have two independant caches and it can occur
5145 // that one buffer is already at threshold plus for that length also exists
5146 // more data in the 2nd buffer so it would overflow
5147
5148 //
5149 // flush session 1
5150 //
5151
5152 {
5153 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
5154 {
5155 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
5156
5157 const uint pw_cache_cnt = pw_cache->cnt;
5158
5159 if (pw_cache_cnt == 0) continue;
5160
5161 pw_cache->cnt = 0;
5162
5163 uint pws_cnt = device_param->pws_cnt;
5164
5165 pw_t *pw = device_param->pws_buf + pws_cnt;
5166
5167 device_param->pw_transpose (&pw_cache->pw_buf, pw);
5168
5169 pw->pw_len = pw_len;
5170
5171 uint pw_cnt = device_param->pw_cnt;
5172
5173 pw_cnt += pw_cache_cnt;
5174
5175 device_param->pw_cnt = pw_cnt;
5176
5177 pws_cnt++;
5178
5179 device_param->pws_cnt = pws_cnt;
5180
5181 if (pws_cnt == device_param->gpu_power_user) break;
5182 }
5183
5184 const uint pw_cnt = device_param->pw_cnt;
5185 const uint pws_cnt = device_param->pws_cnt;
5186
5187 if (pws_cnt)
5188 {
5189 run_copy (device_param, pws_cnt);
5190
5191 run_cracker (device_param, pw_cnt, pws_cnt);
5192
5193 device_param->pw_cnt = 0;
5194 device_param->pws_cnt = 0;
5195 }
5196
5197 if (data.devices_status == STATUS_CRACKED) break;
5198 if (data.devices_status == STATUS_ABORTED) break;
5199 if (data.devices_status == STATUS_QUIT) break;
5200 if (data.devices_status == STATUS_BYPASS) break;
5201 }
5202
5203 //
5204 // flush session 2
5205 //
5206
5207 {
5208 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
5209 {
5210 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
5211
5212 const uint pw_cache_cnt = pw_cache->cnt;
5213
5214 if (pw_cache_cnt == 0) continue;
5215
5216 pw_cache->cnt = 0;
5217
5218 uint pws_cnt = device_param->pws_cnt;
5219
5220 pw_t *pw = device_param->pws_buf + pws_cnt;
5221
5222 device_param->pw_transpose (&pw_cache->pw_buf, pw);
5223
5224 pw->pw_len = pw_len;
5225
5226 uint pw_cnt = device_param->pw_cnt;
5227
5228 pw_cnt += pw_cache_cnt;
5229
5230 device_param->pw_cnt = pw_cnt;
5231
5232 pws_cnt++;
5233
5234 device_param->pws_cnt = pws_cnt;
5235 }
5236
5237 const uint pw_cnt = device_param->pw_cnt;
5238 const uint pws_cnt = device_param->pws_cnt;
5239
5240 if (pws_cnt)
5241 {
5242 run_copy (device_param, pws_cnt);
5243
5244 run_cracker (device_param, pw_cnt, pws_cnt);
5245
5246 device_param->pw_cnt = 0;
5247 device_param->pws_cnt = 0;
5248 }
5249
5250 if (data.devices_status == STATUS_CRACKED) break;
5251 if (data.devices_status == STATUS_ABORTED) break;
5252 if (data.devices_status == STATUS_QUIT) break;
5253 if (data.devices_status == STATUS_BYPASS) break;
5254 }
5255
5256 if (words_fin == 0) break;
5257
5258 device_param->words_done = words_fin;
5259 }
5260
5261 if (attack_mode == ATTACK_MODE_COMBI)
5262 {
5263 fclose (device_param->combs_fp);
5264 }
5265
5266 free (wl_data->buf);
5267 free (wl_data);
5268
5269 fclose (fd);
5270 }
5271
5272 return NULL;
5273 }
5274
5275 static void weak_hash_check (hc_device_param_t *device_param, const uint salt_pos, const uint gpu_loops)
5276 {
5277 #ifdef _CUDA
5278 hc_cuCtxPushCurrent (device_param->context);
5279 #endif
5280
5281 salt_t *salt_buf = &data.salts_buf[salt_pos];
5282
5283 device_param->kernel_params_buf32[24] = salt_pos;
5284 device_param->kernel_params_buf32[27] = 1;
5285 device_param->kernel_params_buf32[28] = salt_buf->digests_cnt;
5286 device_param->kernel_params_buf32[29] = salt_buf->digests_offset;
5287 device_param->kernel_params_buf32[30] = 0;
5288 device_param->kernel_params_buf32[31] = 1;
5289
5290 char *dictfile_old = data.dictfile;
5291 char *dictfile2_old = data.dictfile2;
5292 char *mask_old = data.mask;
5293
5294 const char *weak_hash_check = "weak-hash-check";
5295
5296 data.dictfile = (char *) weak_hash_check;
5297 data.dictfile2 = (char *) weak_hash_check;
5298 data.mask = (char *) weak_hash_check;
5299
5300 /**
5301 * run the kernel
5302 */
5303
5304 if (data.attack_exec == ATTACK_EXEC_ON_GPU)
5305 {
5306 run_kernel (KERN_RUN_1, device_param, 1);
5307 }
5308 else
5309 {
5310 run_kernel (KERN_RUN_1, device_param, 1);
5311
5312 const uint iter = salt_buf->salt_iter;
5313
5314 for (uint loop_pos = 0; loop_pos < iter; loop_pos += gpu_loops)
5315 {
5316 uint loop_left = iter - loop_pos;
5317
5318 loop_left = MIN (loop_left, gpu_loops);
5319
5320 device_param->kernel_params_buf32[25] = loop_pos;
5321 device_param->kernel_params_buf32[26] = loop_left;
5322
5323 run_kernel (KERN_RUN_2, device_param, 1);
5324 }
5325
5326 run_kernel (KERN_RUN_3, device_param, 1);
5327 }
5328
5329 /**
5330 * result
5331 */
5332
5333 check_cracked (device_param, salt_pos);
5334
5335 /**
5336 * cleanup
5337 */
5338
5339 device_param->kernel_params_buf32[24] = 0;
5340 device_param->kernel_params_buf32[25] = 0;
5341 device_param->kernel_params_buf32[26] = 0;
5342 device_param->kernel_params_buf32[27] = 0;
5343 device_param->kernel_params_buf32[28] = 0;
5344 device_param->kernel_params_buf32[29] = 0;
5345 device_param->kernel_params_buf32[30] = 0;
5346 device_param->kernel_params_buf32[31] = 0;
5347
5348 data.dictfile = dictfile_old;
5349 data.dictfile2 = dictfile2_old;
5350 data.mask = mask_old;
5351
5352 #ifdef _CUDA
5353 hc_cuCtxPopCurrent (&device_param->context);
5354 #endif
5355 }
5356
5357 // hlfmt hashcat
5358
5359 static void hlfmt_hash_hashcat (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5360 {
5361 if (data.username == 0)
5362 {
5363 *hashbuf_pos = line_buf;
5364 *hashbuf_len = line_len;
5365 }
5366 else
5367 {
5368 char *pos = line_buf;
5369 int len = line_len;
5370
5371 for (int i = 0; i < line_len; i++, pos++, len--)
5372 {
5373 if (line_buf[i] == data.separator)
5374 {
5375 pos++;
5376
5377 len--;
5378
5379 break;
5380 }
5381 }
5382
5383 *hashbuf_pos = pos;
5384 *hashbuf_len = len;
5385 }
5386 }
5387
5388 static void hlfmt_user_hashcat (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5389 {
5390 char *pos = NULL;
5391 int len = 0;
5392
5393 int sep_cnt = 0;
5394
5395 for (int i = 0; i < line_len; i++)
5396 {
5397 if (line_buf[i] == data.separator)
5398 {
5399 sep_cnt++;
5400
5401 continue;
5402 }
5403
5404 if (sep_cnt == 0)
5405 {
5406 if (pos == NULL) pos = line_buf + i;
5407
5408 len++;
5409 }
5410 }
5411
5412 *userbuf_pos = pos;
5413 *userbuf_len = len;
5414 }
5415
5416 // hlfmt pwdump
5417
5418 static int hlfmt_detect_pwdump (char line_buf[BUFSIZ], int line_len)
5419 {
5420 int sep_cnt = 0;
5421
5422 int sep2_len = 0;
5423 int sep3_len = 0;
5424
5425 for (int i = 0; i < line_len; i++)
5426 {
5427 if (line_buf[i] == ':')
5428 {
5429 sep_cnt++;
5430
5431 continue;
5432 }
5433
5434 if (sep_cnt == 2) sep2_len++;
5435 if (sep_cnt == 3) sep3_len++;
5436 }
5437
5438 if ((sep_cnt == 6) && ((sep2_len == 32) || (sep3_len == 32))) return 1;
5439
5440 return 0;
5441 }
5442
5443 static void hlfmt_hash_pwdump (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5444 {
5445 char *pos = NULL;
5446 int len = 0;
5447
5448 int sep_cnt = 0;
5449
5450 for (int i = 0; i < line_len; i++)
5451 {
5452 if (line_buf[i] == ':')
5453 {
5454 sep_cnt++;
5455
5456 continue;
5457 }
5458
5459 if (data.hash_mode == 1000)
5460 {
5461 if (sep_cnt == 3)
5462 {
5463 if (pos == NULL) pos = line_buf + i;
5464
5465 len++;
5466 }
5467 }
5468 else if (data.hash_mode == 3000)
5469 {
5470 if (sep_cnt == 2)
5471 {
5472 if (pos == NULL) pos = line_buf + i;
5473
5474 len++;
5475 }
5476 }
5477 }
5478
5479 *hashbuf_pos = pos;
5480 *hashbuf_len = len;
5481 }
5482
5483 static void hlfmt_user_pwdump (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5484 {
5485 char *pos = NULL;
5486 int len = 0;
5487
5488 int sep_cnt = 0;
5489
5490 for (int i = 0; i < line_len; i++)
5491 {
5492 if (line_buf[i] == ':')
5493 {
5494 sep_cnt++;
5495
5496 continue;
5497 }
5498
5499 if (sep_cnt == 0)
5500 {
5501 if (pos == NULL) pos = line_buf + i;
5502
5503 len++;
5504 }
5505 }
5506
5507 *userbuf_pos = pos;
5508 *userbuf_len = len;
5509 }
5510
5511 // hlfmt passwd
5512
5513 static int hlfmt_detect_passwd (char line_buf[BUFSIZ], int line_len)
5514 {
5515 int sep_cnt = 0;
5516
5517 char sep5_first = 0;
5518 char sep6_first = 0;
5519
5520 for (int i = 0; i < line_len; i++)
5521 {
5522 if (line_buf[i] == ':')
5523 {
5524 sep_cnt++;
5525
5526 continue;
5527 }
5528
5529 if (sep_cnt == 5) if (sep5_first == 0) sep5_first = line_buf[i];
5530 if (sep_cnt == 6) if (sep6_first == 0) sep6_first = line_buf[i];
5531 }
5532
5533 if ((sep_cnt == 6) && ((sep5_first == '/') || (sep6_first == '/'))) return 1;
5534
5535 return 0;
5536 }
5537
5538 static void hlfmt_hash_passwd (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5539 {
5540 char *pos = NULL;
5541 int len = 0;
5542
5543 int sep_cnt = 0;
5544
5545 for (int i = 0; i < line_len; i++)
5546 {
5547 if (line_buf[i] == ':')
5548 {
5549 sep_cnt++;
5550
5551 continue;
5552 }
5553
5554 if (sep_cnt == 1)
5555 {
5556 if (pos == NULL) pos = line_buf + i;
5557
5558 len++;
5559 }
5560 }
5561
5562 *hashbuf_pos = pos;
5563 *hashbuf_len = len;
5564 }
5565
5566 static void hlfmt_user_passwd (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5567 {
5568 char *pos = NULL;
5569 int len = 0;
5570
5571 int sep_cnt = 0;
5572
5573 for (int i = 0; i < line_len; i++)
5574 {
5575 if (line_buf[i] == ':')
5576 {
5577 sep_cnt++;
5578
5579 continue;
5580 }
5581
5582 if (sep_cnt == 0)
5583 {
5584 if (pos == NULL) pos = line_buf + i;
5585
5586 len++;
5587 }
5588 }
5589
5590 *userbuf_pos = pos;
5591 *userbuf_len = len;
5592 }
5593
5594 // hlfmt shadow
5595
5596 static int hlfmt_detect_shadow (char line_buf[BUFSIZ], int line_len)
5597 {
5598 int sep_cnt = 0;
5599
5600 for (int i = 0; i < line_len; i++)
5601 {
5602 if (line_buf[i] == ':') sep_cnt++;
5603 }
5604
5605 if (sep_cnt == 8) return 1;
5606
5607 return 0;
5608 }
5609
5610 static void hlfmt_hash_shadow (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5611 {
5612 hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len);
5613 }
5614
5615 static void hlfmt_user_shadow (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5616 {
5617 hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len);
5618 }
5619
5620 // hlfmt main
5621
5622 static void hlfmt_hash (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5623 {
5624 switch (hashfile_format)
5625 {
5626 case HLFMT_HASHCAT: hlfmt_hash_hashcat (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5627 case HLFMT_PWDUMP: hlfmt_hash_pwdump (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5628 case HLFMT_PASSWD: hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5629 case HLFMT_SHADOW: hlfmt_hash_shadow (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5630 }
5631 }
5632
5633 static void hlfmt_user (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5634 {
5635 switch (hashfile_format)
5636 {
5637 case HLFMT_HASHCAT: hlfmt_user_hashcat (line_buf, line_len, userbuf_pos, userbuf_len); break;
5638 case HLFMT_PWDUMP: hlfmt_user_pwdump (line_buf, line_len, userbuf_pos, userbuf_len); break;
5639 case HLFMT_PASSWD: hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len); break;
5640 case HLFMT_SHADOW: hlfmt_user_shadow (line_buf, line_len, userbuf_pos, userbuf_len); break;
5641 }
5642 }
5643
5644 static uint hlfmt_detect (FILE *fp, uint max_check)
5645 {
5646 // Exception: those formats are wrongly detected as HLFMT_SHADOW, prevent it
5647
5648 if (data.hash_mode == 5300) return HLFMT_HASHCAT;
5649 if (data.hash_mode == 5400) return HLFMT_HASHCAT;
5650
5651 uint *formats_cnt = (uint *) mycalloc (HLFMTS_CNT, sizeof (uint));
5652
5653 uint num_check = 0;
5654
5655 while (!feof (fp))
5656 {
5657 char line_buf[BUFSIZ];
5658
5659 int line_len = fgetl (fp, line_buf);
5660
5661 if (line_len == 0) continue;
5662
5663 if (hlfmt_detect_pwdump (line_buf, line_len)) formats_cnt[HLFMT_PWDUMP]++;
5664 if (hlfmt_detect_passwd (line_buf, line_len)) formats_cnt[HLFMT_PASSWD]++;
5665 if (hlfmt_detect_shadow (line_buf, line_len)) formats_cnt[HLFMT_SHADOW]++;
5666
5667 if (num_check == max_check) break;
5668
5669 num_check++;
5670 }
5671
5672 uint hashlist_format = HLFMT_HASHCAT;
5673
5674 for (int i = 1; i < HLFMTS_CNT; i++)
5675 {
5676 if (formats_cnt[i - 1] >= formats_cnt[i]) continue;
5677
5678 hashlist_format = i;
5679 }
5680
5681 free (formats_cnt);
5682
5683 return hashlist_format;
5684 }
5685
5686 /**
5687 * main
5688 */
5689
5690 #ifdef _OCL
5691 void *__stdcall ADL_Main_Memory_Alloc (const int iSize)
5692 {
5693 return mymalloc (iSize);
5694 }
5695 #endif
5696
5697 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)
5698 {
5699 uint64_t collisions = 0;
5700
5701 const uint dgst_pos0 = data.dgst_pos0;
5702 const uint dgst_pos1 = data.dgst_pos1;
5703 const uint dgst_pos2 = data.dgst_pos2;
5704 const uint dgst_pos3 = data.dgst_pos3;
5705
5706 memset (bitmap_a, 0, bitmap_size);
5707 memset (bitmap_b, 0, bitmap_size);
5708 memset (bitmap_c, 0, bitmap_size);
5709 memset (bitmap_d, 0, bitmap_size);
5710
5711 for (uint i = 0; i < digests_cnt; i++)
5712 {
5713 uint *digest_ptr = (uint *) digests_buf_ptr;
5714
5715 digests_buf_ptr += dgst_size;
5716
5717 const uint val0 = 1 << (digest_ptr[dgst_pos0] & 0x1f);
5718 const uint val1 = 1 << (digest_ptr[dgst_pos1] & 0x1f);
5719 const uint val2 = 1 << (digest_ptr[dgst_pos2] & 0x1f);
5720 const uint val3 = 1 << (digest_ptr[dgst_pos3] & 0x1f);
5721
5722 const uint idx0 = (digest_ptr[dgst_pos0] >> dgst_shifts) & bitmap_mask;
5723 const uint idx1 = (digest_ptr[dgst_pos1] >> dgst_shifts) & bitmap_mask;
5724 const uint idx2 = (digest_ptr[dgst_pos2] >> dgst_shifts) & bitmap_mask;
5725 const uint idx3 = (digest_ptr[dgst_pos3] >> dgst_shifts) & bitmap_mask;
5726
5727 if (bitmap_a[idx0] & val0) collisions++;
5728 if (bitmap_b[idx1] & val1) collisions++;
5729 if (bitmap_c[idx2] & val2) collisions++;
5730 if (bitmap_d[idx3] & val3) collisions++;
5731
5732 bitmap_a[idx0] |= val0;
5733 bitmap_b[idx1] |= val1;
5734 bitmap_c[idx2] |= val2;
5735 bitmap_d[idx3] |= val3;
5736
5737 if (collisions >= collisions_max) return 0x7fffffff;
5738 }
5739
5740 return collisions;
5741 }
5742
5743 int main (int argc, char **argv)
5744 {
5745 /**
5746 * To help users a bit
5747 */
5748
5749 char *compute = getenv ("COMPUTE");
5750
5751 if (compute)
5752 {
5753 char display[100];
5754
5755 snprintf (display, sizeof (display) - 1, "DISPLAY=%s", compute);
5756
5757 putenv (display);
5758 }
5759 else
5760 {
5761 if (getenv ("DISPLAY") == NULL)
5762 putenv ((char *) "DISPLAY=:0");
5763 }
5764
5765 /*
5766 if (getenv ("GPU_MAX_ALLOC_PERCENT") == NULL)
5767 putenv ((char *) "GPU_MAX_ALLOC_PERCENT=100");
5768
5769 if (getenv ("GPU_USE_SYNC_OBJECTS") == NULL)
5770 putenv ((char *) "GPU_USE_SYNC_OBJECTS=1");
5771 */
5772
5773 /**
5774 * Real init
5775 */
5776
5777 memset (&data, 0, sizeof (hc_global_data_t));
5778
5779 time_t proc_start;
5780
5781 time (&proc_start);
5782
5783 data.proc_start = proc_start;
5784
5785 int myargc = argc;
5786 char **myargv = argv;
5787
5788 hc_thread_mutex_init (mux_dispatcher);
5789 hc_thread_mutex_init (mux_counter);
5790 hc_thread_mutex_init (mux_display);
5791 hc_thread_mutex_init (mux_adl);
5792
5793 /**
5794 * commandline parameters
5795 */
5796
5797 uint usage = USAGE;
5798 uint version = VERSION;
5799 uint quiet = QUIET;
5800 uint benchmark = BENCHMARK;
5801 uint benchmark_mode = BENCHMARK_MODE;
5802 uint show = SHOW;
5803 uint left = LEFT;
5804 uint username = USERNAME;
5805 uint remove = REMOVE;
5806 uint remove_timer = REMOVE_TIMER;
5807 uint64_t skip = SKIP;
5808 uint64_t limit = LIMIT;
5809 uint keyspace = KEYSPACE;
5810 uint potfile_disable = POTFILE_DISABLE;
5811 uint debug_mode = DEBUG_MODE;
5812 char *debug_file = NULL;
5813 char *induction_dir = NULL;
5814 char *outfile_check_dir = NULL;
5815 uint force = FORCE;
5816 uint runtime = RUNTIME;
5817 uint hash_mode = HASH_MODE;
5818 uint attack_mode = ATTACK_MODE;
5819 uint markov_disable = MARKOV_DISABLE;
5820 uint markov_classic = MARKOV_CLASSIC;
5821 uint markov_threshold = MARKOV_THRESHOLD;
5822 char *markov_hcstat = NULL;
5823 char *outfile = NULL;
5824 uint outfile_format = OUTFILE_FORMAT;
5825 uint outfile_autohex = OUTFILE_AUTOHEX;
5826 uint outfile_check_timer = OUTFILE_CHECK_TIMER;
5827 uint restore = RESTORE;
5828 uint restore_timer = RESTORE_TIMER;
5829 uint restore_disable = RESTORE_DISABLE;
5830 uint status = STATUS;
5831 uint status_timer = STATUS_TIMER;
5832 uint status_automat = STATUS_AUTOMAT;
5833 uint loopback = LOOPBACK;
5834 uint weak_hash_threshold = WEAK_HASH_THRESHOLD;
5835 char *session = NULL;
5836 uint hex_charset = HEX_CHARSET;
5837 uint hex_salt = HEX_SALT;
5838 uint hex_wordlist = HEX_WORDLIST;
5839 uint rp_gen = RP_GEN;
5840 uint rp_gen_func_min = RP_GEN_FUNC_MIN;
5841 uint rp_gen_func_max = RP_GEN_FUNC_MAX;
5842 uint rp_gen_seed = RP_GEN_SEED;
5843 char *rule_buf_l = (char *) RULE_BUF_L;
5844 char *rule_buf_r = (char *) RULE_BUF_R;
5845 uint increment = INCREMENT;
5846 uint increment_min = INCREMENT_MIN;
5847 uint increment_max = INCREMENT_MAX;
5848 char *cpu_affinity = NULL;
5849 uint gpu_async = GPU_ASYNC;
5850 char *gpu_devices = NULL;
5851 char *truecrypt_keyfiles = NULL;
5852 uint workload_profile = WORKLOAD_PROFILE;
5853 uint gpu_accel = GPU_ACCEL;
5854 uint gpu_loops = GPU_LOOPS;
5855 uint gpu_temp_disable = GPU_TEMP_DISABLE;
5856 uint gpu_temp_abort = GPU_TEMP_ABORT;
5857 uint gpu_temp_retain = GPU_TEMP_RETAIN;
5858 uint powertune_enable = POWERTUNE_ENABLE;
5859 uint logfile_disable = LOGFILE_DISABLE;
5860 uint segment_size = SEGMENT_SIZE;
5861 uint scrypt_tmto = SCRYPT_TMTO;
5862 char separator = SEPARATOR;
5863 uint bitmap_min = BITMAP_MIN;
5864 uint bitmap_max = BITMAP_MAX;
5865 char *custom_charset_1 = NULL;
5866 char *custom_charset_2 = NULL;
5867 char *custom_charset_3 = NULL;
5868 char *custom_charset_4 = NULL;
5869
5870 #define IDX_HELP 'h'
5871 #define IDX_VERSION 'V'
5872 #define IDX_VERSION_LOWER 'v'
5873 #define IDX_QUIET 0xff02
5874 #define IDX_SHOW 0xff03
5875 #define IDX_LEFT 0xff04
5876 #define IDX_REMOVE 0xff05
5877 #define IDX_REMOVE_TIMER 0xff37
5878 #define IDX_SKIP 's'
5879 #define IDX_LIMIT 'l'
5880 #define IDX_KEYSPACE 0xff35
5881 #define IDX_POTFILE_DISABLE 0xff06
5882 #define IDX_DEBUG_MODE 0xff43
5883 #define IDX_DEBUG_FILE 0xff44
5884 #define IDX_INDUCTION_DIR 0xff46
5885 #define IDX_OUTFILE_CHECK_DIR 0xff47
5886 #define IDX_USERNAME 0xff07
5887 #define IDX_FORCE 0xff08
5888 #define IDX_RUNTIME 0xff09
5889 #define IDX_BENCHMARK 'b'
5890 #define IDX_BENCHMARK_MODE 0xff32
5891 #define IDX_HASH_MODE 'm'
5892 #define IDX_ATTACK_MODE 'a'
5893 #define IDX_RP_FILE 'r'
5894 #define IDX_RP_GEN 'g'
5895 #define IDX_RP_GEN_FUNC_MIN 0xff10
5896 #define IDX_RP_GEN_FUNC_MAX 0xff11
5897 #define IDX_RP_GEN_SEED 0xff34
5898 #define IDX_RULE_BUF_L 'j'
5899 #define IDX_RULE_BUF_R 'k'
5900 #define IDX_INCREMENT 'i'
5901 #define IDX_INCREMENT_MIN 0xff12
5902 #define IDX_INCREMENT_MAX 0xff13
5903 #define IDX_OUTFILE 'o'
5904 #define IDX_OUTFILE_FORMAT 0xff14
5905 #define IDX_OUTFILE_AUTOHEX_DISABLE 0xff39
5906 #define IDX_OUTFILE_CHECK_TIMER 0xff45
5907 #define IDX_RESTORE 0xff15
5908 #define IDX_RESTORE_DISABLE 0xff27
5909 #define IDX_STATUS 0xff17
5910 #define IDX_STATUS_TIMER 0xff18
5911 #define IDX_STATUS_AUTOMAT 0xff50
5912 #define IDX_LOOPBACK 0xff38
5913 #define IDX_WEAK_HASH_THRESHOLD 0xff42
5914 #define IDX_SESSION 0xff19
5915 #define IDX_HEX_CHARSET 0xff20
5916 #define IDX_HEX_SALT 0xff21
5917 #define IDX_HEX_WORDLIST 0xff40
5918 #define IDX_MARKOV_DISABLE 0xff22
5919 #define IDX_MARKOV_CLASSIC 0xff23
5920 #define IDX_MARKOV_THRESHOLD 't'
5921 #define IDX_MARKOV_HCSTAT 0xff24
5922 #define IDX_CPU_AFFINITY 0xff25
5923 #define IDX_GPU_ASYNC 0xff26
5924 #define IDX_GPU_DEVICES 'd'
5925 #define IDX_WORKLOAD_PROFILE 'w'
5926 #define IDX_GPU_ACCEL 'n'
5927 #define IDX_GPU_LOOPS 'u'
5928 #define IDX_GPU_TEMP_DISABLE 0xff29
5929 #define IDX_GPU_TEMP_ABORT 0xff30
5930 #define IDX_GPU_TEMP_RETAIN 0xff31
5931 #define IDX_POWERTUNE_ENABLE 0xff41
5932 #define IDX_LOGFILE_DISABLE 0xff51
5933 #define IDX_TRUECRYPT_KEYFILES 0xff52
5934 #define IDX_SCRYPT_TMTO 0xff61
5935 #define IDX_SEGMENT_SIZE 'c'
5936 #define IDX_SEPARATOR 'p'
5937 #define IDX_BITMAP_MIN 0xff70
5938 #define IDX_BITMAP_MAX 0xff71
5939 #define IDX_CUSTOM_CHARSET_1 '1'
5940 #define IDX_CUSTOM_CHARSET_2 '2'
5941 #define IDX_CUSTOM_CHARSET_3 '3'
5942 #define IDX_CUSTOM_CHARSET_4 '4'
5943
5944 char short_options[] = "hVvm:a:r:j:k:g:o:t:d:n:u:c:p:s:l:1:2:3:4:ibw:";
5945
5946 struct option long_options[] =
5947 {
5948 {"help", no_argument, 0, IDX_HELP},
5949 {"version", no_argument, 0, IDX_VERSION},
5950 {"quiet", no_argument, 0, IDX_QUIET},
5951 {"show", no_argument, 0, IDX_SHOW},
5952 {"left", no_argument, 0, IDX_LEFT},
5953 {"username", no_argument, 0, IDX_USERNAME},
5954 {"remove", no_argument, 0, IDX_REMOVE},
5955 {"remove-timer", required_argument, 0, IDX_REMOVE_TIMER},
5956 {"skip", required_argument, 0, IDX_SKIP},
5957 {"limit", required_argument, 0, IDX_LIMIT},
5958 {"keyspace", no_argument, 0, IDX_KEYSPACE},
5959 {"potfile-disable", no_argument, 0, IDX_POTFILE_DISABLE},
5960 {"debug-mode", required_argument, 0, IDX_DEBUG_MODE},
5961 {"debug-file", required_argument, 0, IDX_DEBUG_FILE},
5962 {"induction-dir", required_argument, 0, IDX_INDUCTION_DIR},
5963 {"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR},
5964 {"force", no_argument, 0, IDX_FORCE},
5965 {"benchmark", no_argument, 0, IDX_BENCHMARK},
5966 {"benchmark-mode", required_argument, 0, IDX_BENCHMARK_MODE},
5967 {"restore", no_argument, 0, IDX_RESTORE},
5968 {"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE},
5969 {"status", no_argument, 0, IDX_STATUS},
5970 {"status-timer", required_argument, 0, IDX_STATUS_TIMER},
5971 {"status-automat", no_argument, 0, IDX_STATUS_AUTOMAT},
5972 {"loopback", no_argument, 0, IDX_LOOPBACK},
5973 {"weak-hash-threshold",
5974 required_argument, 0, IDX_WEAK_HASH_THRESHOLD},
5975 {"session", required_argument, 0, IDX_SESSION},
5976 {"runtime", required_argument, 0, IDX_RUNTIME},
5977 {"generate-rules", required_argument, 0, IDX_RP_GEN},
5978 {"generate-rules-func-min",
5979 required_argument, 0, IDX_RP_GEN_FUNC_MIN},
5980 {"generate-rules-func-max",
5981 required_argument, 0, IDX_RP_GEN_FUNC_MAX},
5982 {"generate-rules-seed",
5983 required_argument, 0, IDX_RP_GEN_SEED},
5984 {"rule-left", required_argument, 0, IDX_RULE_BUF_L},
5985 {"rule-right", required_argument, 0, IDX_RULE_BUF_R},
5986 {"hash-type", required_argument, 0, IDX_HASH_MODE},
5987 {"attack-mode", required_argument, 0, IDX_ATTACK_MODE},
5988 {"rules-file", required_argument, 0, IDX_RP_FILE},
5989 {"outfile", required_argument, 0, IDX_OUTFILE},
5990 {"outfile-format", required_argument, 0, IDX_OUTFILE_FORMAT},
5991 {"outfile-autohex-disable",
5992 no_argument, 0, IDX_OUTFILE_AUTOHEX_DISABLE},
5993 {"outfile-check-timer",
5994 required_argument, 0, IDX_OUTFILE_CHECK_TIMER},
5995 {"hex-charset", no_argument, 0, IDX_HEX_CHARSET},
5996 {"hex-salt", no_argument, 0, IDX_HEX_SALT},
5997 {"hex-wordlist", no_argument, 0, IDX_HEX_WORDLIST},
5998 {"markov-disable", no_argument, 0, IDX_MARKOV_DISABLE},
5999 {"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC},
6000 {"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD},
6001 {"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT},
6002 {"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
6003 {"gpu-async", no_argument, 0, IDX_GPU_ASYNC},
6004 {"gpu-devices", required_argument, 0, IDX_GPU_DEVICES},
6005 {"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE},
6006 {"gpu-accel", required_argument, 0, IDX_GPU_ACCEL},
6007 {"gpu-loops", required_argument, 0, IDX_GPU_LOOPS},
6008 {"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE},
6009 {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
6010 {"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
6011 {"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
6012 {"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
6013 {"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
6014 {"segment-size", required_argument, 0, IDX_SEGMENT_SIZE},
6015 {"scrypt-tmto", required_argument, 0, IDX_SCRYPT_TMTO},
6016 // deprecated
6017 {"seperator", required_argument, 0, IDX_SEPARATOR},
6018 {"separator", required_argument, 0, IDX_SEPARATOR},
6019 {"bitmap-min", required_argument, 0, IDX_BITMAP_MIN},
6020 {"bitmap-max", required_argument, 0, IDX_BITMAP_MAX},
6021 {"increment", no_argument, 0, IDX_INCREMENT},
6022 {"increment-min", required_argument, 0, IDX_INCREMENT_MIN},
6023 {"increment-max", required_argument, 0, IDX_INCREMENT_MAX},
6024 {"custom-charset1", required_argument, 0, IDX_CUSTOM_CHARSET_1},
6025 {"custom-charset2", required_argument, 0, IDX_CUSTOM_CHARSET_2},
6026 {"custom-charset3", required_argument, 0, IDX_CUSTOM_CHARSET_3},
6027 {"custom-charset4", required_argument, 0, IDX_CUSTOM_CHARSET_4},
6028
6029 {0, 0, 0, 0}
6030 };
6031
6032 uint rp_files_cnt = 0;
6033
6034 char **rp_files = (char **) mycalloc (argc, sizeof (char *));
6035
6036 int option_index;
6037 int c;
6038
6039 optind = 1;
6040 optopt = 0;
6041 option_index = 0;
6042
6043 while (((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1) && optopt == 0)
6044 {
6045 switch (c)
6046 {
6047 case IDX_HELP: usage = 1; break;
6048 case IDX_VERSION:
6049 case IDX_VERSION_LOWER: version = 1; break;
6050 case IDX_RESTORE: restore = 1; break;
6051 case IDX_SESSION: session = optarg; break;
6052 case IDX_SHOW: show = 1; break;
6053 case IDX_LEFT: left = 1; break;
6054 case '?': return (-1);
6055 }
6056 }
6057
6058 if (optopt != 0)
6059 {
6060 log_error ("ERROR: Invalid argument specified");
6061
6062 return (-1);
6063 }
6064
6065 /**
6066 * exit functions
6067 */
6068
6069 if (version)
6070 {
6071 log_info (VERSION_TXT);
6072
6073 return (0);
6074 }
6075
6076 if (usage)
6077 {
6078 usage_big_print (PROGNAME);
6079
6080 return (0);
6081 }
6082
6083 /**
6084 * session
6085 */
6086
6087 if (session == NULL) session = (char *) PROGNAME;
6088
6089 size_t session_size = strlen (session) + 32;
6090
6091 data.session = session;
6092
6093 char *eff_restore_file = (char *) mymalloc (session_size);
6094 char *new_restore_file = (char *) mymalloc (session_size);
6095
6096 snprintf (eff_restore_file, session_size - 1, "%s.restore", session);
6097 snprintf (new_restore_file, session_size - 1, "%s.restore.new", session);
6098
6099 data.eff_restore_file = eff_restore_file;
6100 data.new_restore_file = new_restore_file;
6101
6102 if (((show == 1) || (left == 1)) && (restore == 1))
6103 {
6104 if (show == 1) log_error ("ERROR: Mixing --restore parameter and --show is not supported");
6105 else log_error ("ERROR: Mixing --restore parameter and --left is not supported");
6106
6107 return (-1);
6108 }
6109
6110 // this allows the user to use --show and --left while cracking (i.e. while another instance of oclHashcat is running)
6111 if ((show == 1) || (left == 1))
6112 {
6113 restore_disable = 1;
6114
6115 restore = 0;
6116 }
6117
6118 data.restore_disable = restore_disable;
6119
6120 restore_data_t *rd = init_restore (argc, argv);
6121
6122 data.rd = rd;
6123
6124 /**
6125 * restore file
6126 */
6127
6128 if (restore == 1)
6129 {
6130 read_restore (eff_restore_file, rd);
6131
6132 if (rd->version_bin < RESTORE_MIN)
6133 {
6134 log_error ("ERROR: Incompatible restore-file version");
6135
6136 return (-1);
6137 }
6138
6139 myargc = rd->argc;
6140 myargv = rd->argv;
6141
6142 #ifdef _POSIX
6143 rd->pid = getpid ();
6144 #elif _WIN
6145 rd->pid = GetCurrentProcessId ();
6146 #endif
6147 }
6148
6149 uint hash_mode_chgd = 0;
6150 uint runtime_chgd = 0;
6151 uint gpu_loops_chgd = 0;
6152 uint gpu_accel_chgd = 0;
6153 uint attack_mode_chgd = 0;
6154 uint outfile_format_chgd = 0;
6155 uint rp_gen_seed_chgd = 0;
6156 uint remove_timer_chgd = 0;
6157 uint increment_min_chgd = 0;
6158 uint increment_max_chgd = 0;
6159
6160 #if _OCL
6161 uint gpu_temp_abort_chgd = 0;
6162 uint gpu_temp_retain_chgd = 0;
6163 #endif
6164
6165 optind = 1;
6166 optopt = 0;
6167 option_index = 0;
6168
6169 while (((c = getopt_long (myargc, myargv, short_options, long_options, &option_index)) != -1) && optopt == 0)
6170 {
6171 switch (c)
6172 {
6173 //case IDX_HELP: usage = 1; break;
6174 //case IDX_VERSION: version = 1; break;
6175 //case IDX_RESTORE: restore = 1; break;
6176 case IDX_QUIET: quiet = 1; break;
6177 //case IDX_SHOW: show = 1; break;
6178 case IDX_SHOW: break;
6179 //case IDX_LEFT: left = 1; break;
6180 case IDX_LEFT: break;
6181 case IDX_USERNAME: username = 1; break;
6182 case IDX_REMOVE: remove = 1; break;
6183 case IDX_REMOVE_TIMER: remove_timer = atoi (optarg);
6184 remove_timer_chgd = 1; break;
6185 case IDX_POTFILE_DISABLE: potfile_disable = 1; break;
6186 case IDX_DEBUG_MODE: debug_mode = atoi (optarg); break;
6187 case IDX_DEBUG_FILE: debug_file = optarg; break;
6188 case IDX_INDUCTION_DIR: induction_dir = optarg; break;
6189 case IDX_OUTFILE_CHECK_DIR: outfile_check_dir = optarg; break;
6190 case IDX_FORCE: force = 1; break;
6191 case IDX_SKIP: skip = atoll (optarg); break;
6192 case IDX_LIMIT: limit = atoll (optarg); break;
6193 case IDX_KEYSPACE: keyspace = 1; break;
6194 case IDX_BENCHMARK: benchmark = 1; break;
6195 case IDX_BENCHMARK_MODE: benchmark_mode = atoi (optarg); break;
6196 case IDX_RESTORE: break;
6197 case IDX_RESTORE_DISABLE: restore_disable = 1; break;
6198 case IDX_STATUS: status = 1; break;
6199 case IDX_STATUS_TIMER: status_timer = atoi (optarg); break;
6200 case IDX_STATUS_AUTOMAT: status_automat = 1; break;
6201 case IDX_LOOPBACK: loopback = 1; break;
6202 case IDX_WEAK_HASH_THRESHOLD:
6203 weak_hash_threshold = atoi (optarg); break;
6204 //case IDX_SESSION: session = optarg; break;
6205 case IDX_SESSION: break;
6206 case IDX_HASH_MODE: hash_mode = atoi (optarg);
6207 hash_mode_chgd = 1; break;
6208 case IDX_RUNTIME: runtime = atoi (optarg);
6209 runtime_chgd = 1; break;
6210 case IDX_ATTACK_MODE: attack_mode = atoi (optarg);
6211 attack_mode_chgd = 1; break;
6212 case IDX_RP_FILE: rp_files[rp_files_cnt++] = optarg; break;
6213 case IDX_RP_GEN: rp_gen = atoi (optarg); break;
6214 case IDX_RP_GEN_FUNC_MIN: rp_gen_func_min = atoi (optarg); break;
6215 case IDX_RP_GEN_FUNC_MAX: rp_gen_func_max = atoi (optarg); break;
6216 case IDX_RP_GEN_SEED: rp_gen_seed = atoi (optarg);
6217 rp_gen_seed_chgd = 1; break;
6218 case IDX_RULE_BUF_L: rule_buf_l = optarg; break;
6219 case IDX_RULE_BUF_R: rule_buf_r = optarg; break;
6220 case IDX_MARKOV_DISABLE: markov_disable = 1; break;
6221 case IDX_MARKOV_CLASSIC: markov_classic = 1; break;
6222 case IDX_MARKOV_THRESHOLD: markov_threshold = atoi (optarg); break;
6223 case IDX_MARKOV_HCSTAT: markov_hcstat = optarg; break;
6224 case IDX_OUTFILE: outfile = optarg; break;
6225 case IDX_OUTFILE_FORMAT: outfile_format = atoi (optarg);
6226 outfile_format_chgd = 1; break;
6227 case IDX_OUTFILE_AUTOHEX_DISABLE:
6228 outfile_autohex = 0; break;
6229 case IDX_OUTFILE_CHECK_TIMER:
6230 outfile_check_timer = atoi (optarg); break;
6231 case IDX_HEX_CHARSET: hex_charset = 1; break;
6232 case IDX_HEX_SALT: hex_salt = 1; break;
6233 case IDX_HEX_WORDLIST: hex_wordlist = 1; break;
6234 case IDX_CPU_AFFINITY: cpu_affinity = optarg; break;
6235 case IDX_GPU_ASYNC: gpu_async = 1; break;
6236 case IDX_GPU_DEVICES: gpu_devices = optarg; break;
6237 case IDX_WORKLOAD_PROFILE: workload_profile = atoi (optarg); break;
6238 case IDX_GPU_ACCEL: gpu_accel = atoi (optarg);
6239 gpu_accel_chgd = 1; break;
6240 case IDX_GPU_LOOPS: gpu_loops = atoi (optarg);
6241 gpu_loops_chgd = 1; break;
6242 case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break;
6243 case IDX_GPU_TEMP_ABORT:
6244 #if _OCL
6245 gpu_temp_abort_chgd = 1;
6246 #endif
6247 gpu_temp_abort = atoi (optarg); break;
6248 case IDX_GPU_TEMP_RETAIN:
6249 #if _OCL
6250 gpu_temp_retain_chgd = 1;
6251 #endif
6252 gpu_temp_retain = atoi (optarg); break;
6253 case IDX_POWERTUNE_ENABLE: powertune_enable = 1; break;
6254 case IDX_LOGFILE_DISABLE: logfile_disable = 1; break;
6255 case IDX_TRUECRYPT_KEYFILES: truecrypt_keyfiles = optarg; break;
6256 case IDX_SEGMENT_SIZE: segment_size = atoi (optarg); break;
6257 case IDX_SCRYPT_TMTO: scrypt_tmto = atoi (optarg); break;
6258 case IDX_SEPARATOR: separator = optarg[0]; break;
6259 case IDX_BITMAP_MIN: bitmap_min = atoi (optarg); break;
6260 case IDX_BITMAP_MAX: bitmap_max = atoi (optarg); break;
6261 case IDX_INCREMENT: increment = 1; break;
6262 case IDX_INCREMENT_MIN: increment_min = atoi (optarg);
6263 increment_min_chgd = 1; break;
6264 case IDX_INCREMENT_MAX: increment_max = atoi (optarg);
6265 increment_max_chgd = 1; break;
6266 case IDX_CUSTOM_CHARSET_1: custom_charset_1 = optarg; break;
6267 case IDX_CUSTOM_CHARSET_2: custom_charset_2 = optarg; break;
6268 case IDX_CUSTOM_CHARSET_3: custom_charset_3 = optarg; break;
6269 case IDX_CUSTOM_CHARSET_4: custom_charset_4 = optarg; break;
6270
6271 default:
6272 log_error ("ERROR: Invalid argument specified");
6273 return (-1);
6274 }
6275 }
6276
6277 if (optopt != 0)
6278 {
6279 log_error ("ERROR: Invalid argument specified");
6280
6281 return (-1);
6282 }
6283
6284 /**
6285 * Inform user things getting started,
6286 * - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
6287 * - we do not need to check algorithm_pos
6288 */
6289
6290 if (quiet == 0)
6291 {
6292 if (benchmark == 1)
6293 {
6294 log_info ("%s v%.2f starting in benchmark-mode...", PROGNAME, (float) VERSION_BIN / 100);
6295
6296 log_info ("");
6297 }
6298 else if (restore == 1)
6299 {
6300 log_info ("%s v%.2f starting in restore-mode...", PROGNAME, (float) VERSION_BIN / 100);
6301
6302 log_info ("");
6303 }
6304 else
6305 {
6306 log_info ("%s v%.2f starting...", PROGNAME, (float) VERSION_BIN / 100);
6307
6308 log_info ("");
6309 }
6310 }
6311
6312 /**
6313 * sanity check
6314 */
6315
6316 if (attack_mode > 7)
6317 {
6318 log_error ("ERROR: Invalid attack-mode specified");
6319
6320 return (-1);
6321 }
6322
6323 if (runtime_chgd && runtime == 0) // just added to remove compiler warnings for runtime_chgd
6324 {
6325 log_error ("ERROR: Invalid runtime specified");
6326
6327 return (-1);
6328 }
6329
6330 if (hash_mode_chgd && hash_mode > 12800) // just added to remove compiler warnings for hash_mode_chgd
6331 {
6332 log_error ("ERROR: Invalid hash-type specified");
6333
6334 return (-1);
6335 }
6336
6337 // renamed hash modes
6338
6339 if (hash_mode_chgd)
6340 {
6341 int n = -1;
6342
6343 switch (hash_mode)
6344 {
6345 case 123: n = 124;
6346 break;
6347 }
6348
6349 if (n >= 0)
6350 {
6351 log_error ("Old -m specified, use -m %d instead", n);
6352
6353 return (-1);
6354 }
6355 }
6356
6357 if (username == 1)
6358 {
6359 if ((hash_mode == 2500) || (hash_mode == 5200) || ((hash_mode >= 6200) && (hash_mode <= 6299)))
6360 {
6361 log_error ("ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (hash_mode));
6362
6363 return (-1);
6364 }
6365 }
6366
6367 if (outfile_format > 16)
6368 {
6369 log_error ("ERROR: Invalid outfile-format specified");
6370
6371 return (-1);
6372 }
6373
6374 if (left == 1)
6375 {
6376 if (outfile_format_chgd == 1)
6377 {
6378 if (outfile_format > 1)
6379 {
6380 log_error ("ERROR: Mixing outfile-format > 1 is not allowed together with left parameter");
6381
6382 return (-1);
6383 }
6384 }
6385 else
6386 {
6387 outfile_format = OUTFILE_FMT_HASH;
6388 }
6389 }
6390
6391 if (show == 1)
6392 {
6393 if (outfile_format_chgd == 1)
6394 {
6395 if ((outfile_format > 7) && (outfile_format < 16))
6396 {
6397 log_error ("ERROR: Mixing outfile-format > 7 is not allowed together with show parameter");
6398
6399 return (-1);
6400 }
6401 }
6402 }
6403
6404 if (increment_min < INCREMENT_MIN)
6405 {
6406 log_error ("ERROR: Invalid increment-min specified");
6407
6408 return (-1);
6409 }
6410
6411 if (increment_max > INCREMENT_MAX)
6412 {
6413 log_error ("ERROR: Invalid increment-max specified");
6414
6415 return (-1);
6416 }
6417
6418 if (increment_min > increment_max)
6419 {
6420 log_error ("ERROR: Invalid increment-min specified");
6421
6422 return (-1);
6423 }
6424
6425 if ((increment == 1) && (attack_mode == ATTACK_MODE_STRAIGHT))
6426 {
6427 log_error ("ERROR: increment is not allowed in attack-mode 0");
6428
6429 return (-1);
6430 }
6431
6432 if ((increment == 0) && (increment_min_chgd == 1))
6433 {
6434 log_error ("ERROR: increment-min is only supported together with increment switch");
6435
6436 return (-1);
6437 }
6438
6439 if ((increment == 0) && (increment_max_chgd == 1))
6440 {
6441 log_error ("ERROR: increment-max is only supported together with increment switch");
6442
6443 return (-1);
6444 }
6445
6446 if (rp_files_cnt && rp_gen)
6447 {
6448 log_error ("ERROR: Use of both rules-file and rules-generate is not supported");
6449
6450 return (-1);
6451 }
6452
6453 if (rp_files_cnt || rp_gen)
6454 {
6455 if (attack_mode != ATTACK_MODE_STRAIGHT)
6456 {
6457 log_error ("ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0");
6458
6459 return (-1);
6460 }
6461 }
6462
6463 if (rp_gen_func_min > rp_gen_func_max)
6464 {
6465 log_error ("ERROR: Invalid rp-gen-func-min specified");
6466
6467 return (-1);
6468 }
6469
6470 if (gpu_accel_chgd == 1)
6471 {
6472 if (workload_profile != WORKLOAD_PROFILE)
6473 {
6474 log_error ("ERROR: gpu-accel parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
6475
6476 return (-1);
6477 }
6478
6479 if (gpu_accel < 1)
6480 {
6481 log_error ("ERROR: Invalid gpu-accel specified");
6482
6483 return (-1);
6484 }
6485
6486 if (gpu_accel > 800)
6487 {
6488 log_error ("ERROR: Invalid gpu-accel specified");
6489
6490 return (-1);
6491 }
6492 }
6493
6494 if (gpu_loops_chgd == 1)
6495 {
6496 if (workload_profile != WORKLOAD_PROFILE)
6497 {
6498 log_error ("ERROR: gpu-loops parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
6499
6500 return (-1);
6501 }
6502
6503 if (gpu_loops < 1)
6504 {
6505 log_error ("ERROR: Invalid gpu-loops specified");
6506
6507 return (-1);
6508 }
6509
6510 if (gpu_loops > 1024)
6511 {
6512 log_error ("ERROR: Invalid gpu-loops specified");
6513
6514 return (-1);
6515 }
6516 }
6517
6518 if (benchmark == 1)
6519 {
6520 if (workload_profile != WORKLOAD_PROFILE)
6521 {
6522 log_error ("ERROR: Using the workload-profile in benchmark mode is not allowed");
6523
6524 return (-1);
6525 }
6526 }
6527
6528 if ((workload_profile < 1) || (workload_profile > 3))
6529 {
6530 log_error ("ERROR: workload-profile %i not available", workload_profile);
6531
6532 return (-1);
6533 }
6534
6535 if (show == 1 || left == 1)
6536 {
6537 attack_mode = ATTACK_MODE_NONE;
6538
6539 if (remove == 1)
6540 {
6541 log_error ("ERROR: Mixing remove parameter not allowed with show parameter or left parameter");
6542
6543 return (-1);
6544 }
6545
6546 if (potfile_disable == 1)
6547 {
6548 log_error ("ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter");
6549
6550 return (-1);
6551 }
6552 }
6553
6554 uint attack_kern = ATTACK_KERN_NONE;
6555
6556 switch (attack_mode)
6557 {
6558 case ATTACK_MODE_STRAIGHT: attack_kern = ATTACK_KERN_STRAIGHT; break;
6559 case ATTACK_MODE_COMBI: attack_kern = ATTACK_KERN_COMBI; break;
6560 case ATTACK_MODE_BF: attack_kern = ATTACK_KERN_BF; break;
6561 case ATTACK_MODE_HYBRID1: attack_kern = ATTACK_KERN_COMBI; break;
6562 case ATTACK_MODE_HYBRID2: attack_kern = ATTACK_KERN_COMBI; break;
6563 }
6564
6565 if (benchmark == 0)
6566 {
6567 if (keyspace == 1)
6568 {
6569 int num_additional_params = 1;
6570
6571 if (attack_kern == ATTACK_KERN_COMBI)
6572 {
6573 num_additional_params = 2;
6574 }
6575
6576 int keyspace_wordlist_specified = myargc - optind - num_additional_params;
6577
6578 if (keyspace_wordlist_specified == 0) optind--;
6579 }
6580
6581 if (attack_kern == ATTACK_KERN_NONE)
6582 {
6583 if ((optind + 1) != myargc)
6584 {
6585 usage_mini_print (myargv[0]);
6586
6587 return (-1);
6588 }
6589 }
6590 else if (attack_kern == ATTACK_KERN_STRAIGHT)
6591 {
6592 if ((optind + 1) > myargc)
6593 {
6594 usage_mini_print (myargv[0]);
6595
6596 return (-1);
6597 }
6598 }
6599 else if (attack_kern == ATTACK_KERN_COMBI)
6600 {
6601 if ((optind + 3) != myargc)
6602 {
6603 usage_mini_print (myargv[0]);
6604
6605 return (-1);
6606 }
6607 }
6608 else if (attack_kern == ATTACK_KERN_BF)
6609 {
6610 if ((optind + 1) > myargc)
6611 {
6612 usage_mini_print (myargv[0]);
6613
6614 return (-1);
6615 }
6616 }
6617 else
6618 {
6619 usage_mini_print (myargv[0]);
6620
6621 return (-1);
6622 }
6623 }
6624 else
6625 {
6626 if (myargv[optind] != 0)
6627 {
6628 log_error ("ERROR: Invalid argument for benchmark mode specified");
6629
6630 return (-1);
6631 }
6632
6633 if (attack_mode_chgd == 1)
6634 {
6635 if (attack_mode != ATTACK_MODE_BF)
6636 {
6637 log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode");
6638
6639 return (-1);
6640 }
6641 }
6642
6643 if (benchmark_mode == 0)
6644 {
6645 // nothing to do
6646 }
6647 else if (benchmark_mode == 1)
6648 {
6649 if (gpu_accel_chgd == 1 || gpu_loops_chgd == 1)
6650 {
6651 log_error ("ERROR: Benchmark-mode 1 does not allow gpu-accel or gpu-loops changed");
6652
6653 return (-1);
6654 }
6655 }
6656 else
6657 {
6658 log_error ("ERROR: Benchmark-mode must be 0 or 1");
6659
6660 return (-1);
6661 }
6662 }
6663
6664 if (skip != 0 && limit != 0)
6665 {
6666 limit += skip;
6667 }
6668
6669 if (keyspace == 1)
6670 {
6671 if (show == 1)
6672 {
6673 log_error ("ERROR: Mixing show parameter not supported with keyspace parameter");
6674
6675 return (-1);
6676 }
6677 else if (left == 1)
6678 {
6679 log_error ("ERROR: Mixing left parameter not supported wiht keyspace parameter");
6680
6681 return (-1);
6682 }
6683
6684 potfile_disable = 1;
6685
6686 restore_disable = 1;
6687
6688 restore = 0;
6689
6690 weak_hash_threshold = 0;
6691
6692 quiet = 1;
6693 }
6694
6695 if (remove_timer_chgd == 1)
6696 {
6697 if (remove == 0)
6698 {
6699 log_error ("ERROR: Parameter remove-timer require parameter remove enabled");
6700
6701 return (-1);
6702 }
6703
6704 if (remove_timer < 1)
6705 {
6706 log_error ("ERROR: Parameter remove-timer must have a value greater than or equal to 1");
6707
6708 return (-1);
6709 }
6710 }
6711
6712 if (loopback == 1)
6713 {
6714 if (attack_mode == ATTACK_MODE_BF)
6715 {
6716 log_error ("ERROR: Parameter loopback not allowed in attack-mode 3");
6717
6718 return (-1);
6719 }
6720 else if (attack_mode == ATTACK_MODE_STRAIGHT)
6721 {
6722 if ((rp_files_cnt == 0) && (rp_gen == 0))
6723 {
6724 log_error ("ERROR: Parameter loopback not allowed without rules-file or rules-generate");
6725
6726 return (-1);
6727 }
6728 }
6729 }
6730
6731 if (debug_mode > 0)
6732 {
6733 if (attack_mode != ATTACK_MODE_STRAIGHT)
6734 {
6735 log_error ("ERROR: Parameter debug-mode option is only available with attack-mode 0");
6736
6737 return (-1);
6738 }
6739
6740 if ((rp_files_cnt == 0) && (rp_gen == 0))
6741 {
6742 log_error ("ERROR: Parameter debug-mode not allowed without rules-file or rules-generate");
6743
6744 return (-1);
6745 }
6746 }
6747
6748 if (debug_mode > 4)
6749 {
6750 log_error ("ERROR: Invalid debug-mode specified");
6751
6752 return (-1);
6753 }
6754
6755 if (debug_file != NULL)
6756 {
6757 if (debug_mode < 1)
6758 {
6759 log_error ("ERROR: Parameter debug-file requires parameter debug-mode to be set");
6760
6761 return (-1);
6762 }
6763 }
6764
6765 if (induction_dir != NULL)
6766 {
6767 if (attack_mode == ATTACK_MODE_BF)
6768 {
6769 log_error ("ERROR: Parameter induction-dir not allowed with brute-force attacks");
6770
6771 return (-1);
6772 }
6773 }
6774
6775 /**
6776 * induction directory
6777 */
6778
6779 char *induction_directory = NULL;
6780
6781 if (attack_mode != ATTACK_MODE_BF)
6782 {
6783 if (induction_dir == NULL)
6784 {
6785 induction_directory = (char *) mymalloc (session_size);
6786
6787 snprintf (induction_directory, session_size - 1, "%s.%s", session, INDUCT_DIR);
6788
6789 // create induction folder if it does not already exist
6790
6791 if (keyspace == 0)
6792 {
6793 if (rmdir (induction_directory) == -1)
6794 {
6795 if (errno == ENOENT)
6796 {
6797 // good, we can ignore
6798 }
6799 else if (errno == ENOTEMPTY)
6800 {
6801 char *induction_directory_mv = (char *) mymalloc (session_size);
6802
6803 snprintf (induction_directory_mv, session_size - 1, "%s.induct.%d", session, (int) proc_start);
6804
6805 if (rename (induction_directory, induction_directory_mv) != 0)
6806 {
6807 log_error ("ERROR: Rename directory %s to %s: %s", induction_directory, induction_directory_mv, strerror (errno));
6808
6809 return (-1);
6810 }
6811 }
6812 else
6813 {
6814 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6815
6816 return (-1);
6817 }
6818 }
6819
6820 #ifdef _WIN
6821 #define mkdir(name,mode) mkdir (name)
6822 #endif
6823
6824 if (mkdir (induction_directory, 0700) == -1)
6825 {
6826 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6827
6828 return (-1);
6829 }
6830 }
6831 }
6832 else
6833 {
6834 induction_directory = induction_dir;
6835 }
6836 }
6837
6838 data.induction_directory = induction_directory;
6839
6840 /**
6841 * loopback
6842 */
6843
6844 size_t loopback_size = session_size + strlen (LOOPBACK_FILE) + 12;
6845
6846 char *loopback_file = (char *) mymalloc (loopback_size);
6847
6848 /**
6849 * outfile-check directory
6850 */
6851
6852 char *outfile_check_directory = NULL;
6853
6854 if (outfile_check_dir == NULL)
6855 {
6856 outfile_check_directory = (char *) mymalloc (session_size);
6857
6858 snprintf (outfile_check_directory, session_size - 1, "%s.%s", session, OUTFILES_DIR);
6859 }
6860 else
6861 {
6862 outfile_check_directory = outfile_check_dir;
6863 }
6864
6865 data.outfile_check_directory = outfile_check_directory;
6866
6867 if (keyspace == 0)
6868 {
6869 struct stat outfile_check_stat;
6870
6871 if (stat (outfile_check_directory, &outfile_check_stat) == 0)
6872 {
6873 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
6874
6875 if (is_dir == 0)
6876 {
6877 log_error ("ERROR: Directory specified in outfile-check '%s' is not a valid directory", outfile_check_directory);
6878
6879 return (-1);
6880 }
6881 }
6882 else if (outfile_check_dir == NULL)
6883 {
6884 #ifdef _WIN
6885 #define mkdir(name,mode) mkdir (name)
6886 #endif
6887
6888 if (mkdir (outfile_check_directory, 0700) == -1)
6889 {
6890 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
6891
6892 return (-1);
6893 }
6894 }
6895 }
6896
6897 /**
6898 * special other stuff
6899 */
6900
6901 if (hash_mode == 9710)
6902 {
6903 outfile_format = 5;
6904 outfile_format_chgd = 1;
6905 }
6906
6907 if (hash_mode == 9810)
6908 {
6909 outfile_format = 5;
6910 outfile_format_chgd = 1;
6911 }
6912
6913 if (hash_mode == 10410)
6914 {
6915 outfile_format = 5;
6916 outfile_format_chgd = 1;
6917 }
6918
6919 /**
6920 * store stuff
6921 */
6922
6923 data.hash_mode = hash_mode;
6924 data.restore = restore;
6925 data.restore_timer = restore_timer;
6926 data.restore_disable = restore_disable;
6927 data.status = status;
6928 data.status_timer = status_timer;
6929 data.status_automat = status_automat;
6930 data.loopback = loopback;
6931 data.runtime = runtime;
6932 data.remove = remove;
6933 data.remove_timer = remove_timer;
6934 data.debug_mode = debug_mode;
6935 data.debug_file = debug_file;
6936 data.username = username;
6937 data.quiet = quiet;
6938 data.outfile = outfile;
6939 data.outfile_format = outfile_format;
6940 data.outfile_autohex = outfile_autohex;
6941 data.hex_charset = hex_charset;
6942 data.hex_salt = hex_salt;
6943 data.hex_wordlist = hex_wordlist;
6944 data.separator = separator;
6945 data.rp_files = rp_files;
6946 data.rp_files_cnt = rp_files_cnt;
6947 data.rp_gen = rp_gen;
6948 data.rp_gen_seed = rp_gen_seed;
6949 data.force = force;
6950 data.benchmark = benchmark;
6951 data.skip = skip;
6952 data.limit = limit;
6953 data.powertune_enable = powertune_enable;
6954 data.logfile_disable = logfile_disable;
6955 data.truecrypt_keyfiles = truecrypt_keyfiles;
6956 data.scrypt_tmto = scrypt_tmto;
6957
6958 /**
6959 * install_dir
6960 */
6961
6962 char *install_dir = get_install_dir (myargv[0]);
6963
6964 data.install_dir = install_dir;
6965
6966 /**
6967 * cpu affinity
6968 */
6969
6970 if (cpu_affinity)
6971 {
6972 set_cpu_affinity (cpu_affinity);
6973 }
6974
6975 if (rp_gen_seed_chgd == 0)
6976 {
6977 srand (proc_start);
6978 }
6979 else
6980 {
6981 srand (rp_gen_seed);
6982 }
6983
6984 /**
6985 * logfile init
6986 */
6987
6988 if (logfile_disable == 0)
6989 {
6990 size_t logfile_size = strlen (session) + 32;
6991
6992 char *logfile = (char *) mymalloc (logfile_size);
6993
6994 snprintf (logfile, logfile_size - 1, "%s.log", session);
6995
6996 data.logfile = logfile;
6997
6998 char *topid = logfile_generate_topid ();
6999
7000 data.topid = topid;
7001 }
7002
7003 // logfile_append() checks for logfile_disable internally to make it easier from here
7004
7005 #define logfile_top_msg(msg) logfile_append ("%s\t%s", data.topid, (msg));
7006 #define logfile_sub_msg(msg) logfile_append ("%s\t%s\t%s", data.topid, data.subid, (msg));
7007 #define logfile_top_var_uint64(var,val) logfile_append ("%s\t%s\t%llu", data.topid, (var), (val));
7008 #define logfile_sub_var_uint64(var,val) logfile_append ("%s\t%s\t%s\t%llu", data.topid, data.subid, (var), (val));
7009 #define logfile_top_var_uint(var,val) logfile_append ("%s\t%s\t%u", data.topid, (var), (val));
7010 #define logfile_sub_var_uint(var,val) logfile_append ("%s\t%s\t%s\t%u", data.topid, data.subid, (var), (val));
7011 #define logfile_top_var_char(var,val) logfile_append ("%s\t%s\t%c", data.topid, (var), (val));
7012 #define logfile_sub_var_char(var,val) logfile_append ("%s\t%s\t%s\t%c", data.topid, data.subid, (var), (val));
7013 #define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append ("%s\t%s\t%s", data.topid, (var), (val));
7014 #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));
7015
7016 #define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var));
7017 #define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
7018 #define logfile_top_uint(var) logfile_top_var_uint (#var, (var));
7019 #define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var));
7020 #define logfile_top_char(var) logfile_top_var_char (#var, (var));
7021 #define logfile_sub_char(var) logfile_sub_var_char (#var, (var));
7022 #define logfile_top_string(var) logfile_top_var_string (#var, (var));
7023 #define logfile_sub_string(var) logfile_sub_var_string (#var, (var));
7024
7025 logfile_top_msg ("START");
7026
7027 logfile_top_uint (attack_mode);
7028 logfile_top_uint (attack_kern);
7029 logfile_top_uint (benchmark);
7030 logfile_top_uint (benchmark_mode);
7031 logfile_top_uint (bitmap_min);
7032 logfile_top_uint (bitmap_max);
7033 logfile_top_uint (debug_mode);
7034 logfile_top_uint (force);
7035 logfile_top_uint (gpu_accel);
7036 logfile_top_uint (gpu_async);
7037 logfile_top_uint (gpu_loops);
7038 logfile_top_uint (gpu_temp_abort);
7039 logfile_top_uint (gpu_temp_disable);
7040 logfile_top_uint (gpu_temp_retain);
7041 logfile_top_uint (hash_mode);
7042 logfile_top_uint (hex_charset);
7043 logfile_top_uint (hex_salt);
7044 logfile_top_uint (hex_wordlist);
7045 logfile_top_uint (increment);
7046 logfile_top_uint (increment_max);
7047 logfile_top_uint (increment_min);
7048 logfile_top_uint (keyspace);
7049 logfile_top_uint (left);
7050 logfile_top_uint (logfile_disable);
7051 logfile_top_uint (loopback);
7052 logfile_top_uint (markov_classic);
7053 logfile_top_uint (markov_disable);
7054 logfile_top_uint (markov_threshold);
7055 logfile_top_uint (outfile_autohex);
7056 logfile_top_uint (outfile_check_timer);
7057 logfile_top_uint (outfile_format);
7058 logfile_top_uint (potfile_disable);
7059 logfile_top_uint (powertune_enable);
7060 logfile_top_uint (scrypt_tmto);
7061 logfile_top_uint (quiet);
7062 logfile_top_uint (remove);
7063 logfile_top_uint (remove_timer);
7064 logfile_top_uint (restore);
7065 logfile_top_uint (restore_disable);
7066 logfile_top_uint (restore_timer);
7067 logfile_top_uint (rp_gen);
7068 logfile_top_uint (rp_gen_func_max);
7069 logfile_top_uint (rp_gen_func_min);
7070 logfile_top_uint (rp_gen_seed);
7071 logfile_top_uint (runtime);
7072 logfile_top_uint (segment_size);
7073 logfile_top_uint (show);
7074 logfile_top_uint (status);
7075 logfile_top_uint (status_automat);
7076 logfile_top_uint (status_timer);
7077 logfile_top_uint (usage);
7078 logfile_top_uint (username);
7079 logfile_top_uint (version);
7080 logfile_top_uint (weak_hash_threshold);
7081 logfile_top_uint (workload_profile);
7082 logfile_top_uint64 (limit);
7083 logfile_top_uint64 (skip);
7084 logfile_top_char (separator);
7085 logfile_top_string (cpu_affinity);
7086 logfile_top_string (custom_charset_1);
7087 logfile_top_string (custom_charset_2);
7088 logfile_top_string (custom_charset_3);
7089 logfile_top_string (custom_charset_4);
7090 logfile_top_string (debug_file);
7091 logfile_top_string (gpu_devices);
7092 logfile_top_string (induction_dir);
7093 logfile_top_string (markov_hcstat);
7094 logfile_top_string (outfile);
7095 logfile_top_string (outfile_check_dir);
7096 logfile_top_string (rule_buf_l);
7097 logfile_top_string (rule_buf_r);
7098 logfile_top_string (session);
7099 logfile_top_string (truecrypt_keyfiles);
7100
7101 /**
7102 * devices
7103 */
7104
7105 uint gpu_devicemask = devices_to_devicemask (gpu_devices);
7106
7107 /**
7108 * benchmark
7109 */
7110
7111 if (benchmark == 1)
7112 {
7113 /**
7114 * disable useless stuff for benchmark
7115 */
7116
7117 restore_timer = 0;
7118 status_timer = 0;
7119 restore_disable = 1;
7120 potfile_disable = 1;
7121 weak_hash_threshold = 0;
7122
7123 data.restore_timer = restore_timer;
7124 data.status_timer = status_timer;
7125 data.restore_disable = restore_disable;
7126
7127 if (benchmark_mode == 1)
7128 {
7129 markov_disable = 1;
7130 }
7131
7132 /**
7133 * force attack mode to be bruteforce
7134 */
7135
7136 attack_mode = ATTACK_MODE_BF;
7137 attack_kern = ATTACK_KERN_BF;
7138
7139 if (runtime_chgd == 0)
7140 {
7141 runtime = 4;
7142
7143 if (benchmark_mode == 1) runtime = 17;
7144
7145 data.runtime = runtime;
7146 }
7147 }
7148
7149 /**
7150 * config
7151 */
7152
7153 uint hash_type = 0;
7154 uint salt_type = 0;
7155 uint attack_exec = 0;
7156 uint opts_type = 0;
7157 uint kern_type = 0;
7158 uint dgst_size = 0;
7159 uint esalt_size = 0;
7160 uint opti_type = 0;
7161 uint dgst_pos0 = -1;
7162 uint dgst_pos1 = -1;
7163 uint dgst_pos2 = -1;
7164 uint dgst_pos3 = -1;
7165
7166 int (*parse_func) (char *, uint, hash_t *);
7167 int (*sort_by_digest) (const void *, const void *);
7168
7169 uint algorithm_pos = 0;
7170 uint algorithm_max = 1;
7171
7172 uint *algorithms = default_benchmark_algorithms;
7173
7174 if (benchmark == 1 && hash_mode_chgd == 0) algorithm_max = NUM_DEFAULT_BENCHMARK_ALGORITHMS;
7175
7176 for (algorithm_pos = 0; algorithm_pos < algorithm_max; algorithm_pos++)
7177 {
7178 /*
7179 * We need to reset 'rd' in benchmark mode otherwise when the user hits 'bypass'
7180 * the following algos are skipped entirely
7181 */
7182
7183 if (algorithm_pos > 0)
7184 {
7185 local_free (rd);
7186
7187 rd = init_restore (argc, argv);
7188
7189 data.rd = rd;
7190 }
7191
7192 /**
7193 * update hash_mode in case of multihash benchmark
7194 */
7195
7196 if (benchmark == 1)
7197 {
7198 if (hash_mode_chgd == 0)
7199 {
7200 hash_mode = algorithms[algorithm_pos];
7201
7202 data.hash_mode = hash_mode;
7203 }
7204
7205 quiet = 1;
7206
7207 data.quiet = quiet;
7208 }
7209
7210 switch (hash_mode)
7211 {
7212 case 0: hash_type = HASH_TYPE_MD5;
7213 salt_type = SALT_TYPE_NONE;
7214 attack_exec = ATTACK_EXEC_ON_GPU;
7215 opts_type = OPTS_TYPE_PT_GENERATE_LE
7216 | OPTS_TYPE_PT_ADD80
7217 | OPTS_TYPE_PT_ADDBITS14;
7218 kern_type = KERN_TYPE_MD5;
7219 dgst_size = DGST_SIZE_4_4;
7220 parse_func = md5_parse_hash;
7221 sort_by_digest = sort_by_digest_4_4;
7222 opti_type = OPTI_TYPE_ZERO_BYTE
7223 | OPTI_TYPE_PRECOMPUTE_INIT
7224 | OPTI_TYPE_PRECOMPUTE_MERKLE
7225 | OPTI_TYPE_SCALAR_MODE
7226 | OPTI_TYPE_MEET_IN_MIDDLE
7227 | OPTI_TYPE_EARLY_SKIP
7228 | OPTI_TYPE_NOT_ITERATED
7229 | OPTI_TYPE_NOT_SALTED
7230 | OPTI_TYPE_RAW_HASH;
7231 dgst_pos0 = 0;
7232 dgst_pos1 = 3;
7233 dgst_pos2 = 2;
7234 dgst_pos3 = 1;
7235 break;
7236
7237 case 10: hash_type = HASH_TYPE_MD5;
7238 salt_type = SALT_TYPE_INTERN;
7239 attack_exec = ATTACK_EXEC_ON_GPU;
7240 opts_type = OPTS_TYPE_PT_GENERATE_LE
7241 | OPTS_TYPE_ST_ADD80
7242 | OPTS_TYPE_ST_ADDBITS14;
7243 kern_type = KERN_TYPE_MD5_PWSLT;
7244 dgst_size = DGST_SIZE_4_4;
7245 parse_func = md5s_parse_hash;
7246 sort_by_digest = sort_by_digest_4_4;
7247 opti_type = OPTI_TYPE_ZERO_BYTE
7248 | OPTI_TYPE_PRECOMPUTE_INIT
7249 | OPTI_TYPE_PRECOMPUTE_MERKLE
7250 | OPTI_TYPE_SCALAR_MODE
7251 | OPTI_TYPE_MEET_IN_MIDDLE
7252 | OPTI_TYPE_EARLY_SKIP
7253 | OPTI_TYPE_NOT_ITERATED
7254 | OPTI_TYPE_APPENDED_SALT
7255 | OPTI_TYPE_RAW_HASH;
7256 dgst_pos0 = 0;
7257 dgst_pos1 = 3;
7258 dgst_pos2 = 2;
7259 dgst_pos3 = 1;
7260 break;
7261
7262 case 11: hash_type = HASH_TYPE_MD5;
7263 salt_type = SALT_TYPE_INTERN;
7264 attack_exec = ATTACK_EXEC_ON_GPU;
7265 opts_type = OPTS_TYPE_PT_GENERATE_LE
7266 | OPTS_TYPE_ST_ADD80
7267 | OPTS_TYPE_ST_ADDBITS14;
7268 kern_type = KERN_TYPE_MD5_PWSLT;
7269 dgst_size = DGST_SIZE_4_4;
7270 parse_func = joomla_parse_hash;
7271 sort_by_digest = sort_by_digest_4_4;
7272 opti_type = OPTI_TYPE_ZERO_BYTE
7273 | OPTI_TYPE_PRECOMPUTE_INIT
7274 | OPTI_TYPE_PRECOMPUTE_MERKLE
7275 | OPTI_TYPE_SCALAR_MODE
7276 | OPTI_TYPE_MEET_IN_MIDDLE
7277 | OPTI_TYPE_EARLY_SKIP
7278 | OPTI_TYPE_NOT_ITERATED
7279 | OPTI_TYPE_APPENDED_SALT
7280 | OPTI_TYPE_RAW_HASH;
7281 dgst_pos0 = 0;
7282 dgst_pos1 = 3;
7283 dgst_pos2 = 2;
7284 dgst_pos3 = 1;
7285 break;
7286
7287 case 12: hash_type = HASH_TYPE_MD5;
7288 salt_type = SALT_TYPE_INTERN;
7289 attack_exec = ATTACK_EXEC_ON_GPU;
7290 opts_type = OPTS_TYPE_PT_GENERATE_LE
7291 | OPTS_TYPE_ST_ADD80
7292 | OPTS_TYPE_ST_ADDBITS14;
7293 kern_type = KERN_TYPE_MD5_PWSLT;
7294 dgst_size = DGST_SIZE_4_4;
7295 parse_func = postgresql_parse_hash;
7296 sort_by_digest = sort_by_digest_4_4;
7297 opti_type = OPTI_TYPE_ZERO_BYTE
7298 | OPTI_TYPE_PRECOMPUTE_INIT
7299 | OPTI_TYPE_PRECOMPUTE_MERKLE
7300 | OPTI_TYPE_SCALAR_MODE
7301 | OPTI_TYPE_MEET_IN_MIDDLE
7302 | OPTI_TYPE_EARLY_SKIP
7303 | OPTI_TYPE_NOT_ITERATED
7304 | OPTI_TYPE_APPENDED_SALT
7305 | OPTI_TYPE_RAW_HASH;
7306 dgst_pos0 = 0;
7307 dgst_pos1 = 3;
7308 dgst_pos2 = 2;
7309 dgst_pos3 = 1;
7310 break;
7311
7312 case 20: hash_type = HASH_TYPE_MD5;
7313 salt_type = SALT_TYPE_INTERN;
7314 attack_exec = ATTACK_EXEC_ON_GPU;
7315 opts_type = OPTS_TYPE_PT_GENERATE_LE
7316 | OPTS_TYPE_PT_ADD80
7317 | OPTS_TYPE_PT_ADDBITS14;
7318 kern_type = KERN_TYPE_MD5_SLTPW;
7319 dgst_size = DGST_SIZE_4_4;
7320 parse_func = md5s_parse_hash;
7321 sort_by_digest = sort_by_digest_4_4;
7322 opti_type = OPTI_TYPE_ZERO_BYTE
7323 | OPTI_TYPE_PRECOMPUTE_INIT
7324 | OPTI_TYPE_PRECOMPUTE_MERKLE
7325 | OPTI_TYPE_EARLY_SKIP
7326 | OPTI_TYPE_NOT_ITERATED
7327 | OPTI_TYPE_PREPENDED_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 21: 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 = osc_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 22: hash_type = HASH_TYPE_MD5;
7359 salt_type = SALT_TYPE_EMBEDDED;
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 = netscreen_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 23: 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 = skype_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 30: hash_type = HASH_TYPE_MD5;
7405 salt_type = SALT_TYPE_INTERN;
7406 attack_exec = ATTACK_EXEC_ON_GPU;
7407 opts_type = OPTS_TYPE_PT_GENERATE_LE
7408 | OPTS_TYPE_PT_UNICODE
7409 | OPTS_TYPE_ST_ADD80
7410 | OPTS_TYPE_ST_ADDBITS14;
7411 kern_type = KERN_TYPE_MD5_PWUSLT;
7412 dgst_size = DGST_SIZE_4_4;
7413 parse_func = md5s_parse_hash;
7414 sort_by_digest = sort_by_digest_4_4;
7415 opti_type = OPTI_TYPE_ZERO_BYTE
7416 | OPTI_TYPE_PRECOMPUTE_INIT
7417 | OPTI_TYPE_PRECOMPUTE_MERKLE
7418 | OPTI_TYPE_SCALAR_MODE
7419 | OPTI_TYPE_MEET_IN_MIDDLE
7420 | OPTI_TYPE_EARLY_SKIP
7421 | OPTI_TYPE_NOT_ITERATED
7422 | OPTI_TYPE_APPENDED_SALT
7423 | OPTI_TYPE_RAW_HASH;
7424 dgst_pos0 = 0;
7425 dgst_pos1 = 3;
7426 dgst_pos2 = 2;
7427 dgst_pos3 = 1;
7428 break;
7429
7430 case 40: hash_type = HASH_TYPE_MD5;
7431 salt_type = SALT_TYPE_INTERN;
7432 attack_exec = ATTACK_EXEC_ON_GPU;
7433 opts_type = OPTS_TYPE_PT_GENERATE_LE
7434 | OPTS_TYPE_PT_ADD80
7435 | OPTS_TYPE_PT_ADDBITS14
7436 | OPTS_TYPE_PT_UNICODE;
7437 kern_type = KERN_TYPE_MD5_SLTPWU;
7438 dgst_size = DGST_SIZE_4_4;
7439 parse_func = md5s_parse_hash;
7440 sort_by_digest = sort_by_digest_4_4;
7441 opti_type = OPTI_TYPE_ZERO_BYTE
7442 | OPTI_TYPE_PRECOMPUTE_INIT
7443 | OPTI_TYPE_PRECOMPUTE_MERKLE
7444 | OPTI_TYPE_EARLY_SKIP
7445 | OPTI_TYPE_NOT_ITERATED
7446 | OPTI_TYPE_PREPENDED_SALT
7447 | OPTI_TYPE_RAW_HASH;
7448 dgst_pos0 = 0;
7449 dgst_pos1 = 3;
7450 dgst_pos2 = 2;
7451 dgst_pos3 = 1;
7452 break;
7453
7454 case 50: hash_type = HASH_TYPE_MD5;
7455 salt_type = SALT_TYPE_INTERN;
7456 attack_exec = ATTACK_EXEC_ON_GPU;
7457 opts_type = OPTS_TYPE_PT_GENERATE_LE
7458 | OPTS_TYPE_ST_ADD80
7459 | OPTS_TYPE_ST_ADDBITS14;
7460 kern_type = KERN_TYPE_HMACMD5_PW;
7461 dgst_size = DGST_SIZE_4_4;
7462 parse_func = hmacmd5_parse_hash;
7463 sort_by_digest = sort_by_digest_4_4;
7464 opti_type = OPTI_TYPE_ZERO_BYTE
7465 | OPTI_TYPE_NOT_ITERATED;
7466 dgst_pos0 = 0;
7467 dgst_pos1 = 3;
7468 dgst_pos2 = 2;
7469 dgst_pos3 = 1;
7470 break;
7471
7472 case 60: hash_type = HASH_TYPE_MD5;
7473 salt_type = SALT_TYPE_INTERN;
7474 attack_exec = ATTACK_EXEC_ON_GPU;
7475 opts_type = OPTS_TYPE_PT_GENERATE_LE
7476 | OPTS_TYPE_PT_ADD80
7477 | OPTS_TYPE_PT_ADDBITS14;
7478 kern_type = KERN_TYPE_HMACMD5_SLT;
7479 dgst_size = DGST_SIZE_4_4;
7480 parse_func = hmacmd5_parse_hash;
7481 sort_by_digest = sort_by_digest_4_4;
7482 opti_type = OPTI_TYPE_ZERO_BYTE
7483 | OPTI_TYPE_NOT_ITERATED;
7484 dgst_pos0 = 0;
7485 dgst_pos1 = 3;
7486 dgst_pos2 = 2;
7487 dgst_pos3 = 1;
7488 break;
7489
7490 case 100: hash_type = HASH_TYPE_SHA1;
7491 salt_type = SALT_TYPE_NONE;
7492 attack_exec = ATTACK_EXEC_ON_GPU;
7493 opts_type = OPTS_TYPE_PT_GENERATE_BE
7494 | OPTS_TYPE_PT_ADD80
7495 | OPTS_TYPE_PT_ADDBITS15;
7496 kern_type = KERN_TYPE_SHA1;
7497 dgst_size = DGST_SIZE_4_5;
7498 parse_func = sha1_parse_hash;
7499 sort_by_digest = sort_by_digest_4_5;
7500 opti_type = OPTI_TYPE_ZERO_BYTE
7501 | OPTI_TYPE_PRECOMPUTE_INIT
7502 | OPTI_TYPE_PRECOMPUTE_MERKLE
7503 | OPTI_TYPE_SCALAR_MODE
7504 | OPTI_TYPE_EARLY_SKIP
7505 | OPTI_TYPE_NOT_ITERATED
7506 | OPTI_TYPE_NOT_SALTED
7507 | OPTI_TYPE_RAW_HASH;
7508 dgst_pos0 = 3;
7509 dgst_pos1 = 4;
7510 dgst_pos2 = 2;
7511 dgst_pos3 = 1;
7512 break;
7513
7514 case 101: hash_type = HASH_TYPE_SHA1;
7515 salt_type = SALT_TYPE_NONE;
7516 attack_exec = ATTACK_EXEC_ON_GPU;
7517 opts_type = OPTS_TYPE_PT_GENERATE_BE
7518 | OPTS_TYPE_PT_ADD80
7519 | OPTS_TYPE_PT_ADDBITS15;
7520 kern_type = KERN_TYPE_SHA1;
7521 dgst_size = DGST_SIZE_4_5;
7522 parse_func = sha1b64_parse_hash;
7523 sort_by_digest = sort_by_digest_4_5;
7524 opti_type = OPTI_TYPE_ZERO_BYTE
7525 | OPTI_TYPE_PRECOMPUTE_INIT
7526 | OPTI_TYPE_PRECOMPUTE_MERKLE
7527 | OPTI_TYPE_SCALAR_MODE
7528 | OPTI_TYPE_EARLY_SKIP
7529 | OPTI_TYPE_NOT_ITERATED
7530 | OPTI_TYPE_NOT_SALTED
7531 | OPTI_TYPE_RAW_HASH;
7532 dgst_pos0 = 3;
7533 dgst_pos1 = 4;
7534 dgst_pos2 = 2;
7535 dgst_pos3 = 1;
7536 break;
7537
7538 case 110: hash_type = HASH_TYPE_SHA1;
7539 salt_type = SALT_TYPE_INTERN;
7540 attack_exec = ATTACK_EXEC_ON_GPU;
7541 opts_type = OPTS_TYPE_PT_GENERATE_BE
7542 | OPTS_TYPE_ST_ADD80
7543 | OPTS_TYPE_ST_ADDBITS15;
7544 kern_type = KERN_TYPE_SHA1_PWSLT;
7545 dgst_size = DGST_SIZE_4_5;
7546 parse_func = sha1s_parse_hash;
7547 sort_by_digest = sort_by_digest_4_5;
7548 opti_type = OPTI_TYPE_ZERO_BYTE
7549 | OPTI_TYPE_PRECOMPUTE_INIT
7550 | OPTI_TYPE_PRECOMPUTE_MERKLE
7551 | OPTI_TYPE_SCALAR_MODE
7552 | OPTI_TYPE_EARLY_SKIP
7553 | OPTI_TYPE_NOT_ITERATED
7554 | OPTI_TYPE_APPENDED_SALT
7555 | OPTI_TYPE_RAW_HASH;
7556 dgst_pos0 = 3;
7557 dgst_pos1 = 4;
7558 dgst_pos2 = 2;
7559 dgst_pos3 = 1;
7560 break;
7561
7562 case 111: hash_type = HASH_TYPE_SHA1;
7563 salt_type = SALT_TYPE_EMBEDDED;
7564 attack_exec = ATTACK_EXEC_ON_GPU;
7565 opts_type = OPTS_TYPE_PT_GENERATE_BE
7566 | OPTS_TYPE_ST_ADD80
7567 | OPTS_TYPE_ST_ADDBITS15;
7568 kern_type = KERN_TYPE_SHA1_PWSLT;
7569 dgst_size = DGST_SIZE_4_5;
7570 parse_func = sha1b64s_parse_hash;
7571 sort_by_digest = sort_by_digest_4_5;
7572 opti_type = OPTI_TYPE_ZERO_BYTE
7573 | OPTI_TYPE_PRECOMPUTE_INIT
7574 | OPTI_TYPE_PRECOMPUTE_MERKLE
7575 | OPTI_TYPE_SCALAR_MODE
7576 | OPTI_TYPE_EARLY_SKIP
7577 | OPTI_TYPE_NOT_ITERATED
7578 | OPTI_TYPE_APPENDED_SALT
7579 | OPTI_TYPE_RAW_HASH;
7580 dgst_pos0 = 3;
7581 dgst_pos1 = 4;
7582 dgst_pos2 = 2;
7583 dgst_pos3 = 1;
7584 break;
7585
7586 case 112: hash_type = HASH_TYPE_SHA1;
7587 salt_type = SALT_TYPE_INTERN;
7588 attack_exec = ATTACK_EXEC_ON_GPU;
7589 opts_type = OPTS_TYPE_PT_GENERATE_BE
7590 | OPTS_TYPE_ST_ADD80
7591 | OPTS_TYPE_ST_ADDBITS15
7592 | OPTS_TYPE_ST_HEX;
7593 kern_type = KERN_TYPE_SHA1_PWSLT;
7594 dgst_size = DGST_SIZE_4_5;
7595 parse_func = oracles_parse_hash;
7596 sort_by_digest = sort_by_digest_4_5;
7597 opti_type = OPTI_TYPE_ZERO_BYTE
7598 | OPTI_TYPE_PRECOMPUTE_INIT
7599 | OPTI_TYPE_PRECOMPUTE_MERKLE
7600 | OPTI_TYPE_SCALAR_MODE
7601 | OPTI_TYPE_EARLY_SKIP
7602 | OPTI_TYPE_NOT_ITERATED
7603 | OPTI_TYPE_APPENDED_SALT
7604 | OPTI_TYPE_RAW_HASH;
7605 dgst_pos0 = 3;
7606 dgst_pos1 = 4;
7607 dgst_pos2 = 2;
7608 dgst_pos3 = 1;
7609 break;
7610
7611 case 120: hash_type = HASH_TYPE_SHA1;
7612 salt_type = SALT_TYPE_INTERN;
7613 attack_exec = ATTACK_EXEC_ON_GPU;
7614 opts_type = OPTS_TYPE_PT_GENERATE_BE
7615 | OPTS_TYPE_PT_ADD80
7616 | OPTS_TYPE_PT_ADDBITS15;
7617 kern_type = KERN_TYPE_SHA1_SLTPW;
7618 dgst_size = DGST_SIZE_4_5;
7619 parse_func = sha1s_parse_hash;
7620 sort_by_digest = sort_by_digest_4_5;
7621 opti_type = OPTI_TYPE_ZERO_BYTE
7622 | OPTI_TYPE_PRECOMPUTE_INIT
7623 | OPTI_TYPE_PRECOMPUTE_MERKLE
7624 | OPTI_TYPE_EARLY_SKIP
7625 | OPTI_TYPE_NOT_ITERATED
7626 | OPTI_TYPE_PREPENDED_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 121: 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 | OPTS_TYPE_ST_LOWER;
7641 kern_type = KERN_TYPE_SHA1_SLTPW;
7642 dgst_size = DGST_SIZE_4_5;
7643 parse_func = smf_parse_hash;
7644 sort_by_digest = sort_by_digest_4_5;
7645 opti_type = OPTI_TYPE_ZERO_BYTE
7646 | OPTI_TYPE_PRECOMPUTE_INIT
7647 | OPTI_TYPE_PRECOMPUTE_MERKLE
7648 | OPTI_TYPE_EARLY_SKIP
7649 | OPTI_TYPE_NOT_ITERATED
7650 | OPTI_TYPE_PREPENDED_SALT
7651 | OPTI_TYPE_RAW_HASH;
7652 dgst_pos0 = 3;
7653 dgst_pos1 = 4;
7654 dgst_pos2 = 2;
7655 dgst_pos3 = 1;
7656 break;
7657
7658 case 122: hash_type = HASH_TYPE_SHA1;
7659 salt_type = SALT_TYPE_EMBEDDED;
7660 attack_exec = ATTACK_EXEC_ON_GPU;
7661 opts_type = OPTS_TYPE_PT_GENERATE_BE
7662 | OPTS_TYPE_PT_ADD80
7663 | OPTS_TYPE_PT_ADDBITS15
7664 | OPTS_TYPE_ST_HEX;
7665 kern_type = KERN_TYPE_SHA1_SLTPW;
7666 dgst_size = DGST_SIZE_4_5;
7667 parse_func = osx1_parse_hash;
7668 sort_by_digest = sort_by_digest_4_5;
7669 opti_type = OPTI_TYPE_ZERO_BYTE
7670 | OPTI_TYPE_PRECOMPUTE_INIT
7671 | OPTI_TYPE_PRECOMPUTE_MERKLE
7672 | OPTI_TYPE_EARLY_SKIP
7673 | OPTI_TYPE_NOT_ITERATED
7674 | OPTI_TYPE_PREPENDED_SALT
7675 | OPTI_TYPE_RAW_HASH;
7676 dgst_pos0 = 3;
7677 dgst_pos1 = 4;
7678 dgst_pos2 = 2;
7679 dgst_pos3 = 1;
7680 break;
7681
7682 case 124: hash_type = HASH_TYPE_SHA1;
7683 salt_type = SALT_TYPE_EMBEDDED;
7684 attack_exec = ATTACK_EXEC_ON_GPU;
7685 opts_type = OPTS_TYPE_PT_GENERATE_BE
7686 | OPTS_TYPE_PT_ADD80
7687 | OPTS_TYPE_PT_ADDBITS15;
7688 kern_type = KERN_TYPE_SHA1_SLTPW;
7689 dgst_size = DGST_SIZE_4_5;
7690 parse_func = djangosha1_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 130: hash_type = HASH_TYPE_SHA1;
7706 salt_type = SALT_TYPE_INTERN;
7707 attack_exec = ATTACK_EXEC_ON_GPU;
7708 opts_type = OPTS_TYPE_PT_GENERATE_BE
7709 | OPTS_TYPE_PT_UNICODE
7710 | OPTS_TYPE_ST_ADD80
7711 | OPTS_TYPE_ST_ADDBITS15;
7712 kern_type = KERN_TYPE_SHA1_PWUSLT;
7713 dgst_size = DGST_SIZE_4_5;
7714 parse_func = sha1s_parse_hash;
7715 sort_by_digest = sort_by_digest_4_5;
7716 opti_type = OPTI_TYPE_ZERO_BYTE
7717 | OPTI_TYPE_PRECOMPUTE_INIT
7718 | OPTI_TYPE_PRECOMPUTE_MERKLE
7719 | OPTI_TYPE_SCALAR_MODE
7720 | OPTI_TYPE_EARLY_SKIP
7721 | OPTI_TYPE_NOT_ITERATED
7722 | OPTI_TYPE_APPENDED_SALT
7723 | OPTI_TYPE_RAW_HASH;
7724 dgst_pos0 = 3;
7725 dgst_pos1 = 4;
7726 dgst_pos2 = 2;
7727 dgst_pos3 = 1;
7728 break;
7729
7730 case 131: hash_type = HASH_TYPE_SHA1;
7731 salt_type = SALT_TYPE_EMBEDDED;
7732 attack_exec = ATTACK_EXEC_ON_GPU;
7733 opts_type = OPTS_TYPE_PT_GENERATE_BE
7734 | OPTS_TYPE_PT_UNICODE
7735 | OPTS_TYPE_PT_UPPER
7736 | OPTS_TYPE_ST_ADD80
7737 | OPTS_TYPE_ST_ADDBITS15
7738 | OPTS_TYPE_ST_HEX;
7739 kern_type = KERN_TYPE_SHA1_PWUSLT;
7740 dgst_size = DGST_SIZE_4_5;
7741 parse_func = mssql2000_parse_hash;
7742 sort_by_digest = sort_by_digest_4_5;
7743 opti_type = OPTI_TYPE_ZERO_BYTE
7744 | OPTI_TYPE_PRECOMPUTE_INIT
7745 | OPTI_TYPE_PRECOMPUTE_MERKLE
7746 | OPTI_TYPE_SCALAR_MODE
7747 | OPTI_TYPE_EARLY_SKIP
7748 | OPTI_TYPE_NOT_ITERATED
7749 | OPTI_TYPE_APPENDED_SALT
7750 | OPTI_TYPE_RAW_HASH;
7751 dgst_pos0 = 3;
7752 dgst_pos1 = 4;
7753 dgst_pos2 = 2;
7754 dgst_pos3 = 1;
7755 break;
7756
7757 case 132: hash_type = HASH_TYPE_SHA1;
7758 salt_type = SALT_TYPE_EMBEDDED;
7759 attack_exec = ATTACK_EXEC_ON_GPU;
7760 opts_type = OPTS_TYPE_PT_GENERATE_BE
7761 | OPTS_TYPE_PT_UNICODE
7762 | OPTS_TYPE_ST_ADD80
7763 | OPTS_TYPE_ST_ADDBITS15
7764 | OPTS_TYPE_ST_HEX;
7765 kern_type = KERN_TYPE_SHA1_PWUSLT;
7766 dgst_size = DGST_SIZE_4_5;
7767 parse_func = mssql2005_parse_hash;
7768 sort_by_digest = sort_by_digest_4_5;
7769 opti_type = OPTI_TYPE_ZERO_BYTE
7770 | OPTI_TYPE_PRECOMPUTE_INIT
7771 | OPTI_TYPE_PRECOMPUTE_MERKLE
7772 | OPTI_TYPE_SCALAR_MODE
7773 | OPTI_TYPE_EARLY_SKIP
7774 | OPTI_TYPE_NOT_ITERATED
7775 | OPTI_TYPE_APPENDED_SALT
7776 | OPTI_TYPE_RAW_HASH;
7777 dgst_pos0 = 3;
7778 dgst_pos1 = 4;
7779 dgst_pos2 = 2;
7780 dgst_pos3 = 1;
7781 break;
7782
7783 case 133: hash_type = HASH_TYPE_SHA1;
7784 salt_type = SALT_TYPE_EMBEDDED;
7785 attack_exec = ATTACK_EXEC_ON_GPU;
7786 opts_type = OPTS_TYPE_PT_GENERATE_BE
7787 | OPTS_TYPE_PT_UNICODE
7788 | OPTS_TYPE_ST_ADD80
7789 | OPTS_TYPE_ST_ADDBITS15;
7790 kern_type = KERN_TYPE_SHA1_PWUSLT;
7791 dgst_size = DGST_SIZE_4_5;
7792 parse_func = peoplesoft_parse_hash;
7793 sort_by_digest = sort_by_digest_4_5;
7794 opti_type = OPTI_TYPE_ZERO_BYTE
7795 | OPTI_TYPE_PRECOMPUTE_INIT
7796 | OPTI_TYPE_PRECOMPUTE_MERKLE
7797 | OPTI_TYPE_SCALAR_MODE
7798 | OPTI_TYPE_EARLY_SKIP
7799 | OPTI_TYPE_NOT_ITERATED
7800 | OPTI_TYPE_APPENDED_SALT
7801 | OPTI_TYPE_RAW_HASH;
7802 dgst_pos0 = 3;
7803 dgst_pos1 = 4;
7804 dgst_pos2 = 2;
7805 dgst_pos3 = 1;
7806 break;
7807
7808 case 140: hash_type = HASH_TYPE_SHA1;
7809 salt_type = SALT_TYPE_INTERN;
7810 attack_exec = ATTACK_EXEC_ON_GPU;
7811 opts_type = OPTS_TYPE_PT_GENERATE_BE
7812 | OPTS_TYPE_PT_ADD80
7813 | OPTS_TYPE_PT_ADDBITS15
7814 | OPTS_TYPE_PT_UNICODE;
7815 kern_type = KERN_TYPE_SHA1_SLTPWU;
7816 dgst_size = DGST_SIZE_4_5;
7817 parse_func = sha1s_parse_hash;
7818 sort_by_digest = sort_by_digest_4_5;
7819 opti_type = OPTI_TYPE_ZERO_BYTE
7820 | OPTI_TYPE_PRECOMPUTE_INIT
7821 | OPTI_TYPE_PRECOMPUTE_MERKLE
7822 | OPTI_TYPE_EARLY_SKIP
7823 | OPTI_TYPE_NOT_ITERATED
7824 | OPTI_TYPE_PREPENDED_SALT
7825 | OPTI_TYPE_RAW_HASH;
7826 dgst_pos0 = 3;
7827 dgst_pos1 = 4;
7828 dgst_pos2 = 2;
7829 dgst_pos3 = 1;
7830 break;
7831
7832 case 141: hash_type = HASH_TYPE_SHA1;
7833 salt_type = SALT_TYPE_EMBEDDED;
7834 attack_exec = ATTACK_EXEC_ON_GPU;
7835 opts_type = OPTS_TYPE_PT_GENERATE_BE
7836 | OPTS_TYPE_PT_ADD80
7837 | OPTS_TYPE_PT_ADDBITS15
7838 | OPTS_TYPE_PT_UNICODE
7839 | OPTS_TYPE_ST_BASE64;
7840 kern_type = KERN_TYPE_SHA1_SLTPWU;
7841 dgst_size = DGST_SIZE_4_5;
7842 parse_func = episerver_parse_hash;
7843 sort_by_digest = sort_by_digest_4_5;
7844 opti_type = OPTI_TYPE_ZERO_BYTE
7845 | OPTI_TYPE_PRECOMPUTE_INIT
7846 | OPTI_TYPE_PRECOMPUTE_MERKLE
7847 | OPTI_TYPE_EARLY_SKIP
7848 | OPTI_TYPE_NOT_ITERATED
7849 | OPTI_TYPE_PREPENDED_SALT
7850 | OPTI_TYPE_RAW_HASH;
7851 dgst_pos0 = 3;
7852 dgst_pos1 = 4;
7853 dgst_pos2 = 2;
7854 dgst_pos3 = 1;
7855 break;
7856
7857 case 150: hash_type = HASH_TYPE_SHA1;
7858 salt_type = SALT_TYPE_INTERN;
7859 attack_exec = ATTACK_EXEC_ON_GPU;
7860 opts_type = OPTS_TYPE_PT_GENERATE_BE
7861 | OPTS_TYPE_ST_ADD80
7862 | OPTS_TYPE_ST_ADDBITS15;
7863 kern_type = KERN_TYPE_HMACSHA1_PW;
7864 dgst_size = DGST_SIZE_4_5;
7865 parse_func = hmacsha1_parse_hash;
7866 sort_by_digest = sort_by_digest_4_5;
7867 opti_type = OPTI_TYPE_ZERO_BYTE
7868 | OPTI_TYPE_NOT_ITERATED;
7869 dgst_pos0 = 3;
7870 dgst_pos1 = 4;
7871 dgst_pos2 = 2;
7872 dgst_pos3 = 1;
7873 break;
7874
7875 case 160: hash_type = HASH_TYPE_SHA1;
7876 salt_type = SALT_TYPE_INTERN;
7877 attack_exec = ATTACK_EXEC_ON_GPU;
7878 opts_type = OPTS_TYPE_PT_GENERATE_BE
7879 | OPTS_TYPE_PT_ADD80
7880 | OPTS_TYPE_PT_ADDBITS15;
7881 kern_type = KERN_TYPE_HMACSHA1_SLT;
7882 dgst_size = DGST_SIZE_4_5;
7883 parse_func = hmacsha1_parse_hash;
7884 sort_by_digest = sort_by_digest_4_5;
7885 opti_type = OPTI_TYPE_ZERO_BYTE
7886 | OPTI_TYPE_NOT_ITERATED;
7887 dgst_pos0 = 3;
7888 dgst_pos1 = 4;
7889 dgst_pos2 = 2;
7890 dgst_pos3 = 1;
7891 break;
7892
7893 case 190: hash_type = HASH_TYPE_SHA1;
7894 salt_type = SALT_TYPE_NONE;
7895 attack_exec = ATTACK_EXEC_ON_GPU;
7896 opts_type = OPTS_TYPE_PT_GENERATE_BE
7897 | OPTS_TYPE_PT_ADD80
7898 | OPTS_TYPE_PT_ADDBITS15;
7899 kern_type = KERN_TYPE_SHA1_LINKEDIN;
7900 dgst_size = DGST_SIZE_4_5;
7901 parse_func = sha1linkedin_parse_hash;
7902 sort_by_digest = sort_by_digest_4_5;
7903 opti_type = OPTI_TYPE_ZERO_BYTE
7904 | OPTI_TYPE_PRECOMPUTE_INIT
7905 | OPTI_TYPE_SCALAR_MODE
7906 | OPTI_TYPE_EARLY_SKIP
7907 | OPTI_TYPE_NOT_ITERATED
7908 | OPTI_TYPE_NOT_SALTED;
7909 dgst_pos0 = 0;
7910 dgst_pos1 = 4;
7911 dgst_pos2 = 3;
7912 dgst_pos3 = 2;
7913 break;
7914
7915 case 200: hash_type = HASH_TYPE_MYSQL;
7916 salt_type = SALT_TYPE_NONE;
7917 attack_exec = ATTACK_EXEC_ON_GPU;
7918 opts_type = 0;
7919 kern_type = KERN_TYPE_MYSQL;
7920 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7921 parse_func = mysql323_parse_hash;
7922 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7923 opti_type = OPTI_TYPE_ZERO_BYTE
7924 | OPTI_TYPE_SCALAR_MODE;
7925 dgst_pos0 = 0;
7926 dgst_pos1 = 1;
7927 dgst_pos2 = 2;
7928 dgst_pos3 = 3;
7929 break;
7930
7931 case 300: hash_type = HASH_TYPE_SHA1;
7932 salt_type = SALT_TYPE_NONE;
7933 attack_exec = ATTACK_EXEC_ON_GPU;
7934 opts_type = OPTS_TYPE_PT_GENERATE_BE
7935 | OPTS_TYPE_PT_ADD80
7936 | OPTS_TYPE_PT_ADDBITS15;
7937 kern_type = KERN_TYPE_MYSQL41;
7938 dgst_size = DGST_SIZE_4_5;
7939 parse_func = sha1_parse_hash;
7940 sort_by_digest = sort_by_digest_4_5;
7941 opti_type = OPTI_TYPE_ZERO_BYTE
7942 | OPTI_TYPE_PRECOMPUTE_INIT
7943 | OPTI_TYPE_PRECOMPUTE_MERKLE
7944 | OPTI_TYPE_SCALAR_MODE
7945 | OPTI_TYPE_EARLY_SKIP
7946 | OPTI_TYPE_NOT_ITERATED
7947 | OPTI_TYPE_NOT_SALTED;
7948 dgst_pos0 = 3;
7949 dgst_pos1 = 4;
7950 dgst_pos2 = 2;
7951 dgst_pos3 = 1;
7952 break;
7953
7954 case 400: hash_type = HASH_TYPE_MD5;
7955 salt_type = SALT_TYPE_EMBEDDED;
7956 attack_exec = ATTACK_EXEC_ON_CPU;
7957 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7958 kern_type = KERN_TYPE_PHPASS;
7959 dgst_size = DGST_SIZE_4_4;
7960 parse_func = phpass_parse_hash;
7961 sort_by_digest = sort_by_digest_4_4;
7962 opti_type = OPTI_TYPE_ZERO_BYTE;
7963 dgst_pos0 = 0;
7964 dgst_pos1 = 1;
7965 dgst_pos2 = 2;
7966 dgst_pos3 = 3;
7967 break;
7968
7969 case 500: hash_type = HASH_TYPE_MD5;
7970 salt_type = SALT_TYPE_EMBEDDED;
7971 attack_exec = ATTACK_EXEC_ON_CPU;
7972 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7973 kern_type = KERN_TYPE_MD5CRYPT;
7974 dgst_size = DGST_SIZE_4_4;
7975 parse_func = md5crypt_parse_hash;
7976 sort_by_digest = sort_by_digest_4_4;
7977 opti_type = OPTI_TYPE_ZERO_BYTE;
7978 dgst_pos0 = 0;
7979 dgst_pos1 = 1;
7980 dgst_pos2 = 2;
7981 dgst_pos3 = 3;
7982 break;
7983
7984 case 501: hash_type = HASH_TYPE_MD5;
7985 salt_type = SALT_TYPE_EMBEDDED;
7986 attack_exec = ATTACK_EXEC_ON_CPU;
7987 opts_type = OPTS_TYPE_PT_GENERATE_LE
7988 | OPTS_TYPE_HASH_COPY;
7989 kern_type = KERN_TYPE_MD5CRYPT;
7990 dgst_size = DGST_SIZE_4_4;
7991 parse_func = juniper_parse_hash;
7992 sort_by_digest = sort_by_digest_4_4;
7993 opti_type = OPTI_TYPE_ZERO_BYTE;
7994 dgst_pos0 = 0;
7995 dgst_pos1 = 1;
7996 dgst_pos2 = 2;
7997 dgst_pos3 = 3;
7998 break;
7999
8000 case 900: hash_type = HASH_TYPE_MD4;
8001 salt_type = SALT_TYPE_NONE;
8002 attack_exec = ATTACK_EXEC_ON_GPU;
8003 opts_type = OPTS_TYPE_PT_GENERATE_LE
8004 | OPTS_TYPE_PT_ADD80
8005 | OPTS_TYPE_PT_ADDBITS14;
8006 kern_type = KERN_TYPE_MD4;
8007 dgst_size = DGST_SIZE_4_4;
8008 parse_func = md4_parse_hash;
8009 sort_by_digest = sort_by_digest_4_4;
8010 opti_type = OPTI_TYPE_ZERO_BYTE
8011 | OPTI_TYPE_PRECOMPUTE_INIT
8012 | OPTI_TYPE_PRECOMPUTE_MERKLE
8013 | OPTI_TYPE_SCALAR_MODE
8014 | OPTI_TYPE_MEET_IN_MIDDLE
8015 | OPTI_TYPE_EARLY_SKIP
8016 | OPTI_TYPE_NOT_ITERATED
8017 | OPTI_TYPE_NOT_SALTED
8018 | OPTI_TYPE_RAW_HASH;
8019 dgst_pos0 = 0;
8020 dgst_pos1 = 3;
8021 dgst_pos2 = 2;
8022 dgst_pos3 = 1;
8023 break;
8024
8025 case 1000: hash_type = HASH_TYPE_MD4;
8026 salt_type = SALT_TYPE_NONE;
8027 attack_exec = ATTACK_EXEC_ON_GPU;
8028 opts_type = OPTS_TYPE_PT_GENERATE_LE
8029 | OPTS_TYPE_PT_ADD80
8030 | OPTS_TYPE_PT_ADDBITS14
8031 | OPTS_TYPE_PT_UNICODE;
8032 kern_type = KERN_TYPE_MD4_PWU;
8033 dgst_size = DGST_SIZE_4_4;
8034 parse_func = md4_parse_hash;
8035 sort_by_digest = sort_by_digest_4_4;
8036 opti_type = OPTI_TYPE_ZERO_BYTE
8037 | OPTI_TYPE_PRECOMPUTE_INIT
8038 | OPTI_TYPE_PRECOMPUTE_MERKLE
8039 | OPTI_TYPE_SCALAR_MODE
8040 | OPTI_TYPE_MEET_IN_MIDDLE
8041 | OPTI_TYPE_EARLY_SKIP
8042 | OPTI_TYPE_NOT_ITERATED
8043 | OPTI_TYPE_NOT_SALTED
8044 | OPTI_TYPE_RAW_HASH;
8045 dgst_pos0 = 0;
8046 dgst_pos1 = 3;
8047 dgst_pos2 = 2;
8048 dgst_pos3 = 1;
8049 break;
8050
8051 case 1100: hash_type = HASH_TYPE_MD4;
8052 salt_type = SALT_TYPE_INTERN;
8053 attack_exec = ATTACK_EXEC_ON_GPU;
8054 opts_type = OPTS_TYPE_PT_GENERATE_LE
8055 | OPTS_TYPE_PT_ADD80
8056 | OPTS_TYPE_PT_ADDBITS14
8057 | OPTS_TYPE_PT_UNICODE
8058 | OPTS_TYPE_ST_ADD80
8059 | OPTS_TYPE_ST_UNICODE
8060 | OPTS_TYPE_ST_LOWER;
8061 kern_type = KERN_TYPE_MD44_PWUSLT;
8062 dgst_size = DGST_SIZE_4_4;
8063 parse_func = dcc_parse_hash;
8064 sort_by_digest = sort_by_digest_4_4;
8065 opti_type = OPTI_TYPE_ZERO_BYTE
8066 | OPTI_TYPE_PRECOMPUTE_INIT
8067 | OPTI_TYPE_PRECOMPUTE_MERKLE
8068 | OPTI_TYPE_SCALAR_MODE
8069 | OPTI_TYPE_EARLY_SKIP
8070 | OPTI_TYPE_NOT_ITERATED;
8071 dgst_pos0 = 0;
8072 dgst_pos1 = 3;
8073 dgst_pos2 = 2;
8074 dgst_pos3 = 1;
8075 break;
8076
8077 case 1400: hash_type = HASH_TYPE_SHA256;
8078 salt_type = SALT_TYPE_NONE;
8079 attack_exec = ATTACK_EXEC_ON_GPU;
8080 opts_type = OPTS_TYPE_PT_GENERATE_BE
8081 | OPTS_TYPE_PT_ADD80
8082 | OPTS_TYPE_PT_ADDBITS15;
8083 kern_type = KERN_TYPE_SHA256;
8084 dgst_size = DGST_SIZE_4_8;
8085 parse_func = sha256_parse_hash;
8086 sort_by_digest = sort_by_digest_4_8;
8087 opti_type = OPTI_TYPE_ZERO_BYTE
8088 | OPTI_TYPE_PRECOMPUTE_INIT
8089 | OPTI_TYPE_PRECOMPUTE_MERKLE
8090 | OPTI_TYPE_SCALAR_MODE
8091 | OPTI_TYPE_EARLY_SKIP
8092 | OPTI_TYPE_NOT_ITERATED
8093 | OPTI_TYPE_NOT_SALTED
8094 | OPTI_TYPE_RAW_HASH;
8095 dgst_pos0 = 3;
8096 dgst_pos1 = 7;
8097 dgst_pos2 = 2;
8098 dgst_pos3 = 6;
8099 break;
8100
8101 case 1410: hash_type = HASH_TYPE_SHA256;
8102 salt_type = SALT_TYPE_INTERN;
8103 attack_exec = ATTACK_EXEC_ON_GPU;
8104 opts_type = OPTS_TYPE_PT_GENERATE_BE
8105 | OPTS_TYPE_ST_ADD80
8106 | OPTS_TYPE_ST_ADDBITS15;
8107 kern_type = KERN_TYPE_SHA256_PWSLT;
8108 dgst_size = DGST_SIZE_4_8;
8109 parse_func = sha256s_parse_hash;
8110 sort_by_digest = sort_by_digest_4_8;
8111 opti_type = OPTI_TYPE_ZERO_BYTE
8112 | OPTI_TYPE_PRECOMPUTE_INIT
8113 | OPTI_TYPE_PRECOMPUTE_MERKLE
8114 | OPTI_TYPE_SCALAR_MODE
8115 | OPTI_TYPE_EARLY_SKIP
8116 | OPTI_TYPE_NOT_ITERATED
8117 | OPTI_TYPE_APPENDED_SALT
8118 | OPTI_TYPE_RAW_HASH;
8119 dgst_pos0 = 3;
8120 dgst_pos1 = 7;
8121 dgst_pos2 = 2;
8122 dgst_pos3 = 6;
8123 break;
8124
8125 case 1420: hash_type = HASH_TYPE_SHA256;
8126 salt_type = SALT_TYPE_INTERN;
8127 attack_exec = ATTACK_EXEC_ON_GPU;
8128 opts_type = OPTS_TYPE_PT_GENERATE_BE
8129 | OPTS_TYPE_PT_ADD80
8130 | OPTS_TYPE_PT_ADDBITS15;
8131 kern_type = KERN_TYPE_SHA256_SLTPW;
8132 dgst_size = DGST_SIZE_4_8;
8133 parse_func = sha256s_parse_hash;
8134 sort_by_digest = sort_by_digest_4_8;
8135 opti_type = OPTI_TYPE_ZERO_BYTE
8136 | OPTI_TYPE_PRECOMPUTE_INIT
8137 | OPTI_TYPE_PRECOMPUTE_MERKLE
8138 | OPTI_TYPE_EARLY_SKIP
8139 | OPTI_TYPE_NOT_ITERATED
8140 | OPTI_TYPE_PREPENDED_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 1421: hash_type = HASH_TYPE_SHA256;
8149 salt_type = SALT_TYPE_EMBEDDED;
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 = hmailserver_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 1430: hash_type = HASH_TYPE_SHA256;
8172 salt_type = SALT_TYPE_INTERN;
8173 attack_exec = ATTACK_EXEC_ON_GPU;
8174 opts_type = OPTS_TYPE_PT_GENERATE_BE
8175 | OPTS_TYPE_PT_UNICODE
8176 | OPTS_TYPE_ST_ADD80
8177 | OPTS_TYPE_ST_ADDBITS15;
8178 kern_type = KERN_TYPE_SHA256_PWUSLT;
8179 dgst_size = DGST_SIZE_4_8;
8180 parse_func = sha256s_parse_hash;
8181 sort_by_digest = sort_by_digest_4_8;
8182 opti_type = OPTI_TYPE_ZERO_BYTE
8183 | OPTI_TYPE_PRECOMPUTE_INIT
8184 | OPTI_TYPE_PRECOMPUTE_MERKLE
8185 | OPTI_TYPE_SCALAR_MODE
8186 | OPTI_TYPE_EARLY_SKIP
8187 | OPTI_TYPE_NOT_ITERATED
8188 | OPTI_TYPE_APPENDED_SALT
8189 | OPTI_TYPE_RAW_HASH;
8190 dgst_pos0 = 3;
8191 dgst_pos1 = 7;
8192 dgst_pos2 = 2;
8193 dgst_pos3 = 6;
8194 break;
8195
8196 case 1440: hash_type = HASH_TYPE_SHA256;
8197 salt_type = SALT_TYPE_INTERN;
8198 attack_exec = ATTACK_EXEC_ON_GPU;
8199 opts_type = OPTS_TYPE_PT_GENERATE_BE
8200 | OPTS_TYPE_PT_ADD80
8201 | OPTS_TYPE_PT_ADDBITS15
8202 | OPTS_TYPE_PT_UNICODE;
8203 kern_type = KERN_TYPE_SHA256_SLTPWU;
8204 dgst_size = DGST_SIZE_4_8;
8205 parse_func = sha256s_parse_hash;
8206 sort_by_digest = sort_by_digest_4_8;
8207 opti_type = OPTI_TYPE_ZERO_BYTE
8208 | OPTI_TYPE_PRECOMPUTE_INIT
8209 | OPTI_TYPE_PRECOMPUTE_MERKLE
8210 | OPTI_TYPE_EARLY_SKIP
8211 | OPTI_TYPE_NOT_ITERATED
8212 | OPTI_TYPE_PREPENDED_SALT
8213 | OPTI_TYPE_RAW_HASH;
8214 dgst_pos0 = 3;
8215 dgst_pos1 = 7;
8216 dgst_pos2 = 2;
8217 dgst_pos3 = 6;
8218 break;
8219
8220 case 1441: hash_type = HASH_TYPE_SHA256;
8221 salt_type = SALT_TYPE_EMBEDDED;
8222 attack_exec = ATTACK_EXEC_ON_GPU;
8223 opts_type = OPTS_TYPE_PT_GENERATE_BE
8224 | OPTS_TYPE_PT_ADD80
8225 | OPTS_TYPE_PT_ADDBITS15
8226 | OPTS_TYPE_PT_UNICODE
8227 | OPTS_TYPE_ST_BASE64;
8228 kern_type = KERN_TYPE_SHA256_SLTPWU;
8229 dgst_size = DGST_SIZE_4_8;
8230 parse_func = episerver4_parse_hash;
8231 sort_by_digest = sort_by_digest_4_8;
8232 opti_type = OPTI_TYPE_ZERO_BYTE
8233 | OPTI_TYPE_PRECOMPUTE_INIT
8234 | OPTI_TYPE_PRECOMPUTE_MERKLE
8235 | OPTI_TYPE_EARLY_SKIP
8236 | OPTI_TYPE_NOT_ITERATED
8237 | OPTI_TYPE_PREPENDED_SALT
8238 | OPTI_TYPE_RAW_HASH;
8239 dgst_pos0 = 3;
8240 dgst_pos1 = 7;
8241 dgst_pos2 = 2;
8242 dgst_pos3 = 6;
8243 break;
8244
8245 case 1450: hash_type = HASH_TYPE_SHA256;
8246 salt_type = SALT_TYPE_INTERN;
8247 attack_exec = ATTACK_EXEC_ON_GPU;
8248 opts_type = OPTS_TYPE_PT_GENERATE_BE
8249 | OPTS_TYPE_ST_ADD80;
8250 kern_type = KERN_TYPE_HMACSHA256_PW;
8251 dgst_size = DGST_SIZE_4_8;
8252 parse_func = hmacsha256_parse_hash;
8253 sort_by_digest = sort_by_digest_4_8;
8254 opti_type = OPTI_TYPE_ZERO_BYTE
8255 | OPTI_TYPE_NOT_ITERATED;
8256 dgst_pos0 = 3;
8257 dgst_pos1 = 7;
8258 dgst_pos2 = 2;
8259 dgst_pos3 = 6;
8260 break;
8261
8262 case 1460: hash_type = HASH_TYPE_SHA256;
8263 salt_type = SALT_TYPE_INTERN;
8264 attack_exec = ATTACK_EXEC_ON_GPU;
8265 opts_type = OPTS_TYPE_PT_GENERATE_BE
8266 | OPTS_TYPE_PT_ADD80
8267 | OPTS_TYPE_PT_ADDBITS15;
8268 kern_type = KERN_TYPE_HMACSHA256_SLT;
8269 dgst_size = DGST_SIZE_4_8;
8270 parse_func = hmacsha256_parse_hash;
8271 sort_by_digest = sort_by_digest_4_8;
8272 opti_type = OPTI_TYPE_ZERO_BYTE
8273 | OPTI_TYPE_NOT_ITERATED;
8274 dgst_pos0 = 3;
8275 dgst_pos1 = 7;
8276 dgst_pos2 = 2;
8277 dgst_pos3 = 6;
8278 break;
8279
8280 case 1500: hash_type = HASH_TYPE_DESCRYPT;
8281 salt_type = SALT_TYPE_EMBEDDED;
8282 attack_exec = ATTACK_EXEC_ON_GPU;
8283 opts_type = OPTS_TYPE_PT_GENERATE_LE
8284 | OPTS_TYPE_PT_BITSLICE;
8285 kern_type = KERN_TYPE_DESCRYPT;
8286 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8287 parse_func = descrypt_parse_hash;
8288 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8289 opti_type = OPTI_TYPE_ZERO_BYTE
8290 | OPTI_TYPE_SCALAR_MODE
8291 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8292 dgst_pos0 = 0;
8293 dgst_pos1 = 1;
8294 dgst_pos2 = 2;
8295 dgst_pos3 = 3;
8296 break;
8297
8298 case 1600: hash_type = HASH_TYPE_MD5;
8299 salt_type = SALT_TYPE_EMBEDDED;
8300 attack_exec = ATTACK_EXEC_ON_CPU;
8301 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8302 kern_type = KERN_TYPE_APR1CRYPT;
8303 dgst_size = DGST_SIZE_4_4;
8304 parse_func = md5apr1_parse_hash;
8305 sort_by_digest = sort_by_digest_4_4;
8306 opti_type = OPTI_TYPE_ZERO_BYTE;
8307 dgst_pos0 = 0;
8308 dgst_pos1 = 1;
8309 dgst_pos2 = 2;
8310 dgst_pos3 = 3;
8311 break;
8312
8313 case 1700: hash_type = HASH_TYPE_SHA512;
8314 salt_type = SALT_TYPE_NONE;
8315 attack_exec = ATTACK_EXEC_ON_GPU;
8316 opts_type = OPTS_TYPE_PT_GENERATE_BE
8317 | OPTS_TYPE_PT_ADD80
8318 | OPTS_TYPE_PT_ADDBITS15;
8319 kern_type = KERN_TYPE_SHA512;
8320 dgst_size = DGST_SIZE_8_8;
8321 parse_func = sha512_parse_hash;
8322 sort_by_digest = sort_by_digest_8_8;
8323 opti_type = OPTI_TYPE_ZERO_BYTE
8324 | OPTI_TYPE_PRECOMPUTE_INIT
8325 | OPTI_TYPE_PRECOMPUTE_MERKLE
8326 | OPTI_TYPE_SCALAR_MODE
8327 | OPTI_TYPE_EARLY_SKIP
8328 | OPTI_TYPE_NOT_ITERATED
8329 | OPTI_TYPE_NOT_SALTED
8330 | OPTI_TYPE_RAW_HASH;
8331 dgst_pos0 = 14;
8332 dgst_pos1 = 15;
8333 dgst_pos2 = 6;
8334 dgst_pos3 = 7;
8335 break;
8336
8337 case 1710: hash_type = HASH_TYPE_SHA512;
8338 salt_type = SALT_TYPE_INTERN;
8339 attack_exec = ATTACK_EXEC_ON_GPU;
8340 opts_type = OPTS_TYPE_PT_GENERATE_BE
8341 | OPTS_TYPE_ST_ADD80
8342 | OPTS_TYPE_ST_ADDBITS15;
8343 kern_type = KERN_TYPE_SHA512_PWSLT;
8344 dgst_size = DGST_SIZE_8_8;
8345 parse_func = sha512s_parse_hash;
8346 sort_by_digest = sort_by_digest_8_8;
8347 opti_type = OPTI_TYPE_ZERO_BYTE
8348 | OPTI_TYPE_PRECOMPUTE_INIT
8349 | OPTI_TYPE_PRECOMPUTE_MERKLE
8350 | OPTI_TYPE_SCALAR_MODE
8351 | OPTI_TYPE_EARLY_SKIP
8352 | OPTI_TYPE_NOT_ITERATED
8353 | OPTI_TYPE_APPENDED_SALT
8354 | OPTI_TYPE_RAW_HASH;
8355 dgst_pos0 = 14;
8356 dgst_pos1 = 15;
8357 dgst_pos2 = 6;
8358 dgst_pos3 = 7;
8359 break;
8360
8361 case 1711: hash_type = HASH_TYPE_SHA512;
8362 salt_type = SALT_TYPE_EMBEDDED;
8363 attack_exec = ATTACK_EXEC_ON_GPU;
8364 opts_type = OPTS_TYPE_PT_GENERATE_BE
8365 | OPTS_TYPE_ST_ADD80
8366 | OPTS_TYPE_ST_ADDBITS15;
8367 kern_type = KERN_TYPE_SHA512_PWSLT;
8368 dgst_size = DGST_SIZE_8_8;
8369 parse_func = sha512b64s_parse_hash;
8370 sort_by_digest = sort_by_digest_8_8;
8371 opti_type = OPTI_TYPE_ZERO_BYTE
8372 | OPTI_TYPE_PRECOMPUTE_INIT
8373 | OPTI_TYPE_PRECOMPUTE_MERKLE
8374 | OPTI_TYPE_SCALAR_MODE
8375 | OPTI_TYPE_EARLY_SKIP
8376 | OPTI_TYPE_NOT_ITERATED
8377 | OPTI_TYPE_APPENDED_SALT
8378 | OPTI_TYPE_RAW_HASH;
8379 dgst_pos0 = 14;
8380 dgst_pos1 = 15;
8381 dgst_pos2 = 6;
8382 dgst_pos3 = 7;
8383 break;
8384
8385 case 1720: hash_type = HASH_TYPE_SHA512;
8386 salt_type = SALT_TYPE_INTERN;
8387 attack_exec = ATTACK_EXEC_ON_GPU;
8388 opts_type = OPTS_TYPE_PT_GENERATE_BE
8389 | OPTS_TYPE_PT_ADD80
8390 | OPTS_TYPE_PT_ADDBITS15;
8391 kern_type = KERN_TYPE_SHA512_SLTPW;
8392 dgst_size = DGST_SIZE_8_8;
8393 parse_func = sha512s_parse_hash;
8394 sort_by_digest = sort_by_digest_8_8;
8395 opti_type = OPTI_TYPE_ZERO_BYTE
8396 | OPTI_TYPE_PRECOMPUTE_INIT
8397 | OPTI_TYPE_PRECOMPUTE_MERKLE
8398 | OPTI_TYPE_EARLY_SKIP
8399 | OPTI_TYPE_NOT_ITERATED
8400 | OPTI_TYPE_PREPENDED_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 1722: hash_type = HASH_TYPE_SHA512;
8409 salt_type = SALT_TYPE_EMBEDDED;
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 | OPTS_TYPE_ST_HEX;
8415 kern_type = KERN_TYPE_SHA512_SLTPW;
8416 dgst_size = DGST_SIZE_8_8;
8417 parse_func = osx512_parse_hash;
8418 sort_by_digest = sort_by_digest_8_8;
8419 opti_type = OPTI_TYPE_ZERO_BYTE
8420 | OPTI_TYPE_PRECOMPUTE_INIT
8421 | OPTI_TYPE_PRECOMPUTE_MERKLE
8422 | OPTI_TYPE_EARLY_SKIP
8423 | OPTI_TYPE_NOT_ITERATED
8424 | OPTI_TYPE_PREPENDED_SALT
8425 | OPTI_TYPE_RAW_HASH;
8426 dgst_pos0 = 14;
8427 dgst_pos1 = 15;
8428 dgst_pos2 = 6;
8429 dgst_pos3 = 7;
8430 break;
8431
8432 case 1730: hash_type = HASH_TYPE_SHA512;
8433 salt_type = SALT_TYPE_INTERN;
8434 attack_exec = ATTACK_EXEC_ON_GPU;
8435 opts_type = OPTS_TYPE_PT_GENERATE_BE
8436 | OPTS_TYPE_PT_UNICODE
8437 | OPTS_TYPE_ST_ADD80
8438 | OPTS_TYPE_ST_ADDBITS15;
8439 kern_type = KERN_TYPE_SHA512_PWSLTU;
8440 dgst_size = DGST_SIZE_8_8;
8441 parse_func = sha512s_parse_hash;
8442 sort_by_digest = sort_by_digest_8_8;
8443 opti_type = OPTI_TYPE_ZERO_BYTE
8444 | OPTI_TYPE_PRECOMPUTE_INIT
8445 | OPTI_TYPE_PRECOMPUTE_MERKLE
8446 | OPTI_TYPE_SCALAR_MODE
8447 | OPTI_TYPE_EARLY_SKIP
8448 | OPTI_TYPE_NOT_ITERATED
8449 | OPTI_TYPE_APPENDED_SALT
8450 | OPTI_TYPE_RAW_HASH;
8451 dgst_pos0 = 14;
8452 dgst_pos1 = 15;
8453 dgst_pos2 = 6;
8454 dgst_pos3 = 7;
8455 break;
8456
8457 case 1731: hash_type = HASH_TYPE_SHA512;
8458 salt_type = SALT_TYPE_EMBEDDED;
8459 attack_exec = ATTACK_EXEC_ON_GPU;
8460 opts_type = OPTS_TYPE_PT_GENERATE_BE
8461 | OPTS_TYPE_PT_UNICODE
8462 | OPTS_TYPE_ST_ADD80
8463 | OPTS_TYPE_ST_ADDBITS15
8464 | OPTS_TYPE_ST_HEX;
8465 kern_type = KERN_TYPE_SHA512_PWSLTU;
8466 dgst_size = DGST_SIZE_8_8;
8467 parse_func = mssql2012_parse_hash;
8468 sort_by_digest = sort_by_digest_8_8;
8469 opti_type = OPTI_TYPE_ZERO_BYTE
8470 | OPTI_TYPE_PRECOMPUTE_INIT
8471 | OPTI_TYPE_PRECOMPUTE_MERKLE
8472 | OPTI_TYPE_SCALAR_MODE
8473 | OPTI_TYPE_EARLY_SKIP
8474 | OPTI_TYPE_NOT_ITERATED
8475 | OPTI_TYPE_APPENDED_SALT
8476 | OPTI_TYPE_RAW_HASH;
8477 dgst_pos0 = 14;
8478 dgst_pos1 = 15;
8479 dgst_pos2 = 6;
8480 dgst_pos3 = 7;
8481 break;
8482
8483 case 1740: hash_type = HASH_TYPE_SHA512;
8484 salt_type = SALT_TYPE_INTERN;
8485 attack_exec = ATTACK_EXEC_ON_GPU;
8486 opts_type = OPTS_TYPE_PT_GENERATE_BE
8487 | OPTS_TYPE_PT_ADD80
8488 | OPTS_TYPE_PT_ADDBITS15
8489 | OPTS_TYPE_PT_UNICODE;
8490 kern_type = KERN_TYPE_SHA512_SLTPWU;
8491 dgst_size = DGST_SIZE_8_8;
8492 parse_func = sha512s_parse_hash;
8493 sort_by_digest = sort_by_digest_8_8;
8494 opti_type = OPTI_TYPE_ZERO_BYTE
8495 | OPTI_TYPE_PRECOMPUTE_INIT
8496 | OPTI_TYPE_PRECOMPUTE_MERKLE
8497 | OPTI_TYPE_EARLY_SKIP
8498 | OPTI_TYPE_NOT_ITERATED
8499 | OPTI_TYPE_PREPENDED_SALT
8500 | OPTI_TYPE_RAW_HASH;
8501 dgst_pos0 = 14;
8502 dgst_pos1 = 15;
8503 dgst_pos2 = 6;
8504 dgst_pos3 = 7;
8505 break;
8506
8507 case 1750: hash_type = HASH_TYPE_SHA512;
8508 salt_type = SALT_TYPE_INTERN;
8509 attack_exec = ATTACK_EXEC_ON_GPU;
8510 opts_type = OPTS_TYPE_PT_GENERATE_BE
8511 | OPTS_TYPE_ST_ADD80;
8512 kern_type = KERN_TYPE_HMACSHA512_PW;
8513 dgst_size = DGST_SIZE_8_8;
8514 parse_func = hmacsha512_parse_hash;
8515 sort_by_digest = sort_by_digest_8_8;
8516 opti_type = OPTI_TYPE_ZERO_BYTE
8517 | OPTI_TYPE_NOT_ITERATED;
8518 dgst_pos0 = 14;
8519 dgst_pos1 = 15;
8520 dgst_pos2 = 6;
8521 dgst_pos3 = 7;
8522 break;
8523
8524 case 1760: hash_type = HASH_TYPE_SHA512;
8525 salt_type = SALT_TYPE_INTERN;
8526 attack_exec = ATTACK_EXEC_ON_GPU;
8527 opts_type = OPTS_TYPE_PT_GENERATE_BE
8528 | OPTS_TYPE_PT_ADD80
8529 | OPTS_TYPE_PT_ADDBITS15;
8530 kern_type = KERN_TYPE_HMACSHA512_SLT;
8531 dgst_size = DGST_SIZE_8_8;
8532 parse_func = hmacsha512_parse_hash;
8533 sort_by_digest = sort_by_digest_8_8;
8534 opti_type = OPTI_TYPE_ZERO_BYTE
8535 | OPTI_TYPE_NOT_ITERATED;
8536 dgst_pos0 = 14;
8537 dgst_pos1 = 15;
8538 dgst_pos2 = 6;
8539 dgst_pos3 = 7;
8540 break;
8541
8542 case 1800: hash_type = HASH_TYPE_SHA512;
8543 salt_type = SALT_TYPE_EMBEDDED;
8544 attack_exec = ATTACK_EXEC_ON_CPU;
8545 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8546 kern_type = KERN_TYPE_SHA512CRYPT;
8547 dgst_size = DGST_SIZE_8_8;
8548 parse_func = sha512crypt_parse_hash;
8549 sort_by_digest = sort_by_digest_8_8;
8550 opti_type = OPTI_TYPE_ZERO_BYTE;
8551 dgst_pos0 = 0;
8552 dgst_pos1 = 1;
8553 dgst_pos2 = 2;
8554 dgst_pos3 = 3;
8555 break;
8556
8557 case 2100: hash_type = HASH_TYPE_DCC2;
8558 salt_type = SALT_TYPE_EMBEDDED;
8559 attack_exec = ATTACK_EXEC_ON_CPU;
8560 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
8561 | OPTS_TYPE_ST_LOWER
8562 | OPTS_TYPE_ST_UNICODE;
8563 kern_type = KERN_TYPE_DCC2;
8564 dgst_size = DGST_SIZE_4_4;
8565 parse_func = dcc2_parse_hash;
8566 sort_by_digest = sort_by_digest_4_4;
8567 opti_type = OPTI_TYPE_ZERO_BYTE;
8568 dgst_pos0 = 0;
8569 dgst_pos1 = 1;
8570 dgst_pos2 = 2;
8571 dgst_pos3 = 3;
8572 break;
8573
8574 case 2400: hash_type = HASH_TYPE_MD5;
8575 salt_type = SALT_TYPE_NONE;
8576 attack_exec = ATTACK_EXEC_ON_GPU;
8577 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8578 kern_type = KERN_TYPE_MD5PIX;
8579 dgst_size = DGST_SIZE_4_4;
8580 parse_func = md5pix_parse_hash;
8581 sort_by_digest = sort_by_digest_4_4;
8582 opti_type = OPTI_TYPE_ZERO_BYTE
8583 | OPTI_TYPE_PRECOMPUTE_INIT
8584 | OPTI_TYPE_PRECOMPUTE_MERKLE
8585 | OPTI_TYPE_SCALAR_MODE
8586 | OPTI_TYPE_EARLY_SKIP
8587 | OPTI_TYPE_NOT_ITERATED
8588 | OPTI_TYPE_NOT_SALTED;
8589 dgst_pos0 = 0;
8590 dgst_pos1 = 3;
8591 dgst_pos2 = 2;
8592 dgst_pos3 = 1;
8593 break;
8594
8595 case 2410: hash_type = HASH_TYPE_MD5;
8596 salt_type = SALT_TYPE_INTERN;
8597 attack_exec = ATTACK_EXEC_ON_GPU;
8598 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8599 kern_type = KERN_TYPE_MD5ASA;
8600 dgst_size = DGST_SIZE_4_4;
8601 parse_func = md5asa_parse_hash;
8602 sort_by_digest = sort_by_digest_4_4;
8603 opti_type = OPTI_TYPE_ZERO_BYTE
8604 | OPTI_TYPE_PRECOMPUTE_INIT
8605 | OPTI_TYPE_PRECOMPUTE_MERKLE
8606 | OPTI_TYPE_SCALAR_MODE
8607 | OPTI_TYPE_EARLY_SKIP
8608 | OPTI_TYPE_NOT_ITERATED;
8609 dgst_pos0 = 0;
8610 dgst_pos1 = 3;
8611 dgst_pos2 = 2;
8612 dgst_pos3 = 1;
8613 break;
8614
8615 case 2500: hash_type = HASH_TYPE_WPA;
8616 salt_type = SALT_TYPE_EMBEDDED;
8617 attack_exec = ATTACK_EXEC_ON_CPU;
8618 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8619 kern_type = KERN_TYPE_WPA;
8620 dgst_size = DGST_SIZE_4_4;
8621 parse_func = wpa_parse_hash;
8622 sort_by_digest = sort_by_digest_4_4;
8623 opti_type = OPTI_TYPE_ZERO_BYTE;
8624 dgst_pos0 = 0;
8625 dgst_pos1 = 1;
8626 dgst_pos2 = 2;
8627 dgst_pos3 = 3;
8628 break;
8629
8630 case 2600: hash_type = HASH_TYPE_MD5;
8631 salt_type = SALT_TYPE_VIRTUAL;
8632 attack_exec = ATTACK_EXEC_ON_GPU;
8633 opts_type = OPTS_TYPE_PT_GENERATE_LE
8634 | OPTS_TYPE_PT_ADD80
8635 | OPTS_TYPE_PT_ADDBITS14
8636 | OPTS_TYPE_ST_ADD80;
8637 kern_type = KERN_TYPE_MD55_PWSLT1;
8638 dgst_size = DGST_SIZE_4_4;
8639 parse_func = md5md5_parse_hash;
8640 sort_by_digest = sort_by_digest_4_4;
8641 opti_type = OPTI_TYPE_ZERO_BYTE
8642 | OPTI_TYPE_PRECOMPUTE_INIT
8643 | OPTI_TYPE_PRECOMPUTE_MERKLE
8644 | OPTI_TYPE_EARLY_SKIP;
8645 dgst_pos0 = 0;
8646 dgst_pos1 = 3;
8647 dgst_pos2 = 2;
8648 dgst_pos3 = 1;
8649 break;
8650
8651 case 2611: hash_type = HASH_TYPE_MD5;
8652 salt_type = SALT_TYPE_INTERN;
8653 attack_exec = ATTACK_EXEC_ON_GPU;
8654 opts_type = OPTS_TYPE_PT_GENERATE_LE
8655 | OPTS_TYPE_PT_ADD80
8656 | OPTS_TYPE_PT_ADDBITS14
8657 | OPTS_TYPE_ST_ADD80;
8658 kern_type = KERN_TYPE_MD55_PWSLT1;
8659 dgst_size = DGST_SIZE_4_4;
8660 parse_func = vb3_parse_hash;
8661 sort_by_digest = sort_by_digest_4_4;
8662 opti_type = OPTI_TYPE_ZERO_BYTE
8663 | OPTI_TYPE_PRECOMPUTE_INIT
8664 | OPTI_TYPE_PRECOMPUTE_MERKLE
8665 | OPTI_TYPE_EARLY_SKIP;
8666 dgst_pos0 = 0;
8667 dgst_pos1 = 3;
8668 dgst_pos2 = 2;
8669 dgst_pos3 = 1;
8670 break;
8671
8672 case 2612: hash_type = HASH_TYPE_MD5;
8673 salt_type = SALT_TYPE_EMBEDDED;
8674 attack_exec = ATTACK_EXEC_ON_GPU;
8675 opts_type = OPTS_TYPE_PT_GENERATE_LE
8676 | OPTS_TYPE_PT_ADD80
8677 | OPTS_TYPE_PT_ADDBITS14
8678 | OPTS_TYPE_ST_ADD80
8679 | OPTS_TYPE_ST_HEX;
8680 kern_type = KERN_TYPE_MD55_PWSLT1;
8681 dgst_size = DGST_SIZE_4_4;
8682 parse_func = phps_parse_hash;
8683 sort_by_digest = sort_by_digest_4_4;
8684 opti_type = OPTI_TYPE_ZERO_BYTE
8685 | OPTI_TYPE_PRECOMPUTE_INIT
8686 | OPTI_TYPE_PRECOMPUTE_MERKLE
8687 | OPTI_TYPE_EARLY_SKIP;
8688 dgst_pos0 = 0;
8689 dgst_pos1 = 3;
8690 dgst_pos2 = 2;
8691 dgst_pos3 = 1;
8692 break;
8693
8694 case 2711: hash_type = HASH_TYPE_MD5;
8695 salt_type = SALT_TYPE_INTERN;
8696 attack_exec = ATTACK_EXEC_ON_GPU;
8697 opts_type = OPTS_TYPE_PT_GENERATE_LE
8698 | OPTS_TYPE_PT_ADD80
8699 | OPTS_TYPE_PT_ADDBITS14
8700 | OPTS_TYPE_ST_ADD80;
8701 kern_type = KERN_TYPE_MD55_PWSLT2;
8702 dgst_size = DGST_SIZE_4_4;
8703 parse_func = vb30_parse_hash;
8704 sort_by_digest = sort_by_digest_4_4;
8705 opti_type = OPTI_TYPE_ZERO_BYTE
8706 | OPTI_TYPE_PRECOMPUTE_INIT
8707 | OPTI_TYPE_EARLY_SKIP;
8708 dgst_pos0 = 0;
8709 dgst_pos1 = 3;
8710 dgst_pos2 = 2;
8711 dgst_pos3 = 1;
8712 break;
8713
8714 case 2811: hash_type = HASH_TYPE_MD5;
8715 salt_type = SALT_TYPE_INTERN;
8716 attack_exec = ATTACK_EXEC_ON_GPU;
8717 opts_type = OPTS_TYPE_PT_GENERATE_LE
8718 | OPTS_TYPE_PT_ADD80
8719 | OPTS_TYPE_PT_ADDBITS14;
8720 kern_type = KERN_TYPE_MD55_SLTPW;
8721 dgst_size = DGST_SIZE_4_4;
8722 parse_func = ipb2_parse_hash;
8723 sort_by_digest = sort_by_digest_4_4;
8724 opti_type = OPTI_TYPE_ZERO_BYTE
8725 | OPTI_TYPE_PRECOMPUTE_INIT
8726 | OPTI_TYPE_EARLY_SKIP;
8727 dgst_pos0 = 0;
8728 dgst_pos1 = 3;
8729 dgst_pos2 = 2;
8730 dgst_pos3 = 1;
8731 break;
8732
8733 case 3000: hash_type = HASH_TYPE_LM;
8734 salt_type = SALT_TYPE_NONE;
8735 attack_exec = ATTACK_EXEC_ON_GPU;
8736 opts_type = OPTS_TYPE_PT_GENERATE_LE
8737 | OPTS_TYPE_PT_UPPER
8738 | OPTS_TYPE_PT_BITSLICE;
8739 kern_type = KERN_TYPE_LM;
8740 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8741 parse_func = lm_parse_hash;
8742 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8743 opti_type = OPTI_TYPE_ZERO_BYTE
8744 | OPTI_TYPE_SCALAR_MODE
8745 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8746 dgst_pos0 = 0;
8747 dgst_pos1 = 1;
8748 dgst_pos2 = 2;
8749 dgst_pos3 = 3;
8750 break;
8751
8752 case 3100: hash_type = HASH_TYPE_ORACLEH;
8753 salt_type = SALT_TYPE_INTERN;
8754 attack_exec = ATTACK_EXEC_ON_GPU;
8755 opts_type = OPTS_TYPE_PT_GENERATE_LE
8756 | OPTS_TYPE_PT_UPPER
8757 | OPTS_TYPE_ST_UPPER;
8758 kern_type = KERN_TYPE_ORACLEH;
8759 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8760 parse_func = oracleh_parse_hash;
8761 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8762 opti_type = OPTI_TYPE_ZERO_BYTE
8763 | OPTI_TYPE_SCALAR_MODE;
8764 dgst_pos0 = 0;
8765 dgst_pos1 = 1;
8766 dgst_pos2 = 2;
8767 dgst_pos3 = 3;
8768 break;
8769
8770 case 3200: hash_type = HASH_TYPE_BCRYPT;
8771 salt_type = SALT_TYPE_EMBEDDED;
8772 attack_exec = ATTACK_EXEC_ON_CPU;
8773 opts_type = OPTS_TYPE_PT_GENERATE_LE
8774 | OPTS_TYPE_ST_GENERATE_LE;
8775 kern_type = KERN_TYPE_BCRYPT;
8776 dgst_size = DGST_SIZE_4_6;
8777 parse_func = bcrypt_parse_hash;
8778 sort_by_digest = sort_by_digest_4_6;
8779 opti_type = OPTI_TYPE_ZERO_BYTE;
8780 dgst_pos0 = 0;
8781 dgst_pos1 = 1;
8782 dgst_pos2 = 2;
8783 dgst_pos3 = 3;
8784 break;
8785
8786 case 3710: hash_type = HASH_TYPE_MD5;
8787 salt_type = SALT_TYPE_INTERN;
8788 attack_exec = ATTACK_EXEC_ON_GPU;
8789 opts_type = OPTS_TYPE_PT_GENERATE_LE
8790 | OPTS_TYPE_PT_ADD80
8791 | OPTS_TYPE_PT_ADDBITS14;
8792 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8793 dgst_size = DGST_SIZE_4_4;
8794 parse_func = md5s_parse_hash;
8795 sort_by_digest = sort_by_digest_4_4;
8796 opti_type = OPTI_TYPE_ZERO_BYTE
8797 | OPTI_TYPE_PRECOMPUTE_INIT
8798 | OPTI_TYPE_PRECOMPUTE_MERKLE
8799 | OPTI_TYPE_EARLY_SKIP;
8800 dgst_pos0 = 0;
8801 dgst_pos1 = 3;
8802 dgst_pos2 = 2;
8803 dgst_pos3 = 1;
8804 break;
8805
8806 case 3711: hash_type = HASH_TYPE_MD5;
8807 salt_type = SALT_TYPE_EMBEDDED;
8808 attack_exec = ATTACK_EXEC_ON_GPU;
8809 opts_type = OPTS_TYPE_PT_GENERATE_LE
8810 | OPTS_TYPE_PT_ADD80
8811 | OPTS_TYPE_PT_ADDBITS14;
8812 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8813 dgst_size = DGST_SIZE_4_4;
8814 parse_func = mediawiki_b_parse_hash;
8815 sort_by_digest = sort_by_digest_4_4;
8816 opti_type = OPTI_TYPE_ZERO_BYTE
8817 | OPTI_TYPE_PRECOMPUTE_INIT
8818 | OPTI_TYPE_PRECOMPUTE_MERKLE
8819 | OPTI_TYPE_EARLY_SKIP;
8820 dgst_pos0 = 0;
8821 dgst_pos1 = 3;
8822 dgst_pos2 = 2;
8823 dgst_pos3 = 1;
8824 break;
8825
8826 case 3800: hash_type = HASH_TYPE_MD5;
8827 salt_type = SALT_TYPE_INTERN;
8828 attack_exec = ATTACK_EXEC_ON_GPU;
8829 opts_type = OPTS_TYPE_PT_GENERATE_LE
8830 | OPTS_TYPE_ST_ADDBITS14;
8831 kern_type = KERN_TYPE_MD5_SLT_PW_SLT;
8832 dgst_size = DGST_SIZE_4_4;
8833 parse_func = md5s_parse_hash;
8834 sort_by_digest = sort_by_digest_4_4;
8835 opti_type = OPTI_TYPE_ZERO_BYTE
8836 | OPTI_TYPE_PRECOMPUTE_INIT
8837 | OPTI_TYPE_PRECOMPUTE_MERKLE
8838 | OPTI_TYPE_EARLY_SKIP
8839 | OPTI_TYPE_NOT_ITERATED
8840 | OPTI_TYPE_RAW_HASH;
8841 dgst_pos0 = 0;
8842 dgst_pos1 = 3;
8843 dgst_pos2 = 2;
8844 dgst_pos3 = 1;
8845 break;
8846
8847 case 4300: hash_type = HASH_TYPE_MD5;
8848 salt_type = SALT_TYPE_VIRTUAL;
8849 attack_exec = ATTACK_EXEC_ON_GPU;
8850 opts_type = OPTS_TYPE_PT_GENERATE_LE
8851 | OPTS_TYPE_PT_ADD80
8852 | OPTS_TYPE_PT_ADDBITS14
8853 | OPTS_TYPE_ST_ADD80;
8854 kern_type = KERN_TYPE_MD5U5_PWSLT1;
8855 dgst_size = DGST_SIZE_4_4;
8856 parse_func = md5md5_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 dgst_pos0 = 0;
8863 dgst_pos1 = 3;
8864 dgst_pos2 = 2;
8865 dgst_pos3 = 1;
8866 break;
8867
8868
8869 case 4400: hash_type = HASH_TYPE_MD5;
8870 salt_type = SALT_TYPE_NONE;
8871 attack_exec = ATTACK_EXEC_ON_GPU;
8872 opts_type = OPTS_TYPE_PT_GENERATE_BE
8873 | OPTS_TYPE_PT_ADD80
8874 | OPTS_TYPE_PT_ADDBITS15;
8875 kern_type = KERN_TYPE_MD5_SHA1;
8876 dgst_size = DGST_SIZE_4_4;
8877 parse_func = md5_parse_hash;
8878 sort_by_digest = sort_by_digest_4_4;
8879 opti_type = OPTI_TYPE_ZERO_BYTE
8880 | OPTI_TYPE_PRECOMPUTE_INIT
8881 | OPTI_TYPE_PRECOMPUTE_MERKLE
8882 | OPTI_TYPE_EARLY_SKIP
8883 | OPTI_TYPE_NOT_ITERATED
8884 | OPTI_TYPE_NOT_SALTED
8885 | OPTI_TYPE_RAW_HASH;
8886 dgst_pos0 = 0;
8887 dgst_pos1 = 3;
8888 dgst_pos2 = 2;
8889 dgst_pos3 = 1;
8890 break;
8891
8892 case 4500: hash_type = HASH_TYPE_SHA1;
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_SHA11;
8899 dgst_size = DGST_SIZE_4_5;
8900 parse_func = sha1_parse_hash;
8901 sort_by_digest = sort_by_digest_4_5;
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_SALTED;
8907 dgst_pos0 = 3;
8908 dgst_pos1 = 4;
8909 dgst_pos2 = 2;
8910 dgst_pos3 = 1;
8911 break;
8912
8913 case 4700: hash_type = HASH_TYPE_SHA1;
8914 salt_type = SALT_TYPE_NONE;
8915 attack_exec = ATTACK_EXEC_ON_GPU;
8916 opts_type = OPTS_TYPE_PT_GENERATE_LE
8917 | OPTS_TYPE_PT_ADD80
8918 | OPTS_TYPE_PT_ADDBITS14;
8919 kern_type = KERN_TYPE_SHA1_MD5;
8920 dgst_size = DGST_SIZE_4_5;
8921 parse_func = sha1_parse_hash;
8922 sort_by_digest = sort_by_digest_4_5;
8923 opti_type = OPTI_TYPE_ZERO_BYTE
8924 | OPTI_TYPE_PRECOMPUTE_INIT
8925 | OPTI_TYPE_PRECOMPUTE_MERKLE
8926 | OPTI_TYPE_EARLY_SKIP
8927 | OPTI_TYPE_NOT_ITERATED
8928 | OPTI_TYPE_NOT_SALTED
8929 | OPTI_TYPE_RAW_HASH;
8930 dgst_pos0 = 3;
8931 dgst_pos1 = 4;
8932 dgst_pos2 = 2;
8933 dgst_pos3 = 1;
8934 break;
8935
8936 case 4800: hash_type = HASH_TYPE_MD5;
8937 salt_type = SALT_TYPE_EMBEDDED;
8938 attack_exec = ATTACK_EXEC_ON_GPU;
8939 opts_type = OPTS_TYPE_PT_GENERATE_LE
8940 | OPTS_TYPE_PT_ADDBITS14;
8941 kern_type = KERN_TYPE_MD5_CHAP;
8942 dgst_size = DGST_SIZE_4_4;
8943 parse_func = chap_parse_hash;
8944 sort_by_digest = sort_by_digest_4_4;
8945 opti_type = OPTI_TYPE_ZERO_BYTE
8946 | OPTI_TYPE_PRECOMPUTE_INIT
8947 | OPTI_TYPE_PRECOMPUTE_MERKLE
8948 | OPTI_TYPE_MEET_IN_MIDDLE
8949 | OPTI_TYPE_EARLY_SKIP
8950 | OPTI_TYPE_NOT_ITERATED
8951 | OPTI_TYPE_RAW_HASH;
8952 dgst_pos0 = 0;
8953 dgst_pos1 = 3;
8954 dgst_pos2 = 2;
8955 dgst_pos3 = 1;
8956 break;
8957
8958 case 4900: hash_type = HASH_TYPE_SHA1;
8959 salt_type = SALT_TYPE_INTERN;
8960 attack_exec = ATTACK_EXEC_ON_GPU;
8961 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8962 kern_type = KERN_TYPE_SHA1_SLT_PW_SLT;
8963 dgst_size = DGST_SIZE_4_5;
8964 parse_func = sha1s_parse_hash;
8965 sort_by_digest = sort_by_digest_4_5;
8966 opti_type = OPTI_TYPE_ZERO_BYTE
8967 | OPTI_TYPE_PRECOMPUTE_INIT
8968 | OPTI_TYPE_PRECOMPUTE_MERKLE
8969 | OPTI_TYPE_EARLY_SKIP;
8970 dgst_pos0 = 3;
8971 dgst_pos1 = 4;
8972 dgst_pos2 = 2;
8973 dgst_pos3 = 1;
8974 break;
8975
8976 case 5000: hash_type = HASH_TYPE_KECCAK;
8977 salt_type = SALT_TYPE_EMBEDDED;
8978 attack_exec = ATTACK_EXEC_ON_GPU;
8979 opts_type = OPTS_TYPE_PT_GENERATE_LE
8980 | OPTS_TYPE_PT_ADD01;
8981 kern_type = KERN_TYPE_KECCAK;
8982 dgst_size = DGST_SIZE_8_25;
8983 parse_func = keccak_parse_hash;
8984 sort_by_digest = sort_by_digest_8_25;
8985 opti_type = OPTI_TYPE_ZERO_BYTE
8986 | OPTI_TYPE_RAW_HASH;
8987 dgst_pos0 = 2;
8988 dgst_pos1 = 3;
8989 dgst_pos2 = 4;
8990 dgst_pos3 = 5;
8991 break;
8992
8993 case 5100: hash_type = HASH_TYPE_MD5H;
8994 salt_type = SALT_TYPE_NONE;
8995 attack_exec = ATTACK_EXEC_ON_GPU;
8996 opts_type = OPTS_TYPE_PT_GENERATE_LE
8997 | OPTS_TYPE_PT_ADD80
8998 | OPTS_TYPE_PT_ADDBITS14;
8999 kern_type = KERN_TYPE_MD5H;
9000 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9001 parse_func = md5half_parse_hash;
9002 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9003 opti_type = OPTI_TYPE_ZERO_BYTE
9004 | OPTI_TYPE_RAW_HASH;
9005 dgst_pos0 = 0;
9006 dgst_pos1 = 1;
9007 dgst_pos2 = 2;
9008 dgst_pos3 = 3;
9009 break;
9010
9011 case 5200: hash_type = HASH_TYPE_SHA256;
9012 salt_type = SALT_TYPE_EMBEDDED;
9013 attack_exec = ATTACK_EXEC_ON_CPU;
9014 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9015 kern_type = KERN_TYPE_PSAFE3;
9016 dgst_size = DGST_SIZE_4_8;
9017 parse_func = psafe3_parse_hash;
9018 sort_by_digest = sort_by_digest_4_8;
9019 opti_type = OPTI_TYPE_ZERO_BYTE;
9020 dgst_pos0 = 0;
9021 dgst_pos1 = 1;
9022 dgst_pos2 = 2;
9023 dgst_pos3 = 3;
9024 break;
9025
9026 case 5300: hash_type = HASH_TYPE_MD5;
9027 salt_type = SALT_TYPE_EMBEDDED;
9028 attack_exec = ATTACK_EXEC_ON_GPU;
9029 opts_type = OPTS_TYPE_PT_GENERATE_LE
9030 | OPTS_TYPE_ST_ADD80;
9031 kern_type = KERN_TYPE_IKEPSK_MD5;
9032 dgst_size = DGST_SIZE_4_4;
9033 parse_func = ikepsk_md5_parse_hash;
9034 sort_by_digest = sort_by_digest_4_4;
9035 opti_type = OPTI_TYPE_ZERO_BYTE;
9036 dgst_pos0 = 0;
9037 dgst_pos1 = 3;
9038 dgst_pos2 = 2;
9039 dgst_pos3 = 1;
9040 break;
9041
9042 case 5400: hash_type = HASH_TYPE_SHA1;
9043 salt_type = SALT_TYPE_EMBEDDED;
9044 attack_exec = ATTACK_EXEC_ON_GPU;
9045 opts_type = OPTS_TYPE_PT_GENERATE_BE
9046 | OPTS_TYPE_ST_ADD80;
9047 kern_type = KERN_TYPE_IKEPSK_SHA1;
9048 dgst_size = DGST_SIZE_4_5;
9049 parse_func = ikepsk_sha1_parse_hash;
9050 sort_by_digest = sort_by_digest_4_5;
9051 opti_type = OPTI_TYPE_ZERO_BYTE;
9052 dgst_pos0 = 3;
9053 dgst_pos1 = 4;
9054 dgst_pos2 = 2;
9055 dgst_pos3 = 1;
9056 break;
9057
9058 case 5500: hash_type = HASH_TYPE_NETNTLM;
9059 salt_type = SALT_TYPE_EMBEDDED;
9060 attack_exec = ATTACK_EXEC_ON_GPU;
9061 opts_type = OPTS_TYPE_PT_GENERATE_LE
9062 | OPTS_TYPE_PT_ADD80
9063 | OPTS_TYPE_PT_ADDBITS14
9064 | OPTS_TYPE_PT_UNICODE
9065 | OPTS_TYPE_ST_HEX;
9066 kern_type = KERN_TYPE_NETNTLMv1;
9067 dgst_size = DGST_SIZE_4_4;
9068 parse_func = netntlmv1_parse_hash;
9069 sort_by_digest = sort_by_digest_4_4;
9070 opti_type = OPTI_TYPE_ZERO_BYTE
9071 | OPTI_TYPE_SCALAR_MODE
9072 | OPTI_TYPE_PRECOMPUTE_PERMUT;
9073 dgst_pos0 = 0;
9074 dgst_pos1 = 1;
9075 dgst_pos2 = 2;
9076 dgst_pos3 = 3;
9077 break;
9078
9079 case 5600: hash_type = HASH_TYPE_MD5;
9080 salt_type = SALT_TYPE_EMBEDDED;
9081 attack_exec = ATTACK_EXEC_ON_GPU;
9082 opts_type = OPTS_TYPE_PT_GENERATE_LE
9083 | OPTS_TYPE_PT_ADD80
9084 | OPTS_TYPE_PT_ADDBITS14
9085 | OPTS_TYPE_PT_UNICODE;
9086 kern_type = KERN_TYPE_NETNTLMv2;
9087 dgst_size = DGST_SIZE_4_4;
9088 parse_func = netntlmv2_parse_hash;
9089 sort_by_digest = sort_by_digest_4_4;
9090 opti_type = OPTI_TYPE_ZERO_BYTE;
9091 dgst_pos0 = 0;
9092 dgst_pos1 = 3;
9093 dgst_pos2 = 2;
9094 dgst_pos3 = 1;
9095 break;
9096
9097 case 5700: hash_type = HASH_TYPE_SHA256;
9098 salt_type = SALT_TYPE_NONE;
9099 attack_exec = ATTACK_EXEC_ON_GPU;
9100 opts_type = OPTS_TYPE_PT_GENERATE_BE
9101 | OPTS_TYPE_PT_ADD80
9102 | OPTS_TYPE_PT_ADDBITS15;
9103 kern_type = KERN_TYPE_SHA256;
9104 dgst_size = DGST_SIZE_4_8;
9105 parse_func = cisco4_parse_hash;
9106 sort_by_digest = sort_by_digest_4_8;
9107 opti_type = OPTI_TYPE_ZERO_BYTE
9108 | OPTI_TYPE_PRECOMPUTE_INIT
9109 | OPTI_TYPE_PRECOMPUTE_MERKLE
9110 | OPTI_TYPE_SCALAR_MODE
9111 | OPTI_TYPE_EARLY_SKIP
9112 | OPTI_TYPE_NOT_ITERATED
9113 | OPTI_TYPE_NOT_SALTED
9114 | OPTI_TYPE_RAW_HASH;
9115 dgst_pos0 = 3;
9116 dgst_pos1 = 7;
9117 dgst_pos2 = 2;
9118 dgst_pos3 = 6;
9119 break;
9120
9121 case 5800: hash_type = HASH_TYPE_SHA1;
9122 salt_type = SALT_TYPE_INTERN;
9123 attack_exec = ATTACK_EXEC_ON_CPU;
9124 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
9125 | OPTS_TYPE_ST_ADD80;
9126 kern_type = KERN_TYPE_ANDROIDPIN;
9127 dgst_size = DGST_SIZE_4_5;
9128 parse_func = androidpin_parse_hash;
9129 sort_by_digest = sort_by_digest_4_5;
9130 opti_type = OPTI_TYPE_ZERO_BYTE;
9131 dgst_pos0 = 0;
9132 dgst_pos1 = 1;
9133 dgst_pos2 = 2;
9134 dgst_pos3 = 3;
9135 break;
9136
9137 case 6000: hash_type = HASH_TYPE_RIPEMD160;
9138 salt_type = SALT_TYPE_NONE;
9139 attack_exec = ATTACK_EXEC_ON_GPU;
9140 opts_type = OPTS_TYPE_PT_GENERATE_LE
9141 | OPTS_TYPE_PT_ADD80;
9142 kern_type = KERN_TYPE_RIPEMD160;
9143 dgst_size = DGST_SIZE_4_5;
9144 parse_func = ripemd160_parse_hash;
9145 sort_by_digest = sort_by_digest_4_5;
9146 opti_type = OPTI_TYPE_ZERO_BYTE;
9147 dgst_pos0 = 0;
9148 dgst_pos1 = 1;
9149 dgst_pos2 = 2;
9150 dgst_pos3 = 3;
9151 break;
9152
9153 case 6100: hash_type = HASH_TYPE_WHIRLPOOL;
9154 salt_type = SALT_TYPE_NONE;
9155 attack_exec = ATTACK_EXEC_ON_GPU;
9156 opts_type = OPTS_TYPE_PT_GENERATE_BE
9157 | OPTS_TYPE_PT_ADD80;
9158 kern_type = KERN_TYPE_WHIRLPOOL;
9159 dgst_size = DGST_SIZE_4_16;
9160 parse_func = whirlpool_parse_hash;
9161 sort_by_digest = sort_by_digest_4_16;
9162 opti_type = OPTI_TYPE_ZERO_BYTE;
9163 dgst_pos0 = 0;
9164 dgst_pos1 = 1;
9165 dgst_pos2 = 2;
9166 dgst_pos3 = 3;
9167 break;
9168
9169 case 6211: hash_type = HASH_TYPE_RIPEMD160;
9170 salt_type = SALT_TYPE_EMBEDDED;
9171 attack_exec = ATTACK_EXEC_ON_CPU;
9172 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9173 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
9174 dgst_size = DGST_SIZE_4_5;
9175 parse_func = truecrypt_parse_hash_2k;
9176 sort_by_digest = sort_by_digest_4_5;
9177 opti_type = OPTI_TYPE_ZERO_BYTE;
9178 dgst_pos0 = 0;
9179 dgst_pos1 = 1;
9180 dgst_pos2 = 2;
9181 dgst_pos3 = 3;
9182 break;
9183
9184 case 6212: hash_type = HASH_TYPE_RIPEMD160;
9185 salt_type = SALT_TYPE_EMBEDDED;
9186 attack_exec = ATTACK_EXEC_ON_CPU;
9187 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9188 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
9189 dgst_size = DGST_SIZE_4_5;
9190 parse_func = truecrypt_parse_hash_2k;
9191 sort_by_digest = sort_by_digest_4_5;
9192 opti_type = OPTI_TYPE_ZERO_BYTE;
9193 dgst_pos0 = 0;
9194 dgst_pos1 = 1;
9195 dgst_pos2 = 2;
9196 dgst_pos3 = 3;
9197 break;
9198
9199 case 6213: hash_type = HASH_TYPE_RIPEMD160;
9200 salt_type = SALT_TYPE_EMBEDDED;
9201 attack_exec = ATTACK_EXEC_ON_CPU;
9202 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9203 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
9204 dgst_size = DGST_SIZE_4_5;
9205 parse_func = truecrypt_parse_hash_2k;
9206 sort_by_digest = sort_by_digest_4_5;
9207 opti_type = OPTI_TYPE_ZERO_BYTE;
9208 dgst_pos0 = 0;
9209 dgst_pos1 = 1;
9210 dgst_pos2 = 2;
9211 dgst_pos3 = 3;
9212 break;
9213
9214 case 6221: hash_type = HASH_TYPE_SHA512;
9215 salt_type = SALT_TYPE_EMBEDDED;
9216 attack_exec = ATTACK_EXEC_ON_CPU;
9217 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9218 kern_type = KERN_TYPE_TCSHA512_XTS512;
9219 dgst_size = DGST_SIZE_8_8;
9220 parse_func = truecrypt_parse_hash_1k;
9221 sort_by_digest = sort_by_digest_8_8;
9222 opti_type = OPTI_TYPE_ZERO_BYTE;
9223 dgst_pos0 = 0;
9224 dgst_pos1 = 1;
9225 dgst_pos2 = 2;
9226 dgst_pos3 = 3;
9227 break;
9228
9229 case 6222: hash_type = HASH_TYPE_SHA512;
9230 salt_type = SALT_TYPE_EMBEDDED;
9231 attack_exec = ATTACK_EXEC_ON_CPU;
9232 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9233 kern_type = KERN_TYPE_TCSHA512_XTS1024;
9234 dgst_size = DGST_SIZE_8_8;
9235 parse_func = truecrypt_parse_hash_1k;
9236 sort_by_digest = sort_by_digest_8_8;
9237 opti_type = OPTI_TYPE_ZERO_BYTE;
9238 dgst_pos0 = 0;
9239 dgst_pos1 = 1;
9240 dgst_pos2 = 2;
9241 dgst_pos3 = 3;
9242 break;
9243
9244 case 6223: hash_type = HASH_TYPE_SHA512;
9245 salt_type = SALT_TYPE_EMBEDDED;
9246 attack_exec = ATTACK_EXEC_ON_CPU;
9247 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9248 kern_type = KERN_TYPE_TCSHA512_XTS1536;
9249 dgst_size = DGST_SIZE_8_8;
9250 parse_func = truecrypt_parse_hash_1k;
9251 sort_by_digest = sort_by_digest_8_8;
9252 opti_type = OPTI_TYPE_ZERO_BYTE;
9253 dgst_pos0 = 0;
9254 dgst_pos1 = 1;
9255 dgst_pos2 = 2;
9256 dgst_pos3 = 3;
9257 break;
9258
9259 case 6231: hash_type = HASH_TYPE_WHIRLPOOL;
9260 salt_type = SALT_TYPE_EMBEDDED;
9261 attack_exec = ATTACK_EXEC_ON_CPU;
9262 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9263 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS512;
9264 dgst_size = DGST_SIZE_4_8;
9265 parse_func = truecrypt_parse_hash_1k;
9266 sort_by_digest = sort_by_digest_4_8;
9267 opti_type = OPTI_TYPE_ZERO_BYTE;
9268 dgst_pos0 = 0;
9269 dgst_pos1 = 1;
9270 dgst_pos2 = 2;
9271 dgst_pos3 = 3;
9272 break;
9273
9274 case 6232: hash_type = HASH_TYPE_WHIRLPOOL;
9275 salt_type = SALT_TYPE_EMBEDDED;
9276 attack_exec = ATTACK_EXEC_ON_CPU;
9277 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9278 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1024;
9279 dgst_size = DGST_SIZE_4_8;
9280 parse_func = truecrypt_parse_hash_1k;
9281 sort_by_digest = sort_by_digest_4_8;
9282 opti_type = OPTI_TYPE_ZERO_BYTE;
9283 dgst_pos0 = 0;
9284 dgst_pos1 = 1;
9285 dgst_pos2 = 2;
9286 dgst_pos3 = 3;
9287 break;
9288
9289 case 6233: hash_type = HASH_TYPE_WHIRLPOOL;
9290 salt_type = SALT_TYPE_EMBEDDED;
9291 attack_exec = ATTACK_EXEC_ON_CPU;
9292 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9293 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1536;
9294 dgst_size = DGST_SIZE_4_8;
9295 parse_func = truecrypt_parse_hash_1k;
9296 sort_by_digest = sort_by_digest_4_8;
9297 opti_type = OPTI_TYPE_ZERO_BYTE;
9298 dgst_pos0 = 0;
9299 dgst_pos1 = 1;
9300 dgst_pos2 = 2;
9301 dgst_pos3 = 3;
9302 break;
9303
9304 case 6241: hash_type = HASH_TYPE_RIPEMD160;
9305 salt_type = SALT_TYPE_EMBEDDED;
9306 attack_exec = ATTACK_EXEC_ON_CPU;
9307 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9308 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
9309 dgst_size = DGST_SIZE_4_5;
9310 parse_func = truecrypt_parse_hash_1k;
9311 sort_by_digest = sort_by_digest_4_5;
9312 opti_type = OPTI_TYPE_ZERO_BYTE;
9313 dgst_pos0 = 0;
9314 dgst_pos1 = 1;
9315 dgst_pos2 = 2;
9316 dgst_pos3 = 3;
9317 break;
9318
9319 case 6242: hash_type = HASH_TYPE_RIPEMD160;
9320 salt_type = SALT_TYPE_EMBEDDED;
9321 attack_exec = ATTACK_EXEC_ON_CPU;
9322 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9323 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
9324 dgst_size = DGST_SIZE_4_5;
9325 parse_func = truecrypt_parse_hash_1k;
9326 sort_by_digest = sort_by_digest_4_5;
9327 opti_type = OPTI_TYPE_ZERO_BYTE;
9328 dgst_pos0 = 0;
9329 dgst_pos1 = 1;
9330 dgst_pos2 = 2;
9331 dgst_pos3 = 3;
9332 break;
9333
9334 case 6243: hash_type = HASH_TYPE_RIPEMD160;
9335 salt_type = SALT_TYPE_EMBEDDED;
9336 attack_exec = ATTACK_EXEC_ON_CPU;
9337 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9338 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
9339 dgst_size = DGST_SIZE_4_5;
9340 parse_func = truecrypt_parse_hash_1k;
9341 sort_by_digest = sort_by_digest_4_5;
9342 opti_type = OPTI_TYPE_ZERO_BYTE;
9343 dgst_pos0 = 0;
9344 dgst_pos1 = 1;
9345 dgst_pos2 = 2;
9346 dgst_pos3 = 3;
9347 break;
9348
9349 case 6300: hash_type = HASH_TYPE_MD5;
9350 salt_type = SALT_TYPE_EMBEDDED;
9351 attack_exec = ATTACK_EXEC_ON_CPU;
9352 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9353 kern_type = KERN_TYPE_MD5AIX;
9354 dgst_size = DGST_SIZE_4_4;
9355 parse_func = md5aix_parse_hash;
9356 sort_by_digest = sort_by_digest_4_4;
9357 opti_type = OPTI_TYPE_ZERO_BYTE;
9358 dgst_pos0 = 0;
9359 dgst_pos1 = 1;
9360 dgst_pos2 = 2;
9361 dgst_pos3 = 3;
9362 break;
9363
9364 case 6400: hash_type = HASH_TYPE_SHA256;
9365 salt_type = SALT_TYPE_EMBEDDED;
9366 attack_exec = ATTACK_EXEC_ON_CPU;
9367 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9368 kern_type = KERN_TYPE_SHA256AIX;
9369 dgst_size = DGST_SIZE_4_8;
9370 parse_func = sha256aix_parse_hash;
9371 sort_by_digest = sort_by_digest_4_8;
9372 opti_type = OPTI_TYPE_ZERO_BYTE;
9373 dgst_pos0 = 0;
9374 dgst_pos1 = 1;
9375 dgst_pos2 = 2;
9376 dgst_pos3 = 3;
9377 break;
9378
9379 case 6500: hash_type = HASH_TYPE_SHA512;
9380 salt_type = SALT_TYPE_EMBEDDED;
9381 attack_exec = ATTACK_EXEC_ON_CPU;
9382 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9383 kern_type = KERN_TYPE_SHA512AIX;
9384 dgst_size = DGST_SIZE_8_8;
9385 parse_func = sha512aix_parse_hash;
9386 sort_by_digest = sort_by_digest_8_8;
9387 opti_type = OPTI_TYPE_ZERO_BYTE;
9388 dgst_pos0 = 0;
9389 dgst_pos1 = 1;
9390 dgst_pos2 = 2;
9391 dgst_pos3 = 3;
9392 break;
9393
9394 case 6600: hash_type = HASH_TYPE_AES;
9395 salt_type = SALT_TYPE_EMBEDDED;
9396 attack_exec = ATTACK_EXEC_ON_CPU;
9397 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9398 kern_type = KERN_TYPE_AGILEKEY;
9399 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
9400 parse_func = agilekey_parse_hash;
9401 sort_by_digest = sort_by_digest_4_5;
9402 opti_type = OPTI_TYPE_ZERO_BYTE;
9403 dgst_pos0 = 0;
9404 dgst_pos1 = 1;
9405 dgst_pos2 = 2;
9406 dgst_pos3 = 3;
9407 break;
9408
9409 case 6700: hash_type = HASH_TYPE_SHA1;
9410 salt_type = SALT_TYPE_EMBEDDED;
9411 attack_exec = ATTACK_EXEC_ON_CPU;
9412 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9413 kern_type = KERN_TYPE_SHA1AIX;
9414 dgst_size = DGST_SIZE_4_5;
9415 parse_func = sha1aix_parse_hash;
9416 sort_by_digest = sort_by_digest_4_5;
9417 opti_type = OPTI_TYPE_ZERO_BYTE;
9418 dgst_pos0 = 0;
9419 dgst_pos1 = 1;
9420 dgst_pos2 = 2;
9421 dgst_pos3 = 3;
9422 break;
9423
9424 case 6800: hash_type = HASH_TYPE_AES;
9425 salt_type = SALT_TYPE_EMBEDDED;
9426 attack_exec = ATTACK_EXEC_ON_CPU;
9427 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9428 kern_type = KERN_TYPE_LASTPASS;
9429 dgst_size = DGST_SIZE_4_8; // because kernel uses _SHA256_
9430 parse_func = lastpass_parse_hash;
9431 sort_by_digest = sort_by_digest_4_8;
9432 opti_type = OPTI_TYPE_ZERO_BYTE;
9433 dgst_pos0 = 0;
9434 dgst_pos1 = 1;
9435 dgst_pos2 = 2;
9436 dgst_pos3 = 3;
9437 break;
9438
9439 case 6900: hash_type = HASH_TYPE_GOST;
9440 salt_type = SALT_TYPE_NONE;
9441 attack_exec = ATTACK_EXEC_ON_GPU;
9442 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9443 kern_type = KERN_TYPE_GOST;
9444 dgst_size = DGST_SIZE_4_8;
9445 parse_func = gost_parse_hash;
9446 sort_by_digest = sort_by_digest_4_8;
9447 opti_type = OPTI_TYPE_ZERO_BYTE;
9448 dgst_pos0 = 0;
9449 dgst_pos1 = 1;
9450 dgst_pos2 = 2;
9451 dgst_pos3 = 3;
9452 break;
9453
9454 case 7100: hash_type = HASH_TYPE_SHA512;
9455 salt_type = SALT_TYPE_EMBEDDED;
9456 attack_exec = ATTACK_EXEC_ON_CPU;
9457 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9458 kern_type = KERN_TYPE_PBKDF2_SHA512;
9459 dgst_size = DGST_SIZE_8_16;
9460 parse_func = sha512osx_parse_hash;
9461 sort_by_digest = sort_by_digest_8_16;
9462 opti_type = OPTI_TYPE_ZERO_BYTE;
9463 dgst_pos0 = 0;
9464 dgst_pos1 = 1;
9465 dgst_pos2 = 2;
9466 dgst_pos3 = 3;
9467 break;
9468
9469 case 7200: hash_type = HASH_TYPE_SHA512;
9470 salt_type = SALT_TYPE_EMBEDDED;
9471 attack_exec = ATTACK_EXEC_ON_CPU;
9472 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9473 kern_type = KERN_TYPE_PBKDF2_SHA512;
9474 dgst_size = DGST_SIZE_8_16;
9475 parse_func = sha512grub_parse_hash;
9476 sort_by_digest = sort_by_digest_8_16;
9477 opti_type = OPTI_TYPE_ZERO_BYTE;
9478 dgst_pos0 = 0;
9479 dgst_pos1 = 1;
9480 dgst_pos2 = 2;
9481 dgst_pos3 = 3;
9482 break;
9483
9484 case 7300: hash_type = HASH_TYPE_SHA1;
9485 salt_type = SALT_TYPE_EMBEDDED;
9486 attack_exec = ATTACK_EXEC_ON_GPU;
9487 opts_type = OPTS_TYPE_PT_GENERATE_BE
9488 | OPTS_TYPE_ST_ADD80
9489 | OPTS_TYPE_ST_ADDBITS15;
9490 kern_type = KERN_TYPE_RAKP;
9491 dgst_size = DGST_SIZE_4_5;
9492 parse_func = rakp_parse_hash;
9493 sort_by_digest = sort_by_digest_4_5;
9494 opti_type = OPTI_TYPE_ZERO_BYTE
9495 | OPTI_TYPE_NOT_ITERATED;
9496 dgst_pos0 = 3;
9497 dgst_pos1 = 4;
9498 dgst_pos2 = 2;
9499 dgst_pos3 = 1;
9500 break;
9501
9502 case 7400: hash_type = HASH_TYPE_SHA256;
9503 salt_type = SALT_TYPE_EMBEDDED;
9504 attack_exec = ATTACK_EXEC_ON_CPU;
9505 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9506 kern_type = KERN_TYPE_SHA256CRYPT;
9507 dgst_size = DGST_SIZE_4_8;
9508 parse_func = sha256crypt_parse_hash;
9509 sort_by_digest = sort_by_digest_4_8;
9510 opti_type = OPTI_TYPE_ZERO_BYTE;
9511 dgst_pos0 = 0;
9512 dgst_pos1 = 1;
9513 dgst_pos2 = 2;
9514 dgst_pos3 = 3;
9515 break;
9516
9517 case 7500: hash_type = HASH_TYPE_KRB5PA;
9518 salt_type = SALT_TYPE_EMBEDDED;
9519 attack_exec = ATTACK_EXEC_ON_GPU;
9520 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9521 kern_type = KERN_TYPE_KRB5PA;
9522 dgst_size = DGST_SIZE_4_4;
9523 parse_func = krb5pa_parse_hash;
9524 sort_by_digest = sort_by_digest_4_4;
9525 opti_type = OPTI_TYPE_ZERO_BYTE
9526 | OPTI_TYPE_NOT_ITERATED;
9527 dgst_pos0 = 3;
9528 dgst_pos1 = 7;
9529 dgst_pos2 = 2;
9530 dgst_pos3 = 6;
9531 break;
9532
9533 case 7600: hash_type = HASH_TYPE_SHA1;
9534 salt_type = SALT_TYPE_INTERN;
9535 attack_exec = ATTACK_EXEC_ON_GPU;
9536 opts_type = OPTS_TYPE_PT_GENERATE_BE
9537 | OPTS_TYPE_PT_ADD80
9538 | OPTS_TYPE_PT_ADDBITS15;
9539 kern_type = KERN_TYPE_SHA1_SLT_SHA1_PW;
9540 dgst_size = DGST_SIZE_4_5;
9541 parse_func = redmine_parse_hash;
9542 sort_by_digest = sort_by_digest_4_5;
9543 opti_type = OPTI_TYPE_ZERO_BYTE
9544 | OPTI_TYPE_PRECOMPUTE_INIT
9545 | OPTI_TYPE_EARLY_SKIP
9546 | OPTI_TYPE_NOT_ITERATED
9547 | OPTI_TYPE_PREPENDED_SALT;
9548 dgst_pos0 = 3;
9549 dgst_pos1 = 4;
9550 dgst_pos2 = 2;
9551 dgst_pos3 = 1;
9552 break;
9553
9554 case 7700: hash_type = HASH_TYPE_SAPB;
9555 salt_type = SALT_TYPE_EMBEDDED;
9556 attack_exec = ATTACK_EXEC_ON_GPU;
9557 opts_type = OPTS_TYPE_PT_GENERATE_LE
9558 | OPTS_TYPE_PT_UPPER
9559 | OPTS_TYPE_ST_UPPER;
9560 kern_type = KERN_TYPE_SAPB;
9561 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9562 parse_func = sapb_parse_hash;
9563 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9564 opti_type = OPTI_TYPE_ZERO_BYTE
9565 | OPTI_TYPE_PRECOMPUTE_INIT
9566 | OPTI_TYPE_NOT_ITERATED;
9567 dgst_pos0 = 0;
9568 dgst_pos1 = 1;
9569 dgst_pos2 = 2;
9570 dgst_pos3 = 3;
9571 break;
9572
9573 case 7800: hash_type = HASH_TYPE_SAPG;
9574 salt_type = SALT_TYPE_EMBEDDED;
9575 attack_exec = ATTACK_EXEC_ON_GPU;
9576 opts_type = OPTS_TYPE_PT_GENERATE_BE
9577 | OPTS_TYPE_ST_ADD80
9578 | OPTS_TYPE_ST_UPPER;
9579 kern_type = KERN_TYPE_SAPG;
9580 dgst_size = DGST_SIZE_4_5;
9581 parse_func = sapg_parse_hash;
9582 sort_by_digest = sort_by_digest_4_5;
9583 opti_type = OPTI_TYPE_ZERO_BYTE
9584 | OPTI_TYPE_PRECOMPUTE_INIT
9585 | OPTI_TYPE_NOT_ITERATED;
9586 dgst_pos0 = 3;
9587 dgst_pos1 = 4;
9588 dgst_pos2 = 2;
9589 dgst_pos3 = 1;
9590 break;
9591
9592 case 7900: hash_type = HASH_TYPE_SHA512;
9593 salt_type = SALT_TYPE_EMBEDDED;
9594 attack_exec = ATTACK_EXEC_ON_CPU;
9595 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9596 kern_type = KERN_TYPE_DRUPAL7;
9597 dgst_size = DGST_SIZE_8_8;
9598 parse_func = drupal7_parse_hash;
9599 sort_by_digest = sort_by_digest_8_8;
9600 opti_type = OPTI_TYPE_ZERO_BYTE;
9601 dgst_pos0 = 0;
9602 dgst_pos1 = 1;
9603 dgst_pos2 = 2;
9604 dgst_pos3 = 3;
9605 break;
9606
9607 case 8000: hash_type = HASH_TYPE_SHA256;
9608 salt_type = SALT_TYPE_EMBEDDED;
9609 attack_exec = ATTACK_EXEC_ON_GPU;
9610 opts_type = OPTS_TYPE_PT_GENERATE_BE
9611 | OPTS_TYPE_PT_UNICODE
9612 | OPTS_TYPE_ST_ADD80
9613 | OPTS_TYPE_ST_HEX;
9614 kern_type = KERN_TYPE_SYBASEASE;
9615 dgst_size = DGST_SIZE_4_8;
9616 parse_func = sybasease_parse_hash;
9617 sort_by_digest = sort_by_digest_4_8;
9618 opti_type = OPTI_TYPE_ZERO_BYTE
9619 | OPTI_TYPE_PRECOMPUTE_INIT
9620 | OPTI_TYPE_SCALAR_MODE
9621 | OPTI_TYPE_EARLY_SKIP
9622 | OPTI_TYPE_NOT_ITERATED
9623 | OPTI_TYPE_RAW_HASH;
9624 dgst_pos0 = 3;
9625 dgst_pos1 = 7;
9626 dgst_pos2 = 2;
9627 dgst_pos3 = 6;
9628 break;
9629
9630 case 8100: hash_type = HASH_TYPE_SHA1;
9631 salt_type = SALT_TYPE_EMBEDDED;
9632 attack_exec = ATTACK_EXEC_ON_GPU;
9633 opts_type = OPTS_TYPE_PT_GENERATE_BE;
9634 kern_type = KERN_TYPE_NETSCALER;
9635 dgst_size = DGST_SIZE_4_5;
9636 parse_func = netscaler_parse_hash;
9637 sort_by_digest = sort_by_digest_4_5;
9638 opti_type = OPTI_TYPE_ZERO_BYTE
9639 | OPTI_TYPE_PRECOMPUTE_INIT
9640 | OPTI_TYPE_PRECOMPUTE_MERKLE
9641 | OPTI_TYPE_EARLY_SKIP
9642 | OPTI_TYPE_NOT_ITERATED
9643 | OPTI_TYPE_PREPENDED_SALT
9644 | OPTI_TYPE_RAW_HASH;
9645 dgst_pos0 = 3;
9646 dgst_pos1 = 4;
9647 dgst_pos2 = 2;
9648 dgst_pos3 = 1;
9649 break;
9650
9651 case 8200: hash_type = HASH_TYPE_SHA256;
9652 salt_type = SALT_TYPE_EMBEDDED;
9653 attack_exec = ATTACK_EXEC_ON_CPU;
9654 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9655 kern_type = KERN_TYPE_CLOUDKEY;
9656 dgst_size = DGST_SIZE_4_8;
9657 parse_func = cloudkey_parse_hash;
9658 sort_by_digest = sort_by_digest_4_8;
9659 opti_type = OPTI_TYPE_ZERO_BYTE;
9660 dgst_pos0 = 0;
9661 dgst_pos1 = 1;
9662 dgst_pos2 = 2;
9663 dgst_pos3 = 3;
9664 break;
9665
9666 case 8300: hash_type = HASH_TYPE_SHA1;
9667 salt_type = SALT_TYPE_EMBEDDED;
9668 attack_exec = ATTACK_EXEC_ON_GPU;
9669 opts_type = OPTS_TYPE_PT_GENERATE_LE
9670 | OPTS_TYPE_ST_HEX
9671 | OPTS_TYPE_ST_ADD80;
9672 kern_type = KERN_TYPE_NSEC3;
9673 dgst_size = DGST_SIZE_4_5;
9674 parse_func = nsec3_parse_hash;
9675 sort_by_digest = sort_by_digest_4_5;
9676 opti_type = OPTI_TYPE_ZERO_BYTE;
9677 dgst_pos0 = 3;
9678 dgst_pos1 = 4;
9679 dgst_pos2 = 2;
9680 dgst_pos3 = 1;
9681 break;
9682
9683 case 8400: hash_type = HASH_TYPE_SHA1;
9684 salt_type = SALT_TYPE_INTERN;
9685 attack_exec = ATTACK_EXEC_ON_GPU;
9686 opts_type = OPTS_TYPE_PT_GENERATE_BE
9687 | OPTS_TYPE_PT_ADD80
9688 | OPTS_TYPE_PT_ADDBITS15;
9689 kern_type = KERN_TYPE_WBB3;
9690 dgst_size = DGST_SIZE_4_5;
9691 parse_func = wbb3_parse_hash;
9692 sort_by_digest = sort_by_digest_4_5;
9693 opti_type = OPTI_TYPE_ZERO_BYTE
9694 | OPTI_TYPE_PRECOMPUTE_INIT
9695 | OPTI_TYPE_NOT_ITERATED;
9696 dgst_pos0 = 3;
9697 dgst_pos1 = 4;
9698 dgst_pos2 = 2;
9699 dgst_pos3 = 1;
9700 break;
9701
9702 case 8500: hash_type = HASH_TYPE_DESRACF;
9703 salt_type = SALT_TYPE_EMBEDDED;
9704 attack_exec = ATTACK_EXEC_ON_GPU;
9705 opts_type = OPTS_TYPE_PT_GENERATE_LE
9706 | OPTS_TYPE_ST_UPPER;
9707 kern_type = KERN_TYPE_RACF;
9708 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9709 parse_func = racf_parse_hash;
9710 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9711 opti_type = OPTI_TYPE_ZERO_BYTE
9712 | OPTI_TYPE_SCALAR_MODE
9713 | OPTI_TYPE_PRECOMPUTE_PERMUT;
9714 dgst_pos0 = 0;
9715 dgst_pos1 = 1;
9716 dgst_pos2 = 2;
9717 dgst_pos3 = 3;
9718 break;
9719
9720 case 8600: hash_type = HASH_TYPE_LOTUS5;
9721 salt_type = SALT_TYPE_NONE;
9722 attack_exec = ATTACK_EXEC_ON_GPU;
9723 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9724 kern_type = KERN_TYPE_LOTUS5;
9725 dgst_size = DGST_SIZE_4_4;
9726 parse_func = lotus5_parse_hash;
9727 sort_by_digest = sort_by_digest_4_4;
9728 opti_type = OPTI_TYPE_SCALAR_MODE
9729 | OPTI_TYPE_EARLY_SKIP
9730 | OPTI_TYPE_NOT_ITERATED
9731 | OPTI_TYPE_NOT_SALTED
9732 | OPTI_TYPE_RAW_HASH;
9733 dgst_pos0 = 0;
9734 dgst_pos1 = 1;
9735 dgst_pos2 = 2;
9736 dgst_pos3 = 3;
9737 break;
9738
9739 case 8700: hash_type = HASH_TYPE_LOTUS6;
9740 salt_type = SALT_TYPE_EMBEDDED;
9741 attack_exec = ATTACK_EXEC_ON_GPU;
9742 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9743 kern_type = KERN_TYPE_LOTUS6;
9744 dgst_size = DGST_SIZE_4_4;
9745 parse_func = lotus6_parse_hash;
9746 sort_by_digest = sort_by_digest_4_4;
9747 opti_type = OPTI_TYPE_SCALAR_MODE
9748 | OPTI_TYPE_EARLY_SKIP
9749 | OPTI_TYPE_NOT_ITERATED
9750 | OPTI_TYPE_RAW_HASH;
9751 dgst_pos0 = 0;
9752 dgst_pos1 = 1;
9753 dgst_pos2 = 2;
9754 dgst_pos3 = 3;
9755 break;
9756
9757 case 8800: hash_type = HASH_TYPE_ANDROIDFDE;
9758 salt_type = SALT_TYPE_EMBEDDED;
9759 attack_exec = ATTACK_EXEC_ON_CPU;
9760 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9761 kern_type = KERN_TYPE_ANDROIDFDE;
9762 dgst_size = DGST_SIZE_4_4;
9763 parse_func = androidfde_parse_hash;
9764 sort_by_digest = sort_by_digest_4_4;
9765 opti_type = OPTI_TYPE_ZERO_BYTE;
9766 dgst_pos0 = 0;
9767 dgst_pos1 = 1;
9768 dgst_pos2 = 2;
9769 dgst_pos3 = 3;
9770 break;
9771
9772 case 8900: hash_type = HASH_TYPE_SCRYPT;
9773 salt_type = SALT_TYPE_EMBEDDED;
9774 attack_exec = ATTACK_EXEC_ON_CPU;
9775 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9776 kern_type = KERN_TYPE_SCRYPT;
9777 dgst_size = DGST_SIZE_4_8;
9778 parse_func = scrypt_parse_hash;
9779 sort_by_digest = sort_by_digest_4_8;
9780 opti_type = OPTI_TYPE_ZERO_BYTE;
9781 dgst_pos0 = 0;
9782 dgst_pos1 = 1;
9783 dgst_pos2 = 2;
9784 dgst_pos3 = 3;
9785 break;
9786
9787 case 9000: hash_type = HASH_TYPE_SHA1;
9788 salt_type = SALT_TYPE_EMBEDDED;
9789 attack_exec = ATTACK_EXEC_ON_CPU;
9790 opts_type = OPTS_TYPE_PT_GENERATE_LE
9791 | OPTS_TYPE_ST_GENERATE_LE;
9792 kern_type = KERN_TYPE_PSAFE2;
9793 dgst_size = DGST_SIZE_4_5;
9794 parse_func = psafe2_parse_hash;
9795 sort_by_digest = sort_by_digest_4_5;
9796 opti_type = OPTI_TYPE_ZERO_BYTE;
9797 dgst_pos0 = 0;
9798 dgst_pos1 = 1;
9799 dgst_pos2 = 2;
9800 dgst_pos3 = 3;
9801 break;
9802
9803 case 9100: hash_type = HASH_TYPE_LOTUS8;
9804 salt_type = SALT_TYPE_EMBEDDED;
9805 attack_exec = ATTACK_EXEC_ON_CPU;
9806 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9807 kern_type = KERN_TYPE_LOTUS8;
9808 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9809 parse_func = lotus8_parse_hash;
9810 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9811 opti_type = OPTI_TYPE_ZERO_BYTE;
9812 dgst_pos0 = 0;
9813 dgst_pos1 = 1;
9814 dgst_pos2 = 2;
9815 dgst_pos3 = 3;
9816 break;
9817
9818 case 9200: hash_type = HASH_TYPE_SHA256;
9819 salt_type = SALT_TYPE_EMBEDDED;
9820 attack_exec = ATTACK_EXEC_ON_CPU;
9821 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9822 kern_type = KERN_TYPE_PBKDF2_SHA256;
9823 dgst_size = DGST_SIZE_4_32;
9824 parse_func = cisco8_parse_hash;
9825 sort_by_digest = sort_by_digest_4_32;
9826 opti_type = OPTI_TYPE_ZERO_BYTE;
9827 dgst_pos0 = 0;
9828 dgst_pos1 = 1;
9829 dgst_pos2 = 2;
9830 dgst_pos3 = 3;
9831 break;
9832
9833 case 9300: hash_type = HASH_TYPE_SCRYPT;
9834 salt_type = SALT_TYPE_EMBEDDED;
9835 attack_exec = ATTACK_EXEC_ON_CPU;
9836 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9837 kern_type = KERN_TYPE_SCRYPT;
9838 dgst_size = DGST_SIZE_4_8;
9839 parse_func = cisco9_parse_hash;
9840 sort_by_digest = sort_by_digest_4_8;
9841 opti_type = OPTI_TYPE_ZERO_BYTE;
9842 dgst_pos0 = 0;
9843 dgst_pos1 = 1;
9844 dgst_pos2 = 2;
9845 dgst_pos3 = 3;
9846 break;
9847
9848 case 9400: hash_type = HASH_TYPE_OFFICE2007;
9849 salt_type = SALT_TYPE_EMBEDDED;
9850 attack_exec = ATTACK_EXEC_ON_CPU;
9851 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9852 kern_type = KERN_TYPE_OFFICE2007;
9853 dgst_size = DGST_SIZE_4_4;
9854 parse_func = office2007_parse_hash;
9855 sort_by_digest = sort_by_digest_4_4;
9856 opti_type = OPTI_TYPE_ZERO_BYTE;
9857 dgst_pos0 = 0;
9858 dgst_pos1 = 1;
9859 dgst_pos2 = 2;
9860 dgst_pos3 = 3;
9861 break;
9862
9863 case 9500: hash_type = HASH_TYPE_OFFICE2010;
9864 salt_type = SALT_TYPE_EMBEDDED;
9865 attack_exec = ATTACK_EXEC_ON_CPU;
9866 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9867 kern_type = KERN_TYPE_OFFICE2010;
9868 dgst_size = DGST_SIZE_4_4;
9869 parse_func = office2010_parse_hash;
9870 sort_by_digest = sort_by_digest_4_4;
9871 opti_type = OPTI_TYPE_ZERO_BYTE;
9872 dgst_pos0 = 0;
9873 dgst_pos1 = 1;
9874 dgst_pos2 = 2;
9875 dgst_pos3 = 3;
9876 break;
9877
9878 case 9600: hash_type = HASH_TYPE_OFFICE2013;
9879 salt_type = SALT_TYPE_EMBEDDED;
9880 attack_exec = ATTACK_EXEC_ON_CPU;
9881 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9882 kern_type = KERN_TYPE_OFFICE2013;
9883 dgst_size = DGST_SIZE_4_4;
9884 parse_func = office2013_parse_hash;
9885 sort_by_digest = sort_by_digest_4_4;
9886 opti_type = OPTI_TYPE_ZERO_BYTE;
9887 dgst_pos0 = 0;
9888 dgst_pos1 = 1;
9889 dgst_pos2 = 2;
9890 dgst_pos3 = 3;
9891 break;
9892
9893 case 9700: hash_type = HASH_TYPE_OLDOFFICE01;
9894 salt_type = SALT_TYPE_EMBEDDED;
9895 attack_exec = ATTACK_EXEC_ON_GPU;
9896 opts_type = OPTS_TYPE_PT_GENERATE_LE
9897 | OPTS_TYPE_PT_ADD80
9898 | OPTS_TYPE_PT_UNICODE;
9899 kern_type = KERN_TYPE_OLDOFFICE01;
9900 dgst_size = DGST_SIZE_4_4;
9901 parse_func = oldoffice01_parse_hash;
9902 sort_by_digest = sort_by_digest_4_4;
9903 opti_type = OPTI_TYPE_ZERO_BYTE
9904 | OPTI_TYPE_PRECOMPUTE_INIT
9905 | OPTI_TYPE_NOT_ITERATED;
9906 dgst_pos0 = 0;
9907 dgst_pos1 = 1;
9908 dgst_pos2 = 2;
9909 dgst_pos3 = 3;
9910 break;
9911
9912 case 9710: hash_type = HASH_TYPE_OLDOFFICE01;
9913 salt_type = SALT_TYPE_EMBEDDED;
9914 attack_exec = ATTACK_EXEC_ON_GPU;
9915 opts_type = OPTS_TYPE_PT_GENERATE_LE
9916 | OPTS_TYPE_PT_ADD80;
9917 kern_type = KERN_TYPE_OLDOFFICE01CM1;
9918 dgst_size = DGST_SIZE_4_4;
9919 parse_func = oldoffice01cm1_parse_hash;
9920 sort_by_digest = sort_by_digest_4_4;
9921 opti_type = OPTI_TYPE_ZERO_BYTE
9922 | OPTI_TYPE_PRECOMPUTE_INIT
9923 | OPTI_TYPE_NOT_ITERATED;
9924 dgst_pos0 = 0;
9925 dgst_pos1 = 1;
9926 dgst_pos2 = 2;
9927 dgst_pos3 = 3;
9928 break;
9929
9930 case 9720: hash_type = HASH_TYPE_OLDOFFICE01;
9931 salt_type = SALT_TYPE_EMBEDDED;
9932 attack_exec = ATTACK_EXEC_ON_GPU;
9933 opts_type = OPTS_TYPE_PT_GENERATE_LE
9934 | OPTS_TYPE_PT_ADD80
9935 | OPTS_TYPE_PT_UNICODE
9936 | OPTS_TYPE_PT_NEVERCRACK;
9937 kern_type = KERN_TYPE_OLDOFFICE01CM2;
9938 dgst_size = DGST_SIZE_4_4;
9939 parse_func = oldoffice01cm2_parse_hash;
9940 sort_by_digest = sort_by_digest_4_4;
9941 opti_type = OPTI_TYPE_ZERO_BYTE
9942 | OPTI_TYPE_PRECOMPUTE_INIT
9943 | OPTI_TYPE_NOT_ITERATED;
9944 dgst_pos0 = 0;
9945 dgst_pos1 = 1;
9946 dgst_pos2 = 2;
9947 dgst_pos3 = 3;
9948 break;
9949
9950 case 9800: hash_type = HASH_TYPE_OLDOFFICE34;
9951 salt_type = SALT_TYPE_EMBEDDED;
9952 attack_exec = ATTACK_EXEC_ON_GPU;
9953 opts_type = OPTS_TYPE_PT_GENERATE_BE
9954 | OPTS_TYPE_PT_ADD80
9955 | OPTS_TYPE_PT_UNICODE;
9956 kern_type = KERN_TYPE_OLDOFFICE34;
9957 dgst_size = DGST_SIZE_4_4;
9958 parse_func = oldoffice34_parse_hash;
9959 sort_by_digest = sort_by_digest_4_4;
9960 opti_type = OPTI_TYPE_ZERO_BYTE
9961 | OPTI_TYPE_PRECOMPUTE_INIT
9962 | OPTI_TYPE_NOT_ITERATED;
9963 dgst_pos0 = 0;
9964 dgst_pos1 = 1;
9965 dgst_pos2 = 2;
9966 dgst_pos3 = 3;
9967 break;
9968
9969 case 9810: hash_type = HASH_TYPE_OLDOFFICE34;
9970 salt_type = SALT_TYPE_EMBEDDED;
9971 attack_exec = ATTACK_EXEC_ON_GPU;
9972 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9973 kern_type = KERN_TYPE_OLDOFFICE34CM1;
9974 dgst_size = DGST_SIZE_4_4;
9975 parse_func = oldoffice34cm1_parse_hash;
9976 sort_by_digest = sort_by_digest_4_4;
9977 opti_type = OPTI_TYPE_ZERO_BYTE
9978 | OPTI_TYPE_PRECOMPUTE_INIT
9979 | OPTI_TYPE_NOT_ITERATED;
9980 dgst_pos0 = 0;
9981 dgst_pos1 = 1;
9982 dgst_pos2 = 2;
9983 dgst_pos3 = 3;
9984 break;
9985
9986 case 9820: hash_type = HASH_TYPE_OLDOFFICE34;
9987 salt_type = SALT_TYPE_EMBEDDED;
9988 attack_exec = ATTACK_EXEC_ON_GPU;
9989 opts_type = OPTS_TYPE_PT_GENERATE_BE
9990 | OPTS_TYPE_PT_ADD80
9991 | OPTS_TYPE_PT_UNICODE
9992 | OPTS_TYPE_PT_NEVERCRACK;
9993 kern_type = KERN_TYPE_OLDOFFICE34CM2;
9994 dgst_size = DGST_SIZE_4_4;
9995 parse_func = oldoffice34cm2_parse_hash;
9996 sort_by_digest = sort_by_digest_4_4;
9997 opti_type = OPTI_TYPE_ZERO_BYTE
9998 | OPTI_TYPE_PRECOMPUTE_INIT
9999 | OPTI_TYPE_NOT_ITERATED;
10000 dgst_pos0 = 0;
10001 dgst_pos1 = 1;
10002 dgst_pos2 = 2;
10003 dgst_pos3 = 3;
10004 break;
10005
10006 case 9900: hash_type = HASH_TYPE_MD5;
10007 salt_type = SALT_TYPE_NONE;
10008 attack_exec = ATTACK_EXEC_ON_GPU;
10009 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10010 kern_type = KERN_TYPE_RADMIN2;
10011 dgst_size = DGST_SIZE_4_4;
10012 parse_func = radmin2_parse_hash;
10013 sort_by_digest = sort_by_digest_4_4;
10014 opti_type = OPTI_TYPE_ZERO_BYTE
10015 | OPTI_TYPE_PRECOMPUTE_INIT
10016 | OPTI_TYPE_SCALAR_MODE
10017 | OPTI_TYPE_EARLY_SKIP
10018 | OPTI_TYPE_NOT_ITERATED
10019 | OPTI_TYPE_NOT_SALTED;
10020 dgst_pos0 = 0;
10021 dgst_pos1 = 3;
10022 dgst_pos2 = 2;
10023 dgst_pos3 = 1;
10024 break;
10025
10026 case 10000: hash_type = HASH_TYPE_SHA256;
10027 salt_type = SALT_TYPE_EMBEDDED;
10028 attack_exec = ATTACK_EXEC_ON_CPU;
10029 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
10030 kern_type = KERN_TYPE_PBKDF2_SHA256;
10031 dgst_size = DGST_SIZE_4_32;
10032 parse_func = djangopbkdf2_parse_hash;
10033 sort_by_digest = sort_by_digest_4_32;
10034 opti_type = OPTI_TYPE_ZERO_BYTE;
10035 dgst_pos0 = 0;
10036 dgst_pos1 = 1;
10037 dgst_pos2 = 2;
10038 dgst_pos3 = 3;
10039 break;
10040
10041 case 10100: hash_type = HASH_TYPE_SIPHASH;
10042 salt_type = SALT_TYPE_EMBEDDED;
10043 attack_exec = ATTACK_EXEC_ON_GPU;
10044 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10045 kern_type = KERN_TYPE_SIPHASH;
10046 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10047 parse_func = siphash_parse_hash;
10048 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10049 opti_type = OPTI_TYPE_ZERO_BYTE
10050 | OPTI_TYPE_SCALAR_MODE
10051 | OPTI_TYPE_NOT_ITERATED
10052 | OPTI_TYPE_RAW_HASH;
10053 dgst_pos0 = 0;
10054 dgst_pos1 = 1;
10055 dgst_pos2 = 2;
10056 dgst_pos3 = 3;
10057 break;
10058
10059 case 10200: hash_type = HASH_TYPE_MD5;
10060 salt_type = SALT_TYPE_EMBEDDED;
10061 attack_exec = ATTACK_EXEC_ON_GPU;
10062 opts_type = OPTS_TYPE_PT_GENERATE_LE
10063 | OPTS_TYPE_ST_ADD80
10064 | OPTS_TYPE_ST_ADDBITS14;
10065 kern_type = KERN_TYPE_HMACMD5_PW;
10066 dgst_size = DGST_SIZE_4_4;
10067 parse_func = crammd5_parse_hash;
10068 sort_by_digest = sort_by_digest_4_4;
10069 opti_type = OPTI_TYPE_ZERO_BYTE
10070 | OPTI_TYPE_NOT_ITERATED;
10071 dgst_pos0 = 0;
10072 dgst_pos1 = 3;
10073 dgst_pos2 = 2;
10074 dgst_pos3 = 1;
10075 break;
10076
10077 case 10300: hash_type = HASH_TYPE_SHA1;
10078 salt_type = SALT_TYPE_EMBEDDED;
10079 attack_exec = ATTACK_EXEC_ON_CPU;
10080 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
10081 kern_type = KERN_TYPE_SAPH_SHA1;
10082 dgst_size = DGST_SIZE_4_5;
10083 parse_func = saph_sha1_parse_hash;
10084 sort_by_digest = sort_by_digest_4_5;
10085 opti_type = OPTI_TYPE_ZERO_BYTE;
10086 dgst_pos0 = 0;
10087 dgst_pos1 = 1;
10088 dgst_pos2 = 2;
10089 dgst_pos3 = 3;
10090 break;
10091
10092 case 10400: hash_type = HASH_TYPE_PDFU16;
10093 salt_type = SALT_TYPE_EMBEDDED;
10094 attack_exec = ATTACK_EXEC_ON_GPU;
10095 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10096 kern_type = KERN_TYPE_PDF11;
10097 dgst_size = DGST_SIZE_4_4;
10098 parse_func = pdf11_parse_hash;
10099 sort_by_digest = sort_by_digest_4_4;
10100 opti_type = OPTI_TYPE_ZERO_BYTE
10101 | OPTI_TYPE_NOT_ITERATED;
10102 dgst_pos0 = 0;
10103 dgst_pos1 = 1;
10104 dgst_pos2 = 2;
10105 dgst_pos3 = 3;
10106 break;
10107
10108 case 10410: hash_type = HASH_TYPE_PDFU16;
10109 salt_type = SALT_TYPE_EMBEDDED;
10110 attack_exec = ATTACK_EXEC_ON_GPU;
10111 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10112 kern_type = KERN_TYPE_PDF11CM1;
10113 dgst_size = DGST_SIZE_4_4;
10114 parse_func = pdf11cm1_parse_hash;
10115 sort_by_digest = sort_by_digest_4_4;
10116 opti_type = OPTI_TYPE_ZERO_BYTE
10117 | OPTI_TYPE_NOT_ITERATED;
10118 dgst_pos0 = 0;
10119 dgst_pos1 = 1;
10120 dgst_pos2 = 2;
10121 dgst_pos3 = 3;
10122 break;
10123
10124 case 10420: hash_type = HASH_TYPE_PDFU16;
10125 salt_type = SALT_TYPE_EMBEDDED;
10126 attack_exec = ATTACK_EXEC_ON_GPU;
10127 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10128 kern_type = KERN_TYPE_PDF11CM2;
10129 dgst_size = DGST_SIZE_4_4;
10130 parse_func = pdf11cm2_parse_hash;
10131 sort_by_digest = sort_by_digest_4_4;
10132 opti_type = OPTI_TYPE_ZERO_BYTE
10133 | OPTI_TYPE_NOT_ITERATED;
10134 dgst_pos0 = 0;
10135 dgst_pos1 = 1;
10136 dgst_pos2 = 2;
10137 dgst_pos3 = 3;
10138 break;
10139
10140 case 10500: hash_type = HASH_TYPE_PDFU16;
10141 salt_type = SALT_TYPE_EMBEDDED;
10142 attack_exec = ATTACK_EXEC_ON_CPU;
10143 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10144 kern_type = KERN_TYPE_PDF14;
10145 dgst_size = DGST_SIZE_4_4;
10146 parse_func = pdf14_parse_hash;
10147 sort_by_digest = sort_by_digest_4_4;
10148 opti_type = OPTI_TYPE_ZERO_BYTE
10149 | OPTI_TYPE_NOT_ITERATED;
10150 dgst_pos0 = 0;
10151 dgst_pos1 = 1;
10152 dgst_pos2 = 2;
10153 dgst_pos3 = 3;
10154 break;
10155
10156 case 10600: hash_type = HASH_TYPE_SHA256;
10157 salt_type = SALT_TYPE_EMBEDDED;
10158 attack_exec = ATTACK_EXEC_ON_GPU;
10159 opts_type = OPTS_TYPE_PT_GENERATE_BE
10160 | OPTS_TYPE_ST_ADD80
10161 | OPTS_TYPE_ST_ADDBITS15
10162 | OPTS_TYPE_HASH_COPY;
10163 kern_type = KERN_TYPE_SHA256_PWSLT;
10164 dgst_size = DGST_SIZE_4_8;
10165 parse_func = pdf17l3_parse_hash;
10166 sort_by_digest = sort_by_digest_4_8;
10167 opti_type = OPTI_TYPE_ZERO_BYTE
10168 | OPTI_TYPE_PRECOMPUTE_INIT
10169 | OPTI_TYPE_PRECOMPUTE_MERKLE
10170 | OPTI_TYPE_SCALAR_MODE
10171 | OPTI_TYPE_EARLY_SKIP
10172 | OPTI_TYPE_NOT_ITERATED
10173 | OPTI_TYPE_APPENDED_SALT
10174 | OPTI_TYPE_RAW_HASH;
10175 dgst_pos0 = 3;
10176 dgst_pos1 = 7;
10177 dgst_pos2 = 2;
10178 dgst_pos3 = 6;
10179 break;
10180
10181 case 10700: hash_type = HASH_TYPE_PDFU32;
10182 salt_type = SALT_TYPE_EMBEDDED;
10183 attack_exec = ATTACK_EXEC_ON_CPU;
10184 opts_type = OPTS_TYPE_PT_GENERATE_LE
10185 | OPTS_TYPE_HASH_COPY;
10186 kern_type = KERN_TYPE_PDF17L8;
10187 dgst_size = DGST_SIZE_4_8;
10188 parse_func = pdf17l8_parse_hash;
10189 sort_by_digest = sort_by_digest_4_8;
10190 opti_type = OPTI_TYPE_ZERO_BYTE
10191 | OPTI_TYPE_NOT_ITERATED;
10192 dgst_pos0 = 0;
10193 dgst_pos1 = 1;
10194 dgst_pos2 = 2;
10195 dgst_pos3 = 3;
10196 break;
10197
10198 case 10800: hash_type = HASH_TYPE_SHA384;
10199 salt_type = SALT_TYPE_NONE;
10200 attack_exec = ATTACK_EXEC_ON_GPU;
10201 opts_type = OPTS_TYPE_PT_GENERATE_BE
10202 | OPTS_TYPE_PT_ADD80
10203 | OPTS_TYPE_PT_ADDBITS15;
10204 kern_type = KERN_TYPE_SHA384;
10205 dgst_size = DGST_SIZE_8_8;
10206 parse_func = sha384_parse_hash;
10207 sort_by_digest = sort_by_digest_8_8;
10208 opti_type = OPTI_TYPE_ZERO_BYTE
10209 | OPTI_TYPE_PRECOMPUTE_INIT
10210 | OPTI_TYPE_PRECOMPUTE_MERKLE
10211 | OPTI_TYPE_SCALAR_MODE
10212 | OPTI_TYPE_EARLY_SKIP
10213 | OPTI_TYPE_NOT_ITERATED
10214 | OPTI_TYPE_NOT_SALTED
10215 | OPTI_TYPE_RAW_HASH;
10216 dgst_pos0 = 6;
10217 dgst_pos1 = 7;
10218 dgst_pos2 = 4;
10219 dgst_pos3 = 5;
10220 break;
10221
10222 case 10900: hash_type = HASH_TYPE_PBKDF2_SHA256;
10223 salt_type = SALT_TYPE_EMBEDDED;
10224 attack_exec = ATTACK_EXEC_ON_CPU;
10225 opts_type = OPTS_TYPE_PT_GENERATE_LE
10226 | OPTS_TYPE_ST_BASE64
10227 | OPTS_TYPE_HASH_COPY;
10228 kern_type = KERN_TYPE_PBKDF2_SHA256;
10229 dgst_size = DGST_SIZE_4_32;
10230 parse_func = pbkdf2_sha256_parse_hash;
10231 sort_by_digest = sort_by_digest_4_32;
10232 opti_type = OPTI_TYPE_ZERO_BYTE;
10233 dgst_pos0 = 0;
10234 dgst_pos1 = 1;
10235 dgst_pos2 = 2;
10236 dgst_pos3 = 3;
10237 break;
10238
10239 case 11000: hash_type = HASH_TYPE_MD5;
10240 salt_type = SALT_TYPE_INTERN;
10241 attack_exec = ATTACK_EXEC_ON_GPU;
10242 opts_type = OPTS_TYPE_PT_GENERATE_LE
10243 | OPTS_TYPE_PT_ADD80;
10244 kern_type = KERN_TYPE_PRESTASHOP;
10245 dgst_size = DGST_SIZE_4_4;
10246 parse_func = prestashop_parse_hash;
10247 sort_by_digest = sort_by_digest_4_4;
10248 opti_type = OPTI_TYPE_ZERO_BYTE
10249 | OPTI_TYPE_PRECOMPUTE_INIT
10250 | OPTI_TYPE_NOT_ITERATED
10251 | OPTI_TYPE_PREPENDED_SALT;
10252 dgst_pos0 = 0;
10253 dgst_pos1 = 3;
10254 dgst_pos2 = 2;
10255 dgst_pos3 = 1;
10256 break;
10257
10258 case 11100: hash_type = HASH_TYPE_MD5;
10259 salt_type = SALT_TYPE_EMBEDDED;
10260 attack_exec = ATTACK_EXEC_ON_GPU;
10261 opts_type = OPTS_TYPE_PT_GENERATE_LE
10262 | OPTS_TYPE_ST_ADD80;
10263 kern_type = KERN_TYPE_POSTGRESQL_AUTH;
10264 dgst_size = DGST_SIZE_4_4;
10265 parse_func = postgresql_auth_parse_hash;
10266 sort_by_digest = sort_by_digest_4_4;
10267 opti_type = OPTI_TYPE_ZERO_BYTE
10268 | OPTI_TYPE_PRECOMPUTE_INIT
10269 | OPTI_TYPE_PRECOMPUTE_MERKLE
10270 | OPTI_TYPE_EARLY_SKIP;
10271 dgst_pos0 = 0;
10272 dgst_pos1 = 3;
10273 dgst_pos2 = 2;
10274 dgst_pos3 = 1;
10275 break;
10276
10277 case 11200: hash_type = HASH_TYPE_SHA1;
10278 salt_type = SALT_TYPE_EMBEDDED;
10279 attack_exec = ATTACK_EXEC_ON_GPU;
10280 opts_type = OPTS_TYPE_PT_GENERATE_BE
10281 | OPTS_TYPE_PT_ADD80
10282 | OPTS_TYPE_ST_HEX;
10283 kern_type = KERN_TYPE_MYSQL_AUTH;
10284 dgst_size = DGST_SIZE_4_5;
10285 parse_func = mysql_auth_parse_hash;
10286 sort_by_digest = sort_by_digest_4_5;
10287 opti_type = OPTI_TYPE_ZERO_BYTE
10288 | OPTI_TYPE_EARLY_SKIP;
10289 dgst_pos0 = 3;
10290 dgst_pos1 = 4;
10291 dgst_pos2 = 2;
10292 dgst_pos3 = 1;
10293 break;
10294
10295 case 11300: hash_type = HASH_TYPE_BITCOIN_WALLET;
10296 salt_type = SALT_TYPE_EMBEDDED;
10297 attack_exec = ATTACK_EXEC_ON_CPU;
10298 opts_type = OPTS_TYPE_PT_GENERATE_LE
10299 | OPTS_TYPE_ST_HEX
10300 | OPTS_TYPE_ST_ADD80;
10301 kern_type = KERN_TYPE_BITCOIN_WALLET;
10302 dgst_size = DGST_SIZE_4_4;
10303 parse_func = bitcoin_wallet_parse_hash;
10304 sort_by_digest = sort_by_digest_4_4;
10305 opti_type = OPTI_TYPE_ZERO_BYTE;
10306 dgst_pos0 = 0;
10307 dgst_pos1 = 1;
10308 dgst_pos2 = 2;
10309 dgst_pos3 = 3;
10310 break;
10311
10312 case 11400: hash_type = HASH_TYPE_MD5;
10313 salt_type = SALT_TYPE_EMBEDDED;
10314 attack_exec = ATTACK_EXEC_ON_GPU;
10315 opts_type = OPTS_TYPE_PT_GENERATE_LE
10316 | OPTS_TYPE_PT_ADD80
10317 | OPTS_TYPE_HASH_COPY;
10318 kern_type = KERN_TYPE_SIP_AUTH;
10319 dgst_size = DGST_SIZE_4_4;
10320 parse_func = sip_auth_parse_hash;
10321 sort_by_digest = sort_by_digest_4_4;
10322 opti_type = OPTI_TYPE_ZERO_BYTE;
10323 dgst_pos0 = 0;
10324 dgst_pos1 = 3;
10325 dgst_pos2 = 2;
10326 dgst_pos3 = 1;
10327 break;
10328
10329 case 11500: hash_type = HASH_TYPE_CRC32;
10330 salt_type = SALT_TYPE_INTERN;
10331 attack_exec = ATTACK_EXEC_ON_GPU;
10332 opts_type = OPTS_TYPE_PT_GENERATE_LE
10333 | OPTS_TYPE_ST_GENERATE_LE
10334 | OPTS_TYPE_ST_HEX;
10335 kern_type = KERN_TYPE_CRC32;
10336 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10337 parse_func = crc32_parse_hash;
10338 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10339 opti_type = OPTI_TYPE_ZERO_BYTE
10340 | OPTI_TYPE_SCALAR_MODE;
10341 dgst_pos0 = 0;
10342 dgst_pos1 = 1;
10343 dgst_pos2 = 2;
10344 dgst_pos3 = 3;
10345 break;
10346
10347 case 11600: hash_type = HASH_TYPE_AES;
10348 salt_type = SALT_TYPE_EMBEDDED;
10349 attack_exec = ATTACK_EXEC_ON_CPU;
10350 opts_type = OPTS_TYPE_PT_GENERATE_LE
10351 | OPTS_TYPE_PT_NEVERCRACK;
10352 kern_type = KERN_TYPE_SEVEN_ZIP;
10353 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10354 parse_func = seven_zip_parse_hash;
10355 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10356 opti_type = OPTI_TYPE_ZERO_BYTE;
10357 dgst_pos0 = 0;
10358 dgst_pos1 = 1;
10359 dgst_pos2 = 2;
10360 dgst_pos3 = 3;
10361 break;
10362
10363 case 11700: hash_type = HASH_TYPE_GOST_2012SBOG_256;
10364 salt_type = SALT_TYPE_NONE;
10365 attack_exec = ATTACK_EXEC_ON_GPU;
10366 opts_type = OPTS_TYPE_PT_GENERATE_LE
10367 | OPTS_TYPE_PT_ADD01;
10368 kern_type = KERN_TYPE_GOST_2012SBOG_256;
10369 dgst_size = DGST_SIZE_4_8;
10370 parse_func = gost2012sbog_256_parse_hash;
10371 sort_by_digest = sort_by_digest_4_8;
10372 opti_type = OPTI_TYPE_ZERO_BYTE;
10373 dgst_pos0 = 0;
10374 dgst_pos1 = 1;
10375 dgst_pos2 = 2;
10376 dgst_pos3 = 3;
10377 break;
10378
10379 case 11800: hash_type = HASH_TYPE_GOST_2012SBOG_512;
10380 salt_type = SALT_TYPE_NONE;
10381 attack_exec = ATTACK_EXEC_ON_GPU;
10382 opts_type = OPTS_TYPE_PT_GENERATE_LE
10383 | OPTS_TYPE_PT_ADD01;
10384 kern_type = KERN_TYPE_GOST_2012SBOG_512;
10385 dgst_size = DGST_SIZE_4_16;
10386 parse_func = gost2012sbog_512_parse_hash;
10387 sort_by_digest = sort_by_digest_4_16;
10388 opti_type = OPTI_TYPE_ZERO_BYTE;
10389 dgst_pos0 = 0;
10390 dgst_pos1 = 1;
10391 dgst_pos2 = 2;
10392 dgst_pos3 = 3;
10393 break;
10394
10395 case 11900: hash_type = HASH_TYPE_PBKDF2_MD5;
10396 salt_type = SALT_TYPE_EMBEDDED;
10397 attack_exec = ATTACK_EXEC_ON_CPU;
10398 opts_type = OPTS_TYPE_PT_GENERATE_LE
10399 | OPTS_TYPE_ST_BASE64
10400 | OPTS_TYPE_HASH_COPY;
10401 kern_type = KERN_TYPE_PBKDF2_MD5;
10402 dgst_size = DGST_SIZE_4_32;
10403 parse_func = pbkdf2_md5_parse_hash;
10404 sort_by_digest = sort_by_digest_4_32;
10405 opti_type = OPTI_TYPE_ZERO_BYTE;
10406 dgst_pos0 = 0;
10407 dgst_pos1 = 1;
10408 dgst_pos2 = 2;
10409 dgst_pos3 = 3;
10410 break;
10411
10412 case 12000: hash_type = HASH_TYPE_PBKDF2_SHA1;
10413 salt_type = SALT_TYPE_EMBEDDED;
10414 attack_exec = ATTACK_EXEC_ON_CPU;
10415 opts_type = OPTS_TYPE_PT_GENERATE_LE
10416 | OPTS_TYPE_ST_BASE64
10417 | OPTS_TYPE_HASH_COPY;
10418 kern_type = KERN_TYPE_PBKDF2_SHA1;
10419 dgst_size = DGST_SIZE_4_32;
10420 parse_func = pbkdf2_sha1_parse_hash;
10421 sort_by_digest = sort_by_digest_4_32;
10422 opti_type = OPTI_TYPE_ZERO_BYTE;
10423 dgst_pos0 = 0;
10424 dgst_pos1 = 1;
10425 dgst_pos2 = 2;
10426 dgst_pos3 = 3;
10427 break;
10428
10429 case 12100: hash_type = HASH_TYPE_PBKDF2_SHA512;
10430 salt_type = SALT_TYPE_EMBEDDED;
10431 attack_exec = ATTACK_EXEC_ON_CPU;
10432 opts_type = OPTS_TYPE_PT_GENERATE_LE
10433 | OPTS_TYPE_ST_BASE64
10434 | OPTS_TYPE_HASH_COPY;
10435 kern_type = KERN_TYPE_PBKDF2_SHA512;
10436 dgst_size = DGST_SIZE_8_16;
10437 parse_func = pbkdf2_sha512_parse_hash;
10438 sort_by_digest = sort_by_digest_8_16;
10439 opti_type = OPTI_TYPE_ZERO_BYTE;
10440 dgst_pos0 = 0;
10441 dgst_pos1 = 1;
10442 dgst_pos2 = 2;
10443 dgst_pos3 = 3;
10444 break;
10445
10446 case 12200: hash_type = HASH_TYPE_ECRYPTFS;
10447 salt_type = SALT_TYPE_EMBEDDED;
10448 attack_exec = ATTACK_EXEC_ON_CPU;
10449 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10450 kern_type = KERN_TYPE_ECRYPTFS;
10451 dgst_size = DGST_SIZE_8_8;
10452 parse_func = ecryptfs_parse_hash;
10453 sort_by_digest = sort_by_digest_8_8;
10454 opti_type = OPTI_TYPE_ZERO_BYTE;
10455 dgst_pos0 = 0;
10456 dgst_pos1 = 1;
10457 dgst_pos2 = 2;
10458 dgst_pos3 = 3;
10459 break;
10460
10461 case 12300: hash_type = HASH_TYPE_ORACLET;
10462 salt_type = SALT_TYPE_EMBEDDED;
10463 attack_exec = ATTACK_EXEC_ON_CPU;
10464 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10465 kern_type = KERN_TYPE_ORACLET;
10466 dgst_size = DGST_SIZE_8_16;
10467 parse_func = oraclet_parse_hash;
10468 sort_by_digest = sort_by_digest_8_16;
10469 opti_type = OPTI_TYPE_ZERO_BYTE;
10470 dgst_pos0 = 0;
10471 dgst_pos1 = 1;
10472 dgst_pos2 = 2;
10473 dgst_pos3 = 3;
10474 break;
10475
10476 case 12400: hash_type = HASH_TYPE_BSDICRYPT;
10477 salt_type = SALT_TYPE_EMBEDDED;
10478 attack_exec = ATTACK_EXEC_ON_CPU;
10479 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10480 kern_type = KERN_TYPE_BSDICRYPT;
10481 dgst_size = DGST_SIZE_4_4;
10482 parse_func = bsdicrypt_parse_hash;
10483 sort_by_digest = sort_by_digest_4_4;
10484 opti_type = OPTI_TYPE_ZERO_BYTE
10485 | OPTI_TYPE_PRECOMPUTE_PERMUT;
10486 dgst_pos0 = 0;
10487 dgst_pos1 = 1;
10488 dgst_pos2 = 2;
10489 dgst_pos3 = 3;
10490 break;
10491
10492 case 12500: hash_type = HASH_TYPE_RAR3HP;
10493 salt_type = SALT_TYPE_EMBEDDED;
10494 attack_exec = ATTACK_EXEC_ON_CPU;
10495 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10496 kern_type = KERN_TYPE_RAR3;
10497 dgst_size = DGST_SIZE_4_4;
10498 parse_func = rar3hp_parse_hash;
10499 sort_by_digest = sort_by_digest_4_4;
10500 opti_type = OPTI_TYPE_ZERO_BYTE;
10501 dgst_pos0 = 0;
10502 dgst_pos1 = 1;
10503 dgst_pos2 = 2;
10504 dgst_pos3 = 3;
10505 break;
10506
10507 case 12600: hash_type = HASH_TYPE_SHA256;
10508 salt_type = SALT_TYPE_INTERN;
10509 attack_exec = ATTACK_EXEC_ON_GPU;
10510 opts_type = OPTS_TYPE_PT_GENERATE_BE
10511 | OPTS_TYPE_PT_ADD80;
10512 kern_type = KERN_TYPE_CF10;
10513 dgst_size = DGST_SIZE_4_8;
10514 parse_func = cf10_parse_hash;
10515 sort_by_digest = sort_by_digest_4_8;
10516 opti_type = OPTI_TYPE_ZERO_BYTE
10517 | OPTI_TYPE_PRECOMPUTE_INIT
10518 | OPTI_TYPE_EARLY_SKIP
10519 | OPTI_TYPE_NOT_ITERATED;
10520 dgst_pos0 = 3;
10521 dgst_pos1 = 7;
10522 dgst_pos2 = 2;
10523 dgst_pos3 = 6;
10524 break;
10525
10526 case 12700: hash_type = HASH_TYPE_AES;
10527 salt_type = SALT_TYPE_EMBEDDED;
10528 attack_exec = ATTACK_EXEC_ON_CPU;
10529 opts_type = OPTS_TYPE_PT_GENERATE_LE
10530 | OPTS_TYPE_HASH_COPY;
10531 kern_type = KERN_TYPE_MYWALLET;
10532 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
10533 parse_func = mywallet_parse_hash;
10534 sort_by_digest = sort_by_digest_4_5;
10535 opti_type = OPTI_TYPE_ZERO_BYTE;
10536 dgst_pos0 = 0;
10537 dgst_pos1 = 1;
10538 dgst_pos2 = 2;
10539 dgst_pos3 = 3;
10540 break;
10541
10542 case 12800: hash_type = HASH_TYPE_PBKDF2_SHA256;
10543 salt_type = SALT_TYPE_EMBEDDED;
10544 attack_exec = ATTACK_EXEC_ON_CPU;
10545 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10546 kern_type = KERN_TYPE_MS_DRSR;
10547 dgst_size = DGST_SIZE_4_8;
10548 parse_func = ms_drsr_parse_hash;
10549 sort_by_digest = sort_by_digest_4_8;
10550 opti_type = OPTI_TYPE_ZERO_BYTE;
10551 dgst_pos0 = 0;
10552 dgst_pos1 = 1;
10553 dgst_pos2 = 2;
10554 dgst_pos3 = 3;
10555 break;
10556
10557 default: usage_mini_print (PROGNAME); return (-1);
10558 }
10559
10560 /**
10561 * transpose
10562 */
10563
10564 data.parse_func = parse_func;
10565
10566 /**
10567 * misc stuff
10568 */
10569
10570 if (hex_salt)
10571 {
10572 if (salt_type == SALT_TYPE_INTERN)
10573 {
10574 opts_type |= OPTS_TYPE_ST_HEX;
10575 }
10576 else
10577 {
10578 log_error ("ERROR: Parameter hex-salt not valid for hash-type %u", hash_mode);
10579
10580 return (-1);
10581 }
10582 }
10583
10584 uint isSalted = ((salt_type == SALT_TYPE_INTERN)
10585 | (salt_type == SALT_TYPE_EXTERN)
10586 | (salt_type == SALT_TYPE_EMBEDDED)
10587 | (salt_type == SALT_TYPE_VIRTUAL));
10588
10589 sort_by_digest = sort_by_digest_p0p1; // overruled by 64 bit digest
10590
10591 data.hash_type = hash_type;
10592 data.attack_mode = attack_mode;
10593 data.attack_kern = attack_kern;
10594 data.attack_exec = attack_exec;
10595 data.kern_type = kern_type;
10596 data.opts_type = opts_type;
10597 data.dgst_size = dgst_size;
10598 data.salt_type = salt_type;
10599 data.isSalted = isSalted;
10600 data.sort_by_digest = sort_by_digest;
10601 data.dgst_pos0 = dgst_pos0;
10602 data.dgst_pos1 = dgst_pos1;
10603 data.dgst_pos2 = dgst_pos2;
10604 data.dgst_pos3 = dgst_pos3;
10605
10606 esalt_size = 0;
10607
10608 switch (hash_mode)
10609 {
10610 case 2500: esalt_size = sizeof (wpa_t); break;
10611 case 5300: esalt_size = sizeof (ikepsk_t); break;
10612 case 5400: esalt_size = sizeof (ikepsk_t); break;
10613 case 5500: esalt_size = sizeof (netntlm_t); break;
10614 case 5600: esalt_size = sizeof (netntlm_t); break;
10615 case 6211:
10616 case 6212:
10617 case 6213:
10618 case 6221:
10619 case 6222:
10620 case 6223:
10621 case 6231:
10622 case 6232:
10623 case 6233:
10624 case 6241:
10625 case 6242:
10626 case 6243: esalt_size = sizeof (tc_t); break;
10627 case 6600: esalt_size = sizeof (agilekey_t); break;
10628 case 7100: esalt_size = sizeof (pbkdf2_sha512_t); break;
10629 case 7200: esalt_size = sizeof (pbkdf2_sha512_t); break;
10630 case 7300: esalt_size = sizeof (rakp_t); break;
10631 case 7500: esalt_size = sizeof (krb5pa_t); break;
10632 case 8200: esalt_size = sizeof (cloudkey_t); break;
10633 case 8800: esalt_size = sizeof (androidfde_t); break;
10634 case 9200: esalt_size = sizeof (pbkdf2_sha256_t); break;
10635 case 9400: esalt_size = sizeof (office2007_t); break;
10636 case 9500: esalt_size = sizeof (office2010_t); break;
10637 case 9600: esalt_size = sizeof (office2013_t); break;
10638 case 9700: esalt_size = sizeof (oldoffice01_t); break;
10639 case 9710: esalt_size = sizeof (oldoffice01_t); break;
10640 case 9720: esalt_size = sizeof (oldoffice01_t); break;
10641 case 9800: esalt_size = sizeof (oldoffice34_t); break;
10642 case 9810: esalt_size = sizeof (oldoffice34_t); break;
10643 case 9820: esalt_size = sizeof (oldoffice34_t); break;
10644 case 10000: esalt_size = sizeof (pbkdf2_sha256_t); break;
10645 case 10200: esalt_size = sizeof (cram_md5_t); break;
10646 case 10400: esalt_size = sizeof (pdf_t); break;
10647 case 10410: esalt_size = sizeof (pdf_t); break;
10648 case 10420: esalt_size = sizeof (pdf_t); break;
10649 case 10500: esalt_size = sizeof (pdf_t); break;
10650 case 10600: esalt_size = sizeof (pdf_t); break;
10651 case 10700: esalt_size = sizeof (pdf_t); break;
10652 case 10900: esalt_size = sizeof (pbkdf2_sha256_t); break;
10653 case 11300: esalt_size = sizeof (bitcoin_wallet_t); break;
10654 case 11400: esalt_size = sizeof (sip_t); break;
10655 case 11600: esalt_size = sizeof (seven_zip_t); break;
10656 case 11900: esalt_size = sizeof (pbkdf2_md5_t); break;
10657 case 12000: esalt_size = sizeof (pbkdf2_sha1_t); break;
10658 case 12100: esalt_size = sizeof (pbkdf2_sha512_t); break;
10659 }
10660
10661 data.esalt_size = esalt_size;
10662
10663 /**
10664 * choose dictionary parser
10665 */
10666
10667 if (hash_type == HASH_TYPE_LM)
10668 {
10669 get_next_word_func = get_next_word_lm;
10670 }
10671 else if (opts_type & OPTS_TYPE_PT_UPPER)
10672 {
10673 get_next_word_func = get_next_word_uc;
10674 }
10675 else
10676 {
10677 get_next_word_func = get_next_word_std;
10678 }
10679
10680 /**
10681 * dictstat
10682 */
10683
10684 dictstat_t *dictstat_base = (dictstat_t *) mycalloc (MAX_DICTSTAT, sizeof (dictstat_t));
10685
10686 #ifdef _POSIX
10687 size_t dictstat_nmemb = 0;
10688 #endif
10689
10690 #ifdef _WIN
10691 uint dictstat_nmemb = 0;
10692 #endif
10693
10694 char dictstat[256];
10695
10696 FILE *dictstat_fp = NULL;
10697
10698 if (keyspace == 0)
10699 {
10700 memset (dictstat, 0, sizeof (dictstat));
10701
10702 snprintf (dictstat, sizeof (dictstat) - 1, "%s/%s.dictstat", install_dir, PROGNAME);
10703
10704 dictstat_fp = fopen (dictstat, "rb");
10705
10706 if (dictstat_fp)
10707 {
10708 #ifdef _POSIX
10709 struct stat tmpstat;
10710
10711 fstat (fileno (dictstat_fp), &tmpstat);
10712 #endif
10713
10714 #ifdef _WIN
10715 struct stat64 tmpstat;
10716
10717 _fstat64 (fileno (dictstat_fp), &tmpstat);
10718 #endif
10719
10720 if (tmpstat.st_mtime < COMPTIME)
10721 {
10722 /* with v0.15 the format changed so we have to ensure user is using a good version
10723 since there is no version-header in the dictstat file */
10724
10725 fclose (dictstat_fp);
10726
10727 unlink (dictstat);
10728 }
10729 else
10730 {
10731 while (!feof (dictstat_fp))
10732 {
10733 dictstat_t d;
10734
10735 if (fread (&d, sizeof (dictstat_t), 1, dictstat_fp) == 0) continue;
10736
10737 lsearch (&d, dictstat_base, &dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
10738
10739 if (dictstat_nmemb == (MAX_DICTSTAT - 1000))
10740 {
10741 log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat);
10742
10743 return -1;
10744 }
10745 }
10746
10747 fclose (dictstat_fp);
10748 }
10749 }
10750 }
10751
10752 /**
10753 * potfile
10754 */
10755
10756 char potfile[256];
10757
10758 memset (potfile, 0, sizeof (potfile));
10759
10760 snprintf (potfile, sizeof (potfile) - 1, "%s.pot", session);
10761
10762 data.pot_fp = NULL;
10763
10764 FILE *out_fp = NULL;
10765 FILE *pot_fp = NULL;
10766
10767 if (show == 1 || left == 1)
10768 {
10769 pot_fp = fopen (potfile, "rb");
10770
10771 if (pot_fp == NULL)
10772 {
10773 log_error ("ERROR: %s: %s", potfile, strerror (errno));
10774
10775 return (-1);
10776 }
10777
10778 if (outfile != NULL)
10779 {
10780 if ((out_fp = fopen (outfile, "ab")) == NULL)
10781 {
10782 log_error ("ERROR: %s: %s", outfile, strerror (errno));
10783
10784 fclose (pot_fp);
10785
10786 return (-1);
10787 }
10788 }
10789 else
10790 {
10791 out_fp = stdout;
10792 }
10793 }
10794 else
10795 {
10796 if (potfile_disable == 0)
10797 {
10798 pot_fp = fopen (potfile, "ab");
10799
10800 if (pot_fp == NULL)
10801 {
10802 log_error ("ERROR: %s: %s", potfile, strerror (errno));
10803
10804 return (-1);
10805 }
10806
10807 data.pot_fp = pot_fp;
10808 }
10809 }
10810
10811 pot_t *pot = NULL;
10812
10813 uint pot_cnt = 0;
10814 uint pot_avail = 0;
10815
10816 if (show == 1 || left == 1)
10817 {
10818 SUPPRESS_OUTPUT = 1;
10819
10820 pot_avail = count_lines (pot_fp);
10821
10822 rewind (pot_fp);
10823
10824 pot = (pot_t *) mycalloc (pot_avail, sizeof (pot_t));
10825
10826 uint pot_hashes_avail = 0;
10827
10828 uint line_num = 0;
10829
10830 while (!feof (pot_fp))
10831 {
10832 line_num++;
10833
10834 char line_buf[BUFSIZ];
10835
10836 int line_len = fgetl (pot_fp, line_buf);
10837
10838 if (line_len == 0) continue;
10839
10840 char *plain_buf = line_buf + line_len;
10841
10842 pot_t *pot_ptr = &pot[pot_cnt];
10843
10844 hash_t *hashes_buf = &pot_ptr->hash;
10845
10846 // we do not initialize all hashes_buf->digest etc at the beginning, since many lines may not be
10847 // valid lines of this specific hash type (otherwise it would be more waste of memory than gain)
10848
10849 if (pot_cnt == pot_hashes_avail)
10850 {
10851 uint pos = 0;
10852
10853 for (pos = 0; pos < INCR_POT; pos++)
10854 {
10855 if ((pot_cnt + pos) >= pot_avail) break;
10856
10857 pot_t *tmp_pot = &pot[pot_cnt + pos];
10858
10859 hash_t *tmp_hash = &tmp_pot->hash;
10860
10861 tmp_hash->digest = mymalloc (dgst_size);
10862
10863 if (isSalted)
10864 {
10865 tmp_hash->salt = (salt_t *) mymalloc (sizeof (salt_t));
10866 }
10867
10868 if (esalt_size)
10869 {
10870 tmp_hash->esalt = mymalloc (esalt_size);
10871 }
10872
10873 pot_hashes_avail++;
10874 }
10875 }
10876
10877 int plain_len = 0;
10878
10879 int parser_status;
10880
10881 int iter = MAX_CUT_TRIES;
10882
10883 do
10884 {
10885 for (int i = line_len - 1; i; i--, plain_len++, plain_buf--, line_len--)
10886 {
10887 if (line_buf[i] == ':')
10888 {
10889 line_len--;
10890
10891 break;
10892 }
10893 }
10894
10895 if (data.hash_mode != 2500)
10896 {
10897 parser_status = parse_func (line_buf, line_len, hashes_buf);
10898 }
10899 else
10900 {
10901 int max_salt_size = sizeof (hashes_buf->salt->salt_buf);
10902
10903 if (line_len > max_salt_size)
10904 {
10905 parser_status = PARSER_GLOBAL_LENGTH;
10906 }
10907 else
10908 {
10909 memset (&hashes_buf->salt->salt_buf, 0, max_salt_size);
10910
10911 memcpy (&hashes_buf->salt->salt_buf, line_buf, line_len);
10912
10913 hashes_buf->salt->salt_len = line_len;
10914
10915 parser_status = PARSER_OK;
10916 }
10917 }
10918
10919 // if NOT parsed without error, we add the ":" to the plain
10920
10921 if (parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH)
10922 {
10923 plain_len++;
10924 plain_buf--;
10925 }
10926
10927 } while ((parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH) && --iter);
10928
10929 if (parser_status < PARSER_GLOBAL_ZERO)
10930 {
10931 // log_info ("WARNING: Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status));
10932
10933 continue;
10934 }
10935
10936 memcpy (pot_ptr->plain_buf, plain_buf, plain_len);
10937
10938 pot_ptr->plain_len = plain_len;
10939
10940 pot_cnt++;
10941 }
10942
10943 fclose (pot_fp);
10944
10945 SUPPRESS_OUTPUT = 0;
10946
10947 qsort (pot, pot_cnt, sizeof (pot_t), sort_by_pot);
10948 }
10949
10950 /**
10951 * gpu accel and loops auto adjustment
10952 */
10953
10954 if (gpu_accel_chgd == 0) gpu_accel = set_gpu_accel (hash_mode);
10955 if (gpu_loops_chgd == 0) gpu_loops = set_gpu_loops (hash_mode);
10956
10957 if (workload_profile == 1)
10958 {
10959 gpu_loops /= 8;
10960 gpu_accel /= 4;
10961
10962 if (gpu_loops == 0) gpu_loops = 8;
10963 if (gpu_accel == 0) gpu_accel = 2;
10964 }
10965 else if (workload_profile == 3)
10966 {
10967 gpu_loops *= 8;
10968 gpu_accel *= 4;
10969
10970 if (gpu_loops > 1024) gpu_loops = 1024;
10971 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
10972 }
10973
10974 // those hashes *must* run at a specific gpu_loops count because of some optimization inside the kernel
10975
10976 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
10977 {
10978 gpu_loops = 1024;
10979 }
10980
10981 if (hash_mode == 12500)
10982 {
10983 gpu_loops = ROUNDS_RAR3 / 16;
10984 }
10985
10986 data.gpu_accel = gpu_accel;
10987 data.gpu_loops = gpu_loops;
10988
10989 /**
10990 * word len
10991 */
10992
10993 uint pw_min = PW_MIN;
10994 uint pw_max = PW_MAX;
10995
10996 switch (hash_mode)
10997 {
10998 case 400: if (pw_max > 40) pw_max = 40;
10999 break;
11000 case 500: if (pw_max > 16) pw_max = 16;
11001 break;
11002 case 1500: if (pw_max > 8) pw_max = 8;
11003 break;
11004 case 1600: if (pw_max > 16) pw_max = 16;
11005 break;
11006 case 1800: if (pw_max > 16) pw_max = 16;
11007 break;
11008 case 2100: if (pw_max > 16) pw_max = 16;
11009 break;
11010 case 2500: if (pw_min < 8) pw_min = 8;
11011 break;
11012 case 3000: if (pw_max > 7) pw_max = 7;
11013 break;
11014 case 5200: if (pw_max > 24) pw_max = 24;
11015 break;
11016 case 5800: if (pw_max > 16) pw_max = 16;
11017 break;
11018 case 6300: if (pw_max > 16) pw_max = 16;
11019 break;
11020 case 7400: if (pw_max > 16) pw_max = 16;
11021 break;
11022 case 7900: if (pw_max > 48) pw_max = 48;
11023 break;
11024 case 8500: if (pw_max > 8) pw_max = 8;
11025 break;
11026 case 8600: if (pw_max > 16) pw_max = 16;
11027 break;
11028 case 9710: pw_min = 5;
11029 pw_max = 5;
11030 break;
11031 case 9810: pw_min = 5;
11032 pw_max = 5;
11033 break;
11034 case 10410: pw_min = 5;
11035 pw_max = 5;
11036 break;
11037 case 10300: if (pw_max < 3) pw_min = 3;
11038 if (pw_max > 40) pw_max = 40;
11039 break;
11040 case 10500: if (pw_max < 3) pw_min = 3;
11041 if (pw_max > 40) pw_max = 40;
11042 break;
11043 case 10700: if (pw_max > 16) pw_max = 16;
11044 break;
11045 case 11300: if (pw_max > 40) pw_max = 40;
11046 break;
11047 case 12500: if (pw_max > 20) pw_max = 20;
11048 break;
11049 case 12800: if (pw_max > 24) pw_max = 24;
11050 break;
11051 }
11052
11053 if (attack_exec == ATTACK_EXEC_ON_GPU)
11054 {
11055 switch (attack_kern)
11056 {
11057 case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
11058 break;
11059 case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
11060 break;
11061 }
11062 }
11063
11064 /**
11065 * charsets : keep them together for more easy maintainnce
11066 */
11067
11068 cs_t mp_sys[6];
11069 cs_t mp_usr[4];
11070
11071 memset (mp_sys, 0, sizeof (mp_sys));
11072 memset (mp_usr, 0, sizeof (mp_usr));
11073
11074 mp_setup_sys (mp_sys);
11075
11076 if (custom_charset_1) mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
11077 if (custom_charset_2) mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
11078 if (custom_charset_3) mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
11079 if (custom_charset_4) mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
11080
11081 /**
11082 * load hashes, part I: find input mode, count hashes
11083 */
11084
11085 uint hashlist_mode = 0;
11086 uint hashlist_format = HLFMT_HASHCAT;
11087
11088 uint hashes_avail = 0;
11089
11090 if (benchmark == 0)
11091 {
11092 struct stat f;
11093
11094 hashlist_mode = (stat (myargv[optind], &f) == 0) ? HL_MODE_FILE : HL_MODE_ARG;
11095
11096 if ((hash_mode == 2500) ||
11097 (hash_mode == 5200) ||
11098 ((hash_mode >= 6200) && (hash_mode <= 6299)) ||
11099 (hash_mode == 9000))
11100 {
11101 hashlist_mode = HL_MODE_ARG;
11102
11103 char *hashfile = myargv[optind];
11104
11105 data.hashfile = hashfile;
11106
11107 logfile_top_var_string ("target", hashfile);
11108 }
11109
11110 if (hashlist_mode == HL_MODE_ARG)
11111 {
11112 if (hash_mode == 2500)
11113 {
11114 struct stat st;
11115
11116 if (stat (data.hashfile, &st) == -1)
11117 {
11118 log_error ("ERROR: %s: %s", data.hashfile, strerror (errno));
11119
11120 return (-1);
11121 }
11122
11123 hashes_avail = st.st_size / sizeof (hccap_t);
11124 }
11125 else
11126 {
11127 hashes_avail = 1;
11128 }
11129 }
11130 else if (hashlist_mode == HL_MODE_FILE)
11131 {
11132 char *hashfile = myargv[optind];
11133
11134 data.hashfile = hashfile;
11135
11136 logfile_top_var_string ("target", hashfile);
11137
11138 FILE *fp = NULL;
11139
11140 if ((fp = fopen (hashfile, "rb")) == NULL)
11141 {
11142 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
11143
11144 return (-1);
11145 }
11146
11147 if (data.quiet == 0) log_info_nn ("Counting lines in %s", hashfile);
11148
11149 hashes_avail = count_lines (fp);
11150
11151 rewind (fp);
11152
11153 if (hashes_avail == 0)
11154 {
11155 log_error ("ERROR: hashfile is empty or corrupt");
11156
11157 fclose (fp);
11158
11159 return (-1);
11160 }
11161
11162 hashlist_format = hlfmt_detect (fp, 100); // 100 = max numbers to "scan". could be hashes_avail, too
11163
11164 if ((remove == 1) && (hashlist_format != HLFMT_HASHCAT))
11165 {
11166 log_error ("ERROR: remove not supported in native hashfile-format mode");
11167
11168 fclose (fp);
11169
11170 return (-1);
11171 }
11172
11173 fclose (fp);
11174 }
11175 }
11176 else
11177 {
11178 hashlist_mode = HL_MODE_ARG;
11179
11180 hashes_avail = 1;
11181 }
11182
11183 if (hash_mode == 3000) hashes_avail *= 2;
11184
11185 data.hashlist_mode = hashlist_mode;
11186 data.hashlist_format = hashlist_format;
11187
11188 logfile_top_uint (hashlist_mode);
11189 logfile_top_uint (hashlist_format);
11190
11191 /**
11192 * load hashes, part II: allocate required memory, set pointers
11193 */
11194
11195 hash_t *hashes_buf = NULL;
11196 void *digests_buf = NULL;
11197 salt_t *salts_buf = NULL;
11198 void *esalts_buf = NULL;
11199
11200 hashes_buf = (hash_t *) mycalloc (hashes_avail, sizeof (hash_t));
11201
11202 digests_buf = (void *) mycalloc (hashes_avail, dgst_size);
11203
11204 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11205 {
11206 uint32_t hash_pos;
11207
11208 for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
11209 {
11210 hashinfo_t *hash_info = (hashinfo_t *) mymalloc (sizeof (hashinfo_t));
11211
11212 hashes_buf[hash_pos].hash_info = hash_info;
11213
11214 if (username && (remove || show || left))
11215 {
11216 hash_info->user = (user_t*) mymalloc (sizeof (user_t));
11217 }
11218
11219 if (benchmark)
11220 {
11221 hash_info->orighash = (char *) mymalloc (256);
11222 }
11223 }
11224 }
11225
11226 if (isSalted)
11227 {
11228 salts_buf = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
11229
11230 if (esalt_size)
11231 {
11232 esalts_buf = (void *) mycalloc (hashes_avail, esalt_size);
11233 }
11234 }
11235 else
11236 {
11237 salts_buf = (salt_t *) mycalloc (1, sizeof (salt_t));
11238 }
11239
11240 for (uint hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
11241 {
11242 hashes_buf[hash_pos].digest = ((char *) digests_buf) + (hash_pos * dgst_size);
11243
11244 if (isSalted)
11245 {
11246 hashes_buf[hash_pos].salt = &salts_buf[hash_pos];
11247
11248 if (esalt_size)
11249 {
11250 hashes_buf[hash_pos].esalt = ((char *) esalts_buf) + (hash_pos * esalt_size);
11251 }
11252 }
11253 else
11254 {
11255 hashes_buf[hash_pos].salt = &salts_buf[0];
11256 }
11257 }
11258
11259 /**
11260 * load hashes, part III: parse hashes or generate them if benchmark
11261 */
11262
11263 uint hashes_cnt = 0;
11264
11265 if (benchmark == 0)
11266 {
11267 if (keyspace == 1)
11268 {
11269 // useless to read hash file for keyspace, cheat a little bit w/ optind
11270 }
11271 else if (hashes_avail == 0)
11272 {
11273 }
11274 else if (hashlist_mode == HL_MODE_ARG)
11275 {
11276 char *input_buf = myargv[optind];
11277
11278 uint input_len = strlen (input_buf);
11279
11280 logfile_top_var_string ("target", input_buf);
11281
11282 char *hash_buf = NULL;
11283 int hash_len = 0;
11284
11285 hlfmt_hash (hashlist_format, input_buf, input_len, &hash_buf, &hash_len);
11286
11287 if (hash_len)
11288 {
11289 if (opts_type & OPTS_TYPE_HASH_COPY)
11290 {
11291 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
11292
11293 hash_info_tmp->orighash = mystrdup (hash_buf);
11294 }
11295
11296 if (isSalted)
11297 {
11298 memset (hashes_buf[0].salt, 0, sizeof (salt_t));
11299 }
11300
11301 int parser_status = PARSER_OK;
11302
11303 if (hash_mode == 2500)
11304 {
11305 if (hash_len == 0)
11306 {
11307 log_error ("ERROR: hccap file not specified");
11308
11309 return (-1);
11310 }
11311
11312 hashlist_mode = HL_MODE_FILE;
11313
11314 data.hashlist_mode = hashlist_mode;
11315
11316 FILE *fp = fopen (hash_buf, "rb");
11317
11318 if (fp == NULL)
11319 {
11320 log_error ("ERROR: %s: %s", hash_buf, strerror (errno));
11321
11322 return (-1);
11323 }
11324
11325 if (hashes_avail < 1)
11326 {
11327 log_error ("ERROR: hccap file is empty or corrupt");
11328
11329 fclose (fp);
11330
11331 return (-1);
11332 }
11333
11334 uint hccap_size = sizeof (hccap_t);
11335
11336 char in[hccap_size];
11337
11338 while (!feof (fp))
11339 {
11340 int n = fread (&in, hccap_size, 1, fp);
11341
11342 if (n != 1)
11343 {
11344 if (hashes_cnt < 1) parser_status = PARSER_HCCAP_FILE_SIZE;
11345
11346 break;
11347 }
11348
11349 parser_status = parse_func (in, hccap_size, &hashes_buf[hashes_cnt]);
11350
11351 if (parser_status != PARSER_OK)
11352 {
11353 log_info ("WARNING: Hash '%s': %s", hash_buf, strparser (parser_status));
11354
11355 continue;
11356 }
11357
11358 // hack: append MAC1 and MAC2 s.t. in --show and --left the line matches with the .pot file format (i.e. ESSID:MAC1:MAC2)
11359
11360 if ((show == 1) || (left == 1))
11361 {
11362 salt_t *tmp_salt = hashes_buf[hashes_cnt].salt;
11363
11364 char *salt_ptr = (char *) tmp_salt->salt_buf;
11365
11366 int cur_pos = tmp_salt->salt_len;
11367 int rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
11368
11369 wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt;
11370
11371 unsigned char *pke_ptr = (unsigned char *) wpa->pke;
11372
11373 // do the appending task
11374
11375 snprintf (salt_ptr + cur_pos,
11376 rem_len,
11377 ":%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
11378 pke_ptr[20], pke_ptr[27], pke_ptr[26], pke_ptr[25], pke_ptr[24], pke_ptr[31], // MAC1
11379 pke_ptr[30], pke_ptr[29], pke_ptr[28], pke_ptr[35], pke_ptr[34], pke_ptr[33]); // MAC2
11380
11381
11382 // memset () the remaining part of the salt
11383
11384 cur_pos = tmp_salt->salt_len + 1 + 12 + 1 + 12;
11385 rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
11386
11387 if (rem_len > 0) memset (salt_ptr + cur_pos, 0, rem_len);
11388
11389 tmp_salt->salt_len += 1 + 12 + 1 + 12;
11390 }
11391
11392 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);
11393 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);
11394
11395 hashes_cnt++;
11396 }
11397
11398 fclose (fp);
11399 }
11400 else if (hash_mode == 3000)
11401 {
11402 if (hash_len == 32)
11403 {
11404 parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
11405
11406 hash_t *lm_hash_left = NULL;
11407
11408 if (parser_status == PARSER_OK)
11409 {
11410 lm_hash_left = &hashes_buf[hashes_cnt];
11411
11412 hashes_cnt++;
11413 }
11414 else
11415 {
11416 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11417 }
11418
11419
11420 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
11421
11422 hash_t *lm_hash_right = NULL;
11423
11424 if (parser_status == PARSER_OK)
11425 {
11426 lm_hash_right = &hashes_buf[hashes_cnt];
11427
11428 hashes_cnt++;
11429 }
11430 else
11431 {
11432 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11433 }
11434
11435 // show / left
11436
11437 if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
11438 {
11439 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);
11440 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);
11441 }
11442 }
11443 else
11444 {
11445 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11446
11447 if (parser_status == PARSER_OK)
11448 {
11449 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11450 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11451 }
11452
11453 if (parser_status == PARSER_OK)
11454 {
11455 hashes_cnt++;
11456 }
11457 else
11458 {
11459 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11460 }
11461 }
11462 }
11463 else
11464 {
11465 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11466
11467 if (parser_status == PARSER_OK)
11468 {
11469 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11470 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11471 }
11472
11473 if (parser_status == PARSER_OK)
11474 {
11475 hashes_cnt++;
11476 }
11477 else
11478 {
11479 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11480 }
11481 }
11482 }
11483 }
11484 else if (hashlist_mode == HL_MODE_FILE)
11485 {
11486 char *hashfile = data.hashfile;
11487
11488 FILE *fp;
11489
11490 if ((fp = fopen (hashfile, "rb")) == NULL)
11491 {
11492 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
11493
11494 return (-1);
11495 }
11496
11497 uint line_num = 0;
11498
11499 while (!feof (fp))
11500 {
11501 line_num++;
11502
11503 char line_buf[BUFSIZ];
11504
11505 int line_len = fgetl (fp, line_buf);
11506
11507 if (line_len == 0) continue;
11508
11509 char *hash_buf = NULL;
11510 int hash_len = 0;
11511
11512 hlfmt_hash (hashlist_format, line_buf, line_len, &hash_buf, &hash_len);
11513
11514 if (username)
11515 {
11516 char *user_buf = NULL;
11517 int user_len = 0;
11518
11519 hlfmt_user (hashlist_format, line_buf, line_len, &user_buf, &user_len);
11520
11521 if (remove || show)
11522 {
11523 user_t **user = &hashes_buf[hashes_cnt].hash_info->user;
11524
11525 *user = (user_t *) malloc (sizeof (user_t));
11526
11527 user_t *user_ptr = *user;
11528
11529 if (user_buf != NULL)
11530 {
11531 user_ptr->user_name = mystrdup (user_buf);
11532 }
11533 else
11534 {
11535 user_ptr->user_name = mystrdup ("");
11536 }
11537
11538 user_ptr->user_len = user_len;
11539 }
11540 }
11541
11542 if (opts_type & OPTS_TYPE_HASH_COPY)
11543 {
11544 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
11545
11546 hash_info_tmp->orighash = mystrdup (hash_buf);
11547 }
11548
11549 if (isSalted)
11550 {
11551 memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t));
11552 }
11553
11554 if (hash_mode == 3000)
11555 {
11556 if (hash_len == 32)
11557 {
11558 int parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
11559
11560 if (parser_status < PARSER_GLOBAL_ZERO)
11561 {
11562 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11563
11564 continue;
11565 }
11566
11567 hash_t *lm_hash_left = &hashes_buf[hashes_cnt];
11568
11569 hashes_cnt++;
11570
11571 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
11572
11573 if (parser_status < PARSER_GLOBAL_ZERO)
11574 {
11575 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11576
11577 continue;
11578 }
11579
11580 hash_t *lm_hash_right = &hashes_buf[hashes_cnt];
11581
11582 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);
11583
11584 hashes_cnt++;
11585
11586 // show / left
11587
11588 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);
11589 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);
11590 }
11591 else
11592 {
11593 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11594
11595 if (parser_status < PARSER_GLOBAL_ZERO)
11596 {
11597 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11598
11599 continue;
11600 }
11601
11602 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);
11603
11604 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11605 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11606
11607 hashes_cnt++;
11608 }
11609 }
11610 else
11611 {
11612 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11613
11614 if (parser_status < PARSER_GLOBAL_ZERO)
11615 {
11616 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11617
11618 continue;
11619 }
11620
11621 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);
11622
11623 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11624 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11625
11626 hashes_cnt++;
11627 }
11628 }
11629
11630 fclose (fp);
11631
11632 if (data.quiet == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
11633
11634 if ((out_fp != NULL) && (out_fp != stdout)) fclose (out_fp);
11635 }
11636 }
11637 else
11638 {
11639 if (isSalted)
11640 {
11641 hashes_buf[0].salt->salt_len = 8;
11642
11643 // special salt handling
11644
11645 switch (hash_mode)
11646 {
11647 case 1500: hashes_buf[0].salt->salt_len = 2;
11648 break;
11649 case 1731: hashes_buf[0].salt->salt_len = 4;
11650 break;
11651 case 2410: hashes_buf[0].salt->salt_len = 4;
11652 break;
11653 case 2500: memcpy (hashes_buf[0].salt->salt_buf, "hashcat.net", 11);
11654 break;
11655 case 3100: hashes_buf[0].salt->salt_len = 1;
11656 break;
11657 case 5000: hashes_buf[0].salt->keccak_mdlen = 32;
11658 break;
11659 case 5800: hashes_buf[0].salt->salt_len = 16;
11660 break;
11661 case 6800: hashes_buf[0].salt->salt_len = 32;
11662 break;
11663 case 8400: hashes_buf[0].salt->salt_len = 40;
11664 break;
11665 case 8800: hashes_buf[0].salt->salt_len = 16;
11666 break;
11667 case 8900: hashes_buf[0].salt->salt_len = 16;
11668 hashes_buf[0].salt->scrypt_N = 1024;
11669 hashes_buf[0].salt->scrypt_r = 1;
11670 hashes_buf[0].salt->scrypt_p = 1;
11671 break;
11672 case 9100: hashes_buf[0].salt->salt_len = 16;
11673 break;
11674 case 9300: hashes_buf[0].salt->salt_len = 14;
11675 hashes_buf[0].salt->scrypt_N = 16384;
11676 hashes_buf[0].salt->scrypt_r = 1;
11677 hashes_buf[0].salt->scrypt_p = 1;
11678 break;
11679 case 9400: hashes_buf[0].salt->salt_len = 16;
11680 break;
11681 case 9500: hashes_buf[0].salt->salt_len = 16;
11682 break;
11683 case 9600: hashes_buf[0].salt->salt_len = 16;
11684 break;
11685 case 9700: hashes_buf[0].salt->salt_len = 16;
11686 break;
11687 case 9710: hashes_buf[0].salt->salt_len = 16;
11688 break;
11689 case 9720: hashes_buf[0].salt->salt_len = 16;
11690 break;
11691 case 9800: hashes_buf[0].salt->salt_len = 16;
11692 break;
11693 case 9810: hashes_buf[0].salt->salt_len = 16;
11694 break;
11695 case 9820: hashes_buf[0].salt->salt_len = 16;
11696 break;
11697 case 10300: hashes_buf[0].salt->salt_len = 12;
11698 break;
11699 case 11500: hashes_buf[0].salt->salt_len = 4;
11700 break;
11701 case 11600: hashes_buf[0].salt->salt_len = 4;
11702 break;
11703 case 12400: hashes_buf[0].salt->salt_len = 4;
11704 break;
11705 case 12500: hashes_buf[0].salt->salt_len = 8;
11706 break;
11707 case 12600: hashes_buf[0].salt->salt_len = 64;
11708 break;
11709 }
11710
11711 // special esalt handling
11712
11713 switch (hash_mode)
11714 {
11715 case 2500: ((wpa_t *) hashes_buf[0].esalt)->eapol_size = 128;
11716 break;
11717 case 5300: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
11718 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
11719 break;
11720 case 5400: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
11721 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
11722 break;
11723 case 5500: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
11724 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
11725 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
11726 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
11727 break;
11728 case 5600: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
11729 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
11730 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
11731 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
11732 break;
11733 case 7300: ((rakp_t *) hashes_buf[0].esalt)->salt_len = 32;
11734 break;
11735 case 10400: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11736 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11737 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11738 break;
11739 case 10410: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11740 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11741 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11742 break;
11743 case 10420: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11744 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11745 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11746 break;
11747 case 10500: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11748 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11749 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11750 break;
11751 case 10600: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11752 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
11753 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
11754 break;
11755 case 10700: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11756 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
11757 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
11758 break;
11759 case 11600: ((seven_zip_t *) hashes_buf[0].esalt)->iv_len = 16;
11760 ((seven_zip_t *) hashes_buf[0].esalt)->data_len = 112;
11761 ((seven_zip_t *) hashes_buf[0].esalt)->unpack_size = 112;
11762 break;
11763 }
11764 }
11765
11766 // set hashfile
11767
11768 switch (hash_mode)
11769 {
11770 case 5200: data.hashfile = mystrdup ("hashcat.psafe3");
11771 break;
11772 case 5300: data.hashfile = mystrdup ("hashcat.ikemd5");
11773 break;
11774 case 5400: data.hashfile = mystrdup ("hashcat.ikesha1");
11775 break;
11776 case 6211:
11777 case 6212:
11778 case 6213:
11779 case 6221:
11780 case 6222:
11781 case 6223:
11782 case 6231:
11783 case 6232:
11784 case 6233:
11785 case 6241:
11786 case 6242:
11787 case 6243: data.hashfile = mystrdup ("hashcat.tc");
11788 break;
11789 case 6600: data.hashfile = mystrdup ("hashcat.agilekey");
11790 break;
11791 case 8200: data.hashfile = mystrdup ("hashcat.cloudkey");
11792 break;
11793 case 9000: data.hashfile = mystrdup ("hashcat.psafe2");
11794 break;
11795 }
11796
11797 // set default iterations
11798
11799 switch (hash_mode)
11800 {
11801 case 400: hashes_buf[0].salt->salt_iter = ROUNDS_PHPASS;
11802 break;
11803 case 500: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11804 break;
11805 case 501: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11806 break;
11807 case 1600: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11808 break;
11809 case 1800: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512CRYPT;
11810 break;
11811 case 2100: hashes_buf[0].salt->salt_iter = ROUNDS_DCC2;
11812 break;
11813 case 2500: hashes_buf[0].salt->salt_iter = ROUNDS_WPA2;
11814 break;
11815 case 3200: hashes_buf[0].salt->salt_iter = ROUNDS_BCRYPT;
11816 break;
11817 case 5200: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE3;
11818 break;
11819 case 5800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDPIN - 1;
11820 break;
11821 case 6211:
11822 case 6212:
11823 case 6213: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_2K;
11824 break;
11825 case 6221:
11826 case 6222:
11827 case 6223: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11828 break;
11829 case 6231:
11830 case 6232:
11831 case 6233: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11832 break;
11833 case 6241:
11834 case 6242:
11835 case 6243: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11836 break;
11837 case 6300: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11838 break;
11839 case 6400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256AIX;
11840 break;
11841 case 6500: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512AIX;
11842 break;
11843 case 6700: hashes_buf[0].salt->salt_iter = ROUNDS_SHA1AIX;
11844 break;
11845 case 6600: hashes_buf[0].salt->salt_iter = ROUNDS_AGILEKEY;
11846 break;
11847 case 6800: hashes_buf[0].salt->salt_iter = ROUNDS_LASTPASS;
11848 break;
11849 case 7100: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512OSX;
11850 break;
11851 case 7200: hashes_buf[0].salt->salt_iter = ROUNDS_GRUB;
11852 break;
11853 case 7400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256CRYPT;
11854 break;
11855 case 7900: hashes_buf[0].salt->salt_iter = ROUNDS_DRUPAL7;
11856 break;
11857 case 8200: hashes_buf[0].salt->salt_iter = ROUNDS_CLOUDKEY;
11858 break;
11859 case 8300: hashes_buf[0].salt->salt_iter = ROUNDS_NSEC3;
11860 break;
11861 case 8800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDFDE;
11862 break;
11863 case 8900: hashes_buf[0].salt->salt_iter = 1;
11864 break;
11865 case 9000: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE2;
11866 break;
11867 case 9100: hashes_buf[0].salt->salt_iter = ROUNDS_LOTUS8;
11868 break;
11869 case 9200: hashes_buf[0].salt->salt_iter = ROUNDS_CISCO8;
11870 break;
11871 case 9300: hashes_buf[0].salt->salt_iter = 1;
11872 break;
11873 case 9400: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2007;
11874 break;
11875 case 9500: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2010;
11876 break;
11877 case 9600: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2013;
11878 break;
11879 case 10000: hashes_buf[0].salt->salt_iter = ROUNDS_DJANGOPBKDF2;
11880 break;
11881 case 10300: hashes_buf[0].salt->salt_iter = ROUNDS_SAPH_SHA1 - 1;
11882 break;
11883 case 10500: hashes_buf[0].salt->salt_iter = ROUNDS_PDF14;
11884 break;
11885 case 10700: hashes_buf[0].salt->salt_iter = ROUNDS_PDF17L8;
11886 break;
11887 case 10900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA256 - 1;
11888 break;
11889 case 11300: hashes_buf[0].salt->salt_iter = ROUNDS_BITCOIN_WALLET - 1;
11890 break;
11891 case 11600: hashes_buf[0].salt->salt_iter = ROUNDS_SEVEN_ZIP;
11892 break;
11893 case 11900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_MD5 - 1;
11894 break;
11895 case 12000: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA1 - 1;
11896 break;
11897 case 12100: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA512 - 1;
11898 break;
11899 case 12200: hashes_buf[0].salt->salt_iter = ROUNDS_ECRYPTFS - 1;
11900 break;
11901 case 12300: hashes_buf[0].salt->salt_iter = ROUNDS_ORACLET - 1;
11902 break;
11903 case 12400: hashes_buf[0].salt->salt_iter = ROUNDS_BSDICRYPT - 1;
11904 break;
11905 case 12500: hashes_buf[0].salt->salt_iter = ROUNDS_RAR3;
11906 break;
11907 case 12700: hashes_buf[0].salt->salt_iter = ROUNDS_MYWALLET;
11908 break;
11909 case 12800: hashes_buf[0].salt->salt_iter = ROUNDS_MS_DRSR - 1;
11910 break;
11911 }
11912
11913 // set special tuning for benchmark-mode 1
11914
11915 if (benchmark_mode == 1)
11916 {
11917 gpu_loops *= 8;
11918 gpu_accel *= 4;
11919
11920 switch (hash_mode)
11921 {
11922 case 400: gpu_loops = ROUNDS_PHPASS;
11923 gpu_accel = 32;
11924 break;
11925 case 500: gpu_loops = ROUNDS_MD5CRYPT;
11926 gpu_accel = 32;
11927 break;
11928 case 501: gpu_loops = ROUNDS_MD5CRYPT;
11929 gpu_accel = 32;
11930 break;
11931 case 1600: gpu_loops = ROUNDS_MD5CRYPT;
11932 gpu_accel = 32;
11933 break;
11934 case 1800: gpu_loops = ROUNDS_SHA512CRYPT;
11935 gpu_accel = 8;
11936 break;
11937 case 2100: gpu_loops = ROUNDS_DCC2;
11938 gpu_accel = 16;
11939 break;
11940 case 2500: gpu_loops = ROUNDS_WPA2;
11941 gpu_accel = 32;
11942 break;
11943 case 3200: gpu_loops = ROUNDS_BCRYPT;
11944 gpu_accel = 2;
11945 break;
11946 case 5200: gpu_loops = ROUNDS_PSAFE3;
11947 gpu_accel = 16;
11948 break;
11949 case 5800: gpu_loops = ROUNDS_ANDROIDPIN;
11950 gpu_accel = 16;
11951 break;
11952 case 6211: gpu_loops = ROUNDS_TRUECRYPT_2K;
11953 gpu_accel = 64;
11954 break;
11955 case 6212: gpu_loops = ROUNDS_TRUECRYPT_2K;
11956 gpu_accel = 32;
11957 break;
11958 case 6213: gpu_loops = ROUNDS_TRUECRYPT_2K;
11959 gpu_accel = 32;
11960 break;
11961 case 6221: gpu_loops = ROUNDS_TRUECRYPT_1K;
11962 gpu_accel = 8;
11963 break;
11964 case 6222: gpu_loops = ROUNDS_TRUECRYPT_1K;
11965 gpu_accel = 8;
11966 break;
11967 case 6223: gpu_loops = ROUNDS_TRUECRYPT_1K;
11968 gpu_accel = 8;
11969 break;
11970 case 6231: gpu_loops = ROUNDS_TRUECRYPT_1K;
11971 gpu_accel = 8;
11972 break;
11973 case 6232: gpu_loops = ROUNDS_TRUECRYPT_1K;
11974 gpu_accel = 8;
11975 break;
11976 case 6233: gpu_loops = ROUNDS_TRUECRYPT_1K;
11977 gpu_accel = 8;
11978 break;
11979 case 6241: gpu_loops = ROUNDS_TRUECRYPT_1K;
11980 gpu_accel = 128;
11981 break;
11982 case 6242: gpu_loops = ROUNDS_TRUECRYPT_1K;
11983 gpu_accel = 64;
11984 break;
11985 case 6243: gpu_loops = ROUNDS_TRUECRYPT_1K;
11986 gpu_accel = 64;
11987 break;
11988 case 6300: gpu_loops = ROUNDS_MD5CRYPT;
11989 gpu_accel = 32;
11990 break;
11991 case 6700: gpu_loops = ROUNDS_SHA1AIX;
11992 gpu_accel = 128;
11993 break;
11994 case 6400: gpu_loops = ROUNDS_SHA256AIX;
11995 gpu_accel = 128;
11996 break;
11997 case 6500: gpu_loops = ROUNDS_SHA512AIX;
11998 gpu_accel = 32;
11999 break;
12000 case 6600: gpu_loops = ROUNDS_AGILEKEY;
12001 gpu_accel = 64;
12002 break;
12003 case 6800: gpu_loops = ROUNDS_LASTPASS;
12004 gpu_accel = 64;
12005 break;
12006 case 7100: gpu_loops = ROUNDS_SHA512OSX;
12007 gpu_accel = 2;
12008 break;
12009 case 7200: gpu_loops = ROUNDS_GRUB;
12010 gpu_accel = 2;
12011 break;
12012 case 7400: gpu_loops = ROUNDS_SHA256CRYPT;
12013 gpu_accel = 4;
12014 break;
12015 case 7900: gpu_loops = ROUNDS_DRUPAL7;
12016 gpu_accel = 8;
12017 break;
12018 case 8200: gpu_loops = ROUNDS_CLOUDKEY;
12019 gpu_accel = 2;
12020 break;
12021 case 8800: gpu_loops = ROUNDS_ANDROIDFDE;
12022 gpu_accel = 32;
12023 break;
12024 case 8900: gpu_loops = 1;
12025 gpu_accel = 64;
12026 break;
12027 case 9000: gpu_loops = ROUNDS_PSAFE2;
12028 gpu_accel = 16;
12029 break;
12030 case 9100: gpu_loops = ROUNDS_LOTUS8;
12031 gpu_accel = 64;
12032 break;
12033 case 9200: gpu_loops = ROUNDS_CISCO8;
12034 gpu_accel = 8;
12035 break;
12036 case 9300: gpu_loops = 1;
12037 gpu_accel = 4;
12038 break;
12039 case 9400: gpu_loops = ROUNDS_OFFICE2007;
12040 gpu_accel = 32;
12041 break;
12042 case 9500: gpu_loops = ROUNDS_OFFICE2010;
12043 gpu_accel = 32;
12044 break;
12045 case 9600: gpu_loops = ROUNDS_OFFICE2013;
12046 gpu_accel = 4;
12047 break;
12048 case 10000: gpu_loops = ROUNDS_DJANGOPBKDF2;
12049 gpu_accel = 8;
12050 break;
12051 case 10300: gpu_loops = ROUNDS_SAPH_SHA1;
12052 gpu_accel = 16;
12053 break;
12054 case 10500: gpu_loops = ROUNDS_PDF14;
12055 gpu_accel = 256;
12056 break;
12057 case 10700: gpu_loops = ROUNDS_PDF17L8;
12058 gpu_accel = 8;
12059 break;
12060 case 10900: gpu_loops = ROUNDS_PBKDF2_SHA256;
12061 gpu_accel = 8;
12062 break;
12063 case 11300: gpu_loops = ROUNDS_BITCOIN_WALLET;
12064 gpu_accel = 2;
12065 break;
12066 case 11600: gpu_loops = ROUNDS_SEVEN_ZIP;
12067 gpu_accel = 4;
12068 break;
12069 case 11900: gpu_loops = ROUNDS_PBKDF2_MD5;
12070 gpu_accel = 8;
12071 break;
12072 case 12000: gpu_loops = ROUNDS_PBKDF2_SHA1;
12073 gpu_accel = 8;
12074 break;
12075 case 12100: gpu_loops = ROUNDS_PBKDF2_SHA512;
12076 gpu_accel = 8;
12077 break;
12078 case 12200: gpu_loops = ROUNDS_ECRYPTFS;
12079 gpu_accel = 8;
12080 break;
12081 case 12300: gpu_loops = ROUNDS_ORACLET;
12082 gpu_accel = 8;
12083 break;
12084 case 12500: gpu_loops = ROUNDS_RAR3;
12085 gpu_accel = 32;
12086 break;
12087 case 12700: gpu_loops = ROUNDS_MYWALLET;
12088 gpu_accel = 512;
12089 break;
12090 case 12800: gpu_loops = ROUNDS_MS_DRSR;
12091 gpu_accel = 512;
12092 break;
12093 }
12094
12095 // some algorithm collide too fast, make that impossible
12096
12097 switch (hash_mode)
12098 {
12099 case 11500: ((uint *) digests_buf)[1] = 1;
12100 break;
12101 }
12102
12103 if (gpu_loops > 1024) gpu_loops = 1024;
12104 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
12105 }
12106
12107 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
12108 {
12109 gpu_loops = 1024;
12110 }
12111
12112 if (hash_mode == 12500)
12113 {
12114 gpu_loops = ROUNDS_RAR3 / 16;
12115 }
12116
12117 data.gpu_accel = gpu_accel;
12118 data.gpu_loops = gpu_loops;
12119
12120 hashes_cnt = 1;
12121 }
12122
12123 if (show == 1 || left == 1)
12124 {
12125 for (uint i = 0; i < pot_cnt; i++)
12126 {
12127 pot_t *pot_ptr = &pot[i];
12128
12129 hash_t *hashes_buf = &pot_ptr->hash;
12130
12131 local_free (hashes_buf->digest);
12132
12133 if (isSalted)
12134 {
12135 local_free (hashes_buf->salt);
12136 }
12137 }
12138
12139 local_free (pot);
12140
12141 if (data.quiet == 0) log_info_nn ("");
12142
12143 return (0);
12144 }
12145
12146 if (keyspace == 0)
12147 {
12148 if (hashes_cnt == 0)
12149 {
12150 log_error ("ERROR: No hashes loaded");
12151
12152 return (-1);
12153 }
12154 }
12155
12156 /**
12157 * Sanity check for hashfile vs outfile (should not point to the same physical file)
12158 */
12159
12160 if (data.outfile != NULL)
12161 {
12162 if (data.hashfile != NULL)
12163 {
12164 #ifdef _POSIX
12165 struct stat tmpstat_outfile;
12166 struct stat tmpstat_hashfile;
12167 #endif
12168
12169 #ifdef _WIN
12170 struct stat64 tmpstat_outfile;
12171 struct stat64 tmpstat_hashfile;
12172 #endif
12173
12174 FILE *tmp_outfile_fp = fopen (data.outfile, "r");
12175
12176 if (tmp_outfile_fp)
12177 {
12178 #ifdef _POSIX
12179 fstat (fileno (tmp_outfile_fp), &tmpstat_outfile);
12180 #endif
12181
12182 #ifdef _WIN
12183 _fstat64 (fileno (tmp_outfile_fp), &tmpstat_outfile);
12184 #endif
12185
12186 fclose (tmp_outfile_fp);
12187 }
12188
12189 FILE *tmp_hashfile_fp = fopen (data.hashfile, "r");
12190
12191 if (tmp_hashfile_fp)
12192 {
12193 #ifdef _POSIX
12194 fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
12195 #endif
12196
12197 #ifdef _WIN
12198 _fstat64 (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
12199 #endif
12200
12201 fclose (tmp_hashfile_fp);
12202 }
12203
12204 if (tmp_outfile_fp && tmp_outfile_fp)
12205 {
12206 tmpstat_outfile.st_mode = 0;
12207 tmpstat_outfile.st_nlink = 0;
12208 tmpstat_outfile.st_uid = 0;
12209 tmpstat_outfile.st_gid = 0;
12210 tmpstat_outfile.st_rdev = 0;
12211 tmpstat_outfile.st_atime = 0;
12212
12213 tmpstat_hashfile.st_mode = 0;
12214 tmpstat_hashfile.st_nlink = 0;
12215 tmpstat_hashfile.st_uid = 0;
12216 tmpstat_hashfile.st_gid = 0;
12217 tmpstat_hashfile.st_rdev = 0;
12218 tmpstat_hashfile.st_atime = 0;
12219
12220 #ifdef _POSIX
12221 tmpstat_outfile.st_blksize = 0;
12222 tmpstat_outfile.st_blocks = 0;
12223
12224 tmpstat_hashfile.st_blksize = 0;
12225 tmpstat_hashfile.st_blocks = 0;
12226 #endif
12227
12228 #ifdef _POSIX
12229 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat)) == 0)
12230 {
12231 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
12232
12233 return (-1);
12234 }
12235 #endif
12236
12237 #ifdef _WIN
12238 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat64)) == 0)
12239 {
12240 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
12241
12242 return (-1);
12243 }
12244 #endif
12245 }
12246 }
12247 }
12248
12249 /**
12250 * Remove duplicates
12251 */
12252
12253 if (data.quiet == 0) log_info_nn ("Removing duplicate hashes...");
12254
12255 if (isSalted)
12256 {
12257 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
12258 }
12259 else
12260 {
12261 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
12262 }
12263
12264 uint hashes_cnt_orig = hashes_cnt;
12265
12266 hashes_cnt = 1;
12267
12268 for (uint hashes_pos = 1; hashes_pos < hashes_cnt_orig; hashes_pos++)
12269 {
12270 if (isSalted)
12271 {
12272 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) == 0)
12273 {
12274 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
12275 }
12276 }
12277 else
12278 {
12279 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
12280 }
12281
12282 if (hashes_pos > hashes_cnt)
12283 {
12284 memcpy (&hashes_buf[hashes_cnt], &hashes_buf[hashes_pos], sizeof (hash_t));
12285 }
12286
12287 hashes_cnt++;
12288 }
12289
12290 /**
12291 * Potfile removes
12292 */
12293
12294 uint potfile_remove_cracks = 0;
12295
12296 if (potfile_disable == 0)
12297 {
12298 hash_t hash_buf;
12299
12300 hash_buf.digest = mymalloc (dgst_size);
12301 hash_buf.salt = NULL;
12302 hash_buf.esalt = NULL;
12303 hash_buf.hash_info = NULL;
12304 hash_buf.cracked = 0;
12305
12306 if (isSalted)
12307 {
12308 hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
12309 }
12310
12311 if (esalt_size)
12312 {
12313 hash_buf.esalt = mymalloc (esalt_size);
12314 }
12315
12316 if (quiet == 0) log_info_nn ("Comparing hashes with potfile entries...");
12317
12318 // no solution for these special hash types (for instane because they use hashfile in output etc)
12319 if ((hash_mode != 5200) &&
12320 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
12321 (hash_mode != 9000))
12322 {
12323 FILE *fp = fopen (potfile, "rb");
12324
12325 if (fp != NULL)
12326 {
12327 while (!feof (fp))
12328 {
12329 char line_buf[BUFSIZ];
12330
12331 memset (line_buf, 0, BUFSIZ);
12332
12333 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
12334
12335 if (ptr == NULL) break;
12336
12337 int line_len = strlen (line_buf);
12338
12339 if (line_len == 0) continue;
12340
12341 int iter = MAX_CUT_TRIES;
12342
12343 for (int i = line_len - 1; i && iter; i--, line_len--)
12344 {
12345 if (line_buf[i] != ':') continue;
12346
12347 if (isSalted)
12348 {
12349 memset (hash_buf.salt, 0, sizeof (salt_t));
12350 }
12351
12352 hash_t *found = NULL;
12353
12354 if (hash_mode == 6800)
12355 {
12356 if (i < 48) // 48 = 12 * uint in salt_buf[]
12357 {
12358 // manipulate salt_buf
12359 memcpy (hash_buf.salt->salt_buf, line_buf, i);
12360
12361 hash_buf.salt->salt_len = i;
12362
12363 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt);
12364 }
12365 }
12366 else if (hash_mode == 2500)
12367 {
12368 if (i < 48) // 48 = 12 * uint in salt_buf[]
12369 {
12370 // here we have in line_buf: ESSID:MAC1:MAC2 (without the plain)
12371 // manipulate salt_buf
12372
12373 // to be safe work with a copy (because of line_len loop, i etc)
12374
12375 char line_buf_cpy[BUFSIZ];
12376 memset (line_buf_cpy, 0, BUFSIZ);
12377
12378 memset (line_buf_cpy, 0, sizeof (line_buf_cpy));
12379
12380 memcpy (line_buf_cpy, line_buf, i);
12381
12382 char *mac2_pos = strrchr (line_buf_cpy, ':');
12383
12384 if (mac2_pos == NULL) continue;
12385
12386 mac2_pos[0] = 0;
12387 mac2_pos++;
12388
12389 if (strlen (mac2_pos) != 12) continue;
12390
12391 char *mac1_pos = strrchr (line_buf_cpy, ':');
12392
12393 if (mac1_pos == NULL) continue;
12394
12395 mac1_pos[0] = 0;
12396 mac1_pos++;
12397
12398 if (strlen (mac1_pos) != 12) continue;
12399
12400 uint essid_length = mac1_pos - line_buf_cpy - 1;
12401
12402 // here we need the ESSID
12403 memcpy (hash_buf.salt->salt_buf, line_buf_cpy, essid_length);
12404
12405 hash_buf.salt->salt_len = essid_length;
12406
12407 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt_hccap);
12408
12409 if (found)
12410 {
12411 wpa_t *wpa = (wpa_t *) found->esalt;
12412
12413 uint pke[25];
12414
12415 char *pke_ptr = (char *) pke;
12416
12417 for (uint i = 0; i < 25; i++)
12418 {
12419 pke[i] = byte_swap_32 (wpa->pke[i]);
12420 }
12421
12422 unsigned char mac1[6];
12423 unsigned char mac2[6];
12424
12425 memcpy (mac1, pke_ptr + 23, 6);
12426 memcpy (mac2, pke_ptr + 29, 6);
12427
12428 // compare hex string(s) vs binary MAC address(es)
12429
12430 for (uint i = 0, j = 0; i < 6; i++, j += 2)
12431 {
12432 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
12433 {
12434 found = NULL;
12435 break;
12436 }
12437 }
12438
12439 // early skip ;)
12440 if (!found) continue;
12441
12442 for (uint i = 0, j = 0; i < 6; i++, j += 2)
12443 {
12444 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
12445 {
12446 found = NULL;
12447 break;
12448 }
12449 }
12450 }
12451 }
12452 }
12453 else
12454 {
12455 int parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
12456
12457 if (parser_status == PARSER_OK)
12458 {
12459 if (isSalted)
12460 {
12461 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
12462 }
12463 else
12464 {
12465 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
12466 }
12467 }
12468 }
12469
12470 if (found == NULL) continue;
12471
12472 if (!found->cracked) potfile_remove_cracks++;
12473
12474 found->cracked = 1;
12475
12476 if (found) break;
12477
12478 iter--;
12479 }
12480 }
12481
12482 fclose (fp);
12483 }
12484 }
12485
12486 if (esalt_size)
12487 {
12488 local_free (hash_buf.esalt);
12489 }
12490
12491 if (isSalted)
12492 {
12493 local_free (hash_buf.salt);
12494 }
12495
12496 local_free (hash_buf.digest);
12497 }
12498
12499 /**
12500 * Now generate all the buffers required for later
12501 */
12502
12503 void *digests_buf_new = (void *) mycalloc (hashes_avail, dgst_size);
12504
12505 salt_t *salts_buf_new = NULL;
12506 void *esalts_buf_new = NULL;
12507
12508 if (isSalted)
12509 {
12510 salts_buf_new = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
12511
12512 if (esalt_size)
12513 {
12514 esalts_buf_new = (void *) mycalloc (hashes_avail, esalt_size);
12515 }
12516 }
12517 else
12518 {
12519 salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t));
12520 }
12521
12522 if (data.quiet == 0) log_info_nn ("Structuring salts for cracking task...");
12523
12524 uint digests_cnt = hashes_cnt;
12525 uint digests_done = 0;
12526
12527 uint size_digests = digests_cnt * dgst_size;
12528 uint size_shown = digests_cnt * sizeof (uint);
12529
12530 uint *digests_shown = (uint *) mymalloc (size_shown);
12531 uint *digests_shown_tmp = (uint *) mymalloc (size_shown);
12532
12533 uint salts_cnt = 0;
12534 uint salts_done = 0;
12535
12536 hashinfo_t **hash_info = NULL;
12537
12538 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12539 {
12540 hash_info = (hashinfo_t**) mymalloc (hashes_cnt * sizeof (hashinfo_t *));
12541
12542 if (username && (remove || show))
12543 {
12544 uint user_pos;
12545
12546 for (user_pos = 0; user_pos < hashes_cnt; user_pos++)
12547 {
12548 hash_info[user_pos] = (hashinfo_t*) mycalloc (hashes_cnt, sizeof (hashinfo_t));
12549
12550 hash_info[user_pos]->user = (user_t*) mymalloc (sizeof (user_t));
12551 }
12552 }
12553 }
12554
12555 uint *salts_shown = (uint *) mymalloc (size_shown);
12556
12557 salt_t *salt_buf;
12558
12559 {
12560 // copied from inner loop
12561
12562 salt_buf = &salts_buf_new[salts_cnt];
12563
12564 memcpy (salt_buf, hashes_buf[0].salt, sizeof (salt_t));
12565
12566 if (esalt_size)
12567 {
12568 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[0].esalt, esalt_size);
12569 }
12570
12571 salt_buf->digests_cnt = 0;
12572 salt_buf->digests_done = 0;
12573 salt_buf->digests_offset = 0;
12574
12575 salts_cnt++;
12576 }
12577
12578 if (hashes_buf[0].cracked == 1)
12579 {
12580 digests_shown[0] = 1;
12581
12582 digests_done++;
12583
12584 salt_buf->digests_done++;
12585 }
12586
12587 salt_buf->digests_cnt++;
12588
12589 memcpy (((char *) digests_buf_new) + (0 * dgst_size), hashes_buf[0].digest, dgst_size);
12590
12591 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12592 {
12593 hash_info[0] = hashes_buf[0].hash_info;
12594 }
12595
12596 // copy from inner loop
12597
12598 for (uint hashes_pos = 1; hashes_pos < hashes_cnt; hashes_pos++)
12599 {
12600 if (isSalted)
12601 {
12602 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) != 0)
12603 {
12604 salt_buf = &salts_buf_new[salts_cnt];
12605
12606 memcpy (salt_buf, hashes_buf[hashes_pos].salt, sizeof (salt_t));
12607
12608 if (esalt_size)
12609 {
12610 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[hashes_pos].esalt, esalt_size);
12611 }
12612
12613 salt_buf->digests_cnt = 0;
12614 salt_buf->digests_done = 0;
12615 salt_buf->digests_offset = hashes_pos;
12616
12617 salts_cnt++;
12618 }
12619 }
12620
12621 if (hashes_buf[hashes_pos].cracked == 1)
12622 {
12623 digests_shown[hashes_pos] = 1;
12624
12625 digests_done++;
12626
12627 salt_buf->digests_done++;
12628 }
12629
12630 salt_buf->digests_cnt++;
12631
12632 memcpy (((char *) digests_buf_new) + (hashes_pos * dgst_size), hashes_buf[hashes_pos].digest, dgst_size);
12633
12634 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12635 {
12636 hash_info[hashes_pos] = hashes_buf[hashes_pos].hash_info;
12637 }
12638 }
12639
12640 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
12641 {
12642 salt_t *salt_buf = &salts_buf_new[salt_pos];
12643
12644 if (salt_buf->digests_done == salt_buf->digests_cnt)
12645 {
12646 salts_shown[salt_pos] = 1;
12647
12648 salts_done++;
12649 }
12650
12651 if (salts_done == salts_cnt) data.devices_status = STATUS_CRACKED;
12652 }
12653
12654 local_free (digests_buf);
12655 local_free (salts_buf);
12656 local_free (esalts_buf);
12657
12658 digests_buf = digests_buf_new;
12659 salts_buf = salts_buf_new;
12660 esalts_buf = esalts_buf_new;
12661
12662 local_free (hashes_buf);
12663
12664 /**
12665 * special modification not set from parser
12666 */
12667
12668 switch (hash_mode)
12669 {
12670 case 6211: salts_buf->truecrypt_mdlen = 1 * 512; break;
12671 case 6212: salts_buf->truecrypt_mdlen = 2 * 512; break;
12672 case 6213: salts_buf->truecrypt_mdlen = 3 * 512; break;
12673 case 6221: salts_buf->truecrypt_mdlen = 1 * 512; break;
12674 case 6222: salts_buf->truecrypt_mdlen = 2 * 512; break;
12675 case 6223: salts_buf->truecrypt_mdlen = 3 * 512; break;
12676 case 6231: salts_buf->truecrypt_mdlen = 1 * 512; break;
12677 case 6232: salts_buf->truecrypt_mdlen = 2 * 512; break;
12678 case 6233: salts_buf->truecrypt_mdlen = 3 * 512; break;
12679 case 6241: salts_buf->truecrypt_mdlen = 1 * 512; break;
12680 case 6242: salts_buf->truecrypt_mdlen = 2 * 512; break;
12681 case 6243: salts_buf->truecrypt_mdlen = 3 * 512; break;
12682 }
12683
12684 if (truecrypt_keyfiles)
12685 {
12686 uint *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf;
12687
12688 char *keyfiles = strdup (truecrypt_keyfiles);
12689
12690 char *keyfile = strtok (keyfiles, ",");
12691
12692 do
12693 {
12694 truecrypt_crc32 (keyfile, (unsigned char *) keyfile_buf);
12695
12696 } while ((keyfile = strtok (NULL, ",")) != NULL);
12697
12698 free (keyfiles);
12699 }
12700
12701 data.digests_cnt = digests_cnt;
12702 data.digests_done = digests_done;
12703 data.digests_buf = digests_buf;
12704 data.digests_shown = digests_shown;
12705 data.digests_shown_tmp = digests_shown_tmp;
12706
12707 data.salts_cnt = salts_cnt;
12708 data.salts_done = salts_done;
12709 data.salts_buf = salts_buf;
12710 data.salts_shown = salts_shown;
12711
12712 data.esalts_buf = esalts_buf;
12713 data.hash_info = hash_info;
12714
12715 /**
12716 * Automatic Optimizers
12717 */
12718
12719 if (salts_cnt == 1)
12720 opti_type |= OPTI_TYPE_SINGLE_SALT;
12721
12722 if (digests_cnt == 1)
12723 opti_type |= OPTI_TYPE_SINGLE_HASH;
12724
12725 if (attack_exec == ATTACK_EXEC_ON_GPU)
12726 opti_type |= OPTI_TYPE_NOT_ITERATED;
12727
12728 if (attack_mode == ATTACK_MODE_BF)
12729 opti_type |= OPTI_TYPE_BRUTE_FORCE;
12730
12731 data.opti_type = opti_type;
12732
12733 if (opti_type & OPTI_TYPE_BRUTE_FORCE)
12734 {
12735 if (opti_type & OPTI_TYPE_SINGLE_HASH)
12736 {
12737 if (opti_type & OPTI_TYPE_APPENDED_SALT)
12738 {
12739 if (opts_type & OPTS_TYPE_ST_ADD80)
12740 {
12741 opts_type &= ~OPTS_TYPE_ST_ADD80;
12742 opts_type |= OPTS_TYPE_PT_ADD80;
12743 }
12744
12745 if (opts_type & OPTS_TYPE_ST_ADDBITS14)
12746 {
12747 opts_type &= ~OPTS_TYPE_ST_ADDBITS14;
12748 opts_type |= OPTS_TYPE_PT_ADDBITS14;
12749 }
12750
12751 if (opts_type & OPTS_TYPE_ST_ADDBITS15)
12752 {
12753 opts_type &= ~OPTS_TYPE_ST_ADDBITS15;
12754 opts_type |= OPTS_TYPE_PT_ADDBITS15;
12755 }
12756 }
12757 }
12758 }
12759
12760 /**
12761 * generate bitmap tables
12762 */
12763
12764 const uint bitmap_shift1 = 5;
12765 const uint bitmap_shift2 = 13;
12766
12767 if (bitmap_max < bitmap_min) bitmap_max = bitmap_min;
12768
12769 uint *bitmap_s1_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12770 uint *bitmap_s1_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12771 uint *bitmap_s1_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12772 uint *bitmap_s1_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12773 uint *bitmap_s2_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12774 uint *bitmap_s2_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12775 uint *bitmap_s2_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12776 uint *bitmap_s2_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12777
12778 uint bitmap_bits;
12779 uint bitmap_nums;
12780 uint bitmap_mask;
12781 uint bitmap_size;
12782
12783 for (bitmap_bits = bitmap_min; bitmap_bits < bitmap_max; bitmap_bits++)
12784 {
12785 if (data.quiet == 0) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits);
12786
12787 bitmap_nums = 1 << bitmap_bits;
12788
12789 bitmap_mask = bitmap_nums - 1;
12790
12791 bitmap_size = bitmap_nums * sizeof (uint);
12792
12793 if ((hashes_cnt & bitmap_mask) == hashes_cnt) break;
12794
12795 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;
12796 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;
12797
12798 break;
12799 }
12800
12801 bitmap_nums = 1 << bitmap_bits;
12802
12803 bitmap_mask = bitmap_nums - 1;
12804
12805 bitmap_size = bitmap_nums * sizeof (uint);
12806
12807 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);
12808 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);
12809
12810 /**
12811 * prepare quick rule
12812 */
12813
12814 data.rule_buf_l = rule_buf_l;
12815 data.rule_buf_r = rule_buf_r;
12816
12817 int rule_len_l = (int) strlen (rule_buf_l);
12818 int rule_len_r = (int) strlen (rule_buf_r);
12819
12820 data.rule_len_l = rule_len_l;
12821 data.rule_len_r = rule_len_r;
12822
12823 /**
12824 * load rules
12825 */
12826
12827 uint *all_gpu_rules_cnt = NULL;
12828
12829 gpu_rule_t **all_gpu_rules_buf = NULL;
12830
12831 if (rp_files_cnt)
12832 {
12833 all_gpu_rules_cnt = (uint *) mycalloc (rp_files_cnt, sizeof (uint));
12834
12835 all_gpu_rules_buf = (gpu_rule_t **) mycalloc (rp_files_cnt, sizeof (gpu_rule_t *));
12836 }
12837
12838 char rule_buf[BUFSIZ];
12839
12840 int rule_len = 0;
12841
12842 for (uint i = 0; i < rp_files_cnt; i++)
12843 {
12844 uint gpu_rules_avail = 0;
12845
12846 uint gpu_rules_cnt = 0;
12847
12848 gpu_rule_t *gpu_rules_buf = NULL;
12849
12850 char *rp_file = rp_files[i];
12851
12852 char in[BLOCK_SIZE];
12853 char out[BLOCK_SIZE];
12854
12855 FILE *fp = NULL;
12856
12857 uint rule_line = 0;
12858
12859 if ((fp = fopen (rp_file, "rb")) == NULL)
12860 {
12861 log_error ("ERROR: %s: %s", rp_file, strerror (errno));
12862
12863 return (-1);
12864 }
12865
12866 while (!feof (fp))
12867 {
12868 memset (rule_buf, 0, BUFSIZ);
12869
12870 rule_len = fgetl (fp, rule_buf);
12871
12872 rule_line++;
12873
12874 if (rule_len == 0) continue;
12875
12876 if (rule_buf[0] == '#') continue;
12877
12878 if (gpu_rules_avail == gpu_rules_cnt)
12879 {
12880 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12881
12882 gpu_rules_avail += INCR_RULES;
12883 }
12884
12885 memset (in, 0, BLOCK_SIZE);
12886 memset (out, 0, BLOCK_SIZE);
12887
12888 int result = _old_apply_rule (rule_buf, rule_len, in, 1, out);
12889
12890 if (result == -1)
12891 {
12892 log_info ("WARNING: Skipping invalid or unsupported rule in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12893
12894 continue;
12895 }
12896
12897 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1)
12898 {
12899 log_info ("WARNING: Cannot convert rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12900
12901 memset (&gpu_rules_buf[gpu_rules_cnt], 0, sizeof (gpu_rule_t)); // needs to be cleared otherwise we could have some remaining data
12902
12903 continue;
12904 }
12905
12906 /* its so slow
12907 if (rulefind (&gpu_rules_buf[gpu_rules_cnt], gpu_rules_buf, gpu_rules_cnt, sizeof (gpu_rule_t), sort_by_gpu_rule))
12908 {
12909 log_info ("Duplicate rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12910
12911 continue;
12912 }
12913 */
12914
12915 gpu_rules_cnt++;
12916 }
12917
12918 fclose (fp);
12919
12920 all_gpu_rules_cnt[i] = gpu_rules_cnt;
12921
12922 all_gpu_rules_buf[i] = gpu_rules_buf;
12923 }
12924
12925 /**
12926 * merge rules or automatic rule generator
12927 */
12928
12929 uint gpu_rules_cnt = 0;
12930
12931 gpu_rule_t *gpu_rules_buf = NULL;
12932
12933 if (attack_mode == ATTACK_MODE_STRAIGHT)
12934 {
12935 if (rp_files_cnt)
12936 {
12937 gpu_rules_cnt = 1;
12938
12939 uint *repeats = (uint *) mycalloc (rp_files_cnt + 1, sizeof (uint));
12940
12941 repeats[0] = gpu_rules_cnt;
12942
12943 for (uint i = 0; i < rp_files_cnt; i++)
12944 {
12945 gpu_rules_cnt *= all_gpu_rules_cnt[i];
12946
12947 repeats[i + 1] = gpu_rules_cnt;
12948 }
12949
12950 gpu_rules_buf = (gpu_rule_t *) mycalloc (gpu_rules_cnt, sizeof (gpu_rule_t));
12951
12952 memset (gpu_rules_buf, 0, gpu_rules_cnt * sizeof (gpu_rule_t));
12953
12954 for (uint i = 0; i < gpu_rules_cnt; i++)
12955 {
12956 uint out_pos = 0;
12957
12958 gpu_rule_t *out = &gpu_rules_buf[i];
12959
12960 for (uint j = 0; j < rp_files_cnt; j++)
12961 {
12962 uint in_off = (i / repeats[j]) % all_gpu_rules_cnt[j];
12963 uint in_pos;
12964
12965 gpu_rule_t *in = &all_gpu_rules_buf[j][in_off];
12966
12967 for (in_pos = 0; in->cmds[in_pos]; in_pos++, out_pos++)
12968 {
12969 if (out_pos == RULES_MAX - 1)
12970 {
12971 // log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
12972
12973 break;
12974 }
12975
12976 out->cmds[out_pos] = in->cmds[in_pos];
12977 }
12978 }
12979 }
12980
12981 local_free (repeats);
12982 }
12983 else if (rp_gen)
12984 {
12985 uint gpu_rules_avail = 0;
12986
12987 while (gpu_rules_cnt < rp_gen)
12988 {
12989 if (gpu_rules_avail == gpu_rules_cnt)
12990 {
12991 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12992
12993 gpu_rules_avail += INCR_RULES;
12994 }
12995
12996 memset (rule_buf, 0, BLOCK_SIZE);
12997
12998 rule_len = (int) generate_random_rule (rule_buf, rp_gen_func_min, rp_gen_func_max);
12999
13000 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1) continue;
13001
13002 gpu_rules_cnt++;
13003 }
13004 }
13005 }
13006
13007 /**
13008 * generate NOP rules
13009 */
13010
13011 if (gpu_rules_cnt == 0)
13012 {
13013 gpu_rules_buf = (gpu_rule_t *) mymalloc (sizeof (gpu_rule_t));
13014
13015 gpu_rules_buf[gpu_rules_cnt].cmds[0] = RULE_OP_MANGLE_NOOP;
13016
13017 gpu_rules_cnt++;
13018 }
13019
13020 data.gpu_rules_cnt = gpu_rules_cnt;
13021 data.gpu_rules_buf = gpu_rules_buf;
13022
13023 /**
13024 * platform
13025 */
13026
13027 #ifdef _CUDA
13028 if (cuInit (0) != CUDA_SUCCESS)
13029 {
13030 log_error ("ERROR: No NVidia compatible platform found");
13031
13032 return (-1);
13033 }
13034 #endif
13035
13036 /**
13037 * devices get
13038 */
13039
13040 uint devices_all_cnt = 0;
13041
13042 #ifdef _CUDA
13043 CUdevice devices_all[DEVICES_MAX];
13044 CUdevice devices[DEVICES_MAX];
13045
13046 hc_cuDeviceGetCount ((int *) &devices_all_cnt);
13047
13048 for (uint i = 0; i < devices_all_cnt; i++)
13049 {
13050 hc_cuDeviceGet (&devices_all[i], i);
13051 }
13052
13053 #elif _OCL
13054 cl_platform_id CL_platform = NULL;
13055
13056 cl_platform_id CL_platforms[CL_PLATFORMS_MAX];
13057
13058 uint CL_platforms_cnt = 0;
13059
13060 hc_clGetPlatformIDs (CL_PLATFORMS_MAX, CL_platforms, &CL_platforms_cnt);
13061
13062 for (uint i = 0; i < CL_platforms_cnt; i++)
13063 {
13064 char CL_platform_vendor[INFOSZ];
13065
13066 memset (CL_platform_vendor, 0, sizeof (CL_platform_vendor));
13067
13068 hc_clGetPlatformInfo (CL_platforms[i], CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
13069
13070 if ((strcmp (CL_platform_vendor, CL_VENDOR_AMD) != 0)
13071 && (strcmp (CL_platform_vendor, CL_VENDOR_SDS) != 0)
13072 && (strcmp (CL_platform_vendor, CL_VENDOR_APPLE) != 0)) continue;
13073
13074 if (strcmp (CL_platform_vendor, CL_VENDOR_SDS) == 0) gpu_temp_disable = 1;
13075
13076 CL_platform = CL_platforms[i];
13077 }
13078
13079 if (CL_platform == NULL)
13080 {
13081 log_error ("ERROR: No AMD/SDS compatible platform found");
13082
13083 return (-1);
13084 }
13085
13086 cl_device_id devices_all[DEVICES_MAX];
13087 cl_device_id devices[DEVICES_MAX];
13088
13089 hc_clGetDeviceIDs (CL_platform, CL_DEVICE_TYPE_GPU, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
13090
13091 #endif
13092
13093 int hm_adapters_all = devices_all_cnt;
13094
13095 hm_attrs_t hm_adapter_all[DEVICES_MAX];
13096
13097 memset (hm_adapter_all, 0, sizeof (hm_adapter_all));
13098
13099 if (gpu_temp_disable == 0)
13100 {
13101 #ifdef _CUDA
13102 #ifdef LINUX
13103 if (hc_NVML_nvmlInit () == NVML_SUCCESS)
13104 {
13105 HM_ADAPTER nvGPUHandle[DEVICES_MAX];
13106
13107 int tmp_in = hm_get_adapter_index (nvGPUHandle);
13108
13109 int tmp_out = 0;
13110
13111 for (int i = 0; i < tmp_in; i++)
13112 {
13113 hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i];
13114 }
13115
13116 hm_adapters_all = tmp_out;
13117
13118 for (int i = 0; i < tmp_out; i++)
13119 {
13120 unsigned int speed;
13121
13122 if (nvmlDeviceGetFanSpeed (hm_adapter_all[i].adapter_index, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
13123 }
13124 }
13125 #endif
13126
13127 #ifdef WIN
13128 if (NvAPI_Initialize () == NVAPI_OK)
13129 {
13130 HM_ADAPTER nvGPUHandle[DEVICES_MAX];
13131
13132 int tmp_in = hm_get_adapter_index (nvGPUHandle);
13133
13134 int tmp_out = 0;
13135
13136 for (int i = 0; i < tmp_in; i++)
13137 {
13138 hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i];
13139 }
13140
13141 hm_adapters_all = tmp_out;
13142
13143 for (int i = 0; i < tmp_out; i++)
13144 {
13145 NvU32 speed;
13146
13147 if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
13148 }
13149 }
13150 #endif
13151 #endif
13152
13153 #ifdef _OCL
13154 #ifndef OSX
13155 HM_LIB hm_dll = hm_init ();
13156
13157 data.hm_dll = hm_dll;
13158
13159 if (hc_ADL_Main_Control_Create (hm_dll, ADL_Main_Memory_Alloc, 0) == ADL_OK)
13160 {
13161 // total number of adapters
13162
13163 int hm_adapters_num;
13164
13165 if (get_adapters_num (hm_dll, &hm_adapters_num) != 0) return (-1);
13166
13167 // adapter info
13168
13169 LPAdapterInfo lpAdapterInfo = hm_get_adapter_info (hm_dll, hm_adapters_num);
13170
13171 if (lpAdapterInfo == NULL) return (-1);
13172
13173 // get a list (of ids of) valid/usable adapters
13174
13175 int num_adl_adapters = 0;
13176
13177 uint32_t *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo);
13178
13179 if (num_adl_adapters > 0)
13180 {
13181 hc_thread_mutex_lock (mux_adl);
13182
13183 // hm_get_opencl_busid_devid (hm_adapter_all, devices_all_cnt, devices_all);
13184
13185 hm_get_adapter_index (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13186
13187 hm_get_overdrive_version (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13188 hm_check_fanspeed_control (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13189
13190 hc_thread_mutex_unlock (mux_adl);
13191 }
13192
13193 hm_adapters_all = num_adl_adapters;
13194
13195 myfree (valid_adl_device_list);
13196 myfree (lpAdapterInfo);
13197 }
13198 #endif
13199 #endif
13200 }
13201
13202 if (hm_adapters_all == 0)
13203 {
13204 gpu_temp_disable = 1;
13205 }
13206
13207 if (gpu_temp_disable == 1)
13208 {
13209 gpu_temp_abort = 0;
13210 gpu_temp_retain = 0;
13211 }
13212
13213 /**
13214 * enable custom signal handler(s)
13215 */
13216
13217 if (benchmark == 0)
13218 {
13219 hc_signal (sigHandler_default);
13220 }
13221 else
13222 {
13223 hc_signal (sigHandler_benchmark);
13224 }
13225
13226 /**
13227 * devices mask and properties
13228 */
13229
13230 uint devices_cnt = 0;
13231
13232 for (uint device_all_id = 0; device_all_id < devices_all_cnt; device_all_id++)
13233 {
13234 if (gpu_devicemask)
13235 {
13236 uint device_all_id_mask = 1 << device_all_id;
13237
13238 if ((device_all_id_mask & gpu_devicemask) != device_all_id_mask)
13239 {
13240 if (quiet == 0 && algorithm_pos == 0) log_info ("Device #%d: skipped by user", device_all_id_mask + 1);
13241
13242 continue;
13243 }
13244 }
13245
13246 const uint device_id = devices_cnt;
13247
13248 devices[device_id] = devices_all[device_all_id];
13249
13250 memcpy (&data.hm_device[device_id], &hm_adapter_all[device_all_id], sizeof (hm_attrs_t));
13251
13252 char device_name[INFOSZ];
13253
13254 memset (device_name, 0, sizeof (device_name));
13255
13256 #ifdef _CUDA
13257 size_t global_mem_size;
13258 int max_clock_frequency;
13259 int max_compute_units;
13260 int kernel_exec_timeout;
13261
13262 hc_cuDeviceGetName (device_name, sizeof (device_name), devices[device_id]);
13263 hc_cuDeviceTotalMem (&global_mem_size, devices[device_id]);
13264 hc_cuDeviceGetAttribute (&max_clock_frequency, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, devices[device_id]); max_clock_frequency /= 1000;
13265 hc_cuDeviceGetAttribute (&max_compute_units, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, devices[device_id]);
13266 hc_cuDeviceGetAttribute (&kernel_exec_timeout, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, devices[device_id]);
13267
13268 #elif _OCL
13269 cl_ulong global_mem_size;
13270 cl_uint max_clock_frequency;
13271 cl_uint max_compute_units;
13272
13273 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_NAME, sizeof (device_name), &device_name, NULL);
13274 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (global_mem_size), &global_mem_size, NULL);
13275 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (max_clock_frequency), &max_clock_frequency, NULL);
13276 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
13277
13278 #endif
13279
13280 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
13281 {
13282 log_info ("Device #%u: %s, %luMB, %dMhz, %uMCU",
13283 device_all_id + 1,
13284 device_name,
13285 (unsigned int) (global_mem_size / 1024 / 1024),
13286 (unsigned int) (max_clock_frequency),
13287 (unsigned int) max_compute_units);
13288 }
13289
13290 #ifdef _CUDA
13291 if (quiet == 0 && kernel_exec_timeout != 0 && algorithm_pos == 0)
13292 {
13293 log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1);
13294 #if _WIN
13295 log_info (" You can disable it with a regpatch, see here: http://hashcat.net/wiki/doku.php?id=timeout_patch");
13296 #endif
13297 }
13298 #endif
13299
13300 devices_cnt++;
13301 }
13302
13303 if (devices_cnt == 0)
13304 {
13305 log_error ("ERROR: No devices left that matches your specification.");
13306
13307 return (-1);
13308 }
13309
13310 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
13311 {
13312 log_info ("");
13313 }
13314
13315 /**
13316 * inform the user
13317 */
13318
13319 // gpu temp sanity check
13320
13321 if ((gpu_temp_abort != 0) && (gpu_temp_retain != 0))
13322 {
13323 if (gpu_temp_abort < gpu_temp_retain)
13324 {
13325 log_error ("ERROR: invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain.");
13326
13327 return (-1);
13328 }
13329 }
13330
13331 if (data.quiet == 0)
13332 {
13333 log_info ("Hashes: %u hashes; %u unique digests, %u unique salts", hashes_cnt_orig, digests_cnt, salts_cnt);
13334
13335 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);
13336
13337 if (attack_mode == ATTACK_MODE_STRAIGHT)
13338 {
13339 log_info ("Rules: %u", gpu_rules_cnt);
13340 }
13341
13342 if (opti_type)
13343 {
13344 log_info ("Applicable Optimizers:");
13345
13346 for (uint i = 0; i < 32; i++)
13347 {
13348 const uint opti_bit = 1 << i;
13349
13350 if (opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit));
13351 }
13352 }
13353
13354 /**
13355 * Watchdog and Temperature balance
13356 */
13357
13358 if (gpu_temp_abort == 0)
13359 {
13360 log_info ("Watchdog: Temperature abort trigger disabled");
13361 }
13362 else
13363 {
13364 log_info ("Watchdog: Temperature abort trigger set to %uc", gpu_temp_abort);
13365 }
13366
13367 if (gpu_temp_retain == 0)
13368 {
13369 log_info ("Watchdog: Temperature retain trigger disabled");
13370 }
13371 else
13372 {
13373 log_info ("Watchdog: Temperature retain trigger set to %uc", gpu_temp_retain);
13374 }
13375 }
13376
13377 /**
13378 * store all the preparation, not hash_mode dependant
13379 */
13380
13381 data.gpu_temp_disable = gpu_temp_disable;
13382 data.gpu_temp_abort = gpu_temp_abort;
13383 data.gpu_temp_retain = gpu_temp_retain;
13384
13385 data.devices_cnt = devices_cnt;
13386
13387 #ifdef _OCL
13388 /**
13389 * catalyst driver check
13390 */
13391
13392 int catalyst_check = (force == 1) ? 0 : 1;
13393
13394 int catalyst_warn = 0;
13395
13396 int catalyst_broken = 0;
13397 #endif
13398
13399 /**
13400 * devices init
13401 */
13402
13403 #ifdef _OCL
13404 #ifndef OSX
13405 int gpu_temp_retain_set = 0;
13406
13407 int *temp_retain_fanspeed_value = (int *) mycalloc (devices_cnt, sizeof (int));
13408
13409 ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (devices_cnt, sizeof (ADLOD6MemClockState));
13410
13411 int *od_power_control_status = (int *) mycalloc (devices_cnt, sizeof (int));
13412 #endif
13413 #endif
13414
13415 hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (devices_cnt, sizeof (hc_device_param_t));
13416
13417 data.devices_param = devices_param;
13418
13419 for (uint device_id = 0; device_id < devices_cnt; device_id++)
13420 {
13421 hc_device_param_t *device_param = &data.devices_param[device_id];
13422
13423 #ifdef _CUDA
13424 CUdevice device = devices[device_id];
13425
13426 device_param->device = device;
13427
13428 size_t bytes;
13429
13430 hc_cuDeviceTotalMem (&bytes, device);
13431
13432 device_param->gpu_maxmem_alloc = bytes;
13433
13434 int sm_major = 0;
13435 int sm_minor = 0;
13436 int max_compute_units = 0;
13437
13438 hc_cuDeviceComputeCapability (&sm_major, &sm_minor, device);
13439
13440 if (sm_major == 1)
13441 {
13442 log_error ("ERROR: Shader Model 1.0 - 1.3 based GPU detected. Support for CUDA was dropped by NVidia.");
13443 log_error (" Remove it from your system or use -d and select only supported cards.");
13444
13445 return (-1);
13446 }
13447
13448 device_param->sm_major = sm_major;
13449 device_param->sm_minor = sm_minor;
13450
13451 hc_cuDeviceGetAttribute (&max_compute_units, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, device);
13452
13453 if (sm_major >= 5)
13454 {
13455 // those maxwell and newer are so good compared to older chipsets we need to equalize
13456 // their power to older chipsets, otherwise workload distribution which is based on the compute_units
13457 // gets out of control
13458
13459 max_compute_units *= 3;
13460 }
13461
13462 device_param->gpu_processors = max_compute_units;
13463
13464 /**
13465 * calculate vector size
13466 */
13467
13468 uint vliw = get_vliw_by_compute_capability (sm_major, sm_minor);
13469
13470 device_param->gpu_vector_width = get_gpu_vector_width (hash_mode, attack_kern, attack_exec, opti_type, vliw);
13471
13472 #elif _OCL
13473 cl_device_id device = devices[device_id];
13474
13475 device_param->device = device;
13476
13477 cl_uint max_compute_units = 0;
13478
13479 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
13480
13481 device_param->gpu_processors = max_compute_units;
13482
13483 cl_ulong max_mem_alloc_size = 0;
13484
13485 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL);
13486
13487 device_param->gpu_maxmem_alloc = max_mem_alloc_size;
13488
13489 char tmp[INFOSZ], t1[64];
13490
13491 memset (tmp, 0, sizeof (tmp));
13492
13493 hc_clGetDeviceInfo (device, CL_DEVICE_NAME, sizeof (tmp), &tmp, NULL);
13494
13495 device_param->device_name = mystrdup (tmp);
13496
13497 memset (tmp, 0, sizeof (tmp));
13498
13499 hc_clGetDeviceInfo (device, CL_DEVICE_VERSION, sizeof (tmp), &tmp, NULL);
13500
13501 memset (t1, 0, sizeof (t1));
13502
13503 sscanf (tmp, "%*16s %*16s %*16s (%[^)]16s)", t1);
13504
13505 device_param->device_version = mystrdup (t1);
13506
13507 memset (tmp, 0, sizeof (tmp));
13508
13509 hc_clGetDeviceInfo (device, CL_DRIVER_VERSION, sizeof (tmp), &tmp, NULL);
13510
13511 device_param->driver_version = mystrdup (tmp);
13512
13513 /**
13514 * calculate vector size
13515 */
13516
13517 uint vliw = get_vliw_by_device_name (device_param->device_name);
13518
13519 device_param->gpu_vector_width = get_gpu_vector_width (hash_mode, attack_kern, attack_exec, opti_type, vliw);
13520
13521 /**
13522 * catalyst driver check
13523 */
13524
13525 if (catalyst_check == 1)
13526 {
13527 catalyst_warn = 1;
13528
13529 // v14.9 and higher
13530 if ((atoi (device_param->device_version) >= 1573)
13531 && (atoi (device_param->driver_version) >= 1573))
13532 {
13533 catalyst_warn = 0;
13534 }
13535
13536 /*
13537 // v14.9
13538 if ((strstr (device_param->device_version, "1573.") != NULL)
13539 && (strstr (device_param->driver_version, "1573.") != NULL))
13540 {
13541 catalyst_warn = 0;
13542 }
13543
13544 // v14.12 -- version overlaps with v15.4 beta
13545 if ((strstr (device_param->device_version, "1642.") != NULL)
13546 && (strstr (device_param->driver_version, "1642.") != NULL))
13547 {
13548 catalyst_broken = 1;
13549 }
13550
13551 // v15.4 (Beta, Windows only release)
13552 if ((strstr (device_param->device_version, "1642.") != NULL)
13553 && (strstr (device_param->driver_version, "1642.") != NULL))
13554 {
13555 catalyst_warn = 0;
13556 }
13557
13558 // v15.5 (Release, Linux)
13559 if ((strstr (device_param->device_version, "1702.") != NULL)
13560 && (strstr (device_param->driver_version, "1702.") != NULL))
13561 {
13562 catalyst_warn = 0;
13563 }
13564
13565 // v15.3 (Beta, Ubuntu repository release)
13566 if ((strstr (device_param->device_version, "1729.") != NULL)
13567 && (strstr (device_param->driver_version, "1729.") != NULL))
13568 {
13569 catalyst_warn = 0;
13570 }
13571 */
13572
13573 catalyst_check = 0;
13574 }
13575 #endif
13576 }
13577
13578 #ifdef _OCL
13579 if (catalyst_broken == 1)
13580 {
13581 log_error ("");
13582 log_error ("ATTENTION! The installed GPU driver in your system is known to be broken!");
13583 log_error ("It will pass over cracked hashes and does not report them as cracked");
13584 log_error ("You are STRONGLY encouraged not to use it");
13585 log_error ("You can use --force to override this but do not post error reports if you do so");
13586
13587 return (-1);
13588 }
13589
13590 if (catalyst_warn == 1)
13591 {
13592 log_error ("");
13593 log_error ("ATTENTION! Unsupported or incorrect installed GPU driver detected!");
13594 log_error ("You are STRONGLY encouraged to use the official supported GPU driver for good reasons");
13595 log_error ("See oclHashcat's homepage for official supported GPU drivers");
13596 #ifdef _WIN
13597 log_error ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
13598 #endif
13599 log_error ("You can use --force to override this but do not post error reports if you do so");
13600
13601 return (-1);
13602 }
13603 #endif
13604
13605 uint gpu_blocks_all = 0;
13606
13607 #ifdef _CUDA
13608 for (uint device_id = 0; device_id < devices_cnt; device_id++)
13609 {
13610 /**
13611 * host buffer
13612 */
13613
13614 hc_device_param_t *device_param = &data.devices_param[device_id];
13615
13616 /**
13617 * device properties
13618 */
13619
13620 int sm_minor = device_param->sm_minor;
13621 int sm_major = device_param->sm_major;
13622
13623 uint gpu_processors = device_param->gpu_processors;
13624 uint gpu_vector_width = device_param->gpu_vector_width;
13625
13626 /**
13627 * create context for each device
13628 */
13629
13630 uint flags = 0;
13631
13632 if (gpu_async == 0) flags |= CU_CTX_SCHED_BLOCKING_SYNC;
13633 else flags |= CU_CTX_SCHED_SPIN;
13634
13635 hc_cuCtxCreate (&device_param->context, flags, device_param->device);
13636
13637 // does bad things hc_cuCtxSetCacheConfig (CU_FUNC_CACHE_PREFER_L1);
13638
13639 /**
13640 * create input buffers on device
13641 */
13642
13643 uint gpu_threads = GPU_THREADS_NV;
13644
13645 if (hash_mode == 1500) gpu_threads = 64;
13646 if (hash_mode == 3000) gpu_threads = 64;
13647 if (hash_mode == 3200) gpu_threads = 8;
13648 if (hash_mode == 7500) gpu_threads = 64;
13649 if (hash_mode == 8900) gpu_threads = 64;
13650 if (hash_mode == 9000) gpu_threads = 8;
13651 if (hash_mode == 9300) gpu_threads = 64;
13652 if (hash_mode == 9700) gpu_threads = 64;
13653 if (hash_mode == 9710) gpu_threads = 64;
13654 if (hash_mode == 9800) gpu_threads = 64;
13655 if (hash_mode == 9810) gpu_threads = 64;
13656 if (hash_mode == 10400) gpu_threads = 64;
13657 if (hash_mode == 10410) gpu_threads = 64;
13658 if (hash_mode == 10500) gpu_threads = 64;
13659
13660 uint gpu_power = gpu_processors * gpu_threads * gpu_accel;
13661 uint gpu_blocks = gpu_power * gpu_vector_width;
13662
13663 device_param->gpu_threads = gpu_threads;
13664 device_param->gpu_power_user = gpu_power;
13665 device_param->gpu_blocks_user = gpu_blocks;
13666
13667 gpu_blocks_all += gpu_blocks;
13668
13669 uint size_pws = gpu_power * sizeof (pw_t);
13670
13671 uint size_tmps = 4;
13672
13673 switch (hash_mode)
13674 {
13675 case 400: size_tmps = gpu_blocks * sizeof (phpass_tmp_t); break;
13676 case 500: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13677 case 501: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13678 case 1600: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13679 case 1800: size_tmps = gpu_blocks * sizeof (sha512crypt_tmp_t); break;
13680 case 2100: size_tmps = gpu_blocks * sizeof (dcc2_tmp_t); break;
13681 case 2500: size_tmps = gpu_blocks * sizeof (wpa_tmp_t); break;
13682 case 3200: size_tmps = gpu_blocks * sizeof (bcrypt_tmp_t); break;
13683 case 5200: size_tmps = gpu_blocks * sizeof (pwsafe3_tmp_t); break;
13684 case 5800: size_tmps = gpu_blocks * sizeof (androidpin_tmp_t); break;
13685 case 6211:
13686 case 6212:
13687 case 6213: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13688 case 6221:
13689 case 6222:
13690 case 6223: size_tmps = gpu_blocks * sizeof (tc64_tmp_t); break;
13691 case 6231:
13692 case 6232:
13693 case 6233: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13694 case 6241:
13695 case 6242:
13696 case 6243: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13697 case 6300: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13698 case 6400: size_tmps = gpu_blocks * sizeof (sha256aix_tmp_t); break;
13699 case 6500: size_tmps = gpu_blocks * sizeof (sha512aix_tmp_t); break;
13700 case 6600: size_tmps = gpu_blocks * sizeof (agilekey_tmp_t); break;
13701 case 6700: size_tmps = gpu_blocks * sizeof (sha1aix_tmp_t); break;
13702 case 6800: size_tmps = gpu_blocks * sizeof (lastpass_tmp_t); break;
13703 case 7100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13704 case 7200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13705 case 7400: size_tmps = gpu_blocks * sizeof (sha256crypt_tmp_t); break;
13706 case 7900: size_tmps = gpu_blocks * sizeof (drupal7_tmp_t); break;
13707 case 8200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13708 case 8800: size_tmps = gpu_blocks * sizeof (androidfde_tmp_t); break;
13709 case 8900: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
13710 case 9000: size_tmps = gpu_blocks * sizeof (pwsafe2_tmp_t); break;
13711 case 9100: size_tmps = gpu_blocks * sizeof (lotus8_tmp_t); break;
13712 case 9200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13713 case 9300: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
13714 case 9400: size_tmps = gpu_blocks * sizeof (office2007_tmp_t); break;
13715 case 9500: size_tmps = gpu_blocks * sizeof (office2010_tmp_t); break;
13716 case 9600: size_tmps = gpu_blocks * sizeof (office2013_tmp_t); break;
13717 case 10000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13718 case 10200: size_tmps = gpu_blocks * sizeof (cram_md5_t); break;
13719 case 10300: size_tmps = gpu_blocks * sizeof (saph_sha1_tmp_t); break;
13720 case 10500: size_tmps = gpu_blocks * sizeof (pdf14_tmp_t); break;
13721 case 10700: size_tmps = gpu_blocks * sizeof (pdf17l8_tmp_t); break;
13722 case 10900: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13723 case 11300: size_tmps = gpu_blocks * sizeof (bitcoin_wallet_tmp_t); break;
13724 case 11600: size_tmps = gpu_blocks * sizeof (seven_zip_tmp_t); break;
13725 case 11900: size_tmps = gpu_blocks * sizeof (pbkdf2_md5_tmp_t); break;
13726 case 12000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha1_tmp_t); break;
13727 case 12100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13728 case 12200: size_tmps = gpu_blocks * sizeof (ecryptfs_tmp_t); break;
13729 case 12300: size_tmps = gpu_blocks * sizeof (oraclet_tmp_t); break;
13730 case 12400: size_tmps = gpu_blocks * sizeof (bsdicrypt_tmp_t); break;
13731 case 12500: size_tmps = gpu_blocks * sizeof (rar3_tmp_t); break;
13732 case 12700: size_tmps = gpu_blocks * sizeof (mywallet_tmp_t); break;
13733 case 12800: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13734 };
13735
13736 uint size_hooks = 4;
13737
13738 if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23))
13739 {
13740 // fill size_hook with correct size
13741 }
13742
13743 // we can optimize some stuff here...
13744
13745 device_param->size_pws = size_pws;
13746 device_param->size_tmps = size_tmps;
13747 device_param->size_hooks = size_hooks;
13748
13749 uint size_root_css = SP_PW_MAX * sizeof (cs_t);
13750 uint size_markov_css = SP_PW_MAX * CHARSIZ * sizeof (cs_t);
13751
13752 device_param->size_root_css = size_root_css;
13753 device_param->size_markov_css = size_markov_css;
13754
13755 uint size_results = GPU_THREADS_NV * sizeof (uint);
13756
13757 device_param->size_results = size_results;
13758
13759 uint size_rules = gpu_rules_cnt * sizeof (gpu_rule_t);
13760 uint size_plains = digests_cnt * sizeof (plain_t);
13761 uint size_salts = salts_cnt * sizeof (salt_t);
13762 uint size_esalts = salts_cnt * esalt_size;
13763
13764 device_param->size_plains = size_plains;
13765 device_param->size_digests = size_digests;
13766 device_param->size_shown = size_shown;
13767 device_param->size_salts = size_salts;
13768
13769 uint size_combs = GPU_COMBS * sizeof (comb_t);
13770 uint size_bfs = GPU_BFS * sizeof (bf_t);
13771 uint size_tm = 32 * sizeof (bs_word_t);
13772
13773 uint64_t size_scryptV = 1;
13774
13775 if ((hash_mode == 8900) || (hash_mode == 9300))
13776 {
13777 #define SHADER_PER_MP 32
13778 #define WARPS 32
13779
13780 uint tmto_start = 2;
13781 uint tmto_stop = 1024;
13782
13783 if (scrypt_tmto)
13784 {
13785 tmto_start = 1 << scrypt_tmto;
13786 tmto_stop = tmto_start + 1;
13787 }
13788
13789 for (uint tmto = tmto_start; tmto < tmto_stop; tmto <<= 1)
13790 {
13791 // todo -- make sure all salts get the new tmto value
13792
13793 size_scryptV = (128 * data.salts_buf[0].scrypt_r) * data.salts_buf[0].scrypt_N;
13794
13795 size_scryptV /= tmto;
13796
13797 size_scryptV *= gpu_processors * WARPS * SHADER_PER_MP;
13798
13799 if (size_scryptV > (device_param->gpu_maxmem_alloc / 2)) continue;
13800
13801 for (uint salts_pos = 0; salts_pos < data.salts_cnt; salts_pos++)
13802 {
13803 data.salts_buf[salts_pos].scrypt_tmto = tmto;
13804 data.salts_buf[salts_pos].scrypt_phy = gpu_processors * WARPS * SHADER_PER_MP;
13805 }
13806
13807 break;
13808 }
13809
13810 if (data.salts_buf[0].scrypt_tmto == 0)
13811 {
13812 log_error ("ERROR: can't allocate enough GPU memory");
13813
13814 return -1;
13815 }
13816
13817 if (quiet == 0) log_info ("");
13818 if (quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u\n", data.salts_buf[0].scrypt_tmto);
13819 }
13820
13821 /**
13822 * stream
13823 */
13824
13825 hc_cuStreamCreate (&device_param->stream, 0);
13826
13827 /**
13828 * module find
13829 */
13830
13831 char module_file[256];
13832
13833 memset (module_file, 0, sizeof (module_file));
13834
13835 #ifdef __x86_64__
13836 if (attack_exec == ATTACK_EXEC_ON_GPU)
13837 {
13838 if (attack_kern == ATTACK_KERN_STRAIGHT)
13839 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);
13840 else if (attack_kern == ATTACK_KERN_COMBI)
13841 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);
13842 else if (attack_kern == ATTACK_KERN_BF)
13843 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);
13844 }
13845 else
13846 {
13847 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);
13848
13849 if ((hash_mode == 8900) || (hash_mode == 9300))
13850 {
13851 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);
13852 }
13853 }
13854
13855 #else
13856 if (attack_exec == ATTACK_EXEC_ON_GPU)
13857 {
13858 if (attack_kern == ATTACK_KERN_STRAIGHT)
13859 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);
13860 else if (attack_kern == ATTACK_KERN_COMBI)
13861 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);
13862 else if (attack_kern == ATTACK_KERN_BF)
13863 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);
13864 }
13865 else
13866 {
13867 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);
13868
13869 if ((hash_mode == 8900) || (hash_mode == 9300))
13870 {
13871 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);
13872 }
13873 }
13874
13875 #endif
13876
13877 char module_mp_file[256];
13878
13879 memset (module_mp_file, 0, sizeof (module_mp_file));
13880
13881 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
13882 {
13883 #ifdef __x86_64__
13884 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);
13885 #else
13886 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);
13887 #endif
13888 }
13889 else
13890 {
13891 #ifdef __x86_64__
13892 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);
13893 #else
13894 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);
13895 #endif
13896 }
13897
13898 char module_amp_file[256];
13899
13900 memset (module_amp_file, 0, sizeof (module_amp_file));
13901
13902 #ifdef __x86_64__
13903 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);
13904 #else
13905 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);
13906 #endif
13907
13908 /**
13909 * module load
13910 */
13911
13912 hc_cuModuleLoad (&device_param->module, module_file);
13913
13914 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_file);
13915
13916 if (attack_mode != ATTACK_MODE_STRAIGHT)
13917 {
13918 hc_cuModuleLoad (&device_param->module_mp, module_mp_file);
13919
13920 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_mp_file);
13921 }
13922
13923 if (attack_exec == ATTACK_EXEC_ON_GPU)
13924 {
13925 // nothing to do
13926 }
13927 else
13928 {
13929 hc_cuModuleLoad (&device_param->module_amp, module_amp_file);
13930
13931 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_amp_file);
13932 }
13933
13934 /**
13935 * module functions
13936 */
13937
13938 char module_name[64];
13939
13940 memset (module_name, 0, sizeof (module_name));
13941
13942 if (attack_exec == ATTACK_EXEC_ON_GPU)
13943 {
13944 if (opti_type & OPTI_TYPE_SINGLE_HASH)
13945 {
13946 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 4);
13947
13948 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
13949
13950 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 8);
13951
13952 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
13953
13954 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 16);
13955
13956 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
13957 }
13958 else
13959 {
13960 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 4);
13961
13962 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
13963
13964 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 8);
13965
13966 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
13967
13968 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 16);
13969
13970 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
13971 }
13972
13973 if (attack_mode == ATTACK_MODE_BF)
13974 {
13975 if (opts_type & OPTS_TYPE_PT_BITSLICE)
13976 {
13977 snprintf (module_name, sizeof (module_name) - 1, "m%05d_tb", kern_type);
13978
13979 hc_cuModuleGetFunction (&device_param->function_tb, device_param->module, module_name);
13980
13981 snprintf (module_name, sizeof (module_name) - 1, "m%05d_tm", kern_type);
13982
13983 hc_cuModuleGetFunction (&device_param->function_tm, device_param->module, module_name);
13984 }
13985 }
13986 }
13987 else
13988 {
13989 snprintf (module_name, sizeof (module_name) - 1, "m%05d_init", kern_type);
13990
13991 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
13992
13993 snprintf (module_name, sizeof (module_name) - 1, "m%05d_loop", kern_type);
13994
13995 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
13996
13997 snprintf (module_name, sizeof (module_name) - 1, "m%05d_comp", kern_type);
13998
13999 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
14000
14001 if (opts_type & OPTS_TYPE_HOOK12)
14002 {
14003 snprintf (module_name, sizeof (module_name) - 1, "m%05d_hook12", kern_type);
14004
14005 hc_cuModuleGetFunction (&device_param->function12, device_param->module, module_name);
14006 }
14007
14008 if (opts_type & OPTS_TYPE_HOOK23)
14009 {
14010 snprintf (module_name, sizeof (module_name) - 1, "m%05d_hook23", kern_type);
14011
14012 hc_cuModuleGetFunction (&device_param->function23, device_param->module, module_name);
14013 }
14014 }
14015
14016 if (attack_mode == ATTACK_MODE_BF)
14017 {
14018 hc_cuModuleGetFunction (&device_param->function_mp_l, device_param->module_mp, "l_markov");
14019 hc_cuModuleGetFunction (&device_param->function_mp_r, device_param->module_mp, "r_markov");
14020 }
14021 else if (attack_mode == ATTACK_MODE_HYBRID1)
14022 {
14023 hc_cuModuleGetFunction (&device_param->function_mp, device_param->module_mp, "C_markov");
14024 }
14025 else if (attack_mode == ATTACK_MODE_HYBRID2)
14026 {
14027 hc_cuModuleGetFunction (&device_param->function_mp, device_param->module_mp, "C_markov");
14028 }
14029
14030 /**
14031 * amplifiers are not independant
14032 */
14033
14034 if (attack_exec == ATTACK_EXEC_ON_GPU)
14035 {
14036 // nothing to do
14037 }
14038 else
14039 {
14040 hc_cuModuleGetFunction (&device_param->function_amp, device_param->module_amp, "amp");
14041 }
14042
14043 /**
14044 * global buffers
14045 */
14046
14047 hc_cuMemAlloc (&device_param->d_pws_buf, size_pws);
14048 hc_cuMemAlloc (&device_param->d_pws_amp_buf, size_pws);
14049 hc_cuMemAlloc (&device_param->d_tmps, size_tmps);
14050 hc_cuMemAlloc (&device_param->d_hooks, size_hooks);
14051 hc_cuMemAlloc (&device_param->d_bitmap_s1_a, bitmap_size);
14052 hc_cuMemAlloc (&device_param->d_bitmap_s1_b, bitmap_size);
14053 hc_cuMemAlloc (&device_param->d_bitmap_s1_c, bitmap_size);
14054 hc_cuMemAlloc (&device_param->d_bitmap_s1_d, bitmap_size);
14055 hc_cuMemAlloc (&device_param->d_bitmap_s2_a, bitmap_size);
14056 hc_cuMemAlloc (&device_param->d_bitmap_s2_b, bitmap_size);
14057 hc_cuMemAlloc (&device_param->d_bitmap_s2_c, bitmap_size);
14058 hc_cuMemAlloc (&device_param->d_bitmap_s2_d, bitmap_size);
14059 hc_cuMemAlloc (&device_param->d_plain_bufs, size_plains);
14060 hc_cuMemAlloc (&device_param->d_digests_buf, size_digests);
14061 hc_cuMemAlloc (&device_param->d_digests_shown, size_shown);
14062 hc_cuMemAlloc (&device_param->d_salt_bufs, size_salts);
14063 hc_cuMemAlloc (&device_param->d_result, size_results);
14064 hc_cuMemAlloc (&device_param->d_scryptV_buf, size_scryptV);
14065
14066 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_a, bitmap_s1_a, bitmap_size);
14067 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_b, bitmap_s1_b, bitmap_size);
14068 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_c, bitmap_s1_c, bitmap_size);
14069 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_d, bitmap_s1_d, bitmap_size);
14070 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_a, bitmap_s2_a, bitmap_size);
14071 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_b, bitmap_s2_b, bitmap_size);
14072 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_c, bitmap_s2_c, bitmap_size);
14073 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_d, bitmap_s2_d, bitmap_size);
14074 hc_cuMemcpyHtoD (device_param->d_digests_buf, data.digests_buf, size_digests);
14075 hc_cuMemcpyHtoD (device_param->d_digests_shown, data.digests_shown, size_shown);
14076 hc_cuMemcpyHtoD (device_param->d_salt_bufs, data.salts_buf, size_salts);
14077
14078 run_kernel_bzero (device_param, device_param->d_pws_buf, size_pws);
14079 run_kernel_bzero (device_param, device_param->d_pws_amp_buf, size_pws);
14080 run_kernel_bzero (device_param, device_param->d_tmps, size_tmps);
14081 run_kernel_bzero (device_param, device_param->d_hooks, size_hooks);
14082 run_kernel_bzero (device_param, device_param->d_plain_bufs, size_plains);
14083 run_kernel_bzero (device_param, device_param->d_result, size_results);
14084
14085 /**
14086 * special buffers
14087 */
14088
14089 if (attack_kern == ATTACK_KERN_STRAIGHT)
14090 {
14091 hc_cuMemAlloc (&device_param->d_rules, size_rules);
14092
14093 hc_cuMemcpyHtoD (device_param->d_rules, gpu_rules_buf, size_rules);
14094 }
14095 else if (attack_kern == ATTACK_KERN_COMBI)
14096 {
14097 hc_cuMemAlloc (&device_param->d_combs, size_combs);
14098 hc_cuMemAlloc (&device_param->d_root_css_buf, size_root_css);
14099 hc_cuMemAlloc (&device_param->d_markov_css_buf, size_markov_css);
14100
14101 run_kernel_bzero (device_param, device_param->d_combs, size_combs);
14102 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
14103 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
14104 }
14105 else if (attack_kern == ATTACK_KERN_BF)
14106 {
14107 hc_cuMemAlloc (&device_param->d_bfs, size_bfs);
14108 hc_cuMemAlloc (&device_param->d_tm, size_tm);
14109 hc_cuMemAlloc (&device_param->d_root_css_buf, size_root_css);
14110 hc_cuMemAlloc (&device_param->d_markov_css_buf, size_markov_css);
14111
14112 run_kernel_bzero (device_param, device_param->d_bfs, size_bfs);
14113 run_kernel_bzero (device_param, device_param->d_tm, size_tm);
14114 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
14115 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
14116 }
14117
14118 if (size_esalts)
14119 {
14120 hc_cuMemAlloc (&device_param->d_esalt_bufs, size_esalts);
14121
14122 hc_cuMemcpyHtoD (device_param->d_esalt_bufs, data.esalts_buf, size_esalts);
14123 }
14124
14125 /**
14126 * main host data
14127 */
14128
14129 uint *result = (uint *) mymalloc (size_results);
14130
14131 memset (result, 0, size_results);
14132
14133 device_param->result = result;
14134
14135 pw_t *pws_buf = (pw_t *) mymalloc (size_pws);
14136
14137 memset (pws_buf, 0, size_pws);
14138
14139 device_param->pws_buf = pws_buf;
14140
14141 pw_cache_t *pw_caches = (pw_cache_t *) mycalloc (64, sizeof (pw_cache_t));
14142
14143 for (int i = 0; i < 64; i++)
14144 {
14145 pw_caches[i].pw_buf.pw_len = i;
14146 pw_caches[i].cnt = 0;
14147 }
14148
14149 device_param->pw_caches = pw_caches;
14150
14151 comb_t *combs_buf = (comb_t *) mycalloc (GPU_COMBS, sizeof (comb_t));
14152
14153 device_param->combs_buf = combs_buf;
14154
14155 void *hooks_buf = mymalloc (size_hooks);
14156
14157 device_param->hooks_buf = hooks_buf;
14158
14159 switch (device_param->gpu_vector_width)
14160 {
14161 case 1: device_param->pw_transpose = pw_transpose_to_hi1;
14162 device_param->pw_add = pw_add_to_hc1;
14163 break;
14164 case 2: device_param->pw_transpose = pw_transpose_to_hi2;
14165 device_param->pw_add = pw_add_to_hc2;
14166 break;
14167 case 4: device_param->pw_transpose = pw_transpose_to_hi4;
14168 device_param->pw_add = pw_add_to_hc4;
14169 break;
14170 }
14171
14172 /**
14173 * module args
14174 */
14175
14176 device_param->kernel_params_buf32[21] = bitmap_mask;
14177 device_param->kernel_params_buf32[22] = bitmap_shift1;
14178 device_param->kernel_params_buf32[23] = bitmap_shift2;
14179 device_param->kernel_params_buf32[24] = 0; // salt_pos
14180 device_param->kernel_params_buf32[25] = 0; // loop_pos
14181 device_param->kernel_params_buf32[26] = 0; // loop_cnt
14182 device_param->kernel_params_buf32[27] = 0; // gpu_rules_cnt
14183 device_param->kernel_params_buf32[28] = 0; // digests_cnt
14184 device_param->kernel_params_buf32[29] = 0; // digests_offset
14185 device_param->kernel_params_buf32[30] = 0; // combs_mode
14186 device_param->kernel_params_buf32[31] = 0; // gid_max
14187
14188 device_param->kernel_params[ 0] = (attack_exec == ATTACK_EXEC_ON_GPU)
14189 ? &device_param->d_pws_buf
14190 : &device_param->d_pws_amp_buf;
14191 device_param->kernel_params[ 1] = &device_param->d_rules;
14192 device_param->kernel_params[ 2] = &device_param->d_combs;
14193 device_param->kernel_params[ 3] = &device_param->d_bfs;
14194 device_param->kernel_params[ 4] = &device_param->d_tmps;
14195 device_param->kernel_params[ 5] = &device_param->d_hooks;
14196 device_param->kernel_params[ 6] = &device_param->d_bitmap_s1_a;
14197 device_param->kernel_params[ 7] = &device_param->d_bitmap_s1_b;
14198 device_param->kernel_params[ 8] = &device_param->d_bitmap_s1_c;
14199 device_param->kernel_params[ 9] = &device_param->d_bitmap_s1_d;
14200 device_param->kernel_params[10] = &device_param->d_bitmap_s2_a;
14201 device_param->kernel_params[11] = &device_param->d_bitmap_s2_b;
14202 device_param->kernel_params[12] = &device_param->d_bitmap_s2_c;
14203 device_param->kernel_params[13] = &device_param->d_bitmap_s2_d;
14204 device_param->kernel_params[14] = &device_param->d_plain_bufs;
14205 device_param->kernel_params[15] = &device_param->d_digests_buf;
14206 device_param->kernel_params[16] = &device_param->d_digests_shown;
14207 device_param->kernel_params[17] = &device_param->d_salt_bufs;
14208 device_param->kernel_params[18] = &device_param->d_esalt_bufs;
14209 device_param->kernel_params[19] = &device_param->d_result;
14210 device_param->kernel_params[20] = &device_param->d_scryptV_buf;
14211 device_param->kernel_params[21] = &device_param->kernel_params_buf32[21];
14212 device_param->kernel_params[22] = &device_param->kernel_params_buf32[22];
14213 device_param->kernel_params[23] = &device_param->kernel_params_buf32[23];
14214 device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
14215 device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
14216 device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
14217 device_param->kernel_params[27] = &device_param->kernel_params_buf32[27];
14218 device_param->kernel_params[28] = &device_param->kernel_params_buf32[28];
14219 device_param->kernel_params[29] = &device_param->kernel_params_buf32[29];
14220 device_param->kernel_params[30] = &device_param->kernel_params_buf32[30];
14221 device_param->kernel_params[31] = &device_param->kernel_params_buf32[31];
14222
14223 device_param->kernel_params_mp_buf64[3] = 0;
14224 device_param->kernel_params_mp_buf32[4] = 0;
14225 device_param->kernel_params_mp_buf32[5] = 0;
14226 device_param->kernel_params_mp_buf32[6] = 0;
14227 device_param->kernel_params_mp_buf32[7] = 0;
14228 device_param->kernel_params_mp_buf32[8] = 0;
14229
14230 device_param->kernel_params_mp[0] = NULL;
14231 device_param->kernel_params_mp[1] = NULL;
14232 device_param->kernel_params_mp[2] = NULL;
14233 device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];
14234 device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4];
14235 device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5];
14236 device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6];
14237 device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7];
14238 device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf32[8];
14239
14240 device_param->kernel_params_mp_l_buf64[3] = 0;
14241 device_param->kernel_params_mp_l_buf32[4] = 0;
14242 device_param->kernel_params_mp_l_buf32[5] = 0;
14243 device_param->kernel_params_mp_l_buf32[6] = 0;
14244 device_param->kernel_params_mp_l_buf32[7] = 0;
14245 device_param->kernel_params_mp_l_buf32[8] = 0;
14246 device_param->kernel_params_mp_l_buf32[9] = 0;
14247
14248 device_param->kernel_params_mp_l[0] = NULL;
14249 device_param->kernel_params_mp_l[1] = NULL;
14250 device_param->kernel_params_mp_l[2] = NULL;
14251 device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3];
14252 device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4];
14253 device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5];
14254 device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6];
14255 device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7];
14256 device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8];
14257 device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf32[9];
14258
14259 device_param->kernel_params_mp_r_buf64[3] = 0;
14260 device_param->kernel_params_mp_r_buf32[4] = 0;
14261 device_param->kernel_params_mp_r_buf32[5] = 0;
14262 device_param->kernel_params_mp_r_buf32[6] = 0;
14263 device_param->kernel_params_mp_r_buf32[7] = 0;
14264 device_param->kernel_params_mp_r_buf32[8] = 0;
14265
14266 device_param->kernel_params_mp_r[0] = NULL;
14267 device_param->kernel_params_mp_r[1] = NULL;
14268 device_param->kernel_params_mp_r[2] = NULL;
14269 device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3];
14270 device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4];
14271 device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5];
14272 device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6];
14273 device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7];
14274 device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf32[8];
14275
14276 device_param->kernel_params_amp_buf32[5] = 0; // combs_mode
14277 device_param->kernel_params_amp_buf32[6] = 0; // gid_max
14278
14279 device_param->kernel_params_amp[0] = &device_param->d_pws_buf;
14280 device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf;
14281 device_param->kernel_params_amp[2] = &device_param->d_rules;
14282 device_param->kernel_params_amp[3] = &device_param->d_combs;
14283 device_param->kernel_params_amp[4] = &device_param->d_bfs;
14284 device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5];
14285 device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf32[6];
14286
14287 device_param->kernel_params_tb[0] = &device_param->d_pws_buf;
14288
14289 device_param->kernel_params_tm[0] = &device_param->d_bfs;
14290 device_param->kernel_params_tm[1] = &device_param->d_tm;
14291
14292 /* constant memory init */
14293
14294 CUmodule c_module;
14295
14296 if (attack_exec == ATTACK_EXEC_ON_GPU)
14297 {
14298 c_module = device_param->module;
14299 }
14300 else
14301 {
14302 c_module = device_param->module_amp;
14303 }
14304
14305 size_t c_bytes;
14306
14307 if (attack_kern == ATTACK_KERN_STRAIGHT)
14308 {
14309 CUdeviceptr c_rules;
14310
14311 hc_cuModuleGetGlobal (&c_rules, &c_bytes, c_module, "c_rules");
14312
14313 device_param->c_rules = c_rules;
14314 device_param->c_bytes = c_bytes;
14315
14316 hc_cuMemsetD8 (c_rules, 0, c_bytes);
14317 }
14318 else if (attack_kern == ATTACK_KERN_COMBI)
14319 {
14320 CUdeviceptr c_combs;
14321
14322 hc_cuModuleGetGlobal (&c_combs, &c_bytes, c_module, "c_combs");
14323
14324 device_param->c_combs = c_combs;
14325 device_param->c_bytes = c_bytes;
14326
14327 hc_cuMemsetD8 (c_combs, 0, c_bytes);
14328 }
14329 else if (attack_kern == ATTACK_KERN_BF)
14330 {
14331 CUdeviceptr c_bfs;
14332
14333 hc_cuModuleGetGlobal (&c_bfs, &c_bytes, c_module, "c_bfs");
14334
14335 device_param->c_bfs = c_bfs;
14336 device_param->c_bytes = c_bytes;
14337
14338 hc_cuMemsetD8 (c_bfs, 0, c_bytes);
14339
14340 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
14341 {
14342 size_t bytes;
14343
14344 CUdeviceptr c_tm;
14345
14346 hc_cuModuleGetGlobal (&c_tm, &bytes, c_module, "c_tm");
14347
14348 device_param->c_tm = c_tm;
14349
14350 hc_cuMemsetD8 (c_tm, 0, bytes);
14351 }
14352 }
14353
14354 hc_cuCtxPopCurrent (NULL);
14355 }
14356
14357 #elif _OCL
14358 for (uint device_id = 0; device_id < devices_cnt; device_id++)
14359 {
14360 /**
14361 * host buffer
14362 */
14363
14364 hc_device_param_t *device_param = &data.devices_param[device_id];
14365
14366 /**
14367 * device properties
14368 */
14369
14370 char *device_name = device_param->device_name;
14371 char *device_version = device_param->device_version;
14372 char *driver_version = device_param->driver_version;
14373
14374 uint gpu_processors = device_param->gpu_processors;
14375 uint gpu_vector_width = device_param->gpu_vector_width;
14376
14377 /**
14378 * create context for each device
14379 */
14380
14381 device_param->context = hc_clCreateContext (NULL, 1, &device_param->device, NULL, NULL);
14382
14383 /**
14384 * create command-queue
14385 */
14386
14387 device_param->command_queue = hc_clCreateCommandQueueWithProperties (device_param->context, device_param->device, NULL);
14388
14389 /**
14390 * create input buffers on device
14391 */
14392
14393 uint gpu_threads = GPU_THREADS_AMD;
14394
14395 if (hash_mode == 3200) gpu_threads = 8;
14396 if (hash_mode == 9000) gpu_threads = 8;
14397
14398 uint gpu_power = gpu_processors * gpu_threads * gpu_accel;
14399
14400 uint gpu_blocks = gpu_power * gpu_vector_width;
14401
14402 device_param->gpu_threads = gpu_threads;
14403 device_param->gpu_power_user = gpu_power;
14404 device_param->gpu_blocks_user = gpu_blocks;
14405
14406 gpu_blocks_all += gpu_blocks;
14407
14408 uint size_pws = gpu_power * sizeof (pw_t);
14409
14410 uint size_tmps = 4;
14411
14412 switch (hash_mode)
14413 {
14414 case 400: size_tmps = gpu_blocks * sizeof (phpass_tmp_t); break;
14415 case 500: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14416 case 501: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14417 case 1600: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14418 case 1800: size_tmps = gpu_blocks * sizeof (sha512crypt_tmp_t); break;
14419 case 2100: size_tmps = gpu_blocks * sizeof (dcc2_tmp_t); break;
14420 case 2500: size_tmps = gpu_blocks * sizeof (wpa_tmp_t); break;
14421 case 3200: size_tmps = gpu_blocks * sizeof (bcrypt_tmp_t); break;
14422 case 5200: size_tmps = gpu_blocks * sizeof (pwsafe3_tmp_t); break;
14423 case 5800: size_tmps = gpu_blocks * sizeof (androidpin_tmp_t); break;
14424 case 6211:
14425 case 6212:
14426 case 6213: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14427 case 6221:
14428 case 6222:
14429 case 6223: size_tmps = gpu_blocks * sizeof (tc64_tmp_t); break;
14430 case 6231:
14431 case 6232:
14432 case 6233: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14433 case 6241:
14434 case 6242:
14435 case 6243: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14436 case 6300: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14437 case 6400: size_tmps = gpu_blocks * sizeof (sha256aix_tmp_t); break;
14438 case 6500: size_tmps = gpu_blocks * sizeof (sha512aix_tmp_t); break;
14439 case 6600: size_tmps = gpu_blocks * sizeof (agilekey_tmp_t); break;
14440 case 6700: size_tmps = gpu_blocks * sizeof (sha1aix_tmp_t); break;
14441 case 6800: size_tmps = gpu_blocks * sizeof (lastpass_tmp_t); break;
14442 case 7100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14443 case 7200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14444 case 7400: size_tmps = gpu_blocks * sizeof (sha256crypt_tmp_t); break;
14445 case 7900: size_tmps = gpu_blocks * sizeof (drupal7_tmp_t); break;
14446 case 8200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14447 case 8800: size_tmps = gpu_blocks * sizeof (androidfde_tmp_t); break;
14448 case 8900: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
14449 case 9000: size_tmps = gpu_blocks * sizeof (pwsafe2_tmp_t); break;
14450 case 9100: size_tmps = gpu_blocks * sizeof (lotus8_tmp_t); break;
14451 case 9200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14452 case 9300: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
14453 case 9400: size_tmps = gpu_blocks * sizeof (office2007_tmp_t); break;
14454 case 9500: size_tmps = gpu_blocks * sizeof (office2010_tmp_t); break;
14455 case 9600: size_tmps = gpu_blocks * sizeof (office2013_tmp_t); break;
14456 case 10000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14457 case 10200: size_tmps = gpu_blocks * sizeof (cram_md5_t); break;
14458 case 10300: size_tmps = gpu_blocks * sizeof (saph_sha1_tmp_t); break;
14459 case 10500: size_tmps = gpu_blocks * sizeof (pdf14_tmp_t); break;
14460 case 10700: size_tmps = gpu_blocks * sizeof (pdf17l8_tmp_t); break;
14461 case 10900: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14462 case 11300: size_tmps = gpu_blocks * sizeof (bitcoin_wallet_tmp_t); break;
14463 case 11600: size_tmps = gpu_blocks * sizeof (seven_zip_tmp_t); break;
14464 case 11900: size_tmps = gpu_blocks * sizeof (pbkdf2_md5_tmp_t); break;
14465 case 12000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha1_tmp_t); break;
14466 case 12100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14467 case 12200: size_tmps = gpu_blocks * sizeof (ecryptfs_tmp_t); break;
14468 case 12300: size_tmps = gpu_blocks * sizeof (oraclet_tmp_t); break;
14469 case 12400: size_tmps = gpu_blocks * sizeof (bsdicrypt_tmp_t); break;
14470 case 12500: size_tmps = gpu_blocks * sizeof (rar3_tmp_t); break;
14471 case 12700: size_tmps = gpu_blocks * sizeof (mywallet_tmp_t); break;
14472 case 12800: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14473 };
14474
14475 uint size_hooks = 4;
14476
14477 if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23))
14478 {
14479 // insert correct hook size
14480 }
14481
14482 // we can optimize some stuff here...
14483
14484 device_param->size_pws = size_pws;
14485 device_param->size_tmps = size_tmps;
14486 device_param->size_hooks = size_hooks;
14487
14488 uint size_root_css = SP_PW_MAX * sizeof (cs_t);
14489 uint size_markov_css = SP_PW_MAX * CHARSIZ * sizeof (cs_t);
14490
14491 device_param->size_root_css = size_root_css;
14492 device_param->size_markov_css = size_markov_css;
14493
14494 uint size_results = GPU_THREADS_AMD * sizeof (uint);
14495
14496 device_param->size_results = size_results;
14497
14498 uint size_rules = gpu_rules_cnt * sizeof (gpu_rule_t);
14499 uint size_rules_c = GPU_RULES * sizeof (gpu_rule_t);
14500 uint size_plains = digests_cnt * sizeof (plain_t);
14501 uint size_salts = salts_cnt * sizeof (salt_t);
14502 uint size_esalts = salts_cnt * esalt_size;
14503
14504 device_param->size_plains = size_plains;
14505 device_param->size_digests = size_digests;
14506 device_param->size_shown = size_shown;
14507 device_param->size_salts = size_salts;
14508
14509 uint size_combs = GPU_COMBS * sizeof (comb_t);
14510 uint size_bfs = GPU_BFS * sizeof (bf_t);
14511 uint size_tm = 32 * sizeof (bs_word_t);
14512
14513 uint64_t size_scryptV = 1;
14514
14515 if ((hash_mode == 8900) || (hash_mode == 9300))
14516 {
14517 #define SHADER_PER_MP 8
14518 #define WAVEFRONTS 64
14519
14520 uint tmto_start = 2;
14521 uint tmto_stop = 1024;
14522
14523 if (scrypt_tmto)
14524 {
14525 tmto_start = 1 << scrypt_tmto;
14526 tmto_stop = tmto_start + 1;
14527 }
14528
14529 for (uint tmto = tmto_start; tmto < tmto_stop; tmto <<= 1)
14530 {
14531 // todo -- make sure all salts get the new tmto value
14532
14533 size_scryptV = (128 * data.salts_buf[0].scrypt_r) * data.salts_buf[0].scrypt_N;
14534
14535 size_scryptV /= tmto;
14536
14537 size_scryptV *= gpu_processors * WAVEFRONTS * SHADER_PER_MP;
14538
14539 if (size_scryptV > (device_param->gpu_maxmem_alloc / 2)) continue;
14540
14541 for (uint salts_pos = 0; salts_pos < data.salts_cnt; salts_pos++)
14542 {
14543 data.salts_buf[salts_pos].scrypt_tmto = tmto;
14544 data.salts_buf[salts_pos].scrypt_phy = gpu_processors * WAVEFRONTS * SHADER_PER_MP;
14545 }
14546
14547 break;
14548 }
14549
14550 if (data.salts_buf[0].scrypt_tmto == 0)
14551 {
14552 log_error ("ERROR: can't allocate enough GPU memory");
14553
14554 return -1;
14555 }
14556
14557 if (quiet == 0) log_info ("");
14558 if (quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u\n", data.salts_buf[0].scrypt_tmto);
14559 }
14560
14561 /**
14562 * kernel find
14563 */
14564
14565 uint vliw = get_vliw_by_device_name (device_name);
14566
14567 struct stat st;
14568
14569 char kernel_file[256];
14570
14571 memset (kernel_file, 0, sizeof (kernel_file));
14572
14573 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
14574
14575 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14576
14577 #ifdef BINARY_KERNEL
14578 if (attack_exec == ATTACK_EXEC_ON_GPU)
14579 {
14580 if (attack_kern == ATTACK_KERN_STRAIGHT)
14581 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);
14582 else if (attack_kern == ATTACK_KERN_COMBI)
14583 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);
14584 else if (attack_kern == ATTACK_KERN_BF)
14585 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);
14586 }
14587 else
14588 {
14589 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);
14590
14591 if ((hash_mode == 8900) || (hash_mode == 9300))
14592 {
14593 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);
14594 }
14595 }
14596
14597 if (stat (kernel_file, &st) == -1)
14598 {
14599 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_file);
14600
14601 char module_file[256];
14602
14603 memset (module_file, 0, sizeof (module_file));
14604
14605 if (attack_exec == ATTACK_EXEC_ON_GPU)
14606 {
14607 if (attack_kern == ATTACK_KERN_STRAIGHT)
14608 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a0.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14609 else if (attack_kern == ATTACK_KERN_COMBI)
14610 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a1.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14611 else if (attack_kern == ATTACK_KERN_BF)
14612 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a3.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14613 }
14614 else
14615 {
14616 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14617
14618 if ((hash_mode == 8900) || (hash_mode == 9300))
14619 {
14620 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);
14621 }
14622 }
14623
14624 load_kernel (module_file, 1, kernel_lengths, kernel_sources);
14625
14626 cl_program program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
14627
14628 local_free (kernel_sources[0]);
14629
14630 hc_clBuildProgram (program, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14631
14632 size_t binary_size;
14633
14634 clGetProgramInfo (program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
14635
14636 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
14637
14638 clGetProgramInfo (program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
14639
14640 writeProgramBin (kernel_file, binary, binary_size);
14641
14642 local_free (binary);
14643
14644 stat (kernel_file, &st); // to reload filesize
14645 }
14646
14647 #else
14648 if (attack_exec == ATTACK_EXEC_ON_GPU)
14649 {
14650 if (attack_kern == ATTACK_KERN_STRAIGHT)
14651 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a0.cl", install_dir, (int) kern_type);
14652 else if (attack_kern == ATTACK_KERN_COMBI)
14653 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a1.cl", install_dir, (int) kern_type);
14654 else if (attack_kern == ATTACK_KERN_BF)
14655 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a3.cl", install_dir, (int) kern_type);
14656 }
14657 else
14658 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d.cl", install_dir, (int) kern_type);
14659
14660 if (stat (kernel_file, &st) == -1)
14661 {
14662 log_error ("ERROR: %s: %s", kernel_file, strerror (errno));
14663
14664 return -1;
14665 }
14666
14667 #endif
14668
14669 load_kernel (kernel_file, 1, kernel_lengths, kernel_sources);
14670
14671 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_file, st.st_size);
14672
14673 #ifdef BINARY_KERNEL
14674 device_param->program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
14675 #else
14676 device_param->program = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
14677 #endif
14678
14679 local_free (kernel_lengths);
14680
14681 local_free (kernel_sources[0]);
14682
14683 local_free (kernel_sources)
14684
14685 /**
14686 * kernel mp find
14687 */
14688
14689 if (attack_mode != ATTACK_MODE_STRAIGHT)
14690 {
14691 char kernel_mp_file[256];
14692
14693 memset (kernel_mp_file, 0, sizeof (kernel_mp_file));
14694
14695 size_t *kernel_mp_lengths = (size_t *) mymalloc (sizeof (size_t));
14696
14697 const unsigned char **kernel_mp_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14698
14699 #ifdef BINARY_KERNEL
14700 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14701 {
14702 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);
14703 }
14704 else
14705 {
14706 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);
14707 }
14708
14709 if (stat (kernel_mp_file, &st) == -1)
14710 {
14711 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_mp_file);
14712
14713 char module_mp_file[256];
14714
14715 memset (module_mp_file, 0, sizeof (module_mp_file));
14716
14717 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14718 {
14719 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4098/markov_be_v%d.llvmir", install_dir, gpu_vector_width);
14720 }
14721 else
14722 {
14723 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4098/markov_le_v%d.llvmir", install_dir, gpu_vector_width);
14724 }
14725
14726 load_kernel (module_mp_file, 1, kernel_mp_lengths, kernel_mp_sources);
14727
14728 cl_program program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_mp_lengths, (const unsigned char **) kernel_mp_sources, NULL);
14729
14730 local_free (kernel_mp_sources[0]);
14731
14732 hc_clBuildProgram (program_mp, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14733
14734 size_t binary_mp_size;
14735
14736 clGetProgramInfo (program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_mp_size, NULL);
14737
14738 unsigned char *binary_mp = (unsigned char *) mymalloc (binary_mp_size);
14739
14740 clGetProgramInfo (program_mp, CL_PROGRAM_BINARIES, sizeof (binary_mp), &binary_mp, NULL);
14741
14742 writeProgramBin (kernel_mp_file, binary_mp, binary_mp_size);
14743
14744 local_free (binary_mp);
14745
14746 stat (kernel_mp_file, &st); // to reload filesize
14747 }
14748
14749 #else
14750 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14751 {
14752 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/amd/markov_be_v%d.cl", install_dir, gpu_vector_width);
14753 }
14754 else
14755 {
14756 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/amd/markov_le_v%d.cl", install_dir, gpu_vector_width);
14757 }
14758
14759 if (stat (kernel_mp_file, &st) == -1)
14760 {
14761 log_error ("ERROR: %s: %s", kernel_mp_file, strerror (errno));
14762
14763 return -1;
14764 }
14765
14766 #endif
14767
14768 load_kernel (kernel_mp_file, 1, kernel_mp_lengths, kernel_mp_sources);
14769
14770 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_mp_file, st.st_size);
14771
14772 #ifdef BINARY_KERNEL
14773 device_param->program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_mp_lengths, (const unsigned char **) kernel_mp_sources, NULL);
14774 #else
14775 device_param->program_mp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_mp_sources, NULL);
14776 #endif
14777
14778 local_free (kernel_mp_lengths);
14779
14780 local_free (kernel_mp_sources[0]);
14781
14782 local_free (kernel_mp_sources);
14783 }
14784
14785 /**
14786 * kernel amp find
14787 */
14788
14789 if (attack_exec == ATTACK_EXEC_ON_GPU)
14790 {
14791 // nothing to do
14792 }
14793 else
14794 {
14795 char kernel_amp_file[256];
14796
14797 memset (kernel_amp_file, 0, sizeof (kernel_amp_file));
14798
14799 size_t *kernel_amp_lengths = (size_t *) mymalloc (sizeof (size_t));
14800
14801 const unsigned char **kernel_amp_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14802
14803 #ifdef BINARY_KERNEL
14804 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);
14805
14806 if (stat (kernel_amp_file, &st) == -1)
14807 {
14808 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_amp_file);
14809
14810 char module_amp_file[256];
14811
14812 memset (module_amp_file, 0, sizeof (module_amp_file));
14813
14814 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);
14815
14816 load_kernel (module_amp_file, 1, kernel_amp_lengths, kernel_amp_sources);
14817
14818 cl_program program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_amp_lengths, (const unsigned char **) kernel_amp_sources, NULL);
14819
14820 local_free (kernel_amp_sources[0]);
14821
14822 hc_clBuildProgram (program_amp, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14823
14824 size_t binary_amp_size;
14825
14826 clGetProgramInfo (program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_amp_size, NULL);
14827
14828 unsigned char *binary_amp = (unsigned char *) mymalloc (binary_amp_size);
14829
14830 clGetProgramInfo (program_amp, CL_PROGRAM_BINARIES, sizeof (binary_amp), &binary_amp, NULL);
14831
14832 writeProgramBin (kernel_amp_file, binary_amp, binary_amp_size);
14833
14834 local_free (binary_amp);
14835
14836 stat (kernel_amp_file, &st); // to reload filesize
14837 }
14838 #else
14839 snprintf (kernel_amp_file, sizeof (kernel_amp_file) - 1, "%s/amd/amp_a%d_v%d.cl", install_dir, attack_kern, gpu_vector_width);
14840
14841 if (stat (kernel_amp_file, &st) == -1)
14842 {
14843 log_error ("ERROR: %s: %s", kernel_amp_file, strerror (errno));
14844
14845 return -1;
14846 }
14847 #endif
14848
14849 load_kernel (kernel_amp_file, 1, kernel_amp_lengths, kernel_amp_sources);
14850
14851 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_amp_file, st.st_size);
14852
14853 #ifdef BINARY_KERNEL
14854 device_param->program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_amp_lengths, (const unsigned char **) kernel_amp_sources, NULL);
14855 #else
14856 device_param->program_amp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_amp_sources, NULL);
14857 #endif
14858
14859 local_free (kernel_amp_lengths);
14860
14861 local_free (kernel_amp_sources[0]);
14862
14863 local_free (kernel_amp_sources);
14864 }
14865
14866 /**
14867 * kernel compile
14868 */
14869
14870 char *build_opts = NULL;
14871
14872 #ifndef BINARY_KERNEL
14873 build_opts = (char *) mymalloc (256);
14874
14875 sprintf (build_opts, "-I . -I amd/ -D VLIW%d -x clc++ -cl-std=CL1.2", vliw);
14876
14877 if ((hash_mode == 8900) || (hash_mode == 9300))
14878 {
14879 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);
14880 }
14881 #endif
14882
14883 clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
14884
14885 size_t ret_val_size = 0;
14886
14887 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
14888
14889 if (ret_val_size > 1)
14890 {
14891 char *build_log = (char *) malloc (ret_val_size + 1);
14892
14893 memset (build_log, 0, ret_val_size + 1);
14894
14895 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
14896
14897 puts (build_log);
14898
14899 free (build_log);
14900 }
14901
14902 if (attack_mode != ATTACK_MODE_STRAIGHT)
14903 {
14904 hc_clBuildProgram (device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL);
14905 }
14906
14907 if (attack_exec == ATTACK_EXEC_ON_GPU)
14908 {
14909 // nothing to do
14910 }
14911 else
14912 {
14913 hc_clBuildProgram (device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL);
14914 }
14915
14916 /**
14917 * amp is not independent
14918 */
14919
14920 if (attack_exec == ATTACK_EXEC_ON_GPU)
14921 {
14922 // nothing to do
14923 }
14924 else
14925 {
14926 device_param->kernel_amp = hc_clCreateKernel (device_param->program_amp, "amp");
14927 }
14928
14929 /**
14930 * global buffers
14931 */
14932
14933 device_param->d_pws_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
14934 device_param->d_pws_amp_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
14935 device_param->d_tmps = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL);
14936 device_param->d_hooks = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL);
14937 device_param->d_bitmap_s1_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14938 device_param->d_bitmap_s1_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14939 device_param->d_bitmap_s1_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14940 device_param->d_bitmap_s1_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14941 device_param->d_bitmap_s2_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14942 device_param->d_bitmap_s2_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14943 device_param->d_bitmap_s2_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14944 device_param->d_bitmap_s2_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14945 device_param->d_plain_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_plains, NULL);
14946 device_param->d_digests_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_digests, NULL);
14947 device_param->d_digests_shown = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_shown, NULL);
14948 device_param->d_salt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_salts, NULL);
14949 device_param->d_result = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_results, NULL);
14950 device_param->d_scryptV_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_scryptV, NULL);
14951
14952 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_size, bitmap_s1_a, 0, NULL, NULL);
14953 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_size, bitmap_s1_b, 0, NULL, NULL);
14954 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_size, bitmap_s1_c, 0, NULL, NULL);
14955 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_size, bitmap_s1_d, 0, NULL, NULL);
14956 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_size, bitmap_s2_a, 0, NULL, NULL);
14957 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_size, bitmap_s2_b, 0, NULL, NULL);
14958 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_size, bitmap_s2_c, 0, NULL, NULL);
14959 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_size, bitmap_s2_d, 0, NULL, NULL);
14960 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, data.digests_buf, 0, NULL, NULL);
14961 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, data.digests_shown, 0, NULL, NULL);
14962 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, data.salts_buf, 0, NULL, NULL);
14963
14964 run_kernel_bzero (device_param, device_param->d_pws_buf, size_pws);
14965 run_kernel_bzero (device_param, device_param->d_pws_amp_buf, size_pws);
14966 run_kernel_bzero (device_param, device_param->d_tmps, size_tmps);
14967 run_kernel_bzero (device_param, device_param->d_hooks, size_hooks);
14968 run_kernel_bzero (device_param, device_param->d_plain_bufs, size_plains);
14969 run_kernel_bzero (device_param, device_param->d_result, size_results);
14970
14971 /**
14972 * special buffers
14973 */
14974
14975 if (attack_kern == ATTACK_KERN_STRAIGHT)
14976 {
14977 device_param->d_rules = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules, NULL);
14978 device_param->d_rules_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL);
14979
14980 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, gpu_rules_buf, 0, NULL, NULL);
14981
14982 run_kernel_bzero (device_param, device_param->d_rules_c, size_rules_c);
14983 }
14984 else if (attack_kern == ATTACK_KERN_COMBI)
14985 {
14986 device_param->d_combs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
14987 device_param->d_combs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
14988 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
14989 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
14990
14991 run_kernel_bzero (device_param, device_param->d_combs, size_combs);
14992 run_kernel_bzero (device_param, device_param->d_combs_c, size_combs);
14993 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
14994 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
14995 }
14996 else if (attack_kern == ATTACK_KERN_BF)
14997 {
14998 device_param->d_bfs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
14999 device_param->d_bfs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
15000 device_param->d_tm_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_tm, NULL);
15001 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
15002 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
15003
15004 run_kernel_bzero (device_param, device_param->d_bfs, size_bfs);
15005 run_kernel_bzero (device_param, device_param->d_bfs_c, size_bfs);
15006 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
15007 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
15008 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
15009 }
15010
15011 if (size_esalts)
15012 {
15013 device_param->d_esalt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL);
15014
15015 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, data.esalts_buf, 0, NULL, NULL);
15016 }
15017
15018 /**
15019 * main host data
15020 */
15021
15022 uint *result = (uint *) mymalloc (size_results);
15023
15024 memset (result, 0, size_results);
15025
15026 device_param->result = result;
15027
15028 pw_t *pws_buf = (pw_t *) mymalloc (size_pws);
15029
15030 memset (pws_buf, 0, size_pws);
15031
15032 device_param->pws_buf = pws_buf;
15033
15034 pw_cache_t *pw_caches = (pw_cache_t *) mycalloc (64, sizeof (pw_cache_t));
15035
15036 for (int i = 0; i < 64; i++)
15037 {
15038 pw_caches[i].pw_buf.pw_len = i;
15039 pw_caches[i].cnt = 0;
15040 }
15041
15042 device_param->pw_caches = pw_caches;
15043
15044 comb_t *combs_buf = (comb_t *) mycalloc (GPU_COMBS, sizeof (comb_t));
15045
15046 device_param->combs_buf = combs_buf;
15047
15048 void *hooks_buf = mymalloc (size_hooks);
15049
15050 device_param->hooks_buf = hooks_buf;
15051
15052 switch (device_param->gpu_vector_width)
15053 {
15054 case 1: device_param->pw_transpose = pw_transpose_to_hi1;
15055 device_param->pw_add = pw_add_to_hc1;
15056 break;
15057 case 2: device_param->pw_transpose = pw_transpose_to_hi2;
15058 device_param->pw_add = pw_add_to_hc2;
15059 break;
15060 case 4: device_param->pw_transpose = pw_transpose_to_hi4;
15061 device_param->pw_add = pw_add_to_hc4;
15062 break;
15063 }
15064
15065 /**
15066 * kernel args
15067 */
15068
15069 device_param->kernel_params_buf32[21] = bitmap_mask;
15070 device_param->kernel_params_buf32[22] = bitmap_shift1;
15071 device_param->kernel_params_buf32[23] = bitmap_shift2;
15072 device_param->kernel_params_buf32[24] = 0; // salt_pos
15073 device_param->kernel_params_buf32[25] = 0; // loop_pos
15074 device_param->kernel_params_buf32[26] = 0; // loop_cnt
15075 device_param->kernel_params_buf32[27] = 0; // gpu_rules_cnt
15076 device_param->kernel_params_buf32[28] = 0; // digests_cnt
15077 device_param->kernel_params_buf32[29] = 0; // digests_offset
15078 device_param->kernel_params_buf32[30] = 0; // combs_mode
15079 device_param->kernel_params_buf32[31] = 0; // gid_max
15080
15081 device_param->kernel_params[ 0] = (attack_exec == ATTACK_EXEC_ON_GPU)
15082 ? &device_param->d_pws_buf
15083 : &device_param->d_pws_amp_buf;
15084 device_param->kernel_params[ 1] = &device_param->d_rules_c;
15085 device_param->kernel_params[ 2] = &device_param->d_combs_c;
15086 device_param->kernel_params[ 3] = &device_param->d_bfs_c;
15087 device_param->kernel_params[ 4] = &device_param->d_tmps;
15088 device_param->kernel_params[ 5] = &device_param->d_hooks;
15089 device_param->kernel_params[ 6] = &device_param->d_bitmap_s1_a;
15090 device_param->kernel_params[ 7] = &device_param->d_bitmap_s1_b;
15091 device_param->kernel_params[ 8] = &device_param->d_bitmap_s1_c;
15092 device_param->kernel_params[ 9] = &device_param->d_bitmap_s1_d;
15093 device_param->kernel_params[10] = &device_param->d_bitmap_s2_a;
15094 device_param->kernel_params[11] = &device_param->d_bitmap_s2_b;
15095 device_param->kernel_params[12] = &device_param->d_bitmap_s2_c;
15096 device_param->kernel_params[13] = &device_param->d_bitmap_s2_d;
15097 device_param->kernel_params[14] = &device_param->d_plain_bufs;
15098 device_param->kernel_params[15] = &device_param->d_digests_buf;
15099 device_param->kernel_params[16] = &device_param->d_digests_shown;
15100 device_param->kernel_params[17] = &device_param->d_salt_bufs;
15101 device_param->kernel_params[18] = &device_param->d_esalt_bufs;
15102 device_param->kernel_params[19] = &device_param->d_result;
15103 device_param->kernel_params[20] = &device_param->d_scryptV_buf;
15104 device_param->kernel_params[21] = &device_param->kernel_params_buf32[21];
15105 device_param->kernel_params[22] = &device_param->kernel_params_buf32[22];
15106 device_param->kernel_params[23] = &device_param->kernel_params_buf32[23];
15107 device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
15108 device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
15109 device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
15110 device_param->kernel_params[27] = &device_param->kernel_params_buf32[27];
15111 device_param->kernel_params[28] = &device_param->kernel_params_buf32[28];
15112 device_param->kernel_params[29] = &device_param->kernel_params_buf32[29];
15113 device_param->kernel_params[30] = &device_param->kernel_params_buf32[30];
15114 device_param->kernel_params[31] = &device_param->kernel_params_buf32[31];
15115
15116 device_param->kernel_params_mp_buf64[3] = 0;
15117 device_param->kernel_params_mp_buf32[4] = 0;
15118 device_param->kernel_params_mp_buf32[5] = 0;
15119 device_param->kernel_params_mp_buf32[6] = 0;
15120 device_param->kernel_params_mp_buf32[7] = 0;
15121 device_param->kernel_params_mp_buf32[8] = 0;
15122
15123 device_param->kernel_params_mp[0] = NULL;
15124 device_param->kernel_params_mp[1] = NULL;
15125 device_param->kernel_params_mp[2] = NULL;
15126 device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];
15127 device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4];
15128 device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5];
15129 device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6];
15130 device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7];
15131 device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf32[8];
15132
15133 device_param->kernel_params_mp_l_buf64[3] = 0;
15134 device_param->kernel_params_mp_l_buf32[4] = 0;
15135 device_param->kernel_params_mp_l_buf32[5] = 0;
15136 device_param->kernel_params_mp_l_buf32[6] = 0;
15137 device_param->kernel_params_mp_l_buf32[7] = 0;
15138 device_param->kernel_params_mp_l_buf32[8] = 0;
15139 device_param->kernel_params_mp_l_buf32[9] = 0;
15140
15141 device_param->kernel_params_mp_l[0] = NULL;
15142 device_param->kernel_params_mp_l[1] = NULL;
15143 device_param->kernel_params_mp_l[2] = NULL;
15144 device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3];
15145 device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4];
15146 device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5];
15147 device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6];
15148 device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7];
15149 device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8];
15150 device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf32[9];
15151
15152 device_param->kernel_params_mp_r_buf64[3] = 0;
15153 device_param->kernel_params_mp_r_buf32[4] = 0;
15154 device_param->kernel_params_mp_r_buf32[5] = 0;
15155 device_param->kernel_params_mp_r_buf32[6] = 0;
15156 device_param->kernel_params_mp_r_buf32[7] = 0;
15157 device_param->kernel_params_mp_r_buf32[8] = 0;
15158
15159 device_param->kernel_params_mp_r[0] = NULL;
15160 device_param->kernel_params_mp_r[1] = NULL;
15161 device_param->kernel_params_mp_r[2] = NULL;
15162 device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3];
15163 device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4];
15164 device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5];
15165 device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6];
15166 device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7];
15167 device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf32[8];
15168
15169 device_param->kernel_params_amp_buf32[5] = 0; // combs_mode
15170 device_param->kernel_params_amp_buf32[6] = 0; // gid_max
15171
15172 device_param->kernel_params_amp[0] = &device_param->d_pws_buf;
15173 device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf;
15174 device_param->kernel_params_amp[2] = &device_param->d_rules_c;
15175 device_param->kernel_params_amp[3] = &device_param->d_combs_c;
15176 device_param->kernel_params_amp[4] = &device_param->d_bfs_c;
15177 device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5];
15178 device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf32[6];
15179
15180 device_param->kernel_params_tb[0] = &device_param->d_pws_buf;
15181
15182 device_param->kernel_params_tm[0] = &device_param->d_bfs_c;
15183 device_param->kernel_params_tm[1] = &device_param->d_tm_c;
15184
15185 /**
15186 * kernel name
15187 */
15188
15189 char kernel_name[64];
15190
15191 memset (kernel_name, 0, sizeof (kernel_name));
15192
15193 if (attack_exec == ATTACK_EXEC_ON_GPU)
15194 {
15195 if (opti_type & OPTI_TYPE_SINGLE_HASH)
15196 {
15197 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 4);
15198
15199 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15200
15201 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 8);
15202
15203 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15204
15205 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 16);
15206
15207 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15208 }
15209 else
15210 {
15211 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 4);
15212
15213 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15214
15215 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 8);
15216
15217 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15218
15219 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 16);
15220
15221 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15222 }
15223
15224 if (data.attack_mode == ATTACK_MODE_BF)
15225 {
15226 if (opts_type & OPTS_TYPE_PT_BITSLICE)
15227 {
15228 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tb", kern_type);
15229
15230 device_param->kernel_tb = hc_clCreateKernel (device_param->program, kernel_name);
15231
15232 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tm", kern_type);
15233
15234 device_param->kernel_tm = hc_clCreateKernel (device_param->program, kernel_name);
15235 }
15236 }
15237 }
15238 else
15239 {
15240 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_init", kern_type);
15241
15242 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15243
15244 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_loop", kern_type);
15245
15246 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15247
15248 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_comp", kern_type);
15249
15250 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15251
15252 if (opts_type & OPTS_TYPE_HOOK12)
15253 {
15254 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook12", kern_type);
15255
15256 device_param->kernel12 = hc_clCreateKernel (device_param->program, kernel_name);
15257 }
15258
15259 if (opts_type & OPTS_TYPE_HOOK23)
15260 {
15261 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook23", kern_type);
15262
15263 device_param->kernel23 = hc_clCreateKernel (device_param->program, kernel_name);
15264 }
15265 }
15266
15267 for (uint i = 0; i <= 20; i++)
15268 {
15269 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]);
15270 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]);
15271 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]);
15272
15273 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]);
15274 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]);
15275 }
15276
15277 for (uint i = 21; i <= 31; i++)
15278 {
15279 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]);
15280 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]);
15281 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]);
15282
15283 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]);
15284 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]);
15285 }
15286
15287 if (attack_mode == ATTACK_MODE_BF)
15288 {
15289 device_param->kernel_mp_l = hc_clCreateKernel (device_param->program_mp, "l_markov");
15290 device_param->kernel_mp_r = hc_clCreateKernel (device_param->program_mp, "r_markov");
15291
15292 if (opts_type & OPTS_TYPE_PT_BITSLICE)
15293 {
15294 hc_clSetKernelArg (device_param->kernel_tb, 0, sizeof (cl_mem), device_param->kernel_params_tb[0]);
15295
15296 hc_clSetKernelArg (device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]);
15297 hc_clSetKernelArg (device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]);
15298 }
15299 }
15300 else if (attack_mode == ATTACK_MODE_HYBRID1)
15301 {
15302 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
15303 }
15304 else if (attack_mode == ATTACK_MODE_HYBRID2)
15305 {
15306 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
15307 }
15308
15309 if (attack_exec == ATTACK_EXEC_ON_GPU)
15310 {
15311 // nothing to do
15312 }
15313 else
15314 {
15315 for (uint i = 0; i < 5; i++)
15316 {
15317 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]);
15318 }
15319
15320 for (uint i = 5; i < 7; i++)
15321 {
15322 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]);
15323 }
15324 }
15325
15326 /**
15327 * Store initial fanspeed if gpu_temp_retain is enabled
15328 */
15329
15330 if (gpu_temp_disable == 0)
15331 {
15332 if (gpu_temp_retain != 0)
15333 {
15334 hc_thread_mutex_lock (mux_adl);
15335
15336 if (data.hm_device[device_id].fan_supported == 1)
15337 {
15338 if (gpu_temp_retain_chgd == 0)
15339 {
15340 uint cur_temp = 0;
15341 uint default_temp = 0;
15342
15343 int ADL_rc = hc_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_dll, data.hm_device[device_id].adapter_index, (int *) &cur_temp, (int *) &default_temp);
15344
15345 if (ADL_rc == ADL_OK)
15346 {
15347 #define GPU_TEMP_RETAIN_ABORT_DIFF 15
15348
15349 const uint gpu_temp_retain_target = default_temp - GPU_TEMP_RETAIN_ABORT_DIFF;
15350
15351 // special case with multi gpu setups: always use minimum retain
15352
15353 if (gpu_temp_retain_set == 0)
15354 {
15355 gpu_temp_retain = gpu_temp_retain_target;
15356 gpu_temp_retain_set = 1;
15357 }
15358 else
15359 {
15360 gpu_temp_retain = MIN (gpu_temp_retain, gpu_temp_retain_target);
15361 }
15362
15363 if (gpu_temp_abort_chgd == 0) gpu_temp_abort = gpu_temp_retain + GPU_TEMP_RETAIN_ABORT_DIFF;
15364 }
15365 }
15366
15367 const int fan_speed = hm_get_fanspeed_with_device_id (device_id);
15368
15369 temp_retain_fanspeed_value[device_id] = fan_speed;
15370
15371 if (fan_speed == -1)
15372 {
15373 log_info ("WARNING: Failed to get current fan speed settings for gpu number: %i:", device_id + 1);
15374
15375 temp_retain_fanspeed_value[device_id] = 0;
15376 }
15377 }
15378
15379 hc_thread_mutex_unlock (mux_adl);
15380 }
15381 }
15382
15383 /**
15384 * Store original powercontrol/clocks settings, set overdrive 6 performance tuning settings
15385 */
15386
15387 if (powertune_enable == 1)
15388 {
15389 hc_thread_mutex_lock (mux_adl);
15390
15391 if (data.hm_device[device_id].od_version == 6)
15392 {
15393 int ADL_rc;
15394
15395 // check powertune capabilities first, if not available then skip device
15396
15397 int powertune_supported = 0;
15398
15399 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune_supported)) != ADL_OK)
15400 {
15401 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
15402
15403 return (-1);
15404 }
15405
15406 if (powertune_supported != 0)
15407 {
15408 // powercontrol settings
15409
15410 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
15411
15412 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune)) == ADL_OK)
15413 {
15414 ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &od_power_control_status[device_id]);
15415 }
15416
15417 if (ADL_rc != ADL_OK)
15418 {
15419 log_error ("ERROR: Failed to get current ADL PowerControl settings");
15420
15421 return (-1);
15422 }
15423
15424 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index, powertune.iMaxValue)) != ADL_OK)
15425 {
15426 log_error ("ERROR: Failed to set new ADL PowerControl values");
15427
15428 return (-1);
15429 }
15430
15431 // clocks
15432
15433 memset (&od_clock_mem_status[device_id], 0, sizeof (ADLOD6MemClockState));
15434
15435 od_clock_mem_status[device_id].state.iNumberOfPerformanceLevels = 2;
15436
15437 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)
15438 {
15439 log_error ("ERROR: Failed to get ADL memory and engine clock frequency");
15440
15441 return (-1);
15442 }
15443
15444 // Query capabilities only to see if profiles were not "damaged", if so output a warning but do accept the users profile settings
15445
15446 ADLOD6Capabilities caps = {0, 0, 0, {0, 0, 0}, {0, 0, 0}, 0, 0};
15447
15448 if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &caps)) != ADL_OK)
15449 {
15450 log_error ("ERROR: Failed to get ADL device capabilities");
15451
15452 return (-1);
15453 }
15454
15455 int engine_clock_max = caps.sEngineClockRange.iMax * 0.6666;
15456 int memory_clock_max = caps.sMemoryClockRange.iMax * 0.6250;
15457
15458 int warning_trigger_engine = (int) (0.25 * (float) engine_clock_max);
15459 int warning_trigger_memory = (int) (0.25 * (float) memory_clock_max);
15460
15461 int engine_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iEngineClock;
15462 int memory_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock;
15463
15464 // warning if profile has to low max values
15465
15466 if ((engine_clock_max - engine_clock_profile_max) > warning_trigger_engine)
15467 {
15468 log_info ("WARN: the custom profile seems to have too low maximum engine clock values. You therefore may not reach full performance");
15469 }
15470
15471 if ((memory_clock_max - memory_clock_profile_max) > warning_trigger_memory)
15472 {
15473 log_info ("WARN: the custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance");
15474 }
15475
15476 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
15477
15478 performance_state->iNumberOfPerformanceLevels = 2;
15479
15480 performance_state->aLevels[0].iEngineClock = engine_clock_profile_max;
15481 performance_state->aLevels[1].iEngineClock = engine_clock_profile_max;
15482 performance_state->aLevels[0].iMemoryClock = memory_clock_profile_max;
15483 performance_state->aLevels[1].iMemoryClock = memory_clock_profile_max;
15484
15485 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)
15486 {
15487 log_info ("ERROR: Failed to set ADL performance state");
15488
15489 return (-1);
15490 }
15491
15492 local_free (performance_state);
15493 }
15494 }
15495
15496 hc_thread_mutex_unlock (mux_adl);
15497 }
15498 }
15499
15500 /* Temporary fix:
15501 * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
15502 * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
15503 * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem)
15504 * Driver / ADL bug?
15505 */
15506
15507 if (powertune_enable == 1)
15508 {
15509 hc_thread_mutex_lock (mux_adl);
15510
15511 for (uint i = 0; i < devices_cnt; i++)
15512 {
15513 if (data.hm_device[i].od_version == 6)
15514 {
15515 // set powertune value only
15516
15517 int powertune_supported = 0;
15518
15519 int ADL_rc = 0;
15520
15521 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK)
15522 {
15523 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
15524
15525 return (-1);
15526 }
15527
15528 if (powertune_supported != 0)
15529 {
15530 // powertune set
15531 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
15532
15533 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index, &powertune)) != ADL_OK)
15534 {
15535 log_error ("ERROR: Failed to get current ADL PowerControl settings");
15536
15537 return (-1);
15538 }
15539
15540 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, powertune.iMaxValue)) != ADL_OK)
15541 {
15542 log_error ("ERROR: Failed to set new ADL PowerControl values");
15543
15544 return (-1);
15545 }
15546 }
15547 }
15548 }
15549
15550 hc_thread_mutex_unlock (mux_adl);
15551 }
15552 #endif
15553
15554 data.gpu_blocks_all = gpu_blocks_all;
15555
15556 #ifdef _OCL
15557 if (gpu_async == 0) gpu_async = 1; // get rid of the warning
15558 #endif
15559
15560 if (data.quiet == 0) log_info ("");
15561
15562 /**
15563 * Inform user which algorithm is checked and at which workload setting
15564 */
15565
15566 if (benchmark == 1)
15567 {
15568 quiet = 0;
15569
15570 data.quiet = quiet;
15571
15572 char *hash_type = strhashtype (data.hash_mode); // not a bug
15573
15574 log_info ("Hashtype: %s", hash_type);
15575 log_info ("Workload: %u loops, %u accel", gpu_loops, gpu_accel);
15576 log_info ("");
15577 }
15578
15579 /**
15580 * keep track of the progress
15581 */
15582
15583 data.words_progress_done = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15584 data.words_progress_rejected = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15585 data.words_progress_restored = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15586
15587 /**
15588 * open filehandles
15589 */
15590
15591 #if _WIN
15592 if (_setmode (_fileno (stdin), _O_BINARY) == -1)
15593 {
15594 log_error ("ERROR: %s: %s", "stdin", strerror (errno));
15595
15596 return (-1);
15597 }
15598
15599 if (_setmode (_fileno (stdout), _O_BINARY) == -1)
15600 {
15601 log_error ("ERROR: %s: %s", "stdout", strerror (errno));
15602
15603 return (-1);
15604 }
15605
15606 if (_setmode (_fileno (stderr), _O_BINARY) == -1)
15607 {
15608 log_error ("ERROR: %s: %s", "stderr", strerror (errno));
15609
15610 return (-1);
15611 }
15612 #endif
15613
15614 /**
15615 * dictionary pad
15616 */
15617
15618 segment_size *= (1024 * 1024);
15619
15620 data.segment_size = segment_size;
15621
15622 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
15623
15624 wl_data->buf = (char *) mymalloc (segment_size);
15625 wl_data->avail = segment_size;
15626 wl_data->incr = segment_size;
15627 wl_data->cnt = 0;
15628 wl_data->pos = 0;
15629
15630 uint wordlist_mode = ((optind + 1) < myargc) ? WL_MODE_FILE : WL_MODE_STDIN;
15631
15632 data.wordlist_mode = wordlist_mode;
15633
15634 cs_t *css_buf = NULL;
15635 uint css_cnt = 0;
15636 uint dictcnt = 0;
15637 uint maskcnt = 1;
15638 char **masks = NULL;
15639 char **dictfiles = NULL;
15640
15641 uint mask_from_file = 0;
15642
15643 if (attack_mode == ATTACK_MODE_STRAIGHT)
15644 {
15645 if (wordlist_mode == WL_MODE_FILE)
15646 {
15647 int wls_left = myargc - (optind + 1);
15648
15649 for (int i = 0; i < wls_left; i++)
15650 {
15651 char *l0_filename = myargv[optind + 1 + i];
15652
15653 struct stat l0_stat;
15654
15655 if (stat (l0_filename, &l0_stat) == -1)
15656 {
15657 log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
15658
15659 return (-1);
15660 }
15661
15662 uint is_dir = S_ISDIR (l0_stat.st_mode);
15663
15664 if (is_dir == 0)
15665 {
15666 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
15667
15668 dictcnt++;
15669
15670 dictfiles[dictcnt - 1] = l0_filename;
15671 }
15672 else
15673 {
15674 // do not allow --keyspace w/ a directory
15675
15676 if (keyspace == 1)
15677 {
15678 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
15679
15680 return (-1);
15681 }
15682
15683 char **dictionary_files = NULL;
15684
15685 dictionary_files = scan_directory (l0_filename);
15686
15687 if (dictionary_files != NULL)
15688 {
15689 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
15690
15691 for (int d = 0; dictionary_files[d] != NULL; d++)
15692 {
15693 char *l1_filename = dictionary_files[d];
15694
15695 struct stat l1_stat;
15696
15697 if (stat (l1_filename, &l1_stat) == -1)
15698 {
15699 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
15700
15701 return (-1);
15702 }
15703
15704 if (S_ISREG (l1_stat.st_mode))
15705 {
15706 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
15707
15708 dictcnt++;
15709
15710 dictfiles[dictcnt - 1] = strdup (l1_filename);
15711 }
15712 }
15713 }
15714
15715 local_free (dictionary_files);
15716 }
15717 }
15718
15719 if (dictcnt < 1)
15720 {
15721 log_error ("ERROR: No usable dictionary file found.");
15722
15723 return (-1);
15724 }
15725 }
15726 else if (wordlist_mode == WL_MODE_STDIN)
15727 {
15728 dictcnt = 1;
15729 }
15730 }
15731 else if (attack_mode == ATTACK_MODE_COMBI)
15732 {
15733 // display
15734
15735 char *dictfile1 = myargv[optind + 1 + 0];
15736 char *dictfile2 = myargv[optind + 1 + 1];
15737
15738 // find the bigger dictionary and use as base
15739
15740 FILE *fp1;
15741 FILE *fp2;
15742
15743 struct stat tmp_stat;
15744
15745 if ((fp1 = fopen (dictfile1, "rb")) == NULL)
15746 {
15747 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
15748
15749 return (-1);
15750 }
15751
15752 if (stat (dictfile1, &tmp_stat) == -1)
15753 {
15754 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
15755
15756 fclose (fp1);
15757
15758 return (-1);
15759 }
15760
15761 if (S_ISDIR (tmp_stat.st_mode))
15762 {
15763 log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno));
15764
15765 fclose (fp1);
15766
15767 return (-1);
15768 }
15769
15770 if ((fp2 = fopen (dictfile2, "rb")) == NULL)
15771 {
15772 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
15773
15774 fclose (fp1);
15775
15776 return (-1);
15777 }
15778
15779 if (stat (dictfile2, &tmp_stat) == -1)
15780 {
15781 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
15782
15783 fclose (fp1);
15784 fclose (fp2);
15785
15786 return (-1);
15787 }
15788
15789 if (S_ISDIR (tmp_stat.st_mode))
15790 {
15791 log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno));
15792
15793 fclose (fp1);
15794 fclose (fp2);
15795
15796 return (-1);
15797 }
15798
15799 data.combs_cnt = 1;
15800
15801 data.quiet = 1;
15802
15803 const uint64_t words1_cnt = count_words (wl_data, fp1, dictfile1, dictstat_base, &dictstat_nmemb);
15804
15805 data.quiet = quiet;
15806
15807 if (words1_cnt == 0)
15808 {
15809 log_error ("ERROR: %s: empty file", dictfile1);
15810
15811 fclose (fp1);
15812 fclose (fp2);
15813
15814 return (-1);
15815 }
15816
15817 data.combs_cnt = 1;
15818
15819 data.quiet = 1;
15820
15821 const uint64_t words2_cnt = count_words (wl_data, fp2, dictfile2, dictstat_base, &dictstat_nmemb);
15822
15823 data.quiet = quiet;
15824
15825 if (words2_cnt == 0)
15826 {
15827 log_error ("ERROR: %s: empty file", dictfile2);
15828
15829 fclose (fp1);
15830 fclose (fp2);
15831
15832 return (-1);
15833 }
15834
15835 fclose (fp1);
15836 fclose (fp2);
15837
15838 data.dictfile = dictfile1;
15839 data.dictfile2 = dictfile2;
15840
15841 if (words1_cnt >= words2_cnt)
15842 {
15843 data.combs_cnt = words2_cnt;
15844 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
15845
15846 dictfiles = &data.dictfile;
15847
15848 dictcnt = 1;
15849 }
15850 else
15851 {
15852 data.combs_cnt = words1_cnt;
15853 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
15854
15855 dictfiles = &data.dictfile2;
15856
15857 dictcnt = 1;
15858
15859 // we also have to switch wordlist related rules!
15860
15861 char *tmpc = data.rule_buf_l;
15862
15863 data.rule_buf_l = data.rule_buf_r;
15864 data.rule_buf_r = tmpc;
15865
15866 int tmpi = data.rule_len_l;
15867
15868 data.rule_len_l = data.rule_len_r;
15869 data.rule_len_r = tmpi;
15870 }
15871 }
15872 else if (attack_mode == ATTACK_MODE_BF)
15873 {
15874 char *mask = NULL;
15875
15876 maskcnt = 0;
15877
15878 if (benchmark == 0)
15879 {
15880 mask = myargv[optind + 1];
15881
15882 masks = (char **) mymalloc (INCR_MASKS * sizeof (char *));
15883
15884 if ((optind + 2) <= myargc)
15885 {
15886 struct stat file_stat;
15887
15888 if (stat (mask, &file_stat) == -1)
15889 {
15890 maskcnt = 1;
15891
15892 masks[maskcnt - 1] = mystrdup (mask);
15893 }
15894 else
15895 {
15896 int wls_left = myargc - (optind + 1);
15897
15898 uint masks_avail = INCR_MASKS;
15899
15900 for (int i = 0; i < wls_left; i++)
15901 {
15902 if (i != 0)
15903 {
15904 mask = myargv[optind + 1 + i];
15905
15906 if (stat (mask, &file_stat) == -1)
15907 {
15908 log_error ("ERROR: %s: %s", mask, strerror (errno));
15909
15910 return (-1);
15911 }
15912 }
15913
15914 uint is_file = S_ISREG (file_stat.st_mode);
15915
15916 if (is_file == 1)
15917 {
15918 FILE *mask_fp;
15919
15920 if ((mask_fp = fopen (mask, "r")) == NULL)
15921 {
15922 log_error ("ERROR: %s: %s", mask, strerror (errno));
15923
15924 return (-1);
15925 }
15926
15927 char line_buf[BUFSIZ];
15928
15929 while (!feof (mask_fp))
15930 {
15931 memset (line_buf, 0, BUFSIZ);
15932
15933 int line_len = fgetl (mask_fp, line_buf);
15934
15935 if (line_len == 0) continue;
15936
15937 if (line_buf[0] == '#') continue;
15938
15939 if (masks_avail == maskcnt)
15940 {
15941 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
15942
15943 masks_avail += INCR_MASKS;
15944 }
15945
15946 masks[maskcnt] = mystrdup (line_buf);
15947
15948 maskcnt++;
15949 }
15950
15951 fclose (mask_fp);
15952 }
15953 else
15954 {
15955 log_error ("ERROR: %s: unsupported file-type", mask);
15956
15957 return (-1);
15958 }
15959 }
15960
15961 mask_from_file = 1;
15962 }
15963 }
15964 else
15965 {
15966 custom_charset_1 = (char *) "?l?d?u";
15967 custom_charset_2 = (char *) "?l?d";
15968 custom_charset_3 = (char *) "?l?d*!$@_";
15969
15970 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
15971 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
15972 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
15973
15974 masks[maskcnt] = mystrdup ("?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d");
15975
15976 wordlist_mode = WL_MODE_MASK;
15977
15978 data.wordlist_mode = wordlist_mode;
15979
15980 increment = 1;
15981
15982 maskcnt = 1;
15983 }
15984 }
15985 else
15986 {
15987 /**
15988 * generate full masks and charsets
15989 */
15990
15991 masks = (char **) mymalloc (sizeof (char *));
15992
15993 switch (hash_mode)
15994 {
15995 case 1731: pw_min = 5;
15996 pw_max = 5;
15997 mask = mystrdup ("?b?b?b?b?b");
15998 break;
15999 case 12500: pw_min = 5;
16000 pw_max = 5;
16001 mask = mystrdup ("?b?b?b?b?b");
16002 break;
16003 default: pw_min = 7;
16004 pw_max = 7;
16005 mask = mystrdup ("?b?b?b?b?b?b?b");
16006 break;
16007 }
16008
16009 maskcnt = 1;
16010
16011 masks[maskcnt - 1] = mystrdup (mask);
16012
16013 wordlist_mode = WL_MODE_MASK;
16014
16015 data.wordlist_mode = wordlist_mode;
16016
16017 increment = 1;
16018 }
16019
16020 dictfiles = (char **) mycalloc (pw_max, sizeof (char *));
16021
16022 if (increment)
16023 {
16024 if (increment_min > pw_min) pw_min = increment_min;
16025
16026 if (increment_max < pw_max) pw_max = increment_max;
16027 }
16028 }
16029 else if (attack_mode == ATTACK_MODE_HYBRID1)
16030 {
16031 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
16032
16033 // display
16034
16035 char *mask = myargv[myargc - 1];
16036
16037 maskcnt = 0;
16038
16039 masks = (char **) mymalloc (1 * sizeof (char *));
16040
16041 // mod
16042
16043 struct stat file_stat;
16044
16045 if (stat (mask, &file_stat) == -1)
16046 {
16047 maskcnt = 1;
16048
16049 masks[maskcnt - 1] = mystrdup (mask);
16050 }
16051 else
16052 {
16053 uint is_file = S_ISREG (file_stat.st_mode);
16054
16055 if (is_file == 1)
16056 {
16057 FILE *mask_fp;
16058
16059 if ((mask_fp = fopen (mask, "r")) == NULL)
16060 {
16061 log_error ("ERROR: %s: %s", mask, strerror (errno));
16062
16063 return (-1);
16064 }
16065
16066 char line_buf[BUFSIZ];
16067
16068 uint masks_avail = 1;
16069
16070 while (!feof (mask_fp))
16071 {
16072 memset (line_buf, 0, BUFSIZ);
16073
16074 int line_len = fgetl (mask_fp, line_buf);
16075
16076 if (line_len == 0) continue;
16077
16078 if (line_buf[0] == '#') continue;
16079
16080 if (masks_avail == maskcnt)
16081 {
16082 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
16083
16084 masks_avail += INCR_MASKS;
16085 }
16086
16087 masks[maskcnt] = mystrdup (line_buf);
16088
16089 maskcnt++;
16090 }
16091
16092 fclose (mask_fp);
16093
16094 mask_from_file = 1;
16095 }
16096 else
16097 {
16098 maskcnt = 1;
16099
16100 masks[maskcnt - 1] = mystrdup (mask);
16101 }
16102 }
16103
16104 // base
16105
16106 int wls_left = myargc - (optind + 2);
16107
16108 for (int i = 0; i < wls_left; i++)
16109 {
16110 char *filename = myargv[optind + 1 + i];
16111
16112 struct stat file_stat;
16113
16114 if (stat (filename, &file_stat) == -1)
16115 {
16116 log_error ("ERROR: %s: %s", filename, strerror (errno));
16117
16118 return (-1);
16119 }
16120
16121 uint is_dir = S_ISDIR (file_stat.st_mode);
16122
16123 if (is_dir == 0)
16124 {
16125 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16126
16127 dictcnt++;
16128
16129 dictfiles[dictcnt - 1] = filename;
16130 }
16131 else
16132 {
16133 // do not allow --keyspace w/ a directory
16134
16135 if (keyspace == 1)
16136 {
16137 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
16138
16139 return (-1);
16140 }
16141
16142 char **dictionary_files = NULL;
16143
16144 dictionary_files = scan_directory (filename);
16145
16146 if (dictionary_files != NULL)
16147 {
16148 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
16149
16150 for (int d = 0; dictionary_files[d] != NULL; d++)
16151 {
16152 char *l1_filename = dictionary_files[d];
16153
16154 struct stat l1_stat;
16155
16156 if (stat (l1_filename, &l1_stat) == -1)
16157 {
16158 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
16159
16160 return (-1);
16161 }
16162
16163 if (S_ISREG (l1_stat.st_mode))
16164 {
16165 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16166
16167 dictcnt++;
16168
16169 dictfiles[dictcnt - 1] = strdup (l1_filename);
16170 }
16171 }
16172 }
16173
16174 local_free (dictionary_files);
16175 }
16176 }
16177
16178 if (dictcnt < 1)
16179 {
16180 log_error ("ERROR: No usable dictionary file found.");
16181
16182 return (-1);
16183 }
16184
16185 if (increment)
16186 {
16187 maskcnt = 0;
16188
16189 uint mask_min = increment_min; // we can't reject smaller masks here
16190 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
16191
16192 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
16193 {
16194 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
16195
16196 if (cur_mask == NULL) break;
16197
16198 masks[maskcnt] = cur_mask;
16199
16200 maskcnt++;
16201
16202 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
16203 }
16204 }
16205 }
16206 else if (attack_mode == ATTACK_MODE_HYBRID2)
16207 {
16208 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
16209
16210 // display
16211
16212 char *mask = myargv[optind + 1 + 0];
16213
16214 maskcnt = 0;
16215
16216 masks = (char **) mymalloc (1 * sizeof (char *));
16217
16218 // mod
16219
16220 struct stat file_stat;
16221
16222 if (stat (mask, &file_stat) == -1)
16223 {
16224 maskcnt = 1;
16225
16226 masks[maskcnt - 1] = mystrdup (mask);
16227 }
16228 else
16229 {
16230 uint is_file = S_ISREG (file_stat.st_mode);
16231
16232 if (is_file == 1)
16233 {
16234 FILE *mask_fp;
16235
16236 if ((mask_fp = fopen (mask, "r")) == NULL)
16237 {
16238 log_error ("ERROR: %s: %s", mask, strerror (errno));
16239
16240 return (-1);
16241 }
16242
16243 char line_buf[BUFSIZ];
16244
16245 uint masks_avail = 1;
16246
16247 while (!feof (mask_fp))
16248 {
16249 memset (line_buf, 0, BUFSIZ);
16250
16251 int line_len = fgetl (mask_fp, line_buf);
16252
16253 if (line_len == 0) continue;
16254
16255 if (line_buf[0] == '#') continue;
16256
16257 if (masks_avail == maskcnt)
16258 {
16259 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
16260
16261 masks_avail += INCR_MASKS;
16262 }
16263
16264 masks[maskcnt] = mystrdup (line_buf);
16265
16266 maskcnt++;
16267 }
16268
16269 fclose (mask_fp);
16270
16271 mask_from_file = 1;
16272 }
16273 else
16274 {
16275 maskcnt = 1;
16276
16277 masks[maskcnt - 1] = mystrdup (mask);
16278 }
16279 }
16280
16281 // base
16282
16283 int wls_left = myargc - (optind + 2);
16284
16285 for (int i = 0; i < wls_left; i++)
16286 {
16287 char *filename = myargv[optind + 2 + i];
16288
16289 struct stat file_stat;
16290
16291 if (stat (filename, &file_stat) == -1)
16292 {
16293 log_error ("ERROR: %s: %s", filename, strerror (errno));
16294
16295 return (-1);
16296 }
16297
16298 uint is_dir = S_ISDIR (file_stat.st_mode);
16299
16300 if (is_dir == 0)
16301 {
16302 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16303
16304 dictcnt++;
16305
16306 dictfiles[dictcnt - 1] = filename;
16307 }
16308 else
16309 {
16310 // do not allow --keyspace w/ a directory
16311
16312 if (keyspace == 1)
16313 {
16314 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
16315
16316 return (-1);
16317 }
16318
16319 char **dictionary_files = NULL;
16320
16321 dictionary_files = scan_directory (filename);
16322
16323 if (dictionary_files != NULL)
16324 {
16325 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
16326
16327 for (int d = 0; dictionary_files[d] != NULL; d++)
16328 {
16329 char *l1_filename = dictionary_files[d];
16330
16331 struct stat l1_stat;
16332
16333 if (stat (l1_filename, &l1_stat) == -1)
16334 {
16335 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
16336
16337 return (-1);
16338 }
16339
16340 if (S_ISREG (l1_stat.st_mode))
16341 {
16342 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16343
16344 dictcnt++;
16345
16346 dictfiles[dictcnt - 1] = strdup (l1_filename);
16347 }
16348 }
16349 }
16350
16351 local_free (dictionary_files);
16352 }
16353 }
16354
16355 if (dictcnt < 1)
16356 {
16357 log_error ("ERROR: No usable dictionary file found.");
16358
16359 return (-1);
16360 }
16361
16362 if (increment)
16363 {
16364 maskcnt = 0;
16365
16366 uint mask_min = increment_min; // we can't reject smaller masks here
16367 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
16368
16369 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
16370 {
16371 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
16372
16373 if (cur_mask == NULL) break;
16374
16375 masks[maskcnt] = cur_mask;
16376
16377 maskcnt++;
16378
16379 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
16380 }
16381 }
16382 }
16383
16384 data.pw_min = pw_min;
16385 data.pw_max = pw_max;
16386
16387 /**
16388 * weak hash check
16389 */
16390
16391 if (weak_hash_threshold >= salts_cnt)
16392 {
16393 if (data.quiet == 0) log_info_nn ("Checking for weak hashes...");
16394
16395 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
16396 {
16397 weak_hash_check (&data.devices_param[0], salt_pos, gpu_loops);
16398 }
16399 }
16400
16401 // Display hack, guarantee that there is at least one \r before real start
16402
16403 if (data.quiet == 0) log_info_nn ("");
16404
16405 /**
16406 * status and monitor threads
16407 */
16408
16409 if (data.devices_status != STATUS_CRACKED) data.devices_status = STATUS_STARTING;
16410
16411 hc_thread_t i_thread = 0;
16412
16413 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
16414 {
16415 hc_thread_create (i_thread, thread_keypress, &benchmark);
16416 }
16417
16418 if (wordlist_mode == WL_MODE_STDIN) data.status = 1;
16419
16420 uint ni_threads_cnt = 0;
16421
16422 hc_thread_t *ni_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
16423
16424 hc_thread_create (ni_threads[ni_threads_cnt], thread_monitor, NULL);
16425
16426 ni_threads_cnt++;
16427
16428 /**
16429 * Outfile remove
16430 */
16431
16432 if (keyspace == 0)
16433 {
16434 if (outfile_check_timer != 0)
16435 {
16436 if (data.outfile_check_directory != NULL)
16437 {
16438 if ((hash_mode != 5200) &&
16439 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
16440 (hash_mode != 9000))
16441 {
16442 hc_thread_create (ni_threads[ni_threads_cnt], thread_outfile_remove, NULL);
16443
16444 ni_threads_cnt++;
16445 }
16446 else
16447 {
16448 outfile_check_timer = 0;
16449 }
16450 }
16451 else
16452 {
16453 outfile_check_timer = 0;
16454 }
16455 }
16456 }
16457
16458 /**
16459 * Inform the user if we got some hashes remove because of the pot file remove feature
16460 */
16461
16462 if (data.quiet == 0)
16463 {
16464 if (potfile_remove_cracks > 0)
16465 {
16466 if (potfile_remove_cracks == 1) log_info ("INFO: removed 1 hash found in pot file\n");
16467 else log_info ("INFO: removed %u hashes found in pot file\n", potfile_remove_cracks);
16468 }
16469 }
16470
16471 data.outfile_check_timer = outfile_check_timer;
16472
16473 /**
16474 * main loop
16475 */
16476
16477 char **induction_dictionaries = NULL;
16478
16479 int induction_dictionaries_cnt = 0;
16480
16481 hcstat_table_t *root_table_buf = NULL;
16482 hcstat_table_t *markov_table_buf = NULL;
16483
16484 uint initial_restore_done = 0;
16485
16486 data.maskcnt = maskcnt;
16487
16488 for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
16489 {
16490 if (data.devices_status == STATUS_CRACKED) break;
16491
16492 data.devices_status = STATUS_INIT;
16493
16494 if (maskpos > rd->maskpos)
16495 {
16496 rd->dictpos = 0;
16497 }
16498
16499 rd->maskpos = maskpos;
16500 data.maskpos = maskpos;
16501
16502 if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2 || attack_mode == ATTACK_MODE_BF)
16503 {
16504 char *mask = masks[maskpos];
16505
16506 if (mask_from_file == 1)
16507 {
16508 if (mask[0] == '\\' && mask[1] == '#') mask++; // escaped comment sign (sharp) "\#"
16509
16510 char *str_ptr;
16511 uint str_pos;
16512
16513 uint mask_offset = 0;
16514
16515 uint separator_cnt;
16516
16517 for (separator_cnt = 0; separator_cnt < 4; separator_cnt++)
16518 {
16519 str_ptr = strstr (mask + mask_offset, ",");
16520
16521 if (str_ptr == NULL) break;
16522
16523 str_pos = str_ptr - mask;
16524
16525 // escaped separator, i.e. "\,"
16526
16527 if (str_pos > 0)
16528 {
16529 if (mask[str_pos - 1] == '\\')
16530 {
16531 separator_cnt --;
16532
16533 mask_offset = str_pos + 1;
16534
16535 continue;
16536 }
16537 }
16538
16539 // reset the offset
16540
16541 mask_offset = 0;
16542
16543 mask[str_pos] = '\0';
16544
16545 switch (separator_cnt)
16546 {
16547 case 0:
16548 mp_reset_usr (mp_usr, 0);
16549
16550 custom_charset_1 = mask;
16551 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
16552 break;
16553
16554 case 1:
16555 mp_reset_usr (mp_usr, 1);
16556
16557 custom_charset_2 = mask;
16558 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
16559 break;
16560
16561 case 2:
16562 mp_reset_usr (mp_usr, 2);
16563
16564 custom_charset_3 = mask;
16565 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
16566 break;
16567
16568 case 3:
16569 mp_reset_usr (mp_usr, 3);
16570
16571 custom_charset_4 = mask;
16572 mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
16573 break;
16574 }
16575
16576 mask = mask + str_pos + 1;
16577 }
16578 }
16579
16580 if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
16581 {
16582 if (maskpos > 0)
16583 {
16584 local_free (css_buf);
16585 local_free (data.root_css_buf);
16586 local_free (data.markov_css_buf);
16587
16588 local_free (masks[maskpos - 1]);
16589 }
16590
16591 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
16592
16593 data.mask = mask;
16594 data.css_cnt = css_cnt;
16595 data.css_buf = css_buf;
16596
16597 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
16598
16599 memset (uniq_tbls, 0, sizeof (uniq_tbls));
16600
16601 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
16602
16603 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
16604 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
16605
16606 sp_setup_tbl (install_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
16607
16608 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
16609
16610 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
16611 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
16612
16613 data.root_css_buf = root_css_buf;
16614 data.markov_css_buf = markov_css_buf;
16615
16616 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
16617
16618 data.combs_cnt = sp_get_sum (0, css_cnt, root_css_buf);
16619
16620 local_free (root_table_buf);
16621 local_free (markov_table_buf);
16622
16623 // args
16624
16625 for (uint device_id = 0; device_id < devices_cnt; device_id++)
16626 {
16627 hc_device_param_t *device_param = &data.devices_param[device_id];
16628
16629 device_param->kernel_params_mp[0] = &device_param->d_combs;
16630 device_param->kernel_params_mp[1] = &device_param->d_root_css_buf;
16631 device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf;
16632
16633 device_param->kernel_params_mp_buf64[3] = 0;
16634 device_param->kernel_params_mp_buf32[4] = css_cnt;
16635 device_param->kernel_params_mp_buf32[5] = 0;
16636 device_param->kernel_params_mp_buf32[6] = 0;
16637 device_param->kernel_params_mp_buf32[7] = 0;
16638
16639 if (attack_mode == ATTACK_MODE_HYBRID1)
16640 {
16641 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_buf32[5] = full01;
16642 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_buf32[5] = full80;
16643 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_buf32[6] = 1;
16644 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_buf32[7] = 1;
16645 }
16646 else if (attack_mode == ATTACK_MODE_HYBRID2)
16647 {
16648 device_param->kernel_params_mp_buf32[5] = 0;
16649 device_param->kernel_params_mp_buf32[6] = 0;
16650 device_param->kernel_params_mp_buf32[7] = 0;
16651 }
16652
16653 #ifdef _CUDA
16654 hc_cuCtxPushCurrent (device_param->context);
16655
16656 hc_cuMemcpyHtoD (device_param->d_root_css_buf, root_css_buf, device_param->size_root_css);
16657 hc_cuMemcpyHtoD (device_param->d_markov_css_buf, markov_css_buf, device_param->size_markov_css);
16658
16659 hc_cuCtxPopCurrent (&device_param->context);
16660 #elif _OCL
16661 for (uint i = 0; i < 3; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]);
16662 for (uint i = 3; i < 4; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]);
16663 for (uint i = 4; i < 8; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]);
16664
16665 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);
16666 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);
16667 #endif
16668 }
16669 }
16670 else if (attack_mode == ATTACK_MODE_BF)
16671 {
16672 dictcnt = 0; // number of "sub-masks", i.e. when using incremental mode
16673
16674 if (increment)
16675 {
16676 for (uint i = 0; i < dictcnt; i++)
16677 {
16678 local_free (dictfiles[i]);
16679 }
16680
16681 for (uint pw_len = MAX (1, pw_min); pw_len <= pw_max; pw_len++)
16682 {
16683 char *l1_filename = mp_get_truncated_mask (mask, strlen (mask), pw_len);
16684
16685 if (l1_filename == NULL) break;
16686
16687 dictcnt++;
16688
16689 dictfiles[dictcnt - 1] = l1_filename;
16690 }
16691 }
16692 else
16693 {
16694 dictcnt++;
16695
16696 dictfiles[dictcnt - 1] = mask;
16697 }
16698
16699 if (dictcnt == 0)
16700 {
16701 log_error ("ERROR: Mask is too small");
16702
16703 return (-1);
16704 }
16705 }
16706 }
16707
16708 free (induction_dictionaries);
16709
16710 // induction_dictionaries_cnt = 0; // implied
16711
16712 if (attack_mode != ATTACK_MODE_BF)
16713 {
16714 if (keyspace == 0)
16715 {
16716 induction_dictionaries = scan_directory (induction_directory);
16717
16718 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
16719 }
16720 }
16721
16722 if (induction_dictionaries_cnt)
16723 {
16724 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
16725 }
16726
16727 /**
16728 * prevent the user from using --keyspace together w/ maskfile and or dictfile
16729 */
16730 if (keyspace == 1)
16731 {
16732 if ((maskcnt > 1) || (dictcnt > 1))
16733 {
16734 log_error ("ERROR: --keyspace is not supported with --increment or mask files");
16735
16736 return (-1);
16737 }
16738 }
16739
16740 for (uint dictpos = rd->dictpos; dictpos < dictcnt; )
16741 {
16742 char *subid = logfile_generate_subid ();
16743
16744 data.subid = subid;
16745
16746 logfile_sub_msg ("START");
16747
16748 data.devices_status = STATUS_INIT;
16749
16750 memset (data.words_progress_done, 0, data.salts_cnt * sizeof (uint64_t));
16751 memset (data.words_progress_rejected, 0, data.salts_cnt * sizeof (uint64_t));
16752 memset (data.words_progress_restored, 0, data.salts_cnt * sizeof (uint64_t));
16753
16754 memset (data.cpt_buf, 0, CPT_BUF * sizeof (cpt_t));
16755
16756 data.cpt_pos = 0;
16757
16758 data.cpt_start = time (NULL);
16759
16760 data.cpt_total = 0;
16761
16762 if (data.restore == 0)
16763 {
16764 rd->words_cur = skip;
16765
16766 skip = 0;
16767
16768 data.skip = 0;
16769 }
16770
16771 data.ms_paused = 0;
16772
16773 data.words_cur = rd->words_cur;
16774
16775 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
16776 {
16777 hc_device_param_t *device_param = &data.devices_param[device_id];
16778
16779 device_param->speed_pos = 0;
16780
16781 memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (uint64_t));
16782 memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float));
16783 memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
16784
16785 device_param->gpu_power = device_param->gpu_power_user;
16786 device_param->gpu_blocks = device_param->gpu_blocks_user;
16787
16788 device_param->outerloop_pos = 0;
16789 device_param->outerloop_left = 0;
16790 device_param->innerloop_pos = 0;
16791 device_param->innerloop_left = 0;
16792
16793 // some more resets:
16794
16795 memset (device_param->pw_caches, 0, 64 * sizeof (pw_cache_t));
16796
16797 memset (device_param->pws_buf, 0, device_param->size_pws);
16798
16799 device_param->pw_cnt = 0;
16800 device_param->pws_cnt = 0;
16801
16802 device_param->words_off = 0;
16803 device_param->words_done = 0;
16804 }
16805
16806 data.gpu_blocks_div = 0;
16807
16808 // figure out some workload
16809
16810 if (attack_mode == ATTACK_MODE_STRAIGHT)
16811 {
16812 if (data.wordlist_mode == WL_MODE_FILE)
16813 {
16814 char *dictfile = NULL;
16815
16816 if (induction_dictionaries_cnt)
16817 {
16818 dictfile = induction_dictionaries[0];
16819 }
16820 else
16821 {
16822 dictfile = dictfiles[dictpos];
16823 }
16824
16825 data.dictfile = dictfile;
16826
16827 logfile_sub_string (dictfile);
16828
16829 for (uint i = 0; i < rp_files_cnt; i++)
16830 {
16831 logfile_sub_var_string ("rulefile", rp_files[i]);
16832 }
16833
16834 FILE *fd2 = fopen (dictfile, "rb");
16835
16836 if (fd2 == NULL)
16837 {
16838 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16839
16840 return (-1);
16841 }
16842
16843 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16844
16845 fclose (fd2);
16846
16847 if (data.words_cnt == 0)
16848 {
16849 if (data.devices_status == STATUS_CRACKED) break;
16850 if (data.devices_status == STATUS_ABORTED) break;
16851
16852 dictpos++;
16853
16854 continue;
16855 }
16856 }
16857 }
16858 else if (attack_mode == ATTACK_MODE_COMBI)
16859 {
16860 char *dictfile = data.dictfile;
16861 char *dictfile2 = data.dictfile2;
16862
16863 logfile_sub_string (dictfile);
16864 logfile_sub_string (dictfile2);
16865
16866 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
16867 {
16868 FILE *fd2 = fopen (dictfile, "rb");
16869
16870 if (fd2 == NULL)
16871 {
16872 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16873
16874 return (-1);
16875 }
16876
16877 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16878
16879 fclose (fd2);
16880 }
16881 else if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
16882 {
16883 FILE *fd2 = fopen (dictfile2, "rb");
16884
16885 if (fd2 == NULL)
16886 {
16887 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
16888
16889 return (-1);
16890 }
16891
16892 data.words_cnt = count_words (wl_data, fd2, dictfile2, dictstat_base, &dictstat_nmemb);
16893
16894 fclose (fd2);
16895 }
16896
16897 if (data.words_cnt == 0)
16898 {
16899 if (data.devices_status == STATUS_CRACKED) break;
16900 if (data.devices_status == STATUS_ABORTED) break;
16901
16902 dictpos++;
16903
16904 continue;
16905 }
16906 }
16907 else if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
16908 {
16909 char *dictfile = NULL;
16910
16911 if (induction_dictionaries_cnt)
16912 {
16913 dictfile = induction_dictionaries[0];
16914 }
16915 else
16916 {
16917 dictfile = dictfiles[dictpos];
16918 }
16919
16920 data.dictfile = dictfile;
16921
16922 char *mask = data.mask;
16923
16924 logfile_sub_string (dictfile);
16925 logfile_sub_string (mask);
16926
16927 FILE *fd2 = fopen (dictfile, "rb");
16928
16929 if (fd2 == NULL)
16930 {
16931 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16932
16933 return (-1);
16934 }
16935
16936 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16937
16938 fclose (fd2);
16939
16940 if (data.words_cnt == 0)
16941 {
16942 if (data.devices_status == STATUS_CRACKED) break;
16943 if (data.devices_status == STATUS_ABORTED) break;
16944
16945 dictpos++;
16946
16947 continue;
16948 }
16949 }
16950 else if (attack_mode == ATTACK_MODE_BF)
16951 {
16952 local_free (css_buf);
16953 local_free (data.root_css_buf);
16954 local_free (data.markov_css_buf);
16955
16956 char *mask = dictfiles[dictpos];
16957
16958 logfile_sub_string (mask);
16959
16960 // base
16961
16962 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
16963
16964 if (opts_type & OPTS_TYPE_PT_UNICODE)
16965 {
16966 uint css_cnt_unicode = css_cnt * 2;
16967
16968 cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t));
16969
16970 for (uint i = 0, j = 0; i < css_cnt; i += 1, j += 2)
16971 {
16972 memcpy (&css_buf_unicode[j + 0], &css_buf[i], sizeof (cs_t));
16973
16974 css_buf_unicode[j + 1].cs_buf[0] = 0;
16975 css_buf_unicode[j + 1].cs_len = 1;
16976 }
16977
16978 free (css_buf);
16979
16980 css_buf = css_buf_unicode;
16981 css_cnt = css_cnt_unicode;
16982 }
16983
16984 // check if mask is not too large or too small for pw_min/pw_max (*2 if unicode)
16985
16986 uint mask_min = pw_min;
16987 uint mask_max = pw_max;
16988
16989 if (opts_type & OPTS_TYPE_PT_UNICODE)
16990 {
16991 mask_min *= 2;
16992 mask_max *= 2;
16993 }
16994
16995 if ((css_cnt < mask_min) || (css_cnt > mask_max))
16996 {
16997 if (css_cnt < mask_min)
16998 {
16999 log_info ("WARNING: skipping mask '%s' because it is smaller than the minimum password length", mask);
17000 }
17001
17002 if (css_cnt > mask_max)
17003 {
17004 log_info ("WARNING: skipping mask '%s' because it is larger than the maximum password length", mask);
17005 }
17006
17007 // skip to next mask
17008
17009 dictpos++;
17010
17011 rd->dictpos = dictpos;
17012
17013 logfile_sub_msg ("STOP");
17014
17015 continue;
17016 }
17017
17018 uint save_css_cnt = css_cnt;
17019
17020 if (opti_type & OPTI_TYPE_SINGLE_HASH)
17021 {
17022 if (opti_type & OPTI_TYPE_APPENDED_SALT)
17023 {
17024 uint salt_len = (uint) data.salts_buf[0].salt_len;
17025 char *salt_buf = (char *) data.salts_buf[0].salt_buf;
17026
17027 uint css_cnt_salt = css_cnt + salt_len;
17028
17029 cs_t *css_buf_salt = (cs_t *) mycalloc (css_cnt_salt, sizeof (cs_t));
17030
17031 memcpy (css_buf_salt, css_buf, css_cnt * sizeof (cs_t));
17032
17033 for (uint i = 0, j = css_cnt; i < salt_len; i++, j++)
17034 {
17035 css_buf_salt[j].cs_buf[0] = salt_buf[i];
17036 css_buf_salt[j].cs_len = 1;
17037 }
17038
17039 free (css_buf);
17040
17041 css_buf = css_buf_salt;
17042 css_cnt = css_cnt_salt;
17043 }
17044 }
17045
17046 data.mask = mask;
17047 data.css_cnt = css_cnt;
17048 data.css_buf = css_buf;
17049
17050 if (maskpos > 0 && dictpos == 0) free (masks[maskpos - 1]);
17051
17052 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
17053
17054 memset (uniq_tbls, 0, sizeof (uniq_tbls));
17055
17056 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
17057
17058 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
17059 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
17060
17061 sp_setup_tbl (install_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
17062
17063 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
17064
17065 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
17066 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
17067
17068 data.root_css_buf = root_css_buf;
17069 data.markov_css_buf = markov_css_buf;
17070
17071 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
17072
17073 data.words_cnt = sp_get_sum (0, css_cnt, root_css_buf);
17074
17075 local_free (root_table_buf);
17076 local_free (markov_table_buf);
17077
17078 // copy + args
17079
17080 uint css_cnt_l = css_cnt;
17081 uint css_cnt_r;
17082
17083 if (attack_exec == ATTACK_EXEC_ON_GPU)
17084 {
17085 if (save_css_cnt < 6)
17086 {
17087 css_cnt_r = 1;
17088 }
17089 else if (save_css_cnt == 6)
17090 {
17091 css_cnt_r = 2;
17092 }
17093 else
17094 {
17095 if (opts_type & OPTS_TYPE_PT_UNICODE)
17096 {
17097 if (save_css_cnt == 8 || save_css_cnt == 10)
17098 {
17099 css_cnt_r = 2;
17100 }
17101 else
17102 {
17103 css_cnt_r = 4;
17104 }
17105 }
17106 else
17107 {
17108 if ((css_buf[0].cs_len * css_buf[1].cs_len * css_buf[2].cs_len) > 256)
17109 {
17110 css_cnt_r = 3;
17111 }
17112 else
17113 {
17114 css_cnt_r = 4;
17115 }
17116 }
17117 }
17118 }
17119 else
17120 {
17121 css_cnt_r = 1;
17122
17123 /* unfinished code?
17124 int sum = css_buf[css_cnt_r - 1].cs_len;
17125
17126 for (uint i = 1; i < 4 && i < css_cnt; i++)
17127 {
17128 if (sum > 1) break; // we really don't need alot of amplifier them for slow hashes
17129
17130 css_cnt_r++;
17131
17132 sum *= css_buf[css_cnt_r - 1].cs_len;
17133 }
17134 */
17135 }
17136
17137 css_cnt_l -= css_cnt_r;
17138
17139 data.bfs_cnt = sp_get_sum (0, css_cnt_r, root_css_buf);
17140
17141 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17142 {
17143 hc_device_param_t *device_param = &data.devices_param[device_id];
17144
17145 device_param->kernel_params_mp_l[0] = &device_param->d_pws_buf;
17146 device_param->kernel_params_mp_l[1] = &device_param->d_root_css_buf;
17147 device_param->kernel_params_mp_l[2] = &device_param->d_markov_css_buf;
17148
17149 device_param->kernel_params_mp_l_buf64[3] = 0;
17150 device_param->kernel_params_mp_l_buf32[4] = css_cnt_l;
17151 device_param->kernel_params_mp_l_buf32[5] = css_cnt_r;
17152 device_param->kernel_params_mp_l_buf32[6] = 0;
17153 device_param->kernel_params_mp_l_buf32[7] = 0;
17154 device_param->kernel_params_mp_l_buf32[8] = 0;
17155
17156 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_l_buf32[6] = full01;
17157 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_l_buf32[6] = full80;
17158 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1;
17159 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1;
17160
17161 device_param->kernel_params_mp_r[0] = &device_param->d_bfs;
17162 device_param->kernel_params_mp_r[1] = &device_param->d_root_css_buf;
17163 device_param->kernel_params_mp_r[2] = &device_param->d_markov_css_buf;
17164
17165 device_param->kernel_params_mp_r_buf64[3] = 0;
17166 device_param->kernel_params_mp_r_buf32[4] = css_cnt_r;
17167 device_param->kernel_params_mp_r_buf32[5] = 0;
17168 device_param->kernel_params_mp_r_buf32[6] = 0;
17169 device_param->kernel_params_mp_r_buf32[7] = 0;
17170
17171 #ifdef _CUDA
17172 hc_cuCtxPushCurrent (device_param->context);
17173
17174 hc_cuMemcpyHtoD (device_param->d_root_css_buf, root_css_buf, device_param->size_root_css);
17175 hc_cuMemcpyHtoD (device_param->d_markov_css_buf, markov_css_buf, device_param->size_markov_css);
17176
17177 hc_cuCtxPopCurrent (&device_param->context);
17178 #elif _OCL
17179 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]);
17180 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]);
17181 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]);
17182
17183 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]);
17184 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]);
17185 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]);
17186
17187 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);
17188 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);
17189 #endif
17190 }
17191 }
17192
17193 uint64_t words_base = data.words_cnt;
17194
17195 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
17196 {
17197 if (data.gpu_rules_cnt)
17198 {
17199 words_base /= data.gpu_rules_cnt;
17200 }
17201 }
17202 else if (data.attack_kern == ATTACK_KERN_COMBI)
17203 {
17204 if (data.combs_cnt)
17205 {
17206 words_base /= data.combs_cnt;
17207 }
17208 }
17209 else if (data.attack_kern == ATTACK_KERN_BF)
17210 {
17211 if (data.bfs_cnt)
17212 {
17213 words_base /= data.bfs_cnt;
17214 }
17215 }
17216
17217 data.words_base = words_base;
17218
17219 if (keyspace == 1)
17220 {
17221 log_info ("%llu", (unsigned long long int) words_base);
17222
17223 return (0);
17224 }
17225
17226 if (data.words_cur > data.words_base)
17227 {
17228 log_error ("ERROR: restore value greater keyspace");
17229
17230 return (-1);
17231 }
17232
17233 if (data.words_cur)
17234 {
17235 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
17236 {
17237 for (uint i = 0; i < data.salts_cnt; i++)
17238 {
17239 data.words_progress_restored[i] = data.words_cur * data.gpu_rules_cnt;
17240 }
17241 }
17242 else if (data.attack_kern == ATTACK_KERN_COMBI)
17243 {
17244 for (uint i = 0; i < data.salts_cnt; i++)
17245 {
17246 data.words_progress_restored[i] = data.words_cur * data.combs_cnt;
17247 }
17248 }
17249 else if (data.attack_kern == ATTACK_KERN_BF)
17250 {
17251 for (uint i = 0; i < data.salts_cnt; i++)
17252 {
17253 data.words_progress_restored[i] = data.words_cur * data.bfs_cnt;
17254 }
17255 }
17256 }
17257
17258 /*
17259 * Inform user about possible slow speeds
17260 */
17261
17262 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
17263 {
17264 if (data.words_base < gpu_blocks_all)
17265 {
17266 if (quiet == 0)
17267 {
17268 log_info ("");
17269 log_info ("ATTENTION!");
17270 log_info (" The wordlist or mask you are using is too small.");
17271 log_info (" Therefore, oclHashcat is unable to utilize the full parallelization power of your GPU(s).");
17272 log_info (" The cracking speed will drop.");
17273 log_info (" Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
17274 log_info ("");
17275 }
17276 }
17277 }
17278
17279 /*
17280 * Update loopback file
17281 */
17282
17283 if (loopback == 1)
17284 {
17285 time_t now;
17286
17287 time (&now);
17288
17289 uint random_num = get_random_num (0, 9999);
17290
17291 snprintf (loopback_file, loopback_size - 1, "%s/%s.%d_%i", induction_directory, LOOPBACK_FILE, (int) now, random_num);
17292
17293 data.loopback_file = loopback_file;
17294 }
17295
17296 /*
17297 * Update dictionary statistic
17298 */
17299
17300 if (keyspace == 0)
17301 {
17302 dictstat_fp = fopen (dictstat, "wb");
17303
17304 if (dictstat_fp)
17305 {
17306 fwrite (dictstat_base, sizeof (dictstat_t), dictstat_nmemb, dictstat_fp);
17307
17308 fclose (dictstat_fp);
17309 }
17310 }
17311
17312 data.devices_status = STATUS_RUNNING;
17313
17314 if (initial_restore_done == 0)
17315 {
17316 if (data.restore_disable == 0) cycle_restore ();
17317
17318 initial_restore_done = 1;
17319 }
17320
17321 hc_timer_set (&data.timer_running);
17322
17323 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
17324 {
17325 if ((quiet == 0) && (status == 0) && (benchmark == 0))
17326 {
17327 if (quiet == 0) fprintf (stdout, "%s", PROMPT);
17328 if (quiet == 0) fflush (stdout);
17329 }
17330 }
17331 else if (wordlist_mode == WL_MODE_STDIN)
17332 {
17333 if (data.quiet == 0) log_info ("Starting attack in stdin mode...");
17334 if (data.quiet == 0) log_info ("");
17335 }
17336
17337 time_t runtime_start;
17338
17339 time (&runtime_start);
17340
17341 data.runtime_start = runtime_start;
17342
17343 /**
17344 * create cracker threads
17345 */
17346
17347 hc_thread_t *c_threads = (hc_thread_t *) mycalloc (devices_cnt, sizeof (hc_thread_t));
17348
17349 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17350 {
17351 hc_device_param_t *device_param = &devices_param[device_id];
17352
17353 device_param->device_id = device_id;
17354
17355 if (wordlist_mode == WL_MODE_STDIN)
17356 {
17357 hc_thread_create (c_threads[device_id], thread_calc_stdin, device_param);
17358 }
17359 else
17360 {
17361 hc_thread_create (c_threads[device_id], thread_calc, device_param);
17362 }
17363 }
17364
17365 // wait for crack threads to exit
17366
17367 hc_thread_wait (devices_cnt, c_threads);
17368
17369 local_free (c_threads);
17370
17371 data.restore = 0;
17372
17373 // finalize task
17374
17375 logfile_sub_var_uint ("status-after-work", data.devices_status);
17376
17377 if (data.devices_status == STATUS_CRACKED) break;
17378 if (data.devices_status == STATUS_ABORTED) break;
17379
17380 if (data.devices_status == STATUS_BYPASS)
17381 {
17382 data.devices_status = STATUS_RUNNING;
17383 }
17384
17385 if (induction_dictionaries_cnt)
17386 {
17387 unlink (induction_dictionaries[0]);
17388 }
17389
17390 free (induction_dictionaries);
17391
17392 if (attack_mode != ATTACK_MODE_BF)
17393 {
17394 induction_dictionaries = scan_directory (induction_directory);
17395
17396 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
17397 }
17398
17399 if (benchmark == 0)
17400 {
17401 if (((dictpos + 1) < dictcnt) || ((maskpos + 1) < maskcnt) || induction_dictionaries_cnt)
17402 {
17403 if (quiet == 0) clear_prompt ();
17404
17405 if (quiet == 0) log_info ("");
17406
17407 if (status == 1)
17408 {
17409 status_display ();
17410 }
17411 else
17412 {
17413 if (quiet == 0) status_display ();
17414 }
17415
17416 if (quiet == 0) log_info ("");
17417 }
17418 }
17419
17420 if (attack_mode == ATTACK_MODE_BF)
17421 {
17422 dictpos++;
17423
17424 rd->dictpos = dictpos;
17425 }
17426 else
17427 {
17428 if (induction_dictionaries_cnt)
17429 {
17430 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
17431 }
17432 else
17433 {
17434 dictpos++;
17435
17436 rd->dictpos = dictpos;
17437 }
17438 }
17439
17440 time_t runtime_stop;
17441
17442 time (&runtime_stop);
17443
17444 data.runtime_stop = runtime_stop;
17445
17446 logfile_sub_uint (runtime_start);
17447 logfile_sub_uint (runtime_stop);
17448
17449 logfile_sub_msg ("STOP");
17450
17451 global_free (subid);
17452 }
17453
17454 if (data.devices_status == STATUS_CRACKED) break;
17455 if (data.devices_status == STATUS_ABORTED) break;
17456 if (data.devices_status == STATUS_QUIT) break;
17457
17458 if (data.devices_status == STATUS_BYPASS)
17459 {
17460 data.devices_status = STATUS_RUNNING;
17461 }
17462 }
17463
17464 // 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
17465
17466 if (attack_mode == ATTACK_MODE_STRAIGHT)
17467 {
17468 if (data.wordlist_mode == WL_MODE_FILE)
17469 {
17470 if (data.dictfile == NULL)
17471 {
17472 if (dictfiles != NULL)
17473 {
17474 data.dictfile = dictfiles[0];
17475
17476 hc_timer_set (&data.timer_running);
17477 }
17478 }
17479 }
17480 }
17481 // NOTE: combi is okay because it is already set beforehand
17482 else if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2)
17483 {
17484 if (data.dictfile == NULL)
17485 {
17486 if (dictfiles != NULL)
17487 {
17488 hc_timer_set (&data.timer_running);
17489
17490 data.dictfile = dictfiles[0];
17491 }
17492 }
17493 }
17494 else if (attack_mode == ATTACK_MODE_BF)
17495 {
17496 if (data.mask == NULL)
17497 {
17498 hc_timer_set (&data.timer_running);
17499
17500 data.mask = masks[0];
17501 }
17502 }
17503
17504 if ((data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
17505 {
17506 data.devices_status = STATUS_EXHAUSTED;
17507 }
17508
17509 // if cracked / aborted remove last induction dictionary
17510
17511 for (int file_pos = 0; file_pos < induction_dictionaries_cnt; file_pos++)
17512 {
17513 struct stat induct_stat;
17514
17515 if (stat (induction_dictionaries[file_pos], &induct_stat) == 0)
17516 {
17517 unlink (induction_dictionaries[file_pos]);
17518 }
17519 }
17520
17521 // wait for non-interactive threads
17522
17523 for (uint thread_idx = 0; thread_idx < ni_threads_cnt; thread_idx++)
17524 {
17525 hc_thread_wait (1, &ni_threads[thread_idx]);
17526 }
17527
17528 local_free (ni_threads);
17529
17530 // wait for interactive threads
17531
17532 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
17533 {
17534 hc_thread_wait (1, &i_thread);
17535 }
17536
17537 // we dont need restore file anymore
17538 if (data.restore_disable == 0)
17539 {
17540 if ((data.devices_status == STATUS_EXHAUSTED) || (data.devices_status == STATUS_CRACKED))
17541 {
17542 unlink (eff_restore_file);
17543 unlink (new_restore_file);
17544 }
17545 else
17546 {
17547 cycle_restore ();
17548 }
17549 }
17550
17551 // finally save left hashes
17552
17553 if ((hashlist_mode == HL_MODE_FILE) && (remove == 1) && (data.digests_saved != data.digests_done))
17554 {
17555 save_hash ();
17556 }
17557
17558 /**
17559 * Clean up
17560 */
17561
17562 if (benchmark == 1)
17563 {
17564 status_benchmark ();
17565
17566 log_info ("");
17567 }
17568 else
17569 {
17570 if (quiet == 0) clear_prompt ();
17571
17572 if (quiet == 0) log_info ("");
17573
17574 if (status == 1)
17575 {
17576 status_display ();
17577 }
17578 else
17579 {
17580 if (quiet == 0) status_display ();
17581 }
17582
17583 if (quiet == 0) log_info ("");
17584 }
17585
17586 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17587 {
17588 hc_device_param_t *device_param = &data.devices_param[device_id];
17589
17590 local_free (device_param->result);
17591
17592 local_free (device_param->pw_caches);
17593
17594 local_free (device_param->combs_buf);
17595
17596 local_free (device_param->hooks_buf);
17597
17598 #ifdef _CUDA
17599 hc_cuCtxPushCurrent (device_param->context);
17600
17601 if (device_param->pws_buf) myfree (device_param->pws_buf);
17602 if (device_param->d_pws_buf) hc_cuMemFree (device_param->d_pws_buf);
17603 if (device_param->d_pws_amp_buf) hc_cuMemFree (device_param->d_pws_amp_buf);
17604 if (device_param->d_rules) hc_cuMemFree (device_param->d_rules);
17605 if (device_param->d_combs) hc_cuMemFree (device_param->d_combs);
17606 if (device_param->d_bfs) hc_cuMemFree (device_param->d_bfs);
17607 if (device_param->d_bitmap_s1_a) hc_cuMemFree (device_param->d_bitmap_s1_a);
17608 if (device_param->d_bitmap_s1_b) hc_cuMemFree (device_param->d_bitmap_s1_b);
17609 if (device_param->d_bitmap_s1_c) hc_cuMemFree (device_param->d_bitmap_s1_c);
17610 if (device_param->d_bitmap_s1_d) hc_cuMemFree (device_param->d_bitmap_s1_d);
17611 if (device_param->d_bitmap_s2_a) hc_cuMemFree (device_param->d_bitmap_s2_a);
17612 if (device_param->d_bitmap_s2_b) hc_cuMemFree (device_param->d_bitmap_s2_b);
17613 if (device_param->d_bitmap_s2_c) hc_cuMemFree (device_param->d_bitmap_s2_c);
17614 if (device_param->d_bitmap_s2_d) hc_cuMemFree (device_param->d_bitmap_s2_d);
17615 if (device_param->d_plain_bufs) hc_cuMemFree (device_param->d_plain_bufs);
17616 if (device_param->d_digests_buf) hc_cuMemFree (device_param->d_digests_buf);
17617 if (device_param->d_digests_shown) hc_cuMemFree (device_param->d_digests_shown);
17618 if (device_param->d_salt_bufs) hc_cuMemFree (device_param->d_salt_bufs);
17619 if (device_param->d_esalt_bufs) hc_cuMemFree (device_param->d_esalt_bufs);
17620 if (device_param->d_tmps) hc_cuMemFree (device_param->d_tmps);
17621 if (device_param->d_hooks) hc_cuMemFree (device_param->d_hooks);
17622 if (device_param->d_result) hc_cuMemFree (device_param->d_result);
17623 if (device_param->d_scryptV_buf) hc_cuMemFree (device_param->d_scryptV_buf);
17624 if (device_param->d_root_css_buf) hc_cuMemFree (device_param->d_root_css_buf);
17625 if (device_param->d_markov_css_buf) hc_cuMemFree (device_param->d_markov_css_buf);
17626
17627 if (device_param->stream) hc_cuStreamDestroy (device_param->stream);
17628 if (device_param->module) hc_cuModuleUnload (device_param->module);
17629
17630 hc_cuCtxPopCurrent (&device_param->context);
17631
17632 if (device_param->context) hc_cuCtxDestroy (device_param->context);
17633
17634 #elif _OCL
17635 local_free (device_param->device_name);
17636
17637 local_free (device_param->device_version);
17638
17639 local_free (device_param->driver_version);
17640
17641 if (device_param->pws_buf) myfree (device_param->pws_buf);
17642 if (device_param->d_pws_buf) hc_clReleaseMemObject (device_param->d_pws_buf);
17643 if (device_param->d_pws_amp_buf) hc_clReleaseMemObject (device_param->d_pws_amp_buf);
17644 if (device_param->d_rules) hc_clReleaseMemObject (device_param->d_rules);
17645 if (device_param->d_rules_c) hc_clReleaseMemObject (device_param->d_rules_c);
17646 if (device_param->d_combs) hc_clReleaseMemObject (device_param->d_combs);
17647 if (device_param->d_combs_c) hc_clReleaseMemObject (device_param->d_combs_c);
17648 if (device_param->d_bfs) hc_clReleaseMemObject (device_param->d_bfs);
17649 if (device_param->d_bfs_c) hc_clReleaseMemObject (device_param->d_bfs_c);
17650 if (device_param->d_bitmap_s1_a) hc_clReleaseMemObject (device_param->d_bitmap_s1_a);
17651 if (device_param->d_bitmap_s1_b) hc_clReleaseMemObject (device_param->d_bitmap_s1_b);
17652 if (device_param->d_bitmap_s1_c) hc_clReleaseMemObject (device_param->d_bitmap_s1_c);
17653 if (device_param->d_bitmap_s1_d) hc_clReleaseMemObject (device_param->d_bitmap_s1_d);
17654 if (device_param->d_bitmap_s2_a) hc_clReleaseMemObject (device_param->d_bitmap_s2_a);
17655 if (device_param->d_bitmap_s2_b) hc_clReleaseMemObject (device_param->d_bitmap_s2_b);
17656 if (device_param->d_bitmap_s2_c) hc_clReleaseMemObject (device_param->d_bitmap_s2_c);
17657 if (device_param->d_bitmap_s2_d) hc_clReleaseMemObject (device_param->d_bitmap_s2_d);
17658 if (device_param->d_plain_bufs) hc_clReleaseMemObject (device_param->d_plain_bufs);
17659 if (device_param->d_digests_buf) hc_clReleaseMemObject (device_param->d_digests_buf);
17660 if (device_param->d_digests_shown) hc_clReleaseMemObject (device_param->d_digests_shown);
17661 if (device_param->d_salt_bufs) hc_clReleaseMemObject (device_param->d_salt_bufs);
17662 if (device_param->d_esalt_bufs) hc_clReleaseMemObject (device_param->d_esalt_bufs);
17663 if (device_param->d_tmps) hc_clReleaseMemObject (device_param->d_tmps);
17664 if (device_param->d_hooks) hc_clReleaseMemObject (device_param->d_hooks);
17665 if (device_param->d_result) hc_clReleaseMemObject (device_param->d_result);
17666 if (device_param->d_scryptV_buf) hc_clReleaseMemObject (device_param->d_scryptV_buf);
17667 if (device_param->d_root_css_buf) hc_clReleaseMemObject (device_param->d_root_css_buf);
17668 if (device_param->d_markov_css_buf) hc_clReleaseMemObject (device_param->d_markov_css_buf);
17669
17670 if (device_param->kernel1) hc_clReleaseKernel (device_param->kernel1);
17671 if (device_param->kernel12) hc_clReleaseKernel (device_param->kernel12);
17672 if (device_param->kernel2) hc_clReleaseKernel (device_param->kernel2);
17673 if (device_param->kernel23) hc_clReleaseKernel (device_param->kernel23);
17674 if (device_param->kernel3) hc_clReleaseKernel (device_param->kernel3);
17675 if (device_param->kernel_mp) hc_clReleaseKernel (device_param->kernel_mp);
17676 if (device_param->kernel_mp_l) hc_clReleaseKernel (device_param->kernel_mp_l);
17677 if (device_param->kernel_mp_r) hc_clReleaseKernel (device_param->kernel_mp_r);
17678
17679 if (device_param->program) hc_clReleaseProgram (device_param->program);
17680 if (device_param->program_mp) hc_clReleaseProgram (device_param->program_mp);
17681 if (device_param->command_queue) hc_clReleaseCommandQueue (device_param->command_queue);
17682 if (device_param->context) hc_clReleaseContext (device_param->context);
17683 #endif
17684 }
17685
17686 #ifdef _OCL
17687 #ifndef OSX
17688
17689 // reset default fan speed
17690
17691 if (gpu_temp_disable == 0)
17692 {
17693 if (gpu_temp_retain != 0)
17694 {
17695 hc_thread_mutex_lock (mux_adl);
17696
17697 for (uint i = 0; i < data.devices_cnt; i++)
17698 {
17699 if (data.hm_device[i].fan_supported == 1)
17700 {
17701 int fanspeed = temp_retain_fanspeed_value[i];
17702
17703 if (fanspeed == -1) continue;
17704
17705 int rc = hm_set_fanspeed_with_device_id (i, fanspeed);
17706
17707 if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", i);
17708 }
17709 }
17710
17711 hc_thread_mutex_unlock (mux_adl);
17712 }
17713 }
17714
17715 // reset power tuning
17716
17717 if (powertune_enable == 1)
17718 {
17719 hc_thread_mutex_lock (mux_adl);
17720
17721 for (uint i = 0; i < data.devices_cnt; i++)
17722 {
17723 if (data.hm_device[i].od_version == 6)
17724 {
17725 // check powertune capabilities first, if not available then skip device
17726
17727 int powertune_supported = 0;
17728
17729 if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK)
17730 {
17731 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
17732
17733 return (-1);
17734 }
17735
17736 if (powertune_supported != 0)
17737 {
17738 // powercontrol settings
17739
17740 if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, od_power_control_status[i])) != ADL_OK)
17741 {
17742 log_info ("ERROR: Failed to restore the ADL PowerControl values");
17743
17744 return (-1);
17745 }
17746
17747 // clocks
17748
17749 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
17750
17751 performance_state->iNumberOfPerformanceLevels = 2;
17752
17753 performance_state->aLevels[0].iEngineClock = od_clock_mem_status[i].state.aLevels[0].iEngineClock;
17754 performance_state->aLevels[1].iEngineClock = od_clock_mem_status[i].state.aLevels[1].iEngineClock;
17755 performance_state->aLevels[0].iMemoryClock = od_clock_mem_status[i].state.aLevels[0].iMemoryClock;
17756 performance_state->aLevels[1].iMemoryClock = od_clock_mem_status[i].state.aLevels[1].iMemoryClock;
17757
17758 if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
17759 {
17760 log_info ("ERROR: Failed to restore ADL performance state");
17761
17762 return (-1);
17763 }
17764
17765 local_free (performance_state);
17766 }
17767 }
17768 }
17769
17770 hc_thread_mutex_unlock (mux_adl);
17771 }
17772
17773 #endif
17774 #endif
17775
17776 if (gpu_temp_disable == 0)
17777 {
17778 #ifdef _CUDA
17779 #ifdef LINUX
17780 hc_NVML_nvmlShutdown ();
17781 #endif
17782
17783 #ifdef WIN
17784 NvAPI_Unload ();
17785 #endif
17786 #endif
17787
17788 #ifdef _OCL
17789 #ifndef OSX
17790 hc_ADL_Main_Control_Destroy (data.hm_dll);
17791
17792 hm_close (data.hm_dll);
17793 #endif
17794 #endif
17795 }
17796
17797 // free memory
17798
17799 local_free (masks);
17800
17801 local_free (dictstat_base);
17802
17803 for (uint pot_pos = 0; pot_pos < pot_cnt; pot_pos++)
17804 {
17805 pot_t *pot_ptr = &pot[pot_pos];
17806
17807 hash_t *hash = &pot_ptr->hash;
17808
17809 local_free (hash->digest);
17810
17811 if (isSalted)
17812 {
17813 local_free (hash->salt);
17814 }
17815 }
17816
17817 local_free (pot);
17818
17819 local_free (all_gpu_rules_cnt);
17820 local_free (all_gpu_rules_buf);
17821
17822 local_free (wl_data->buf);
17823 local_free (wl_data);
17824
17825 local_free (bitmap_s1_a);
17826 local_free (bitmap_s1_b);
17827 local_free (bitmap_s1_c);
17828 local_free (bitmap_s1_d);
17829 local_free (bitmap_s2_a);
17830 local_free (bitmap_s2_b);
17831 local_free (bitmap_s2_c);
17832 local_free (bitmap_s2_d);
17833
17834 #ifdef _OCL
17835 #ifndef OSX
17836 local_free (temp_retain_fanspeed_value);
17837 local_free (od_clock_mem_status);
17838 local_free (od_power_control_status);
17839 #endif
17840 #endif
17841
17842 global_free (devices_param);
17843
17844 global_free (gpu_rules_buf);
17845
17846 global_free (root_css_buf);
17847 global_free (markov_css_buf);
17848
17849 global_free (digests_buf);
17850 global_free (digests_shown);
17851 global_free (digests_shown_tmp);
17852
17853 global_free (salts_buf);
17854 global_free (salts_shown);
17855
17856 global_free (esalts_buf);
17857
17858 global_free (words_progress_done);
17859 global_free (words_progress_rejected);
17860 global_free (words_progress_restored);
17861
17862 if (pot_fp) fclose (pot_fp);
17863
17864 if (data.devices_status == STATUS_QUIT) break;
17865 }
17866
17867 // destroy others mutex
17868
17869 hc_thread_mutex_delete (mux_dispatcher);
17870 hc_thread_mutex_delete (mux_counter);
17871 hc_thread_mutex_delete (mux_display);
17872 hc_thread_mutex_delete (mux_adl);
17873
17874 // free memory
17875
17876 local_free (eff_restore_file);
17877 local_free (new_restore_file);
17878
17879 local_free (rd);
17880
17881 // loopback
17882
17883 local_free (loopback_file);
17884
17885 if (loopback == 1) unlink (loopback_file);
17886
17887 // induction directory
17888
17889 if (induction_dir == NULL)
17890 {
17891 if (attack_mode != ATTACK_MODE_BF)
17892 {
17893 if (rmdir (induction_directory) == -1)
17894 {
17895 if (errno == ENOENT)
17896 {
17897 // good, we can ignore
17898 }
17899 else if (errno == ENOTEMPTY)
17900 {
17901 // good, we can ignore
17902 }
17903 else
17904 {
17905 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
17906
17907 return (-1);
17908 }
17909 }
17910
17911 local_free (induction_directory);
17912 }
17913 }
17914
17915 // outfile-check directory
17916
17917 if (outfile_check_dir == NULL)
17918 {
17919 if (rmdir (outfile_check_directory) == -1)
17920 {
17921 if (errno == ENOENT)
17922 {
17923 // good, we can ignore
17924 }
17925 else if (errno == ENOTEMPTY)
17926 {
17927 // good, we can ignore
17928 }
17929 else
17930 {
17931 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
17932
17933 return (-1);
17934 }
17935 }
17936
17937 local_free (outfile_check_directory);
17938 }
17939
17940 time_t proc_stop;
17941
17942 time (&proc_stop);
17943
17944 logfile_top_uint (proc_start);
17945 logfile_top_uint (proc_stop);
17946
17947 logfile_top_msg ("STOP");
17948
17949 if (quiet == 0) log_info_nn ("Started: %s", ctime (&proc_start));
17950 if (quiet == 0) log_info_nn ("Stopped: %s", ctime (&proc_stop));
17951
17952 if (data.devices_status == STATUS_ABORTED) return 2;
17953 if (data.devices_status == STATUS_QUIT) return 2;
17954 if (data.devices_status == STATUS_EXHAUSTED) return 1;
17955 if (data.devices_status == STATUS_CRACKED) return 0;
17956
17957 return -1;
17958 }