a93c68cb398586b5b1a3c6c20d6eb96b0c54c74d
[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 #include <getopt.h>
10
11 const char *PROGNAME = "oclHashcat";
12 const char *VERSION_TXT = "2.01";
13 const uint VERSION_BIN = 201;
14 const uint RESTORE_MIN = 201;
15
16 #define INCR_RULES 10000
17 #define INCR_SALTS 100000
18 #define INCR_MASKS 1000
19 #define INCR_POT 1000
20
21 #define USAGE 0
22 #define VERSION 0
23 #define QUIET 0
24 #define MARKOV_THRESHOLD 0
25 #define MARKOV_DISABLE 0
26 #define MARKOV_CLASSIC 0
27 #define BENCHMARK 0
28 #define BENCHMARK_MODE 1
29 #define RESTORE 0
30 #define RESTORE_TIMER 60
31 #define RESTORE_DISABLE 0
32 #define STATUS 0
33 #define STATUS_TIMER 10
34 #define STATUS_AUTOMAT 0
35 #define LOOPBACK 0
36 #define WEAK_HASH_THRESHOLD 100
37 #define SHOW 0
38 #define LEFT 0
39 #define USERNAME 0
40 #define REMOVE 0
41 #define REMOVE_TIMER 60
42 #define SKIP 0
43 #define LIMIT 0
44 #define KEYSPACE 0
45 #define POTFILE_DISABLE 0
46 #define DEBUG_MODE 0
47 #define RP_GEN 0
48 #define RP_GEN_FUNC_MIN 1
49 #define RP_GEN_FUNC_MAX 4
50 #define RP_GEN_SEED 0
51 #define RULE_BUF_L ":"
52 #define RULE_BUF_R ":"
53 #define FORCE 0
54 #define RUNTIME 0
55 #define HEX_CHARSET 0
56 #define HEX_SALT 0
57 #define HEX_WORDLIST 0
58 #define OUTFILE_FORMAT 3
59 #define OUTFILE_AUTOHEX 1
60 #define OUTFILE_CHECK_TIMER 5
61 #define ATTACK_MODE 0
62 #define HASH_MODE 0
63 #define SEGMENT_SIZE 32
64 #define INCREMENT 0
65 #define INCREMENT_MIN 1
66 #define INCREMENT_MAX PW_MAX
67 #define SEPARATOR ':'
68 #define BITMAP_MIN 16
69 #define BITMAP_MAX 24
70 #define GPU_TEMP_DISABLE 0
71 #define GPU_TEMP_ABORT 90
72 #define GPU_TEMP_RETAIN 80
73 #define WORKLOAD_PROFILE 2
74 #define GPU_ACCEL 0
75 #define GPU_LOOPS 0
76 #define GPU_RULES 1024
77 #define GPU_COMBS 1024
78 #define GPU_BFS 1024
79 #define GPU_THREADS 64
80 #define POWERTUNE_ENABLE 0
81 #define LOGFILE_DISABLE 0
82 #define SCRYPT_TMTO 0
83
84 #define WL_MODE_STDIN 1
85 #define WL_MODE_FILE 2
86 #define WL_MODE_MASK 3
87
88 #define HL_MODE_FILE 4
89 #define HL_MODE_ARG 5
90
91 #define HLFMT_HASHCAT 0
92 #define HLFMT_PWDUMP 1
93 #define HLFMT_PASSWD 2
94 #define HLFMT_SHADOW 3
95 #define HLFMT_DCC 4
96 #define HLFMT_DCC2 5
97 #define HLFMT_NETNTLM1 7
98 #define HLFMT_NETNTLM2 8
99 #define HLFMT_NSLDAP 9
100 #define HLFMT_NSLDAPS 10
101 #define HLFMTS_CNT 11
102
103 #define ATTACK_MODE_STRAIGHT 0
104 #define ATTACK_MODE_COMBI 1
105 #define ATTACK_MODE_TOGGLE 2
106 #define ATTACK_MODE_BF 3
107 #define ATTACK_MODE_PERM 4
108 #define ATTACK_MODE_TABLE 5
109 #define ATTACK_MODE_HYBRID1 6
110 #define ATTACK_MODE_HYBRID2 7
111 #define ATTACK_MODE_NONE 100
112
113 #define ATTACK_KERN_STRAIGHT 0
114 #define ATTACK_KERN_COMBI 1
115 #define ATTACK_KERN_BF 3
116 #define ATTACK_KERN_NONE 100
117
118 #define ATTACK_EXEC_ON_CPU 10
119 #define ATTACK_EXEC_ON_GPU 11
120
121 #define COMBINATOR_MODE_BASE_LEFT 10001
122 #define COMBINATOR_MODE_BASE_RIGHT 10002
123
124 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
125 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
126
127 #define MAX_CUT_TRIES 4
128
129 #define MAX_DICTSTAT 10000
130
131 #define NUM_DEFAULT_BENCHMARK_ALGORITHMS 128
132
133 #define global_free(attr) \
134 { \
135 myfree ((void *) data.attr); \
136 \
137 data.attr = NULL; \
138 }
139
140 #define local_free(attr) \
141 { \
142 myfree ((void *) attr); \
143 \
144 attr = NULL; \
145 }
146
147 static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
148 {
149 900,
150 0,
151 5100,
152 100,
153 1400,
154 10800,
155 1700,
156 5000,
157 10100,
158 6000,
159 6100,
160 6900,
161 11700,
162 11800,
163 400,
164 8900,
165 11900,
166 12000,
167 10900,
168 12100,
169 23,
170 2500,
171 5300,
172 5400,
173 5500,
174 5600,
175 7300,
176 7500,
177 8300,
178 11100,
179 11200,
180 11400,
181 121,
182 2611,
183 2711,
184 2811,
185 8400,
186 11,
187 2612,
188 7900,
189 21,
190 11000,
191 124,
192 10000,
193 3711,
194 7600,
195 12,
196 131,
197 132,
198 1731,
199 200,
200 300,
201 3100,
202 112,
203 12300,
204 8000,
205 141,
206 1441,
207 1600,
208 12600,
209 1421,
210 101,
211 111,
212 1711,
213 3000,
214 1000,
215 1100,
216 2100,
217 12800,
218 1500,
219 12400,
220 500,
221 3200,
222 7400,
223 1800,
224 122,
225 1722,
226 7100,
227 6300,
228 6700,
229 6400,
230 6500,
231 2400,
232 2410,
233 5700,
234 9200,
235 9300,
236 22,
237 501,
238 5800,
239 8100,
240 8500,
241 7200,
242 9900,
243 7700,
244 7800,
245 10300,
246 8600,
247 8700,
248 9100,
249 133,
250 11600,
251 12500,
252 6211,
253 6221,
254 6231,
255 6241,
256 8800,
257 12200,
258 9700,
259 9710,
260 9800,
261 9810,
262 9400,
263 9500,
264 9600,
265 10400,
266 10410,
267 10500,
268 10600,
269 10700,
270 9000,
271 5200,
272 6800,
273 6600,
274 8200,
275 11300,
276 12700
277 };
278
279 /**
280 * types
281 */
282
283 static void (*get_next_word_func) (char *, uint32_t, uint32_t *, uint32_t *);
284
285 /**
286 * globals
287 */
288
289 static unsigned int full01 = 0x01010101;
290 static unsigned int full80 = 0x80808080;
291
292 int SUPPRESS_OUTPUT = 0;
293
294 hc_thread_mutex_t mux_adl;
295 hc_thread_mutex_t mux_counter;
296 hc_thread_mutex_t mux_dispatcher;
297 hc_thread_mutex_t mux_display;
298
299 hc_global_data_t data;
300
301 const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => ";
302
303 const char *USAGE_MINI[] =
304 {
305 "Usage: %s [options]... hash|hashfile|hccapfile [dictionary|mask|directory]...",
306 "",
307 "Try --help for more help.",
308 NULL
309 };
310
311 const char *USAGE_BIG[] =
312 {
313 "%s, advanced password recovery",
314 "",
315 "Usage: %s [options]... hash|hashfile|hccapfile [dictionary|mask|directory]...",
316 "",
317 "=======",
318 "Options",
319 "=======",
320 "",
321 "* General:",
322 "",
323 " -m, --hash-type=NUM Hash-type, see references below",
324 " -a, --attack-mode=NUM Attack-mode, see references below",
325 " -V, --version Print version",
326 " -h, --help Print help",
327 " --quiet Suppress output",
328 "",
329 "* Benchmark:",
330 "",
331 " -b, --benchmark Run benchmark",
332 " --benchmark-mode=NUM Benchmark-mode, see references below",
333 "",
334 "* Misc:",
335 "",
336 " --hex-charset Assume charset is given in hex",
337 " --hex-salt Assume salt is given in hex",
338 " --hex-wordlist Assume words in wordlist is given in hex",
339 " --force Ignore warnings",
340 " --status Enable automatic update of the status-screen",
341 " --status-timer=NUM Seconds between status-screen update",
342 " --status-automat Display the status view in a machine readable format",
343 " --loopback Add new plains to induct directory",
344 " --weak-hash-threshold=NUM Threshold when to stop checking for weak hashes, default is 100 salts",
345 "",
346 "* Markov:",
347 "",
348 " --markov-hcstat=FILE Specify hcstat file to use, default is hashcat.hcstat",
349 " --markov-disable Disables markov-chains, emulates classic brute-force",
350 " --markov-classic Enables classic markov-chains, no per-position enhancement",
351 " -t, --markov-threshold=NUM Threshold when to stop accepting new markov-chains",
352 "",
353 "* Session:",
354 "",
355 " --runtime=NUM Abort session after NUM seconds of runtime",
356 " --session=STR Define specific session name",
357 " --restore Restore session from --session",
358 " --restore-disable Do not write restore file",
359 "",
360 "* Files:",
361 "",
362 " -o, --outfile=FILE Define outfile for recovered hash",
363 " --outfile-format=NUM Define outfile-format for recovered hash, see references below",
364 " --outfile-autohex-disable Disable the use of $HEX[] in output plains",
365 " --outfile-check-timer=NUM Seconds between outfile checks",
366 " -p, --separator=CHAR Separator char for hashlists and outfile",
367 " --show Show cracked passwords only",
368 " --left Show un-cracked passwords only",
369 " --username Enable ignoring of usernames in hashfile (recommended: also use --show)",
370 " --remove Enable remove of hash once it is cracked",
371 " --remove-timer=NUM Update input hash file each NUM seconds",
372 " --potfile-disable Do not write potfile",
373 " --debug-mode=NUM Defines the debug mode (hybrid only by using rules), see references below",
374 " --debug-file=FILE Output file for debugging rules (see also --debug-mode)",
375 " --induction-dir=FOLDER Specify induction directory to use, default is $session.induct",
376 " --outfile-check-dir=FOLDER Specify the outfile directory which should be monitored, default is $session.outfiles",
377 " --logfile-disable Disable the logfile",
378 " --truecrypt-keyfiles=FILE Keyfiles used, seperate with comma",
379 "",
380 "* Resources:",
381 "",
382 " -c, --segment-size=NUM Size in MB to cache from the wordfile",
383 " --bitmap-min=NUM Minimum number of bits allowed for bitmaps",
384 " --bitmap-max=NUM Maximum number of bits allowed for bitmaps",
385 " --cpu-affinity=STR Locks to CPU devices, seperate with comma",
386 " -d, --gpu-devices=STR OpenCL devices to use, separate with comma",
387 " --gpu-platform=STR OpenCL platform to use, in case multiple OpenCL platforms are present",
388 " -w, --workload-profile=NUM Enable a specific workload profile, see references below",
389 " -n, --gpu-accel=NUM Workload tuning: 1, 8, 40, 80, 160",
390 " -u, --gpu-loops=NUM Workload fine-tuning: 8 - 1024",
391 " --gpu-temp-disable Disable temperature and fanspeed readings and triggers",
392 " --gpu-temp-abort=NUM Abort session if GPU temperature reaches NUM degrees celsius",
393 " --gpu-temp-retain=NUM Try to retain GPU temperature at NUM degrees celsius (AMD only)",
394 " --powertune-enable Enable automatic power tuning option (AMD OverDrive 6 only)",
395 " --scrypt-tmto=NUM Manually override automatically calculated TMTO value for scrypt",
396 "",
397 "* Distributed:",
398 "",
399 " -s, --skip=NUM Skip number of words",
400 " -l, --limit=NUM Limit number of words",
401 " --keyspace Show keyspace base:mod values and quit",
402 "",
403 "* Rules:",
404 "",
405 " -j, --rule-left=RULE Single rule applied to each word from left dict",
406 " -k, --rule-right=RULE Single rule applied to each word from right dict",
407 " -r, --rules-file=FILE Rules-file, multi use: -r 1.rule -r 2.rule",
408 " -g, --generate-rules=NUM Generate NUM random rules",
409 " --generate-rules-func-min=NUM Force NUM functions per random rule min",
410 " --generate-rules-func-max=NUM Force NUM functions per random rule max",
411 " --generate-rules-seed=NUM Force RNG seed to NUM",
412 "",
413 "* Custom charsets:",
414 "",
415 " -1, --custom-charset1=CS User-defined charsets",
416 " -2, --custom-charset2=CS Example:",
417 " -3, --custom-charset3=CS --custom-charset1=?dabcdef : sets charset ?1 to 0123456789abcdef",
418 " -4, --custom-charset4=CS -2 mycharset.hcchr : sets charset ?2 to chars contained in file",
419 "",
420 "* Increment:",
421 "",
422 " -i, --increment Enable increment mode",
423 " --increment-min=NUM Start incrementing at NUM",
424 " --increment-max=NUM Stop incrementing at NUM",
425 "",
426 "==========",
427 "References",
428 "==========",
429 "",
430 "* Workload Profile:",
431 "",
432 " 1 = Reduced performance profile (low latency desktop)",
433 " 2 = Default performance profile",
434 " 3 = Tuned performance profile (high latency desktop)",
435 "",
436 "* Benchmark Settings:",
437 "",
438 " 0 = Manual Tuning",
439 " 1 = Performance Tuning, default",
440 "",
441 "* Outfile Formats:",
442 "",
443 " 1 = hash[:salt]",
444 " 2 = plain",
445 " 3 = hash[:salt]:plain",
446 " 4 = hex_plain",
447 " 5 = hash[:salt]:hex_plain",
448 " 6 = plain:hex_plain",
449 " 7 = hash[:salt]:plain:hex_plain",
450 " 8 = crackpos",
451 " 9 = hash[:salt]:crackpos",
452 " 10 = plain:crackpos",
453 " 11 = hash[:salt]:plain:crackpos",
454 " 12 = hex_plain:crackpos",
455 " 13 = hash[:salt]:hex_plain:crackpos",
456 " 14 = plain:hex_plain:crackpos",
457 " 15 = hash[:salt]:plain:hex_plain:crackpos",
458 "",
459 "* Debug mode output formats (for hybrid mode only, by using rules):",
460 "",
461 " 1 = save finding rule",
462 " 2 = save original word",
463 " 3 = save original word and finding rule",
464 " 4 = save original word, finding rule and modified plain",
465 "",
466 "* Built-in charsets:",
467 "",
468 " ?l = abcdefghijklmnopqrstuvwxyz",
469 " ?u = ABCDEFGHIJKLMNOPQRSTUVWXYZ",
470 " ?d = 0123456789",
471 " ?s = !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
472 " ?a = ?l?u?d?s",
473 " ?b = 0x00 - 0xff",
474 "",
475 "* Attack modes:",
476 "",
477 " 0 = Straight",
478 " 1 = Combination",
479 " 3 = Brute-force",
480 " 6 = Hybrid dict + mask",
481 " 7 = Hybrid mask + dict",
482 "",
483 "* Hash types:",
484 "",
485 "[[ Roll-your-own: Raw Hashes ]]",
486 "",
487 " 900 = MD4",
488 " 0 = MD5",
489 " 5100 = Half MD5",
490 " 100 = SHA1",
491 " 10800 = SHA-384",
492 " 1400 = SHA-256",
493 " 1700 = SHA-512",
494 " 5000 = SHA-3(Keccak)",
495 " 10100 = SipHash",
496 " 6000 = RipeMD160",
497 " 6100 = Whirlpool",
498 " 6900 = GOST R 34.11-94",
499 " 11700 = GOST R 34.11-2012 (Streebog) 256-bit",
500 " 11800 = GOST R 34.11-2012 (Streebog) 512-bit",
501 "",
502 "[[ Roll-your-own: Iterated and / or Salted Hashes ]]",
503 "",
504 " 10 = md5($pass.$salt)",
505 " 20 = md5($salt.$pass)",
506 " 30 = md5(unicode($pass).$salt)",
507 " 40 = md5($salt.unicode($pass))",
508 " 3800 = md5($salt.$pass.$salt)",
509 " 3710 = md5($salt.md5($pass))",
510 " 2600 = md5(md5($pass)",
511 " 4300 = md5(strtoupper(md5($pass)))",
512 " 4400 = md5(sha1($pass))",
513 " 110 = sha1($pass.$salt)",
514 " 120 = sha1($salt.$pass)",
515 " 130 = sha1(unicode($pass).$salt)",
516 " 140 = sha1($salt.unicode($pass))",
517 " 4500 = sha1(sha1($pass)",
518 " 4700 = sha1(md5($pass))",
519 " 4900 = sha1($salt.$pass.$salt)",
520 " 1410 = sha256($pass.$salt)",
521 " 1420 = sha256($salt.$pass)",
522 " 1430 = sha256(unicode($pass).$salt)",
523 " 1440 = sha256($salt.unicode($pass))",
524 " 1710 = sha512($pass.$salt)",
525 " 1720 = sha512($salt.$pass)",
526 " 1730 = sha512(unicode($pass).$salt)",
527 " 1740 = sha512($salt.unicode($pass))",
528 "",
529 "[[ Roll-your-own: Authenticated Hashes ]]",
530 "",
531 " 50 = HMAC-MD5 (key = $pass)",
532 " 60 = HMAC-MD5 (key = $salt)",
533 " 150 = HMAC-SHA1 (key = $pass)",
534 " 160 = HMAC-SHA1 (key = $salt)",
535 " 1450 = HMAC-SHA256 (key = $pass)",
536 " 1460 = HMAC-SHA256 (key = $salt)",
537 " 1750 = HMAC-SHA512 (key = $pass)",
538 " 1760 = HMAC-SHA512 (key = $salt)",
539 "",
540 "[[ Generic KDF ]]",
541 "",
542 " 400 = phpass",
543 " 8900 = scrypt",
544 " 11900 = PBKDF2-HMAC-MD5",
545 " 12000 = PBKDF2-HMAC-SHA1",
546 " 10900 = PBKDF2-HMAC-SHA256",
547 " 12100 = PBKDF2-HMAC-SHA512",
548 "",
549 "[[ Network protocols, Challenge-Response ]]",
550 "",
551 " 23 = Skype",
552 " 2500 = WPA/WPA2",
553 " 4800 = iSCSI CHAP authentication, MD5(Chap)",
554 " 5300 = IKE-PSK MD5",
555 " 5400 = IKE-PSK SHA1",
556 " 5500 = NetNTLMv1",
557 " 5500 = NetNTLMv1 + ESS",
558 " 5600 = NetNTLMv2",
559 " 7300 = IPMI2 RAKP HMAC-SHA1",
560 " 7500 = Kerberos 5 AS-REQ Pre-Auth etype 23",
561 " 8300 = DNSSEC (NSEC3)",
562 " 10200 = Cram MD5",
563 " 11100 = PostgreSQL Challenge-Response Authentication (MD5)",
564 " 11200 = MySQL Challenge-Response Authentication (SHA1)",
565 " 11400 = SIP digest authentication (MD5)",
566 "",
567 "[[ Forums, CMS, E-Commerce, Frameworks, Middleware, Wiki, Management ]]",
568 "",
569 " 121 = SMF (Simple Machines Forum)",
570 " 400 = phpBB3",
571 " 2611 = vBulletin < v3.8.5",
572 " 2711 = vBulletin > v3.8.5",
573 " 2811 = MyBB",
574 " 2811 = IPB (Invison Power Board)",
575 " 8400 = WBB3 (Woltlab Burning Board)",
576 " 11 = Joomla < 2.5.18",
577 " 400 = Joomla > 2.5.18",
578 " 400 = Wordpress",
579 " 2612 = PHPS",
580 " 7900 = Drupal7",
581 " 21 = osCommerce",
582 " 21 = xt:Commerce",
583 " 11000 = PrestaShop",
584 " 124 = Django (SHA-1)",
585 " 10000 = Django (PBKDF2-SHA256)",
586 " 3711 = Mediawiki B type",
587 " 7600 = Redmine",
588 "",
589 "[[ Database Server ]]",
590 "",
591 " 12 = PostgreSQL",
592 " 131 = MSSQL(2000)",
593 " 132 = MSSQL(2005)",
594 " 1731 = MSSQL(2012)",
595 " 1731 = MSSQL(2014)",
596 " 200 = MySQL323",
597 " 300 = MySQL4.1/MySQL5",
598 " 3100 = Oracle H: Type (Oracle 7+)",
599 " 112 = Oracle S: Type (Oracle 11+)",
600 " 12300 = Oracle T: Type (Oracle 12+)",
601 " 8000 = Sybase ASE",
602 "",
603 "[[ HTTP, SMTP, LDAP Server]]",
604 "",
605 " 141 = EPiServer 6.x < v4",
606 " 1441 = EPiServer 6.x > v4",
607 " 1600 = Apache $apr1$",
608 " 12600 = ColdFusion 10+",
609 " 1421 = hMailServer",
610 " 101 = nsldap, SHA-1(Base64), Netscape LDAP SHA",
611 " 111 = nsldaps, SSHA-1(Base64), Netscape LDAP SSHA",
612 " 1711 = SSHA-512(Base64), LDAP {SSHA512}",
613 "",
614 "[[ Checksums ]]",
615 "",
616 " 11500 = CRC32",
617 "",
618 "[[ Operating-Systems ]]",
619 "",
620 " 3000 = LM",
621 " 1000 = NTLM",
622 " 1100 = Domain Cached Credentials (DCC), MS Cache",
623 " 2100 = Domain Cached Credentials 2 (DCC2), MS Cache 2",
624 " 12800 = MS-AzureSync PBKDF2-HMAC-SHA256",
625 " 1500 = descrypt, DES(Unix), Traditional DES",
626 " 12400 = BSDiCrypt, Extended DES",
627 " 500 = md5crypt $1$, MD5(Unix)",
628 " 3200 = bcrypt $2*$, Blowfish(Unix)",
629 " 7400 = sha256crypt $5$, SHA256(Unix)",
630 " 1800 = sha512crypt $6$, SHA512(Unix)",
631 " 122 = OSX v10.4",
632 " 122 = OSX v10.5",
633 " 122 = OSX v10.6",
634 " 1722 = OSX v10.7",
635 " 7100 = OSX v10.8",
636 " 7100 = OSX v10.9",
637 " 7100 = OSX v10.10",
638 " 6300 = AIX {smd5}",
639 " 6700 = AIX {ssha1}",
640 " 6400 = AIX {ssha256}",
641 " 6500 = AIX {ssha512}",
642 " 2400 = Cisco-PIX",
643 " 2410 = Cisco-ASA",
644 " 500 = Cisco-IOS $1$",
645 " 5700 = Cisco-IOS $4$",
646 " 9200 = Cisco-IOS $8$",
647 " 9300 = Cisco-IOS $9$",
648 " 22 = Juniper Netscreen/SSG (ScreenOS)",
649 " 501 = Juniper IVE",
650 " 5800 = Android PIN",
651 " 8100 = Citrix Netscaler",
652 " 8500 = RACF",
653 " 7200 = GRUB 2",
654 " 9900 = Radmin2",
655 "",
656 "[[ Enterprise Application Software (EAS) ]]",
657 "",
658 " 7700 = SAP CODVN B (BCODE)",
659 " 7800 = SAP CODVN F/G (PASSCODE)",
660 " 10300 = SAP CODVN H (PWDSALTEDHASH) iSSHA-1",
661 " 8600 = Lotus Notes/Domino 5",
662 " 8700 = Lotus Notes/Domino 6",
663 " 9100 = Lotus Notes/Domino 8",
664 " 133 = PeopleSoft",
665 "",
666 "[[ Archives ]]",
667 "",
668 " 11600 = 7-Zip",
669 " 12500 = RAR3-hp",
670 "",
671 "[[ Full-Disk encryptions (FDE) ]]",
672 "",
673 " 62XY = TrueCrypt 5.0+",
674 " X = 1 = PBKDF2-HMAC-RipeMD160",
675 " X = 2 = PBKDF2-HMAC-SHA512",
676 " X = 3 = PBKDF2-HMAC-Whirlpool",
677 " X = 4 = PBKDF2-HMAC-RipeMD160 + boot-mode",
678 " Y = 1 = XTS 512 bit (Ciphers: AES or Serpent or Twofish)",
679 " Y = 2 = XTS 1024 bit (Ciphers: AES or Serpent or Twofish or AES-Twofish or Serpent-AES or Twofish-Serpent)",
680 " Y = 3 = XTS 1536 bit (Ciphers: All)",
681 " 8800 = Android FDE < v4.3",
682 " 12200 = eCryptfs",
683 "",
684 "[[ Documents ]]",
685 "",
686 " 9700 = MS Office <= 2003 MD5 + RC4, oldoffice$0, oldoffice$1",
687 " 9710 = MS Office <= 2003 MD5 + RC4, collider-mode #1",
688 " 9720 = MS Office <= 2003 MD5 + RC4, collider-mode #2",
689 " 9800 = MS Office <= 2003 SHA1 + RC4, oldoffice$3, oldoffice$4",
690 " 9810 = MS Office <= 2003 SHA1 + RC4, collider-mode #1",
691 " 9820 = MS Office <= 2003 SHA1 + RC4, collider-mode #2",
692 " 9400 = MS Office 2007",
693 " 9500 = MS Office 2010",
694 " 9600 = MS Office 2013",
695 " 10400 = PDF 1.1 - 1.3 (Acrobat 2 - 4)",
696 " 10410 = PDF 1.1 - 1.3 (Acrobat 2 - 4) + collider-mode #1",
697 " 10420 = PDF 1.1 - 1.3 (Acrobat 2 - 4) + collider-mode #2",
698 " 10500 = PDF 1.4 - 1.6 (Acrobat 5 - 8)",
699 " 10600 = PDF 1.7 Level 3 (Acrobat 9)",
700 " 10700 = PDF 1.7 Level 8 (Acrobat 10 - 11)",
701 "",
702 "[[ Password Managers ]]",
703 "",
704 " 9000 = Password Safe v2",
705 " 5200 = Password Safe v3",
706 " 6800 = Lastpass",
707 " 6600 = 1Password, agilekeychain",
708 " 8200 = 1Password, cloudkeychain",
709 " 11300 = Bitcoin/Litecoin wallet.dat",
710 " 12700 = Blockchain, My Wallet",
711 "",
712 NULL
713 };
714
715 /**
716 * oclHashcat specific functions
717 */
718
719 void status_display_automat ()
720 {
721 FILE *out = stdout;
722
723 fprintf (out, "STATUS\t%u\t", data.devices_status);
724
725 /**
726 * speed new
727 */
728
729 fprintf (out, "SPEED\t");
730
731 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
732 {
733 hc_device_param_t *device_param = &data.devices_param[device_id];
734
735 uint64_t speed_cnt = 0;
736 float speed_ms = 0;
737
738 for (int i = 0; i < SPEED_CACHE; i++)
739 {
740 float rec_ms;
741
742 hc_timer_get (device_param->speed_rec[i], rec_ms);
743
744 if (rec_ms > SPEED_MAXAGE) continue;
745
746 speed_cnt += device_param->speed_cnt[i];
747 speed_ms += device_param->speed_ms[i];
748 }
749
750 speed_cnt /= SPEED_CACHE;
751 speed_ms /= SPEED_CACHE;
752
753 fprintf (out, "%llu\t%f\t", (unsigned long long int) speed_cnt, speed_ms);
754 }
755
756 /**
757 * words_cur
758 */
759
760 uint64_t words_cur = get_lowest_words_done ();
761
762 fprintf (out, "CURKU\t%llu\t", (unsigned long long int) words_cur);
763
764 /**
765 * counter
766 */
767
768 uint salts_left = data.salts_cnt - data.salts_done;
769
770 if (salts_left == 0) salts_left = 1;
771
772 uint64_t progress_total = data.words_cnt * salts_left;
773
774 uint64_t all_done = 0;
775 uint64_t all_rejected = 0;
776 uint64_t all_restored = 0;
777
778 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
779 {
780 if (salts_left > 1)
781 {
782 // otherwise the final cracked status shows 0/XXX progress
783
784 if (data.salts_shown[salt_pos] == 1) continue;
785 }
786
787 all_done += data.words_progress_done[salt_pos];
788 all_rejected += data.words_progress_rejected[salt_pos];
789 all_restored += data.words_progress_restored[salt_pos];
790 }
791
792 uint64_t progress_cur = all_restored + all_done + all_rejected;
793 uint64_t progress_end = progress_total;
794
795 uint64_t progress_skip = 0;
796
797 if (data.skip)
798 {
799 progress_skip = MIN (data.skip, data.words_base) * salts_left;
800
801 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.gpu_rules_cnt;
802 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt;
803 else if (data.attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt;
804 }
805
806 if (data.limit)
807 {
808 progress_end = MIN (data.limit, data.words_base) * salts_left;
809
810 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.gpu_rules_cnt;
811 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt;
812 else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
813 }
814
815 uint64_t progress_cur_relative_skip = progress_cur - progress_skip;
816 uint64_t progress_end_relative_skip = progress_end - progress_skip;
817
818 fprintf (out, "PROGRESS\t%llu\t%llu\t", (unsigned long long int) progress_cur_relative_skip, (unsigned long long int) progress_end_relative_skip);
819
820 /**
821 * cracks
822 */
823
824 fprintf (out, "RECHASH\t%u\t%u\t", data.digests_done, data.digests_cnt);
825 fprintf (out, "RECSALT\t%u\t%u\t", data.salts_done, data.salts_cnt);
826
827 /**
828 * temperature
829 */
830
831 if (data.gpu_temp_disable == 0)
832 {
833 fprintf (out, "TEMP\t");
834
835 hc_thread_mutex_lock (mux_adl);
836
837 for (uint i = 0; i < data.devices_cnt; i++)
838 {
839 int temp = hm_get_temperature_with_device_id (i);
840
841 fprintf (out, "%d\t", temp);
842 }
843
844 hc_thread_mutex_unlock (mux_adl);
845 }
846
847 #ifdef _WIN
848 fputc ('\r', out);
849 fputc ('\n', out);
850 #endif
851
852 #ifdef _POSIX
853 fputc ('\n', out);
854 #endif
855
856 fflush (out);
857 }
858
859 void status_display ()
860 {
861 if (data.devices_status == STATUS_INIT) return;
862 if (data.devices_status == STATUS_STARTING) return;
863 if (data.devices_status == STATUS_BYPASS) return;
864
865 if (data.status_automat == 1)
866 {
867 status_display_automat ();
868
869 return;
870 }
871
872 char tmp_buf[1000];
873
874 uint tmp_len = 0;
875
876 log_info ("Session.Name...: %s", data.session);
877
878 char *status_type = strstatus (data.devices_status);
879
880 uint hash_mode = data.hash_mode;
881
882 char *hash_type = strhashtype (hash_mode); // not a bug
883
884 log_info ("Status.........: %s", status_type);
885
886 /**
887 * show rules
888 */
889
890 if (data.rp_files_cnt)
891 {
892 uint i;
893
894 for (i = 0, tmp_len = 0; i < data.rp_files_cnt - 1 && tmp_len < sizeof (tmp_buf); i++)
895 {
896 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s), ", data.rp_files[i]);
897 }
898
899 snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", data.rp_files[i]);
900
901 log_info ("Rules.Type.....: %s", tmp_buf);
902
903 tmp_len = 0;
904 }
905
906 if (data.rp_gen)
907 {
908 log_info ("Rules.Type.....: Generated (%u)", data.rp_gen);
909
910 if (data.rp_gen_seed)
911 {
912 log_info ("Rules.Seed.....: %u", data.rp_gen_seed);
913 }
914 }
915
916 /**
917 * show input
918 */
919
920 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
921 {
922 if (data.wordlist_mode == WL_MODE_FILE)
923 {
924 if (data.dictfile != NULL) log_info ("Input.Mode.....: File (%s)", data.dictfile);
925 }
926 else if (data.wordlist_mode == WL_MODE_STDIN)
927 {
928 log_info ("Input.Mode.....: Pipe");
929 }
930 }
931 else if (data.attack_mode == ATTACK_MODE_COMBI)
932 {
933 if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
934 if (data.dictfile2 != NULL) log_info ("Input.Right....: File (%s)", data.dictfile2);
935 }
936 else if (data.attack_mode == ATTACK_MODE_BF)
937 {
938 char *mask = data.mask;
939
940 if (mask != NULL)
941 {
942 uint mask_len = data.css_cnt;
943
944 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "Mask (%s)", mask);
945
946 if (mask_len > 0)
947 {
948 if (data.opti_type & OPTI_TYPE_SINGLE_HASH)
949 {
950 if (data.opti_type & OPTI_TYPE_APPENDED_SALT)
951 {
952 mask_len -= data.salts_buf[0].salt_len;
953 }
954 }
955
956 if (data.opts_type & OPTS_TYPE_PT_UNICODE) mask_len /= 2;
957
958 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " [%i]", mask_len);
959 }
960
961 if (data.maskcnt > 1)
962 {
963 float mask_percentage = (float) data.maskpos / (float) data.maskcnt;
964
965 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100);
966 }
967
968 log_info ("Input.Mode.....: %s", tmp_buf);
969 }
970
971 tmp_len = 0;
972 }
973 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
974 {
975 if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
976 if (data.mask != NULL) log_info ("Input.Right....: Mask (%s) [%i]", data.mask, data.css_cnt);
977 }
978 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
979 {
980 if (data.mask != NULL) log_info ("Input.Left.....: Mask (%s) [%i]", data.mask, data.css_cnt);
981 if (data.dictfile != NULL) log_info ("Input.Right....: File (%s)", data.dictfile);
982 }
983
984 if (data.digests_cnt == 1)
985 {
986 if (data.hash_mode == 2500)
987 {
988 wpa_t *wpa = (wpa_t *) data.esalts_buf;
989
990 uint pke[25];
991
992 char *pke_ptr = (char *) pke;
993
994 for (uint i = 0; i < 25; i++)
995 {
996 pke[i] = byte_swap_32 (wpa->pke[i]);
997 }
998
999 char mac1[6];
1000 char mac2[6];
1001
1002 memcpy (mac1, pke_ptr + 23, 6);
1003 memcpy (mac2, pke_ptr + 29, 6);
1004
1005 log_info ("Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)",
1006 (char *) data.salts_buf[0].salt_buf,
1007 mac1[0] & 0xff,
1008 mac1[1] & 0xff,
1009 mac1[2] & 0xff,
1010 mac1[3] & 0xff,
1011 mac1[4] & 0xff,
1012 mac1[5] & 0xff,
1013 mac2[0] & 0xff,
1014 mac2[1] & 0xff,
1015 mac2[2] & 0xff,
1016 mac2[3] & 0xff,
1017 mac2[4] & 0xff,
1018 mac2[5] & 0xff);
1019 }
1020 else if (data.hash_mode == 5200)
1021 {
1022 log_info ("Hash.Target....: File (%s)", data.hashfile);
1023 }
1024 else if (data.hash_mode == 9000)
1025 {
1026 log_info ("Hash.Target....: File (%s)", data.hashfile);
1027 }
1028 else if ((data.hash_mode >= 6200) && (data.hash_mode <= 6299))
1029 {
1030 log_info ("Hash.Target....: File (%s)", data.hashfile);
1031 }
1032 else
1033 {
1034 char out_buf[4096];
1035
1036 ascii_digest (out_buf, 0, 0);
1037
1038 // limit length
1039 if (strlen (out_buf) > 40)
1040 {
1041 out_buf[41] = '.';
1042 out_buf[42] = '.';
1043 out_buf[43] = '.';
1044 out_buf[44] = 0;
1045 }
1046
1047 log_info ("Hash.Target....: %s", out_buf);
1048 }
1049 }
1050 else
1051 {
1052 if (data.hash_mode == 3000)
1053 {
1054 char out_buf1[4096];
1055 char out_buf2[4096];
1056
1057 ascii_digest (out_buf1, 0, 0);
1058 ascii_digest (out_buf2, 0, 1);
1059
1060 log_info ("Hash.Target....: %s, %s", out_buf1, out_buf2);
1061 }
1062 else
1063 {
1064 log_info ("Hash.Target....: File (%s)", data.hashfile);
1065 }
1066 }
1067
1068 log_info ("Hash.Type......: %s", hash_type);
1069
1070 /**
1071 * speed new
1072 */
1073
1074 uint64_t speed_cnt[DEVICES_MAX];
1075 float speed_ms[DEVICES_MAX];
1076
1077 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1078 {
1079 hc_device_param_t *device_param = &data.devices_param[device_id];
1080
1081 // we need to clear values (set to 0) because in case the gpu does
1082 // not get new candidates it idles around but speed display would
1083 // show it as working.
1084 // if we instantly set it to 0 after reading it happens that the
1085 // speed can be shown as zero if the users refreshs to fast.
1086 // therefore, we add a timestamp when a stat was recorded and if its
1087 // to old we will not use it
1088
1089 speed_cnt[device_id] = 0;
1090 speed_ms[device_id] = 0;
1091
1092 for (int i = 0; i < SPEED_CACHE; i++)
1093 {
1094 float rec_ms;
1095
1096 hc_timer_get (device_param->speed_rec[i], rec_ms);
1097
1098 if (rec_ms > SPEED_MAXAGE) continue;
1099
1100 speed_cnt[device_id] += device_param->speed_cnt[i];
1101 speed_ms[device_id] += device_param->speed_ms[i];
1102 }
1103
1104 speed_cnt[device_id] /= SPEED_CACHE;
1105 speed_ms[device_id] /= SPEED_CACHE;
1106 }
1107
1108 float hashes_all_ms = 0;
1109
1110 float hashes_dev_ms[DEVICES_MAX];
1111
1112 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1113 {
1114 hashes_dev_ms[device_id] = 0;
1115
1116 if (speed_ms[device_id])
1117 {
1118 hashes_dev_ms[device_id] = speed_cnt[device_id] / speed_ms[device_id];
1119
1120 hashes_all_ms += hashes_dev_ms[device_id];
1121 }
1122 }
1123
1124 /**
1125 * timers
1126 */
1127
1128 float ms_running = 0;
1129
1130 hc_timer_get (data.timer_running, ms_running);
1131
1132 float ms_paused = data.ms_paused;
1133
1134 if (data.devices_status == STATUS_PAUSED)
1135 {
1136 float ms_paused_tmp = 0;
1137
1138 hc_timer_get (data.timer_paused, ms_paused_tmp);
1139
1140 ms_paused += ms_paused_tmp;
1141 }
1142
1143 #ifdef WIN
1144
1145 __time64_t sec_run = ms_running / 1000;
1146
1147 #else
1148
1149 time_t sec_run = ms_running / 1000;
1150
1151 #endif
1152
1153 if (sec_run)
1154 {
1155 char display_run[32];
1156
1157 struct tm tm_run;
1158
1159 struct tm *tmp;
1160
1161 #ifdef WIN
1162
1163 tmp = _gmtime64 (&sec_run);
1164
1165 #else
1166
1167 tmp = gmtime (&sec_run);
1168
1169 #endif
1170
1171 if (tmp != NULL)
1172 {
1173 memcpy (&tm_run, tmp, sizeof (struct tm));
1174
1175 format_timer_display (&tm_run, display_run, sizeof (tm_run));
1176
1177 char *start = ctime (&data.proc_start);
1178
1179 size_t start_len = strlen (start);
1180
1181 if (start[start_len - 1] == '\n') start[start_len - 1] = 0;
1182 if (start[start_len - 2] == '\r') start[start_len - 2] = 0;
1183
1184 log_info ("Time.Started...: %s (%s)", start, display_run);
1185 }
1186 }
1187 else
1188 {
1189 log_info ("Time.Started...: 0 secs");
1190 }
1191
1192 /**
1193 * counters
1194 */
1195
1196 uint salts_left = data.salts_cnt - data.salts_done;
1197
1198 if (salts_left == 0) salts_left = 1;
1199
1200 uint64_t progress_total = data.words_cnt * salts_left;
1201
1202 uint64_t all_done = 0;
1203 uint64_t all_rejected = 0;
1204 uint64_t all_restored = 0;
1205
1206 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
1207 {
1208 if (salts_left > 1)
1209 {
1210 // otherwise the final cracked status shows 0/XXX progress
1211
1212 if (data.salts_shown[salt_pos] == 1) continue;
1213 }
1214
1215 all_done += data.words_progress_done[salt_pos];
1216 all_rejected += data.words_progress_rejected[salt_pos];
1217 all_restored += data.words_progress_restored[salt_pos];
1218 }
1219
1220 uint64_t progress_cur = all_restored + all_done + all_rejected;
1221 uint64_t progress_end = progress_total;
1222
1223 uint64_t progress_skip = 0;
1224
1225 if (data.skip)
1226 {
1227 progress_skip = MIN (data.skip, data.words_base) * salts_left;
1228
1229 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.gpu_rules_cnt;
1230 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt;
1231 else if (data.attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt;
1232 }
1233
1234 if (data.limit)
1235 {
1236 progress_end = MIN (data.limit, data.words_base) * salts_left;
1237
1238 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.gpu_rules_cnt;
1239 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt;
1240 else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
1241 }
1242
1243 uint64_t progress_cur_relative_skip = progress_cur - progress_skip;
1244 uint64_t progress_end_relative_skip = progress_end - progress_skip;
1245
1246 float speed_ms_real = ms_running - ms_paused;
1247 uint64_t speed_plains_real = all_done;
1248
1249 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1250 {
1251 if (data.devices_status != STATUS_CRACKED)
1252 {
1253 uint64_t words_per_ms = 0;
1254
1255 if (speed_plains_real && speed_ms_real)
1256 {
1257 words_per_ms = speed_plains_real / speed_ms_real;
1258 }
1259
1260 #ifdef WIN
1261 __time64_t sec_etc = 0;
1262 #else
1263 time_t sec_etc = 0;
1264 #endif
1265
1266 if (words_per_ms)
1267 {
1268 uint64_t progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip;
1269
1270 uint64_t ms_left = progress_left_relative_skip / words_per_ms;
1271
1272 sec_etc = ms_left / 1000;
1273 }
1274
1275 if (sec_etc == 0)
1276 {
1277 log_info ("Time.Estimated.: 0 secs");
1278 }
1279 else if ((uint64_t) sec_etc > ETC_MAX)
1280 {
1281 log_info ("Time.Estimated.: > 10 Years");
1282 }
1283 else
1284 {
1285 char display_etc[32];
1286
1287 struct tm tm_etc;
1288
1289 struct tm *tmp;
1290
1291 #ifdef WIN
1292
1293 tmp = _gmtime64 (&sec_etc);
1294
1295 #else
1296
1297 tmp = gmtime (&sec_etc);
1298
1299 #endif
1300
1301 if (tmp != NULL)
1302 {
1303 memcpy (&tm_etc, tmp, sizeof (tm_etc));
1304
1305 format_timer_display (&tm_etc, display_etc, sizeof (display_etc));
1306
1307 time_t now;
1308
1309 time (&now);
1310
1311 now += sec_etc;
1312
1313 char *etc = ctime (&now);
1314
1315 size_t etc_len = strlen (etc);
1316
1317 if (etc[etc_len - 1] == '\n') etc[etc_len - 1] = 0;
1318 if (etc[etc_len - 2] == '\r') etc[etc_len - 2] = 0;
1319
1320 log_info ("Time.Estimated.: %s (%s)", etc, display_etc);
1321 }
1322 }
1323 }
1324 }
1325
1326 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1327 {
1328 char display_dev_cur[16];
1329
1330 memset (display_dev_cur, 0, sizeof (display_dev_cur));
1331
1332 strncpy (display_dev_cur, "0.00", 4);
1333
1334 format_speed_display (hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur));
1335
1336 log_info ("Speed.GPU.#%d...: %9sH/s", device_id + 1, display_dev_cur);
1337 }
1338
1339 char display_all_cur[16];
1340
1341 memset (display_all_cur, 0, sizeof (display_all_cur));
1342
1343 strncpy (display_all_cur, "0.00", 4);
1344
1345 format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur));
1346
1347 if (data.devices_cnt > 1) log_info ("Speed.GPU.#*...: %9sH/s", display_all_cur);
1348
1349 const float digests_percent = (float) data.digests_done / data.digests_cnt;
1350 const float salts_percent = (float) data.salts_done / data.salts_cnt;
1351
1352 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);
1353
1354 // crack-per-time
1355
1356 if (data.digests_cnt > 100)
1357 {
1358 time_t now = time (NULL);
1359
1360 int cpt_cur_min = 0;
1361 int cpt_cur_hour = 0;
1362 int cpt_cur_day = 0;
1363
1364 for (int i = 0; i < CPT_BUF; i++)
1365 {
1366 const uint cracked = data.cpt_buf[i].cracked;
1367 const time_t timestamp = data.cpt_buf[i].timestamp;
1368
1369 if ((timestamp + 60) > now)
1370 {
1371 cpt_cur_min += cracked;
1372 }
1373
1374 if ((timestamp + 3600) > now)
1375 {
1376 cpt_cur_hour += cracked;
1377 }
1378
1379 if ((timestamp + 86400) > now)
1380 {
1381 cpt_cur_day += cracked;
1382 }
1383 }
1384
1385 float cpt_avg_min = (float) data.cpt_total / ((speed_ms_real / 1000) / 60);
1386 float cpt_avg_hour = (float) data.cpt_total / ((speed_ms_real / 1000) / 3600);
1387 float cpt_avg_day = (float) data.cpt_total / ((speed_ms_real / 1000) / 86400);
1388
1389 if ((data.cpt_start + 86400) < now)
1390 {
1391 log_info ("Recovered/Time.: CUR:%llu,%llu,%llu AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1392 cpt_cur_min,
1393 cpt_cur_hour,
1394 cpt_cur_day,
1395 cpt_avg_min,
1396 cpt_avg_hour,
1397 cpt_avg_day);
1398 }
1399 else if ((data.cpt_start + 3600) < now)
1400 {
1401 log_info ("Recovered/Time.: CUR:%llu,%llu,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1402 cpt_cur_min,
1403 cpt_cur_hour,
1404 cpt_avg_min,
1405 cpt_avg_hour,
1406 cpt_avg_day);
1407 }
1408 else if ((data.cpt_start + 60) < now)
1409 {
1410 log_info ("Recovered/Time.: CUR:%llu,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1411 cpt_cur_min,
1412 cpt_avg_min,
1413 cpt_avg_hour,
1414 cpt_avg_day);
1415 }
1416 else
1417 {
1418 log_info ("Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1419 cpt_avg_min,
1420 cpt_avg_hour,
1421 cpt_avg_day);
1422 }
1423 }
1424
1425 // Restore point
1426
1427 uint64_t restore_point = get_lowest_words_done ();
1428
1429 uint64_t restore_total = data.words_base;
1430
1431 float percent_restore = 0;
1432
1433 if (restore_total != 0) percent_restore = (float) restore_point / (float) restore_total;
1434
1435 if (progress_end_relative_skip)
1436 {
1437 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1438 {
1439 float percent_finished = (float) progress_cur_relative_skip / (float) progress_end_relative_skip;
1440 float percent_rejected = 0.0;
1441
1442 if (progress_cur)
1443 {
1444 percent_rejected = (float) (all_rejected) / (float) progress_cur;
1445 }
1446
1447 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);
1448 log_info ("Rejected.......: %llu/%llu (%.02f%%)", (unsigned long long int) all_rejected, (unsigned long long int) progress_cur_relative_skip, percent_rejected * 100);
1449
1450 if (data.restore_disable == 0)
1451 {
1452 if (percent_finished != 1)
1453 {
1454 log_info ("Restore.Point..: %llu/%llu (%.02f%%)", (unsigned long long int) restore_point, (unsigned long long int) restore_total, percent_restore * 100);
1455 }
1456 }
1457 }
1458 }
1459 else
1460 {
1461 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1462 {
1463 log_info ("Progress.......: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1464 log_info ("Rejected.......: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1465
1466 if (data.restore_disable == 0)
1467 {
1468 log_info ("Restore.Point..: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1469 }
1470 }
1471 else
1472 {
1473 log_info ("Progress.......: %llu", (unsigned long long int) progress_cur_relative_skip);
1474 log_info ("Rejected.......: %llu", (unsigned long long int) all_rejected);
1475
1476 // --restore not allowed if stdin is used -- really? why?
1477
1478 //if (data.restore_disable == 0)
1479 //{
1480 // log_info ("Restore.Point..: %llu", (unsigned long long int) restore_point);
1481 //}
1482 }
1483 }
1484
1485 if (data.gpu_temp_disable == 0)
1486 {
1487 hc_thread_mutex_lock (mux_adl);
1488
1489 for (uint i = 0; i < data.devices_cnt; i++)
1490 {
1491 if (data.hm_device[i].fan_supported == 1)
1492 {
1493 const int temperature = hm_get_temperature_with_device_id (i);
1494 const int utilization = hm_get_utilization_with_device_id (i);
1495 const int fanspeed = hm_get_fanspeed_with_device_id (i);
1496
1497 if (data.vendor_id == VENDOR_ID_AMD)
1498 {
1499 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed);
1500 }
1501
1502 if (data.vendor_id == VENDOR_ID_NV)
1503 {
1504 #ifdef LINUX
1505 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed);
1506 #else
1507 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2drpm Fan", i + 1, utilization, temperature, fanspeed);
1508 #endif
1509 }
1510 }
1511 else
1512 {
1513 const int temperature = hm_get_temperature_with_device_id (i);
1514 const int utilization = hm_get_utilization_with_device_id (i);
1515
1516 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, N/A Fan", i + 1, utilization, temperature);
1517 }
1518 }
1519
1520 hc_thread_mutex_unlock (mux_adl);
1521 }
1522 }
1523
1524 static void status_benchmark ()
1525 {
1526 if (data.devices_status == STATUS_INIT) return;
1527 if (data.devices_status == STATUS_STARTING) return;
1528
1529 if (data.words_cnt == 0) return;
1530
1531 uint64_t speed_cnt[DEVICES_MAX];
1532 float speed_ms[DEVICES_MAX];
1533
1534 uint device_id;
1535
1536 for (device_id = 0; device_id < data.devices_cnt; device_id++)
1537 {
1538 hc_device_param_t *device_param = &data.devices_param[device_id];
1539
1540 speed_cnt[device_id] = 0;
1541 speed_ms[device_id] = 0;
1542
1543 for (int i = 0; i < SPEED_CACHE; i++)
1544 {
1545 speed_cnt[device_id] += device_param->speed_cnt[i];
1546 speed_ms[device_id] += device_param->speed_ms[i];
1547 }
1548
1549 speed_cnt[device_id] /= SPEED_CACHE;
1550 speed_ms[device_id] /= SPEED_CACHE;
1551 }
1552
1553 float hashes_all_ms = 0;
1554
1555 float hashes_dev_ms[DEVICES_MAX];
1556
1557 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1558 {
1559 hashes_dev_ms[device_id] = 0;
1560
1561 if (speed_ms[device_id])
1562 {
1563 hashes_dev_ms[device_id] = speed_cnt[device_id] / speed_ms[device_id];
1564
1565 hashes_all_ms += hashes_dev_ms[device_id];
1566 }
1567 }
1568
1569 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1570 {
1571 char display_dev_cur[16];
1572
1573 memset (display_dev_cur, 0, sizeof (display_dev_cur));
1574
1575 strncpy (display_dev_cur, "0.00", 4);
1576
1577 format_speed_display (hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur));
1578
1579 log_info ("Speed.GPU.#%d.: %9sH/s", device_id + 1, display_dev_cur);
1580 }
1581
1582 char display_all_cur[16];
1583
1584 memset (display_all_cur, 0, sizeof (display_all_cur));
1585
1586 strncpy (display_all_cur, "0.00", 4);
1587
1588 format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur));
1589
1590 if (data.devices_cnt > 1) log_info ("Speed.GPU.#*.: %9sH/s", display_all_cur);
1591 }
1592
1593 /**
1594 * oclHashcat -only- functions
1595 */
1596
1597 static void generate_source_kernel_filename (const uint attack_exec, const uint attack_kern, const uint kern_type, char *install_dir, char *source_file)
1598 {
1599 if (attack_exec == ATTACK_EXEC_ON_GPU)
1600 {
1601 if (attack_kern == ATTACK_KERN_STRAIGHT)
1602 snprintf (source_file, 255, "%s/OpenCL/m%05d_a0.cl", install_dir, (int) kern_type);
1603 else if (attack_kern == ATTACK_KERN_COMBI)
1604 snprintf (source_file, 255, "%s/OpenCL/m%05d_a1.cl", install_dir, (int) kern_type);
1605 else if (attack_kern == ATTACK_KERN_BF)
1606 snprintf (source_file, 255, "%s/OpenCL/m%05d_a3.cl", install_dir, (int) kern_type);
1607 }
1608 else
1609 snprintf (source_file, 255, "%s/OpenCL/m%05d.cl", install_dir, (int) kern_type);
1610 }
1611
1612 static void generate_cached_kernel_filename (const uint attack_exec, const uint attack_kern, const uint kern_type, char *install_dir, char *device_name, char *device_version, char *driver_version, int vendor_id, char *cached_file)
1613 {
1614 if (attack_exec == ATTACK_EXEC_ON_GPU)
1615 {
1616 if (attack_kern == ATTACK_KERN_STRAIGHT)
1617 snprintf (cached_file, 255, "%s/kernels/%d/m%05d_a0.%s_%s_%s_%d.kernel", install_dir, vendor_id, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
1618 else if (attack_kern == ATTACK_KERN_COMBI)
1619 snprintf (cached_file, 255, "%s/kernels/%d/m%05d_a1.%s_%s_%s_%d.kernel", install_dir, vendor_id, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
1620 else if (attack_kern == ATTACK_KERN_BF)
1621 snprintf (cached_file, 255, "%s/kernels/%d/m%05d_a3.%s_%s_%s_%d.kernel", install_dir, vendor_id, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
1622 }
1623 else
1624 {
1625 snprintf (cached_file, 255, "%s/kernels/%d/m%05d.%s_%s_%s_%d.kernel", install_dir, vendor_id, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
1626 }
1627 }
1628
1629 static void generate_source_kernel_mp_filename (const uint opti_type, const uint opts_type, char *install_dir, char *source_file)
1630 {
1631 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
1632 {
1633 snprintf (source_file, 255, "%s/OpenCL/markov_be.cl", install_dir);
1634 }
1635 else
1636 {
1637 snprintf (source_file, 255, "%s/OpenCL/markov_le.cl", install_dir);
1638 }
1639 }
1640
1641 static void generate_cached_kernel_mp_filename (const uint opti_type, const uint opts_type, char *install_dir, char *device_name, char *device_version, char *driver_version, int vendor_id, char *cached_file)
1642 {
1643 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
1644 {
1645 snprintf (cached_file, 255, "%s/kernels/%d/markov_be.%s_%s_%s_%d.kernel", install_dir, vendor_id, device_name, device_version, driver_version, COMPTIME);
1646 }
1647 else
1648 {
1649 snprintf (cached_file, 255, "%s/kernels/%d/markov_le.%s_%s_%s_%d.kernel", install_dir, vendor_id, device_name, device_version, driver_version, COMPTIME);
1650 }
1651 }
1652
1653 static void generate_source_kernel_amp_filename (const uint attack_kern, char *install_dir, char *source_file)
1654 {
1655 snprintf (source_file, 255, "%s/OpenCL/amp_a%d.cl", install_dir, attack_kern);
1656 }
1657
1658 static void generate_cached_kernel_amp_filename (const uint attack_kern, char *install_dir, char *device_name, char *device_version, char *driver_version, int vendor_id, char *cached_file)
1659 {
1660 snprintf (cached_file, 255, "%s/kernels/%d/amp_a%d.%s_%s_%s_%d.kernel", install_dir, vendor_id, attack_kern, device_name, device_version, driver_version, COMPTIME);
1661 }
1662
1663 static uint convert_from_hex (char *line_buf, const uint line_len)
1664 {
1665 if (line_len & 1) return (line_len); // not in hex
1666
1667 if (data.hex_wordlist == 1)
1668 {
1669 uint i;
1670 uint j;
1671
1672 for (i = 0, j = 0; j < line_len; i += 1, j += 2)
1673 {
1674 line_buf[i] = hex_to_char (&line_buf[j]);
1675 }
1676
1677 memset (line_buf + i, 0, line_len - i);
1678
1679 return (i);
1680 }
1681 else if (line_len >= 6) // $HEX[] = 6
1682 {
1683 if (line_buf[0] != '$') return (line_len);
1684 if (line_buf[1] != 'H') return (line_len);
1685 if (line_buf[2] != 'E') return (line_len);
1686 if (line_buf[3] != 'X') return (line_len);
1687 if (line_buf[4] != '[') return (line_len);
1688 if (line_buf[line_len - 1] != ']') return (line_len);
1689
1690 uint i;
1691 uint j;
1692
1693 for (i = 0, j = 5; j < line_len - 1; i += 1, j += 2)
1694 {
1695 line_buf[i] = hex_to_char (&line_buf[j]);
1696 }
1697
1698 memset (line_buf + i, 0, line_len - i);
1699
1700 return (i);
1701 }
1702
1703 return (line_len);
1704 }
1705
1706 static uint count_lines (FILE *fd)
1707 {
1708 uint cnt = 0;
1709
1710 char *buf = (char *) mymalloc (BUFSIZ);
1711
1712 size_t nread_tmp = 0;
1713
1714 char *ptr = buf;
1715
1716 while (!feof (fd))
1717 {
1718 size_t nread = fread (buf, sizeof (char), BUFSIZ, fd);
1719 nread_tmp = nread;
1720
1721 if (nread < 1) continue;
1722
1723 ptr = buf;
1724
1725 do
1726 {
1727 if (*ptr++ == '\n') cnt++;
1728
1729 } while (nread--);
1730 }
1731
1732 // special case (if last line did not contain a newline char ... at the very end of the file)
1733
1734 if (nread_tmp > 3)
1735 {
1736 ptr -= 2;
1737
1738 if (*ptr != '\n')
1739 {
1740 ptr--;
1741
1742 if (*ptr != '\n') // needed ? different on windows systems?
1743 {
1744 cnt++;
1745 }
1746 }
1747 }
1748
1749 myfree (buf);
1750
1751 return cnt;
1752 }
1753
1754 static void clear_prompt ()
1755 {
1756 fputc ('\r', stdout);
1757
1758 for (size_t i = 0; i < strlen (PROMPT); i++)
1759 {
1760 fputc (' ', stdout);
1761 }
1762
1763 fputc ('\r', stdout);
1764
1765 fflush (stdout);
1766 }
1767
1768 static void gidd_to_pw_t (hc_device_param_t *device_param, const uint64_t gidd, pw_t *pw)
1769 {
1770 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL);
1771 }
1772
1773 static void check_hash (hc_device_param_t *device_param, const uint salt_pos, const uint digest_pos)
1774 {
1775 char *outfile = data.outfile;
1776 uint quiet = data.quiet;
1777 FILE *pot_fp = data.pot_fp;
1778 uint loopback = data.loopback;
1779 uint debug_mode = data.debug_mode;
1780 char *debug_file = data.debug_file;
1781
1782 char debug_rule_buf[BLOCK_SIZE];
1783 int debug_rule_len = 0; // -1 error
1784 uint debug_plain_len = 0;
1785
1786 unsigned char debug_plain_ptr[BLOCK_SIZE];
1787
1788 // hash
1789
1790 char out_buf[4096]; memset (out_buf, 0, sizeof (out_buf));
1791
1792 ascii_digest (out_buf, salt_pos, digest_pos);
1793
1794 uint idx = data.salts_buf[salt_pos].digests_offset + digest_pos;
1795
1796 // plain
1797
1798 plain_t plain;
1799
1800 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, idx * sizeof (plain_t), sizeof (plain_t), &plain, 0, NULL, NULL);
1801
1802 uint gidvid = plain.gidvid;
1803 uint il_pos = plain.il_pos;
1804
1805 uint64_t crackpos = device_param->words_off;
1806
1807 uint plain_buf[16];
1808
1809 unsigned char *plain_ptr = (unsigned char *) plain_buf;
1810 unsigned int plain_len = 0;
1811
1812 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
1813 {
1814 uint64_t gidd = gidvid;
1815 uint64_t gidm = 0;
1816
1817 pw_t pw;
1818
1819 gidd_to_pw_t (device_param, gidd, &pw);
1820
1821 for (int i = 0, j = gidm; i < 16; i++, j++)
1822 {
1823 plain_buf[i] = pw.hi1[0][j];
1824 }
1825
1826 plain_len = pw.pw_len;
1827
1828 const uint off = device_param->innerloop_pos + il_pos;
1829
1830 if (debug_mode > 0)
1831 {
1832 debug_rule_len = 0;
1833
1834 // save rule
1835 if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4))
1836 {
1837 memset (debug_rule_buf, 0, sizeof (debug_rule_buf));
1838
1839 debug_rule_len = gpu_rule_to_cpu_rule (debug_rule_buf, &data.gpu_rules_buf[off]);
1840 }
1841
1842 // save plain
1843 if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4))
1844 {
1845 memset (debug_plain_ptr, 0, sizeof (debug_plain_ptr));
1846
1847 memcpy (debug_plain_ptr, plain_ptr, plain_len);
1848
1849 debug_plain_len = plain_len;
1850 }
1851 }
1852
1853 plain_len = apply_rules (data.gpu_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], plain_len);
1854
1855 crackpos += gidvid;
1856 crackpos *= data.gpu_rules_cnt;
1857 crackpos += device_param->innerloop_pos + il_pos;
1858
1859 if (plain_len > data.pw_max) plain_len = data.pw_max;
1860 }
1861 else if (data.attack_mode == ATTACK_MODE_COMBI)
1862 {
1863 uint64_t gidd = gidvid;
1864 uint64_t gidm = 0;
1865
1866 pw_t pw;
1867
1868 gidd_to_pw_t (device_param, gidd, &pw);
1869
1870 for (int i = 0, j = gidm; i < 16; i++, j++)
1871 {
1872 plain_buf[i] = pw.hi1[0][j];
1873 }
1874
1875 plain_len = pw.pw_len;
1876
1877 char *comb_buf = (char *) device_param->combs_buf[il_pos].i;
1878 uint comb_len = device_param->combs_buf[il_pos].pw_len;
1879
1880 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
1881 {
1882 memcpy (plain_ptr + plain_len, comb_buf, comb_len);
1883 }
1884 else
1885 {
1886 memmove (plain_ptr + comb_len, plain_ptr, plain_len);
1887
1888 memcpy (plain_ptr, comb_buf, comb_len);
1889 }
1890
1891 plain_len += comb_len;
1892
1893 crackpos += gidvid;
1894 crackpos *= data.combs_cnt;
1895 crackpos += device_param->innerloop_pos + il_pos;
1896
1897 if (data.pw_max != PW_DICTMAX1)
1898 {
1899 if (plain_len > data.pw_max) plain_len = data.pw_max;
1900 }
1901 }
1902 else if (data.attack_mode == ATTACK_MODE_BF)
1903 {
1904 uint64_t l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid;
1905 uint64_t r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos;
1906
1907 uint l_start = device_param->kernel_params_mp_l_buf32[5];
1908 uint r_start = device_param->kernel_params_mp_r_buf32[5];
1909
1910 uint l_stop = device_param->kernel_params_mp_l_buf32[4];
1911 uint r_stop = device_param->kernel_params_mp_r_buf32[4];
1912
1913 sp_exec (l_off, (char *) plain_ptr + l_start, data.root_css_buf, data.markov_css_buf, l_start, l_start + l_stop);
1914 sp_exec (r_off, (char *) plain_ptr + r_start, data.root_css_buf, data.markov_css_buf, r_start, r_start + r_stop);
1915
1916 plain_len = data.css_cnt;
1917
1918 crackpos += gidvid;
1919 crackpos *= data.bfs_cnt;
1920 crackpos += device_param->innerloop_pos + il_pos;
1921 }
1922 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
1923 {
1924 uint64_t gidd = gidvid;
1925 uint64_t gidm = 0;
1926
1927 pw_t pw;
1928
1929 gidd_to_pw_t (device_param, gidd, &pw);
1930
1931 for (int i = 0, j = gidm; i < 16; i++, j++)
1932 {
1933 plain_buf[i] = pw.hi1[0][j];
1934 }
1935
1936 plain_len = pw.pw_len;
1937
1938 uint64_t off = device_param->kernel_params_mp_buf64[3] + il_pos;
1939
1940 uint start = 0;
1941 uint stop = device_param->kernel_params_mp_buf32[4];
1942
1943 sp_exec (off, (char *) plain_ptr + plain_len, data.root_css_buf, data.markov_css_buf, start, start + stop);
1944
1945 plain_len += start + stop;
1946
1947 crackpos += gidvid;
1948 crackpos *= data.combs_cnt;
1949 crackpos += device_param->innerloop_pos + il_pos;
1950
1951 if (data.pw_max != PW_DICTMAX1)
1952 {
1953 if (plain_len > data.pw_max) plain_len = data.pw_max;
1954 }
1955 }
1956 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
1957 {
1958 uint64_t gidd = gidvid;
1959 uint64_t gidm = 0;
1960
1961 pw_t pw;
1962
1963 gidd_to_pw_t (device_param, gidd, &pw);
1964
1965 for (int i = 0, j = gidm; i < 16; i++, j++)
1966 {
1967 plain_buf[i] = pw.hi1[0][j];
1968 }
1969
1970 plain_len = pw.pw_len;
1971
1972 uint64_t off = device_param->kernel_params_mp_buf64[3] + il_pos;
1973
1974 uint start = 0;
1975 uint stop = device_param->kernel_params_mp_buf32[4];
1976
1977 memmove (plain_ptr + stop, plain_ptr, plain_len);
1978
1979 sp_exec (off, (char *) plain_ptr, data.root_css_buf, data.markov_css_buf, start, start + stop);
1980
1981 plain_len += start + stop;
1982
1983 crackpos += gidvid;
1984 crackpos *= data.combs_cnt;
1985 crackpos += device_param->innerloop_pos + il_pos;
1986
1987 if (data.pw_max != PW_DICTMAX1)
1988 {
1989 if (plain_len > data.pw_max) plain_len = data.pw_max;
1990 }
1991 }
1992
1993 if (data.opti_type & OPTI_TYPE_BRUTE_FORCE) // lots of optimizations can happen here
1994 {
1995 if (data.opti_type & OPTI_TYPE_SINGLE_HASH)
1996 {
1997 if (data.opti_type & OPTI_TYPE_APPENDED_SALT)
1998 {
1999 plain_len = plain_len - data.salts_buf[0].salt_len;
2000 }
2001 }
2002
2003 if (data.opts_type & OPTS_TYPE_PT_UNICODE)
2004 {
2005 for (uint i = 0, j = 0; i < plain_len; i += 2, j += 1)
2006 {
2007 plain_ptr[j] = plain_ptr[i];
2008 }
2009
2010 plain_len = plain_len / 2;
2011 }
2012 }
2013
2014 // if enabled, update also the potfile
2015
2016 if (pot_fp)
2017 {
2018 fprintf (pot_fp, "%s:", out_buf);
2019
2020 format_plain (pot_fp, plain_ptr, plain_len, 1);
2021
2022 fputc ('\n', pot_fp);
2023
2024 fflush (pot_fp);
2025 }
2026
2027 // outfile
2028
2029 FILE *out_fp = NULL;
2030
2031 if (outfile != NULL)
2032 {
2033 if ((out_fp = fopen (outfile, "ab")) == NULL)
2034 {
2035 log_error ("ERROR: %s: %s", outfile, strerror (errno));
2036
2037 out_fp = stdout;
2038 }
2039 }
2040 else
2041 {
2042 out_fp = stdout;
2043
2044 if (quiet == 0) clear_prompt ();
2045 }
2046
2047 format_output (out_fp, out_buf, plain_ptr, plain_len, crackpos, NULL, 0);
2048
2049 if (outfile != NULL)
2050 {
2051 if (out_fp != stdout)
2052 {
2053 fclose (out_fp);
2054 }
2055 }
2056 else
2057 {
2058 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
2059 {
2060 if ((data.devices_status != STATUS_CRACKED) && (data.status != 1))
2061 {
2062 if (quiet == 0) fprintf (stdout, "%s", PROMPT);
2063 if (quiet == 0) fflush (stdout);
2064 }
2065 }
2066 }
2067
2068 // loopback
2069
2070 if (loopback)
2071 {
2072 char *loopback_file = data.loopback_file;
2073
2074 FILE *fb_fp = NULL;
2075
2076 if ((fb_fp = fopen (loopback_file, "ab")) != NULL)
2077 {
2078 format_plain (fb_fp, plain_ptr, plain_len, 1);
2079
2080 fputc ('\n', fb_fp);
2081
2082 fclose (fb_fp);
2083 }
2084 }
2085
2086 // (rule) debug mode
2087
2088 // the next check implies that:
2089 // - (data.attack_mode == ATTACK_MODE_STRAIGHT)
2090 // - debug_mode > 0
2091
2092 if ((debug_plain_len > 0) || (debug_rule_len > 0))
2093 {
2094 if (debug_rule_len < 0) debug_rule_len = 0;
2095
2096 if ((quiet == 0) && (debug_file == NULL)) clear_prompt ();
2097
2098 format_debug (debug_file, debug_mode, debug_plain_ptr, debug_plain_len, plain_ptr, plain_len, debug_rule_buf, debug_rule_len);
2099
2100 if ((quiet == 0) && (debug_file == NULL))
2101 {
2102 fprintf (stdout, "%s", PROMPT);
2103 fflush (stdout);
2104 }
2105 }
2106 }
2107
2108 static void check_cracked (hc_device_param_t *device_param, const uint salt_pos)
2109 {
2110 salt_t *salt_buf = &data.salts_buf[salt_pos];
2111
2112 int found = 0;
2113
2114 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_result, CL_TRUE, 0, device_param->size_results, device_param->result, 0, NULL, NULL);
2115
2116 for (uint i = 0; i < GPU_THREADS; i++) if (device_param->result[i] == 1) found = 1;
2117
2118 if (found == 1)
2119 {
2120 // display hack (for weak hashes etc, it could be that there is still something to clear on the current line)
2121
2122 log_info_nn ("");
2123
2124 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);
2125
2126 uint cpt_cracked = 0;
2127
2128 for (uint digest_pos = 0; digest_pos < salt_buf->digests_cnt; digest_pos++)
2129 {
2130 uint idx = salt_buf->digests_offset + digest_pos;
2131
2132 if (data.digests_shown_tmp[idx] == 0) continue;
2133
2134 if (data.digests_shown[idx] == 1) continue;
2135
2136 if ((data.opts_type & OPTS_TYPE_PT_NEVERCRACK) == 0)
2137 {
2138 data.digests_shown[idx] = 1;
2139
2140 data.digests_done++;
2141
2142 cpt_cracked++;
2143
2144 salt_buf->digests_done++;
2145
2146 if (salt_buf->digests_done == salt_buf->digests_cnt)
2147 {
2148 data.salts_shown[salt_pos] = 1;
2149
2150 data.salts_done++;
2151 }
2152 }
2153
2154 if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
2155
2156 check_hash (device_param, salt_pos, digest_pos);
2157 }
2158
2159 if (cpt_cracked > 0)
2160 {
2161 data.cpt_buf[data.cpt_pos].timestamp = time (NULL);
2162 data.cpt_buf[data.cpt_pos].cracked = cpt_cracked;
2163
2164 data.cpt_pos++;
2165
2166 data.cpt_total += cpt_cracked;
2167
2168 if (data.cpt_pos == CPT_BUF) data.cpt_pos = 0;
2169 }
2170
2171 if (data.opts_type & OPTS_TYPE_PT_NEVERCRACK)
2172 {
2173 // we need to reset cracked state on the gpu
2174 // otherwise host thinks again and again the hash was cracked
2175 // and returns invalid password each time
2176
2177 memset (data.digests_shown_tmp, 0, salt_buf->digests_cnt * sizeof (uint));
2178
2179 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);
2180 }
2181
2182 memset (device_param->result, 0, device_param->size_results);
2183
2184 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_result, CL_TRUE, 0, device_param->size_results, device_param->result, 0, NULL, NULL);
2185 }
2186 }
2187
2188 static void save_hash ()
2189 {
2190 char *hashfile = data.hashfile;
2191
2192 char new_hashfile[256];
2193 char old_hashfile[256];
2194
2195 memset (new_hashfile, 0, sizeof (new_hashfile));
2196 memset (old_hashfile, 0, sizeof (old_hashfile));
2197
2198 snprintf (new_hashfile, 255, "%s.new", hashfile);
2199 snprintf (old_hashfile, 255, "%s.old", hashfile);
2200
2201 unlink (new_hashfile);
2202
2203 char separator = data.separator;
2204
2205 FILE *fp = fopen (new_hashfile, "wb");
2206
2207 if (fp == NULL)
2208 {
2209 log_error ("ERROR: %s: %s", new_hashfile, strerror (errno));
2210
2211 exit (-1);
2212 }
2213
2214 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
2215 {
2216 if (data.salts_shown[salt_pos] == 1) continue;
2217
2218 salt_t *salt_buf = &data.salts_buf[salt_pos];
2219
2220 for (uint digest_pos = 0; digest_pos < salt_buf->digests_cnt; digest_pos++)
2221 {
2222 uint idx = salt_buf->digests_offset + digest_pos;
2223
2224 if (data.digests_shown[idx] == 1) continue;
2225
2226 if (data.hash_mode != 2500)
2227 {
2228 char out_buf[4096];
2229
2230 memset (out_buf, 0, sizeof (out_buf));
2231
2232 if (data.username == 1)
2233 {
2234 user_t *user = data.hash_info[idx]->user;
2235
2236 uint i;
2237
2238 for (i = 0; i < user->user_len; i++) fputc (user->user_name[i], fp);
2239
2240 fputc (separator, fp);
2241 }
2242
2243 ascii_digest (out_buf, salt_pos, digest_pos);
2244
2245 fputs (out_buf, fp);
2246
2247 log_out (fp, "");
2248 }
2249 else
2250 {
2251 hccap_t hccap;
2252
2253 to_hccap_t (&hccap, salt_pos, digest_pos);
2254
2255 fwrite (&hccap, sizeof (hccap_t), 1, fp);
2256 }
2257 }
2258 }
2259
2260 fflush (fp);
2261
2262 fclose (fp);
2263
2264 unlink (old_hashfile);
2265
2266 if (rename (hashfile, old_hashfile) != 0)
2267 {
2268 log_error ("ERROR: Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno));
2269
2270 exit (-1);
2271 }
2272
2273 unlink (hashfile);
2274
2275 if (rename (new_hashfile, hashfile) != 0)
2276 {
2277 log_error ("ERROR: Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno));
2278
2279 exit (-1);
2280 }
2281
2282 unlink (old_hashfile);
2283 }
2284
2285 static float find_gpu_blocks_div (const uint64_t total_left, const uint gpu_blocks_all)
2286 {
2287 // function called only in case gpu_blocks_all > words_left)
2288
2289 float gpu_blocks_div = (float) (total_left) / gpu_blocks_all;
2290
2291 gpu_blocks_div += gpu_blocks_div / 100;
2292
2293 uint32_t gpu_blocks_new = (uint32_t) (gpu_blocks_all * gpu_blocks_div);
2294
2295 while (gpu_blocks_new < total_left)
2296 {
2297 gpu_blocks_div += gpu_blocks_div / 100;
2298
2299 gpu_blocks_new = (uint32_t) (gpu_blocks_all * gpu_blocks_div);
2300 }
2301
2302 if (data.quiet == 0)
2303 {
2304 clear_prompt ();
2305
2306 log_info ("");
2307
2308 log_info ("INFO: approaching final keyspace, workload adjusted");
2309
2310 log_info ("");
2311
2312 fprintf (stdout, "%s", PROMPT);
2313
2314 fflush (stdout);
2315 }
2316
2317 if ((gpu_blocks_all * gpu_blocks_div) < 8) return 1;
2318
2319 return gpu_blocks_div;
2320 }
2321
2322 static void run_kernel (const uint kern_run, hc_device_param_t *device_param, const uint num)
2323 {
2324 uint num_elements = num;
2325
2326 device_param->kernel_params_buf32[30] = data.combs_mode;
2327 device_param->kernel_params_buf32[31] = num;
2328
2329 uint gpu_threads = device_param->gpu_threads;
2330
2331 while (num_elements % gpu_threads) num_elements++;
2332
2333 cl_kernel kernel = NULL;
2334
2335 switch (kern_run)
2336 {
2337 case KERN_RUN_1: kernel = device_param->kernel1; break;
2338 case KERN_RUN_12: kernel = device_param->kernel12; break;
2339 case KERN_RUN_2: kernel = device_param->kernel2; break;
2340 case KERN_RUN_23: kernel = device_param->kernel23; break;
2341 case KERN_RUN_3: kernel = device_param->kernel3; break;
2342 }
2343
2344 hc_clSetKernelArg (kernel, 21, sizeof (cl_uint), device_param->kernel_params[21]);
2345 hc_clSetKernelArg (kernel, 22, sizeof (cl_uint), device_param->kernel_params[22]);
2346 hc_clSetKernelArg (kernel, 23, sizeof (cl_uint), device_param->kernel_params[23]);
2347 hc_clSetKernelArg (kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]);
2348 hc_clSetKernelArg (kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]);
2349 hc_clSetKernelArg (kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]);
2350 hc_clSetKernelArg (kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]);
2351 hc_clSetKernelArg (kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]);
2352 hc_clSetKernelArg (kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]);
2353 hc_clSetKernelArg (kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]);
2354 hc_clSetKernelArg (kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]);
2355
2356 if ((data.opts_type & OPTS_TYPE_PT_BITSLICE) && (data.attack_mode == ATTACK_MODE_BF))
2357 {
2358 const size_t global_work_size[3] = { num_elements, 32, 1 };
2359 const size_t local_work_size[3] = { gpu_threads / 32, 32, 1 };
2360
2361 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 2, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2362 }
2363 else
2364 {
2365 const size_t global_work_size[3] = { num_elements, 1, 1 };
2366 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2367
2368 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2369 }
2370
2371 hc_clFlush (device_param->command_queue);
2372
2373 hc_clFinish (device_param->command_queue);
2374 }
2375
2376 static void run_kernel_mp (const uint kern_run, hc_device_param_t *device_param, const uint num)
2377 {
2378 uint num_elements = num;
2379
2380 switch (kern_run)
2381 {
2382 case KERN_RUN_MP: device_param->kernel_params_mp_buf32[8] = num; break;
2383 case KERN_RUN_MP_R: device_param->kernel_params_mp_r_buf32[8] = num; break;
2384 case KERN_RUN_MP_L: device_param->kernel_params_mp_l_buf32[9] = num; break;
2385 }
2386
2387 // causes problems with special threads like in bcrypt
2388 // const uint gpu_threads = device_param->gpu_threads;
2389
2390 const uint gpu_threads = GPU_THREADS;
2391
2392 while (num_elements % gpu_threads) num_elements++;
2393
2394 cl_kernel kernel = NULL;
2395
2396 switch (kern_run)
2397 {
2398 case KERN_RUN_MP: kernel = device_param->kernel_mp; break;
2399 case KERN_RUN_MP_R: kernel = device_param->kernel_mp_r; break;
2400 case KERN_RUN_MP_L: kernel = device_param->kernel_mp_l; break;
2401 }
2402
2403 switch (kern_run)
2404 {
2405 case KERN_RUN_MP: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp[3]);
2406 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp[4]);
2407 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp[5]);
2408 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp[6]);
2409 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp[7]);
2410 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp[8]);
2411 break;
2412 case KERN_RUN_MP_R: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_r[3]);
2413 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_r[4]);
2414 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_r[5]);
2415 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_r[6]);
2416 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_r[7]);
2417 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_r[8]);
2418 break;
2419 case KERN_RUN_MP_L: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_l[3]);
2420 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_l[4]);
2421 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_l[5]);
2422 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_l[6]);
2423 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_l[7]);
2424 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_l[8]);
2425 hc_clSetKernelArg (kernel, 9, sizeof (cl_uint), device_param->kernel_params_mp_l[9]);
2426 break;
2427 }
2428
2429 const size_t global_work_size[3] = { num_elements, 1, 1 };
2430 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2431
2432 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2433
2434 hc_clFlush (device_param->command_queue);
2435
2436 hc_clFinish (device_param->command_queue);
2437 }
2438
2439 static void run_kernel_tb (hc_device_param_t *device_param, const uint num)
2440 {
2441 uint num_elements = num;
2442
2443 uint gpu_threads = device_param->gpu_threads;
2444
2445 while (num_elements % gpu_threads) num_elements++;
2446
2447 cl_kernel kernel = device_param->kernel_tb;
2448
2449 const size_t global_work_size[3] = { num_elements, 1, 1 };
2450 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2451
2452 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2453
2454 hc_clFlush (device_param->command_queue);
2455
2456 hc_clFinish (device_param->command_queue);
2457 }
2458
2459 static void run_kernel_tm (hc_device_param_t *device_param)
2460 {
2461 const uint num_elements = 1024; // fixed
2462
2463 const uint gpu_threads = 32;
2464
2465 cl_kernel kernel = device_param->kernel_tm;
2466
2467 const size_t global_work_size[3] = { num_elements, 1, 1 };
2468 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2469
2470 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2471
2472 hc_clFlush (device_param->command_queue);
2473
2474 hc_clFinish (device_param->command_queue);
2475 }
2476
2477 static void run_kernel_amp (hc_device_param_t *device_param, const uint num)
2478 {
2479 uint num_elements = num;
2480
2481 device_param->kernel_params_amp_buf32[5] = data.combs_mode;
2482 device_param->kernel_params_amp_buf32[6] = num_elements;
2483
2484 // causes problems with special threads like in bcrypt
2485 // const uint gpu_threads = device_param->gpu_threads;
2486
2487 const uint gpu_threads = GPU_THREADS;
2488
2489 while (num_elements % gpu_threads) num_elements++;
2490
2491 cl_kernel kernel = device_param->kernel_amp;
2492
2493 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]);
2494 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_amp[6]);
2495
2496 const size_t global_work_size[3] = { num_elements, 1, 1 };
2497 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2498
2499 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2500
2501 hc_clFlush (device_param->command_queue);
2502
2503 hc_clFinish (device_param->command_queue);
2504 }
2505
2506 static void run_kernel_bzero (hc_device_param_t *device_param, cl_mem buf, const uint size)
2507 {
2508 if (data.vendor_id == VENDOR_ID_AMD)
2509 {
2510 const cl_uchar zero = 0;
2511
2512 hc_clEnqueueFillBuffer (device_param->command_queue, buf, &zero, sizeof (cl_uchar), 0, size, 0, NULL, NULL);
2513 }
2514
2515 if (data.vendor_id == VENDOR_ID_NV)
2516 {
2517 // NOTE: clEnqueueFillBuffer () always fails with -59
2518 // IOW, it's not supported by Nvidia ForceWare <= 352.21,
2519 // How's that possible, OpenCL 1.2 support is advertised??
2520 // We need to workaround...
2521
2522 #define FILLSZ 0x100000
2523
2524 char *tmp = (char *) mymalloc (FILLSZ);
2525
2526 memset (tmp, 0, FILLSZ);
2527
2528 for (uint i = 0; i < size; i += FILLSZ)
2529 {
2530 const int left = size - i;
2531
2532 const int fillsz = MIN (FILLSZ, left);
2533
2534 hc_clEnqueueWriteBuffer (device_param->command_queue, buf, CL_TRUE, i, fillsz, tmp, 0, NULL, NULL);
2535 }
2536
2537 myfree (tmp);
2538 }
2539 }
2540
2541 static int run_rule_engine (const int rule_len, const char *rule_buf)
2542 {
2543 if (rule_len == 0)
2544 {
2545 return 0;
2546 }
2547 else if (rule_len == 1)
2548 {
2549 if (rule_buf[0] == RULE_OP_MANGLE_NOOP) return 0;
2550 }
2551
2552 return 1;
2553 }
2554
2555 static void run_copy (hc_device_param_t *device_param, const uint pws_cnt)
2556 {
2557 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
2558 {
2559 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);
2560 }
2561 else if (data.attack_kern == ATTACK_KERN_COMBI)
2562 {
2563 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);
2564 }
2565 else if (data.attack_kern == ATTACK_KERN_BF)
2566 {
2567 const uint64_t off = device_param->words_off;
2568
2569 device_param->kernel_params_mp_l_buf64[3] = off;
2570
2571 run_kernel_mp (KERN_RUN_MP_L, device_param, pws_cnt);
2572 }
2573 }
2574
2575 static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, const uint pws_cnt)
2576 {
2577 const uint gpu_loops = data.gpu_loops;
2578
2579 // init speed timer
2580
2581 uint speed_pos = device_param->speed_pos;
2582
2583 #ifdef _POSIX
2584 if (device_param->timer_speed.tv_sec == 0)
2585 {
2586 hc_timer_set (&device_param->timer_speed);
2587 }
2588 #endif
2589
2590 #ifdef _WIN
2591 if (device_param->timer_speed.QuadPart == 0)
2592 {
2593 hc_timer_set (&device_param->timer_speed);
2594 }
2595 #endif
2596
2597 // find higest password length, this is for optimization stuff
2598
2599 uint highest_pw_len = 0;
2600
2601 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
2602 {
2603 }
2604 else if (data.attack_kern == ATTACK_KERN_COMBI)
2605 {
2606 }
2607 else if (data.attack_kern == ATTACK_KERN_BF)
2608 {
2609 highest_pw_len = device_param->kernel_params_mp_l_buf32[4]
2610 + device_param->kernel_params_mp_l_buf32[5];
2611 }
2612
2613 // bitslice optimization stuff
2614
2615 if (data.attack_mode == ATTACK_MODE_BF)
2616 {
2617 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
2618 {
2619 run_kernel_tb (device_param, pws_cnt);
2620 }
2621 }
2622
2623 // iteration type
2624
2625 uint innerloop_step = 0;
2626 uint innerloop_cnt = 0;
2627
2628 if (data.attack_exec == ATTACK_EXEC_ON_GPU) innerloop_step = gpu_loops;
2629 else innerloop_step = 1;
2630
2631 if (data.attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = data.gpu_rules_cnt;
2632 else if (data.attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = data.combs_cnt;
2633 else if (data.attack_kern == ATTACK_KERN_BF) innerloop_cnt = data.bfs_cnt;
2634
2635 // loop start: most outer loop = salt iteration, then innerloops (if multi)
2636
2637 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
2638 {
2639 while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
2640
2641 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
2642
2643 if (data.devices_status == STATUS_CRACKED) break;
2644 if (data.devices_status == STATUS_ABORTED) break;
2645 if (data.devices_status == STATUS_QUIT) break;
2646 if (data.devices_status == STATUS_BYPASS) break;
2647
2648 if (data.salts_shown[salt_pos] == 1) continue;
2649
2650 salt_t *salt_buf = &data.salts_buf[salt_pos];
2651
2652 device_param->kernel_params_buf32[24] = salt_pos;
2653 device_param->kernel_params_buf32[28] = salt_buf->digests_cnt;
2654 device_param->kernel_params_buf32[29] = salt_buf->digests_offset;
2655
2656 FILE *combs_fp = device_param->combs_fp;
2657
2658 if (data.attack_mode == ATTACK_MODE_COMBI)
2659 {
2660 rewind (combs_fp);
2661 }
2662
2663 // innerloops
2664
2665 for (uint innerloop_pos = 0; innerloop_pos < innerloop_cnt; innerloop_pos += innerloop_step)
2666 {
2667 while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
2668
2669 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
2670
2671 if (data.devices_status == STATUS_CRACKED) break;
2672 if (data.devices_status == STATUS_ABORTED) break;
2673 if (data.devices_status == STATUS_QUIT) break;
2674 if (data.devices_status == STATUS_BYPASS) break;
2675
2676 uint innerloop_left = innerloop_cnt - innerloop_pos;
2677
2678 if (innerloop_left > innerloop_step) innerloop_left = innerloop_step;
2679
2680 device_param->innerloop_pos = innerloop_pos;
2681 device_param->innerloop_left = innerloop_left;
2682
2683 device_param->kernel_params_buf32[27] = innerloop_left;
2684
2685 if (innerloop_left == 0) continue;
2686
2687 // initialize amplifiers
2688
2689 if (data.attack_mode == ATTACK_MODE_COMBI)
2690 {
2691 char line_buf[BUFSIZ];
2692
2693 uint i = 0;
2694
2695 while (i < innerloop_left)
2696 {
2697 if (feof (combs_fp)) break;
2698
2699 int line_len = fgetl (combs_fp, line_buf);
2700
2701 if (line_len >= PW_MAX1) continue;
2702
2703 line_len = convert_from_hex (line_buf, line_len);
2704
2705 char *line_buf_new = line_buf;
2706
2707 if (run_rule_engine (data.rule_len_r, data.rule_buf_r))
2708 {
2709 char rule_buf_out[BLOCK_SIZE];
2710
2711 memset (rule_buf_out, 0, sizeof (rule_buf_out));
2712
2713 int rule_len_out = _old_apply_rule (data.rule_buf_r, data.rule_len_r, line_buf, line_len, rule_buf_out);
2714
2715 if (rule_len_out < 0)
2716 {
2717 data.words_progress_rejected[salt_pos] += pw_cnt;
2718
2719 continue;
2720 }
2721
2722 line_len = rule_len_out;
2723
2724 line_buf_new = rule_buf_out;
2725 }
2726
2727 line_len = MIN (line_len, PW_DICTMAX);
2728
2729 char *ptr = (char *) device_param->combs_buf[i].i;
2730
2731 memcpy (ptr, line_buf_new, line_len);
2732
2733 memset (ptr + line_len, 0, PW_DICTMAX1 - line_len);
2734
2735 if (data.opts_type & OPTS_TYPE_PT_UPPER)
2736 {
2737 uppercase (ptr, line_len);
2738 }
2739
2740 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
2741 {
2742 if (data.opts_type & OPTS_TYPE_PT_ADD80)
2743 {
2744 ptr[line_len] = 0x80;
2745 }
2746
2747 if (data.opts_type & OPTS_TYPE_PT_ADD01)
2748 {
2749 ptr[line_len] = 0x01;
2750 }
2751 }
2752
2753 device_param->combs_buf[i].pw_len = line_len;
2754
2755 i++;
2756 }
2757
2758 for (uint j = i; j < innerloop_left; j++)
2759 {
2760 device_param->combs_buf[j].i[0] = 0;
2761 device_param->combs_buf[j].i[1] = 0;
2762 device_param->combs_buf[j].i[2] = 0;
2763 device_param->combs_buf[j].i[3] = 0;
2764 device_param->combs_buf[j].i[4] = 0;
2765 device_param->combs_buf[j].i[5] = 0;
2766 device_param->combs_buf[j].i[6] = 0;
2767 device_param->combs_buf[j].i[7] = 0;
2768
2769 device_param->combs_buf[j].pw_len = 0;
2770 }
2771
2772 innerloop_left = i;
2773 }
2774 else if (data.attack_mode == ATTACK_MODE_BF)
2775 {
2776 uint64_t off = innerloop_pos;
2777
2778 device_param->kernel_params_mp_r_buf64[3] = off;
2779
2780 run_kernel_mp (KERN_RUN_MP_R, device_param, innerloop_left);
2781 }
2782 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
2783 {
2784 uint64_t off = innerloop_pos;
2785
2786 device_param->kernel_params_mp_buf64[3] = off;
2787
2788 run_kernel_mp (KERN_RUN_MP, device_param, innerloop_left);
2789 }
2790 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
2791 {
2792 uint64_t off = innerloop_pos;
2793
2794 device_param->kernel_params_mp_buf64[3] = off;
2795
2796 run_kernel_mp (KERN_RUN_MP, device_param, innerloop_left);
2797 }
2798
2799 // copy amplifiers
2800
2801 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
2802 {
2803 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);
2804 }
2805 else if (data.attack_mode == ATTACK_MODE_COMBI)
2806 {
2807 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);
2808 }
2809 else if (data.attack_mode == ATTACK_MODE_BF)
2810 {
2811 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);
2812 }
2813 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
2814 {
2815 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);
2816 }
2817 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
2818 {
2819 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);
2820 }
2821
2822 if (data.attack_exec == ATTACK_EXEC_ON_GPU)
2823 {
2824 if (data.attack_mode == ATTACK_MODE_BF)
2825 {
2826 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
2827 {
2828 const uint size_tm = 32 * sizeof (bs_word_t);
2829
2830 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
2831
2832 run_kernel_tm (device_param);
2833
2834 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL);
2835 }
2836 }
2837
2838 if (highest_pw_len < 16)
2839 {
2840 run_kernel (KERN_RUN_1, device_param, pws_cnt);
2841 }
2842 else if (highest_pw_len < 32)
2843 {
2844 run_kernel (KERN_RUN_2, device_param, pws_cnt);
2845 }
2846 else
2847 {
2848 run_kernel (KERN_RUN_3, device_param, pws_cnt);
2849 }
2850 }
2851 else
2852 {
2853 run_kernel_amp (device_param, pws_cnt);
2854
2855 run_kernel (KERN_RUN_1, device_param, pws_cnt);
2856
2857 if (data.opts_type & OPTS_TYPE_HOOK12)
2858 {
2859 run_kernel (KERN_RUN_12, device_param, pws_cnt);
2860 }
2861
2862 uint iter = salt_buf->salt_iter;
2863
2864 for (uint loop_pos = 0; loop_pos < iter; loop_pos += gpu_loops)
2865 {
2866 uint loop_left = iter - loop_pos;
2867
2868 loop_left = MIN (loop_left, gpu_loops);
2869
2870 device_param->kernel_params_buf32[25] = loop_pos;
2871 device_param->kernel_params_buf32[26] = loop_left;
2872
2873 run_kernel (KERN_RUN_2, device_param, pws_cnt);
2874
2875 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
2876
2877 if (data.devices_status == STATUS_CRACKED) break;
2878 if (data.devices_status == STATUS_ABORTED) break;
2879 if (data.devices_status == STATUS_QUIT) break;
2880 }
2881
2882 if (data.opts_type & OPTS_TYPE_HOOK23)
2883 {
2884 run_kernel (KERN_RUN_23, device_param, pws_cnt);
2885
2886 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL);
2887
2888 // do something with data
2889
2890 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL);
2891 }
2892
2893 run_kernel (KERN_RUN_3, device_param, pws_cnt);
2894 }
2895
2896 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
2897
2898 if (data.devices_status == STATUS_CRACKED) break;
2899 if (data.devices_status == STATUS_ABORTED) break;
2900 if (data.devices_status == STATUS_QUIT) break;
2901
2902 /**
2903 * result
2904 */
2905
2906 hc_thread_mutex_lock (mux_display);
2907
2908 check_cracked (device_param, salt_pos);
2909
2910 hc_thread_mutex_unlock (mux_display);
2911
2912 /**
2913 * progress
2914 */
2915
2916 uint64_t perf_sum_all = (uint64_t) pw_cnt * (uint64_t) innerloop_left;
2917
2918 hc_thread_mutex_lock (mux_counter);
2919
2920 data.words_progress_done[salt_pos] += perf_sum_all;
2921
2922 hc_thread_mutex_unlock (mux_counter);
2923
2924 /**
2925 * speed
2926 */
2927
2928 float speed_ms;
2929
2930 hc_timer_get (device_param->timer_speed, speed_ms);
2931
2932 hc_timer_set (&device_param->timer_speed);
2933
2934 hc_thread_mutex_lock (mux_display);
2935
2936 device_param->speed_cnt[speed_pos] = perf_sum_all;
2937
2938 device_param->speed_ms[speed_pos] = speed_ms;
2939
2940 device_param->speed_rec[speed_pos] = device_param->timer_speed;
2941
2942 hc_thread_mutex_unlock (mux_display);
2943
2944 speed_pos++;
2945
2946 if (speed_pos == SPEED_CACHE)
2947 {
2948 speed_pos = 0;
2949 }
2950 }
2951 }
2952
2953 device_param->speed_pos = speed_pos;
2954 }
2955
2956 static void load_segment (wl_data_t *wl_data, FILE *fd)
2957 {
2958 // NOTE: use (never changing) ->incr here instead of ->avail otherwise the buffer gets bigger and bigger
2959
2960 wl_data->pos = 0;
2961
2962 wl_data->cnt = fread (wl_data->buf, 1, wl_data->incr - 1000, fd);
2963
2964 wl_data->buf[wl_data->cnt] = 0;
2965
2966 if (wl_data->cnt == 0) return;
2967
2968 if (wl_data->buf[wl_data->cnt - 1] == '\n') return;
2969
2970 while (!feof (fd))
2971 {
2972 if (wl_data->cnt == wl_data->avail)
2973 {
2974 wl_data->buf = (char *) myrealloc (wl_data->buf, wl_data->avail, wl_data->incr);
2975
2976 wl_data->avail += wl_data->incr;
2977 }
2978
2979 const int c = fgetc (fd);
2980
2981 if (c == EOF) break;
2982
2983 wl_data->buf[wl_data->cnt] = (char) c;
2984
2985 wl_data->cnt++;
2986
2987 if (c == '\n') break;
2988 }
2989
2990 // ensure stream ends with a newline
2991
2992 if (wl_data->buf[wl_data->cnt - 1] != '\n')
2993 {
2994 wl_data->cnt++;
2995
2996 wl_data->buf[wl_data->cnt - 1] = '\n';
2997 }
2998
2999 return;
3000 }
3001
3002 static void get_next_word_lm (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3003 {
3004 char *ptr = buf;
3005
3006 for (uint32_t i = 0; i < sz; i++, ptr++)
3007 {
3008 if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
3009
3010 if (i == 7)
3011 {
3012 *off = i;
3013 *len = i;
3014
3015 return;
3016 }
3017
3018 if (*ptr != '\n') continue;
3019
3020 *off = i + 1;
3021
3022 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3023
3024 *len = i;
3025
3026 return;
3027 }
3028
3029 *off = sz;
3030 *len = sz;
3031 }
3032
3033 static void get_next_word_uc (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3034 {
3035 char *ptr = buf;
3036
3037 for (uint32_t i = 0; i < sz; i++, ptr++)
3038 {
3039 if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
3040
3041 if (*ptr != '\n') continue;
3042
3043 *off = i + 1;
3044
3045 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3046
3047 *len = i;
3048
3049 return;
3050 }
3051
3052 *off = sz;
3053 *len = sz;
3054 }
3055
3056 static void get_next_word_std (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3057 {
3058 char *ptr = buf;
3059
3060 for (uint32_t i = 0; i < sz; i++, ptr++)
3061 {
3062 if (*ptr != '\n') continue;
3063
3064 *off = i + 1;
3065
3066 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3067
3068 *len = i;
3069
3070 return;
3071 }
3072
3073 *off = sz;
3074 *len = sz;
3075 }
3076
3077 static void get_next_word (wl_data_t *wl_data, FILE *fd, char **out_buf, uint *out_len)
3078 {
3079 while (wl_data->pos < wl_data->cnt)
3080 {
3081 uint off;
3082 uint len;
3083
3084 char *ptr = wl_data->buf + wl_data->pos;
3085
3086 get_next_word_func (ptr, wl_data->cnt - wl_data->pos, &len, &off);
3087
3088 wl_data->pos += off;
3089
3090 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3091 {
3092 char rule_buf_out[BLOCK_SIZE];
3093
3094 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3095
3096 int rule_len_out = -1;
3097
3098 if (len < BLOCK_SIZE)
3099 {
3100 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, ptr, len, rule_buf_out);
3101 }
3102
3103 if (rule_len_out < 0)
3104 {
3105 continue;
3106 }
3107
3108 if (rule_len_out > PW_MAX)
3109 {
3110 continue;
3111 }
3112 }
3113 else
3114 {
3115 if (len > PW_MAX)
3116 {
3117 continue;
3118 }
3119 }
3120
3121 *out_buf = ptr;
3122 *out_len = len;
3123
3124 return;
3125 }
3126
3127 if (feof (fd))
3128 {
3129 fprintf (stderr, "bug!!\n");
3130
3131 return;
3132 }
3133
3134 load_segment (wl_data, fd);
3135
3136 get_next_word (wl_data, fd, out_buf, out_len);
3137 }
3138
3139 #ifdef _POSIX
3140 static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, size_t *dictstat_nmemb)
3141 #endif
3142
3143 #ifdef _WIN
3144 static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, uint *dictstat_nmemb)
3145 #endif
3146 {
3147 hc_signal (NULL);
3148
3149 dictstat_t d;
3150
3151 d.cnt = 0;
3152
3153 #ifdef _POSIX
3154 fstat (fileno (fd), &d.stat);
3155 #endif
3156
3157 #ifdef _WIN
3158 _fstat64 (fileno (fd), &d.stat);
3159 #endif
3160
3161 d.stat.st_mode = 0;
3162 d.stat.st_nlink = 0;
3163 d.stat.st_uid = 0;
3164 d.stat.st_gid = 0;
3165 d.stat.st_rdev = 0;
3166 d.stat.st_atime = 0;
3167
3168 #ifdef _POSIX
3169 d.stat.st_blksize = 0;
3170 d.stat.st_blocks = 0;
3171 #endif
3172
3173 if (d.stat.st_size == 0) return 0;
3174
3175 dictstat_t *d_cache = (dictstat_t *) lfind (&d, dictstat_base, dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
3176
3177 if (run_rule_engine (data.rule_len_l, data.rule_buf_l) == 0)
3178 {
3179 if (d_cache)
3180 {
3181 uint64_t cnt = d_cache->cnt;
3182
3183 uint64_t keyspace = cnt;
3184
3185 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
3186 {
3187 keyspace *= data.gpu_rules_cnt;
3188 }
3189 else if (data.attack_kern == ATTACK_KERN_COMBI)
3190 {
3191 keyspace *= data.combs_cnt;
3192 }
3193
3194 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);
3195 if (data.quiet == 0) log_info ("");
3196
3197 hc_signal (sigHandler_default);
3198
3199 return (keyspace);
3200 }
3201 }
3202
3203 time_t now = 0;
3204 time_t prev = 0;
3205
3206 uint64_t comp = 0;
3207 uint64_t cnt = 0;
3208 uint64_t cnt2 = 0;
3209
3210 while (!feof (fd))
3211 {
3212 load_segment (wl_data, fd);
3213
3214 comp += wl_data->cnt;
3215
3216 uint32_t i = 0;
3217
3218 while (i < wl_data->cnt)
3219 {
3220 uint32_t len;
3221 uint32_t off;
3222
3223 get_next_word_func (wl_data->buf + i, wl_data->cnt - i, &len, &off);
3224
3225 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3226 {
3227 char rule_buf_out[BLOCK_SIZE];
3228
3229 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3230
3231 int rule_len_out = -1;
3232
3233 if (len < BLOCK_SIZE)
3234 {
3235 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, wl_data->buf + i, len, rule_buf_out);
3236 }
3237
3238 if (rule_len_out < 0)
3239 {
3240 len = PW_MAX1;
3241 }
3242 else
3243 {
3244 len = rule_len_out;
3245 }
3246 }
3247
3248 if (len < PW_MAX1)
3249 {
3250 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
3251 {
3252 cnt += data.gpu_rules_cnt;
3253 }
3254 else if (data.attack_kern == ATTACK_KERN_COMBI)
3255 {
3256 cnt += data.combs_cnt;
3257 }
3258
3259 d.cnt++;
3260 }
3261
3262 i += off;
3263
3264 cnt2++;
3265 }
3266
3267 time (&now);
3268
3269 if ((now - prev) == 0) continue;
3270
3271 float percent = (float) comp / (float) d.stat.st_size;
3272
3273 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);
3274
3275 time (&prev);
3276 }
3277
3278 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);
3279 if (data.quiet == 0) log_info ("");
3280
3281 lsearch (&d, dictstat_base, dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
3282
3283 hc_signal (sigHandler_default);
3284
3285 return (cnt);
3286 }
3287
3288 static void pw_transpose_to_hi1 (const pw_t *p1, pw_t *p2)
3289 {
3290 memcpy (p2->hi1, p1->hi1, 64 * sizeof (uint));
3291 }
3292
3293 static uint pw_add_to_hc1 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
3294 {
3295 if (data.devices_status == STATUS_BYPASS) return 0;
3296
3297 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
3298
3299 uint cache_cnt = pw_cache->cnt;
3300
3301 uint8_t *pw_hc1 = pw_cache->pw_buf.hc1[cache_cnt];
3302
3303 memcpy (pw_hc1, pw_buf, pw_len);
3304
3305 memset (pw_hc1 + pw_len, 0, 256 - pw_len);
3306
3307 uint pws_cnt = device_param->pws_cnt;
3308
3309 cache_cnt++;
3310
3311 pw_t *pw = device_param->pws_buf + pws_cnt;
3312
3313 device_param->pw_transpose (&pw_cache->pw_buf, pw);
3314
3315 pw->pw_len = pw_len;
3316
3317 pws_cnt++;
3318
3319 device_param->pws_cnt = pws_cnt;
3320 device_param->pw_cnt = pws_cnt * 1;
3321
3322 cache_cnt = 0;
3323
3324 pw_cache->cnt = cache_cnt;
3325
3326 return pws_cnt;
3327 }
3328
3329 static void *thread_monitor (void *p)
3330 {
3331 uint runtime_check = 0;
3332 uint remove_check = 0;
3333 uint status_check = 0;
3334 uint hwmon_check = 0;
3335 uint restore_check = 0;
3336
3337 uint restore_left = data.restore_timer;
3338 uint remove_left = data.remove_timer;
3339 uint status_left = data.status_timer;
3340
3341 // these variables are mainly used for fan control (AMD only)
3342
3343 int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
3344
3345 // temperature controller "loopback" values
3346
3347 int *temp_diff_old = (int *) mycalloc (data.devices_cnt, sizeof (int));
3348 int *temp_diff_sum = (int *) mycalloc (data.devices_cnt, sizeof (int));
3349
3350 int temp_threshold = 1; // degrees celcius
3351
3352 int fan_speed_min = 15; // in percentage
3353 int fan_speed_max = 100;
3354
3355 time_t last_temp_check_time;
3356
3357 uint sleep_time = 1;
3358
3359 if (data.runtime)
3360 {
3361 runtime_check = 1;
3362 }
3363
3364 if (data.restore_timer)
3365 {
3366 restore_check = 1;
3367 }
3368
3369 if ((data.remove == 1) && (data.hashlist_mode == HL_MODE_FILE))
3370 {
3371 remove_check = 1;
3372 }
3373
3374 if (data.status == 1)
3375 {
3376 status_check = 1;
3377 }
3378
3379 if (data.gpu_temp_disable == 0)
3380 {
3381 time (&last_temp_check_time);
3382
3383 hwmon_check = 1;
3384 }
3385
3386 if ((runtime_check == 0) && (remove_check == 0) && (status_check == 0) && (hwmon_check == 0) && (restore_check == 0))
3387 {
3388 return (p);
3389 }
3390
3391 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
3392 {
3393 hc_sleep (sleep_time);
3394
3395 if (data.devices_status != STATUS_RUNNING) continue;
3396
3397 if (hwmon_check == 1)
3398 {
3399 hc_thread_mutex_lock (mux_adl);
3400
3401 time_t temp_check_time;
3402
3403 time (&temp_check_time);
3404
3405 uint Ta = temp_check_time - last_temp_check_time; // set Ta = sleep_time; is not good enough (see --remove etc)
3406
3407 if (Ta == 0) Ta = 1;
3408
3409 for (uint i = 0; i < data.devices_cnt; i++)
3410 {
3411 const int temperature = hm_get_temperature_with_device_id (i);
3412
3413 if (temperature > (int) data.gpu_temp_abort)
3414 {
3415 log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", i + 1);
3416
3417 if (data.devices_status != STATUS_QUIT) myabort ();
3418
3419 break;
3420 }
3421
3422 const int gpu_temp_retain = data.gpu_temp_retain;
3423
3424 if (gpu_temp_retain) // VENDOR_ID_AMD implied
3425 {
3426 if (data.hm_device[i].fan_supported == 1)
3427 {
3428 int temp_cur = temperature;
3429
3430 int temp_diff_new = gpu_temp_retain - temp_cur;
3431
3432 temp_diff_sum[i] = temp_diff_sum[i] + temp_diff_new;
3433
3434 // calculate Ta value (time difference in seconds between the last check and this check)
3435
3436 last_temp_check_time = temp_check_time;
3437
3438 float Kp = 1.8;
3439 float Ki = 0.005;
3440 float Kd = 6;
3441
3442 // PID controller (3-term controller: proportional - Kp, integral - Ki, derivative - Kd)
3443
3444 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);
3445
3446 if (abs (fan_diff_required) >= temp_threshold)
3447 {
3448 const int fan_speed_cur = hm_get_fanspeed_with_device_id (i);
3449
3450 int fan_speed_level = fan_speed_cur;
3451
3452 if (fan_speed_chgd[i] == 0) fan_speed_level = temp_cur;
3453
3454 int fan_speed_new = fan_speed_level - fan_diff_required;
3455
3456 if (fan_speed_new > fan_speed_max) fan_speed_new = fan_speed_max;
3457 if (fan_speed_new < fan_speed_min) fan_speed_new = fan_speed_min;
3458
3459 if (fan_speed_new != fan_speed_cur)
3460 {
3461 int freely_change_fan_speed = (fan_speed_chgd[i] == 1);
3462 int fan_speed_must_change = (fan_speed_new > fan_speed_cur);
3463
3464 if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1))
3465 {
3466 hm_set_fanspeed_with_device_id_amd (i, fan_speed_new);
3467
3468 fan_speed_chgd[i] = 1;
3469 }
3470
3471 temp_diff_old[i] = temp_diff_new;
3472 }
3473 }
3474 }
3475 }
3476 }
3477
3478 hc_thread_mutex_unlock (mux_adl);
3479 }
3480
3481 if (restore_check == 1)
3482 {
3483 restore_left--;
3484
3485 if (restore_left == 0)
3486 {
3487 if (data.restore_disable == 0) cycle_restore ();
3488
3489 restore_left = data.restore_timer;
3490 }
3491 }
3492
3493 if ((runtime_check == 1) && (data.runtime_start > 0))
3494 {
3495 time_t runtime_cur;
3496
3497 time (&runtime_cur);
3498
3499 int runtime_left = data.runtime_start + data.runtime - runtime_cur;
3500
3501 if (runtime_left <= 0)
3502 {
3503 if (data.benchmark == 0)
3504 {
3505 if (data.quiet == 0) log_info ("\nNOTE: Runtime limit reached, aborting...\n");
3506 }
3507
3508 if (data.devices_status != STATUS_QUIT) myabort ();
3509 }
3510 }
3511
3512 if (remove_check == 1)
3513 {
3514 remove_left--;
3515
3516 if (remove_left == 0)
3517 {
3518 if (data.digests_saved != data.digests_done)
3519 {
3520 data.digests_saved = data.digests_done;
3521
3522 save_hash ();
3523 }
3524
3525 remove_left = data.remove_timer;
3526 }
3527 }
3528
3529 if (status_check == 1)
3530 {
3531 status_left--;
3532
3533 if (status_left == 0)
3534 {
3535 hc_thread_mutex_lock (mux_display);
3536
3537 if (data.quiet == 0) clear_prompt ();
3538
3539 if (data.quiet == 0) log_info ("");
3540
3541 status_display ();
3542
3543 if (data.quiet == 0) log_info ("");
3544
3545 hc_thread_mutex_unlock (mux_display);
3546
3547 status_left = data.status_timer;
3548 }
3549 }
3550 }
3551
3552 myfree (fan_speed_chgd);
3553
3554 myfree (temp_diff_old);
3555 myfree (temp_diff_sum);
3556
3557 p = NULL;
3558
3559 return (p);
3560 }
3561
3562 static void *thread_outfile_remove (void *p)
3563 {
3564 // some hash-dependent constants
3565 char *outfile_dir = data.outfile_check_directory;
3566 uint dgst_size = data.dgst_size;
3567 uint isSalted = data.isSalted;
3568 uint esalt_size = data.esalt_size;
3569 uint hash_mode = data.hash_mode;
3570
3571 uint outfile_check_timer = data.outfile_check_timer;
3572
3573 char separator = data.separator;
3574
3575 // some hash-dependent functions
3576 int (*sort_by_digest) (const void *, const void *) = data.sort_by_digest;
3577 int (*parse_func) (char *, uint, hash_t *) = data.parse_func;
3578
3579 // buffers
3580 hash_t hash_buf;
3581
3582 memset (&hash_buf, 0, sizeof (hash_buf));
3583
3584 hash_buf.digest = mymalloc (dgst_size);
3585
3586 if (isSalted) hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
3587
3588 if (esalt_size) hash_buf.esalt = (void *) mymalloc (esalt_size);
3589
3590 uint digest_buf[64];
3591
3592 outfile_data_t *out_info = NULL;
3593
3594 char **out_files = NULL;
3595
3596 time_t folder_mtime = 0;
3597
3598 int out_cnt = 0;
3599
3600 uint check_left = outfile_check_timer; // or 1 if we want to check it at startup
3601
3602 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
3603 {
3604 hc_sleep (1);
3605
3606 if (data.devices_status != STATUS_RUNNING) continue;
3607
3608 check_left--;
3609
3610 if (check_left == 0)
3611 {
3612 struct stat outfile_check_stat;
3613
3614 if (stat (outfile_dir, &outfile_check_stat) == 0)
3615 {
3616 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
3617
3618 if (is_dir == 1)
3619 {
3620 if (outfile_check_stat.st_mtime > folder_mtime)
3621 {
3622 char **out_files_new = scan_directory (outfile_dir);
3623
3624 int out_cnt_new = count_dictionaries (out_files_new);
3625
3626 outfile_data_t *out_info_new = NULL;
3627
3628 if (out_cnt_new > 0)
3629 {
3630 out_info_new = (outfile_data_t *) mycalloc (out_cnt_new, sizeof (outfile_data_t));
3631
3632 for (int i = 0; i < out_cnt_new; i++)
3633 {
3634 out_info_new[i].file_name = out_files_new[i];
3635
3636 // check if there are files that we have seen/checked before (and not changed)
3637
3638 for (int j = 0; j < out_cnt; j++)
3639 {
3640 if (strcmp (out_info[j].file_name, out_info_new[i].file_name) == 0)
3641 {
3642 struct stat outfile_stat;
3643
3644 if (stat (out_info_new[i].file_name, &outfile_stat) == 0)
3645 {
3646 if (outfile_stat.st_ctime == out_info[j].ctime)
3647 {
3648 out_info_new[i].ctime = out_info[j].ctime;
3649 out_info_new[i].seek = out_info[j].seek;
3650 }
3651 }
3652 }
3653 }
3654 }
3655 }
3656
3657 local_free (out_info);
3658 local_free (out_files);
3659
3660 out_files = out_files_new;
3661 out_cnt = out_cnt_new;
3662 out_info = out_info_new;
3663
3664 folder_mtime = outfile_check_stat.st_mtime;
3665 }
3666
3667 for (int j = 0; j < out_cnt; j++)
3668 {
3669 FILE *fp = fopen (out_info[j].file_name, "rb");
3670
3671 if (fp != NULL)
3672 {
3673 //hc_thread_mutex_lock (mux_display);
3674
3675 #ifdef _POSIX
3676 struct stat outfile_stat;
3677
3678 fstat (fileno (fp), &outfile_stat);
3679 #endif
3680
3681 #ifdef _WIN
3682 struct stat64 outfile_stat;
3683
3684 _fstat64 (fileno (fp), &outfile_stat);
3685 #endif
3686
3687 if (outfile_stat.st_ctime > out_info[j].ctime)
3688 {
3689 out_info[j].ctime = outfile_stat.st_ctime;
3690 out_info[j].seek = 0;
3691 }
3692
3693 fseek (fp, out_info[j].seek, SEEK_SET);
3694
3695 while (!feof (fp))
3696 {
3697 char line_buf[BUFSIZ];
3698
3699 memset (line_buf, 0, BUFSIZ);
3700
3701 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
3702
3703 if (ptr == NULL) break;
3704
3705 int line_len = strlen (line_buf);
3706
3707 if (line_len <= 0) continue;
3708
3709 int iter = MAX_CUT_TRIES;
3710
3711 for (uint i = line_len - 1; i && iter; i--, line_len--)
3712 {
3713 if (line_buf[i] != separator) continue;
3714
3715 int parser_status = PARSER_OK;
3716
3717 if ((hash_mode != 2500) && (hash_mode != 6800))
3718 {
3719 parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
3720 }
3721
3722 uint found = 0;
3723
3724 if (parser_status == PARSER_OK)
3725 {
3726 for (uint salt_pos = 0; (found == 0) && (salt_pos < data.salts_cnt); salt_pos++)
3727 {
3728 if (data.salts_shown[salt_pos] == 1) continue;
3729
3730 salt_t *salt_buf = &data.salts_buf[salt_pos];
3731
3732 for (uint digest_pos = 0; (found == 0) && (digest_pos < salt_buf->digests_cnt); digest_pos++)
3733 {
3734 uint idx = salt_buf->digests_offset + digest_pos;
3735
3736 if (data.digests_shown[idx] == 1) continue;
3737
3738 uint cracked = 0;
3739
3740 if (hash_mode == 6800)
3741 {
3742 if (i == salt_buf->salt_len)
3743 {
3744 cracked = (memcmp (line_buf, salt_buf->salt_buf, salt_buf->salt_len) == 0);
3745 }
3746 }
3747 else if (hash_mode == 2500)
3748 {
3749 // BSSID : MAC1 : MAC2 (:plain)
3750 if (i == (salt_buf->salt_len + 1 + 12 + 1 + 12))
3751 {
3752 cracked = (memcmp (line_buf, salt_buf->salt_buf, salt_buf->salt_len) == 0);
3753
3754 if (!cracked) continue;
3755
3756 // now compare MAC1 and MAC2 too, since we have this additional info
3757 char *mac1_pos = line_buf + salt_buf->salt_len + 1;
3758 char *mac2_pos = mac1_pos + 12 + 1;
3759
3760 wpa_t *wpas = (wpa_t *) data.esalts_buf;
3761 wpa_t *wpa = &wpas[salt_pos];
3762
3763 uint pke[25];
3764
3765 char *pke_ptr = (char *) pke;
3766
3767 for (uint i = 0; i < 25; i++)
3768 {
3769 pke[i] = byte_swap_32 (wpa->pke[i]);
3770 }
3771
3772 unsigned char mac1[6];
3773 unsigned char mac2[6];
3774
3775 memcpy (mac1, pke_ptr + 23, 6);
3776 memcpy (mac2, pke_ptr + 29, 6);
3777
3778 // compare hex string(s) vs binary MAC address(es)
3779
3780 for (uint i = 0, j = 0; i < 6; i++, j += 2)
3781 {
3782 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
3783 {
3784 cracked = 0;
3785 break;
3786 }
3787 }
3788
3789 // early skip ;)
3790 if (!cracked) continue;
3791
3792 for (uint i = 0, j = 0; i < 6; i++, j += 2)
3793 {
3794 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
3795 {
3796 cracked = 0;
3797 break;
3798 }
3799 }
3800 }
3801 }
3802 else
3803 {
3804 char *digests_buf_ptr = (char *) data.digests_buf;
3805
3806 memcpy (digest_buf, digests_buf_ptr + (data.salts_buf[salt_pos].digests_offset * dgst_size) + (digest_pos * dgst_size), dgst_size);
3807
3808 cracked = (sort_by_digest (digest_buf, hash_buf.digest) == 0);
3809 }
3810
3811 if (cracked == 1)
3812 {
3813 found = 1;
3814
3815 data.digests_shown[idx] = 1;
3816
3817 data.digests_done++;
3818
3819 salt_buf->digests_done++;
3820
3821 if (salt_buf->digests_done == salt_buf->digests_cnt)
3822 {
3823 data.salts_shown[salt_pos] = 1;
3824
3825 data.salts_done++;
3826
3827 if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
3828 }
3829 }
3830 }
3831
3832 if (data.devices_status == STATUS_CRACKED) break;
3833 }
3834 }
3835
3836 if (found) break;
3837
3838 if (data.devices_status == STATUS_CRACKED) break;
3839
3840 iter--;
3841 }
3842
3843 if (data.devices_status == STATUS_CRACKED) break;
3844 }
3845
3846 out_info[j].seek = ftell (fp);
3847
3848 //hc_thread_mutex_unlock (mux_display);
3849
3850 fclose (fp);
3851 }
3852 }
3853 }
3854 }
3855
3856 check_left = outfile_check_timer;
3857 }
3858 }
3859
3860 if (esalt_size) local_free (hash_buf.esalt);
3861
3862 if (isSalted) local_free (hash_buf.salt);
3863
3864 local_free (hash_buf.digest);
3865
3866 local_free (out_info);
3867
3868 local_free (out_files);
3869
3870 p = NULL;
3871
3872 return (p);
3873 }
3874
3875 static uint get_work (hc_device_param_t *device_param, const uint64_t max)
3876 {
3877 hc_thread_mutex_lock (mux_dispatcher);
3878
3879 const uint64_t words_cur = data.words_cur;
3880 const uint64_t words_base = (data.limit == 0) ? data.words_base : data.limit;
3881
3882 device_param->words_off = words_cur;
3883
3884 const uint64_t words_left = words_base - words_cur;
3885
3886 if (data.gpu_blocks_all > words_left)
3887 {
3888 if (data.gpu_blocks_div == 0)
3889 {
3890 data.gpu_blocks_div = find_gpu_blocks_div (words_left, data.gpu_blocks_all);
3891 }
3892 }
3893
3894 if (data.gpu_blocks_div)
3895 {
3896 if (device_param->gpu_blocks == device_param->gpu_blocks_user)
3897 {
3898 const uint32_t gpu_blocks_new = (float) device_param->gpu_blocks * data.gpu_blocks_div;
3899 const uint32_t gpu_power_new = gpu_blocks_new;
3900
3901 if (gpu_blocks_new < device_param->gpu_blocks)
3902 {
3903 device_param->gpu_blocks = gpu_blocks_new;
3904 device_param->gpu_power = gpu_power_new;
3905 }
3906 }
3907 }
3908
3909 const uint gpu_blocks = device_param->gpu_blocks;
3910
3911 uint work = MIN (words_left, gpu_blocks);
3912
3913 work = MIN (work, max);
3914
3915 data.words_cur += work;
3916
3917 hc_thread_mutex_unlock (mux_dispatcher);
3918
3919 return work;
3920 }
3921
3922 static void *thread_calc_stdin (void *p)
3923 {
3924 hc_device_param_t *device_param = (hc_device_param_t *) p;
3925
3926 const uint attack_kern = data.attack_kern;
3927
3928 const uint gpu_blocks = device_param->gpu_blocks;
3929
3930 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
3931 {
3932 hc_thread_mutex_lock (mux_dispatcher);
3933
3934 if (feof (stdin) != 0)
3935 {
3936 hc_thread_mutex_unlock (mux_dispatcher);
3937
3938 break;
3939 }
3940
3941 uint words_cur = 0;
3942
3943 while (words_cur < gpu_blocks)
3944 {
3945 char buf[BUFSIZ];
3946
3947 char *line_buf = fgets (buf, sizeof (buf), stdin);
3948
3949 if (line_buf == NULL) break;
3950
3951 uint line_len = in_superchop (line_buf);
3952
3953 line_len = convert_from_hex (line_buf, line_len);
3954
3955 // post-process rule engine
3956
3957 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3958 {
3959 char rule_buf_out[BLOCK_SIZE];
3960
3961 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3962
3963 int rule_len_out = -1;
3964
3965 if (line_len < BLOCK_SIZE)
3966 {
3967 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, line_buf, line_len, rule_buf_out);
3968 }
3969
3970 if (rule_len_out < 0) continue;
3971
3972 line_buf = rule_buf_out;
3973 line_len = rule_len_out;
3974 }
3975
3976 if (line_len > PW_MAX)
3977 {
3978 continue;
3979 }
3980
3981 if (attack_kern == ATTACK_KERN_STRAIGHT)
3982 {
3983 if ((line_len < data.pw_min) || (line_len > data.pw_max))
3984 {
3985 hc_thread_mutex_lock (mux_counter);
3986
3987 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
3988 {
3989 data.words_progress_rejected[salt_pos] += data.gpu_rules_cnt;
3990 }
3991
3992 hc_thread_mutex_unlock (mux_counter);
3993
3994 continue;
3995 }
3996 }
3997 else if (attack_kern == ATTACK_KERN_COMBI)
3998 {
3999 // do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
4000 // since we still need to combine the plains
4001
4002 if (line_len > data.pw_max)
4003 {
4004 hc_thread_mutex_lock (mux_counter);
4005
4006 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4007 {
4008 data.words_progress_rejected[salt_pos] += data.combs_cnt;
4009 }
4010
4011 hc_thread_mutex_unlock (mux_counter);
4012
4013 continue;
4014 }
4015 }
4016
4017 device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
4018
4019 words_cur++;
4020
4021 if (data.devices_status == STATUS_CRACKED) break;
4022 if (data.devices_status == STATUS_ABORTED) break;
4023 if (data.devices_status == STATUS_QUIT) break;
4024 if (data.devices_status == STATUS_BYPASS) break;
4025 }
4026
4027 hc_thread_mutex_unlock (mux_dispatcher);
4028
4029 if (data.devices_status == STATUS_CRACKED) break;
4030 if (data.devices_status == STATUS_ABORTED) break;
4031 if (data.devices_status == STATUS_QUIT) break;
4032 if (data.devices_status == STATUS_BYPASS) break;
4033
4034 // we need 2 flushing because we have two independant caches and it can occur
4035 // that one buffer is already at threshold plus for that length also exists
4036 // more data in the 2nd buffer so it would overflow
4037
4038 // flush session 1
4039
4040 {
4041 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4042 {
4043 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4044
4045 const uint pw_cache_cnt = pw_cache->cnt;
4046
4047 if (pw_cache_cnt == 0) continue;
4048
4049 pw_cache->cnt = 0;
4050
4051 uint pws_cnt = device_param->pws_cnt;
4052
4053 pw_t *pw = device_param->pws_buf + pws_cnt;
4054
4055 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4056
4057 pw->pw_len = pw_len;
4058
4059 uint pw_cnt = device_param->pw_cnt;
4060
4061 pw_cnt += pw_cache_cnt;
4062
4063 device_param->pw_cnt = pw_cnt;
4064
4065 pws_cnt++;
4066
4067 device_param->pws_cnt = pws_cnt;
4068
4069 if (pws_cnt == device_param->gpu_power_user) break;
4070 }
4071
4072 const uint pw_cnt = device_param->pw_cnt;
4073 const uint pws_cnt = device_param->pws_cnt;
4074
4075 if (pws_cnt)
4076 {
4077 run_copy (device_param, pws_cnt);
4078
4079 run_cracker (device_param, pw_cnt, pws_cnt);
4080
4081 device_param->pw_cnt = 0;
4082 device_param->pws_cnt = 0;
4083 }
4084 }
4085
4086 // flush session 2
4087
4088 {
4089 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4090 {
4091 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4092
4093 const uint pw_cache_cnt = pw_cache->cnt;
4094
4095 if (pw_cache_cnt == 0) continue;
4096
4097 pw_cache->cnt = 0;
4098
4099 uint pws_cnt = device_param->pws_cnt;
4100
4101 pw_t *pw = device_param->pws_buf + pws_cnt;
4102
4103 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4104
4105 pw->pw_len = pw_len;
4106
4107 uint pw_cnt = device_param->pw_cnt;
4108
4109 pw_cnt += pw_cache_cnt;
4110
4111 device_param->pw_cnt = pw_cnt;
4112
4113 pws_cnt++;
4114
4115 device_param->pws_cnt = pws_cnt;
4116 }
4117
4118 const uint pw_cnt = device_param->pw_cnt;
4119 const uint pws_cnt = device_param->pws_cnt;
4120
4121 if (pws_cnt)
4122 {
4123 run_copy (device_param, pws_cnt);
4124
4125 run_cracker (device_param, pw_cnt, pws_cnt);
4126
4127 device_param->pw_cnt = 0;
4128 device_param->pws_cnt = 0;
4129 }
4130 }
4131 }
4132
4133 return NULL;
4134 }
4135
4136 static void *thread_calc (void *p)
4137 {
4138 hc_device_param_t *device_param = (hc_device_param_t *) p;
4139
4140 const uint attack_mode = data.attack_mode;
4141 const uint attack_kern = data.attack_kern;
4142
4143 if (attack_mode == ATTACK_MODE_BF)
4144 {
4145 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4146 {
4147 const uint work = get_work (device_param, -1);
4148
4149 if (work == 0) break;
4150
4151 const uint64_t words_off = device_param->words_off;
4152 const uint64_t words_fin = words_off + work;
4153
4154 const uint pw_cnt = work;
4155 const uint pws_cnt = work;
4156
4157 device_param->pw_cnt = pw_cnt;
4158 device_param->pws_cnt = pws_cnt;
4159
4160 if (pws_cnt)
4161 {
4162 run_copy (device_param, pws_cnt);
4163
4164 run_cracker (device_param, pw_cnt, pws_cnt);
4165
4166 device_param->pw_cnt = 0;
4167 device_param->pws_cnt = 0;
4168 }
4169
4170 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
4171
4172 if (data.devices_status == STATUS_CRACKED) break;
4173 if (data.devices_status == STATUS_ABORTED) break;
4174 if (data.devices_status == STATUS_QUIT) break;
4175 if (data.devices_status == STATUS_BYPASS) break;
4176
4177 device_param->words_done = words_fin;
4178 }
4179 }
4180 else
4181 {
4182 const uint segment_size = data.segment_size;
4183
4184 char *dictfile = data.dictfile;
4185
4186 if (attack_mode == ATTACK_MODE_COMBI)
4187 {
4188 if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
4189 {
4190 dictfile = data.dictfile2;
4191 }
4192 }
4193
4194 FILE *fd = fopen (dictfile, "rb");
4195
4196 if (fd == NULL)
4197 {
4198 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
4199
4200 return NULL;
4201 }
4202
4203 if (attack_mode == ATTACK_MODE_COMBI)
4204 {
4205 const uint combs_mode = data.combs_mode;
4206
4207 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
4208 {
4209 const char *dictfilec = data.dictfile2;
4210
4211 FILE *combs_fp = fopen (dictfilec, "rb");
4212
4213 if (combs_fp == NULL)
4214 {
4215 log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
4216
4217 fclose (fd);
4218
4219 return NULL;
4220 }
4221
4222 device_param->combs_fp = combs_fp;
4223 }
4224 else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
4225 {
4226 const char *dictfilec = data.dictfile;
4227
4228 FILE *combs_fp = fopen (dictfilec, "rb");
4229
4230 if (combs_fp == NULL)
4231 {
4232 log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
4233
4234 fclose (fd);
4235
4236 return NULL;
4237 }
4238
4239 device_param->combs_fp = combs_fp;
4240 }
4241 }
4242
4243 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
4244
4245 wl_data->buf = (char *) mymalloc (segment_size);
4246 wl_data->avail = segment_size;
4247 wl_data->incr = segment_size;
4248 wl_data->cnt = 0;
4249 wl_data->pos = 0;
4250
4251 uint64_t words_cur = 0;
4252
4253 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4254 {
4255 uint64_t words_off = 0;
4256 uint64_t words_fin = 0;
4257
4258 uint64_t max = -1;
4259
4260 while (max)
4261 {
4262 const uint work = get_work (device_param, max);
4263
4264 if (work == 0) break;
4265
4266 words_off = device_param->words_off;
4267 words_fin = words_off + work;
4268
4269 char *line_buf;
4270 uint line_len;
4271
4272 for ( ; words_cur < words_off; words_cur++) get_next_word (wl_data, fd, &line_buf, &line_len);
4273
4274 max = 0;
4275
4276 for ( ; words_cur < words_fin; words_cur++)
4277 {
4278 get_next_word (wl_data, fd, &line_buf, &line_len);
4279
4280 line_len = convert_from_hex (line_buf, line_len);
4281
4282 // post-process rule engine
4283
4284 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
4285 {
4286 char rule_buf_out[BLOCK_SIZE];
4287
4288 memset (rule_buf_out, 0, sizeof (rule_buf_out));
4289
4290 int rule_len_out = -1;
4291
4292 if (line_len < BLOCK_SIZE)
4293 {
4294 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, line_buf, line_len, rule_buf_out);
4295 }
4296
4297 if (rule_len_out < 0) continue;
4298
4299 line_buf = rule_buf_out;
4300 line_len = rule_len_out;
4301 }
4302
4303 if (attack_kern == ATTACK_KERN_STRAIGHT)
4304 {
4305 if ((line_len < data.pw_min) || (line_len > data.pw_max))
4306 {
4307 max++;
4308
4309 hc_thread_mutex_lock (mux_counter);
4310
4311 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4312 {
4313 data.words_progress_rejected[salt_pos] += data.gpu_rules_cnt;
4314 }
4315
4316 hc_thread_mutex_unlock (mux_counter);
4317
4318 continue;
4319 }
4320 }
4321 else if (attack_kern == ATTACK_KERN_COMBI)
4322 {
4323 // do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
4324 // since we still need to combine the plains
4325
4326 if (line_len > data.pw_max)
4327 {
4328 max++;
4329
4330 hc_thread_mutex_lock (mux_counter);
4331
4332 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4333 {
4334 data.words_progress_rejected[salt_pos] += data.combs_cnt;
4335 }
4336
4337 hc_thread_mutex_unlock (mux_counter);
4338
4339 continue;
4340 }
4341 }
4342
4343 device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
4344
4345 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
4346
4347 if (data.devices_status == STATUS_CRACKED) break;
4348 if (data.devices_status == STATUS_ABORTED) break;
4349 if (data.devices_status == STATUS_QUIT) break;
4350 if (data.devices_status == STATUS_BYPASS) break;
4351 }
4352
4353 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
4354
4355 if (data.devices_status == STATUS_CRACKED) break;
4356 if (data.devices_status == STATUS_ABORTED) break;
4357 if (data.devices_status == STATUS_QUIT) break;
4358 if (data.devices_status == STATUS_BYPASS) break;
4359 }
4360
4361 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
4362
4363 if (data.devices_status == STATUS_CRACKED) break;
4364 if (data.devices_status == STATUS_ABORTED) break;
4365 if (data.devices_status == STATUS_QUIT) break;
4366 if (data.devices_status == STATUS_BYPASS) break;
4367
4368 // we need 2 flushing because we have two independant caches and it can occur
4369 // that one buffer is already at threshold plus for that length also exists
4370 // more data in the 2nd buffer so it would overflow
4371
4372 //
4373 // flush session 1
4374 //
4375
4376 {
4377 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4378 {
4379 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4380
4381 const uint pw_cache_cnt = pw_cache->cnt;
4382
4383 if (pw_cache_cnt == 0) continue;
4384
4385 pw_cache->cnt = 0;
4386
4387 uint pws_cnt = device_param->pws_cnt;
4388
4389 pw_t *pw = device_param->pws_buf + pws_cnt;
4390
4391 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4392
4393 pw->pw_len = pw_len;
4394
4395 uint pw_cnt = device_param->pw_cnt;
4396
4397 pw_cnt += pw_cache_cnt;
4398
4399 device_param->pw_cnt = pw_cnt;
4400
4401 pws_cnt++;
4402
4403 device_param->pws_cnt = pws_cnt;
4404
4405 if (pws_cnt == device_param->gpu_power_user) break;
4406 }
4407
4408 const uint pw_cnt = device_param->pw_cnt;
4409 const uint pws_cnt = device_param->pws_cnt;
4410
4411 if (pws_cnt)
4412 {
4413 run_copy (device_param, pws_cnt);
4414
4415 run_cracker (device_param, pw_cnt, pws_cnt);
4416
4417 device_param->pw_cnt = 0;
4418 device_param->pws_cnt = 0;
4419 }
4420
4421 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
4422
4423 if (data.devices_status == STATUS_CRACKED) break;
4424 if (data.devices_status == STATUS_ABORTED) break;
4425 if (data.devices_status == STATUS_QUIT) break;
4426 if (data.devices_status == STATUS_BYPASS) break;
4427 }
4428
4429 //
4430 // flush session 2
4431 //
4432
4433 {
4434 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4435 {
4436 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4437
4438 const uint pw_cache_cnt = pw_cache->cnt;
4439
4440 if (pw_cache_cnt == 0) continue;
4441
4442 pw_cache->cnt = 0;
4443
4444 uint pws_cnt = device_param->pws_cnt;
4445
4446 pw_t *pw = device_param->pws_buf + pws_cnt;
4447
4448 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4449
4450 pw->pw_len = pw_len;
4451
4452 uint pw_cnt = device_param->pw_cnt;
4453
4454 pw_cnt += pw_cache_cnt;
4455
4456 device_param->pw_cnt = pw_cnt;
4457
4458 pws_cnt++;
4459
4460 device_param->pws_cnt = pws_cnt;
4461 }
4462
4463 const uint pw_cnt = device_param->pw_cnt;
4464 const uint pws_cnt = device_param->pws_cnt;
4465
4466 if (pws_cnt)
4467 {
4468 run_copy (device_param, pws_cnt);
4469
4470 run_cracker (device_param, pw_cnt, pws_cnt);
4471
4472 device_param->pw_cnt = 0;
4473 device_param->pws_cnt = 0;
4474 }
4475
4476 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
4477
4478 if (data.devices_status == STATUS_CRACKED) break;
4479 if (data.devices_status == STATUS_ABORTED) break;
4480 if (data.devices_status == STATUS_QUIT) break;
4481 if (data.devices_status == STATUS_BYPASS) break;
4482 }
4483
4484 if (words_fin == 0) break;
4485
4486 device_param->words_done = words_fin;
4487 }
4488
4489 if (attack_mode == ATTACK_MODE_COMBI)
4490 {
4491 fclose (device_param->combs_fp);
4492 }
4493
4494 free (wl_data->buf);
4495 free (wl_data);
4496
4497 fclose (fd);
4498 }
4499
4500 return NULL;
4501 }
4502
4503 static void weak_hash_check (hc_device_param_t *device_param, const uint salt_pos, const uint gpu_loops)
4504 {
4505 salt_t *salt_buf = &data.salts_buf[salt_pos];
4506
4507 device_param->kernel_params_buf32[24] = salt_pos;
4508 device_param->kernel_params_buf32[27] = 1;
4509 device_param->kernel_params_buf32[28] = salt_buf->digests_cnt;
4510 device_param->kernel_params_buf32[29] = salt_buf->digests_offset;
4511 device_param->kernel_params_buf32[30] = 0;
4512 device_param->kernel_params_buf32[31] = 1;
4513
4514 char *dictfile_old = data.dictfile;
4515 char *dictfile2_old = data.dictfile2;
4516 char *mask_old = data.mask;
4517
4518 const char *weak_hash_check = "weak-hash-check";
4519
4520 data.dictfile = (char *) weak_hash_check;
4521 data.dictfile2 = (char *) weak_hash_check;
4522 data.mask = (char *) weak_hash_check;
4523
4524 /**
4525 * run the kernel
4526 */
4527
4528 if (data.attack_exec == ATTACK_EXEC_ON_GPU)
4529 {
4530 run_kernel (KERN_RUN_1, device_param, 1);
4531 }
4532 else
4533 {
4534 run_kernel (KERN_RUN_1, device_param, 1);
4535
4536 const uint iter = salt_buf->salt_iter;
4537
4538 for (uint loop_pos = 0; loop_pos < iter; loop_pos += gpu_loops)
4539 {
4540 uint loop_left = iter - loop_pos;
4541
4542 loop_left = MIN (loop_left, gpu_loops);
4543
4544 device_param->kernel_params_buf32[25] = loop_pos;
4545 device_param->kernel_params_buf32[26] = loop_left;
4546
4547 run_kernel (KERN_RUN_2, device_param, 1);
4548 }
4549
4550 run_kernel (KERN_RUN_3, device_param, 1);
4551 }
4552
4553 /**
4554 * result
4555 */
4556
4557 check_cracked (device_param, salt_pos);
4558
4559 /**
4560 * cleanup
4561 */
4562
4563 device_param->kernel_params_buf32[24] = 0;
4564 device_param->kernel_params_buf32[25] = 0;
4565 device_param->kernel_params_buf32[26] = 0;
4566 device_param->kernel_params_buf32[27] = 0;
4567 device_param->kernel_params_buf32[28] = 0;
4568 device_param->kernel_params_buf32[29] = 0;
4569 device_param->kernel_params_buf32[30] = 0;
4570 device_param->kernel_params_buf32[31] = 0;
4571
4572 data.dictfile = dictfile_old;
4573 data.dictfile2 = dictfile2_old;
4574 data.mask = mask_old;
4575 }
4576
4577 // hlfmt hashcat
4578
4579 static void hlfmt_hash_hashcat (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
4580 {
4581 if (data.username == 0)
4582 {
4583 *hashbuf_pos = line_buf;
4584 *hashbuf_len = line_len;
4585 }
4586 else
4587 {
4588 char *pos = line_buf;
4589 int len = line_len;
4590
4591 for (int i = 0; i < line_len; i++, pos++, len--)
4592 {
4593 if (line_buf[i] == data.separator)
4594 {
4595 pos++;
4596
4597 len--;
4598
4599 break;
4600 }
4601 }
4602
4603 *hashbuf_pos = pos;
4604 *hashbuf_len = len;
4605 }
4606 }
4607
4608 static void hlfmt_user_hashcat (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
4609 {
4610 char *pos = NULL;
4611 int len = 0;
4612
4613 int sep_cnt = 0;
4614
4615 for (int i = 0; i < line_len; i++)
4616 {
4617 if (line_buf[i] == data.separator)
4618 {
4619 sep_cnt++;
4620
4621 continue;
4622 }
4623
4624 if (sep_cnt == 0)
4625 {
4626 if (pos == NULL) pos = line_buf + i;
4627
4628 len++;
4629 }
4630 }
4631
4632 *userbuf_pos = pos;
4633 *userbuf_len = len;
4634 }
4635
4636 // hlfmt pwdump
4637
4638 static int hlfmt_detect_pwdump (char line_buf[BUFSIZ], int line_len)
4639 {
4640 int sep_cnt = 0;
4641
4642 int sep2_len = 0;
4643 int sep3_len = 0;
4644
4645 for (int i = 0; i < line_len; i++)
4646 {
4647 if (line_buf[i] == ':')
4648 {
4649 sep_cnt++;
4650
4651 continue;
4652 }
4653
4654 if (sep_cnt == 2) sep2_len++;
4655 if (sep_cnt == 3) sep3_len++;
4656 }
4657
4658 if ((sep_cnt == 6) && ((sep2_len == 32) || (sep3_len == 32))) return 1;
4659
4660 return 0;
4661 }
4662
4663 static void hlfmt_hash_pwdump (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
4664 {
4665 char *pos = NULL;
4666 int len = 0;
4667
4668 int sep_cnt = 0;
4669
4670 for (int i = 0; i < line_len; i++)
4671 {
4672 if (line_buf[i] == ':')
4673 {
4674 sep_cnt++;
4675
4676 continue;
4677 }
4678
4679 if (data.hash_mode == 1000)
4680 {
4681 if (sep_cnt == 3)
4682 {
4683 if (pos == NULL) pos = line_buf + i;
4684
4685 len++;
4686 }
4687 }
4688 else if (data.hash_mode == 3000)
4689 {
4690 if (sep_cnt == 2)
4691 {
4692 if (pos == NULL) pos = line_buf + i;
4693
4694 len++;
4695 }
4696 }
4697 }
4698
4699 *hashbuf_pos = pos;
4700 *hashbuf_len = len;
4701 }
4702
4703 static void hlfmt_user_pwdump (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
4704 {
4705 char *pos = NULL;
4706 int len = 0;
4707
4708 int sep_cnt = 0;
4709
4710 for (int i = 0; i < line_len; i++)
4711 {
4712 if (line_buf[i] == ':')
4713 {
4714 sep_cnt++;
4715
4716 continue;
4717 }
4718
4719 if (sep_cnt == 0)
4720 {
4721 if (pos == NULL) pos = line_buf + i;
4722
4723 len++;
4724 }
4725 }
4726
4727 *userbuf_pos = pos;
4728 *userbuf_len = len;
4729 }
4730
4731 // hlfmt passwd
4732
4733 static int hlfmt_detect_passwd (char line_buf[BUFSIZ], int line_len)
4734 {
4735 int sep_cnt = 0;
4736
4737 char sep5_first = 0;
4738 char sep6_first = 0;
4739
4740 for (int i = 0; i < line_len; i++)
4741 {
4742 if (line_buf[i] == ':')
4743 {
4744 sep_cnt++;
4745
4746 continue;
4747 }
4748
4749 if (sep_cnt == 5) if (sep5_first == 0) sep5_first = line_buf[i];
4750 if (sep_cnt == 6) if (sep6_first == 0) sep6_first = line_buf[i];
4751 }
4752
4753 if ((sep_cnt == 6) && ((sep5_first == '/') || (sep6_first == '/'))) return 1;
4754
4755 return 0;
4756 }
4757
4758 static void hlfmt_hash_passwd (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
4759 {
4760 char *pos = NULL;
4761 int len = 0;
4762
4763 int sep_cnt = 0;
4764
4765 for (int i = 0; i < line_len; i++)
4766 {
4767 if (line_buf[i] == ':')
4768 {
4769 sep_cnt++;
4770
4771 continue;
4772 }
4773
4774 if (sep_cnt == 1)
4775 {
4776 if (pos == NULL) pos = line_buf + i;
4777
4778 len++;
4779 }
4780 }
4781
4782 *hashbuf_pos = pos;
4783 *hashbuf_len = len;
4784 }
4785
4786 static void hlfmt_user_passwd (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
4787 {
4788 char *pos = NULL;
4789 int len = 0;
4790
4791 int sep_cnt = 0;
4792
4793 for (int i = 0; i < line_len; i++)
4794 {
4795 if (line_buf[i] == ':')
4796 {
4797 sep_cnt++;
4798
4799 continue;
4800 }
4801
4802 if (sep_cnt == 0)
4803 {
4804 if (pos == NULL) pos = line_buf + i;
4805
4806 len++;
4807 }
4808 }
4809
4810 *userbuf_pos = pos;
4811 *userbuf_len = len;
4812 }
4813
4814 // hlfmt shadow
4815
4816 static int hlfmt_detect_shadow (char line_buf[BUFSIZ], int line_len)
4817 {
4818 int sep_cnt = 0;
4819
4820 for (int i = 0; i < line_len; i++)
4821 {
4822 if (line_buf[i] == ':') sep_cnt++;
4823 }
4824
4825 if (sep_cnt == 8) return 1;
4826
4827 return 0;
4828 }
4829
4830 static void hlfmt_hash_shadow (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
4831 {
4832 hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len);
4833 }
4834
4835 static void hlfmt_user_shadow (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
4836 {
4837 hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len);
4838 }
4839
4840 // hlfmt main
4841
4842 static void hlfmt_hash (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
4843 {
4844 switch (hashfile_format)
4845 {
4846 case HLFMT_HASHCAT: hlfmt_hash_hashcat (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
4847 case HLFMT_PWDUMP: hlfmt_hash_pwdump (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
4848 case HLFMT_PASSWD: hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
4849 case HLFMT_SHADOW: hlfmt_hash_shadow (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
4850 }
4851 }
4852
4853 static void hlfmt_user (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
4854 {
4855 switch (hashfile_format)
4856 {
4857 case HLFMT_HASHCAT: hlfmt_user_hashcat (line_buf, line_len, userbuf_pos, userbuf_len); break;
4858 case HLFMT_PWDUMP: hlfmt_user_pwdump (line_buf, line_len, userbuf_pos, userbuf_len); break;
4859 case HLFMT_PASSWD: hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len); break;
4860 case HLFMT_SHADOW: hlfmt_user_shadow (line_buf, line_len, userbuf_pos, userbuf_len); break;
4861 }
4862 }
4863
4864 static uint hlfmt_detect (FILE *fp, uint max_check)
4865 {
4866 // Exception: those formats are wrongly detected as HLFMT_SHADOW, prevent it
4867
4868 if (data.hash_mode == 5300) return HLFMT_HASHCAT;
4869 if (data.hash_mode == 5400) return HLFMT_HASHCAT;
4870
4871 uint *formats_cnt = (uint *) mycalloc (HLFMTS_CNT, sizeof (uint));
4872
4873 uint num_check = 0;
4874
4875 while (!feof (fp))
4876 {
4877 char line_buf[BUFSIZ];
4878
4879 int line_len = fgetl (fp, line_buf);
4880
4881 if (line_len == 0) continue;
4882
4883 if (hlfmt_detect_pwdump (line_buf, line_len)) formats_cnt[HLFMT_PWDUMP]++;
4884 if (hlfmt_detect_passwd (line_buf, line_len)) formats_cnt[HLFMT_PASSWD]++;
4885 if (hlfmt_detect_shadow (line_buf, line_len)) formats_cnt[HLFMT_SHADOW]++;
4886
4887 if (num_check == max_check) break;
4888
4889 num_check++;
4890 }
4891
4892 uint hashlist_format = HLFMT_HASHCAT;
4893
4894 for (int i = 1; i < HLFMTS_CNT; i++)
4895 {
4896 if (formats_cnt[i - 1] >= formats_cnt[i]) continue;
4897
4898 hashlist_format = i;
4899 }
4900
4901 free (formats_cnt);
4902
4903 return hashlist_format;
4904 }
4905
4906 /**
4907 * some further helper function
4908 */
4909
4910 // wrapper around mymalloc for ADL
4911
4912 void *__stdcall ADL_Main_Memory_Alloc (const int iSize)
4913 {
4914 return mymalloc (iSize);
4915 }
4916
4917 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)
4918 {
4919 uint64_t collisions = 0;
4920
4921 const uint dgst_pos0 = data.dgst_pos0;
4922 const uint dgst_pos1 = data.dgst_pos1;
4923 const uint dgst_pos2 = data.dgst_pos2;
4924 const uint dgst_pos3 = data.dgst_pos3;
4925
4926 memset (bitmap_a, 0, bitmap_size);
4927 memset (bitmap_b, 0, bitmap_size);
4928 memset (bitmap_c, 0, bitmap_size);
4929 memset (bitmap_d, 0, bitmap_size);
4930
4931 for (uint i = 0; i < digests_cnt; i++)
4932 {
4933 uint *digest_ptr = (uint *) digests_buf_ptr;
4934
4935 digests_buf_ptr += dgst_size;
4936
4937 const uint val0 = 1 << (digest_ptr[dgst_pos0] & 0x1f);
4938 const uint val1 = 1 << (digest_ptr[dgst_pos1] & 0x1f);
4939 const uint val2 = 1 << (digest_ptr[dgst_pos2] & 0x1f);
4940 const uint val3 = 1 << (digest_ptr[dgst_pos3] & 0x1f);
4941
4942 const uint idx0 = (digest_ptr[dgst_pos0] >> dgst_shifts) & bitmap_mask;
4943 const uint idx1 = (digest_ptr[dgst_pos1] >> dgst_shifts) & bitmap_mask;
4944 const uint idx2 = (digest_ptr[dgst_pos2] >> dgst_shifts) & bitmap_mask;
4945 const uint idx3 = (digest_ptr[dgst_pos3] >> dgst_shifts) & bitmap_mask;
4946
4947 if (bitmap_a[idx0] & val0) collisions++;
4948 if (bitmap_b[idx1] & val1) collisions++;
4949 if (bitmap_c[idx2] & val2) collisions++;
4950 if (bitmap_d[idx3] & val3) collisions++;
4951
4952 bitmap_a[idx0] |= val0;
4953 bitmap_b[idx1] |= val1;
4954 bitmap_c[idx2] |= val2;
4955 bitmap_d[idx3] |= val3;
4956
4957 if (collisions >= collisions_max) return 0x7fffffff;
4958 }
4959
4960 return collisions;
4961 }
4962
4963 /**
4964 * main
4965 */
4966
4967 int main (int argc, char **argv)
4968 {
4969 /**
4970 * To help users a bit
4971 */
4972
4973 char *compute = getenv ("COMPUTE");
4974
4975 if (compute)
4976 {
4977 char display[100];
4978
4979 snprintf (display, sizeof (display) - 1, "DISPLAY=%s", compute);
4980
4981 putenv (display);
4982 }
4983 else
4984 {
4985 if (getenv ("DISPLAY") == NULL)
4986 putenv ((char *) "DISPLAY=:0");
4987 }
4988
4989 /*
4990 if (getenv ("GPU_MAX_ALLOC_PERCENT") == NULL)
4991 putenv ((char *) "GPU_MAX_ALLOC_PERCENT=100");
4992
4993 if (getenv ("GPU_USE_SYNC_OBJECTS") == NULL)
4994 putenv ((char *) "GPU_USE_SYNC_OBJECTS=1");
4995 */
4996
4997 /**
4998 * Real init
4999 */
5000
5001 memset (&data, 0, sizeof (hc_global_data_t));
5002
5003 time_t proc_start;
5004
5005 time (&proc_start);
5006
5007 data.proc_start = proc_start;
5008
5009 int myargc = argc;
5010 char **myargv = argv;
5011
5012 hc_thread_mutex_init (mux_dispatcher);
5013 hc_thread_mutex_init (mux_counter);
5014 hc_thread_mutex_init (mux_display);
5015 hc_thread_mutex_init (mux_adl);
5016
5017 /**
5018 * commandline parameters
5019 */
5020
5021 uint usage = USAGE;
5022 uint version = VERSION;
5023 uint quiet = QUIET;
5024 uint benchmark = BENCHMARK;
5025 uint benchmark_mode = BENCHMARK_MODE;
5026 uint show = SHOW;
5027 uint left = LEFT;
5028 uint username = USERNAME;
5029 uint remove = REMOVE;
5030 uint remove_timer = REMOVE_TIMER;
5031 uint64_t skip = SKIP;
5032 uint64_t limit = LIMIT;
5033 uint keyspace = KEYSPACE;
5034 uint potfile_disable = POTFILE_DISABLE;
5035 uint debug_mode = DEBUG_MODE;
5036 char *debug_file = NULL;
5037 char *induction_dir = NULL;
5038 char *outfile_check_dir = NULL;
5039 uint force = FORCE;
5040 uint runtime = RUNTIME;
5041 uint hash_mode = HASH_MODE;
5042 uint attack_mode = ATTACK_MODE;
5043 uint markov_disable = MARKOV_DISABLE;
5044 uint markov_classic = MARKOV_CLASSIC;
5045 uint markov_threshold = MARKOV_THRESHOLD;
5046 char *markov_hcstat = NULL;
5047 char *outfile = NULL;
5048 uint outfile_format = OUTFILE_FORMAT;
5049 uint outfile_autohex = OUTFILE_AUTOHEX;
5050 uint outfile_check_timer = OUTFILE_CHECK_TIMER;
5051 uint restore = RESTORE;
5052 uint restore_timer = RESTORE_TIMER;
5053 uint restore_disable = RESTORE_DISABLE;
5054 uint status = STATUS;
5055 uint status_timer = STATUS_TIMER;
5056 uint status_automat = STATUS_AUTOMAT;
5057 uint loopback = LOOPBACK;
5058 uint weak_hash_threshold = WEAK_HASH_THRESHOLD;
5059 char *session = NULL;
5060 uint hex_charset = HEX_CHARSET;
5061 uint hex_salt = HEX_SALT;
5062 uint hex_wordlist = HEX_WORDLIST;
5063 uint rp_gen = RP_GEN;
5064 uint rp_gen_func_min = RP_GEN_FUNC_MIN;
5065 uint rp_gen_func_max = RP_GEN_FUNC_MAX;
5066 uint rp_gen_seed = RP_GEN_SEED;
5067 char *rule_buf_l = (char *) RULE_BUF_L;
5068 char *rule_buf_r = (char *) RULE_BUF_R;
5069 uint increment = INCREMENT;
5070 uint increment_min = INCREMENT_MIN;
5071 uint increment_max = INCREMENT_MAX;
5072 char *cpu_affinity = NULL;
5073 char *gpu_devices = NULL;
5074 char *gpu_platform = NULL;
5075 char *truecrypt_keyfiles = NULL;
5076 uint workload_profile = WORKLOAD_PROFILE;
5077 uint gpu_accel = GPU_ACCEL;
5078 uint gpu_loops = GPU_LOOPS;
5079 uint gpu_temp_disable = GPU_TEMP_DISABLE;
5080 uint gpu_temp_abort = GPU_TEMP_ABORT;
5081 uint gpu_temp_retain = GPU_TEMP_RETAIN;
5082 uint powertune_enable = POWERTUNE_ENABLE;
5083 uint logfile_disable = LOGFILE_DISABLE;
5084 uint segment_size = SEGMENT_SIZE;
5085 uint scrypt_tmto = SCRYPT_TMTO;
5086 char separator = SEPARATOR;
5087 uint bitmap_min = BITMAP_MIN;
5088 uint bitmap_max = BITMAP_MAX;
5089 char *custom_charset_1 = NULL;
5090 char *custom_charset_2 = NULL;
5091 char *custom_charset_3 = NULL;
5092 char *custom_charset_4 = NULL;
5093
5094 #define IDX_HELP 'h'
5095 #define IDX_VERSION 'V'
5096 #define IDX_VERSION_LOWER 'v'
5097 #define IDX_QUIET 0xff02
5098 #define IDX_SHOW 0xff03
5099 #define IDX_LEFT 0xff04
5100 #define IDX_REMOVE 0xff05
5101 #define IDX_REMOVE_TIMER 0xff37
5102 #define IDX_SKIP 's'
5103 #define IDX_LIMIT 'l'
5104 #define IDX_KEYSPACE 0xff35
5105 #define IDX_POTFILE_DISABLE 0xff06
5106 #define IDX_DEBUG_MODE 0xff43
5107 #define IDX_DEBUG_FILE 0xff44
5108 #define IDX_INDUCTION_DIR 0xff46
5109 #define IDX_OUTFILE_CHECK_DIR 0xff47
5110 #define IDX_USERNAME 0xff07
5111 #define IDX_FORCE 0xff08
5112 #define IDX_RUNTIME 0xff09
5113 #define IDX_BENCHMARK 'b'
5114 #define IDX_BENCHMARK_MODE 0xff32
5115 #define IDX_HASH_MODE 'm'
5116 #define IDX_ATTACK_MODE 'a'
5117 #define IDX_RP_FILE 'r'
5118 #define IDX_RP_GEN 'g'
5119 #define IDX_RP_GEN_FUNC_MIN 0xff10
5120 #define IDX_RP_GEN_FUNC_MAX 0xff11
5121 #define IDX_RP_GEN_SEED 0xff34
5122 #define IDX_RULE_BUF_L 'j'
5123 #define IDX_RULE_BUF_R 'k'
5124 #define IDX_INCREMENT 'i'
5125 #define IDX_INCREMENT_MIN 0xff12
5126 #define IDX_INCREMENT_MAX 0xff13
5127 #define IDX_OUTFILE 'o'
5128 #define IDX_OUTFILE_FORMAT 0xff14
5129 #define IDX_OUTFILE_AUTOHEX_DISABLE 0xff39
5130 #define IDX_OUTFILE_CHECK_TIMER 0xff45
5131 #define IDX_RESTORE 0xff15
5132 #define IDX_RESTORE_DISABLE 0xff27
5133 #define IDX_STATUS 0xff17
5134 #define IDX_STATUS_TIMER 0xff18
5135 #define IDX_STATUS_AUTOMAT 0xff50
5136 #define IDX_LOOPBACK 0xff38
5137 #define IDX_WEAK_HASH_THRESHOLD 0xff42
5138 #define IDX_SESSION 0xff19
5139 #define IDX_HEX_CHARSET 0xff20
5140 #define IDX_HEX_SALT 0xff21
5141 #define IDX_HEX_WORDLIST 0xff40
5142 #define IDX_MARKOV_DISABLE 0xff22
5143 #define IDX_MARKOV_CLASSIC 0xff23
5144 #define IDX_MARKOV_THRESHOLD 't'
5145 #define IDX_MARKOV_HCSTAT 0xff24
5146 #define IDX_CPU_AFFINITY 0xff25
5147 #define IDX_GPU_DEVICES 'd'
5148 #define IDX_GPU_PLATFORM 0xff72
5149 #define IDX_WORKLOAD_PROFILE 'w'
5150 #define IDX_GPU_ACCEL 'n'
5151 #define IDX_GPU_LOOPS 'u'
5152 #define IDX_GPU_TEMP_DISABLE 0xff29
5153 #define IDX_GPU_TEMP_ABORT 0xff30
5154 #define IDX_GPU_TEMP_RETAIN 0xff31
5155 #define IDX_POWERTUNE_ENABLE 0xff41
5156 #define IDX_LOGFILE_DISABLE 0xff51
5157 #define IDX_TRUECRYPT_KEYFILES 0xff52
5158 #define IDX_SCRYPT_TMTO 0xff61
5159 #define IDX_SEGMENT_SIZE 'c'
5160 #define IDX_SEPARATOR 'p'
5161 #define IDX_BITMAP_MIN 0xff70
5162 #define IDX_BITMAP_MAX 0xff71
5163 #define IDX_CUSTOM_CHARSET_1 '1'
5164 #define IDX_CUSTOM_CHARSET_2 '2'
5165 #define IDX_CUSTOM_CHARSET_3 '3'
5166 #define IDX_CUSTOM_CHARSET_4 '4'
5167
5168 char short_options[] = "hVvm:a:r:j:k:g:o:t:d:n:u:c:p:s:l:1:2:3:4:ibw:";
5169
5170 struct option long_options[] =
5171 {
5172 {"help", no_argument, 0, IDX_HELP},
5173 {"version", no_argument, 0, IDX_VERSION},
5174 {"quiet", no_argument, 0, IDX_QUIET},
5175 {"show", no_argument, 0, IDX_SHOW},
5176 {"left", no_argument, 0, IDX_LEFT},
5177 {"username", no_argument, 0, IDX_USERNAME},
5178 {"remove", no_argument, 0, IDX_REMOVE},
5179 {"remove-timer", required_argument, 0, IDX_REMOVE_TIMER},
5180 {"skip", required_argument, 0, IDX_SKIP},
5181 {"limit", required_argument, 0, IDX_LIMIT},
5182 {"keyspace", no_argument, 0, IDX_KEYSPACE},
5183 {"potfile-disable", no_argument, 0, IDX_POTFILE_DISABLE},
5184 {"debug-mode", required_argument, 0, IDX_DEBUG_MODE},
5185 {"debug-file", required_argument, 0, IDX_DEBUG_FILE},
5186 {"induction-dir", required_argument, 0, IDX_INDUCTION_DIR},
5187 {"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR},
5188 {"force", no_argument, 0, IDX_FORCE},
5189 {"benchmark", no_argument, 0, IDX_BENCHMARK},
5190 {"benchmark-mode", required_argument, 0, IDX_BENCHMARK_MODE},
5191 {"restore", no_argument, 0, IDX_RESTORE},
5192 {"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE},
5193 {"status", no_argument, 0, IDX_STATUS},
5194 {"status-timer", required_argument, 0, IDX_STATUS_TIMER},
5195 {"status-automat", no_argument, 0, IDX_STATUS_AUTOMAT},
5196 {"loopback", no_argument, 0, IDX_LOOPBACK},
5197 {"weak-hash-threshold",
5198 required_argument, 0, IDX_WEAK_HASH_THRESHOLD},
5199 {"session", required_argument, 0, IDX_SESSION},
5200 {"runtime", required_argument, 0, IDX_RUNTIME},
5201 {"generate-rules", required_argument, 0, IDX_RP_GEN},
5202 {"generate-rules-func-min",
5203 required_argument, 0, IDX_RP_GEN_FUNC_MIN},
5204 {"generate-rules-func-max",
5205 required_argument, 0, IDX_RP_GEN_FUNC_MAX},
5206 {"generate-rules-seed",
5207 required_argument, 0, IDX_RP_GEN_SEED},
5208 {"rule-left", required_argument, 0, IDX_RULE_BUF_L},
5209 {"rule-right", required_argument, 0, IDX_RULE_BUF_R},
5210 {"hash-type", required_argument, 0, IDX_HASH_MODE},
5211 {"attack-mode", required_argument, 0, IDX_ATTACK_MODE},
5212 {"rules-file", required_argument, 0, IDX_RP_FILE},
5213 {"outfile", required_argument, 0, IDX_OUTFILE},
5214 {"outfile-format", required_argument, 0, IDX_OUTFILE_FORMAT},
5215 {"outfile-autohex-disable",
5216 no_argument, 0, IDX_OUTFILE_AUTOHEX_DISABLE},
5217 {"outfile-check-timer",
5218 required_argument, 0, IDX_OUTFILE_CHECK_TIMER},
5219 {"hex-charset", no_argument, 0, IDX_HEX_CHARSET},
5220 {"hex-salt", no_argument, 0, IDX_HEX_SALT},
5221 {"hex-wordlist", no_argument, 0, IDX_HEX_WORDLIST},
5222 {"markov-disable", no_argument, 0, IDX_MARKOV_DISABLE},
5223 {"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC},
5224 {"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD},
5225 {"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT},
5226 {"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
5227 {"gpu-devices", required_argument, 0, IDX_GPU_DEVICES},
5228 {"gpu-platform", required_argument, 0, IDX_GPU_PLATFORM},
5229 {"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE},
5230 {"gpu-accel", required_argument, 0, IDX_GPU_ACCEL},
5231 {"gpu-loops", required_argument, 0, IDX_GPU_LOOPS},
5232 {"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE},
5233 {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
5234 {"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
5235 {"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
5236 {"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
5237 {"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
5238 {"segment-size", required_argument, 0, IDX_SEGMENT_SIZE},
5239 {"scrypt-tmto", required_argument, 0, IDX_SCRYPT_TMTO},
5240 // deprecated
5241 {"seperator", required_argument, 0, IDX_SEPARATOR},
5242 {"separator", required_argument, 0, IDX_SEPARATOR},
5243 {"bitmap-min", required_argument, 0, IDX_BITMAP_MIN},
5244 {"bitmap-max", required_argument, 0, IDX_BITMAP_MAX},
5245 {"increment", no_argument, 0, IDX_INCREMENT},
5246 {"increment-min", required_argument, 0, IDX_INCREMENT_MIN},
5247 {"increment-max", required_argument, 0, IDX_INCREMENT_MAX},
5248 {"custom-charset1", required_argument, 0, IDX_CUSTOM_CHARSET_1},
5249 {"custom-charset2", required_argument, 0, IDX_CUSTOM_CHARSET_2},
5250 {"custom-charset3", required_argument, 0, IDX_CUSTOM_CHARSET_3},
5251 {"custom-charset4", required_argument, 0, IDX_CUSTOM_CHARSET_4},
5252
5253 {0, 0, 0, 0}
5254 };
5255
5256 uint rp_files_cnt = 0;
5257
5258 char **rp_files = (char **) mycalloc (argc, sizeof (char *));
5259
5260 int option_index;
5261 int c;
5262
5263 optind = 1;
5264 optopt = 0;
5265 option_index = 0;
5266
5267 while (((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1) && optopt == 0)
5268 {
5269 switch (c)
5270 {
5271 case IDX_HELP: usage = 1; break;
5272 case IDX_VERSION:
5273 case IDX_VERSION_LOWER: version = 1; break;
5274 case IDX_RESTORE: restore = 1; break;
5275 case IDX_SESSION: session = optarg; break;
5276 case IDX_SHOW: show = 1; break;
5277 case IDX_LEFT: left = 1; break;
5278 case '?': return (-1);
5279 }
5280 }
5281
5282 if (optopt != 0)
5283 {
5284 log_error ("ERROR: Invalid argument specified");
5285
5286 return (-1);
5287 }
5288
5289 /**
5290 * exit functions
5291 */
5292
5293 if (version)
5294 {
5295 log_info (VERSION_TXT);
5296
5297 return (0);
5298 }
5299
5300 if (usage)
5301 {
5302 usage_big_print (PROGNAME);
5303
5304 return (0);
5305 }
5306
5307 /**
5308 * session
5309 */
5310
5311 if (session == NULL) session = (char *) PROGNAME;
5312
5313 size_t session_size = strlen (session) + 32;
5314
5315 data.session = session;
5316
5317 char *eff_restore_file = (char *) mymalloc (session_size);
5318 char *new_restore_file = (char *) mymalloc (session_size);
5319
5320 snprintf (eff_restore_file, session_size - 1, "%s.restore", session);
5321 snprintf (new_restore_file, session_size - 1, "%s.restore.new", session);
5322
5323 data.eff_restore_file = eff_restore_file;
5324 data.new_restore_file = new_restore_file;
5325
5326 if (((show == 1) || (left == 1)) && (restore == 1))
5327 {
5328 if (show == 1) log_error ("ERROR: Mixing --restore parameter and --show is not supported");
5329 else log_error ("ERROR: Mixing --restore parameter and --left is not supported");
5330
5331 return (-1);
5332 }
5333
5334 // this allows the user to use --show and --left while cracking (i.e. while another instance of oclHashcat is running)
5335 if ((show == 1) || (left == 1))
5336 {
5337 restore_disable = 1;
5338
5339 restore = 0;
5340 }
5341
5342 data.restore_disable = restore_disable;
5343
5344 restore_data_t *rd = init_restore (argc, argv);
5345
5346 data.rd = rd;
5347
5348 /**
5349 * restore file
5350 */
5351
5352 if (restore == 1)
5353 {
5354 read_restore (eff_restore_file, rd);
5355
5356 if (rd->version_bin < RESTORE_MIN)
5357 {
5358 log_error ("ERROR: Incompatible restore-file version");
5359
5360 return (-1);
5361 }
5362
5363 myargc = rd->argc;
5364 myargv = rd->argv;
5365
5366 #ifdef _POSIX
5367 rd->pid = getpid ();
5368 #elif _WIN
5369 rd->pid = GetCurrentProcessId ();
5370 #endif
5371 }
5372
5373 uint hash_mode_chgd = 0;
5374 uint runtime_chgd = 0;
5375 uint gpu_loops_chgd = 0;
5376 uint gpu_accel_chgd = 0;
5377 uint attack_mode_chgd = 0;
5378 uint outfile_format_chgd = 0;
5379 uint rp_gen_seed_chgd = 0;
5380 uint remove_timer_chgd = 0;
5381 uint increment_min_chgd = 0;
5382 uint increment_max_chgd = 0;
5383 uint gpu_temp_abort_chgd = 0;
5384 uint gpu_temp_retain_chgd = 0;
5385
5386 optind = 1;
5387 optopt = 0;
5388 option_index = 0;
5389
5390 while (((c = getopt_long (myargc, myargv, short_options, long_options, &option_index)) != -1) && optopt == 0)
5391 {
5392 switch (c)
5393 {
5394 //case IDX_HELP: usage = 1; break;
5395 //case IDX_VERSION: version = 1; break;
5396 //case IDX_RESTORE: restore = 1; break;
5397 case IDX_QUIET: quiet = 1; break;
5398 //case IDX_SHOW: show = 1; break;
5399 case IDX_SHOW: break;
5400 //case IDX_LEFT: left = 1; break;
5401 case IDX_LEFT: break;
5402 case IDX_USERNAME: username = 1; break;
5403 case IDX_REMOVE: remove = 1; break;
5404 case IDX_REMOVE_TIMER: remove_timer = atoi (optarg);
5405 remove_timer_chgd = 1; break;
5406 case IDX_POTFILE_DISABLE: potfile_disable = 1; break;
5407 case IDX_DEBUG_MODE: debug_mode = atoi (optarg); break;
5408 case IDX_DEBUG_FILE: debug_file = optarg; break;
5409 case IDX_INDUCTION_DIR: induction_dir = optarg; break;
5410 case IDX_OUTFILE_CHECK_DIR: outfile_check_dir = optarg; break;
5411 case IDX_FORCE: force = 1; break;
5412 case IDX_SKIP: skip = atoll (optarg); break;
5413 case IDX_LIMIT: limit = atoll (optarg); break;
5414 case IDX_KEYSPACE: keyspace = 1; break;
5415 case IDX_BENCHMARK: benchmark = 1; break;
5416 case IDX_BENCHMARK_MODE: benchmark_mode = atoi (optarg); break;
5417 case IDX_RESTORE: break;
5418 case IDX_RESTORE_DISABLE: restore_disable = 1; break;
5419 case IDX_STATUS: status = 1; break;
5420 case IDX_STATUS_TIMER: status_timer = atoi (optarg); break;
5421 case IDX_STATUS_AUTOMAT: status_automat = 1; break;
5422 case IDX_LOOPBACK: loopback = 1; break;
5423 case IDX_WEAK_HASH_THRESHOLD:
5424 weak_hash_threshold = atoi (optarg); break;
5425 //case IDX_SESSION: session = optarg; break;
5426 case IDX_SESSION: break;
5427 case IDX_HASH_MODE: hash_mode = atoi (optarg);
5428 hash_mode_chgd = 1; break;
5429 case IDX_RUNTIME: runtime = atoi (optarg);
5430 runtime_chgd = 1; break;
5431 case IDX_ATTACK_MODE: attack_mode = atoi (optarg);
5432 attack_mode_chgd = 1; break;
5433 case IDX_RP_FILE: rp_files[rp_files_cnt++] = optarg; break;
5434 case IDX_RP_GEN: rp_gen = atoi (optarg); break;
5435 case IDX_RP_GEN_FUNC_MIN: rp_gen_func_min = atoi (optarg); break;
5436 case IDX_RP_GEN_FUNC_MAX: rp_gen_func_max = atoi (optarg); break;
5437 case IDX_RP_GEN_SEED: rp_gen_seed = atoi (optarg);
5438 rp_gen_seed_chgd = 1; break;
5439 case IDX_RULE_BUF_L: rule_buf_l = optarg; break;
5440 case IDX_RULE_BUF_R: rule_buf_r = optarg; break;
5441 case IDX_MARKOV_DISABLE: markov_disable = 1; break;
5442 case IDX_MARKOV_CLASSIC: markov_classic = 1; break;
5443 case IDX_MARKOV_THRESHOLD: markov_threshold = atoi (optarg); break;
5444 case IDX_MARKOV_HCSTAT: markov_hcstat = optarg; break;
5445 case IDX_OUTFILE: outfile = optarg; break;
5446 case IDX_OUTFILE_FORMAT: outfile_format = atoi (optarg);
5447 outfile_format_chgd = 1; break;
5448 case IDX_OUTFILE_AUTOHEX_DISABLE:
5449 outfile_autohex = 0; break;
5450 case IDX_OUTFILE_CHECK_TIMER:
5451 outfile_check_timer = atoi (optarg); break;
5452 case IDX_HEX_CHARSET: hex_charset = 1; break;
5453 case IDX_HEX_SALT: hex_salt = 1; break;
5454 case IDX_HEX_WORDLIST: hex_wordlist = 1; break;
5455 case IDX_CPU_AFFINITY: cpu_affinity = optarg; break;
5456 case IDX_GPU_DEVICES: gpu_devices = optarg; break;
5457 case IDX_GPU_PLATFORM: gpu_platform = optarg; break;
5458 case IDX_WORKLOAD_PROFILE: workload_profile = atoi (optarg); break;
5459 case IDX_GPU_ACCEL: gpu_accel = atoi (optarg);
5460 gpu_accel_chgd = 1; break;
5461 case IDX_GPU_LOOPS: gpu_loops = atoi (optarg);
5462 gpu_loops_chgd = 1; break;
5463 case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break;
5464 case IDX_GPU_TEMP_ABORT: gpu_temp_abort_chgd = 1;
5465 gpu_temp_abort = atoi (optarg); break;
5466 case IDX_GPU_TEMP_RETAIN: gpu_temp_retain_chgd = 1;
5467 gpu_temp_retain = atoi (optarg); break;
5468 case IDX_POWERTUNE_ENABLE: powertune_enable = 1; break;
5469 case IDX_LOGFILE_DISABLE: logfile_disable = 1; break;
5470 case IDX_TRUECRYPT_KEYFILES: truecrypt_keyfiles = optarg; break;
5471 case IDX_SEGMENT_SIZE: segment_size = atoi (optarg); break;
5472 case IDX_SCRYPT_TMTO: scrypt_tmto = atoi (optarg); break;
5473 case IDX_SEPARATOR: separator = optarg[0]; break;
5474 case IDX_BITMAP_MIN: bitmap_min = atoi (optarg); break;
5475 case IDX_BITMAP_MAX: bitmap_max = atoi (optarg); break;
5476 case IDX_INCREMENT: increment = 1; break;
5477 case IDX_INCREMENT_MIN: increment_min = atoi (optarg);
5478 increment_min_chgd = 1; break;
5479 case IDX_INCREMENT_MAX: increment_max = atoi (optarg);
5480 increment_max_chgd = 1; break;
5481 case IDX_CUSTOM_CHARSET_1: custom_charset_1 = optarg; break;
5482 case IDX_CUSTOM_CHARSET_2: custom_charset_2 = optarg; break;
5483 case IDX_CUSTOM_CHARSET_3: custom_charset_3 = optarg; break;
5484 case IDX_CUSTOM_CHARSET_4: custom_charset_4 = optarg; break;
5485
5486 default:
5487 log_error ("ERROR: Invalid argument specified");
5488 return (-1);
5489 }
5490 }
5491
5492 if (optopt != 0)
5493 {
5494 log_error ("ERROR: Invalid argument specified");
5495
5496 return (-1);
5497 }
5498
5499 /**
5500 * Inform user things getting started,
5501 * - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
5502 * - we do not need to check algorithm_pos
5503 */
5504
5505 if (quiet == 0)
5506 {
5507 if (benchmark == 1)
5508 {
5509 log_info ("%s v%.2f starting in benchmark-mode...", PROGNAME, (float) VERSION_BIN / 100);
5510
5511 log_info ("");
5512 }
5513 else if (restore == 1)
5514 {
5515 log_info ("%s v%.2f starting in restore-mode...", PROGNAME, (float) VERSION_BIN / 100);
5516
5517 log_info ("");
5518 }
5519 else
5520 {
5521 log_info ("%s v%.2f starting...", PROGNAME, (float) VERSION_BIN / 100);
5522
5523 log_info ("");
5524 }
5525 }
5526
5527 /**
5528 * sanity check
5529 */
5530
5531 if (attack_mode > 7)
5532 {
5533 log_error ("ERROR: Invalid attack-mode specified");
5534
5535 return (-1);
5536 }
5537
5538 if (runtime_chgd && runtime == 0) // just added to remove compiler warnings for runtime_chgd
5539 {
5540 log_error ("ERROR: Invalid runtime specified");
5541
5542 return (-1);
5543 }
5544
5545 if (hash_mode_chgd && hash_mode > 12800) // just added to remove compiler warnings for hash_mode_chgd
5546 {
5547 log_error ("ERROR: Invalid hash-type specified");
5548
5549 return (-1);
5550 }
5551
5552 // renamed hash modes
5553
5554 if (hash_mode_chgd)
5555 {
5556 int n = -1;
5557
5558 switch (hash_mode)
5559 {
5560 case 123: n = 124;
5561 break;
5562 }
5563
5564 if (n >= 0)
5565 {
5566 log_error ("Old -m specified, use -m %d instead", n);
5567
5568 return (-1);
5569 }
5570 }
5571
5572 if (username == 1)
5573 {
5574 if ((hash_mode == 2500) || (hash_mode == 5200) || ((hash_mode >= 6200) && (hash_mode <= 6299)))
5575 {
5576 log_error ("ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (hash_mode));
5577
5578 return (-1);
5579 }
5580 }
5581
5582 if (outfile_format > 16)
5583 {
5584 log_error ("ERROR: Invalid outfile-format specified");
5585
5586 return (-1);
5587 }
5588
5589 if (left == 1)
5590 {
5591 if (outfile_format_chgd == 1)
5592 {
5593 if (outfile_format > 1)
5594 {
5595 log_error ("ERROR: Mixing outfile-format > 1 is not allowed together with left parameter");
5596
5597 return (-1);
5598 }
5599 }
5600 else
5601 {
5602 outfile_format = OUTFILE_FMT_HASH;
5603 }
5604 }
5605
5606 if (show == 1)
5607 {
5608 if (outfile_format_chgd == 1)
5609 {
5610 if ((outfile_format > 7) && (outfile_format < 16))
5611 {
5612 log_error ("ERROR: Mixing outfile-format > 7 is not allowed together with show parameter");
5613
5614 return (-1);
5615 }
5616 }
5617 }
5618
5619 if (increment_min < INCREMENT_MIN)
5620 {
5621 log_error ("ERROR: Invalid increment-min specified");
5622
5623 return (-1);
5624 }
5625
5626 if (increment_max > INCREMENT_MAX)
5627 {
5628 log_error ("ERROR: Invalid increment-max specified");
5629
5630 return (-1);
5631 }
5632
5633 if (increment_min > increment_max)
5634 {
5635 log_error ("ERROR: Invalid increment-min specified");
5636
5637 return (-1);
5638 }
5639
5640 if ((increment == 1) && (attack_mode == ATTACK_MODE_STRAIGHT))
5641 {
5642 log_error ("ERROR: increment is not allowed in attack-mode 0");
5643
5644 return (-1);
5645 }
5646
5647 if ((increment == 0) && (increment_min_chgd == 1))
5648 {
5649 log_error ("ERROR: increment-min is only supported together with increment switch");
5650
5651 return (-1);
5652 }
5653
5654 if ((increment == 0) && (increment_max_chgd == 1))
5655 {
5656 log_error ("ERROR: increment-max is only supported together with increment switch");
5657
5658 return (-1);
5659 }
5660
5661 if (rp_files_cnt && rp_gen)
5662 {
5663 log_error ("ERROR: Use of both rules-file and rules-generate is not supported");
5664
5665 return (-1);
5666 }
5667
5668 if (rp_files_cnt || rp_gen)
5669 {
5670 if (attack_mode != ATTACK_MODE_STRAIGHT)
5671 {
5672 log_error ("ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0");
5673
5674 return (-1);
5675 }
5676 }
5677
5678 if (rp_gen_func_min > rp_gen_func_max)
5679 {
5680 log_error ("ERROR: Invalid rp-gen-func-min specified");
5681
5682 return (-1);
5683 }
5684
5685 if (gpu_accel_chgd == 1)
5686 {
5687 if (workload_profile != WORKLOAD_PROFILE)
5688 {
5689 log_error ("ERROR: gpu-accel parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
5690
5691 return (-1);
5692 }
5693
5694 if (gpu_accel < 1)
5695 {
5696 log_error ("ERROR: Invalid gpu-accel specified");
5697
5698 return (-1);
5699 }
5700
5701 if (gpu_accel > 800)
5702 {
5703 log_error ("ERROR: Invalid gpu-accel specified");
5704
5705 return (-1);
5706 }
5707 }
5708
5709 if (gpu_loops_chgd == 1)
5710 {
5711 if (workload_profile != WORKLOAD_PROFILE)
5712 {
5713 log_error ("ERROR: gpu-loops parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
5714
5715 return (-1);
5716 }
5717
5718 if (gpu_loops < 1)
5719 {
5720 log_error ("ERROR: Invalid gpu-loops specified");
5721
5722 return (-1);
5723 }
5724
5725 if (gpu_loops > 1024)
5726 {
5727 log_error ("ERROR: Invalid gpu-loops specified");
5728
5729 return (-1);
5730 }
5731 }
5732
5733 if (benchmark == 1)
5734 {
5735 if (workload_profile != WORKLOAD_PROFILE)
5736 {
5737 log_error ("ERROR: Using the workload-profile in benchmark mode is not allowed");
5738
5739 return (-1);
5740 }
5741 }
5742
5743 if ((workload_profile < 1) || (workload_profile > 3))
5744 {
5745 log_error ("ERROR: workload-profile %i not available", workload_profile);
5746
5747 return (-1);
5748 }
5749
5750 if (show == 1 || left == 1)
5751 {
5752 attack_mode = ATTACK_MODE_NONE;
5753
5754 if (remove == 1)
5755 {
5756 log_error ("ERROR: Mixing remove parameter not allowed with show parameter or left parameter");
5757
5758 return (-1);
5759 }
5760
5761 if (potfile_disable == 1)
5762 {
5763 log_error ("ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter");
5764
5765 return (-1);
5766 }
5767 }
5768
5769 uint attack_kern = ATTACK_KERN_NONE;
5770
5771 switch (attack_mode)
5772 {
5773 case ATTACK_MODE_STRAIGHT: attack_kern = ATTACK_KERN_STRAIGHT; break;
5774 case ATTACK_MODE_COMBI: attack_kern = ATTACK_KERN_COMBI; break;
5775 case ATTACK_MODE_BF: attack_kern = ATTACK_KERN_BF; break;
5776 case ATTACK_MODE_HYBRID1: attack_kern = ATTACK_KERN_COMBI; break;
5777 case ATTACK_MODE_HYBRID2: attack_kern = ATTACK_KERN_COMBI; break;
5778 }
5779
5780 if (benchmark == 0)
5781 {
5782 if (keyspace == 1)
5783 {
5784 int num_additional_params = 1;
5785
5786 if (attack_kern == ATTACK_KERN_COMBI)
5787 {
5788 num_additional_params = 2;
5789 }
5790
5791 int keyspace_wordlist_specified = myargc - optind - num_additional_params;
5792
5793 if (keyspace_wordlist_specified == 0) optind--;
5794 }
5795
5796 if (attack_kern == ATTACK_KERN_NONE)
5797 {
5798 if ((optind + 1) != myargc)
5799 {
5800 usage_mini_print (myargv[0]);
5801
5802 return (-1);
5803 }
5804 }
5805 else if (attack_kern == ATTACK_KERN_STRAIGHT)
5806 {
5807 if ((optind + 1) > myargc)
5808 {
5809 usage_mini_print (myargv[0]);
5810
5811 return (-1);
5812 }
5813 }
5814 else if (attack_kern == ATTACK_KERN_COMBI)
5815 {
5816 if ((optind + 3) != myargc)
5817 {
5818 usage_mini_print (myargv[0]);
5819
5820 return (-1);
5821 }
5822 }
5823 else if (attack_kern == ATTACK_KERN_BF)
5824 {
5825 if ((optind + 1) > myargc)
5826 {
5827 usage_mini_print (myargv[0]);
5828
5829 return (-1);
5830 }
5831 }
5832 else
5833 {
5834 usage_mini_print (myargv[0]);
5835
5836 return (-1);
5837 }
5838 }
5839 else
5840 {
5841 if (myargv[optind] != 0)
5842 {
5843 log_error ("ERROR: Invalid argument for benchmark mode specified");
5844
5845 return (-1);
5846 }
5847
5848 if (attack_mode_chgd == 1)
5849 {
5850 if (attack_mode != ATTACK_MODE_BF)
5851 {
5852 log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode");
5853
5854 return (-1);
5855 }
5856 }
5857
5858 if (benchmark_mode == 0)
5859 {
5860 // nothing to do
5861 }
5862 else if (benchmark_mode == 1)
5863 {
5864 if (gpu_accel_chgd == 1 || gpu_loops_chgd == 1)
5865 {
5866 log_error ("ERROR: Benchmark-mode 1 does not allow gpu-accel or gpu-loops changed");
5867
5868 return (-1);
5869 }
5870 }
5871 else
5872 {
5873 log_error ("ERROR: Benchmark-mode must be 0 or 1");
5874
5875 return (-1);
5876 }
5877 }
5878
5879 if (skip != 0 && limit != 0)
5880 {
5881 limit += skip;
5882 }
5883
5884 if (keyspace == 1)
5885 {
5886 if (show == 1)
5887 {
5888 log_error ("ERROR: Mixing show parameter not supported with keyspace parameter");
5889
5890 return (-1);
5891 }
5892 else if (left == 1)
5893 {
5894 log_error ("ERROR: Mixing left parameter not supported wiht keyspace parameter");
5895
5896 return (-1);
5897 }
5898
5899 potfile_disable = 1;
5900
5901 restore_disable = 1;
5902
5903 restore = 0;
5904
5905 weak_hash_threshold = 0;
5906
5907 quiet = 1;
5908 }
5909
5910 if (remove_timer_chgd == 1)
5911 {
5912 if (remove == 0)
5913 {
5914 log_error ("ERROR: Parameter remove-timer require parameter remove enabled");
5915
5916 return (-1);
5917 }
5918
5919 if (remove_timer < 1)
5920 {
5921 log_error ("ERROR: Parameter remove-timer must have a value greater than or equal to 1");
5922
5923 return (-1);
5924 }
5925 }
5926
5927 if (loopback == 1)
5928 {
5929 if (attack_mode == ATTACK_MODE_BF)
5930 {
5931 log_error ("ERROR: Parameter loopback not allowed in attack-mode 3");
5932
5933 return (-1);
5934 }
5935 else if (attack_mode == ATTACK_MODE_STRAIGHT)
5936 {
5937 if ((rp_files_cnt == 0) && (rp_gen == 0))
5938 {
5939 log_error ("ERROR: Parameter loopback not allowed without rules-file or rules-generate");
5940
5941 return (-1);
5942 }
5943 }
5944 }
5945
5946 if (debug_mode > 0)
5947 {
5948 if (attack_mode != ATTACK_MODE_STRAIGHT)
5949 {
5950 log_error ("ERROR: Parameter debug-mode option is only available with attack-mode 0");
5951
5952 return (-1);
5953 }
5954
5955 if ((rp_files_cnt == 0) && (rp_gen == 0))
5956 {
5957 log_error ("ERROR: Parameter debug-mode not allowed without rules-file or rules-generate");
5958
5959 return (-1);
5960 }
5961 }
5962
5963 if (debug_mode > 4)
5964 {
5965 log_error ("ERROR: Invalid debug-mode specified");
5966
5967 return (-1);
5968 }
5969
5970 if (debug_file != NULL)
5971 {
5972 if (debug_mode < 1)
5973 {
5974 log_error ("ERROR: Parameter debug-file requires parameter debug-mode to be set");
5975
5976 return (-1);
5977 }
5978 }
5979
5980 if (induction_dir != NULL)
5981 {
5982 if (attack_mode == ATTACK_MODE_BF)
5983 {
5984 log_error ("ERROR: Parameter induction-dir not allowed with brute-force attacks");
5985
5986 return (-1);
5987 }
5988 }
5989
5990 /**
5991 * induction directory
5992 */
5993
5994 char *induction_directory = NULL;
5995
5996 if (attack_mode != ATTACK_MODE_BF)
5997 {
5998 if (induction_dir == NULL)
5999 {
6000 induction_directory = (char *) mymalloc (session_size);
6001
6002 snprintf (induction_directory, session_size - 1, "%s.%s", session, INDUCT_DIR);
6003
6004 // create induction folder if it does not already exist
6005
6006 if (keyspace == 0)
6007 {
6008 if (rmdir (induction_directory) == -1)
6009 {
6010 if (errno == ENOENT)
6011 {
6012 // good, we can ignore
6013 }
6014 else if (errno == ENOTEMPTY)
6015 {
6016 char *induction_directory_mv = (char *) mymalloc (session_size);
6017
6018 snprintf (induction_directory_mv, session_size - 1, "%s.induct.%d", session, (int) proc_start);
6019
6020 if (rename (induction_directory, induction_directory_mv) != 0)
6021 {
6022 log_error ("ERROR: Rename directory %s to %s: %s", induction_directory, induction_directory_mv, strerror (errno));
6023
6024 return (-1);
6025 }
6026 }
6027 else
6028 {
6029 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6030
6031 return (-1);
6032 }
6033 }
6034
6035 #ifdef _WIN
6036 #define mkdir(name,mode) mkdir (name)
6037 #endif
6038
6039 if (mkdir (induction_directory, 0700) == -1)
6040 {
6041 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6042
6043 return (-1);
6044 }
6045 }
6046 }
6047 else
6048 {
6049 induction_directory = induction_dir;
6050 }
6051 }
6052
6053 data.induction_directory = induction_directory;
6054
6055 /**
6056 * loopback
6057 */
6058
6059 size_t loopback_size = session_size + strlen (LOOPBACK_FILE) + 12;
6060
6061 char *loopback_file = (char *) mymalloc (loopback_size);
6062
6063 /**
6064 * outfile-check directory
6065 */
6066
6067 char *outfile_check_directory = NULL;
6068
6069 if (outfile_check_dir == NULL)
6070 {
6071 outfile_check_directory = (char *) mymalloc (session_size);
6072
6073 snprintf (outfile_check_directory, session_size - 1, "%s.%s", session, OUTFILES_DIR);
6074 }
6075 else
6076 {
6077 outfile_check_directory = outfile_check_dir;
6078 }
6079
6080 data.outfile_check_directory = outfile_check_directory;
6081
6082 if (keyspace == 0)
6083 {
6084 struct stat outfile_check_stat;
6085
6086 if (stat (outfile_check_directory, &outfile_check_stat) == 0)
6087 {
6088 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
6089
6090 if (is_dir == 0)
6091 {
6092 log_error ("ERROR: Directory specified in outfile-check '%s' is not a valid directory", outfile_check_directory);
6093
6094 return (-1);
6095 }
6096 }
6097 else if (outfile_check_dir == NULL)
6098 {
6099 #ifdef _WIN
6100 #define mkdir(name,mode) mkdir (name)
6101 #endif
6102
6103 if (mkdir (outfile_check_directory, 0700) == -1)
6104 {
6105 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
6106
6107 return (-1);
6108 }
6109 }
6110 }
6111
6112 /**
6113 * special other stuff
6114 */
6115
6116 if (hash_mode == 9710)
6117 {
6118 outfile_format = 5;
6119 outfile_format_chgd = 1;
6120 }
6121
6122 if (hash_mode == 9810)
6123 {
6124 outfile_format = 5;
6125 outfile_format_chgd = 1;
6126 }
6127
6128 if (hash_mode == 10410)
6129 {
6130 outfile_format = 5;
6131 outfile_format_chgd = 1;
6132 }
6133
6134 /**
6135 * store stuff
6136 */
6137
6138 data.hash_mode = hash_mode;
6139 data.restore = restore;
6140 data.restore_timer = restore_timer;
6141 data.restore_disable = restore_disable;
6142 data.status = status;
6143 data.status_timer = status_timer;
6144 data.status_automat = status_automat;
6145 data.loopback = loopback;
6146 data.runtime = runtime;
6147 data.remove = remove;
6148 data.remove_timer = remove_timer;
6149 data.debug_mode = debug_mode;
6150 data.debug_file = debug_file;
6151 data.username = username;
6152 data.quiet = quiet;
6153 data.outfile = outfile;
6154 data.outfile_format = outfile_format;
6155 data.outfile_autohex = outfile_autohex;
6156 data.hex_charset = hex_charset;
6157 data.hex_salt = hex_salt;
6158 data.hex_wordlist = hex_wordlist;
6159 data.separator = separator;
6160 data.rp_files = rp_files;
6161 data.rp_files_cnt = rp_files_cnt;
6162 data.rp_gen = rp_gen;
6163 data.rp_gen_seed = rp_gen_seed;
6164 data.force = force;
6165 data.benchmark = benchmark;
6166 data.skip = skip;
6167 data.limit = limit;
6168 data.powertune_enable = powertune_enable;
6169 data.logfile_disable = logfile_disable;
6170 data.truecrypt_keyfiles = truecrypt_keyfiles;
6171 data.scrypt_tmto = scrypt_tmto;
6172
6173 /**
6174 * folders, as discussed on https://github.com/hashcat/oclHashcat/issues/20
6175 */
6176
6177 #ifdef LINUX
6178
6179 char *resolved_path = realpath (myargv[0], NULL);
6180
6181 char *install_dir = get_install_dir (resolved_path);
6182 char *profile_dir = NULL;
6183 char *session_dir = NULL;
6184
6185 if (strcmp (install_dir, INSTALL_FOLDER) == 0)
6186 {
6187 struct passwd *pw = getpwuid (getuid ());
6188
6189 const char *homedir = pw->pw_dir;
6190
6191 profile_dir = get_profile_dir (homedir);
6192 session_dir = get_session_dir (profile_dir, session);
6193 }
6194 else
6195 {
6196 profile_dir = install_dir;
6197 session_dir = install_dir;
6198 }
6199
6200 myfree (resolved_path);
6201
6202 #else
6203
6204 char *install_dir = get_install_dir (myargv[0]);
6205 char *profile_dir = install_dir;
6206 char *session_dir = install_dir;
6207
6208 #endif
6209
6210 data.install_dir = install_dir;
6211 data.profile_dir = profile_dir;
6212 data.session_dir = session_dir;
6213
6214 /**
6215 * cpu affinity
6216 */
6217
6218 if (cpu_affinity)
6219 {
6220 set_cpu_affinity (cpu_affinity);
6221 }
6222
6223 if (rp_gen_seed_chgd == 0)
6224 {
6225 srand (proc_start);
6226 }
6227 else
6228 {
6229 srand (rp_gen_seed);
6230 }
6231
6232 /**
6233 * logfile init
6234 */
6235
6236 if (logfile_disable == 0)
6237 {
6238 size_t logfile_size = strlen (session) + 32;
6239
6240 char *logfile = (char *) mymalloc (logfile_size);
6241
6242 snprintf (logfile, logfile_size - 1, "%s.log", session);
6243
6244 data.logfile = logfile;
6245
6246 char *topid = logfile_generate_topid ();
6247
6248 data.topid = topid;
6249 }
6250
6251 // logfile_append() checks for logfile_disable internally to make it easier from here
6252
6253 #define logfile_top_msg(msg) logfile_append ("%s\t%s", data.topid, (msg));
6254 #define logfile_sub_msg(msg) logfile_append ("%s\t%s\t%s", data.topid, data.subid, (msg));
6255 #define logfile_top_var_uint64(var,val) logfile_append ("%s\t%s\t%llu", data.topid, (var), (val));
6256 #define logfile_sub_var_uint64(var,val) logfile_append ("%s\t%s\t%s\t%llu", data.topid, data.subid, (var), (val));
6257 #define logfile_top_var_uint(var,val) logfile_append ("%s\t%s\t%u", data.topid, (var), (val));
6258 #define logfile_sub_var_uint(var,val) logfile_append ("%s\t%s\t%s\t%u", data.topid, data.subid, (var), (val));
6259 #define logfile_top_var_char(var,val) logfile_append ("%s\t%s\t%c", data.topid, (var), (val));
6260 #define logfile_sub_var_char(var,val) logfile_append ("%s\t%s\t%s\t%c", data.topid, data.subid, (var), (val));
6261 #define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append ("%s\t%s\t%s", data.topid, (var), (val));
6262 #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));
6263
6264 #define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var));
6265 #define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
6266 #define logfile_top_uint(var) logfile_top_var_uint (#var, (var));
6267 #define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var));
6268 #define logfile_top_char(var) logfile_top_var_char (#var, (var));
6269 #define logfile_sub_char(var) logfile_sub_var_char (#var, (var));
6270 #define logfile_top_string(var) logfile_top_var_string (#var, (var));
6271 #define logfile_sub_string(var) logfile_sub_var_string (#var, (var));
6272
6273 logfile_top_msg ("START");
6274
6275 logfile_top_uint (attack_mode);
6276 logfile_top_uint (attack_kern);
6277 logfile_top_uint (benchmark);
6278 logfile_top_uint (benchmark_mode);
6279 logfile_top_uint (bitmap_min);
6280 logfile_top_uint (bitmap_max);
6281 logfile_top_uint (debug_mode);
6282 logfile_top_uint (force);
6283 logfile_top_uint (gpu_accel);
6284 logfile_top_uint (gpu_loops);
6285 logfile_top_uint (gpu_temp_abort);
6286 logfile_top_uint (gpu_temp_disable);
6287 logfile_top_uint (gpu_temp_retain);
6288 logfile_top_uint (hash_mode);
6289 logfile_top_uint (hex_charset);
6290 logfile_top_uint (hex_salt);
6291 logfile_top_uint (hex_wordlist);
6292 logfile_top_uint (increment);
6293 logfile_top_uint (increment_max);
6294 logfile_top_uint (increment_min);
6295 logfile_top_uint (keyspace);
6296 logfile_top_uint (left);
6297 logfile_top_uint (logfile_disable);
6298 logfile_top_uint (loopback);
6299 logfile_top_uint (markov_classic);
6300 logfile_top_uint (markov_disable);
6301 logfile_top_uint (markov_threshold);
6302 logfile_top_uint (outfile_autohex);
6303 logfile_top_uint (outfile_check_timer);
6304 logfile_top_uint (outfile_format);
6305 logfile_top_uint (potfile_disable);
6306 logfile_top_uint (powertune_enable);
6307 logfile_top_uint (scrypt_tmto);
6308 logfile_top_uint (quiet);
6309 logfile_top_uint (remove);
6310 logfile_top_uint (remove_timer);
6311 logfile_top_uint (restore);
6312 logfile_top_uint (restore_disable);
6313 logfile_top_uint (restore_timer);
6314 logfile_top_uint (rp_gen);
6315 logfile_top_uint (rp_gen_func_max);
6316 logfile_top_uint (rp_gen_func_min);
6317 logfile_top_uint (rp_gen_seed);
6318 logfile_top_uint (runtime);
6319 logfile_top_uint (segment_size);
6320 logfile_top_uint (show);
6321 logfile_top_uint (status);
6322 logfile_top_uint (status_automat);
6323 logfile_top_uint (status_timer);
6324 logfile_top_uint (usage);
6325 logfile_top_uint (username);
6326 logfile_top_uint (version);
6327 logfile_top_uint (weak_hash_threshold);
6328 logfile_top_uint (workload_profile);
6329 logfile_top_uint64 (limit);
6330 logfile_top_uint64 (skip);
6331 logfile_top_char (separator);
6332 logfile_top_string (cpu_affinity);
6333 logfile_top_string (custom_charset_1);
6334 logfile_top_string (custom_charset_2);
6335 logfile_top_string (custom_charset_3);
6336 logfile_top_string (custom_charset_4);
6337 logfile_top_string (debug_file);
6338 logfile_top_string (gpu_devices);
6339 logfile_top_string (gpu_platform);
6340 logfile_top_string (induction_dir);
6341 logfile_top_string (markov_hcstat);
6342 logfile_top_string (outfile);
6343 logfile_top_string (outfile_check_dir);
6344 logfile_top_string (rule_buf_l);
6345 logfile_top_string (rule_buf_r);
6346 logfile_top_string (session);
6347 logfile_top_string (truecrypt_keyfiles);
6348
6349 /**
6350 * devices
6351 */
6352
6353 uint gpu_devicemask = devices_to_devicemask (gpu_devices);
6354
6355 /**
6356 * benchmark
6357 */
6358
6359 if (benchmark == 1)
6360 {
6361 /**
6362 * disable useless stuff for benchmark
6363 */
6364
6365 restore_timer = 0;
6366 status_timer = 0;
6367 restore_disable = 1;
6368 potfile_disable = 1;
6369 weak_hash_threshold = 0;
6370
6371 data.restore_timer = restore_timer;
6372 data.status_timer = status_timer;
6373 data.restore_disable = restore_disable;
6374
6375 if (benchmark_mode == 1)
6376 {
6377 markov_disable = 1;
6378 }
6379
6380 /**
6381 * force attack mode to be bruteforce
6382 */
6383
6384 attack_mode = ATTACK_MODE_BF;
6385 attack_kern = ATTACK_KERN_BF;
6386
6387 if (runtime_chgd == 0)
6388 {
6389 runtime = 4;
6390
6391 if (benchmark_mode == 1) runtime = 17;
6392
6393 data.runtime = runtime;
6394 }
6395 }
6396
6397 /**
6398 * config
6399 */
6400
6401 uint hash_type = 0;
6402 uint salt_type = 0;
6403 uint attack_exec = 0;
6404 uint opts_type = 0;
6405 uint kern_type = 0;
6406 uint dgst_size = 0;
6407 uint esalt_size = 0;
6408 uint opti_type = 0;
6409 uint dgst_pos0 = -1;
6410 uint dgst_pos1 = -1;
6411 uint dgst_pos2 = -1;
6412 uint dgst_pos3 = -1;
6413
6414 int (*parse_func) (char *, uint, hash_t *);
6415 int (*sort_by_digest) (const void *, const void *);
6416
6417 uint algorithm_pos = 0;
6418 uint algorithm_max = 1;
6419
6420 uint *algorithms = default_benchmark_algorithms;
6421
6422 if (benchmark == 1 && hash_mode_chgd == 0) algorithm_max = NUM_DEFAULT_BENCHMARK_ALGORITHMS;
6423
6424 for (algorithm_pos = 0; algorithm_pos < algorithm_max; algorithm_pos++)
6425 {
6426 /*
6427 * We need to reset 'rd' in benchmark mode otherwise when the user hits 'bypass'
6428 * the following algos are skipped entirely
6429 */
6430
6431 if (algorithm_pos > 0)
6432 {
6433 local_free (rd);
6434
6435 rd = init_restore (argc, argv);
6436
6437 data.rd = rd;
6438 }
6439
6440 /**
6441 * update hash_mode in case of multihash benchmark
6442 */
6443
6444 if (benchmark == 1)
6445 {
6446 if (hash_mode_chgd == 0)
6447 {
6448 hash_mode = algorithms[algorithm_pos];
6449
6450 data.hash_mode = hash_mode;
6451 }
6452
6453 quiet = 1;
6454
6455 data.quiet = quiet;
6456 }
6457
6458 switch (hash_mode)
6459 {
6460 case 0: hash_type = HASH_TYPE_MD5;
6461 salt_type = SALT_TYPE_NONE;
6462 attack_exec = ATTACK_EXEC_ON_GPU;
6463 opts_type = OPTS_TYPE_PT_GENERATE_LE
6464 | OPTS_TYPE_PT_ADD80
6465 | OPTS_TYPE_PT_ADDBITS14;
6466 kern_type = KERN_TYPE_MD5;
6467 dgst_size = DGST_SIZE_4_4;
6468 parse_func = md5_parse_hash;
6469 sort_by_digest = sort_by_digest_4_4;
6470 opti_type = OPTI_TYPE_ZERO_BYTE
6471 | OPTI_TYPE_PRECOMPUTE_INIT
6472 | OPTI_TYPE_PRECOMPUTE_MERKLE
6473 | OPTI_TYPE_MEET_IN_MIDDLE
6474 | OPTI_TYPE_EARLY_SKIP
6475 | OPTI_TYPE_NOT_ITERATED
6476 | OPTI_TYPE_NOT_SALTED
6477 | OPTI_TYPE_RAW_HASH;
6478 dgst_pos0 = 0;
6479 dgst_pos1 = 3;
6480 dgst_pos2 = 2;
6481 dgst_pos3 = 1;
6482 break;
6483
6484 case 10: hash_type = HASH_TYPE_MD5;
6485 salt_type = SALT_TYPE_INTERN;
6486 attack_exec = ATTACK_EXEC_ON_GPU;
6487 opts_type = OPTS_TYPE_PT_GENERATE_LE
6488 | OPTS_TYPE_ST_ADD80
6489 | OPTS_TYPE_ST_ADDBITS14;
6490 kern_type = KERN_TYPE_MD5_PWSLT;
6491 dgst_size = DGST_SIZE_4_4;
6492 parse_func = md5s_parse_hash;
6493 sort_by_digest = sort_by_digest_4_4;
6494 opti_type = OPTI_TYPE_ZERO_BYTE
6495 | OPTI_TYPE_PRECOMPUTE_INIT
6496 | OPTI_TYPE_PRECOMPUTE_MERKLE
6497 | OPTI_TYPE_MEET_IN_MIDDLE
6498 | OPTI_TYPE_EARLY_SKIP
6499 | OPTI_TYPE_NOT_ITERATED
6500 | OPTI_TYPE_APPENDED_SALT
6501 | OPTI_TYPE_RAW_HASH;
6502 dgst_pos0 = 0;
6503 dgst_pos1 = 3;
6504 dgst_pos2 = 2;
6505 dgst_pos3 = 1;
6506 break;
6507
6508 case 11: hash_type = HASH_TYPE_MD5;
6509 salt_type = SALT_TYPE_INTERN;
6510 attack_exec = ATTACK_EXEC_ON_GPU;
6511 opts_type = OPTS_TYPE_PT_GENERATE_LE
6512 | OPTS_TYPE_ST_ADD80
6513 | OPTS_TYPE_ST_ADDBITS14;
6514 kern_type = KERN_TYPE_MD5_PWSLT;
6515 dgst_size = DGST_SIZE_4_4;
6516 parse_func = joomla_parse_hash;
6517 sort_by_digest = sort_by_digest_4_4;
6518 opti_type = OPTI_TYPE_ZERO_BYTE
6519 | OPTI_TYPE_PRECOMPUTE_INIT
6520 | OPTI_TYPE_PRECOMPUTE_MERKLE
6521 | OPTI_TYPE_MEET_IN_MIDDLE
6522 | OPTI_TYPE_EARLY_SKIP
6523 | OPTI_TYPE_NOT_ITERATED
6524 | OPTI_TYPE_APPENDED_SALT
6525 | OPTI_TYPE_RAW_HASH;
6526 dgst_pos0 = 0;
6527 dgst_pos1 = 3;
6528 dgst_pos2 = 2;
6529 dgst_pos3 = 1;
6530 break;
6531
6532 case 12: hash_type = HASH_TYPE_MD5;
6533 salt_type = SALT_TYPE_INTERN;
6534 attack_exec = ATTACK_EXEC_ON_GPU;
6535 opts_type = OPTS_TYPE_PT_GENERATE_LE
6536 | OPTS_TYPE_ST_ADD80
6537 | OPTS_TYPE_ST_ADDBITS14;
6538 kern_type = KERN_TYPE_MD5_PWSLT;
6539 dgst_size = DGST_SIZE_4_4;
6540 parse_func = postgresql_parse_hash;
6541 sort_by_digest = sort_by_digest_4_4;
6542 opti_type = OPTI_TYPE_ZERO_BYTE
6543 | OPTI_TYPE_PRECOMPUTE_INIT
6544 | OPTI_TYPE_PRECOMPUTE_MERKLE
6545 | OPTI_TYPE_MEET_IN_MIDDLE
6546 | OPTI_TYPE_EARLY_SKIP
6547 | OPTI_TYPE_NOT_ITERATED
6548 | OPTI_TYPE_APPENDED_SALT
6549 | OPTI_TYPE_RAW_HASH;
6550 dgst_pos0 = 0;
6551 dgst_pos1 = 3;
6552 dgst_pos2 = 2;
6553 dgst_pos3 = 1;
6554 break;
6555
6556 case 20: hash_type = HASH_TYPE_MD5;
6557 salt_type = SALT_TYPE_INTERN;
6558 attack_exec = ATTACK_EXEC_ON_GPU;
6559 opts_type = OPTS_TYPE_PT_GENERATE_LE
6560 | OPTS_TYPE_PT_ADD80
6561 | OPTS_TYPE_PT_ADDBITS14;
6562 kern_type = KERN_TYPE_MD5_SLTPW;
6563 dgst_size = DGST_SIZE_4_4;
6564 parse_func = md5s_parse_hash;
6565 sort_by_digest = sort_by_digest_4_4;
6566 opti_type = OPTI_TYPE_ZERO_BYTE
6567 | OPTI_TYPE_PRECOMPUTE_INIT
6568 | OPTI_TYPE_PRECOMPUTE_MERKLE
6569 | OPTI_TYPE_EARLY_SKIP
6570 | OPTI_TYPE_NOT_ITERATED
6571 | OPTI_TYPE_PREPENDED_SALT
6572 | OPTI_TYPE_RAW_HASH;
6573 dgst_pos0 = 0;
6574 dgst_pos1 = 3;
6575 dgst_pos2 = 2;
6576 dgst_pos3 = 1;
6577 break;
6578
6579 case 21: hash_type = HASH_TYPE_MD5;
6580 salt_type = SALT_TYPE_INTERN;
6581 attack_exec = ATTACK_EXEC_ON_GPU;
6582 opts_type = OPTS_TYPE_PT_GENERATE_LE
6583 | OPTS_TYPE_PT_ADD80
6584 | OPTS_TYPE_PT_ADDBITS14;
6585 kern_type = KERN_TYPE_MD5_SLTPW;
6586 dgst_size = DGST_SIZE_4_4;
6587 parse_func = osc_parse_hash;
6588 sort_by_digest = sort_by_digest_4_4;
6589 opti_type = OPTI_TYPE_ZERO_BYTE
6590 | OPTI_TYPE_PRECOMPUTE_INIT
6591 | OPTI_TYPE_PRECOMPUTE_MERKLE
6592 | OPTI_TYPE_EARLY_SKIP
6593 | OPTI_TYPE_NOT_ITERATED
6594 | OPTI_TYPE_PREPENDED_SALT
6595 | OPTI_TYPE_RAW_HASH;
6596 dgst_pos0 = 0;
6597 dgst_pos1 = 3;
6598 dgst_pos2 = 2;
6599 dgst_pos3 = 1;
6600 break;
6601
6602 case 22: hash_type = HASH_TYPE_MD5;
6603 salt_type = SALT_TYPE_EMBEDDED;
6604 attack_exec = ATTACK_EXEC_ON_GPU;
6605 opts_type = OPTS_TYPE_PT_GENERATE_LE
6606 | OPTS_TYPE_PT_ADD80
6607 | OPTS_TYPE_PT_ADDBITS14;
6608 kern_type = KERN_TYPE_MD5_SLTPW;
6609 dgst_size = DGST_SIZE_4_4;
6610 parse_func = netscreen_parse_hash;
6611 sort_by_digest = sort_by_digest_4_4;
6612 opti_type = OPTI_TYPE_ZERO_BYTE
6613 | OPTI_TYPE_PRECOMPUTE_INIT
6614 | OPTI_TYPE_PRECOMPUTE_MERKLE
6615 | OPTI_TYPE_EARLY_SKIP
6616 | OPTI_TYPE_NOT_ITERATED
6617 | OPTI_TYPE_PREPENDED_SALT
6618 | OPTI_TYPE_RAW_HASH;
6619 dgst_pos0 = 0;
6620 dgst_pos1 = 3;
6621 dgst_pos2 = 2;
6622 dgst_pos3 = 1;
6623 break;
6624
6625 case 23: hash_type = HASH_TYPE_MD5;
6626 salt_type = SALT_TYPE_EMBEDDED;
6627 attack_exec = ATTACK_EXEC_ON_GPU;
6628 opts_type = OPTS_TYPE_PT_GENERATE_LE
6629 | OPTS_TYPE_PT_ADD80
6630 | OPTS_TYPE_PT_ADDBITS14;
6631 kern_type = KERN_TYPE_MD5_SLTPW;
6632 dgst_size = DGST_SIZE_4_4;
6633 parse_func = skype_parse_hash;
6634 sort_by_digest = sort_by_digest_4_4;
6635 opti_type = OPTI_TYPE_ZERO_BYTE
6636 | OPTI_TYPE_PRECOMPUTE_INIT
6637 | OPTI_TYPE_PRECOMPUTE_MERKLE
6638 | OPTI_TYPE_EARLY_SKIP
6639 | OPTI_TYPE_NOT_ITERATED
6640 | OPTI_TYPE_PREPENDED_SALT
6641 | OPTI_TYPE_RAW_HASH;
6642 dgst_pos0 = 0;
6643 dgst_pos1 = 3;
6644 dgst_pos2 = 2;
6645 dgst_pos3 = 1;
6646 break;
6647
6648 case 30: hash_type = HASH_TYPE_MD5;
6649 salt_type = SALT_TYPE_INTERN;
6650 attack_exec = ATTACK_EXEC_ON_GPU;
6651 opts_type = OPTS_TYPE_PT_GENERATE_LE
6652 | OPTS_TYPE_PT_UNICODE
6653 | OPTS_TYPE_ST_ADD80
6654 | OPTS_TYPE_ST_ADDBITS14;
6655 kern_type = KERN_TYPE_MD5_PWUSLT;
6656 dgst_size = DGST_SIZE_4_4;
6657 parse_func = md5s_parse_hash;
6658 sort_by_digest = sort_by_digest_4_4;
6659 opti_type = OPTI_TYPE_ZERO_BYTE
6660 | OPTI_TYPE_PRECOMPUTE_INIT
6661 | OPTI_TYPE_PRECOMPUTE_MERKLE
6662 | OPTI_TYPE_MEET_IN_MIDDLE
6663 | OPTI_TYPE_EARLY_SKIP
6664 | OPTI_TYPE_NOT_ITERATED
6665 | OPTI_TYPE_APPENDED_SALT
6666 | OPTI_TYPE_RAW_HASH;
6667 dgst_pos0 = 0;
6668 dgst_pos1 = 3;
6669 dgst_pos2 = 2;
6670 dgst_pos3 = 1;
6671 break;
6672
6673 case 40: hash_type = HASH_TYPE_MD5;
6674 salt_type = SALT_TYPE_INTERN;
6675 attack_exec = ATTACK_EXEC_ON_GPU;
6676 opts_type = OPTS_TYPE_PT_GENERATE_LE
6677 | OPTS_TYPE_PT_ADD80
6678 | OPTS_TYPE_PT_ADDBITS14
6679 | OPTS_TYPE_PT_UNICODE;
6680 kern_type = KERN_TYPE_MD5_SLTPWU;
6681 dgst_size = DGST_SIZE_4_4;
6682 parse_func = md5s_parse_hash;
6683 sort_by_digest = sort_by_digest_4_4;
6684 opti_type = OPTI_TYPE_ZERO_BYTE
6685 | OPTI_TYPE_PRECOMPUTE_INIT
6686 | OPTI_TYPE_PRECOMPUTE_MERKLE
6687 | OPTI_TYPE_EARLY_SKIP
6688 | OPTI_TYPE_NOT_ITERATED
6689 | OPTI_TYPE_PREPENDED_SALT
6690 | OPTI_TYPE_RAW_HASH;
6691 dgst_pos0 = 0;
6692 dgst_pos1 = 3;
6693 dgst_pos2 = 2;
6694 dgst_pos3 = 1;
6695 break;
6696
6697 case 50: hash_type = HASH_TYPE_MD5;
6698 salt_type = SALT_TYPE_INTERN;
6699 attack_exec = ATTACK_EXEC_ON_GPU;
6700 opts_type = OPTS_TYPE_PT_GENERATE_LE
6701 | OPTS_TYPE_ST_ADD80
6702 | OPTS_TYPE_ST_ADDBITS14;
6703 kern_type = KERN_TYPE_HMACMD5_PW;
6704 dgst_size = DGST_SIZE_4_4;
6705 parse_func = hmacmd5_parse_hash;
6706 sort_by_digest = sort_by_digest_4_4;
6707 opti_type = OPTI_TYPE_ZERO_BYTE
6708 | OPTI_TYPE_NOT_ITERATED;
6709 dgst_pos0 = 0;
6710 dgst_pos1 = 3;
6711 dgst_pos2 = 2;
6712 dgst_pos3 = 1;
6713 break;
6714
6715 case 60: hash_type = HASH_TYPE_MD5;
6716 salt_type = SALT_TYPE_INTERN;
6717 attack_exec = ATTACK_EXEC_ON_GPU;
6718 opts_type = OPTS_TYPE_PT_GENERATE_LE
6719 | OPTS_TYPE_PT_ADD80
6720 | OPTS_TYPE_PT_ADDBITS14;
6721 kern_type = KERN_TYPE_HMACMD5_SLT;
6722 dgst_size = DGST_SIZE_4_4;
6723 parse_func = hmacmd5_parse_hash;
6724 sort_by_digest = sort_by_digest_4_4;
6725 opti_type = OPTI_TYPE_ZERO_BYTE
6726 | OPTI_TYPE_NOT_ITERATED;
6727 dgst_pos0 = 0;
6728 dgst_pos1 = 3;
6729 dgst_pos2 = 2;
6730 dgst_pos3 = 1;
6731 break;
6732
6733 case 100: hash_type = HASH_TYPE_SHA1;
6734 salt_type = SALT_TYPE_NONE;
6735 attack_exec = ATTACK_EXEC_ON_GPU;
6736 opts_type = OPTS_TYPE_PT_GENERATE_BE
6737 | OPTS_TYPE_PT_ADD80
6738 | OPTS_TYPE_PT_ADDBITS15;
6739 kern_type = KERN_TYPE_SHA1;
6740 dgst_size = DGST_SIZE_4_5;
6741 parse_func = sha1_parse_hash;
6742 sort_by_digest = sort_by_digest_4_5;
6743 opti_type = OPTI_TYPE_ZERO_BYTE
6744 | OPTI_TYPE_PRECOMPUTE_INIT
6745 | OPTI_TYPE_PRECOMPUTE_MERKLE
6746 | OPTI_TYPE_EARLY_SKIP
6747 | OPTI_TYPE_NOT_ITERATED
6748 | OPTI_TYPE_NOT_SALTED
6749 | OPTI_TYPE_RAW_HASH;
6750 dgst_pos0 = 3;
6751 dgst_pos1 = 4;
6752 dgst_pos2 = 2;
6753 dgst_pos3 = 1;
6754 break;
6755
6756 case 101: hash_type = HASH_TYPE_SHA1;
6757 salt_type = SALT_TYPE_NONE;
6758 attack_exec = ATTACK_EXEC_ON_GPU;
6759 opts_type = OPTS_TYPE_PT_GENERATE_BE
6760 | OPTS_TYPE_PT_ADD80
6761 | OPTS_TYPE_PT_ADDBITS15;
6762 kern_type = KERN_TYPE_SHA1;
6763 dgst_size = DGST_SIZE_4_5;
6764 parse_func = sha1b64_parse_hash;
6765 sort_by_digest = sort_by_digest_4_5;
6766 opti_type = OPTI_TYPE_ZERO_BYTE
6767 | OPTI_TYPE_PRECOMPUTE_INIT
6768 | OPTI_TYPE_PRECOMPUTE_MERKLE
6769 | OPTI_TYPE_EARLY_SKIP
6770 | OPTI_TYPE_NOT_ITERATED
6771 | OPTI_TYPE_NOT_SALTED
6772 | OPTI_TYPE_RAW_HASH;
6773 dgst_pos0 = 3;
6774 dgst_pos1 = 4;
6775 dgst_pos2 = 2;
6776 dgst_pos3 = 1;
6777 break;
6778
6779 case 110: hash_type = HASH_TYPE_SHA1;
6780 salt_type = SALT_TYPE_INTERN;
6781 attack_exec = ATTACK_EXEC_ON_GPU;
6782 opts_type = OPTS_TYPE_PT_GENERATE_BE
6783 | OPTS_TYPE_ST_ADD80
6784 | OPTS_TYPE_ST_ADDBITS15;
6785 kern_type = KERN_TYPE_SHA1_PWSLT;
6786 dgst_size = DGST_SIZE_4_5;
6787 parse_func = sha1s_parse_hash;
6788 sort_by_digest = sort_by_digest_4_5;
6789 opti_type = OPTI_TYPE_ZERO_BYTE
6790 | OPTI_TYPE_PRECOMPUTE_INIT
6791 | OPTI_TYPE_PRECOMPUTE_MERKLE
6792 | OPTI_TYPE_EARLY_SKIP
6793 | OPTI_TYPE_NOT_ITERATED
6794 | OPTI_TYPE_APPENDED_SALT
6795 | OPTI_TYPE_RAW_HASH;
6796 dgst_pos0 = 3;
6797 dgst_pos1 = 4;
6798 dgst_pos2 = 2;
6799 dgst_pos3 = 1;
6800 break;
6801
6802 case 111: hash_type = HASH_TYPE_SHA1;
6803 salt_type = SALT_TYPE_EMBEDDED;
6804 attack_exec = ATTACK_EXEC_ON_GPU;
6805 opts_type = OPTS_TYPE_PT_GENERATE_BE
6806 | OPTS_TYPE_ST_ADD80
6807 | OPTS_TYPE_ST_ADDBITS15;
6808 kern_type = KERN_TYPE_SHA1_PWSLT;
6809 dgst_size = DGST_SIZE_4_5;
6810 parse_func = sha1b64s_parse_hash;
6811 sort_by_digest = sort_by_digest_4_5;
6812 opti_type = OPTI_TYPE_ZERO_BYTE
6813 | OPTI_TYPE_PRECOMPUTE_INIT
6814 | OPTI_TYPE_PRECOMPUTE_MERKLE
6815 | OPTI_TYPE_EARLY_SKIP
6816 | OPTI_TYPE_NOT_ITERATED
6817 | OPTI_TYPE_APPENDED_SALT
6818 | OPTI_TYPE_RAW_HASH;
6819 dgst_pos0 = 3;
6820 dgst_pos1 = 4;
6821 dgst_pos2 = 2;
6822 dgst_pos3 = 1;
6823 break;
6824
6825 case 112: hash_type = HASH_TYPE_SHA1;
6826 salt_type = SALT_TYPE_INTERN;
6827 attack_exec = ATTACK_EXEC_ON_GPU;
6828 opts_type = OPTS_TYPE_PT_GENERATE_BE
6829 | OPTS_TYPE_ST_ADD80
6830 | OPTS_TYPE_ST_ADDBITS15
6831 | OPTS_TYPE_ST_HEX;
6832 kern_type = KERN_TYPE_SHA1_PWSLT;
6833 dgst_size = DGST_SIZE_4_5;
6834 parse_func = oracles_parse_hash;
6835 sort_by_digest = sort_by_digest_4_5;
6836 opti_type = OPTI_TYPE_ZERO_BYTE
6837 | OPTI_TYPE_PRECOMPUTE_INIT
6838 | OPTI_TYPE_PRECOMPUTE_MERKLE
6839 | OPTI_TYPE_EARLY_SKIP
6840 | OPTI_TYPE_NOT_ITERATED
6841 | OPTI_TYPE_APPENDED_SALT
6842 | OPTI_TYPE_RAW_HASH;
6843 dgst_pos0 = 3;
6844 dgst_pos1 = 4;
6845 dgst_pos2 = 2;
6846 dgst_pos3 = 1;
6847 break;
6848
6849 case 120: hash_type = HASH_TYPE_SHA1;
6850 salt_type = SALT_TYPE_INTERN;
6851 attack_exec = ATTACK_EXEC_ON_GPU;
6852 opts_type = OPTS_TYPE_PT_GENERATE_BE
6853 | OPTS_TYPE_PT_ADD80
6854 | OPTS_TYPE_PT_ADDBITS15;
6855 kern_type = KERN_TYPE_SHA1_SLTPW;
6856 dgst_size = DGST_SIZE_4_5;
6857 parse_func = sha1s_parse_hash;
6858 sort_by_digest = sort_by_digest_4_5;
6859 opti_type = OPTI_TYPE_ZERO_BYTE
6860 | OPTI_TYPE_PRECOMPUTE_INIT
6861 | OPTI_TYPE_PRECOMPUTE_MERKLE
6862 | OPTI_TYPE_EARLY_SKIP
6863 | OPTI_TYPE_NOT_ITERATED
6864 | OPTI_TYPE_PREPENDED_SALT
6865 | OPTI_TYPE_RAW_HASH;
6866 dgst_pos0 = 3;
6867 dgst_pos1 = 4;
6868 dgst_pos2 = 2;
6869 dgst_pos3 = 1;
6870 break;
6871
6872 case 121: hash_type = HASH_TYPE_SHA1;
6873 salt_type = SALT_TYPE_INTERN;
6874 attack_exec = ATTACK_EXEC_ON_GPU;
6875 opts_type = OPTS_TYPE_PT_GENERATE_BE
6876 | OPTS_TYPE_PT_ADD80
6877 | OPTS_TYPE_PT_ADDBITS15
6878 | OPTS_TYPE_ST_LOWER;
6879 kern_type = KERN_TYPE_SHA1_SLTPW;
6880 dgst_size = DGST_SIZE_4_5;
6881 parse_func = smf_parse_hash;
6882 sort_by_digest = sort_by_digest_4_5;
6883 opti_type = OPTI_TYPE_ZERO_BYTE
6884 | OPTI_TYPE_PRECOMPUTE_INIT
6885 | OPTI_TYPE_PRECOMPUTE_MERKLE
6886 | OPTI_TYPE_EARLY_SKIP
6887 | OPTI_TYPE_NOT_ITERATED
6888 | OPTI_TYPE_PREPENDED_SALT
6889 | OPTI_TYPE_RAW_HASH;
6890 dgst_pos0 = 3;
6891 dgst_pos1 = 4;
6892 dgst_pos2 = 2;
6893 dgst_pos3 = 1;
6894 break;
6895
6896 case 122: hash_type = HASH_TYPE_SHA1;
6897 salt_type = SALT_TYPE_EMBEDDED;
6898 attack_exec = ATTACK_EXEC_ON_GPU;
6899 opts_type = OPTS_TYPE_PT_GENERATE_BE
6900 | OPTS_TYPE_PT_ADD80
6901 | OPTS_TYPE_PT_ADDBITS15
6902 | OPTS_TYPE_ST_HEX;
6903 kern_type = KERN_TYPE_SHA1_SLTPW;
6904 dgst_size = DGST_SIZE_4_5;
6905 parse_func = osx1_parse_hash;
6906 sort_by_digest = sort_by_digest_4_5;
6907 opti_type = OPTI_TYPE_ZERO_BYTE
6908 | OPTI_TYPE_PRECOMPUTE_INIT
6909 | OPTI_TYPE_PRECOMPUTE_MERKLE
6910 | OPTI_TYPE_EARLY_SKIP
6911 | OPTI_TYPE_NOT_ITERATED
6912 | OPTI_TYPE_PREPENDED_SALT
6913 | OPTI_TYPE_RAW_HASH;
6914 dgst_pos0 = 3;
6915 dgst_pos1 = 4;
6916 dgst_pos2 = 2;
6917 dgst_pos3 = 1;
6918 break;
6919
6920 case 124: hash_type = HASH_TYPE_SHA1;
6921 salt_type = SALT_TYPE_EMBEDDED;
6922 attack_exec = ATTACK_EXEC_ON_GPU;
6923 opts_type = OPTS_TYPE_PT_GENERATE_BE
6924 | OPTS_TYPE_PT_ADD80
6925 | OPTS_TYPE_PT_ADDBITS15;
6926 kern_type = KERN_TYPE_SHA1_SLTPW;
6927 dgst_size = DGST_SIZE_4_5;
6928 parse_func = djangosha1_parse_hash;
6929 sort_by_digest = sort_by_digest_4_5;
6930 opti_type = OPTI_TYPE_ZERO_BYTE
6931 | OPTI_TYPE_PRECOMPUTE_INIT
6932 | OPTI_TYPE_PRECOMPUTE_MERKLE
6933 | OPTI_TYPE_EARLY_SKIP
6934 | OPTI_TYPE_NOT_ITERATED
6935 | OPTI_TYPE_PREPENDED_SALT
6936 | OPTI_TYPE_RAW_HASH;
6937 dgst_pos0 = 3;
6938 dgst_pos1 = 4;
6939 dgst_pos2 = 2;
6940 dgst_pos3 = 1;
6941 break;
6942
6943 case 130: hash_type = HASH_TYPE_SHA1;
6944 salt_type = SALT_TYPE_INTERN;
6945 attack_exec = ATTACK_EXEC_ON_GPU;
6946 opts_type = OPTS_TYPE_PT_GENERATE_BE
6947 | OPTS_TYPE_PT_UNICODE
6948 | OPTS_TYPE_ST_ADD80
6949 | OPTS_TYPE_ST_ADDBITS15;
6950 kern_type = KERN_TYPE_SHA1_PWUSLT;
6951 dgst_size = DGST_SIZE_4_5;
6952 parse_func = sha1s_parse_hash;
6953 sort_by_digest = sort_by_digest_4_5;
6954 opti_type = OPTI_TYPE_ZERO_BYTE
6955 | OPTI_TYPE_PRECOMPUTE_INIT
6956 | OPTI_TYPE_PRECOMPUTE_MERKLE
6957 | OPTI_TYPE_EARLY_SKIP
6958 | OPTI_TYPE_NOT_ITERATED
6959 | OPTI_TYPE_APPENDED_SALT
6960 | OPTI_TYPE_RAW_HASH;
6961 dgst_pos0 = 3;
6962 dgst_pos1 = 4;
6963 dgst_pos2 = 2;
6964 dgst_pos3 = 1;
6965 break;
6966
6967 case 131: hash_type = HASH_TYPE_SHA1;
6968 salt_type = SALT_TYPE_EMBEDDED;
6969 attack_exec = ATTACK_EXEC_ON_GPU;
6970 opts_type = OPTS_TYPE_PT_GENERATE_BE
6971 | OPTS_TYPE_PT_UNICODE
6972 | OPTS_TYPE_PT_UPPER
6973 | OPTS_TYPE_ST_ADD80
6974 | OPTS_TYPE_ST_ADDBITS15
6975 | OPTS_TYPE_ST_HEX;
6976 kern_type = KERN_TYPE_SHA1_PWUSLT;
6977 dgst_size = DGST_SIZE_4_5;
6978 parse_func = mssql2000_parse_hash;
6979 sort_by_digest = sort_by_digest_4_5;
6980 opti_type = OPTI_TYPE_ZERO_BYTE
6981 | OPTI_TYPE_PRECOMPUTE_INIT
6982 | OPTI_TYPE_PRECOMPUTE_MERKLE
6983 | OPTI_TYPE_EARLY_SKIP
6984 | OPTI_TYPE_NOT_ITERATED
6985 | OPTI_TYPE_APPENDED_SALT
6986 | OPTI_TYPE_RAW_HASH;
6987 dgst_pos0 = 3;
6988 dgst_pos1 = 4;
6989 dgst_pos2 = 2;
6990 dgst_pos3 = 1;
6991 break;
6992
6993 case 132: hash_type = HASH_TYPE_SHA1;
6994 salt_type = SALT_TYPE_EMBEDDED;
6995 attack_exec = ATTACK_EXEC_ON_GPU;
6996 opts_type = OPTS_TYPE_PT_GENERATE_BE
6997 | OPTS_TYPE_PT_UNICODE
6998 | OPTS_TYPE_ST_ADD80
6999 | OPTS_TYPE_ST_ADDBITS15
7000 | OPTS_TYPE_ST_HEX;
7001 kern_type = KERN_TYPE_SHA1_PWUSLT;
7002 dgst_size = DGST_SIZE_4_5;
7003 parse_func = mssql2005_parse_hash;
7004 sort_by_digest = sort_by_digest_4_5;
7005 opti_type = OPTI_TYPE_ZERO_BYTE
7006 | OPTI_TYPE_PRECOMPUTE_INIT
7007 | OPTI_TYPE_PRECOMPUTE_MERKLE
7008 | OPTI_TYPE_EARLY_SKIP
7009 | OPTI_TYPE_NOT_ITERATED
7010 | OPTI_TYPE_APPENDED_SALT
7011 | OPTI_TYPE_RAW_HASH;
7012 dgst_pos0 = 3;
7013 dgst_pos1 = 4;
7014 dgst_pos2 = 2;
7015 dgst_pos3 = 1;
7016 break;
7017
7018 case 133: hash_type = HASH_TYPE_SHA1;
7019 salt_type = SALT_TYPE_EMBEDDED;
7020 attack_exec = ATTACK_EXEC_ON_GPU;
7021 opts_type = OPTS_TYPE_PT_GENERATE_BE
7022 | OPTS_TYPE_PT_UNICODE
7023 | OPTS_TYPE_ST_ADD80
7024 | OPTS_TYPE_ST_ADDBITS15;
7025 kern_type = KERN_TYPE_SHA1_PWUSLT;
7026 dgst_size = DGST_SIZE_4_5;
7027 parse_func = peoplesoft_parse_hash;
7028 sort_by_digest = sort_by_digest_4_5;
7029 opti_type = OPTI_TYPE_ZERO_BYTE
7030 | OPTI_TYPE_PRECOMPUTE_INIT
7031 | OPTI_TYPE_PRECOMPUTE_MERKLE
7032 | OPTI_TYPE_EARLY_SKIP
7033 | OPTI_TYPE_NOT_ITERATED
7034 | OPTI_TYPE_APPENDED_SALT
7035 | OPTI_TYPE_RAW_HASH;
7036 dgst_pos0 = 3;
7037 dgst_pos1 = 4;
7038 dgst_pos2 = 2;
7039 dgst_pos3 = 1;
7040 break;
7041
7042 case 140: hash_type = HASH_TYPE_SHA1;
7043 salt_type = SALT_TYPE_INTERN;
7044 attack_exec = ATTACK_EXEC_ON_GPU;
7045 opts_type = OPTS_TYPE_PT_GENERATE_BE
7046 | OPTS_TYPE_PT_ADD80
7047 | OPTS_TYPE_PT_ADDBITS15
7048 | OPTS_TYPE_PT_UNICODE;
7049 kern_type = KERN_TYPE_SHA1_SLTPWU;
7050 dgst_size = DGST_SIZE_4_5;
7051 parse_func = sha1s_parse_hash;
7052 sort_by_digest = sort_by_digest_4_5;
7053 opti_type = OPTI_TYPE_ZERO_BYTE
7054 | OPTI_TYPE_PRECOMPUTE_INIT
7055 | OPTI_TYPE_PRECOMPUTE_MERKLE
7056 | OPTI_TYPE_EARLY_SKIP
7057 | OPTI_TYPE_NOT_ITERATED
7058 | OPTI_TYPE_PREPENDED_SALT
7059 | OPTI_TYPE_RAW_HASH;
7060 dgst_pos0 = 3;
7061 dgst_pos1 = 4;
7062 dgst_pos2 = 2;
7063 dgst_pos3 = 1;
7064 break;
7065
7066 case 141: hash_type = HASH_TYPE_SHA1;
7067 salt_type = SALT_TYPE_EMBEDDED;
7068 attack_exec = ATTACK_EXEC_ON_GPU;
7069 opts_type = OPTS_TYPE_PT_GENERATE_BE
7070 | OPTS_TYPE_PT_ADD80
7071 | OPTS_TYPE_PT_ADDBITS15
7072 | OPTS_TYPE_PT_UNICODE
7073 | OPTS_TYPE_ST_BASE64;
7074 kern_type = KERN_TYPE_SHA1_SLTPWU;
7075 dgst_size = DGST_SIZE_4_5;
7076 parse_func = episerver_parse_hash;
7077 sort_by_digest = sort_by_digest_4_5;
7078 opti_type = OPTI_TYPE_ZERO_BYTE
7079 | OPTI_TYPE_PRECOMPUTE_INIT
7080 | OPTI_TYPE_PRECOMPUTE_MERKLE
7081 | OPTI_TYPE_EARLY_SKIP
7082 | OPTI_TYPE_NOT_ITERATED
7083 | OPTI_TYPE_PREPENDED_SALT
7084 | OPTI_TYPE_RAW_HASH;
7085 dgst_pos0 = 3;
7086 dgst_pos1 = 4;
7087 dgst_pos2 = 2;
7088 dgst_pos3 = 1;
7089 break;
7090
7091 case 150: hash_type = HASH_TYPE_SHA1;
7092 salt_type = SALT_TYPE_INTERN;
7093 attack_exec = ATTACK_EXEC_ON_GPU;
7094 opts_type = OPTS_TYPE_PT_GENERATE_BE
7095 | OPTS_TYPE_ST_ADD80
7096 | OPTS_TYPE_ST_ADDBITS15;
7097 kern_type = KERN_TYPE_HMACSHA1_PW;
7098 dgst_size = DGST_SIZE_4_5;
7099 parse_func = hmacsha1_parse_hash;
7100 sort_by_digest = sort_by_digest_4_5;
7101 opti_type = OPTI_TYPE_ZERO_BYTE
7102 | OPTI_TYPE_NOT_ITERATED;
7103 dgst_pos0 = 3;
7104 dgst_pos1 = 4;
7105 dgst_pos2 = 2;
7106 dgst_pos3 = 1;
7107 break;
7108
7109 case 160: hash_type = HASH_TYPE_SHA1;
7110 salt_type = SALT_TYPE_INTERN;
7111 attack_exec = ATTACK_EXEC_ON_GPU;
7112 opts_type = OPTS_TYPE_PT_GENERATE_BE
7113 | OPTS_TYPE_PT_ADD80
7114 | OPTS_TYPE_PT_ADDBITS15;
7115 kern_type = KERN_TYPE_HMACSHA1_SLT;
7116 dgst_size = DGST_SIZE_4_5;
7117 parse_func = hmacsha1_parse_hash;
7118 sort_by_digest = sort_by_digest_4_5;
7119 opti_type = OPTI_TYPE_ZERO_BYTE
7120 | OPTI_TYPE_NOT_ITERATED;
7121 dgst_pos0 = 3;
7122 dgst_pos1 = 4;
7123 dgst_pos2 = 2;
7124 dgst_pos3 = 1;
7125 break;
7126
7127 case 190: hash_type = HASH_TYPE_SHA1;
7128 salt_type = SALT_TYPE_NONE;
7129 attack_exec = ATTACK_EXEC_ON_GPU;
7130 opts_type = OPTS_TYPE_PT_GENERATE_BE
7131 | OPTS_TYPE_PT_ADD80
7132 | OPTS_TYPE_PT_ADDBITS15;
7133 kern_type = KERN_TYPE_SHA1_LINKEDIN;
7134 dgst_size = DGST_SIZE_4_5;
7135 parse_func = sha1linkedin_parse_hash;
7136 sort_by_digest = sort_by_digest_4_5;
7137 opti_type = OPTI_TYPE_ZERO_BYTE
7138 | OPTI_TYPE_PRECOMPUTE_INIT
7139 | OPTI_TYPE_EARLY_SKIP
7140 | OPTI_TYPE_NOT_ITERATED
7141 | OPTI_TYPE_NOT_SALTED;
7142 dgst_pos0 = 0;
7143 dgst_pos1 = 4;
7144 dgst_pos2 = 3;
7145 dgst_pos3 = 2;
7146 break;
7147
7148 case 200: hash_type = HASH_TYPE_MYSQL;
7149 salt_type = SALT_TYPE_NONE;
7150 attack_exec = ATTACK_EXEC_ON_GPU;
7151 opts_type = 0;
7152 kern_type = KERN_TYPE_MYSQL;
7153 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7154 parse_func = mysql323_parse_hash;
7155 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7156 opti_type = OPTI_TYPE_ZERO_BYTE;
7157 dgst_pos0 = 0;
7158 dgst_pos1 = 1;
7159 dgst_pos2 = 2;
7160 dgst_pos3 = 3;
7161 break;
7162
7163 case 300: hash_type = HASH_TYPE_SHA1;
7164 salt_type = SALT_TYPE_NONE;
7165 attack_exec = ATTACK_EXEC_ON_GPU;
7166 opts_type = OPTS_TYPE_PT_GENERATE_BE
7167 | OPTS_TYPE_PT_ADD80
7168 | OPTS_TYPE_PT_ADDBITS15;
7169 kern_type = KERN_TYPE_MYSQL41;
7170 dgst_size = DGST_SIZE_4_5;
7171 parse_func = sha1_parse_hash;
7172 sort_by_digest = sort_by_digest_4_5;
7173 opti_type = OPTI_TYPE_ZERO_BYTE
7174 | OPTI_TYPE_PRECOMPUTE_INIT
7175 | OPTI_TYPE_PRECOMPUTE_MERKLE
7176 | OPTI_TYPE_EARLY_SKIP
7177 | OPTI_TYPE_NOT_ITERATED
7178 | OPTI_TYPE_NOT_SALTED;
7179 dgst_pos0 = 3;
7180 dgst_pos1 = 4;
7181 dgst_pos2 = 2;
7182 dgst_pos3 = 1;
7183 break;
7184
7185 case 400: hash_type = HASH_TYPE_MD5;
7186 salt_type = SALT_TYPE_EMBEDDED;
7187 attack_exec = ATTACK_EXEC_ON_CPU;
7188 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7189 kern_type = KERN_TYPE_PHPASS;
7190 dgst_size = DGST_SIZE_4_4;
7191 parse_func = phpass_parse_hash;
7192 sort_by_digest = sort_by_digest_4_4;
7193 opti_type = OPTI_TYPE_ZERO_BYTE;
7194 dgst_pos0 = 0;
7195 dgst_pos1 = 1;
7196 dgst_pos2 = 2;
7197 dgst_pos3 = 3;
7198 break;
7199
7200 case 500: hash_type = HASH_TYPE_MD5;
7201 salt_type = SALT_TYPE_EMBEDDED;
7202 attack_exec = ATTACK_EXEC_ON_CPU;
7203 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7204 kern_type = KERN_TYPE_MD5CRYPT;
7205 dgst_size = DGST_SIZE_4_4;
7206 parse_func = md5crypt_parse_hash;
7207 sort_by_digest = sort_by_digest_4_4;
7208 opti_type = OPTI_TYPE_ZERO_BYTE;
7209 dgst_pos0 = 0;
7210 dgst_pos1 = 1;
7211 dgst_pos2 = 2;
7212 dgst_pos3 = 3;
7213 break;
7214
7215 case 501: hash_type = HASH_TYPE_MD5;
7216 salt_type = SALT_TYPE_EMBEDDED;
7217 attack_exec = ATTACK_EXEC_ON_CPU;
7218 opts_type = OPTS_TYPE_PT_GENERATE_LE
7219 | OPTS_TYPE_HASH_COPY;
7220 kern_type = KERN_TYPE_MD5CRYPT;
7221 dgst_size = DGST_SIZE_4_4;
7222 parse_func = juniper_parse_hash;
7223 sort_by_digest = sort_by_digest_4_4;
7224 opti_type = OPTI_TYPE_ZERO_BYTE;
7225 dgst_pos0 = 0;
7226 dgst_pos1 = 1;
7227 dgst_pos2 = 2;
7228 dgst_pos3 = 3;
7229 break;
7230
7231 case 900: hash_type = HASH_TYPE_MD4;
7232 salt_type = SALT_TYPE_NONE;
7233 attack_exec = ATTACK_EXEC_ON_GPU;
7234 opts_type = OPTS_TYPE_PT_GENERATE_LE
7235 | OPTS_TYPE_PT_ADD80
7236 | OPTS_TYPE_PT_ADDBITS14;
7237 kern_type = KERN_TYPE_MD4;
7238 dgst_size = DGST_SIZE_4_4;
7239 parse_func = md4_parse_hash;
7240 sort_by_digest = sort_by_digest_4_4;
7241 opti_type = OPTI_TYPE_ZERO_BYTE
7242 | OPTI_TYPE_PRECOMPUTE_INIT
7243 | OPTI_TYPE_PRECOMPUTE_MERKLE
7244 | OPTI_TYPE_MEET_IN_MIDDLE
7245 | OPTI_TYPE_EARLY_SKIP
7246 | OPTI_TYPE_NOT_ITERATED
7247 | OPTI_TYPE_NOT_SALTED
7248 | OPTI_TYPE_RAW_HASH;
7249 dgst_pos0 = 0;
7250 dgst_pos1 = 3;
7251 dgst_pos2 = 2;
7252 dgst_pos3 = 1;
7253 break;
7254
7255 case 1000: hash_type = HASH_TYPE_MD4;
7256 salt_type = SALT_TYPE_NONE;
7257 attack_exec = ATTACK_EXEC_ON_GPU;
7258 opts_type = OPTS_TYPE_PT_GENERATE_LE
7259 | OPTS_TYPE_PT_ADD80
7260 | OPTS_TYPE_PT_ADDBITS14
7261 | OPTS_TYPE_PT_UNICODE;
7262 kern_type = KERN_TYPE_MD4_PWU;
7263 dgst_size = DGST_SIZE_4_4;
7264 parse_func = md4_parse_hash;
7265 sort_by_digest = sort_by_digest_4_4;
7266 opti_type = OPTI_TYPE_ZERO_BYTE
7267 | OPTI_TYPE_PRECOMPUTE_INIT
7268 | OPTI_TYPE_PRECOMPUTE_MERKLE
7269 | OPTI_TYPE_MEET_IN_MIDDLE
7270 | OPTI_TYPE_EARLY_SKIP
7271 | OPTI_TYPE_NOT_ITERATED
7272 | OPTI_TYPE_NOT_SALTED
7273 | OPTI_TYPE_RAW_HASH;
7274 dgst_pos0 = 0;
7275 dgst_pos1 = 3;
7276 dgst_pos2 = 2;
7277 dgst_pos3 = 1;
7278 break;
7279
7280 case 1100: hash_type = HASH_TYPE_MD4;
7281 salt_type = SALT_TYPE_INTERN;
7282 attack_exec = ATTACK_EXEC_ON_GPU;
7283 opts_type = OPTS_TYPE_PT_GENERATE_LE
7284 | OPTS_TYPE_PT_ADD80
7285 | OPTS_TYPE_PT_ADDBITS14
7286 | OPTS_TYPE_PT_UNICODE
7287 | OPTS_TYPE_ST_ADD80
7288 | OPTS_TYPE_ST_UNICODE
7289 | OPTS_TYPE_ST_LOWER;
7290 kern_type = KERN_TYPE_MD44_PWUSLT;
7291 dgst_size = DGST_SIZE_4_4;
7292 parse_func = dcc_parse_hash;
7293 sort_by_digest = sort_by_digest_4_4;
7294 opti_type = OPTI_TYPE_ZERO_BYTE
7295 | OPTI_TYPE_PRECOMPUTE_INIT
7296 | OPTI_TYPE_PRECOMPUTE_MERKLE
7297 | OPTI_TYPE_EARLY_SKIP
7298 | OPTI_TYPE_NOT_ITERATED;
7299 dgst_pos0 = 0;
7300 dgst_pos1 = 3;
7301 dgst_pos2 = 2;
7302 dgst_pos3 = 1;
7303 break;
7304
7305 case 1400: hash_type = HASH_TYPE_SHA256;
7306 salt_type = SALT_TYPE_NONE;
7307 attack_exec = ATTACK_EXEC_ON_GPU;
7308 opts_type = OPTS_TYPE_PT_GENERATE_BE
7309 | OPTS_TYPE_PT_ADD80
7310 | OPTS_TYPE_PT_ADDBITS15;
7311 kern_type = KERN_TYPE_SHA256;
7312 dgst_size = DGST_SIZE_4_8;
7313 parse_func = sha256_parse_hash;
7314 sort_by_digest = sort_by_digest_4_8;
7315 opti_type = OPTI_TYPE_ZERO_BYTE
7316 | OPTI_TYPE_PRECOMPUTE_INIT
7317 | OPTI_TYPE_PRECOMPUTE_MERKLE
7318 | OPTI_TYPE_EARLY_SKIP
7319 | OPTI_TYPE_NOT_ITERATED
7320 | OPTI_TYPE_NOT_SALTED
7321 | OPTI_TYPE_RAW_HASH;
7322 dgst_pos0 = 3;
7323 dgst_pos1 = 7;
7324 dgst_pos2 = 2;
7325 dgst_pos3 = 6;
7326 break;
7327
7328 case 1410: hash_type = HASH_TYPE_SHA256;
7329 salt_type = SALT_TYPE_INTERN;
7330 attack_exec = ATTACK_EXEC_ON_GPU;
7331 opts_type = OPTS_TYPE_PT_GENERATE_BE
7332 | OPTS_TYPE_ST_ADD80
7333 | OPTS_TYPE_ST_ADDBITS15;
7334 kern_type = KERN_TYPE_SHA256_PWSLT;
7335 dgst_size = DGST_SIZE_4_8;
7336 parse_func = sha256s_parse_hash;
7337 sort_by_digest = sort_by_digest_4_8;
7338 opti_type = OPTI_TYPE_ZERO_BYTE
7339 | OPTI_TYPE_PRECOMPUTE_INIT
7340 | OPTI_TYPE_PRECOMPUTE_MERKLE
7341 | OPTI_TYPE_EARLY_SKIP
7342 | OPTI_TYPE_NOT_ITERATED
7343 | OPTI_TYPE_APPENDED_SALT
7344 | OPTI_TYPE_RAW_HASH;
7345 dgst_pos0 = 3;
7346 dgst_pos1 = 7;
7347 dgst_pos2 = 2;
7348 dgst_pos3 = 6;
7349 break;
7350
7351 case 1420: hash_type = HASH_TYPE_SHA256;
7352 salt_type = SALT_TYPE_INTERN;
7353 attack_exec = ATTACK_EXEC_ON_GPU;
7354 opts_type = OPTS_TYPE_PT_GENERATE_BE
7355 | OPTS_TYPE_PT_ADD80
7356 | OPTS_TYPE_PT_ADDBITS15;
7357 kern_type = KERN_TYPE_SHA256_SLTPW;
7358 dgst_size = DGST_SIZE_4_8;
7359 parse_func = sha256s_parse_hash;
7360 sort_by_digest = sort_by_digest_4_8;
7361 opti_type = OPTI_TYPE_ZERO_BYTE
7362 | OPTI_TYPE_PRECOMPUTE_INIT
7363 | OPTI_TYPE_PRECOMPUTE_MERKLE
7364 | OPTI_TYPE_EARLY_SKIP
7365 | OPTI_TYPE_NOT_ITERATED
7366 | OPTI_TYPE_PREPENDED_SALT
7367 | OPTI_TYPE_RAW_HASH;
7368 dgst_pos0 = 3;
7369 dgst_pos1 = 7;
7370 dgst_pos2 = 2;
7371 dgst_pos3 = 6;
7372 break;
7373
7374 case 1421: hash_type = HASH_TYPE_SHA256;
7375 salt_type = SALT_TYPE_EMBEDDED;
7376 attack_exec = ATTACK_EXEC_ON_GPU;
7377 opts_type = OPTS_TYPE_PT_GENERATE_BE
7378 | OPTS_TYPE_PT_ADD80
7379 | OPTS_TYPE_PT_ADDBITS15;
7380 kern_type = KERN_TYPE_SHA256_SLTPW;
7381 dgst_size = DGST_SIZE_4_8;
7382 parse_func = hmailserver_parse_hash;
7383 sort_by_digest = sort_by_digest_4_8;
7384 opti_type = OPTI_TYPE_ZERO_BYTE
7385 | OPTI_TYPE_PRECOMPUTE_INIT
7386 | OPTI_TYPE_PRECOMPUTE_MERKLE
7387 | OPTI_TYPE_EARLY_SKIP
7388 | OPTI_TYPE_NOT_ITERATED
7389 | OPTI_TYPE_PREPENDED_SALT
7390 | OPTI_TYPE_RAW_HASH;
7391 dgst_pos0 = 3;
7392 dgst_pos1 = 7;
7393 dgst_pos2 = 2;
7394 dgst_pos3 = 6;
7395 break;
7396
7397 case 1430: hash_type = HASH_TYPE_SHA256;
7398 salt_type = SALT_TYPE_INTERN;
7399 attack_exec = ATTACK_EXEC_ON_GPU;
7400 opts_type = OPTS_TYPE_PT_GENERATE_BE
7401 | OPTS_TYPE_PT_UNICODE
7402 | OPTS_TYPE_ST_ADD80
7403 | OPTS_TYPE_ST_ADDBITS15;
7404 kern_type = KERN_TYPE_SHA256_PWUSLT;
7405 dgst_size = DGST_SIZE_4_8;
7406 parse_func = sha256s_parse_hash;
7407 sort_by_digest = sort_by_digest_4_8;
7408 opti_type = OPTI_TYPE_ZERO_BYTE
7409 | OPTI_TYPE_PRECOMPUTE_INIT
7410 | OPTI_TYPE_PRECOMPUTE_MERKLE
7411 | OPTI_TYPE_EARLY_SKIP
7412 | OPTI_TYPE_NOT_ITERATED
7413 | OPTI_TYPE_APPENDED_SALT
7414 | OPTI_TYPE_RAW_HASH;
7415 dgst_pos0 = 3;
7416 dgst_pos1 = 7;
7417 dgst_pos2 = 2;
7418 dgst_pos3 = 6;
7419 break;
7420
7421 case 1440: hash_type = HASH_TYPE_SHA256;
7422 salt_type = SALT_TYPE_INTERN;
7423 attack_exec = ATTACK_EXEC_ON_GPU;
7424 opts_type = OPTS_TYPE_PT_GENERATE_BE
7425 | OPTS_TYPE_PT_ADD80
7426 | OPTS_TYPE_PT_ADDBITS15
7427 | OPTS_TYPE_PT_UNICODE;
7428 kern_type = KERN_TYPE_SHA256_SLTPWU;
7429 dgst_size = DGST_SIZE_4_8;
7430 parse_func = sha256s_parse_hash;
7431 sort_by_digest = sort_by_digest_4_8;
7432 opti_type = OPTI_TYPE_ZERO_BYTE
7433 | OPTI_TYPE_PRECOMPUTE_INIT
7434 | OPTI_TYPE_PRECOMPUTE_MERKLE
7435 | OPTI_TYPE_EARLY_SKIP
7436 | OPTI_TYPE_NOT_ITERATED
7437 | OPTI_TYPE_PREPENDED_SALT
7438 | OPTI_TYPE_RAW_HASH;
7439 dgst_pos0 = 3;
7440 dgst_pos1 = 7;
7441 dgst_pos2 = 2;
7442 dgst_pos3 = 6;
7443 break;
7444
7445 case 1441: hash_type = HASH_TYPE_SHA256;
7446 salt_type = SALT_TYPE_EMBEDDED;
7447 attack_exec = ATTACK_EXEC_ON_GPU;
7448 opts_type = OPTS_TYPE_PT_GENERATE_BE
7449 | OPTS_TYPE_PT_ADD80
7450 | OPTS_TYPE_PT_ADDBITS15
7451 | OPTS_TYPE_PT_UNICODE
7452 | OPTS_TYPE_ST_BASE64;
7453 kern_type = KERN_TYPE_SHA256_SLTPWU;
7454 dgst_size = DGST_SIZE_4_8;
7455 parse_func = episerver4_parse_hash;
7456 sort_by_digest = sort_by_digest_4_8;
7457 opti_type = OPTI_TYPE_ZERO_BYTE
7458 | OPTI_TYPE_PRECOMPUTE_INIT
7459 | OPTI_TYPE_PRECOMPUTE_MERKLE
7460 | OPTI_TYPE_EARLY_SKIP
7461 | OPTI_TYPE_NOT_ITERATED
7462 | OPTI_TYPE_PREPENDED_SALT
7463 | OPTI_TYPE_RAW_HASH;
7464 dgst_pos0 = 3;
7465 dgst_pos1 = 7;
7466 dgst_pos2 = 2;
7467 dgst_pos3 = 6;
7468 break;
7469
7470 case 1450: hash_type = HASH_TYPE_SHA256;
7471 salt_type = SALT_TYPE_INTERN;
7472 attack_exec = ATTACK_EXEC_ON_GPU;
7473 opts_type = OPTS_TYPE_PT_GENERATE_BE
7474 | OPTS_TYPE_ST_ADD80;
7475 kern_type = KERN_TYPE_HMACSHA256_PW;
7476 dgst_size = DGST_SIZE_4_8;
7477 parse_func = hmacsha256_parse_hash;
7478 sort_by_digest = sort_by_digest_4_8;
7479 opti_type = OPTI_TYPE_ZERO_BYTE
7480 | OPTI_TYPE_NOT_ITERATED;
7481 dgst_pos0 = 3;
7482 dgst_pos1 = 7;
7483 dgst_pos2 = 2;
7484 dgst_pos3 = 6;
7485 break;
7486
7487 case 1460: hash_type = HASH_TYPE_SHA256;
7488 salt_type = SALT_TYPE_INTERN;
7489 attack_exec = ATTACK_EXEC_ON_GPU;
7490 opts_type = OPTS_TYPE_PT_GENERATE_BE
7491 | OPTS_TYPE_PT_ADD80
7492 | OPTS_TYPE_PT_ADDBITS15;
7493 kern_type = KERN_TYPE_HMACSHA256_SLT;
7494 dgst_size = DGST_SIZE_4_8;
7495 parse_func = hmacsha256_parse_hash;
7496 sort_by_digest = sort_by_digest_4_8;
7497 opti_type = OPTI_TYPE_ZERO_BYTE
7498 | OPTI_TYPE_NOT_ITERATED;
7499 dgst_pos0 = 3;
7500 dgst_pos1 = 7;
7501 dgst_pos2 = 2;
7502 dgst_pos3 = 6;
7503 break;
7504
7505 case 1500: hash_type = HASH_TYPE_DESCRYPT;
7506 salt_type = SALT_TYPE_EMBEDDED;
7507 attack_exec = ATTACK_EXEC_ON_GPU;
7508 opts_type = OPTS_TYPE_PT_GENERATE_LE
7509 | OPTS_TYPE_PT_BITSLICE;
7510 kern_type = KERN_TYPE_DESCRYPT;
7511 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7512 parse_func = descrypt_parse_hash;
7513 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7514 opti_type = OPTI_TYPE_ZERO_BYTE
7515 | OPTI_TYPE_PRECOMPUTE_PERMUT;
7516 dgst_pos0 = 0;
7517 dgst_pos1 = 1;
7518 dgst_pos2 = 2;
7519 dgst_pos3 = 3;
7520 break;
7521
7522 case 1600: hash_type = HASH_TYPE_MD5;
7523 salt_type = SALT_TYPE_EMBEDDED;
7524 attack_exec = ATTACK_EXEC_ON_CPU;
7525 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7526 kern_type = KERN_TYPE_APR1CRYPT;
7527 dgst_size = DGST_SIZE_4_4;
7528 parse_func = md5apr1_parse_hash;
7529 sort_by_digest = sort_by_digest_4_4;
7530 opti_type = OPTI_TYPE_ZERO_BYTE;
7531 dgst_pos0 = 0;
7532 dgst_pos1 = 1;
7533 dgst_pos2 = 2;
7534 dgst_pos3 = 3;
7535 break;
7536
7537 case 1700: hash_type = HASH_TYPE_SHA512;
7538 salt_type = SALT_TYPE_NONE;
7539 attack_exec = ATTACK_EXEC_ON_GPU;
7540 opts_type = OPTS_TYPE_PT_GENERATE_BE
7541 | OPTS_TYPE_PT_ADD80
7542 | OPTS_TYPE_PT_ADDBITS15;
7543 kern_type = KERN_TYPE_SHA512;
7544 dgst_size = DGST_SIZE_8_8;
7545 parse_func = sha512_parse_hash;
7546 sort_by_digest = sort_by_digest_8_8;
7547 opti_type = OPTI_TYPE_ZERO_BYTE
7548 | OPTI_TYPE_PRECOMPUTE_INIT
7549 | OPTI_TYPE_PRECOMPUTE_MERKLE
7550 | OPTI_TYPE_EARLY_SKIP
7551 | OPTI_TYPE_NOT_ITERATED
7552 | OPTI_TYPE_NOT_SALTED
7553 | OPTI_TYPE_RAW_HASH;
7554 dgst_pos0 = 14;
7555 dgst_pos1 = 15;
7556 dgst_pos2 = 6;
7557 dgst_pos3 = 7;
7558 break;
7559
7560 case 1710: hash_type = HASH_TYPE_SHA512;
7561 salt_type = SALT_TYPE_INTERN;
7562 attack_exec = ATTACK_EXEC_ON_GPU;
7563 opts_type = OPTS_TYPE_PT_GENERATE_BE
7564 | OPTS_TYPE_ST_ADD80
7565 | OPTS_TYPE_ST_ADDBITS15;
7566 kern_type = KERN_TYPE_SHA512_PWSLT;
7567 dgst_size = DGST_SIZE_8_8;
7568 parse_func = sha512s_parse_hash;
7569 sort_by_digest = sort_by_digest_8_8;
7570 opti_type = OPTI_TYPE_ZERO_BYTE
7571 | OPTI_TYPE_PRECOMPUTE_INIT
7572 | OPTI_TYPE_PRECOMPUTE_MERKLE
7573 | OPTI_TYPE_EARLY_SKIP
7574 | OPTI_TYPE_NOT_ITERATED
7575 | OPTI_TYPE_APPENDED_SALT
7576 | OPTI_TYPE_RAW_HASH;
7577 dgst_pos0 = 14;
7578 dgst_pos1 = 15;
7579 dgst_pos2 = 6;
7580 dgst_pos3 = 7;
7581 break;
7582
7583 case 1711: hash_type = HASH_TYPE_SHA512;
7584 salt_type = SALT_TYPE_EMBEDDED;
7585 attack_exec = ATTACK_EXEC_ON_GPU;
7586 opts_type = OPTS_TYPE_PT_GENERATE_BE
7587 | OPTS_TYPE_ST_ADD80
7588 | OPTS_TYPE_ST_ADDBITS15;
7589 kern_type = KERN_TYPE_SHA512_PWSLT;
7590 dgst_size = DGST_SIZE_8_8;
7591 parse_func = sha512b64s_parse_hash;
7592 sort_by_digest = sort_by_digest_8_8;
7593 opti_type = OPTI_TYPE_ZERO_BYTE
7594 | OPTI_TYPE_PRECOMPUTE_INIT
7595 | OPTI_TYPE_PRECOMPUTE_MERKLE
7596 | OPTI_TYPE_EARLY_SKIP
7597 | OPTI_TYPE_NOT_ITERATED
7598 | OPTI_TYPE_APPENDED_SALT
7599 | OPTI_TYPE_RAW_HASH;
7600 dgst_pos0 = 14;
7601 dgst_pos1 = 15;
7602 dgst_pos2 = 6;
7603 dgst_pos3 = 7;
7604 break;
7605
7606 case 1720: hash_type = HASH_TYPE_SHA512;
7607 salt_type = SALT_TYPE_INTERN;
7608 attack_exec = ATTACK_EXEC_ON_GPU;
7609 opts_type = OPTS_TYPE_PT_GENERATE_BE
7610 | OPTS_TYPE_PT_ADD80
7611 | OPTS_TYPE_PT_ADDBITS15;
7612 kern_type = KERN_TYPE_SHA512_SLTPW;
7613 dgst_size = DGST_SIZE_8_8;
7614 parse_func = sha512s_parse_hash;
7615 sort_by_digest = sort_by_digest_8_8;
7616 opti_type = OPTI_TYPE_ZERO_BYTE
7617 | OPTI_TYPE_PRECOMPUTE_INIT
7618 | OPTI_TYPE_PRECOMPUTE_MERKLE
7619 | OPTI_TYPE_EARLY_SKIP
7620 | OPTI_TYPE_NOT_ITERATED
7621 | OPTI_TYPE_PREPENDED_SALT
7622 | OPTI_TYPE_RAW_HASH;
7623 dgst_pos0 = 14;
7624 dgst_pos1 = 15;
7625 dgst_pos2 = 6;
7626 dgst_pos3 = 7;
7627 break;
7628
7629 case 1722: hash_type = HASH_TYPE_SHA512;
7630 salt_type = SALT_TYPE_EMBEDDED;
7631 attack_exec = ATTACK_EXEC_ON_GPU;
7632 opts_type = OPTS_TYPE_PT_GENERATE_BE
7633 | OPTS_TYPE_PT_ADD80
7634 | OPTS_TYPE_PT_ADDBITS15
7635 | OPTS_TYPE_ST_HEX;
7636 kern_type = KERN_TYPE_SHA512_SLTPW;
7637 dgst_size = DGST_SIZE_8_8;
7638 parse_func = osx512_parse_hash;
7639 sort_by_digest = sort_by_digest_8_8;
7640 opti_type = OPTI_TYPE_ZERO_BYTE
7641 | OPTI_TYPE_PRECOMPUTE_INIT
7642 | OPTI_TYPE_PRECOMPUTE_MERKLE
7643 | OPTI_TYPE_EARLY_SKIP
7644 | OPTI_TYPE_NOT_ITERATED
7645 | OPTI_TYPE_PREPENDED_SALT
7646 | OPTI_TYPE_RAW_HASH;
7647 dgst_pos0 = 14;
7648 dgst_pos1 = 15;
7649 dgst_pos2 = 6;
7650 dgst_pos3 = 7;
7651 break;
7652
7653 case 1730: hash_type = HASH_TYPE_SHA512;
7654 salt_type = SALT_TYPE_INTERN;
7655 attack_exec = ATTACK_EXEC_ON_GPU;
7656 opts_type = OPTS_TYPE_PT_GENERATE_BE
7657 | OPTS_TYPE_PT_UNICODE
7658 | OPTS_TYPE_ST_ADD80
7659 | OPTS_TYPE_ST_ADDBITS15;
7660 kern_type = KERN_TYPE_SHA512_PWSLTU;
7661 dgst_size = DGST_SIZE_8_8;
7662 parse_func = sha512s_parse_hash;
7663 sort_by_digest = sort_by_digest_8_8;
7664 opti_type = OPTI_TYPE_ZERO_BYTE
7665 | OPTI_TYPE_PRECOMPUTE_INIT
7666 | OPTI_TYPE_PRECOMPUTE_MERKLE
7667 | OPTI_TYPE_EARLY_SKIP
7668 | OPTI_TYPE_NOT_ITERATED
7669 | OPTI_TYPE_APPENDED_SALT
7670 | OPTI_TYPE_RAW_HASH;
7671 dgst_pos0 = 14;
7672 dgst_pos1 = 15;
7673 dgst_pos2 = 6;
7674 dgst_pos3 = 7;
7675 break;
7676
7677 case 1731: hash_type = HASH_TYPE_SHA512;
7678 salt_type = SALT_TYPE_EMBEDDED;
7679 attack_exec = ATTACK_EXEC_ON_GPU;
7680 opts_type = OPTS_TYPE_PT_GENERATE_BE
7681 | OPTS_TYPE_PT_UNICODE
7682 | OPTS_TYPE_ST_ADD80
7683 | OPTS_TYPE_ST_ADDBITS15
7684 | OPTS_TYPE_ST_HEX;
7685 kern_type = KERN_TYPE_SHA512_PWSLTU;
7686 dgst_size = DGST_SIZE_8_8;
7687 parse_func = mssql2012_parse_hash;
7688 sort_by_digest = sort_by_digest_8_8;
7689 opti_type = OPTI_TYPE_ZERO_BYTE
7690 | OPTI_TYPE_PRECOMPUTE_INIT
7691 | OPTI_TYPE_PRECOMPUTE_MERKLE
7692 | OPTI_TYPE_EARLY_SKIP
7693 | OPTI_TYPE_NOT_ITERATED
7694 | OPTI_TYPE_APPENDED_SALT
7695 | OPTI_TYPE_RAW_HASH;
7696 dgst_pos0 = 14;
7697 dgst_pos1 = 15;
7698 dgst_pos2 = 6;
7699 dgst_pos3 = 7;
7700 break;
7701
7702 case 1740: hash_type = HASH_TYPE_SHA512;
7703 salt_type = SALT_TYPE_INTERN;
7704 attack_exec = ATTACK_EXEC_ON_GPU;
7705 opts_type = OPTS_TYPE_PT_GENERATE_BE
7706 | OPTS_TYPE_PT_ADD80
7707 | OPTS_TYPE_PT_ADDBITS15
7708 | OPTS_TYPE_PT_UNICODE;
7709 kern_type = KERN_TYPE_SHA512_SLTPWU;
7710 dgst_size = DGST_SIZE_8_8;
7711 parse_func = sha512s_parse_hash;
7712 sort_by_digest = sort_by_digest_8_8;
7713 opti_type = OPTI_TYPE_ZERO_BYTE
7714 | OPTI_TYPE_PRECOMPUTE_INIT
7715 | OPTI_TYPE_PRECOMPUTE_MERKLE
7716 | OPTI_TYPE_EARLY_SKIP
7717 | OPTI_TYPE_NOT_ITERATED
7718 | OPTI_TYPE_PREPENDED_SALT
7719 | OPTI_TYPE_RAW_HASH;
7720 dgst_pos0 = 14;
7721 dgst_pos1 = 15;
7722 dgst_pos2 = 6;
7723 dgst_pos3 = 7;
7724 break;
7725
7726 case 1750: hash_type = HASH_TYPE_SHA512;
7727 salt_type = SALT_TYPE_INTERN;
7728 attack_exec = ATTACK_EXEC_ON_GPU;
7729 opts_type = OPTS_TYPE_PT_GENERATE_BE
7730 | OPTS_TYPE_ST_ADD80;
7731 kern_type = KERN_TYPE_HMACSHA512_PW;
7732 dgst_size = DGST_SIZE_8_8;
7733 parse_func = hmacsha512_parse_hash;
7734 sort_by_digest = sort_by_digest_8_8;
7735 opti_type = OPTI_TYPE_ZERO_BYTE
7736 | OPTI_TYPE_NOT_ITERATED;
7737 dgst_pos0 = 14;
7738 dgst_pos1 = 15;
7739 dgst_pos2 = 6;
7740 dgst_pos3 = 7;
7741 break;
7742
7743 case 1760: hash_type = HASH_TYPE_SHA512;
7744 salt_type = SALT_TYPE_INTERN;
7745 attack_exec = ATTACK_EXEC_ON_GPU;
7746 opts_type = OPTS_TYPE_PT_GENERATE_BE
7747 | OPTS_TYPE_PT_ADD80
7748 | OPTS_TYPE_PT_ADDBITS15;
7749 kern_type = KERN_TYPE_HMACSHA512_SLT;
7750 dgst_size = DGST_SIZE_8_8;
7751 parse_func = hmacsha512_parse_hash;
7752 sort_by_digest = sort_by_digest_8_8;
7753 opti_type = OPTI_TYPE_ZERO_BYTE
7754 | OPTI_TYPE_NOT_ITERATED;
7755 dgst_pos0 = 14;
7756 dgst_pos1 = 15;
7757 dgst_pos2 = 6;
7758 dgst_pos3 = 7;
7759 break;
7760
7761 case 1800: hash_type = HASH_TYPE_SHA512;
7762 salt_type = SALT_TYPE_EMBEDDED;
7763 attack_exec = ATTACK_EXEC_ON_CPU;
7764 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
7765 kern_type = KERN_TYPE_SHA512CRYPT;
7766 dgst_size = DGST_SIZE_8_8;
7767 parse_func = sha512crypt_parse_hash;
7768 sort_by_digest = sort_by_digest_8_8;
7769 opti_type = OPTI_TYPE_ZERO_BYTE;
7770 dgst_pos0 = 0;
7771 dgst_pos1 = 1;
7772 dgst_pos2 = 2;
7773 dgst_pos3 = 3;
7774 break;
7775
7776 case 2100: hash_type = HASH_TYPE_DCC2;
7777 salt_type = SALT_TYPE_EMBEDDED;
7778 attack_exec = ATTACK_EXEC_ON_CPU;
7779 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
7780 | OPTS_TYPE_ST_LOWER
7781 | OPTS_TYPE_ST_UNICODE;
7782 kern_type = KERN_TYPE_DCC2;
7783 dgst_size = DGST_SIZE_4_4;
7784 parse_func = dcc2_parse_hash;
7785 sort_by_digest = sort_by_digest_4_4;
7786 opti_type = OPTI_TYPE_ZERO_BYTE;
7787 dgst_pos0 = 0;
7788 dgst_pos1 = 1;
7789 dgst_pos2 = 2;
7790 dgst_pos3 = 3;
7791 break;
7792
7793 case 2400: hash_type = HASH_TYPE_MD5;
7794 salt_type = SALT_TYPE_NONE;
7795 attack_exec = ATTACK_EXEC_ON_GPU;
7796 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7797 kern_type = KERN_TYPE_MD5PIX;
7798 dgst_size = DGST_SIZE_4_4;
7799 parse_func = md5pix_parse_hash;
7800 sort_by_digest = sort_by_digest_4_4;
7801 opti_type = OPTI_TYPE_ZERO_BYTE
7802 | OPTI_TYPE_PRECOMPUTE_INIT
7803 | OPTI_TYPE_PRECOMPUTE_MERKLE
7804 | OPTI_TYPE_EARLY_SKIP
7805 | OPTI_TYPE_NOT_ITERATED
7806 | OPTI_TYPE_NOT_SALTED;
7807 dgst_pos0 = 0;
7808 dgst_pos1 = 3;
7809 dgst_pos2 = 2;
7810 dgst_pos3 = 1;
7811 break;
7812
7813 case 2410: hash_type = HASH_TYPE_MD5;
7814 salt_type = SALT_TYPE_INTERN;
7815 attack_exec = ATTACK_EXEC_ON_GPU;
7816 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7817 kern_type = KERN_TYPE_MD5ASA;
7818 dgst_size = DGST_SIZE_4_4;
7819 parse_func = md5asa_parse_hash;
7820 sort_by_digest = sort_by_digest_4_4;
7821 opti_type = OPTI_TYPE_ZERO_BYTE
7822 | OPTI_TYPE_PRECOMPUTE_INIT
7823 | OPTI_TYPE_PRECOMPUTE_MERKLE
7824 | OPTI_TYPE_EARLY_SKIP
7825 | OPTI_TYPE_NOT_ITERATED;
7826 dgst_pos0 = 0;
7827 dgst_pos1 = 3;
7828 dgst_pos2 = 2;
7829 dgst_pos3 = 1;
7830 break;
7831
7832 case 2500: hash_type = HASH_TYPE_WPA;
7833 salt_type = SALT_TYPE_EMBEDDED;
7834 attack_exec = ATTACK_EXEC_ON_CPU;
7835 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
7836 kern_type = KERN_TYPE_WPA;
7837 dgst_size = DGST_SIZE_4_4;
7838 parse_func = wpa_parse_hash;
7839 sort_by_digest = sort_by_digest_4_4;
7840 opti_type = OPTI_TYPE_ZERO_BYTE;
7841 dgst_pos0 = 0;
7842 dgst_pos1 = 1;
7843 dgst_pos2 = 2;
7844 dgst_pos3 = 3;
7845 break;
7846
7847 case 2600: hash_type = HASH_TYPE_MD5;
7848 salt_type = SALT_TYPE_VIRTUAL;
7849 attack_exec = ATTACK_EXEC_ON_GPU;
7850 opts_type = OPTS_TYPE_PT_GENERATE_LE
7851 | OPTS_TYPE_PT_ADD80
7852 | OPTS_TYPE_PT_ADDBITS14
7853 | OPTS_TYPE_ST_ADD80;
7854 kern_type = KERN_TYPE_MD55_PWSLT1;
7855 dgst_size = DGST_SIZE_4_4;
7856 parse_func = md5md5_parse_hash;
7857 sort_by_digest = sort_by_digest_4_4;
7858 opti_type = OPTI_TYPE_ZERO_BYTE
7859 | OPTI_TYPE_PRECOMPUTE_INIT
7860 | OPTI_TYPE_PRECOMPUTE_MERKLE
7861 | OPTI_TYPE_EARLY_SKIP;
7862 dgst_pos0 = 0;
7863 dgst_pos1 = 3;
7864 dgst_pos2 = 2;
7865 dgst_pos3 = 1;
7866 break;
7867
7868 case 2611: hash_type = HASH_TYPE_MD5;
7869 salt_type = SALT_TYPE_INTERN;
7870 attack_exec = ATTACK_EXEC_ON_GPU;
7871 opts_type = OPTS_TYPE_PT_GENERATE_LE
7872 | OPTS_TYPE_PT_ADD80
7873 | OPTS_TYPE_PT_ADDBITS14
7874 | OPTS_TYPE_ST_ADD80;
7875 kern_type = KERN_TYPE_MD55_PWSLT1;
7876 dgst_size = DGST_SIZE_4_4;
7877 parse_func = vb3_parse_hash;
7878 sort_by_digest = sort_by_digest_4_4;
7879 opti_type = OPTI_TYPE_ZERO_BYTE
7880 | OPTI_TYPE_PRECOMPUTE_INIT
7881 | OPTI_TYPE_PRECOMPUTE_MERKLE
7882 | OPTI_TYPE_EARLY_SKIP;
7883 dgst_pos0 = 0;
7884 dgst_pos1 = 3;
7885 dgst_pos2 = 2;
7886 dgst_pos3 = 1;
7887 break;
7888
7889 case 2612: hash_type = HASH_TYPE_MD5;
7890 salt_type = SALT_TYPE_EMBEDDED;
7891 attack_exec = ATTACK_EXEC_ON_GPU;
7892 opts_type = OPTS_TYPE_PT_GENERATE_LE
7893 | OPTS_TYPE_PT_ADD80
7894 | OPTS_TYPE_PT_ADDBITS14
7895 | OPTS_TYPE_ST_ADD80
7896 | OPTS_TYPE_ST_HEX;
7897 kern_type = KERN_TYPE_MD55_PWSLT1;
7898 dgst_size = DGST_SIZE_4_4;
7899 parse_func = phps_parse_hash;
7900 sort_by_digest = sort_by_digest_4_4;
7901 opti_type = OPTI_TYPE_ZERO_BYTE
7902 | OPTI_TYPE_PRECOMPUTE_INIT
7903 | OPTI_TYPE_PRECOMPUTE_MERKLE
7904 | OPTI_TYPE_EARLY_SKIP;
7905 dgst_pos0 = 0;
7906 dgst_pos1 = 3;
7907 dgst_pos2 = 2;
7908 dgst_pos3 = 1;
7909 break;
7910
7911 case 2711: hash_type = HASH_TYPE_MD5;
7912 salt_type = SALT_TYPE_INTERN;
7913 attack_exec = ATTACK_EXEC_ON_GPU;
7914 opts_type = OPTS_TYPE_PT_GENERATE_LE
7915 | OPTS_TYPE_PT_ADD80
7916 | OPTS_TYPE_PT_ADDBITS14
7917 | OPTS_TYPE_ST_ADD80;
7918 kern_type = KERN_TYPE_MD55_PWSLT2;
7919 dgst_size = DGST_SIZE_4_4;
7920 parse_func = vb30_parse_hash;
7921 sort_by_digest = sort_by_digest_4_4;
7922 opti_type = OPTI_TYPE_ZERO_BYTE
7923 | OPTI_TYPE_PRECOMPUTE_INIT
7924 | OPTI_TYPE_EARLY_SKIP;
7925 dgst_pos0 = 0;
7926 dgst_pos1 = 3;
7927 dgst_pos2 = 2;
7928 dgst_pos3 = 1;
7929 break;
7930
7931 case 2811: hash_type = HASH_TYPE_MD5;
7932 salt_type = SALT_TYPE_INTERN;
7933 attack_exec = ATTACK_EXEC_ON_GPU;
7934 opts_type = OPTS_TYPE_PT_GENERATE_LE
7935 | OPTS_TYPE_PT_ADD80
7936 | OPTS_TYPE_PT_ADDBITS14;
7937 kern_type = KERN_TYPE_MD55_SLTPW;
7938 dgst_size = DGST_SIZE_4_4;
7939 parse_func = ipb2_parse_hash;
7940 sort_by_digest = sort_by_digest_4_4;
7941 opti_type = OPTI_TYPE_ZERO_BYTE
7942 | OPTI_TYPE_PRECOMPUTE_INIT
7943 | OPTI_TYPE_EARLY_SKIP;
7944 dgst_pos0 = 0;
7945 dgst_pos1 = 3;
7946 dgst_pos2 = 2;
7947 dgst_pos3 = 1;
7948 break;
7949
7950 case 3000: hash_type = HASH_TYPE_LM;
7951 salt_type = SALT_TYPE_NONE;
7952 attack_exec = ATTACK_EXEC_ON_GPU;
7953 opts_type = OPTS_TYPE_PT_GENERATE_LE
7954 | OPTS_TYPE_PT_UPPER
7955 | OPTS_TYPE_PT_BITSLICE;
7956 kern_type = KERN_TYPE_LM;
7957 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7958 parse_func = lm_parse_hash;
7959 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7960 opti_type = OPTI_TYPE_ZERO_BYTE
7961 | OPTI_TYPE_PRECOMPUTE_PERMUT;
7962 dgst_pos0 = 0;
7963 dgst_pos1 = 1;
7964 dgst_pos2 = 2;
7965 dgst_pos3 = 3;
7966 break;
7967
7968 case 3100: hash_type = HASH_TYPE_ORACLEH;
7969 salt_type = SALT_TYPE_INTERN;
7970 attack_exec = ATTACK_EXEC_ON_GPU;
7971 opts_type = OPTS_TYPE_PT_GENERATE_LE
7972 | OPTS_TYPE_PT_UPPER
7973 | OPTS_TYPE_ST_UPPER;
7974 kern_type = KERN_TYPE_ORACLEH;
7975 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7976 parse_func = oracleh_parse_hash;
7977 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7978 opti_type = OPTI_TYPE_ZERO_BYTE;
7979 dgst_pos0 = 0;
7980 dgst_pos1 = 1;
7981 dgst_pos2 = 2;
7982 dgst_pos3 = 3;
7983 break;
7984
7985 case 3200: hash_type = HASH_TYPE_BCRYPT;
7986 salt_type = SALT_TYPE_EMBEDDED;
7987 attack_exec = ATTACK_EXEC_ON_CPU;
7988 opts_type = OPTS_TYPE_PT_GENERATE_LE
7989 | OPTS_TYPE_ST_GENERATE_LE;
7990 kern_type = KERN_TYPE_BCRYPT;
7991 dgst_size = DGST_SIZE_4_6;
7992 parse_func = bcrypt_parse_hash;
7993 sort_by_digest = sort_by_digest_4_6;
7994 opti_type = OPTI_TYPE_ZERO_BYTE;
7995 dgst_pos0 = 0;
7996 dgst_pos1 = 1;
7997 dgst_pos2 = 2;
7998 dgst_pos3 = 3;
7999 break;
8000
8001 case 3710: hash_type = HASH_TYPE_MD5;
8002 salt_type = SALT_TYPE_INTERN;
8003 attack_exec = ATTACK_EXEC_ON_GPU;
8004 opts_type = OPTS_TYPE_PT_GENERATE_LE
8005 | OPTS_TYPE_PT_ADD80
8006 | OPTS_TYPE_PT_ADDBITS14;
8007 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8008 dgst_size = DGST_SIZE_4_4;
8009 parse_func = md5s_parse_hash;
8010 sort_by_digest = sort_by_digest_4_4;
8011 opti_type = OPTI_TYPE_ZERO_BYTE
8012 | OPTI_TYPE_PRECOMPUTE_INIT
8013 | OPTI_TYPE_PRECOMPUTE_MERKLE
8014 | OPTI_TYPE_EARLY_SKIP;
8015 dgst_pos0 = 0;
8016 dgst_pos1 = 3;
8017 dgst_pos2 = 2;
8018 dgst_pos3 = 1;
8019 break;
8020
8021 case 3711: hash_type = HASH_TYPE_MD5;
8022 salt_type = SALT_TYPE_EMBEDDED;
8023 attack_exec = ATTACK_EXEC_ON_GPU;
8024 opts_type = OPTS_TYPE_PT_GENERATE_LE
8025 | OPTS_TYPE_PT_ADD80
8026 | OPTS_TYPE_PT_ADDBITS14;
8027 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8028 dgst_size = DGST_SIZE_4_4;
8029 parse_func = mediawiki_b_parse_hash;
8030 sort_by_digest = sort_by_digest_4_4;
8031 opti_type = OPTI_TYPE_ZERO_BYTE
8032 | OPTI_TYPE_PRECOMPUTE_INIT
8033 | OPTI_TYPE_PRECOMPUTE_MERKLE
8034 | OPTI_TYPE_EARLY_SKIP;
8035 dgst_pos0 = 0;
8036 dgst_pos1 = 3;
8037 dgst_pos2 = 2;
8038 dgst_pos3 = 1;
8039 break;
8040
8041 case 3800: hash_type = HASH_TYPE_MD5;
8042 salt_type = SALT_TYPE_INTERN;
8043 attack_exec = ATTACK_EXEC_ON_GPU;
8044 opts_type = OPTS_TYPE_PT_GENERATE_LE
8045 | OPTS_TYPE_ST_ADDBITS14;
8046 kern_type = KERN_TYPE_MD5_SLT_PW_SLT;
8047 dgst_size = DGST_SIZE_4_4;
8048 parse_func = md5s_parse_hash;
8049 sort_by_digest = sort_by_digest_4_4;
8050 opti_type = OPTI_TYPE_ZERO_BYTE
8051 | OPTI_TYPE_PRECOMPUTE_INIT
8052 | OPTI_TYPE_PRECOMPUTE_MERKLE
8053 | OPTI_TYPE_EARLY_SKIP
8054 | OPTI_TYPE_NOT_ITERATED
8055 | OPTI_TYPE_RAW_HASH;
8056 dgst_pos0 = 0;
8057 dgst_pos1 = 3;
8058 dgst_pos2 = 2;
8059 dgst_pos3 = 1;
8060 break;
8061
8062 case 4300: hash_type = HASH_TYPE_MD5;
8063 salt_type = SALT_TYPE_VIRTUAL;
8064 attack_exec = ATTACK_EXEC_ON_GPU;
8065 opts_type = OPTS_TYPE_PT_GENERATE_LE
8066 | OPTS_TYPE_PT_ADD80
8067 | OPTS_TYPE_PT_ADDBITS14
8068 | OPTS_TYPE_ST_ADD80;
8069 kern_type = KERN_TYPE_MD5U5_PWSLT1;
8070 dgst_size = DGST_SIZE_4_4;
8071 parse_func = md5md5_parse_hash;
8072 sort_by_digest = sort_by_digest_4_4;
8073 opti_type = OPTI_TYPE_ZERO_BYTE
8074 | OPTI_TYPE_PRECOMPUTE_INIT
8075 | OPTI_TYPE_PRECOMPUTE_MERKLE
8076 | OPTI_TYPE_EARLY_SKIP;
8077 dgst_pos0 = 0;
8078 dgst_pos1 = 3;
8079 dgst_pos2 = 2;
8080 dgst_pos3 = 1;
8081 break;
8082
8083
8084 case 4400: hash_type = HASH_TYPE_MD5;
8085 salt_type = SALT_TYPE_NONE;
8086 attack_exec = ATTACK_EXEC_ON_GPU;
8087 opts_type = OPTS_TYPE_PT_GENERATE_BE
8088 | OPTS_TYPE_PT_ADD80
8089 | OPTS_TYPE_PT_ADDBITS15;
8090 kern_type = KERN_TYPE_MD5_SHA1;
8091 dgst_size = DGST_SIZE_4_4;
8092 parse_func = md5_parse_hash;
8093 sort_by_digest = sort_by_digest_4_4;
8094 opti_type = OPTI_TYPE_ZERO_BYTE
8095 | OPTI_TYPE_PRECOMPUTE_INIT
8096 | OPTI_TYPE_PRECOMPUTE_MERKLE
8097 | OPTI_TYPE_EARLY_SKIP
8098 | OPTI_TYPE_NOT_ITERATED
8099 | OPTI_TYPE_NOT_SALTED
8100 | OPTI_TYPE_RAW_HASH;
8101 dgst_pos0 = 0;
8102 dgst_pos1 = 3;
8103 dgst_pos2 = 2;
8104 dgst_pos3 = 1;
8105 break;
8106
8107 case 4500: hash_type = HASH_TYPE_SHA1;
8108 salt_type = SALT_TYPE_NONE;
8109 attack_exec = ATTACK_EXEC_ON_GPU;
8110 opts_type = OPTS_TYPE_PT_GENERATE_BE
8111 | OPTS_TYPE_PT_ADD80
8112 | OPTS_TYPE_PT_ADDBITS15;
8113 kern_type = KERN_TYPE_SHA11;
8114 dgst_size = DGST_SIZE_4_5;
8115 parse_func = sha1_parse_hash;
8116 sort_by_digest = sort_by_digest_4_5;
8117 opti_type = OPTI_TYPE_ZERO_BYTE
8118 | OPTI_TYPE_PRECOMPUTE_INIT
8119 | OPTI_TYPE_PRECOMPUTE_MERKLE
8120 | OPTI_TYPE_EARLY_SKIP
8121 | OPTI_TYPE_NOT_SALTED;
8122 dgst_pos0 = 3;
8123 dgst_pos1 = 4;
8124 dgst_pos2 = 2;
8125 dgst_pos3 = 1;
8126 break;
8127
8128 case 4700: hash_type = HASH_TYPE_SHA1;
8129 salt_type = SALT_TYPE_NONE;
8130 attack_exec = ATTACK_EXEC_ON_GPU;
8131 opts_type = OPTS_TYPE_PT_GENERATE_LE
8132 | OPTS_TYPE_PT_ADD80
8133 | OPTS_TYPE_PT_ADDBITS14;
8134 kern_type = KERN_TYPE_SHA1_MD5;
8135 dgst_size = DGST_SIZE_4_5;
8136 parse_func = sha1_parse_hash;
8137 sort_by_digest = sort_by_digest_4_5;
8138 opti_type = OPTI_TYPE_ZERO_BYTE
8139 | OPTI_TYPE_PRECOMPUTE_INIT
8140 | OPTI_TYPE_PRECOMPUTE_MERKLE
8141 | OPTI_TYPE_EARLY_SKIP
8142 | OPTI_TYPE_NOT_ITERATED
8143 | OPTI_TYPE_NOT_SALTED
8144 | OPTI_TYPE_RAW_HASH;
8145 dgst_pos0 = 3;
8146 dgst_pos1 = 4;
8147 dgst_pos2 = 2;
8148 dgst_pos3 = 1;
8149 break;
8150
8151 case 4800: hash_type = HASH_TYPE_MD5;
8152 salt_type = SALT_TYPE_EMBEDDED;
8153 attack_exec = ATTACK_EXEC_ON_GPU;
8154 opts_type = OPTS_TYPE_PT_GENERATE_LE
8155 | OPTS_TYPE_PT_ADDBITS14;
8156 kern_type = KERN_TYPE_MD5_CHAP;
8157 dgst_size = DGST_SIZE_4_4;
8158 parse_func = chap_parse_hash;
8159 sort_by_digest = sort_by_digest_4_4;
8160 opti_type = OPTI_TYPE_ZERO_BYTE
8161 | OPTI_TYPE_PRECOMPUTE_INIT
8162 | OPTI_TYPE_PRECOMPUTE_MERKLE
8163 | OPTI_TYPE_MEET_IN_MIDDLE
8164 | OPTI_TYPE_EARLY_SKIP
8165 | OPTI_TYPE_NOT_ITERATED
8166 | OPTI_TYPE_RAW_HASH;
8167 dgst_pos0 = 0;
8168 dgst_pos1 = 3;
8169 dgst_pos2 = 2;
8170 dgst_pos3 = 1;
8171 break;
8172
8173 case 4900: hash_type = HASH_TYPE_SHA1;
8174 salt_type = SALT_TYPE_INTERN;
8175 attack_exec = ATTACK_EXEC_ON_GPU;
8176 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8177 kern_type = KERN_TYPE_SHA1_SLT_PW_SLT;
8178 dgst_size = DGST_SIZE_4_5;
8179 parse_func = sha1s_parse_hash;
8180 sort_by_digest = sort_by_digest_4_5;
8181 opti_type = OPTI_TYPE_ZERO_BYTE
8182 | OPTI_TYPE_PRECOMPUTE_INIT
8183 | OPTI_TYPE_PRECOMPUTE_MERKLE
8184 | OPTI_TYPE_EARLY_SKIP;
8185 dgst_pos0 = 3;
8186 dgst_pos1 = 4;
8187 dgst_pos2 = 2;
8188 dgst_pos3 = 1;
8189 break;
8190
8191 case 5000: hash_type = HASH_TYPE_KECCAK;
8192 salt_type = SALT_TYPE_EMBEDDED;
8193 attack_exec = ATTACK_EXEC_ON_GPU;
8194 opts_type = OPTS_TYPE_PT_GENERATE_LE
8195 | OPTS_TYPE_PT_ADD01;
8196 kern_type = KERN_TYPE_KECCAK;
8197 dgst_size = DGST_SIZE_8_25;
8198 parse_func = keccak_parse_hash;
8199 sort_by_digest = sort_by_digest_8_25;
8200 opti_type = OPTI_TYPE_ZERO_BYTE
8201 | OPTI_TYPE_RAW_HASH;
8202 dgst_pos0 = 2;
8203 dgst_pos1 = 3;
8204 dgst_pos2 = 4;
8205 dgst_pos3 = 5;
8206 break;
8207
8208 case 5100: hash_type = HASH_TYPE_MD5H;
8209 salt_type = SALT_TYPE_NONE;
8210 attack_exec = ATTACK_EXEC_ON_GPU;
8211 opts_type = OPTS_TYPE_PT_GENERATE_LE
8212 | OPTS_TYPE_PT_ADD80
8213 | OPTS_TYPE_PT_ADDBITS14;
8214 kern_type = KERN_TYPE_MD5H;
8215 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8216 parse_func = md5half_parse_hash;
8217 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8218 opti_type = OPTI_TYPE_ZERO_BYTE
8219 | OPTI_TYPE_RAW_HASH;
8220 dgst_pos0 = 0;
8221 dgst_pos1 = 1;
8222 dgst_pos2 = 2;
8223 dgst_pos3 = 3;
8224 break;
8225
8226 case 5200: hash_type = HASH_TYPE_SHA256;
8227 salt_type = SALT_TYPE_EMBEDDED;
8228 attack_exec = ATTACK_EXEC_ON_CPU;
8229 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8230 kern_type = KERN_TYPE_PSAFE3;
8231 dgst_size = DGST_SIZE_4_8;
8232 parse_func = psafe3_parse_hash;
8233 sort_by_digest = sort_by_digest_4_8;
8234 opti_type = OPTI_TYPE_ZERO_BYTE;
8235 dgst_pos0 = 0;
8236 dgst_pos1 = 1;
8237 dgst_pos2 = 2;
8238 dgst_pos3 = 3;
8239 break;
8240
8241 case 5300: hash_type = HASH_TYPE_MD5;
8242 salt_type = SALT_TYPE_EMBEDDED;
8243 attack_exec = ATTACK_EXEC_ON_GPU;
8244 opts_type = OPTS_TYPE_PT_GENERATE_LE
8245 | OPTS_TYPE_ST_ADD80;
8246 kern_type = KERN_TYPE_IKEPSK_MD5;
8247 dgst_size = DGST_SIZE_4_4;
8248 parse_func = ikepsk_md5_parse_hash;
8249 sort_by_digest = sort_by_digest_4_4;
8250 opti_type = OPTI_TYPE_ZERO_BYTE;
8251 dgst_pos0 = 0;
8252 dgst_pos1 = 3;
8253 dgst_pos2 = 2;
8254 dgst_pos3 = 1;
8255 break;
8256
8257 case 5400: hash_type = HASH_TYPE_SHA1;
8258 salt_type = SALT_TYPE_EMBEDDED;
8259 attack_exec = ATTACK_EXEC_ON_GPU;
8260 opts_type = OPTS_TYPE_PT_GENERATE_BE
8261 | OPTS_TYPE_ST_ADD80;
8262 kern_type = KERN_TYPE_IKEPSK_SHA1;
8263 dgst_size = DGST_SIZE_4_5;
8264 parse_func = ikepsk_sha1_parse_hash;
8265 sort_by_digest = sort_by_digest_4_5;
8266 opti_type = OPTI_TYPE_ZERO_BYTE;
8267 dgst_pos0 = 3;
8268 dgst_pos1 = 4;
8269 dgst_pos2 = 2;
8270 dgst_pos3 = 1;
8271 break;
8272
8273 case 5500: hash_type = HASH_TYPE_NETNTLM;
8274 salt_type = SALT_TYPE_EMBEDDED;
8275 attack_exec = ATTACK_EXEC_ON_GPU;
8276 opts_type = OPTS_TYPE_PT_GENERATE_LE
8277 | OPTS_TYPE_PT_ADD80
8278 | OPTS_TYPE_PT_ADDBITS14
8279 | OPTS_TYPE_PT_UNICODE
8280 | OPTS_TYPE_ST_HEX;
8281 kern_type = KERN_TYPE_NETNTLMv1;
8282 dgst_size = DGST_SIZE_4_4;
8283 parse_func = netntlmv1_parse_hash;
8284 sort_by_digest = sort_by_digest_4_4;
8285 opti_type = OPTI_TYPE_ZERO_BYTE
8286 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8287 dgst_pos0 = 0;
8288 dgst_pos1 = 1;
8289 dgst_pos2 = 2;
8290 dgst_pos3 = 3;
8291 break;
8292
8293 case 5600: hash_type = HASH_TYPE_MD5;
8294 salt_type = SALT_TYPE_EMBEDDED;
8295 attack_exec = ATTACK_EXEC_ON_GPU;
8296 opts_type = OPTS_TYPE_PT_GENERATE_LE
8297 | OPTS_TYPE_PT_ADD80
8298 | OPTS_TYPE_PT_ADDBITS14
8299 | OPTS_TYPE_PT_UNICODE;
8300 kern_type = KERN_TYPE_NETNTLMv2;
8301 dgst_size = DGST_SIZE_4_4;
8302 parse_func = netntlmv2_parse_hash;
8303 sort_by_digest = sort_by_digest_4_4;
8304 opti_type = OPTI_TYPE_ZERO_BYTE;
8305 dgst_pos0 = 0;
8306 dgst_pos1 = 3;
8307 dgst_pos2 = 2;
8308 dgst_pos3 = 1;
8309 break;
8310
8311 case 5700: hash_type = HASH_TYPE_SHA256;
8312 salt_type = SALT_TYPE_NONE;
8313 attack_exec = ATTACK_EXEC_ON_GPU;
8314 opts_type = OPTS_TYPE_PT_GENERATE_BE
8315 | OPTS_TYPE_PT_ADD80
8316 | OPTS_TYPE_PT_ADDBITS15;
8317 kern_type = KERN_TYPE_SHA256;
8318 dgst_size = DGST_SIZE_4_8;
8319 parse_func = cisco4_parse_hash;
8320 sort_by_digest = sort_by_digest_4_8;
8321 opti_type = OPTI_TYPE_ZERO_BYTE
8322 | OPTI_TYPE_PRECOMPUTE_INIT
8323 | OPTI_TYPE_PRECOMPUTE_MERKLE
8324 | OPTI_TYPE_EARLY_SKIP
8325 | OPTI_TYPE_NOT_ITERATED
8326 | OPTI_TYPE_NOT_SALTED
8327 | OPTI_TYPE_RAW_HASH;
8328 dgst_pos0 = 3;
8329 dgst_pos1 = 7;
8330 dgst_pos2 = 2;
8331 dgst_pos3 = 6;
8332 break;
8333
8334 case 5800: hash_type = HASH_TYPE_SHA1;
8335 salt_type = SALT_TYPE_INTERN;
8336 attack_exec = ATTACK_EXEC_ON_CPU;
8337 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
8338 | OPTS_TYPE_ST_ADD80;
8339 kern_type = KERN_TYPE_ANDROIDPIN;
8340 dgst_size = DGST_SIZE_4_5;
8341 parse_func = androidpin_parse_hash;
8342 sort_by_digest = sort_by_digest_4_5;
8343 opti_type = OPTI_TYPE_ZERO_BYTE;
8344 dgst_pos0 = 0;
8345 dgst_pos1 = 1;
8346 dgst_pos2 = 2;
8347 dgst_pos3 = 3;
8348 break;
8349
8350 case 6000: hash_type = HASH_TYPE_RIPEMD160;
8351 salt_type = SALT_TYPE_NONE;
8352 attack_exec = ATTACK_EXEC_ON_GPU;
8353 opts_type = OPTS_TYPE_PT_GENERATE_LE
8354 | OPTS_TYPE_PT_ADD80;
8355 kern_type = KERN_TYPE_RIPEMD160;
8356 dgst_size = DGST_SIZE_4_5;
8357 parse_func = ripemd160_parse_hash;
8358 sort_by_digest = sort_by_digest_4_5;
8359 opti_type = OPTI_TYPE_ZERO_BYTE;
8360 dgst_pos0 = 0;
8361 dgst_pos1 = 1;
8362 dgst_pos2 = 2;
8363 dgst_pos3 = 3;
8364 break;
8365
8366 case 6100: hash_type = HASH_TYPE_WHIRLPOOL;
8367 salt_type = SALT_TYPE_NONE;
8368 attack_exec = ATTACK_EXEC_ON_GPU;
8369 opts_type = OPTS_TYPE_PT_GENERATE_BE
8370 | OPTS_TYPE_PT_ADD80;
8371 kern_type = KERN_TYPE_WHIRLPOOL;
8372 dgst_size = DGST_SIZE_4_16;
8373 parse_func = whirlpool_parse_hash;
8374 sort_by_digest = sort_by_digest_4_16;
8375 opti_type = OPTI_TYPE_ZERO_BYTE;
8376 dgst_pos0 = 0;
8377 dgst_pos1 = 1;
8378 dgst_pos2 = 2;
8379 dgst_pos3 = 3;
8380 break;
8381
8382 case 6211: hash_type = HASH_TYPE_RIPEMD160;
8383 salt_type = SALT_TYPE_EMBEDDED;
8384 attack_exec = ATTACK_EXEC_ON_CPU;
8385 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8386 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
8387 dgst_size = DGST_SIZE_4_5;
8388 parse_func = truecrypt_parse_hash_2k;
8389 sort_by_digest = sort_by_digest_4_5;
8390 opti_type = OPTI_TYPE_ZERO_BYTE;
8391 dgst_pos0 = 0;
8392 dgst_pos1 = 1;
8393 dgst_pos2 = 2;
8394 dgst_pos3 = 3;
8395 break;
8396
8397 case 6212: hash_type = HASH_TYPE_RIPEMD160;
8398 salt_type = SALT_TYPE_EMBEDDED;
8399 attack_exec = ATTACK_EXEC_ON_CPU;
8400 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8401 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
8402 dgst_size = DGST_SIZE_4_5;
8403 parse_func = truecrypt_parse_hash_2k;
8404 sort_by_digest = sort_by_digest_4_5;
8405 opti_type = OPTI_TYPE_ZERO_BYTE;
8406 dgst_pos0 = 0;
8407 dgst_pos1 = 1;
8408 dgst_pos2 = 2;
8409 dgst_pos3 = 3;
8410 break;
8411
8412 case 6213: hash_type = HASH_TYPE_RIPEMD160;
8413 salt_type = SALT_TYPE_EMBEDDED;
8414 attack_exec = ATTACK_EXEC_ON_CPU;
8415 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8416 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
8417 dgst_size = DGST_SIZE_4_5;
8418 parse_func = truecrypt_parse_hash_2k;
8419 sort_by_digest = sort_by_digest_4_5;
8420 opti_type = OPTI_TYPE_ZERO_BYTE;
8421 dgst_pos0 = 0;
8422 dgst_pos1 = 1;
8423 dgst_pos2 = 2;
8424 dgst_pos3 = 3;
8425 break;
8426
8427 case 6221: hash_type = HASH_TYPE_SHA512;
8428 salt_type = SALT_TYPE_EMBEDDED;
8429 attack_exec = ATTACK_EXEC_ON_CPU;
8430 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8431 kern_type = KERN_TYPE_TCSHA512_XTS512;
8432 dgst_size = DGST_SIZE_8_8;
8433 parse_func = truecrypt_parse_hash_1k;
8434 sort_by_digest = sort_by_digest_8_8;
8435 opti_type = OPTI_TYPE_ZERO_BYTE;
8436 dgst_pos0 = 0;
8437 dgst_pos1 = 1;
8438 dgst_pos2 = 2;
8439 dgst_pos3 = 3;
8440 break;
8441
8442 case 6222: hash_type = HASH_TYPE_SHA512;
8443 salt_type = SALT_TYPE_EMBEDDED;
8444 attack_exec = ATTACK_EXEC_ON_CPU;
8445 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8446 kern_type = KERN_TYPE_TCSHA512_XTS1024;
8447 dgst_size = DGST_SIZE_8_8;
8448 parse_func = truecrypt_parse_hash_1k;
8449 sort_by_digest = sort_by_digest_8_8;
8450 opti_type = OPTI_TYPE_ZERO_BYTE;
8451 dgst_pos0 = 0;
8452 dgst_pos1 = 1;
8453 dgst_pos2 = 2;
8454 dgst_pos3 = 3;
8455 break;
8456
8457 case 6223: hash_type = HASH_TYPE_SHA512;
8458 salt_type = SALT_TYPE_EMBEDDED;
8459 attack_exec = ATTACK_EXEC_ON_CPU;
8460 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8461 kern_type = KERN_TYPE_TCSHA512_XTS1536;
8462 dgst_size = DGST_SIZE_8_8;
8463 parse_func = truecrypt_parse_hash_1k;
8464 sort_by_digest = sort_by_digest_8_8;
8465 opti_type = OPTI_TYPE_ZERO_BYTE;
8466 dgst_pos0 = 0;
8467 dgst_pos1 = 1;
8468 dgst_pos2 = 2;
8469 dgst_pos3 = 3;
8470 break;
8471
8472 case 6231: hash_type = HASH_TYPE_WHIRLPOOL;
8473 salt_type = SALT_TYPE_EMBEDDED;
8474 attack_exec = ATTACK_EXEC_ON_CPU;
8475 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8476 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS512;
8477 dgst_size = DGST_SIZE_4_8;
8478 parse_func = truecrypt_parse_hash_1k;
8479 sort_by_digest = sort_by_digest_4_8;
8480 opti_type = OPTI_TYPE_ZERO_BYTE;
8481 dgst_pos0 = 0;
8482 dgst_pos1 = 1;
8483 dgst_pos2 = 2;
8484 dgst_pos3 = 3;
8485 break;
8486
8487 case 6232: hash_type = HASH_TYPE_WHIRLPOOL;
8488 salt_type = SALT_TYPE_EMBEDDED;
8489 attack_exec = ATTACK_EXEC_ON_CPU;
8490 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8491 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1024;
8492 dgst_size = DGST_SIZE_4_8;
8493 parse_func = truecrypt_parse_hash_1k;
8494 sort_by_digest = sort_by_digest_4_8;
8495 opti_type = OPTI_TYPE_ZERO_BYTE;
8496 dgst_pos0 = 0;
8497 dgst_pos1 = 1;
8498 dgst_pos2 = 2;
8499 dgst_pos3 = 3;
8500 break;
8501
8502 case 6233: hash_type = HASH_TYPE_WHIRLPOOL;
8503 salt_type = SALT_TYPE_EMBEDDED;
8504 attack_exec = ATTACK_EXEC_ON_CPU;
8505 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8506 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1536;
8507 dgst_size = DGST_SIZE_4_8;
8508 parse_func = truecrypt_parse_hash_1k;
8509 sort_by_digest = sort_by_digest_4_8;
8510 opti_type = OPTI_TYPE_ZERO_BYTE;
8511 dgst_pos0 = 0;
8512 dgst_pos1 = 1;
8513 dgst_pos2 = 2;
8514 dgst_pos3 = 3;
8515 break;
8516
8517 case 6241: hash_type = HASH_TYPE_RIPEMD160;
8518 salt_type = SALT_TYPE_EMBEDDED;
8519 attack_exec = ATTACK_EXEC_ON_CPU;
8520 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8521 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
8522 dgst_size = DGST_SIZE_4_5;
8523 parse_func = truecrypt_parse_hash_1k;
8524 sort_by_digest = sort_by_digest_4_5;
8525 opti_type = OPTI_TYPE_ZERO_BYTE;
8526 dgst_pos0 = 0;
8527 dgst_pos1 = 1;
8528 dgst_pos2 = 2;
8529 dgst_pos3 = 3;
8530 break;
8531
8532 case 6242: hash_type = HASH_TYPE_RIPEMD160;
8533 salt_type = SALT_TYPE_EMBEDDED;
8534 attack_exec = ATTACK_EXEC_ON_CPU;
8535 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8536 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
8537 dgst_size = DGST_SIZE_4_5;
8538 parse_func = truecrypt_parse_hash_1k;
8539 sort_by_digest = sort_by_digest_4_5;
8540 opti_type = OPTI_TYPE_ZERO_BYTE;
8541 dgst_pos0 = 0;
8542 dgst_pos1 = 1;
8543 dgst_pos2 = 2;
8544 dgst_pos3 = 3;
8545 break;
8546
8547 case 6243: hash_type = HASH_TYPE_RIPEMD160;
8548 salt_type = SALT_TYPE_EMBEDDED;
8549 attack_exec = ATTACK_EXEC_ON_CPU;
8550 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8551 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
8552 dgst_size = DGST_SIZE_4_5;
8553 parse_func = truecrypt_parse_hash_1k;
8554 sort_by_digest = sort_by_digest_4_5;
8555 opti_type = OPTI_TYPE_ZERO_BYTE;
8556 dgst_pos0 = 0;
8557 dgst_pos1 = 1;
8558 dgst_pos2 = 2;
8559 dgst_pos3 = 3;
8560 break;
8561
8562 case 6300: hash_type = HASH_TYPE_MD5;
8563 salt_type = SALT_TYPE_EMBEDDED;
8564 attack_exec = ATTACK_EXEC_ON_CPU;
8565 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8566 kern_type = KERN_TYPE_MD5AIX;
8567 dgst_size = DGST_SIZE_4_4;
8568 parse_func = md5aix_parse_hash;
8569 sort_by_digest = sort_by_digest_4_4;
8570 opti_type = OPTI_TYPE_ZERO_BYTE;
8571 dgst_pos0 = 0;
8572 dgst_pos1 = 1;
8573 dgst_pos2 = 2;
8574 dgst_pos3 = 3;
8575 break;
8576
8577 case 6400: hash_type = HASH_TYPE_SHA256;
8578 salt_type = SALT_TYPE_EMBEDDED;
8579 attack_exec = ATTACK_EXEC_ON_CPU;
8580 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8581 kern_type = KERN_TYPE_SHA256AIX;
8582 dgst_size = DGST_SIZE_4_8;
8583 parse_func = sha256aix_parse_hash;
8584 sort_by_digest = sort_by_digest_4_8;
8585 opti_type = OPTI_TYPE_ZERO_BYTE;
8586 dgst_pos0 = 0;
8587 dgst_pos1 = 1;
8588 dgst_pos2 = 2;
8589 dgst_pos3 = 3;
8590 break;
8591
8592 case 6500: hash_type = HASH_TYPE_SHA512;
8593 salt_type = SALT_TYPE_EMBEDDED;
8594 attack_exec = ATTACK_EXEC_ON_CPU;
8595 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8596 kern_type = KERN_TYPE_SHA512AIX;
8597 dgst_size = DGST_SIZE_8_8;
8598 parse_func = sha512aix_parse_hash;
8599 sort_by_digest = sort_by_digest_8_8;
8600 opti_type = OPTI_TYPE_ZERO_BYTE;
8601 dgst_pos0 = 0;
8602 dgst_pos1 = 1;
8603 dgst_pos2 = 2;
8604 dgst_pos3 = 3;
8605 break;
8606
8607 case 6600: hash_type = HASH_TYPE_AES;
8608 salt_type = SALT_TYPE_EMBEDDED;
8609 attack_exec = ATTACK_EXEC_ON_CPU;
8610 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8611 kern_type = KERN_TYPE_AGILEKEY;
8612 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
8613 parse_func = agilekey_parse_hash;
8614 sort_by_digest = sort_by_digest_4_5;
8615 opti_type = OPTI_TYPE_ZERO_BYTE;
8616 dgst_pos0 = 0;
8617 dgst_pos1 = 1;
8618 dgst_pos2 = 2;
8619 dgst_pos3 = 3;
8620 break;
8621
8622 case 6700: hash_type = HASH_TYPE_SHA1;
8623 salt_type = SALT_TYPE_EMBEDDED;
8624 attack_exec = ATTACK_EXEC_ON_CPU;
8625 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8626 kern_type = KERN_TYPE_SHA1AIX;
8627 dgst_size = DGST_SIZE_4_5;
8628 parse_func = sha1aix_parse_hash;
8629 sort_by_digest = sort_by_digest_4_5;
8630 opti_type = OPTI_TYPE_ZERO_BYTE;
8631 dgst_pos0 = 0;
8632 dgst_pos1 = 1;
8633 dgst_pos2 = 2;
8634 dgst_pos3 = 3;
8635 break;
8636
8637 case 6800: hash_type = HASH_TYPE_AES;
8638 salt_type = SALT_TYPE_EMBEDDED;
8639 attack_exec = ATTACK_EXEC_ON_CPU;
8640 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8641 kern_type = KERN_TYPE_LASTPASS;
8642 dgst_size = DGST_SIZE_4_8; // because kernel uses _SHA256_
8643 parse_func = lastpass_parse_hash;
8644 sort_by_digest = sort_by_digest_4_8;
8645 opti_type = OPTI_TYPE_ZERO_BYTE;
8646 dgst_pos0 = 0;
8647 dgst_pos1 = 1;
8648 dgst_pos2 = 2;
8649 dgst_pos3 = 3;
8650 break;
8651
8652 case 6900: hash_type = HASH_TYPE_GOST;
8653 salt_type = SALT_TYPE_NONE;
8654 attack_exec = ATTACK_EXEC_ON_GPU;
8655 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8656 kern_type = KERN_TYPE_GOST;
8657 dgst_size = DGST_SIZE_4_8;
8658 parse_func = gost_parse_hash;
8659 sort_by_digest = sort_by_digest_4_8;
8660 opti_type = OPTI_TYPE_ZERO_BYTE;
8661 dgst_pos0 = 0;
8662 dgst_pos1 = 1;
8663 dgst_pos2 = 2;
8664 dgst_pos3 = 3;
8665 break;
8666
8667 case 7100: hash_type = HASH_TYPE_SHA512;
8668 salt_type = SALT_TYPE_EMBEDDED;
8669 attack_exec = ATTACK_EXEC_ON_CPU;
8670 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8671 kern_type = KERN_TYPE_PBKDF2_SHA512;
8672 dgst_size = DGST_SIZE_8_16;
8673 parse_func = sha512osx_parse_hash;
8674 sort_by_digest = sort_by_digest_8_16;
8675 opti_type = OPTI_TYPE_ZERO_BYTE;
8676 dgst_pos0 = 0;
8677 dgst_pos1 = 1;
8678 dgst_pos2 = 2;
8679 dgst_pos3 = 3;
8680 break;
8681
8682 case 7200: hash_type = HASH_TYPE_SHA512;
8683 salt_type = SALT_TYPE_EMBEDDED;
8684 attack_exec = ATTACK_EXEC_ON_CPU;
8685 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8686 kern_type = KERN_TYPE_PBKDF2_SHA512;
8687 dgst_size = DGST_SIZE_8_16;
8688 parse_func = sha512grub_parse_hash;
8689 sort_by_digest = sort_by_digest_8_16;
8690 opti_type = OPTI_TYPE_ZERO_BYTE;
8691 dgst_pos0 = 0;
8692 dgst_pos1 = 1;
8693 dgst_pos2 = 2;
8694 dgst_pos3 = 3;
8695 break;
8696
8697 case 7300: hash_type = HASH_TYPE_SHA1;
8698 salt_type = SALT_TYPE_EMBEDDED;
8699 attack_exec = ATTACK_EXEC_ON_GPU;
8700 opts_type = OPTS_TYPE_PT_GENERATE_BE
8701 | OPTS_TYPE_ST_ADD80
8702 | OPTS_TYPE_ST_ADDBITS15;
8703 kern_type = KERN_TYPE_RAKP;
8704 dgst_size = DGST_SIZE_4_5;
8705 parse_func = rakp_parse_hash;
8706 sort_by_digest = sort_by_digest_4_5;
8707 opti_type = OPTI_TYPE_ZERO_BYTE
8708 | OPTI_TYPE_NOT_ITERATED;
8709 dgst_pos0 = 3;
8710 dgst_pos1 = 4;
8711 dgst_pos2 = 2;
8712 dgst_pos3 = 1;
8713 break;
8714
8715 case 7400: hash_type = HASH_TYPE_SHA256;
8716 salt_type = SALT_TYPE_EMBEDDED;
8717 attack_exec = ATTACK_EXEC_ON_CPU;
8718 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8719 kern_type = KERN_TYPE_SHA256CRYPT;
8720 dgst_size = DGST_SIZE_4_8;
8721 parse_func = sha256crypt_parse_hash;
8722 sort_by_digest = sort_by_digest_4_8;
8723 opti_type = OPTI_TYPE_ZERO_BYTE;
8724 dgst_pos0 = 0;
8725 dgst_pos1 = 1;
8726 dgst_pos2 = 2;
8727 dgst_pos3 = 3;
8728 break;
8729
8730 case 7500: hash_type = HASH_TYPE_KRB5PA;
8731 salt_type = SALT_TYPE_EMBEDDED;
8732 attack_exec = ATTACK_EXEC_ON_GPU;
8733 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8734 kern_type = KERN_TYPE_KRB5PA;
8735 dgst_size = DGST_SIZE_4_4;
8736 parse_func = krb5pa_parse_hash;
8737 sort_by_digest = sort_by_digest_4_4;
8738 opti_type = OPTI_TYPE_ZERO_BYTE
8739 | OPTI_TYPE_NOT_ITERATED;
8740 dgst_pos0 = 3;
8741 dgst_pos1 = 7;
8742 dgst_pos2 = 2;
8743 dgst_pos3 = 6;
8744 break;
8745
8746 case 7600: hash_type = HASH_TYPE_SHA1;
8747 salt_type = SALT_TYPE_INTERN;
8748 attack_exec = ATTACK_EXEC_ON_GPU;
8749 opts_type = OPTS_TYPE_PT_GENERATE_BE
8750 | OPTS_TYPE_PT_ADD80
8751 | OPTS_TYPE_PT_ADDBITS15;
8752 kern_type = KERN_TYPE_SHA1_SLT_SHA1_PW;
8753 dgst_size = DGST_SIZE_4_5;
8754 parse_func = redmine_parse_hash;
8755 sort_by_digest = sort_by_digest_4_5;
8756 opti_type = OPTI_TYPE_ZERO_BYTE
8757 | OPTI_TYPE_PRECOMPUTE_INIT
8758 | OPTI_TYPE_EARLY_SKIP
8759 | OPTI_TYPE_NOT_ITERATED
8760 | OPTI_TYPE_PREPENDED_SALT;
8761 dgst_pos0 = 3;
8762 dgst_pos1 = 4;
8763 dgst_pos2 = 2;
8764 dgst_pos3 = 1;
8765 break;
8766
8767 case 7700: hash_type = HASH_TYPE_SAPB;
8768 salt_type = SALT_TYPE_EMBEDDED;
8769 attack_exec = ATTACK_EXEC_ON_GPU;
8770 opts_type = OPTS_TYPE_PT_GENERATE_LE
8771 | OPTS_TYPE_PT_UPPER
8772 | OPTS_TYPE_ST_UPPER;
8773 kern_type = KERN_TYPE_SAPB;
8774 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8775 parse_func = sapb_parse_hash;
8776 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8777 opti_type = OPTI_TYPE_ZERO_BYTE
8778 | OPTI_TYPE_PRECOMPUTE_INIT
8779 | OPTI_TYPE_NOT_ITERATED;
8780 dgst_pos0 = 0;
8781 dgst_pos1 = 1;
8782 dgst_pos2 = 2;
8783 dgst_pos3 = 3;
8784 break;
8785
8786 case 7800: hash_type = HASH_TYPE_SAPG;
8787 salt_type = SALT_TYPE_EMBEDDED;
8788 attack_exec = ATTACK_EXEC_ON_GPU;
8789 opts_type = OPTS_TYPE_PT_GENERATE_BE
8790 | OPTS_TYPE_ST_ADD80
8791 | OPTS_TYPE_ST_UPPER;
8792 kern_type = KERN_TYPE_SAPG;
8793 dgst_size = DGST_SIZE_4_5;
8794 parse_func = sapg_parse_hash;
8795 sort_by_digest = sort_by_digest_4_5;
8796 opti_type = OPTI_TYPE_ZERO_BYTE
8797 | OPTI_TYPE_PRECOMPUTE_INIT
8798 | OPTI_TYPE_NOT_ITERATED;
8799 dgst_pos0 = 3;
8800 dgst_pos1 = 4;
8801 dgst_pos2 = 2;
8802 dgst_pos3 = 1;
8803 break;
8804
8805 case 7900: hash_type = HASH_TYPE_SHA512;
8806 salt_type = SALT_TYPE_EMBEDDED;
8807 attack_exec = ATTACK_EXEC_ON_CPU;
8808 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8809 kern_type = KERN_TYPE_DRUPAL7;
8810 dgst_size = DGST_SIZE_8_8;
8811 parse_func = drupal7_parse_hash;
8812 sort_by_digest = sort_by_digest_8_8;
8813 opti_type = OPTI_TYPE_ZERO_BYTE;
8814 dgst_pos0 = 0;
8815 dgst_pos1 = 1;
8816 dgst_pos2 = 2;
8817 dgst_pos3 = 3;
8818 break;
8819
8820 case 8000: hash_type = HASH_TYPE_SHA256;
8821 salt_type = SALT_TYPE_EMBEDDED;
8822 attack_exec = ATTACK_EXEC_ON_GPU;
8823 opts_type = OPTS_TYPE_PT_GENERATE_BE
8824 | OPTS_TYPE_PT_UNICODE
8825 | OPTS_TYPE_ST_ADD80
8826 | OPTS_TYPE_ST_HEX;
8827 kern_type = KERN_TYPE_SYBASEASE;
8828 dgst_size = DGST_SIZE_4_8;
8829 parse_func = sybasease_parse_hash;
8830 sort_by_digest = sort_by_digest_4_8;
8831 opti_type = OPTI_TYPE_ZERO_BYTE
8832 | OPTI_TYPE_PRECOMPUTE_INIT
8833 | OPTI_TYPE_EARLY_SKIP
8834 | OPTI_TYPE_NOT_ITERATED
8835 | OPTI_TYPE_RAW_HASH;
8836 dgst_pos0 = 3;
8837 dgst_pos1 = 7;
8838 dgst_pos2 = 2;
8839 dgst_pos3 = 6;
8840 break;
8841
8842 case 8100: hash_type = HASH_TYPE_SHA1;
8843 salt_type = SALT_TYPE_EMBEDDED;
8844 attack_exec = ATTACK_EXEC_ON_GPU;
8845 opts_type = OPTS_TYPE_PT_GENERATE_BE;
8846 kern_type = KERN_TYPE_NETSCALER;
8847 dgst_size = DGST_SIZE_4_5;
8848 parse_func = netscaler_parse_hash;
8849 sort_by_digest = sort_by_digest_4_5;
8850 opti_type = OPTI_TYPE_ZERO_BYTE
8851 | OPTI_TYPE_PRECOMPUTE_INIT
8852 | OPTI_TYPE_PRECOMPUTE_MERKLE
8853 | OPTI_TYPE_EARLY_SKIP
8854 | OPTI_TYPE_NOT_ITERATED
8855 | OPTI_TYPE_PREPENDED_SALT
8856 | OPTI_TYPE_RAW_HASH;
8857 dgst_pos0 = 3;
8858 dgst_pos1 = 4;
8859 dgst_pos2 = 2;
8860 dgst_pos3 = 1;
8861 break;
8862
8863 case 8200: hash_type = HASH_TYPE_SHA256;
8864 salt_type = SALT_TYPE_EMBEDDED;
8865 attack_exec = ATTACK_EXEC_ON_CPU;
8866 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8867 kern_type = KERN_TYPE_CLOUDKEY;
8868 dgst_size = DGST_SIZE_4_8;
8869 parse_func = cloudkey_parse_hash;
8870 sort_by_digest = sort_by_digest_4_8;
8871 opti_type = OPTI_TYPE_ZERO_BYTE;
8872 dgst_pos0 = 0;
8873 dgst_pos1 = 1;
8874 dgst_pos2 = 2;
8875 dgst_pos3 = 3;
8876 break;
8877
8878 case 8300: hash_type = HASH_TYPE_SHA1;
8879 salt_type = SALT_TYPE_EMBEDDED;
8880 attack_exec = ATTACK_EXEC_ON_GPU;
8881 opts_type = OPTS_TYPE_PT_GENERATE_LE
8882 | OPTS_TYPE_ST_HEX
8883 | OPTS_TYPE_ST_ADD80;
8884 kern_type = KERN_TYPE_NSEC3;
8885 dgst_size = DGST_SIZE_4_5;
8886 parse_func = nsec3_parse_hash;
8887 sort_by_digest = sort_by_digest_4_5;
8888 opti_type = OPTI_TYPE_ZERO_BYTE;
8889 dgst_pos0 = 3;
8890 dgst_pos1 = 4;
8891 dgst_pos2 = 2;
8892 dgst_pos3 = 1;
8893 break;
8894
8895 case 8400: hash_type = HASH_TYPE_SHA1;
8896 salt_type = SALT_TYPE_INTERN;
8897 attack_exec = ATTACK_EXEC_ON_GPU;
8898 opts_type = OPTS_TYPE_PT_GENERATE_BE
8899 | OPTS_TYPE_PT_ADD80
8900 | OPTS_TYPE_PT_ADDBITS15;
8901 kern_type = KERN_TYPE_WBB3;
8902 dgst_size = DGST_SIZE_4_5;
8903 parse_func = wbb3_parse_hash;
8904 sort_by_digest = sort_by_digest_4_5;
8905 opti_type = OPTI_TYPE_ZERO_BYTE
8906 | OPTI_TYPE_PRECOMPUTE_INIT
8907 | OPTI_TYPE_NOT_ITERATED;
8908 dgst_pos0 = 3;
8909 dgst_pos1 = 4;
8910 dgst_pos2 = 2;
8911 dgst_pos3 = 1;
8912 break;
8913
8914 case 8500: hash_type = HASH_TYPE_DESRACF;
8915 salt_type = SALT_TYPE_EMBEDDED;
8916 attack_exec = ATTACK_EXEC_ON_GPU;
8917 opts_type = OPTS_TYPE_PT_GENERATE_LE
8918 | OPTS_TYPE_ST_UPPER;
8919 kern_type = KERN_TYPE_RACF;
8920 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8921 parse_func = racf_parse_hash;
8922 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8923 opti_type = OPTI_TYPE_ZERO_BYTE
8924 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8925 dgst_pos0 = 0;
8926 dgst_pos1 = 1;
8927 dgst_pos2 = 2;
8928 dgst_pos3 = 3;
8929 break;
8930
8931 case 8600: hash_type = HASH_TYPE_LOTUS5;
8932 salt_type = SALT_TYPE_NONE;
8933 attack_exec = ATTACK_EXEC_ON_GPU;
8934 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8935 kern_type = KERN_TYPE_LOTUS5;
8936 dgst_size = DGST_SIZE_4_4;
8937 parse_func = lotus5_parse_hash;
8938 sort_by_digest = sort_by_digest_4_4;
8939 opti_type = OPTI_TYPE_EARLY_SKIP
8940 | OPTI_TYPE_NOT_ITERATED
8941 | OPTI_TYPE_NOT_SALTED
8942 | OPTI_TYPE_RAW_HASH;
8943 dgst_pos0 = 0;
8944 dgst_pos1 = 1;
8945 dgst_pos2 = 2;
8946 dgst_pos3 = 3;
8947 break;
8948
8949 case 8700: hash_type = HASH_TYPE_LOTUS6;
8950 salt_type = SALT_TYPE_EMBEDDED;
8951 attack_exec = ATTACK_EXEC_ON_GPU;
8952 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8953 kern_type = KERN_TYPE_LOTUS6;
8954 dgst_size = DGST_SIZE_4_4;
8955 parse_func = lotus6_parse_hash;
8956 sort_by_digest = sort_by_digest_4_4;
8957 opti_type = OPTI_TYPE_EARLY_SKIP
8958 | OPTI_TYPE_NOT_ITERATED
8959 | OPTI_TYPE_RAW_HASH;
8960 dgst_pos0 = 0;
8961 dgst_pos1 = 1;
8962 dgst_pos2 = 2;
8963 dgst_pos3 = 3;
8964 break;
8965
8966 case 8800: hash_type = HASH_TYPE_ANDROIDFDE;
8967 salt_type = SALT_TYPE_EMBEDDED;
8968 attack_exec = ATTACK_EXEC_ON_CPU;
8969 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8970 kern_type = KERN_TYPE_ANDROIDFDE;
8971 dgst_size = DGST_SIZE_4_4;
8972 parse_func = androidfde_parse_hash;
8973 sort_by_digest = sort_by_digest_4_4;
8974 opti_type = OPTI_TYPE_ZERO_BYTE;
8975 dgst_pos0 = 0;
8976 dgst_pos1 = 1;
8977 dgst_pos2 = 2;
8978 dgst_pos3 = 3;
8979 break;
8980
8981 case 8900: hash_type = HASH_TYPE_SCRYPT;
8982 salt_type = SALT_TYPE_EMBEDDED;
8983 attack_exec = ATTACK_EXEC_ON_CPU;
8984 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8985 kern_type = KERN_TYPE_SCRYPT;
8986 dgst_size = DGST_SIZE_4_8;
8987 parse_func = scrypt_parse_hash;
8988 sort_by_digest = sort_by_digest_4_8;
8989 opti_type = OPTI_TYPE_ZERO_BYTE;
8990 dgst_pos0 = 0;
8991 dgst_pos1 = 1;
8992 dgst_pos2 = 2;
8993 dgst_pos3 = 3;
8994 break;
8995
8996 case 9000: hash_type = HASH_TYPE_SHA1;
8997 salt_type = SALT_TYPE_EMBEDDED;
8998 attack_exec = ATTACK_EXEC_ON_CPU;
8999 opts_type = OPTS_TYPE_PT_GENERATE_LE
9000 | OPTS_TYPE_ST_GENERATE_LE;
9001 kern_type = KERN_TYPE_PSAFE2;
9002 dgst_size = DGST_SIZE_4_5;
9003 parse_func = psafe2_parse_hash;
9004 sort_by_digest = sort_by_digest_4_5;
9005 opti_type = OPTI_TYPE_ZERO_BYTE;
9006 dgst_pos0 = 0;
9007 dgst_pos1 = 1;
9008 dgst_pos2 = 2;
9009 dgst_pos3 = 3;
9010 break;
9011
9012 case 9100: hash_type = HASH_TYPE_LOTUS8;
9013 salt_type = SALT_TYPE_EMBEDDED;
9014 attack_exec = ATTACK_EXEC_ON_CPU;
9015 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9016 kern_type = KERN_TYPE_LOTUS8;
9017 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9018 parse_func = lotus8_parse_hash;
9019 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9020 opti_type = OPTI_TYPE_ZERO_BYTE;
9021 dgst_pos0 = 0;
9022 dgst_pos1 = 1;
9023 dgst_pos2 = 2;
9024 dgst_pos3 = 3;
9025 break;
9026
9027 case 9200: hash_type = HASH_TYPE_SHA256;
9028 salt_type = SALT_TYPE_EMBEDDED;
9029 attack_exec = ATTACK_EXEC_ON_CPU;
9030 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9031 kern_type = KERN_TYPE_PBKDF2_SHA256;
9032 dgst_size = DGST_SIZE_4_32;
9033 parse_func = cisco8_parse_hash;
9034 sort_by_digest = sort_by_digest_4_32;
9035 opti_type = OPTI_TYPE_ZERO_BYTE;
9036 dgst_pos0 = 0;
9037 dgst_pos1 = 1;
9038 dgst_pos2 = 2;
9039 dgst_pos3 = 3;
9040 break;
9041
9042 case 9300: hash_type = HASH_TYPE_SCRYPT;
9043 salt_type = SALT_TYPE_EMBEDDED;
9044 attack_exec = ATTACK_EXEC_ON_CPU;
9045 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9046 kern_type = KERN_TYPE_SCRYPT;
9047 dgst_size = DGST_SIZE_4_8;
9048 parse_func = cisco9_parse_hash;
9049 sort_by_digest = sort_by_digest_4_8;
9050 opti_type = OPTI_TYPE_ZERO_BYTE;
9051 dgst_pos0 = 0;
9052 dgst_pos1 = 1;
9053 dgst_pos2 = 2;
9054 dgst_pos3 = 3;
9055 break;
9056
9057 case 9400: hash_type = HASH_TYPE_OFFICE2007;
9058 salt_type = SALT_TYPE_EMBEDDED;
9059 attack_exec = ATTACK_EXEC_ON_CPU;
9060 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9061 kern_type = KERN_TYPE_OFFICE2007;
9062 dgst_size = DGST_SIZE_4_4;
9063 parse_func = office2007_parse_hash;
9064 sort_by_digest = sort_by_digest_4_4;
9065 opti_type = OPTI_TYPE_ZERO_BYTE;
9066 dgst_pos0 = 0;
9067 dgst_pos1 = 1;
9068 dgst_pos2 = 2;
9069 dgst_pos3 = 3;
9070 break;
9071
9072 case 9500: hash_type = HASH_TYPE_OFFICE2010;
9073 salt_type = SALT_TYPE_EMBEDDED;
9074 attack_exec = ATTACK_EXEC_ON_CPU;
9075 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9076 kern_type = KERN_TYPE_OFFICE2010;
9077 dgst_size = DGST_SIZE_4_4;
9078 parse_func = office2010_parse_hash;
9079 sort_by_digest = sort_by_digest_4_4;
9080 opti_type = OPTI_TYPE_ZERO_BYTE;
9081 dgst_pos0 = 0;
9082 dgst_pos1 = 1;
9083 dgst_pos2 = 2;
9084 dgst_pos3 = 3;
9085 break;
9086
9087 case 9600: hash_type = HASH_TYPE_OFFICE2013;
9088 salt_type = SALT_TYPE_EMBEDDED;
9089 attack_exec = ATTACK_EXEC_ON_CPU;
9090 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9091 kern_type = KERN_TYPE_OFFICE2013;
9092 dgst_size = DGST_SIZE_4_4;
9093 parse_func = office2013_parse_hash;
9094 sort_by_digest = sort_by_digest_4_4;
9095 opti_type = OPTI_TYPE_ZERO_BYTE;
9096 dgst_pos0 = 0;
9097 dgst_pos1 = 1;
9098 dgst_pos2 = 2;
9099 dgst_pos3 = 3;
9100 break;
9101
9102 case 9700: hash_type = HASH_TYPE_OLDOFFICE01;
9103 salt_type = SALT_TYPE_EMBEDDED;
9104 attack_exec = ATTACK_EXEC_ON_GPU;
9105 opts_type = OPTS_TYPE_PT_GENERATE_LE
9106 | OPTS_TYPE_PT_ADD80
9107 | OPTS_TYPE_PT_UNICODE;
9108 kern_type = KERN_TYPE_OLDOFFICE01;
9109 dgst_size = DGST_SIZE_4_4;
9110 parse_func = oldoffice01_parse_hash;
9111 sort_by_digest = sort_by_digest_4_4;
9112 opti_type = OPTI_TYPE_ZERO_BYTE
9113 | OPTI_TYPE_PRECOMPUTE_INIT
9114 | OPTI_TYPE_NOT_ITERATED;
9115 dgst_pos0 = 0;
9116 dgst_pos1 = 1;
9117 dgst_pos2 = 2;
9118 dgst_pos3 = 3;
9119 break;
9120
9121 case 9710: hash_type = HASH_TYPE_OLDOFFICE01;
9122 salt_type = SALT_TYPE_EMBEDDED;
9123 attack_exec = ATTACK_EXEC_ON_GPU;
9124 opts_type = OPTS_TYPE_PT_GENERATE_LE
9125 | OPTS_TYPE_PT_ADD80;
9126 kern_type = KERN_TYPE_OLDOFFICE01CM1;
9127 dgst_size = DGST_SIZE_4_4;
9128 parse_func = oldoffice01cm1_parse_hash;
9129 sort_by_digest = sort_by_digest_4_4;
9130 opti_type = OPTI_TYPE_ZERO_BYTE
9131 | OPTI_TYPE_PRECOMPUTE_INIT
9132 | OPTI_TYPE_NOT_ITERATED;
9133 dgst_pos0 = 0;
9134 dgst_pos1 = 1;
9135 dgst_pos2 = 2;
9136 dgst_pos3 = 3;
9137 break;
9138
9139 case 9720: hash_type = HASH_TYPE_OLDOFFICE01;
9140 salt_type = SALT_TYPE_EMBEDDED;
9141 attack_exec = ATTACK_EXEC_ON_GPU;
9142 opts_type = OPTS_TYPE_PT_GENERATE_LE
9143 | OPTS_TYPE_PT_ADD80
9144 | OPTS_TYPE_PT_UNICODE
9145 | OPTS_TYPE_PT_NEVERCRACK;
9146 kern_type = KERN_TYPE_OLDOFFICE01CM2;
9147 dgst_size = DGST_SIZE_4_4;
9148 parse_func = oldoffice01cm2_parse_hash;
9149 sort_by_digest = sort_by_digest_4_4;
9150 opti_type = OPTI_TYPE_ZERO_BYTE
9151 | OPTI_TYPE_PRECOMPUTE_INIT
9152 | OPTI_TYPE_NOT_ITERATED;
9153 dgst_pos0 = 0;
9154 dgst_pos1 = 1;
9155 dgst_pos2 = 2;
9156 dgst_pos3 = 3;
9157 break;
9158
9159 case 9800: hash_type = HASH_TYPE_OLDOFFICE34;
9160 salt_type = SALT_TYPE_EMBEDDED;
9161 attack_exec = ATTACK_EXEC_ON_GPU;
9162 opts_type = OPTS_TYPE_PT_GENERATE_BE
9163 | OPTS_TYPE_PT_ADD80
9164 | OPTS_TYPE_PT_UNICODE;
9165 kern_type = KERN_TYPE_OLDOFFICE34;
9166 dgst_size = DGST_SIZE_4_4;
9167 parse_func = oldoffice34_parse_hash;
9168 sort_by_digest = sort_by_digest_4_4;
9169 opti_type = OPTI_TYPE_ZERO_BYTE
9170 | OPTI_TYPE_PRECOMPUTE_INIT
9171 | OPTI_TYPE_NOT_ITERATED;
9172 dgst_pos0 = 0;
9173 dgst_pos1 = 1;
9174 dgst_pos2 = 2;
9175 dgst_pos3 = 3;
9176 break;
9177
9178 case 9810: hash_type = HASH_TYPE_OLDOFFICE34;
9179 salt_type = SALT_TYPE_EMBEDDED;
9180 attack_exec = ATTACK_EXEC_ON_GPU;
9181 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9182 kern_type = KERN_TYPE_OLDOFFICE34CM1;
9183 dgst_size = DGST_SIZE_4_4;
9184 parse_func = oldoffice34cm1_parse_hash;
9185 sort_by_digest = sort_by_digest_4_4;
9186 opti_type = OPTI_TYPE_ZERO_BYTE
9187 | OPTI_TYPE_PRECOMPUTE_INIT
9188 | OPTI_TYPE_NOT_ITERATED;
9189 dgst_pos0 = 0;
9190 dgst_pos1 = 1;
9191 dgst_pos2 = 2;
9192 dgst_pos3 = 3;
9193 break;
9194
9195 case 9820: hash_type = HASH_TYPE_OLDOFFICE34;
9196 salt_type = SALT_TYPE_EMBEDDED;
9197 attack_exec = ATTACK_EXEC_ON_GPU;
9198 opts_type = OPTS_TYPE_PT_GENERATE_BE
9199 | OPTS_TYPE_PT_ADD80
9200 | OPTS_TYPE_PT_UNICODE
9201 | OPTS_TYPE_PT_NEVERCRACK;
9202 kern_type = KERN_TYPE_OLDOFFICE34CM2;
9203 dgst_size = DGST_SIZE_4_4;
9204 parse_func = oldoffice34cm2_parse_hash;
9205 sort_by_digest = sort_by_digest_4_4;
9206 opti_type = OPTI_TYPE_ZERO_BYTE
9207 | OPTI_TYPE_PRECOMPUTE_INIT
9208 | OPTI_TYPE_NOT_ITERATED;
9209 dgst_pos0 = 0;
9210 dgst_pos1 = 1;
9211 dgst_pos2 = 2;
9212 dgst_pos3 = 3;
9213 break;
9214
9215 case 9900: hash_type = HASH_TYPE_MD5;
9216 salt_type = SALT_TYPE_NONE;
9217 attack_exec = ATTACK_EXEC_ON_GPU;
9218 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9219 kern_type = KERN_TYPE_RADMIN2;
9220 dgst_size = DGST_SIZE_4_4;
9221 parse_func = radmin2_parse_hash;
9222 sort_by_digest = sort_by_digest_4_4;
9223 opti_type = OPTI_TYPE_ZERO_BYTE
9224 | OPTI_TYPE_PRECOMPUTE_INIT
9225 | OPTI_TYPE_EARLY_SKIP
9226 | OPTI_TYPE_NOT_ITERATED
9227 | OPTI_TYPE_NOT_SALTED;
9228 dgst_pos0 = 0;
9229 dgst_pos1 = 3;
9230 dgst_pos2 = 2;
9231 dgst_pos3 = 1;
9232 break;
9233
9234 case 10000: hash_type = HASH_TYPE_SHA256;
9235 salt_type = SALT_TYPE_EMBEDDED;
9236 attack_exec = ATTACK_EXEC_ON_CPU;
9237 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9238 kern_type = KERN_TYPE_PBKDF2_SHA256;
9239 dgst_size = DGST_SIZE_4_32;
9240 parse_func = djangopbkdf2_parse_hash;
9241 sort_by_digest = sort_by_digest_4_32;
9242 opti_type = OPTI_TYPE_ZERO_BYTE;
9243 dgst_pos0 = 0;
9244 dgst_pos1 = 1;
9245 dgst_pos2 = 2;
9246 dgst_pos3 = 3;
9247 break;
9248
9249 case 10100: hash_type = HASH_TYPE_SIPHASH;
9250 salt_type = SALT_TYPE_EMBEDDED;
9251 attack_exec = ATTACK_EXEC_ON_GPU;
9252 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9253 kern_type = KERN_TYPE_SIPHASH;
9254 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9255 parse_func = siphash_parse_hash;
9256 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9257 opti_type = OPTI_TYPE_ZERO_BYTE
9258 | OPTI_TYPE_NOT_ITERATED
9259 | OPTI_TYPE_RAW_HASH;
9260 dgst_pos0 = 0;
9261 dgst_pos1 = 1;
9262 dgst_pos2 = 2;
9263 dgst_pos3 = 3;
9264 break;
9265
9266 case 10200: hash_type = HASH_TYPE_MD5;
9267 salt_type = SALT_TYPE_EMBEDDED;
9268 attack_exec = ATTACK_EXEC_ON_GPU;
9269 opts_type = OPTS_TYPE_PT_GENERATE_LE
9270 | OPTS_TYPE_ST_ADD80
9271 | OPTS_TYPE_ST_ADDBITS14;
9272 kern_type = KERN_TYPE_HMACMD5_PW;
9273 dgst_size = DGST_SIZE_4_4;
9274 parse_func = crammd5_parse_hash;
9275 sort_by_digest = sort_by_digest_4_4;
9276 opti_type = OPTI_TYPE_ZERO_BYTE
9277 | OPTI_TYPE_NOT_ITERATED;
9278 dgst_pos0 = 0;
9279 dgst_pos1 = 3;
9280 dgst_pos2 = 2;
9281 dgst_pos3 = 1;
9282 break;
9283
9284 case 10300: hash_type = HASH_TYPE_SHA1;
9285 salt_type = SALT_TYPE_EMBEDDED;
9286 attack_exec = ATTACK_EXEC_ON_CPU;
9287 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9288 kern_type = KERN_TYPE_SAPH_SHA1;
9289 dgst_size = DGST_SIZE_4_5;
9290 parse_func = saph_sha1_parse_hash;
9291 sort_by_digest = sort_by_digest_4_5;
9292 opti_type = OPTI_TYPE_ZERO_BYTE;
9293 dgst_pos0 = 0;
9294 dgst_pos1 = 1;
9295 dgst_pos2 = 2;
9296 dgst_pos3 = 3;
9297 break;
9298
9299 case 10400: hash_type = HASH_TYPE_PDFU16;
9300 salt_type = SALT_TYPE_EMBEDDED;
9301 attack_exec = ATTACK_EXEC_ON_GPU;
9302 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9303 kern_type = KERN_TYPE_PDF11;
9304 dgst_size = DGST_SIZE_4_4;
9305 parse_func = pdf11_parse_hash;
9306 sort_by_digest = sort_by_digest_4_4;
9307 opti_type = OPTI_TYPE_ZERO_BYTE
9308 | OPTI_TYPE_NOT_ITERATED;
9309 dgst_pos0 = 0;
9310 dgst_pos1 = 1;
9311 dgst_pos2 = 2;
9312 dgst_pos3 = 3;
9313 break;
9314
9315 case 10410: hash_type = HASH_TYPE_PDFU16;
9316 salt_type = SALT_TYPE_EMBEDDED;
9317 attack_exec = ATTACK_EXEC_ON_GPU;
9318 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9319 kern_type = KERN_TYPE_PDF11CM1;
9320 dgst_size = DGST_SIZE_4_4;
9321 parse_func = pdf11cm1_parse_hash;
9322 sort_by_digest = sort_by_digest_4_4;
9323 opti_type = OPTI_TYPE_ZERO_BYTE
9324 | OPTI_TYPE_NOT_ITERATED;
9325 dgst_pos0 = 0;
9326 dgst_pos1 = 1;
9327 dgst_pos2 = 2;
9328 dgst_pos3 = 3;
9329 break;
9330
9331 case 10420: hash_type = HASH_TYPE_PDFU16;
9332 salt_type = SALT_TYPE_EMBEDDED;
9333 attack_exec = ATTACK_EXEC_ON_GPU;
9334 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9335 kern_type = KERN_TYPE_PDF11CM2;
9336 dgst_size = DGST_SIZE_4_4;
9337 parse_func = pdf11cm2_parse_hash;
9338 sort_by_digest = sort_by_digest_4_4;
9339 opti_type = OPTI_TYPE_ZERO_BYTE
9340 | OPTI_TYPE_NOT_ITERATED;
9341 dgst_pos0 = 0;
9342 dgst_pos1 = 1;
9343 dgst_pos2 = 2;
9344 dgst_pos3 = 3;
9345 break;
9346
9347 case 10500: hash_type = HASH_TYPE_PDFU16;
9348 salt_type = SALT_TYPE_EMBEDDED;
9349 attack_exec = ATTACK_EXEC_ON_CPU;
9350 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9351 kern_type = KERN_TYPE_PDF14;
9352 dgst_size = DGST_SIZE_4_4;
9353 parse_func = pdf14_parse_hash;
9354 sort_by_digest = sort_by_digest_4_4;
9355 opti_type = OPTI_TYPE_ZERO_BYTE
9356 | OPTI_TYPE_NOT_ITERATED;
9357 dgst_pos0 = 0;
9358 dgst_pos1 = 1;
9359 dgst_pos2 = 2;
9360 dgst_pos3 = 3;
9361 break;
9362
9363 case 10600: hash_type = HASH_TYPE_SHA256;
9364 salt_type = SALT_TYPE_EMBEDDED;
9365 attack_exec = ATTACK_EXEC_ON_GPU;
9366 opts_type = OPTS_TYPE_PT_GENERATE_BE
9367 | OPTS_TYPE_ST_ADD80
9368 | OPTS_TYPE_ST_ADDBITS15
9369 | OPTS_TYPE_HASH_COPY;
9370 kern_type = KERN_TYPE_SHA256_PWSLT;
9371 dgst_size = DGST_SIZE_4_8;
9372 parse_func = pdf17l3_parse_hash;
9373 sort_by_digest = sort_by_digest_4_8;
9374 opti_type = OPTI_TYPE_ZERO_BYTE
9375 | OPTI_TYPE_PRECOMPUTE_INIT
9376 | OPTI_TYPE_PRECOMPUTE_MERKLE
9377 | OPTI_TYPE_EARLY_SKIP
9378 | OPTI_TYPE_NOT_ITERATED
9379 | OPTI_TYPE_APPENDED_SALT
9380 | OPTI_TYPE_RAW_HASH;
9381 dgst_pos0 = 3;
9382 dgst_pos1 = 7;
9383 dgst_pos2 = 2;
9384 dgst_pos3 = 6;
9385 break;
9386
9387 case 10700: hash_type = HASH_TYPE_PDFU32;
9388 salt_type = SALT_TYPE_EMBEDDED;
9389 attack_exec = ATTACK_EXEC_ON_CPU;
9390 opts_type = OPTS_TYPE_PT_GENERATE_LE
9391 | OPTS_TYPE_HASH_COPY;
9392 kern_type = KERN_TYPE_PDF17L8;
9393 dgst_size = DGST_SIZE_4_8;
9394 parse_func = pdf17l8_parse_hash;
9395 sort_by_digest = sort_by_digest_4_8;
9396 opti_type = OPTI_TYPE_ZERO_BYTE
9397 | OPTI_TYPE_NOT_ITERATED;
9398 dgst_pos0 = 0;
9399 dgst_pos1 = 1;
9400 dgst_pos2 = 2;
9401 dgst_pos3 = 3;
9402 break;
9403
9404 case 10800: hash_type = HASH_TYPE_SHA384;
9405 salt_type = SALT_TYPE_NONE;
9406 attack_exec = ATTACK_EXEC_ON_GPU;
9407 opts_type = OPTS_TYPE_PT_GENERATE_BE
9408 | OPTS_TYPE_PT_ADD80
9409 | OPTS_TYPE_PT_ADDBITS15;
9410 kern_type = KERN_TYPE_SHA384;
9411 dgst_size = DGST_SIZE_8_8;
9412 parse_func = sha384_parse_hash;
9413 sort_by_digest = sort_by_digest_8_8;
9414 opti_type = OPTI_TYPE_ZERO_BYTE
9415 | OPTI_TYPE_PRECOMPUTE_INIT
9416 | OPTI_TYPE_PRECOMPUTE_MERKLE
9417 | OPTI_TYPE_EARLY_SKIP
9418 | OPTI_TYPE_NOT_ITERATED
9419 | OPTI_TYPE_NOT_SALTED
9420 | OPTI_TYPE_RAW_HASH;
9421 dgst_pos0 = 6;
9422 dgst_pos1 = 7;
9423 dgst_pos2 = 4;
9424 dgst_pos3 = 5;
9425 break;
9426
9427 case 10900: hash_type = HASH_TYPE_PBKDF2_SHA256;
9428 salt_type = SALT_TYPE_EMBEDDED;
9429 attack_exec = ATTACK_EXEC_ON_CPU;
9430 opts_type = OPTS_TYPE_PT_GENERATE_LE
9431 | OPTS_TYPE_ST_BASE64
9432 | OPTS_TYPE_HASH_COPY;
9433 kern_type = KERN_TYPE_PBKDF2_SHA256;
9434 dgst_size = DGST_SIZE_4_32;
9435 parse_func = pbkdf2_sha256_parse_hash;
9436 sort_by_digest = sort_by_digest_4_32;
9437 opti_type = OPTI_TYPE_ZERO_BYTE;
9438 dgst_pos0 = 0;
9439 dgst_pos1 = 1;
9440 dgst_pos2 = 2;
9441 dgst_pos3 = 3;
9442 break;
9443
9444 case 11000: hash_type = HASH_TYPE_MD5;
9445 salt_type = SALT_TYPE_INTERN;
9446 attack_exec = ATTACK_EXEC_ON_GPU;
9447 opts_type = OPTS_TYPE_PT_GENERATE_LE
9448 | OPTS_TYPE_PT_ADD80;
9449 kern_type = KERN_TYPE_PRESTASHOP;
9450 dgst_size = DGST_SIZE_4_4;
9451 parse_func = prestashop_parse_hash;
9452 sort_by_digest = sort_by_digest_4_4;
9453 opti_type = OPTI_TYPE_ZERO_BYTE
9454 | OPTI_TYPE_PRECOMPUTE_INIT
9455 | OPTI_TYPE_NOT_ITERATED
9456 | OPTI_TYPE_PREPENDED_SALT;
9457 dgst_pos0 = 0;
9458 dgst_pos1 = 3;
9459 dgst_pos2 = 2;
9460 dgst_pos3 = 1;
9461 break;
9462
9463 case 11100: hash_type = HASH_TYPE_MD5;
9464 salt_type = SALT_TYPE_EMBEDDED;
9465 attack_exec = ATTACK_EXEC_ON_GPU;
9466 opts_type = OPTS_TYPE_PT_GENERATE_LE
9467 | OPTS_TYPE_ST_ADD80;
9468 kern_type = KERN_TYPE_POSTGRESQL_AUTH;
9469 dgst_size = DGST_SIZE_4_4;
9470 parse_func = postgresql_auth_parse_hash;
9471 sort_by_digest = sort_by_digest_4_4;
9472 opti_type = OPTI_TYPE_ZERO_BYTE
9473 | OPTI_TYPE_PRECOMPUTE_INIT
9474 | OPTI_TYPE_PRECOMPUTE_MERKLE
9475 | OPTI_TYPE_EARLY_SKIP;
9476 dgst_pos0 = 0;
9477 dgst_pos1 = 3;
9478 dgst_pos2 = 2;
9479 dgst_pos3 = 1;
9480 break;
9481
9482 case 11200: hash_type = HASH_TYPE_SHA1;
9483 salt_type = SALT_TYPE_EMBEDDED;
9484 attack_exec = ATTACK_EXEC_ON_GPU;
9485 opts_type = OPTS_TYPE_PT_GENERATE_BE
9486 | OPTS_TYPE_PT_ADD80
9487 | OPTS_TYPE_ST_HEX;
9488 kern_type = KERN_TYPE_MYSQL_AUTH;
9489 dgst_size = DGST_SIZE_4_5;
9490 parse_func = mysql_auth_parse_hash;
9491 sort_by_digest = sort_by_digest_4_5;
9492 opti_type = OPTI_TYPE_ZERO_BYTE
9493 | OPTI_TYPE_EARLY_SKIP;
9494 dgst_pos0 = 3;
9495 dgst_pos1 = 4;
9496 dgst_pos2 = 2;
9497 dgst_pos3 = 1;
9498 break;
9499
9500 case 11300: hash_type = HASH_TYPE_BITCOIN_WALLET;
9501 salt_type = SALT_TYPE_EMBEDDED;
9502 attack_exec = ATTACK_EXEC_ON_CPU;
9503 opts_type = OPTS_TYPE_PT_GENERATE_LE
9504 | OPTS_TYPE_ST_HEX
9505 | OPTS_TYPE_ST_ADD80;
9506 kern_type = KERN_TYPE_BITCOIN_WALLET;
9507 dgst_size = DGST_SIZE_4_4;
9508 parse_func = bitcoin_wallet_parse_hash;
9509 sort_by_digest = sort_by_digest_4_4;
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 11400: hash_type = HASH_TYPE_MD5;
9518 salt_type = SALT_TYPE_EMBEDDED;
9519 attack_exec = ATTACK_EXEC_ON_GPU;
9520 opts_type = OPTS_TYPE_PT_GENERATE_LE
9521 | OPTS_TYPE_PT_ADD80
9522 | OPTS_TYPE_HASH_COPY;
9523 kern_type = KERN_TYPE_SIP_AUTH;
9524 dgst_size = DGST_SIZE_4_4;
9525 parse_func = sip_auth_parse_hash;
9526 sort_by_digest = sort_by_digest_4_4;
9527 opti_type = OPTI_TYPE_ZERO_BYTE;
9528 dgst_pos0 = 0;
9529 dgst_pos1 = 3;
9530 dgst_pos2 = 2;
9531 dgst_pos3 = 1;
9532 break;
9533
9534 case 11500: hash_type = HASH_TYPE_CRC32;
9535 salt_type = SALT_TYPE_INTERN;
9536 attack_exec = ATTACK_EXEC_ON_GPU;
9537 opts_type = OPTS_TYPE_PT_GENERATE_LE
9538 | OPTS_TYPE_ST_GENERATE_LE
9539 | OPTS_TYPE_ST_HEX;
9540 kern_type = KERN_TYPE_CRC32;
9541 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9542 parse_func = crc32_parse_hash;
9543 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9544 opti_type = OPTI_TYPE_ZERO_BYTE;
9545 dgst_pos0 = 0;
9546 dgst_pos1 = 1;
9547 dgst_pos2 = 2;
9548 dgst_pos3 = 3;
9549 break;
9550
9551 case 11600: hash_type = HASH_TYPE_AES;
9552 salt_type = SALT_TYPE_EMBEDDED;
9553 attack_exec = ATTACK_EXEC_ON_CPU;
9554 opts_type = OPTS_TYPE_PT_GENERATE_LE
9555 | OPTS_TYPE_PT_NEVERCRACK;
9556 kern_type = KERN_TYPE_SEVEN_ZIP;
9557 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9558 parse_func = seven_zip_parse_hash;
9559 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9560 opti_type = OPTI_TYPE_ZERO_BYTE;
9561 dgst_pos0 = 0;
9562 dgst_pos1 = 1;
9563 dgst_pos2 = 2;
9564 dgst_pos3 = 3;
9565 break;
9566
9567 case 11700: hash_type = HASH_TYPE_GOST_2012SBOG_256;
9568 salt_type = SALT_TYPE_NONE;
9569 attack_exec = ATTACK_EXEC_ON_GPU;
9570 opts_type = OPTS_TYPE_PT_GENERATE_LE
9571 | OPTS_TYPE_PT_ADD01;
9572 kern_type = KERN_TYPE_GOST_2012SBOG_256;
9573 dgst_size = DGST_SIZE_4_8;
9574 parse_func = gost2012sbog_256_parse_hash;
9575 sort_by_digest = sort_by_digest_4_8;
9576 opti_type = OPTI_TYPE_ZERO_BYTE;
9577 dgst_pos0 = 0;
9578 dgst_pos1 = 1;
9579 dgst_pos2 = 2;
9580 dgst_pos3 = 3;
9581 break;
9582
9583 case 11800: hash_type = HASH_TYPE_GOST_2012SBOG_512;
9584 salt_type = SALT_TYPE_NONE;
9585 attack_exec = ATTACK_EXEC_ON_GPU;
9586 opts_type = OPTS_TYPE_PT_GENERATE_LE
9587 | OPTS_TYPE_PT_ADD01;
9588 kern_type = KERN_TYPE_GOST_2012SBOG_512;
9589 dgst_size = DGST_SIZE_4_16;
9590 parse_func = gost2012sbog_512_parse_hash;
9591 sort_by_digest = sort_by_digest_4_16;
9592 opti_type = OPTI_TYPE_ZERO_BYTE;
9593 dgst_pos0 = 0;
9594 dgst_pos1 = 1;
9595 dgst_pos2 = 2;
9596 dgst_pos3 = 3;
9597 break;
9598
9599 case 11900: hash_type = HASH_TYPE_PBKDF2_MD5;
9600 salt_type = SALT_TYPE_EMBEDDED;
9601 attack_exec = ATTACK_EXEC_ON_CPU;
9602 opts_type = OPTS_TYPE_PT_GENERATE_LE
9603 | OPTS_TYPE_ST_BASE64
9604 | OPTS_TYPE_HASH_COPY;
9605 kern_type = KERN_TYPE_PBKDF2_MD5;
9606 dgst_size = DGST_SIZE_4_32;
9607 parse_func = pbkdf2_md5_parse_hash;
9608 sort_by_digest = sort_by_digest_4_32;
9609 opti_type = OPTI_TYPE_ZERO_BYTE;
9610 dgst_pos0 = 0;
9611 dgst_pos1 = 1;
9612 dgst_pos2 = 2;
9613 dgst_pos3 = 3;
9614 break;
9615
9616 case 12000: hash_type = HASH_TYPE_PBKDF2_SHA1;
9617 salt_type = SALT_TYPE_EMBEDDED;
9618 attack_exec = ATTACK_EXEC_ON_CPU;
9619 opts_type = OPTS_TYPE_PT_GENERATE_LE
9620 | OPTS_TYPE_ST_BASE64
9621 | OPTS_TYPE_HASH_COPY;
9622 kern_type = KERN_TYPE_PBKDF2_SHA1;
9623 dgst_size = DGST_SIZE_4_32;
9624 parse_func = pbkdf2_sha1_parse_hash;
9625 sort_by_digest = sort_by_digest_4_32;
9626 opti_type = OPTI_TYPE_ZERO_BYTE;
9627 dgst_pos0 = 0;
9628 dgst_pos1 = 1;
9629 dgst_pos2 = 2;
9630 dgst_pos3 = 3;
9631 break;
9632
9633 case 12100: hash_type = HASH_TYPE_PBKDF2_SHA512;
9634 salt_type = SALT_TYPE_EMBEDDED;
9635 attack_exec = ATTACK_EXEC_ON_CPU;
9636 opts_type = OPTS_TYPE_PT_GENERATE_LE
9637 | OPTS_TYPE_ST_BASE64
9638 | OPTS_TYPE_HASH_COPY;
9639 kern_type = KERN_TYPE_PBKDF2_SHA512;
9640 dgst_size = DGST_SIZE_8_16;
9641 parse_func = pbkdf2_sha512_parse_hash;
9642 sort_by_digest = sort_by_digest_8_16;
9643 opti_type = OPTI_TYPE_ZERO_BYTE;
9644 dgst_pos0 = 0;
9645 dgst_pos1 = 1;
9646 dgst_pos2 = 2;
9647 dgst_pos3 = 3;
9648 break;
9649
9650 case 12200: hash_type = HASH_TYPE_ECRYPTFS;
9651 salt_type = SALT_TYPE_EMBEDDED;
9652 attack_exec = ATTACK_EXEC_ON_CPU;
9653 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9654 kern_type = KERN_TYPE_ECRYPTFS;
9655 dgst_size = DGST_SIZE_8_8;
9656 parse_func = ecryptfs_parse_hash;
9657 sort_by_digest = sort_by_digest_8_8;
9658 opti_type = OPTI_TYPE_ZERO_BYTE;
9659 dgst_pos0 = 0;
9660 dgst_pos1 = 1;
9661 dgst_pos2 = 2;
9662 dgst_pos3 = 3;
9663 break;
9664
9665 case 12300: hash_type = HASH_TYPE_ORACLET;
9666 salt_type = SALT_TYPE_EMBEDDED;
9667 attack_exec = ATTACK_EXEC_ON_CPU;
9668 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9669 kern_type = KERN_TYPE_ORACLET;
9670 dgst_size = DGST_SIZE_8_16;
9671 parse_func = oraclet_parse_hash;
9672 sort_by_digest = sort_by_digest_8_16;
9673 opti_type = OPTI_TYPE_ZERO_BYTE;
9674 dgst_pos0 = 0;
9675 dgst_pos1 = 1;
9676 dgst_pos2 = 2;
9677 dgst_pos3 = 3;
9678 break;
9679
9680 case 12400: hash_type = HASH_TYPE_BSDICRYPT;
9681 salt_type = SALT_TYPE_EMBEDDED;
9682 attack_exec = ATTACK_EXEC_ON_CPU;
9683 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9684 kern_type = KERN_TYPE_BSDICRYPT;
9685 dgst_size = DGST_SIZE_4_4;
9686 parse_func = bsdicrypt_parse_hash;
9687 sort_by_digest = sort_by_digest_4_4;
9688 opti_type = OPTI_TYPE_ZERO_BYTE
9689 | OPTI_TYPE_PRECOMPUTE_PERMUT;
9690 dgst_pos0 = 0;
9691 dgst_pos1 = 1;
9692 dgst_pos2 = 2;
9693 dgst_pos3 = 3;
9694 break;
9695
9696 case 12500: hash_type = HASH_TYPE_RAR3HP;
9697 salt_type = SALT_TYPE_EMBEDDED;
9698 attack_exec = ATTACK_EXEC_ON_CPU;
9699 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9700 kern_type = KERN_TYPE_RAR3;
9701 dgst_size = DGST_SIZE_4_4;
9702 parse_func = rar3hp_parse_hash;
9703 sort_by_digest = sort_by_digest_4_4;
9704 opti_type = OPTI_TYPE_ZERO_BYTE;
9705 dgst_pos0 = 0;
9706 dgst_pos1 = 1;
9707 dgst_pos2 = 2;
9708 dgst_pos3 = 3;
9709 break;
9710
9711 case 12600: hash_type = HASH_TYPE_SHA256;
9712 salt_type = SALT_TYPE_INTERN;
9713 attack_exec = ATTACK_EXEC_ON_GPU;
9714 opts_type = OPTS_TYPE_PT_GENERATE_BE
9715 | OPTS_TYPE_PT_ADD80;
9716 kern_type = KERN_TYPE_CF10;
9717 dgst_size = DGST_SIZE_4_8;
9718 parse_func = cf10_parse_hash;
9719 sort_by_digest = sort_by_digest_4_8;
9720 opti_type = OPTI_TYPE_ZERO_BYTE
9721 | OPTI_TYPE_PRECOMPUTE_INIT
9722 | OPTI_TYPE_EARLY_SKIP
9723 | OPTI_TYPE_NOT_ITERATED;
9724 dgst_pos0 = 3;
9725 dgst_pos1 = 7;
9726 dgst_pos2 = 2;
9727 dgst_pos3 = 6;
9728 break;
9729
9730 case 12700: hash_type = HASH_TYPE_AES;
9731 salt_type = SALT_TYPE_EMBEDDED;
9732 attack_exec = ATTACK_EXEC_ON_CPU;
9733 opts_type = OPTS_TYPE_PT_GENERATE_LE
9734 | OPTS_TYPE_HASH_COPY;
9735 kern_type = KERN_TYPE_MYWALLET;
9736 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
9737 parse_func = mywallet_parse_hash;
9738 sort_by_digest = sort_by_digest_4_5;
9739 opti_type = OPTI_TYPE_ZERO_BYTE;
9740 dgst_pos0 = 0;
9741 dgst_pos1 = 1;
9742 dgst_pos2 = 2;
9743 dgst_pos3 = 3;
9744 break;
9745
9746 case 12800: hash_type = HASH_TYPE_PBKDF2_SHA256;
9747 salt_type = SALT_TYPE_EMBEDDED;
9748 attack_exec = ATTACK_EXEC_ON_CPU;
9749 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9750 kern_type = KERN_TYPE_MS_DRSR;
9751 dgst_size = DGST_SIZE_4_8;
9752 parse_func = ms_drsr_parse_hash;
9753 sort_by_digest = sort_by_digest_4_8;
9754 opti_type = OPTI_TYPE_ZERO_BYTE;
9755 dgst_pos0 = 0;
9756 dgst_pos1 = 1;
9757 dgst_pos2 = 2;
9758 dgst_pos3 = 3;
9759 break;
9760
9761 default: usage_mini_print (PROGNAME); return (-1);
9762 }
9763
9764 /**
9765 * transpose
9766 */
9767
9768 data.parse_func = parse_func;
9769
9770 /**
9771 * misc stuff
9772 */
9773
9774 if (hex_salt)
9775 {
9776 if (salt_type == SALT_TYPE_INTERN)
9777 {
9778 opts_type |= OPTS_TYPE_ST_HEX;
9779 }
9780 else
9781 {
9782 log_error ("ERROR: Parameter hex-salt not valid for hash-type %u", hash_mode);
9783
9784 return (-1);
9785 }
9786 }
9787
9788 uint isSalted = ((salt_type == SALT_TYPE_INTERN)
9789 | (salt_type == SALT_TYPE_EXTERN)
9790 | (salt_type == SALT_TYPE_EMBEDDED)
9791 | (salt_type == SALT_TYPE_VIRTUAL));
9792
9793 sort_by_digest = sort_by_digest_p0p1; // overruled by 64 bit digest
9794
9795 data.hash_type = hash_type;
9796 data.attack_mode = attack_mode;
9797 data.attack_kern = attack_kern;
9798 data.attack_exec = attack_exec;
9799 data.kern_type = kern_type;
9800 data.opts_type = opts_type;
9801 data.dgst_size = dgst_size;
9802 data.salt_type = salt_type;
9803 data.isSalted = isSalted;
9804 data.sort_by_digest = sort_by_digest;
9805 data.dgst_pos0 = dgst_pos0;
9806 data.dgst_pos1 = dgst_pos1;
9807 data.dgst_pos2 = dgst_pos2;
9808 data.dgst_pos3 = dgst_pos3;
9809
9810 esalt_size = 0;
9811
9812 switch (hash_mode)
9813 {
9814 case 2500: esalt_size = sizeof (wpa_t); break;
9815 case 5300: esalt_size = sizeof (ikepsk_t); break;
9816 case 5400: esalt_size = sizeof (ikepsk_t); break;
9817 case 5500: esalt_size = sizeof (netntlm_t); break;
9818 case 5600: esalt_size = sizeof (netntlm_t); break;
9819 case 6211:
9820 case 6212:
9821 case 6213:
9822 case 6221:
9823 case 6222:
9824 case 6223:
9825 case 6231:
9826 case 6232:
9827 case 6233:
9828 case 6241:
9829 case 6242:
9830 case 6243: esalt_size = sizeof (tc_t); break;
9831 case 6600: esalt_size = sizeof (agilekey_t); break;
9832 case 7100: esalt_size = sizeof (pbkdf2_sha512_t); break;
9833 case 7200: esalt_size = sizeof (pbkdf2_sha512_t); break;
9834 case 7300: esalt_size = sizeof (rakp_t); break;
9835 case 7500: esalt_size = sizeof (krb5pa_t); break;
9836 case 8200: esalt_size = sizeof (cloudkey_t); break;
9837 case 8800: esalt_size = sizeof (androidfde_t); break;
9838 case 9200: esalt_size = sizeof (pbkdf2_sha256_t); break;
9839 case 9400: esalt_size = sizeof (office2007_t); break;
9840 case 9500: esalt_size = sizeof (office2010_t); break;
9841 case 9600: esalt_size = sizeof (office2013_t); break;
9842 case 9700: esalt_size = sizeof (oldoffice01_t); break;
9843 case 9710: esalt_size = sizeof (oldoffice01_t); break;
9844 case 9720: esalt_size = sizeof (oldoffice01_t); break;
9845 case 9800: esalt_size = sizeof (oldoffice34_t); break;
9846 case 9810: esalt_size = sizeof (oldoffice34_t); break;
9847 case 9820: esalt_size = sizeof (oldoffice34_t); break;
9848 case 10000: esalt_size = sizeof (pbkdf2_sha256_t); break;
9849 case 10200: esalt_size = sizeof (cram_md5_t); break;
9850 case 10400: esalt_size = sizeof (pdf_t); break;
9851 case 10410: esalt_size = sizeof (pdf_t); break;
9852 case 10420: esalt_size = sizeof (pdf_t); break;
9853 case 10500: esalt_size = sizeof (pdf_t); break;
9854 case 10600: esalt_size = sizeof (pdf_t); break;
9855 case 10700: esalt_size = sizeof (pdf_t); break;
9856 case 10900: esalt_size = sizeof (pbkdf2_sha256_t); break;
9857 case 11300: esalt_size = sizeof (bitcoin_wallet_t); break;
9858 case 11400: esalt_size = sizeof (sip_t); break;
9859 case 11600: esalt_size = sizeof (seven_zip_t); break;
9860 case 11900: esalt_size = sizeof (pbkdf2_md5_t); break;
9861 case 12000: esalt_size = sizeof (pbkdf2_sha1_t); break;
9862 case 12100: esalt_size = sizeof (pbkdf2_sha512_t); break;
9863 }
9864
9865 data.esalt_size = esalt_size;
9866
9867 /**
9868 * choose dictionary parser
9869 */
9870
9871 if (hash_type == HASH_TYPE_LM)
9872 {
9873 get_next_word_func = get_next_word_lm;
9874 }
9875 else if (opts_type & OPTS_TYPE_PT_UPPER)
9876 {
9877 get_next_word_func = get_next_word_uc;
9878 }
9879 else
9880 {
9881 get_next_word_func = get_next_word_std;
9882 }
9883
9884 /**
9885 * dictstat
9886 */
9887
9888 dictstat_t *dictstat_base = (dictstat_t *) mycalloc (MAX_DICTSTAT, sizeof (dictstat_t));
9889
9890 #ifdef _POSIX
9891 size_t dictstat_nmemb = 0;
9892 #endif
9893
9894 #ifdef _WIN
9895 uint dictstat_nmemb = 0;
9896 #endif
9897
9898 char dictstat[256];
9899
9900 FILE *dictstat_fp = NULL;
9901
9902 if (keyspace == 0)
9903 {
9904 memset (dictstat, 0, sizeof (dictstat));
9905
9906 snprintf (dictstat, sizeof (dictstat) - 1, "%s/%s.dictstat", install_dir, PROGNAME);
9907
9908 dictstat_fp = fopen (dictstat, "rb");
9909
9910 if (dictstat_fp)
9911 {
9912 #ifdef _POSIX
9913 struct stat tmpstat;
9914
9915 fstat (fileno (dictstat_fp), &tmpstat);
9916 #endif
9917
9918 #ifdef _WIN
9919 struct stat64 tmpstat;
9920
9921 _fstat64 (fileno (dictstat_fp), &tmpstat);
9922 #endif
9923
9924 if (tmpstat.st_mtime < COMPTIME)
9925 {
9926 /* with v0.15 the format changed so we have to ensure user is using a good version
9927 since there is no version-header in the dictstat file */
9928
9929 fclose (dictstat_fp);
9930
9931 unlink (dictstat);
9932 }
9933 else
9934 {
9935 while (!feof (dictstat_fp))
9936 {
9937 dictstat_t d;
9938
9939 if (fread (&d, sizeof (dictstat_t), 1, dictstat_fp) == 0) continue;
9940
9941 lsearch (&d, dictstat_base, &dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
9942
9943 if (dictstat_nmemb == (MAX_DICTSTAT - 1000))
9944 {
9945 log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat);
9946
9947 return -1;
9948 }
9949 }
9950
9951 fclose (dictstat_fp);
9952 }
9953 }
9954 }
9955
9956 /**
9957 * potfile
9958 */
9959
9960 char potfile[256];
9961
9962 memset (potfile, 0, sizeof (potfile));
9963
9964 snprintf (potfile, sizeof (potfile) - 1, "%s.pot", session);
9965
9966 data.pot_fp = NULL;
9967
9968 FILE *out_fp = NULL;
9969 FILE *pot_fp = NULL;
9970
9971 if (show == 1 || left == 1)
9972 {
9973 pot_fp = fopen (potfile, "rb");
9974
9975 if (pot_fp == NULL)
9976 {
9977 log_error ("ERROR: %s: %s", potfile, strerror (errno));
9978
9979 return (-1);
9980 }
9981
9982 if (outfile != NULL)
9983 {
9984 if ((out_fp = fopen (outfile, "ab")) == NULL)
9985 {
9986 log_error ("ERROR: %s: %s", outfile, strerror (errno));
9987
9988 fclose (pot_fp);
9989
9990 return (-1);
9991 }
9992 }
9993 else
9994 {
9995 out_fp = stdout;
9996 }
9997 }
9998 else
9999 {
10000 if (potfile_disable == 0)
10001 {
10002 pot_fp = fopen (potfile, "ab");
10003
10004 if (pot_fp == NULL)
10005 {
10006 log_error ("ERROR: %s: %s", potfile, strerror (errno));
10007
10008 return (-1);
10009 }
10010
10011 data.pot_fp = pot_fp;
10012 }
10013 }
10014
10015 pot_t *pot = NULL;
10016
10017 uint pot_cnt = 0;
10018 uint pot_avail = 0;
10019
10020 if (show == 1 || left == 1)
10021 {
10022 SUPPRESS_OUTPUT = 1;
10023
10024 pot_avail = count_lines (pot_fp);
10025
10026 rewind (pot_fp);
10027
10028 pot = (pot_t *) mycalloc (pot_avail, sizeof (pot_t));
10029
10030 uint pot_hashes_avail = 0;
10031
10032 uint line_num = 0;
10033
10034 while (!feof (pot_fp))
10035 {
10036 line_num++;
10037
10038 char line_buf[BUFSIZ];
10039
10040 int line_len = fgetl (pot_fp, line_buf);
10041
10042 if (line_len == 0) continue;
10043
10044 char *plain_buf = line_buf + line_len;
10045
10046 pot_t *pot_ptr = &pot[pot_cnt];
10047
10048 hash_t *hashes_buf = &pot_ptr->hash;
10049
10050 // we do not initialize all hashes_buf->digest etc at the beginning, since many lines may not be
10051 // valid lines of this specific hash type (otherwise it would be more waste of memory than gain)
10052
10053 if (pot_cnt == pot_hashes_avail)
10054 {
10055 uint pos = 0;
10056
10057 for (pos = 0; pos < INCR_POT; pos++)
10058 {
10059 if ((pot_cnt + pos) >= pot_avail) break;
10060
10061 pot_t *tmp_pot = &pot[pot_cnt + pos];
10062
10063 hash_t *tmp_hash = &tmp_pot->hash;
10064
10065 tmp_hash->digest = mymalloc (dgst_size);
10066
10067 if (isSalted)
10068 {
10069 tmp_hash->salt = (salt_t *) mymalloc (sizeof (salt_t));
10070 }
10071
10072 if (esalt_size)
10073 {
10074 tmp_hash->esalt = mymalloc (esalt_size);
10075 }
10076
10077 pot_hashes_avail++;
10078 }
10079 }
10080
10081 int plain_len = 0;
10082
10083 int parser_status;
10084
10085 int iter = MAX_CUT_TRIES;
10086
10087 do
10088 {
10089 for (int i = line_len - 1; i; i--, plain_len++, plain_buf--, line_len--)
10090 {
10091 if (line_buf[i] == ':')
10092 {
10093 line_len--;
10094
10095 break;
10096 }
10097 }
10098
10099 if (data.hash_mode != 2500)
10100 {
10101 parser_status = parse_func (line_buf, line_len, hashes_buf);
10102 }
10103 else
10104 {
10105 int max_salt_size = sizeof (hashes_buf->salt->salt_buf);
10106
10107 if (line_len > max_salt_size)
10108 {
10109 parser_status = PARSER_GLOBAL_LENGTH;
10110 }
10111 else
10112 {
10113 memset (&hashes_buf->salt->salt_buf, 0, max_salt_size);
10114
10115 memcpy (&hashes_buf->salt->salt_buf, line_buf, line_len);
10116
10117 hashes_buf->salt->salt_len = line_len;
10118
10119 parser_status = PARSER_OK;
10120 }
10121 }
10122
10123 // if NOT parsed without error, we add the ":" to the plain
10124
10125 if (parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH)
10126 {
10127 plain_len++;
10128 plain_buf--;
10129 }
10130
10131 } while ((parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH) && --iter);
10132
10133 if (parser_status < PARSER_GLOBAL_ZERO)
10134 {
10135 // log_info ("WARNING: Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status));
10136
10137 continue;
10138 }
10139
10140 memcpy (pot_ptr->plain_buf, plain_buf, plain_len);
10141
10142 pot_ptr->plain_len = plain_len;
10143
10144 pot_cnt++;
10145 }
10146
10147 fclose (pot_fp);
10148
10149 SUPPRESS_OUTPUT = 0;
10150
10151 qsort (pot, pot_cnt, sizeof (pot_t), sort_by_pot);
10152 }
10153
10154 /**
10155 * gpu accel and loops auto adjustment
10156 */
10157
10158 if (gpu_accel_chgd == 0) gpu_accel = set_gpu_accel (hash_mode);
10159 if (gpu_loops_chgd == 0) gpu_loops = set_gpu_loops (hash_mode);
10160
10161 if (workload_profile == 1)
10162 {
10163 gpu_loops /= 8;
10164 gpu_accel /= 4;
10165
10166 if (gpu_loops == 0) gpu_loops = 8;
10167 if (gpu_accel == 0) gpu_accel = 2;
10168 }
10169 else if (workload_profile == 3)
10170 {
10171 gpu_loops *= 8;
10172 gpu_accel *= 4;
10173
10174 if (gpu_loops > 1024) gpu_loops = 1024;
10175 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
10176 }
10177
10178 // those hashes *must* run at a specific gpu_loops count because of some optimization inside the kernel
10179
10180 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
10181 {
10182 gpu_loops = 1024;
10183 }
10184
10185 if (hash_mode == 12500)
10186 {
10187 gpu_loops = ROUNDS_RAR3 / 16;
10188 }
10189
10190 data.gpu_accel = gpu_accel;
10191 data.gpu_loops = gpu_loops;
10192
10193 /**
10194 * word len
10195 */
10196
10197 uint pw_min = PW_MIN;
10198 uint pw_max = PW_MAX;
10199
10200 switch (hash_mode)
10201 {
10202 case 400: if (pw_max > 40) pw_max = 40;
10203 break;
10204 case 500: if (pw_max > 16) pw_max = 16;
10205 break;
10206 case 1500: if (pw_max > 8) pw_max = 8;
10207 break;
10208 case 1600: if (pw_max > 16) pw_max = 16;
10209 break;
10210 case 1800: if (pw_max > 16) pw_max = 16;
10211 break;
10212 case 2100: if (pw_max > 16) pw_max = 16;
10213 break;
10214 case 2500: if (pw_min < 8) pw_min = 8;
10215 break;
10216 case 3000: if (pw_max > 7) pw_max = 7;
10217 break;
10218 case 5200: if (pw_max > 24) pw_max = 24;
10219 break;
10220 case 5800: if (pw_max > 16) pw_max = 16;
10221 break;
10222 case 6300: if (pw_max > 16) pw_max = 16;
10223 break;
10224 case 7400: if (pw_max > 16) pw_max = 16;
10225 break;
10226 case 7900: if (pw_max > 48) pw_max = 48;
10227 break;
10228 case 8500: if (pw_max > 8) pw_max = 8;
10229 break;
10230 case 8600: if (pw_max > 16) pw_max = 16;
10231 break;
10232 case 9710: pw_min = 5;
10233 pw_max = 5;
10234 break;
10235 case 9810: pw_min = 5;
10236 pw_max = 5;
10237 break;
10238 case 10410: pw_min = 5;
10239 pw_max = 5;
10240 break;
10241 case 10300: if (pw_max < 3) pw_min = 3;
10242 if (pw_max > 40) pw_max = 40;
10243 break;
10244 case 10500: if (pw_max < 3) pw_min = 3;
10245 if (pw_max > 40) pw_max = 40;
10246 break;
10247 case 10700: if (pw_max > 16) pw_max = 16;
10248 break;
10249 case 11300: if (pw_max > 40) pw_max = 40;
10250 break;
10251 case 12500: if (pw_max > 20) pw_max = 20;
10252 break;
10253 case 12800: if (pw_max > 24) pw_max = 24;
10254 break;
10255 }
10256
10257 if (attack_exec == ATTACK_EXEC_ON_GPU)
10258 {
10259 switch (attack_kern)
10260 {
10261 case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
10262 break;
10263 case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
10264 break;
10265 }
10266 }
10267
10268 /**
10269 * charsets : keep them together for more easy maintainnce
10270 */
10271
10272 cs_t mp_sys[6];
10273 cs_t mp_usr[4];
10274
10275 memset (mp_sys, 0, sizeof (mp_sys));
10276 memset (mp_usr, 0, sizeof (mp_usr));
10277
10278 mp_setup_sys (mp_sys);
10279
10280 if (custom_charset_1) mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
10281 if (custom_charset_2) mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
10282 if (custom_charset_3) mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
10283 if (custom_charset_4) mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
10284
10285 /**
10286 * load hashes, part I: find input mode, count hashes
10287 */
10288
10289 uint hashlist_mode = 0;
10290 uint hashlist_format = HLFMT_HASHCAT;
10291
10292 uint hashes_avail = 0;
10293
10294 if (benchmark == 0)
10295 {
10296 struct stat f;
10297
10298 hashlist_mode = (stat (myargv[optind], &f) == 0) ? HL_MODE_FILE : HL_MODE_ARG;
10299
10300 if ((hash_mode == 2500) ||
10301 (hash_mode == 5200) ||
10302 ((hash_mode >= 6200) && (hash_mode <= 6299)) ||
10303 (hash_mode == 9000))
10304 {
10305 hashlist_mode = HL_MODE_ARG;
10306
10307 char *hashfile = myargv[optind];
10308
10309 data.hashfile = hashfile;
10310
10311 logfile_top_var_string ("target", hashfile);
10312 }
10313
10314 if (hashlist_mode == HL_MODE_ARG)
10315 {
10316 if (hash_mode == 2500)
10317 {
10318 struct stat st;
10319
10320 if (stat (data.hashfile, &st) == -1)
10321 {
10322 log_error ("ERROR: %s: %s", data.hashfile, strerror (errno));
10323
10324 return (-1);
10325 }
10326
10327 hashes_avail = st.st_size / sizeof (hccap_t);
10328 }
10329 else
10330 {
10331 hashes_avail = 1;
10332 }
10333 }
10334 else if (hashlist_mode == HL_MODE_FILE)
10335 {
10336 char *hashfile = myargv[optind];
10337
10338 data.hashfile = hashfile;
10339
10340 logfile_top_var_string ("target", hashfile);
10341
10342 FILE *fp = NULL;
10343
10344 if ((fp = fopen (hashfile, "rb")) == NULL)
10345 {
10346 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
10347
10348 return (-1);
10349 }
10350
10351 if (data.quiet == 0) log_info_nn ("Counting lines in %s", hashfile);
10352
10353 hashes_avail = count_lines (fp);
10354
10355 rewind (fp);
10356
10357 if (hashes_avail == 0)
10358 {
10359 log_error ("ERROR: hashfile is empty or corrupt");
10360
10361 fclose (fp);
10362
10363 return (-1);
10364 }
10365
10366 hashlist_format = hlfmt_detect (fp, 100); // 100 = max numbers to "scan". could be hashes_avail, too
10367
10368 if ((remove == 1) && (hashlist_format != HLFMT_HASHCAT))
10369 {
10370 log_error ("ERROR: remove not supported in native hashfile-format mode");
10371
10372 fclose (fp);
10373
10374 return (-1);
10375 }
10376
10377 fclose (fp);
10378 }
10379 }
10380 else
10381 {
10382 hashlist_mode = HL_MODE_ARG;
10383
10384 hashes_avail = 1;
10385 }
10386
10387 if (hash_mode == 3000) hashes_avail *= 2;
10388
10389 data.hashlist_mode = hashlist_mode;
10390 data.hashlist_format = hashlist_format;
10391
10392 logfile_top_uint (hashlist_mode);
10393 logfile_top_uint (hashlist_format);
10394
10395 /**
10396 * load hashes, part II: allocate required memory, set pointers
10397 */
10398
10399 hash_t *hashes_buf = NULL;
10400 void *digests_buf = NULL;
10401 salt_t *salts_buf = NULL;
10402 void *esalts_buf = NULL;
10403
10404 hashes_buf = (hash_t *) mycalloc (hashes_avail, sizeof (hash_t));
10405
10406 digests_buf = (void *) mycalloc (hashes_avail, dgst_size);
10407
10408 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
10409 {
10410 uint32_t hash_pos;
10411
10412 for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
10413 {
10414 hashinfo_t *hash_info = (hashinfo_t *) mymalloc (sizeof (hashinfo_t));
10415
10416 hashes_buf[hash_pos].hash_info = hash_info;
10417
10418 if (username && (remove || show || left))
10419 {
10420 hash_info->user = (user_t*) mymalloc (sizeof (user_t));
10421 }
10422
10423 if (benchmark)
10424 {
10425 hash_info->orighash = (char *) mymalloc (256);
10426 }
10427 }
10428 }
10429
10430 if (isSalted)
10431 {
10432 salts_buf = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
10433
10434 if (esalt_size)
10435 {
10436 esalts_buf = (void *) mycalloc (hashes_avail, esalt_size);
10437 }
10438 }
10439 else
10440 {
10441 salts_buf = (salt_t *) mycalloc (1, sizeof (salt_t));
10442 }
10443
10444 for (uint hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
10445 {
10446 hashes_buf[hash_pos].digest = ((char *) digests_buf) + (hash_pos * dgst_size);
10447
10448 if (isSalted)
10449 {
10450 hashes_buf[hash_pos].salt = &salts_buf[hash_pos];
10451
10452 if (esalt_size)
10453 {
10454 hashes_buf[hash_pos].esalt = ((char *) esalts_buf) + (hash_pos * esalt_size);
10455 }
10456 }
10457 else
10458 {
10459 hashes_buf[hash_pos].salt = &salts_buf[0];
10460 }
10461 }
10462
10463 /**
10464 * load hashes, part III: parse hashes or generate them if benchmark
10465 */
10466
10467 uint hashes_cnt = 0;
10468
10469 if (benchmark == 0)
10470 {
10471 if (keyspace == 1)
10472 {
10473 // useless to read hash file for keyspace, cheat a little bit w/ optind
10474 }
10475 else if (hashes_avail == 0)
10476 {
10477 }
10478 else if (hashlist_mode == HL_MODE_ARG)
10479 {
10480 char *input_buf = myargv[optind];
10481
10482 uint input_len = strlen (input_buf);
10483
10484 logfile_top_var_string ("target", input_buf);
10485
10486 char *hash_buf = NULL;
10487 int hash_len = 0;
10488
10489 hlfmt_hash (hashlist_format, input_buf, input_len, &hash_buf, &hash_len);
10490
10491 if (hash_len)
10492 {
10493 if (opts_type & OPTS_TYPE_HASH_COPY)
10494 {
10495 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
10496
10497 hash_info_tmp->orighash = mystrdup (hash_buf);
10498 }
10499
10500 if (isSalted)
10501 {
10502 memset (hashes_buf[0].salt, 0, sizeof (salt_t));
10503 }
10504
10505 int parser_status = PARSER_OK;
10506
10507 if (hash_mode == 2500)
10508 {
10509 if (hash_len == 0)
10510 {
10511 log_error ("ERROR: hccap file not specified");
10512
10513 return (-1);
10514 }
10515
10516 hashlist_mode = HL_MODE_FILE;
10517
10518 data.hashlist_mode = hashlist_mode;
10519
10520 FILE *fp = fopen (hash_buf, "rb");
10521
10522 if (fp == NULL)
10523 {
10524 log_error ("ERROR: %s: %s", hash_buf, strerror (errno));
10525
10526 return (-1);
10527 }
10528
10529 if (hashes_avail < 1)
10530 {
10531 log_error ("ERROR: hccap file is empty or corrupt");
10532
10533 fclose (fp);
10534
10535 return (-1);
10536 }
10537
10538 uint hccap_size = sizeof (hccap_t);
10539
10540 char in[hccap_size];
10541
10542 while (!feof (fp))
10543 {
10544 int n = fread (&in, hccap_size, 1, fp);
10545
10546 if (n != 1)
10547 {
10548 if (hashes_cnt < 1) parser_status = PARSER_HCCAP_FILE_SIZE;
10549
10550 break;
10551 }
10552
10553 parser_status = parse_func (in, hccap_size, &hashes_buf[hashes_cnt]);
10554
10555 if (parser_status != PARSER_OK)
10556 {
10557 log_info ("WARNING: Hash '%s': %s", hash_buf, strparser (parser_status));
10558
10559 continue;
10560 }
10561
10562 // hack: append MAC1 and MAC2 s.t. in --show and --left the line matches with the .pot file format (i.e. ESSID:MAC1:MAC2)
10563
10564 if ((show == 1) || (left == 1))
10565 {
10566 salt_t *tmp_salt = hashes_buf[hashes_cnt].salt;
10567
10568 char *salt_ptr = (char *) tmp_salt->salt_buf;
10569
10570 int cur_pos = tmp_salt->salt_len;
10571 int rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
10572
10573 wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt;
10574
10575 unsigned char *pke_ptr = (unsigned char *) wpa->pke;
10576
10577 // do the appending task
10578
10579 snprintf (salt_ptr + cur_pos,
10580 rem_len,
10581 ":%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
10582 pke_ptr[20], pke_ptr[27], pke_ptr[26], pke_ptr[25], pke_ptr[24], pke_ptr[31], // MAC1
10583 pke_ptr[30], pke_ptr[29], pke_ptr[28], pke_ptr[35], pke_ptr[34], pke_ptr[33]); // MAC2
10584
10585
10586 // memset () the remaining part of the salt
10587
10588 cur_pos = tmp_salt->salt_len + 1 + 12 + 1 + 12;
10589 rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
10590
10591 if (rem_len > 0) memset (salt_ptr + cur_pos, 0, rem_len);
10592
10593 tmp_salt->salt_len += 1 + 12 + 1 + 12;
10594 }
10595
10596 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);
10597 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);
10598
10599 hashes_cnt++;
10600 }
10601
10602 fclose (fp);
10603 }
10604 else if (hash_mode == 3000)
10605 {
10606 if (hash_len == 32)
10607 {
10608 parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
10609
10610 hash_t *lm_hash_left = NULL;
10611
10612 if (parser_status == PARSER_OK)
10613 {
10614 lm_hash_left = &hashes_buf[hashes_cnt];
10615
10616 hashes_cnt++;
10617 }
10618 else
10619 {
10620 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
10621 }
10622
10623
10624 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
10625
10626 hash_t *lm_hash_right = NULL;
10627
10628 if (parser_status == PARSER_OK)
10629 {
10630 lm_hash_right = &hashes_buf[hashes_cnt];
10631
10632 hashes_cnt++;
10633 }
10634 else
10635 {
10636 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
10637 }
10638
10639 // show / left
10640
10641 if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
10642 {
10643 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);
10644 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);
10645 }
10646 }
10647 else
10648 {
10649 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
10650
10651 if (parser_status == PARSER_OK)
10652 {
10653 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10654 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10655 }
10656
10657 if (parser_status == PARSER_OK)
10658 {
10659 hashes_cnt++;
10660 }
10661 else
10662 {
10663 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
10664 }
10665 }
10666 }
10667 else
10668 {
10669 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
10670
10671 if (parser_status == PARSER_OK)
10672 {
10673 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10674 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10675 }
10676
10677 if (parser_status == PARSER_OK)
10678 {
10679 hashes_cnt++;
10680 }
10681 else
10682 {
10683 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
10684 }
10685 }
10686 }
10687 }
10688 else if (hashlist_mode == HL_MODE_FILE)
10689 {
10690 char *hashfile = data.hashfile;
10691
10692 FILE *fp;
10693
10694 if ((fp = fopen (hashfile, "rb")) == NULL)
10695 {
10696 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
10697
10698 return (-1);
10699 }
10700
10701 uint line_num = 0;
10702
10703 while (!feof (fp))
10704 {
10705 line_num++;
10706
10707 char line_buf[BUFSIZ];
10708
10709 int line_len = fgetl (fp, line_buf);
10710
10711 if (line_len == 0) continue;
10712
10713 char *hash_buf = NULL;
10714 int hash_len = 0;
10715
10716 hlfmt_hash (hashlist_format, line_buf, line_len, &hash_buf, &hash_len);
10717
10718 if (username)
10719 {
10720 char *user_buf = NULL;
10721 int user_len = 0;
10722
10723 hlfmt_user (hashlist_format, line_buf, line_len, &user_buf, &user_len);
10724
10725 if (remove || show)
10726 {
10727 user_t **user = &hashes_buf[hashes_cnt].hash_info->user;
10728
10729 *user = (user_t *) malloc (sizeof (user_t));
10730
10731 user_t *user_ptr = *user;
10732
10733 if (user_buf != NULL)
10734 {
10735 user_ptr->user_name = mystrdup (user_buf);
10736 }
10737 else
10738 {
10739 user_ptr->user_name = mystrdup ("");
10740 }
10741
10742 user_ptr->user_len = user_len;
10743 }
10744 }
10745
10746 if (opts_type & OPTS_TYPE_HASH_COPY)
10747 {
10748 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
10749
10750 hash_info_tmp->orighash = mystrdup (hash_buf);
10751 }
10752
10753 if (isSalted)
10754 {
10755 memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t));
10756 }
10757
10758 if (hash_mode == 3000)
10759 {
10760 if (hash_len == 32)
10761 {
10762 int parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
10763
10764 if (parser_status < PARSER_GLOBAL_ZERO)
10765 {
10766 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
10767
10768 continue;
10769 }
10770
10771 hash_t *lm_hash_left = &hashes_buf[hashes_cnt];
10772
10773 hashes_cnt++;
10774
10775 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
10776
10777 if (parser_status < PARSER_GLOBAL_ZERO)
10778 {
10779 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
10780
10781 continue;
10782 }
10783
10784 hash_t *lm_hash_right = &hashes_buf[hashes_cnt];
10785
10786 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);
10787
10788 hashes_cnt++;
10789
10790 // show / left
10791
10792 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);
10793 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);
10794 }
10795 else
10796 {
10797 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
10798
10799 if (parser_status < PARSER_GLOBAL_ZERO)
10800 {
10801 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
10802
10803 continue;
10804 }
10805
10806 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);
10807
10808 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10809 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10810
10811 hashes_cnt++;
10812 }
10813 }
10814 else
10815 {
10816 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
10817
10818 if (parser_status < PARSER_GLOBAL_ZERO)
10819 {
10820 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
10821
10822 continue;
10823 }
10824
10825 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);
10826
10827 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10828 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10829
10830 hashes_cnt++;
10831 }
10832 }
10833
10834 fclose (fp);
10835
10836 if (data.quiet == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
10837
10838 if ((out_fp != NULL) && (out_fp != stdout)) fclose (out_fp);
10839 }
10840 }
10841 else
10842 {
10843 if (isSalted)
10844 {
10845 hashes_buf[0].salt->salt_len = 8;
10846
10847 // special salt handling
10848
10849 switch (hash_mode)
10850 {
10851 case 1500: hashes_buf[0].salt->salt_len = 2;
10852 break;
10853 case 1731: hashes_buf[0].salt->salt_len = 4;
10854 break;
10855 case 2410: hashes_buf[0].salt->salt_len = 4;
10856 break;
10857 case 2500: memcpy (hashes_buf[0].salt->salt_buf, "hashcat.net", 11);
10858 break;
10859 case 3100: hashes_buf[0].salt->salt_len = 1;
10860 break;
10861 case 5000: hashes_buf[0].salt->keccak_mdlen = 32;
10862 break;
10863 case 5800: hashes_buf[0].salt->salt_len = 16;
10864 break;
10865 case 6800: hashes_buf[0].salt->salt_len = 32;
10866 break;
10867 case 8400: hashes_buf[0].salt->salt_len = 40;
10868 break;
10869 case 8800: hashes_buf[0].salt->salt_len = 16;
10870 break;
10871 case 8900: hashes_buf[0].salt->salt_len = 16;
10872 hashes_buf[0].salt->scrypt_N = 1024;
10873 hashes_buf[0].salt->scrypt_r = 1;
10874 hashes_buf[0].salt->scrypt_p = 1;
10875 break;
10876 case 9100: hashes_buf[0].salt->salt_len = 16;
10877 break;
10878 case 9300: hashes_buf[0].salt->salt_len = 14;
10879 hashes_buf[0].salt->scrypt_N = 16384;
10880 hashes_buf[0].salt->scrypt_r = 1;
10881 hashes_buf[0].salt->scrypt_p = 1;
10882 break;
10883 case 9400: hashes_buf[0].salt->salt_len = 16;
10884 break;
10885 case 9500: hashes_buf[0].salt->salt_len = 16;
10886 break;
10887 case 9600: hashes_buf[0].salt->salt_len = 16;
10888 break;
10889 case 9700: hashes_buf[0].salt->salt_len = 16;
10890 break;
10891 case 9710: hashes_buf[0].salt->salt_len = 16;
10892 break;
10893 case 9720: hashes_buf[0].salt->salt_len = 16;
10894 break;
10895 case 9800: hashes_buf[0].salt->salt_len = 16;
10896 break;
10897 case 9810: hashes_buf[0].salt->salt_len = 16;
10898 break;
10899 case 9820: hashes_buf[0].salt->salt_len = 16;
10900 break;
10901 case 10300: hashes_buf[0].salt->salt_len = 12;
10902 break;
10903 case 11500: hashes_buf[0].salt->salt_len = 4;
10904 break;
10905 case 11600: hashes_buf[0].salt->salt_len = 4;
10906 break;
10907 case 12400: hashes_buf[0].salt->salt_len = 4;
10908 break;
10909 case 12500: hashes_buf[0].salt->salt_len = 8;
10910 break;
10911 case 12600: hashes_buf[0].salt->salt_len = 64;
10912 break;
10913 }
10914
10915 // special esalt handling
10916
10917 switch (hash_mode)
10918 {
10919 case 2500: ((wpa_t *) hashes_buf[0].esalt)->eapol_size = 128;
10920 break;
10921 case 5300: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
10922 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
10923 break;
10924 case 5400: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
10925 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
10926 break;
10927 case 5500: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
10928 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
10929 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
10930 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
10931 break;
10932 case 5600: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
10933 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
10934 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
10935 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
10936 break;
10937 case 7300: ((rakp_t *) hashes_buf[0].esalt)->salt_len = 32;
10938 break;
10939 case 10400: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10940 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
10941 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
10942 break;
10943 case 10410: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10944 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
10945 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
10946 break;
10947 case 10420: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10948 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
10949 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
10950 break;
10951 case 10500: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10952 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
10953 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
10954 break;
10955 case 10600: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10956 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
10957 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
10958 break;
10959 case 10700: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10960 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
10961 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
10962 break;
10963 case 11600: ((seven_zip_t *) hashes_buf[0].esalt)->iv_len = 16;
10964 ((seven_zip_t *) hashes_buf[0].esalt)->data_len = 112;
10965 ((seven_zip_t *) hashes_buf[0].esalt)->unpack_size = 112;
10966 break;
10967 }
10968 }
10969
10970 // set hashfile
10971
10972 switch (hash_mode)
10973 {
10974 case 5200: data.hashfile = mystrdup ("hashcat.psafe3");
10975 break;
10976 case 5300: data.hashfile = mystrdup ("hashcat.ikemd5");
10977 break;
10978 case 5400: data.hashfile = mystrdup ("hashcat.ikesha1");
10979 break;
10980 case 6211:
10981 case 6212:
10982 case 6213:
10983 case 6221:
10984 case 6222:
10985 case 6223:
10986 case 6231:
10987 case 6232:
10988 case 6233:
10989 case 6241:
10990 case 6242:
10991 case 6243: data.hashfile = mystrdup ("hashcat.tc");
10992 break;
10993 case 6600: data.hashfile = mystrdup ("hashcat.agilekey");
10994 break;
10995 case 8200: data.hashfile = mystrdup ("hashcat.cloudkey");
10996 break;
10997 case 9000: data.hashfile = mystrdup ("hashcat.psafe2");
10998 break;
10999 }
11000
11001 // set default iterations
11002
11003 switch (hash_mode)
11004 {
11005 case 400: hashes_buf[0].salt->salt_iter = ROUNDS_PHPASS;
11006 break;
11007 case 500: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11008 break;
11009 case 501: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11010 break;
11011 case 1600: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11012 break;
11013 case 1800: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512CRYPT;
11014 break;
11015 case 2100: hashes_buf[0].salt->salt_iter = ROUNDS_DCC2;
11016 break;
11017 case 2500: hashes_buf[0].salt->salt_iter = ROUNDS_WPA2;
11018 break;
11019 case 3200: hashes_buf[0].salt->salt_iter = ROUNDS_BCRYPT;
11020 break;
11021 case 5200: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE3;
11022 break;
11023 case 5800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDPIN - 1;
11024 break;
11025 case 6211:
11026 case 6212:
11027 case 6213: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_2K;
11028 break;
11029 case 6221:
11030 case 6222:
11031 case 6223: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11032 break;
11033 case 6231:
11034 case 6232:
11035 case 6233: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11036 break;
11037 case 6241:
11038 case 6242:
11039 case 6243: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11040 break;
11041 case 6300: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11042 break;
11043 case 6400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256AIX;
11044 break;
11045 case 6500: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512AIX;
11046 break;
11047 case 6700: hashes_buf[0].salt->salt_iter = ROUNDS_SHA1AIX;
11048 break;
11049 case 6600: hashes_buf[0].salt->salt_iter = ROUNDS_AGILEKEY;
11050 break;
11051 case 6800: hashes_buf[0].salt->salt_iter = ROUNDS_LASTPASS;
11052 break;
11053 case 7100: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512OSX;
11054 break;
11055 case 7200: hashes_buf[0].salt->salt_iter = ROUNDS_GRUB;
11056 break;
11057 case 7400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256CRYPT;
11058 break;
11059 case 7900: hashes_buf[0].salt->salt_iter = ROUNDS_DRUPAL7;
11060 break;
11061 case 8200: hashes_buf[0].salt->salt_iter = ROUNDS_CLOUDKEY;
11062 break;
11063 case 8300: hashes_buf[0].salt->salt_iter = ROUNDS_NSEC3;
11064 break;
11065 case 8800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDFDE;
11066 break;
11067 case 8900: hashes_buf[0].salt->salt_iter = 1;
11068 break;
11069 case 9000: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE2;
11070 break;
11071 case 9100: hashes_buf[0].salt->salt_iter = ROUNDS_LOTUS8;
11072 break;
11073 case 9200: hashes_buf[0].salt->salt_iter = ROUNDS_CISCO8;
11074 break;
11075 case 9300: hashes_buf[0].salt->salt_iter = 1;
11076 break;
11077 case 9400: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2007;
11078 break;
11079 case 9500: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2010;
11080 break;
11081 case 9600: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2013;
11082 break;
11083 case 10000: hashes_buf[0].salt->salt_iter = ROUNDS_DJANGOPBKDF2;
11084 break;
11085 case 10300: hashes_buf[0].salt->salt_iter = ROUNDS_SAPH_SHA1 - 1;
11086 break;
11087 case 10500: hashes_buf[0].salt->salt_iter = ROUNDS_PDF14;
11088 break;
11089 case 10700: hashes_buf[0].salt->salt_iter = ROUNDS_PDF17L8;
11090 break;
11091 case 10900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA256 - 1;
11092 break;
11093 case 11300: hashes_buf[0].salt->salt_iter = ROUNDS_BITCOIN_WALLET - 1;
11094 break;
11095 case 11600: hashes_buf[0].salt->salt_iter = ROUNDS_SEVEN_ZIP;
11096 break;
11097 case 11900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_MD5 - 1;
11098 break;
11099 case 12000: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA1 - 1;
11100 break;
11101 case 12100: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA512 - 1;
11102 break;
11103 case 12200: hashes_buf[0].salt->salt_iter = ROUNDS_ECRYPTFS - 1;
11104 break;
11105 case 12300: hashes_buf[0].salt->salt_iter = ROUNDS_ORACLET - 1;
11106 break;
11107 case 12400: hashes_buf[0].salt->salt_iter = ROUNDS_BSDICRYPT - 1;
11108 break;
11109 case 12500: hashes_buf[0].salt->salt_iter = ROUNDS_RAR3;
11110 break;
11111 case 12700: hashes_buf[0].salt->salt_iter = ROUNDS_MYWALLET;
11112 break;
11113 case 12800: hashes_buf[0].salt->salt_iter = ROUNDS_MS_DRSR - 1;
11114 break;
11115 }
11116
11117 // set special tuning for benchmark-mode 1
11118
11119 if (benchmark_mode == 1)
11120 {
11121 gpu_loops *= 8;
11122 gpu_accel *= 4;
11123
11124 switch (hash_mode)
11125 {
11126 case 400: gpu_loops = ROUNDS_PHPASS;
11127 gpu_accel = 32;
11128 break;
11129 case 500: gpu_loops = ROUNDS_MD5CRYPT;
11130 gpu_accel = 32;
11131 break;
11132 case 501: gpu_loops = ROUNDS_MD5CRYPT;
11133 gpu_accel = 32;
11134 break;
11135 case 1600: gpu_loops = ROUNDS_MD5CRYPT;
11136 gpu_accel = 32;
11137 break;
11138 case 1800: gpu_loops = ROUNDS_SHA512CRYPT;
11139 gpu_accel = 16;
11140 break;
11141 case 2100: gpu_loops = ROUNDS_DCC2;
11142 gpu_accel = 16;
11143 break;
11144 case 2500: gpu_loops = ROUNDS_WPA2;
11145 gpu_accel = 32;
11146 break;
11147 case 3200: gpu_loops = ROUNDS_BCRYPT;
11148 gpu_accel = 8;
11149 break;
11150 case 5200: gpu_loops = ROUNDS_PSAFE3;
11151 gpu_accel = 16;
11152 break;
11153 case 5800: gpu_loops = ROUNDS_ANDROIDPIN;
11154 gpu_accel = 16;
11155 break;
11156 case 6211: gpu_loops = ROUNDS_TRUECRYPT_2K;
11157 gpu_accel = 64;
11158 break;
11159 case 6212: gpu_loops = ROUNDS_TRUECRYPT_2K;
11160 gpu_accel = 32;
11161 break;
11162 case 6213: gpu_loops = ROUNDS_TRUECRYPT_2K;
11163 gpu_accel = 32;
11164 break;
11165 case 6221: gpu_loops = ROUNDS_TRUECRYPT_1K;
11166 gpu_accel = 8;
11167 break;
11168 case 6222: gpu_loops = ROUNDS_TRUECRYPT_1K;
11169 gpu_accel = 8;
11170 break;
11171 case 6223: gpu_loops = ROUNDS_TRUECRYPT_1K;
11172 gpu_accel = 8;
11173 break;
11174 case 6231: gpu_loops = ROUNDS_TRUECRYPT_1K;
11175 gpu_accel = 8;
11176 break;
11177 case 6232: gpu_loops = ROUNDS_TRUECRYPT_1K;
11178 gpu_accel = 8;
11179 break;
11180 case 6233: gpu_loops = ROUNDS_TRUECRYPT_1K;
11181 gpu_accel = 8;
11182 break;
11183 case 6241: gpu_loops = ROUNDS_TRUECRYPT_1K;
11184 gpu_accel = 128;
11185 break;
11186 case 6242: gpu_loops = ROUNDS_TRUECRYPT_1K;
11187 gpu_accel = 64;
11188 break;
11189 case 6243: gpu_loops = ROUNDS_TRUECRYPT_1K;
11190 gpu_accel = 64;
11191 break;
11192 case 6300: gpu_loops = ROUNDS_MD5CRYPT;
11193 gpu_accel = 32;
11194 break;
11195 case 6700: gpu_loops = ROUNDS_SHA1AIX;
11196 gpu_accel = 128;
11197 break;
11198 case 6400: gpu_loops = ROUNDS_SHA256AIX;
11199 gpu_accel = 128;
11200 break;
11201 case 6500: gpu_loops = ROUNDS_SHA512AIX;
11202 gpu_accel = 32;
11203 break;
11204 case 6600: gpu_loops = ROUNDS_AGILEKEY;
11205 gpu_accel = 64;
11206 break;
11207 case 6800: gpu_loops = ROUNDS_LASTPASS;
11208 gpu_accel = 64;
11209 break;
11210 case 7100: gpu_loops = ROUNDS_SHA512OSX;
11211 gpu_accel = 8;
11212 break;
11213 case 7200: gpu_loops = ROUNDS_GRUB;
11214 gpu_accel = 16;
11215 break;
11216 case 7400: gpu_loops = ROUNDS_SHA256CRYPT;
11217 gpu_accel = 8;
11218 break;
11219 case 7900: gpu_loops = ROUNDS_DRUPAL7;
11220 gpu_accel = 8;
11221 break;
11222 case 8200: gpu_loops = ROUNDS_CLOUDKEY;
11223 gpu_accel = 8;
11224 break;
11225 case 8800: gpu_loops = ROUNDS_ANDROIDFDE;
11226 gpu_accel = 32;
11227 break;
11228 case 8900: gpu_loops = 1;
11229 gpu_accel = 64;
11230 break;
11231 case 9000: gpu_loops = ROUNDS_PSAFE2;
11232 gpu_accel = 16;
11233 break;
11234 case 9100: gpu_loops = ROUNDS_LOTUS8;
11235 gpu_accel = 64;
11236 break;
11237 case 9200: gpu_loops = ROUNDS_CISCO8;
11238 gpu_accel = 8;
11239 break;
11240 case 9300: gpu_loops = 1;
11241 gpu_accel = 4;
11242 break;
11243 case 9400: gpu_loops = ROUNDS_OFFICE2007;
11244 gpu_accel = 32;
11245 break;
11246 case 9500: gpu_loops = ROUNDS_OFFICE2010;
11247 gpu_accel = 32;
11248 break;
11249 case 9600: gpu_loops = ROUNDS_OFFICE2013;
11250 gpu_accel = 8;
11251 break;
11252 case 10000: gpu_loops = ROUNDS_DJANGOPBKDF2;
11253 gpu_accel = 8;
11254 break;
11255 case 10300: gpu_loops = ROUNDS_SAPH_SHA1;
11256 gpu_accel = 16;
11257 break;
11258 case 10500: gpu_loops = ROUNDS_PDF14;
11259 gpu_accel = 256;
11260 break;
11261 case 10700: gpu_loops = ROUNDS_PDF17L8;
11262 gpu_accel = 8;
11263 break;
11264 case 10900: gpu_loops = ROUNDS_PBKDF2_SHA256;
11265 gpu_accel = 8;
11266 break;
11267 case 11300: gpu_loops = ROUNDS_BITCOIN_WALLET;
11268 gpu_accel = 8;
11269 break;
11270 case 11600: gpu_loops = ROUNDS_SEVEN_ZIP;
11271 gpu_accel = 8;
11272 break;
11273 case 11900: gpu_loops = ROUNDS_PBKDF2_MD5;
11274 gpu_accel = 8;
11275 break;
11276 case 12000: gpu_loops = ROUNDS_PBKDF2_SHA1;
11277 gpu_accel = 8;
11278 break;
11279 case 12100: gpu_loops = ROUNDS_PBKDF2_SHA512;
11280 gpu_accel = 8;
11281 break;
11282 case 12200: gpu_loops = ROUNDS_ECRYPTFS;
11283 gpu_accel = 8;
11284 break;
11285 case 12300: gpu_loops = ROUNDS_ORACLET;
11286 gpu_accel = 8;
11287 break;
11288 case 12500: gpu_loops = ROUNDS_RAR3;
11289 gpu_accel = 32;
11290 break;
11291 case 12700: gpu_loops = ROUNDS_MYWALLET;
11292 gpu_accel = 512;
11293 break;
11294 case 12800: gpu_loops = ROUNDS_MS_DRSR;
11295 gpu_accel = 512;
11296 break;
11297 }
11298
11299 // some algorithm collide too fast, make that impossible
11300
11301 switch (hash_mode)
11302 {
11303 case 11500: ((uint *) digests_buf)[1] = 1;
11304 break;
11305 }
11306
11307 if (gpu_loops > 1024) gpu_loops = 1024;
11308 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
11309 }
11310
11311 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
11312 {
11313 gpu_loops = 1024;
11314 }
11315
11316 if (hash_mode == 12500)
11317 {
11318 gpu_loops = ROUNDS_RAR3 / 16;
11319 }
11320
11321 data.gpu_accel = gpu_accel;
11322 data.gpu_loops = gpu_loops;
11323
11324 hashes_cnt = 1;
11325 }
11326
11327 if (show == 1 || left == 1)
11328 {
11329 for (uint i = 0; i < pot_cnt; i++)
11330 {
11331 pot_t *pot_ptr = &pot[i];
11332
11333 hash_t *hashes_buf = &pot_ptr->hash;
11334
11335 local_free (hashes_buf->digest);
11336
11337 if (isSalted)
11338 {
11339 local_free (hashes_buf->salt);
11340 }
11341 }
11342
11343 local_free (pot);
11344
11345 if (data.quiet == 0) log_info_nn ("");
11346
11347 return (0);
11348 }
11349
11350 if (keyspace == 0)
11351 {
11352 if (hashes_cnt == 0)
11353 {
11354 log_error ("ERROR: No hashes loaded");
11355
11356 return (-1);
11357 }
11358 }
11359
11360 /**
11361 * Sanity check for hashfile vs outfile (should not point to the same physical file)
11362 */
11363
11364 if (data.outfile != NULL)
11365 {
11366 if (data.hashfile != NULL)
11367 {
11368 #ifdef _POSIX
11369 struct stat tmpstat_outfile;
11370 struct stat tmpstat_hashfile;
11371 #endif
11372
11373 #ifdef _WIN
11374 struct stat64 tmpstat_outfile;
11375 struct stat64 tmpstat_hashfile;
11376 #endif
11377
11378 FILE *tmp_outfile_fp = fopen (data.outfile, "r");
11379
11380 if (tmp_outfile_fp)
11381 {
11382 #ifdef _POSIX
11383 fstat (fileno (tmp_outfile_fp), &tmpstat_outfile);
11384 #endif
11385
11386 #ifdef _WIN
11387 _fstat64 (fileno (tmp_outfile_fp), &tmpstat_outfile);
11388 #endif
11389
11390 fclose (tmp_outfile_fp);
11391 }
11392
11393 FILE *tmp_hashfile_fp = fopen (data.hashfile, "r");
11394
11395 if (tmp_hashfile_fp)
11396 {
11397 #ifdef _POSIX
11398 fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
11399 #endif
11400
11401 #ifdef _WIN
11402 _fstat64 (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
11403 #endif
11404
11405 fclose (tmp_hashfile_fp);
11406 }
11407
11408 if (tmp_outfile_fp && tmp_outfile_fp)
11409 {
11410 tmpstat_outfile.st_mode = 0;
11411 tmpstat_outfile.st_nlink = 0;
11412 tmpstat_outfile.st_uid = 0;
11413 tmpstat_outfile.st_gid = 0;
11414 tmpstat_outfile.st_rdev = 0;
11415 tmpstat_outfile.st_atime = 0;
11416
11417 tmpstat_hashfile.st_mode = 0;
11418 tmpstat_hashfile.st_nlink = 0;
11419 tmpstat_hashfile.st_uid = 0;
11420 tmpstat_hashfile.st_gid = 0;
11421 tmpstat_hashfile.st_rdev = 0;
11422 tmpstat_hashfile.st_atime = 0;
11423
11424 #ifdef _POSIX
11425 tmpstat_outfile.st_blksize = 0;
11426 tmpstat_outfile.st_blocks = 0;
11427
11428 tmpstat_hashfile.st_blksize = 0;
11429 tmpstat_hashfile.st_blocks = 0;
11430 #endif
11431
11432 #ifdef _POSIX
11433 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat)) == 0)
11434 {
11435 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
11436
11437 return (-1);
11438 }
11439 #endif
11440
11441 #ifdef _WIN
11442 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat64)) == 0)
11443 {
11444 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
11445
11446 return (-1);
11447 }
11448 #endif
11449 }
11450 }
11451 }
11452
11453 /**
11454 * Remove duplicates
11455 */
11456
11457 if (data.quiet == 0) log_info_nn ("Removing duplicate hashes...");
11458
11459 if (isSalted)
11460 {
11461 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
11462 }
11463 else
11464 {
11465 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
11466 }
11467
11468 uint hashes_cnt_orig = hashes_cnt;
11469
11470 hashes_cnt = 1;
11471
11472 for (uint hashes_pos = 1; hashes_pos < hashes_cnt_orig; hashes_pos++)
11473 {
11474 if (isSalted)
11475 {
11476 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) == 0)
11477 {
11478 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
11479 }
11480 }
11481 else
11482 {
11483 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
11484 }
11485
11486 if (hashes_pos > hashes_cnt)
11487 {
11488 memcpy (&hashes_buf[hashes_cnt], &hashes_buf[hashes_pos], sizeof (hash_t));
11489 }
11490
11491 hashes_cnt++;
11492 }
11493
11494 /**
11495 * Potfile removes
11496 */
11497
11498 uint potfile_remove_cracks = 0;
11499
11500 if (potfile_disable == 0)
11501 {
11502 hash_t hash_buf;
11503
11504 hash_buf.digest = mymalloc (dgst_size);
11505 hash_buf.salt = NULL;
11506 hash_buf.esalt = NULL;
11507 hash_buf.hash_info = NULL;
11508 hash_buf.cracked = 0;
11509
11510 if (isSalted)
11511 {
11512 hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
11513 }
11514
11515 if (esalt_size)
11516 {
11517 hash_buf.esalt = mymalloc (esalt_size);
11518 }
11519
11520 if (quiet == 0) log_info_nn ("Comparing hashes with potfile entries...");
11521
11522 // no solution for these special hash types (for instane because they use hashfile in output etc)
11523 if ((hash_mode != 5200) &&
11524 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
11525 (hash_mode != 9000))
11526 {
11527 FILE *fp = fopen (potfile, "rb");
11528
11529 if (fp != NULL)
11530 {
11531 while (!feof (fp))
11532 {
11533 char line_buf[BUFSIZ];
11534
11535 memset (line_buf, 0, BUFSIZ);
11536
11537 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
11538
11539 if (ptr == NULL) break;
11540
11541 int line_len = strlen (line_buf);
11542
11543 if (line_len == 0) continue;
11544
11545 int iter = MAX_CUT_TRIES;
11546
11547 for (int i = line_len - 1; i && iter; i--, line_len--)
11548 {
11549 if (line_buf[i] != ':') continue;
11550
11551 if (isSalted)
11552 {
11553 memset (hash_buf.salt, 0, sizeof (salt_t));
11554 }
11555
11556 hash_t *found = NULL;
11557
11558 if (hash_mode == 6800)
11559 {
11560 if (i < 48) // 48 = 12 * uint in salt_buf[]
11561 {
11562 // manipulate salt_buf
11563 memcpy (hash_buf.salt->salt_buf, line_buf, i);
11564
11565 hash_buf.salt->salt_len = i;
11566
11567 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt);
11568 }
11569 }
11570 else if (hash_mode == 2500)
11571 {
11572 if (i < 48) // 48 = 12 * uint in salt_buf[]
11573 {
11574 // here we have in line_buf: ESSID:MAC1:MAC2 (without the plain)
11575 // manipulate salt_buf
11576
11577 // to be safe work with a copy (because of line_len loop, i etc)
11578
11579 char line_buf_cpy[BUFSIZ];
11580 memset (line_buf_cpy, 0, BUFSIZ);
11581
11582 memset (line_buf_cpy, 0, sizeof (line_buf_cpy));
11583
11584 memcpy (line_buf_cpy, line_buf, i);
11585
11586 char *mac2_pos = strrchr (line_buf_cpy, ':');
11587
11588 if (mac2_pos == NULL) continue;
11589
11590 mac2_pos[0] = 0;
11591 mac2_pos++;
11592
11593 if (strlen (mac2_pos) != 12) continue;
11594
11595 char *mac1_pos = strrchr (line_buf_cpy, ':');
11596
11597 if (mac1_pos == NULL) continue;
11598
11599 mac1_pos[0] = 0;
11600 mac1_pos++;
11601
11602 if (strlen (mac1_pos) != 12) continue;
11603
11604 uint essid_length = mac1_pos - line_buf_cpy - 1;
11605
11606 // here we need the ESSID
11607 memcpy (hash_buf.salt->salt_buf, line_buf_cpy, essid_length);
11608
11609 hash_buf.salt->salt_len = essid_length;
11610
11611 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt_hccap);
11612
11613 if (found)
11614 {
11615 wpa_t *wpa = (wpa_t *) found->esalt;
11616
11617 uint pke[25];
11618
11619 char *pke_ptr = (char *) pke;
11620
11621 for (uint i = 0; i < 25; i++)
11622 {
11623 pke[i] = byte_swap_32 (wpa->pke[i]);
11624 }
11625
11626 unsigned char mac1[6];
11627 unsigned char mac2[6];
11628
11629 memcpy (mac1, pke_ptr + 23, 6);
11630 memcpy (mac2, pke_ptr + 29, 6);
11631
11632 // compare hex string(s) vs binary MAC address(es)
11633
11634 for (uint i = 0, j = 0; i < 6; i++, j += 2)
11635 {
11636 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
11637 {
11638 found = NULL;
11639 break;
11640 }
11641 }
11642
11643 // early skip ;)
11644 if (!found) continue;
11645
11646 for (uint i = 0, j = 0; i < 6; i++, j += 2)
11647 {
11648 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
11649 {
11650 found = NULL;
11651 break;
11652 }
11653 }
11654 }
11655 }
11656 }
11657 else
11658 {
11659 int parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
11660
11661 if (parser_status == PARSER_OK)
11662 {
11663 if (isSalted)
11664 {
11665 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
11666 }
11667 else
11668 {
11669 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
11670 }
11671 }
11672 }
11673
11674 if (found == NULL) continue;
11675
11676 if (!found->cracked) potfile_remove_cracks++;
11677
11678 found->cracked = 1;
11679
11680 if (found) break;
11681
11682 iter--;
11683 }
11684 }
11685
11686 fclose (fp);
11687 }
11688 }
11689
11690 if (esalt_size)
11691 {
11692 local_free (hash_buf.esalt);
11693 }
11694
11695 if (isSalted)
11696 {
11697 local_free (hash_buf.salt);
11698 }
11699
11700 local_free (hash_buf.digest);
11701 }
11702
11703 /**
11704 * Now generate all the buffers required for later
11705 */
11706
11707 void *digests_buf_new = (void *) mycalloc (hashes_avail, dgst_size);
11708
11709 salt_t *salts_buf_new = NULL;
11710 void *esalts_buf_new = NULL;
11711
11712 if (isSalted)
11713 {
11714 salts_buf_new = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
11715
11716 if (esalt_size)
11717 {
11718 esalts_buf_new = (void *) mycalloc (hashes_avail, esalt_size);
11719 }
11720 }
11721 else
11722 {
11723 salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t));
11724 }
11725
11726 if (data.quiet == 0) log_info_nn ("Structuring salts for cracking task...");
11727
11728 uint digests_cnt = hashes_cnt;
11729 uint digests_done = 0;
11730
11731 uint size_digests = digests_cnt * dgst_size;
11732 uint size_shown = digests_cnt * sizeof (uint);
11733
11734 uint *digests_shown = (uint *) mymalloc (size_shown);
11735 uint *digests_shown_tmp = (uint *) mymalloc (size_shown);
11736
11737 uint salts_cnt = 0;
11738 uint salts_done = 0;
11739
11740 hashinfo_t **hash_info = NULL;
11741
11742 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11743 {
11744 hash_info = (hashinfo_t**) mymalloc (hashes_cnt * sizeof (hashinfo_t *));
11745
11746 if (username && (remove || show))
11747 {
11748 uint user_pos;
11749
11750 for (user_pos = 0; user_pos < hashes_cnt; user_pos++)
11751 {
11752 hash_info[user_pos] = (hashinfo_t*) mycalloc (hashes_cnt, sizeof (hashinfo_t));
11753
11754 hash_info[user_pos]->user = (user_t*) mymalloc (sizeof (user_t));
11755 }
11756 }
11757 }
11758
11759 uint *salts_shown = (uint *) mymalloc (size_shown);
11760
11761 salt_t *salt_buf;
11762
11763 {
11764 // copied from inner loop
11765
11766 salt_buf = &salts_buf_new[salts_cnt];
11767
11768 memcpy (salt_buf, hashes_buf[0].salt, sizeof (salt_t));
11769
11770 if (esalt_size)
11771 {
11772 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[0].esalt, esalt_size);
11773 }
11774
11775 salt_buf->digests_cnt = 0;
11776 salt_buf->digests_done = 0;
11777 salt_buf->digests_offset = 0;
11778
11779 salts_cnt++;
11780 }
11781
11782 if (hashes_buf[0].cracked == 1)
11783 {
11784 digests_shown[0] = 1;
11785
11786 digests_done++;
11787
11788 salt_buf->digests_done++;
11789 }
11790
11791 salt_buf->digests_cnt++;
11792
11793 memcpy (((char *) digests_buf_new) + (0 * dgst_size), hashes_buf[0].digest, dgst_size);
11794
11795 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11796 {
11797 hash_info[0] = hashes_buf[0].hash_info;
11798 }
11799
11800 // copy from inner loop
11801
11802 for (uint hashes_pos = 1; hashes_pos < hashes_cnt; hashes_pos++)
11803 {
11804 if (isSalted)
11805 {
11806 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) != 0)
11807 {
11808 salt_buf = &salts_buf_new[salts_cnt];
11809
11810 memcpy (salt_buf, hashes_buf[hashes_pos].salt, sizeof (salt_t));
11811
11812 if (esalt_size)
11813 {
11814 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[hashes_pos].esalt, esalt_size);
11815 }
11816
11817 salt_buf->digests_cnt = 0;
11818 salt_buf->digests_done = 0;
11819 salt_buf->digests_offset = hashes_pos;
11820
11821 salts_cnt++;
11822 }
11823 }
11824
11825 if (hashes_buf[hashes_pos].cracked == 1)
11826 {
11827 digests_shown[hashes_pos] = 1;
11828
11829 digests_done++;
11830
11831 salt_buf->digests_done++;
11832 }
11833
11834 salt_buf->digests_cnt++;
11835
11836 memcpy (((char *) digests_buf_new) + (hashes_pos * dgst_size), hashes_buf[hashes_pos].digest, dgst_size);
11837
11838 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11839 {
11840 hash_info[hashes_pos] = hashes_buf[hashes_pos].hash_info;
11841 }
11842 }
11843
11844 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
11845 {
11846 salt_t *salt_buf = &salts_buf_new[salt_pos];
11847
11848 if (salt_buf->digests_done == salt_buf->digests_cnt)
11849 {
11850 salts_shown[salt_pos] = 1;
11851
11852 salts_done++;
11853 }
11854
11855 if (salts_done == salts_cnt) data.devices_status = STATUS_CRACKED;
11856 }
11857
11858 local_free (digests_buf);
11859 local_free (salts_buf);
11860 local_free (esalts_buf);
11861
11862 digests_buf = digests_buf_new;
11863 salts_buf = salts_buf_new;
11864 esalts_buf = esalts_buf_new;
11865
11866 local_free (hashes_buf);
11867
11868 /**
11869 * special modification not set from parser
11870 */
11871
11872 switch (hash_mode)
11873 {
11874 case 6211: salts_buf->truecrypt_mdlen = 1 * 512; break;
11875 case 6212: salts_buf->truecrypt_mdlen = 2 * 512; break;
11876 case 6213: salts_buf->truecrypt_mdlen = 3 * 512; break;
11877 case 6221: salts_buf->truecrypt_mdlen = 1 * 512; break;
11878 case 6222: salts_buf->truecrypt_mdlen = 2 * 512; break;
11879 case 6223: salts_buf->truecrypt_mdlen = 3 * 512; break;
11880 case 6231: salts_buf->truecrypt_mdlen = 1 * 512; break;
11881 case 6232: salts_buf->truecrypt_mdlen = 2 * 512; break;
11882 case 6233: salts_buf->truecrypt_mdlen = 3 * 512; break;
11883 case 6241: salts_buf->truecrypt_mdlen = 1 * 512; break;
11884 case 6242: salts_buf->truecrypt_mdlen = 2 * 512; break;
11885 case 6243: salts_buf->truecrypt_mdlen = 3 * 512; break;
11886 }
11887
11888 if (truecrypt_keyfiles)
11889 {
11890 uint *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf;
11891
11892 char *keyfiles = strdup (truecrypt_keyfiles);
11893
11894 char *keyfile = strtok (keyfiles, ",");
11895
11896 do
11897 {
11898 truecrypt_crc32 (keyfile, (unsigned char *) keyfile_buf);
11899
11900 } while ((keyfile = strtok (NULL, ",")) != NULL);
11901
11902 free (keyfiles);
11903 }
11904
11905 data.digests_cnt = digests_cnt;
11906 data.digests_done = digests_done;
11907 data.digests_buf = digests_buf;
11908 data.digests_shown = digests_shown;
11909 data.digests_shown_tmp = digests_shown_tmp;
11910
11911 data.salts_cnt = salts_cnt;
11912 data.salts_done = salts_done;
11913 data.salts_buf = salts_buf;
11914 data.salts_shown = salts_shown;
11915
11916 data.esalts_buf = esalts_buf;
11917 data.hash_info = hash_info;
11918
11919 /**
11920 * Automatic Optimizers
11921 */
11922
11923 if (salts_cnt == 1)
11924 opti_type |= OPTI_TYPE_SINGLE_SALT;
11925
11926 if (digests_cnt == 1)
11927 opti_type |= OPTI_TYPE_SINGLE_HASH;
11928
11929 if (attack_exec == ATTACK_EXEC_ON_GPU)
11930 opti_type |= OPTI_TYPE_NOT_ITERATED;
11931
11932 if (attack_mode == ATTACK_MODE_BF)
11933 opti_type |= OPTI_TYPE_BRUTE_FORCE;
11934
11935 data.opti_type = opti_type;
11936
11937 if (opti_type & OPTI_TYPE_BRUTE_FORCE)
11938 {
11939 if (opti_type & OPTI_TYPE_SINGLE_HASH)
11940 {
11941 if (opti_type & OPTI_TYPE_APPENDED_SALT)
11942 {
11943 if (opts_type & OPTS_TYPE_ST_ADD80)
11944 {
11945 opts_type &= ~OPTS_TYPE_ST_ADD80;
11946 opts_type |= OPTS_TYPE_PT_ADD80;
11947 }
11948
11949 if (opts_type & OPTS_TYPE_ST_ADDBITS14)
11950 {
11951 opts_type &= ~OPTS_TYPE_ST_ADDBITS14;
11952 opts_type |= OPTS_TYPE_PT_ADDBITS14;
11953 }
11954
11955 if (opts_type & OPTS_TYPE_ST_ADDBITS15)
11956 {
11957 opts_type &= ~OPTS_TYPE_ST_ADDBITS15;
11958 opts_type |= OPTS_TYPE_PT_ADDBITS15;
11959 }
11960 }
11961 }
11962 }
11963
11964 /**
11965 * Some algorithm, like descrypt, can benefit from JIT compilation
11966 */
11967
11968 uint force_jit_compilation = 0;
11969
11970 if (hash_mode == 8900)
11971 {
11972 force_jit_compilation = 8900;
11973 }
11974 else if (hash_mode == 9300)
11975 {
11976 force_jit_compilation = 8900;
11977 }
11978 else if (hash_mode == 1500 && attack_mode == ATTACK_MODE_BF && data.salts_cnt == 1)
11979 {
11980 force_jit_compilation = 1500;
11981 }
11982
11983 /**
11984 * generate bitmap tables
11985 */
11986
11987 const uint bitmap_shift1 = 5;
11988 const uint bitmap_shift2 = 13;
11989
11990 if (bitmap_max < bitmap_min) bitmap_max = bitmap_min;
11991
11992 uint *bitmap_s1_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
11993 uint *bitmap_s1_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
11994 uint *bitmap_s1_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
11995 uint *bitmap_s1_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
11996 uint *bitmap_s2_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
11997 uint *bitmap_s2_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
11998 uint *bitmap_s2_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
11999 uint *bitmap_s2_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12000
12001 uint bitmap_bits;
12002 uint bitmap_nums;
12003 uint bitmap_mask;
12004 uint bitmap_size;
12005
12006 for (bitmap_bits = bitmap_min; bitmap_bits < bitmap_max; bitmap_bits++)
12007 {
12008 if (data.quiet == 0) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits);
12009
12010 bitmap_nums = 1 << bitmap_bits;
12011
12012 bitmap_mask = bitmap_nums - 1;
12013
12014 bitmap_size = bitmap_nums * sizeof (uint);
12015
12016 if ((hashes_cnt & bitmap_mask) == hashes_cnt) break;
12017
12018 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;
12019 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;
12020
12021 break;
12022 }
12023
12024 bitmap_nums = 1 << bitmap_bits;
12025
12026 bitmap_mask = bitmap_nums - 1;
12027
12028 bitmap_size = bitmap_nums * sizeof (uint);
12029
12030 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);
12031 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);
12032
12033 /**
12034 * prepare quick rule
12035 */
12036
12037 data.rule_buf_l = rule_buf_l;
12038 data.rule_buf_r = rule_buf_r;
12039
12040 int rule_len_l = (int) strlen (rule_buf_l);
12041 int rule_len_r = (int) strlen (rule_buf_r);
12042
12043 data.rule_len_l = rule_len_l;
12044 data.rule_len_r = rule_len_r;
12045
12046 /**
12047 * load rules
12048 */
12049
12050 uint *all_gpu_rules_cnt = NULL;
12051
12052 gpu_rule_t **all_gpu_rules_buf = NULL;
12053
12054 if (rp_files_cnt)
12055 {
12056 all_gpu_rules_cnt = (uint *) mycalloc (rp_files_cnt, sizeof (uint));
12057
12058 all_gpu_rules_buf = (gpu_rule_t **) mycalloc (rp_files_cnt, sizeof (gpu_rule_t *));
12059 }
12060
12061 char rule_buf[BUFSIZ];
12062
12063 int rule_len = 0;
12064
12065 for (uint i = 0; i < rp_files_cnt; i++)
12066 {
12067 uint gpu_rules_avail = 0;
12068
12069 uint gpu_rules_cnt = 0;
12070
12071 gpu_rule_t *gpu_rules_buf = NULL;
12072
12073 char *rp_file = rp_files[i];
12074
12075 char in[BLOCK_SIZE];
12076 char out[BLOCK_SIZE];
12077
12078 FILE *fp = NULL;
12079
12080 uint rule_line = 0;
12081
12082 if ((fp = fopen (rp_file, "rb")) == NULL)
12083 {
12084 log_error ("ERROR: %s: %s", rp_file, strerror (errno));
12085
12086 return (-1);
12087 }
12088
12089 while (!feof (fp))
12090 {
12091 memset (rule_buf, 0, BUFSIZ);
12092
12093 rule_len = fgetl (fp, rule_buf);
12094
12095 rule_line++;
12096
12097 if (rule_len == 0) continue;
12098
12099 if (rule_buf[0] == '#') continue;
12100
12101 if (gpu_rules_avail == gpu_rules_cnt)
12102 {
12103 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12104
12105 gpu_rules_avail += INCR_RULES;
12106 }
12107
12108 memset (in, 0, BLOCK_SIZE);
12109 memset (out, 0, BLOCK_SIZE);
12110
12111 int result = _old_apply_rule (rule_buf, rule_len, in, 1, out);
12112
12113 if (result == -1)
12114 {
12115 log_info ("WARNING: Skipping invalid or unsupported rule in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12116
12117 continue;
12118 }
12119
12120 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1)
12121 {
12122 log_info ("WARNING: Cannot convert rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12123
12124 memset (&gpu_rules_buf[gpu_rules_cnt], 0, sizeof (gpu_rule_t)); // needs to be cleared otherwise we could have some remaining data
12125
12126 continue;
12127 }
12128
12129 /* its so slow
12130 if (rulefind (&gpu_rules_buf[gpu_rules_cnt], gpu_rules_buf, gpu_rules_cnt, sizeof (gpu_rule_t), sort_by_gpu_rule))
12131 {
12132 log_info ("Duplicate rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12133
12134 continue;
12135 }
12136 */
12137
12138 gpu_rules_cnt++;
12139 }
12140
12141 fclose (fp);
12142
12143 all_gpu_rules_cnt[i] = gpu_rules_cnt;
12144
12145 all_gpu_rules_buf[i] = gpu_rules_buf;
12146 }
12147
12148 /**
12149 * merge rules or automatic rule generator
12150 */
12151
12152 uint gpu_rules_cnt = 0;
12153
12154 gpu_rule_t *gpu_rules_buf = NULL;
12155
12156 if (attack_mode == ATTACK_MODE_STRAIGHT)
12157 {
12158 if (rp_files_cnt)
12159 {
12160 gpu_rules_cnt = 1;
12161
12162 uint *repeats = (uint *) mycalloc (rp_files_cnt + 1, sizeof (uint));
12163
12164 repeats[0] = gpu_rules_cnt;
12165
12166 for (uint i = 0; i < rp_files_cnt; i++)
12167 {
12168 gpu_rules_cnt *= all_gpu_rules_cnt[i];
12169
12170 repeats[i + 1] = gpu_rules_cnt;
12171 }
12172
12173 gpu_rules_buf = (gpu_rule_t *) mycalloc (gpu_rules_cnt, sizeof (gpu_rule_t));
12174
12175 memset (gpu_rules_buf, 0, gpu_rules_cnt * sizeof (gpu_rule_t));
12176
12177 for (uint i = 0; i < gpu_rules_cnt; i++)
12178 {
12179 uint out_pos = 0;
12180
12181 gpu_rule_t *out = &gpu_rules_buf[i];
12182
12183 for (uint j = 0; j < rp_files_cnt; j++)
12184 {
12185 uint in_off = (i / repeats[j]) % all_gpu_rules_cnt[j];
12186 uint in_pos;
12187
12188 gpu_rule_t *in = &all_gpu_rules_buf[j][in_off];
12189
12190 for (in_pos = 0; in->cmds[in_pos]; in_pos++, out_pos++)
12191 {
12192 if (out_pos == RULES_MAX - 1)
12193 {
12194 // log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
12195
12196 break;
12197 }
12198
12199 out->cmds[out_pos] = in->cmds[in_pos];
12200 }
12201 }
12202 }
12203
12204 local_free (repeats);
12205 }
12206 else if (rp_gen)
12207 {
12208 uint gpu_rules_avail = 0;
12209
12210 while (gpu_rules_cnt < rp_gen)
12211 {
12212 if (gpu_rules_avail == gpu_rules_cnt)
12213 {
12214 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12215
12216 gpu_rules_avail += INCR_RULES;
12217 }
12218
12219 memset (rule_buf, 0, BLOCK_SIZE);
12220
12221 rule_len = (int) generate_random_rule (rule_buf, rp_gen_func_min, rp_gen_func_max);
12222
12223 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1) continue;
12224
12225 gpu_rules_cnt++;
12226 }
12227 }
12228 }
12229
12230 /**
12231 * generate NOP rules
12232 */
12233
12234 if (gpu_rules_cnt == 0)
12235 {
12236 gpu_rules_buf = (gpu_rule_t *) mymalloc (sizeof (gpu_rule_t));
12237
12238 gpu_rules_buf[gpu_rules_cnt].cmds[0] = RULE_OP_MANGLE_NOOP;
12239
12240 gpu_rules_cnt++;
12241 }
12242
12243 data.gpu_rules_cnt = gpu_rules_cnt;
12244 data.gpu_rules_buf = gpu_rules_buf;
12245
12246 /**
12247 * platform
12248 */
12249
12250 cl_platform_id CL_platforms[CL_PLATFORMS_MAX];
12251
12252 uint CL_platforms_cnt = 0;
12253
12254 hc_clGetPlatformIDs (CL_PLATFORMS_MAX, CL_platforms, &CL_platforms_cnt);
12255
12256 if (CL_platforms_cnt == 0)
12257 {
12258 log_error ("ERROR: No OpenCL compatible platform found");
12259
12260 return (-1);
12261 }
12262
12263 uint CL_platform_sel = 0;
12264
12265 if (CL_platforms_cnt > 1)
12266 {
12267 if (gpu_platform == NULL)
12268 {
12269 log_error ("ERROR: Too many OpenCL compatible platforms found");
12270 log_error (" Please select a single platform using the --gpu-platform option");
12271 log_error ("");
12272 log_error ("Available OpenCL platforms:");
12273
12274 for (uint i = 0; i < CL_platforms_cnt; i++)
12275 {
12276 char CL_platform_vendor[INFOSZ];
12277
12278 memset (CL_platform_vendor, 0, sizeof (CL_platform_vendor));
12279
12280 hc_clGetPlatformInfo (CL_platforms[i], CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
12281
12282 printf ("* %d = %s\n", i + 1, CL_platform_vendor);
12283 }
12284
12285 return (-1);
12286 }
12287 else
12288 {
12289 CL_platform_sel = atoi (gpu_platform);
12290
12291 if (CL_platform_sel > CL_platforms_cnt)
12292 {
12293 log_error ("ERROR: invalid OpenCL platforms selected");
12294
12295 return (-1);
12296 }
12297 }
12298 }
12299
12300 cl_platform_id CL_platform = CL_platforms[CL_platform_sel - 1];
12301
12302 char CL_platform_vendor[INFOSZ];
12303
12304 memset (CL_platform_vendor, 0, sizeof (CL_platform_vendor));
12305
12306 hc_clGetPlatformInfo (CL_platform, CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
12307
12308 uint vendor_id;
12309
12310 if (strcmp (CL_platform_vendor, CL_VENDOR_AMD) == 0)
12311 {
12312 vendor_id = VENDOR_ID_AMD;
12313 }
12314 else if (strcmp (CL_platform_vendor, CL_VENDOR_NV) == 0)
12315 {
12316 vendor_id = VENDOR_ID_NV;
12317
12318 // make sure that we do not directly control the fan for NVidia
12319
12320 gpu_temp_retain = 0;
12321 data.gpu_temp_retain = gpu_temp_retain;
12322 }
12323 else
12324 {
12325 vendor_id = VENDOR_ID_UNKNOWN;
12326 }
12327
12328 if (vendor_id == VENDOR_ID_UNKNOWN)
12329 {
12330 log_error ("Warning: unknown OpenCL vendor '%s' detected", CL_platform_vendor);
12331
12332 gpu_temp_disable = 1;
12333 }
12334
12335 data.vendor_id = vendor_id;
12336
12337 /**
12338 * devices
12339 */
12340
12341 cl_device_id devices_all[DEVICES_MAX];
12342 cl_device_id devices[DEVICES_MAX];
12343
12344 uint devices_all_cnt = 0;
12345
12346 hc_clGetDeviceIDs (CL_platform, CL_DEVICE_TYPE_GPU, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
12347
12348 int hm_adapters_all = devices_all_cnt;
12349
12350 hm_attrs_t hm_adapter_all[DEVICES_MAX];
12351
12352 memset (hm_adapter_all, 0, sizeof (hm_adapter_all));
12353
12354 if (gpu_temp_disable == 0)
12355 {
12356 if (vendor_id == VENDOR_ID_NV)
12357 {
12358 #ifdef LINUX
12359 HM_LIB hm_dll = hm_init ();
12360
12361 data.hm_dll = hm_dll;
12362
12363 if (hc_NVML_nvmlInit (hm_dll) == NVML_SUCCESS)
12364 {
12365 HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX];
12366
12367 int tmp_in = hm_get_adapter_index_nv (nvGPUHandle);
12368
12369 int tmp_out = 0;
12370
12371 for (int i = 0; i < tmp_in; i++)
12372 {
12373 hm_adapter_all[tmp_out++].adapter_index.nv = nvGPUHandle[i];
12374 }
12375
12376 hm_adapters_all = tmp_out;
12377
12378 for (int i = 0; i < tmp_out; i++)
12379 {
12380 unsigned int speed;
12381
12382 if (hc_NVML_nvmlDeviceGetFanSpeed (hm_dll, 1, hm_adapter_all[i].adapter_index.nv, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
12383 }
12384 }
12385 #endif
12386
12387 #ifdef WIN
12388 if (NvAPI_Initialize () == NVAPI_OK)
12389 {
12390 HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX];
12391
12392 int tmp_in = hm_get_adapter_index_nv (nvGPUHandle);
12393
12394 int tmp_out = 0;
12395
12396 for (int i = 0; i < tmp_in; i++)
12397 {
12398 hm_adapter_all[tmp_out++].adapter_index.nv = nvGPUHandle[i];
12399 }
12400
12401 hm_adapters_all = tmp_out;
12402
12403 for (int i = 0; i < tmp_out; i++)
12404 {
12405 NvU32 speed;
12406
12407 if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index.nv, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
12408 }
12409 }
12410 #endif
12411 }
12412
12413 if (vendor_id == VENDOR_ID_AMD)
12414 {
12415 HM_LIB hm_dll = hm_init ();
12416
12417 data.hm_dll = hm_dll;
12418
12419 if (hc_ADL_Main_Control_Create (hm_dll, ADL_Main_Memory_Alloc, 0) == ADL_OK)
12420 {
12421 // total number of adapters
12422
12423 int hm_adapters_num;
12424
12425 if (get_adapters_num_amd (hm_dll, &hm_adapters_num) != 0) return (-1);
12426
12427 // adapter info
12428
12429 LPAdapterInfo lpAdapterInfo = hm_get_adapter_info_amd (hm_dll, hm_adapters_num);
12430
12431 if (lpAdapterInfo == NULL) return (-1);
12432
12433 // get a list (of ids of) valid/usable adapters
12434
12435 int num_adl_adapters = 0;
12436
12437 uint32_t *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo);
12438
12439 if (num_adl_adapters > 0)
12440 {
12441 hc_thread_mutex_lock (mux_adl);
12442
12443 // hm_get_opencl_busid_devid (hm_adapter_all, devices_all_cnt, devices_all);
12444
12445 hm_get_adapter_index_amd (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
12446
12447 hm_get_overdrive_version (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
12448 hm_check_fanspeed_control (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
12449
12450 hc_thread_mutex_unlock (mux_adl);
12451 }
12452
12453 hm_adapters_all = num_adl_adapters;
12454
12455 myfree (valid_adl_device_list);
12456 myfree (lpAdapterInfo);
12457 }
12458 }
12459 }
12460
12461 if (hm_adapters_all == 0)
12462 {
12463 gpu_temp_disable = 1;
12464 }
12465
12466 if (gpu_temp_disable == 1)
12467 {
12468 gpu_temp_abort = 0;
12469 gpu_temp_retain = 0;
12470 }
12471
12472 /**
12473 * enable custom signal handler(s)
12474 */
12475
12476 if (benchmark == 0)
12477 {
12478 hc_signal (sigHandler_default);
12479 }
12480 else
12481 {
12482 hc_signal (sigHandler_benchmark);
12483 }
12484
12485 /**
12486 * devices mask and properties
12487 */
12488
12489 uint devices_cnt = 0;
12490
12491 for (uint device_all_id = 0; device_all_id < devices_all_cnt; device_all_id++)
12492 {
12493 if (gpu_devicemask)
12494 {
12495 uint device_all_id_mask = 1 << device_all_id;
12496
12497 if ((device_all_id_mask & gpu_devicemask) != device_all_id_mask)
12498 {
12499 if (quiet == 0 && algorithm_pos == 0) log_info ("Device #%d: skipped by user", device_all_id_mask + 1);
12500
12501 continue;
12502 }
12503 }
12504
12505 const uint device_id = devices_cnt;
12506
12507 devices[device_id] = devices_all[device_all_id];
12508
12509 memcpy (&data.hm_device[device_id], &hm_adapter_all[device_all_id], sizeof (hm_attrs_t));
12510
12511 char device_name[INFOSZ];
12512
12513 memset (device_name, 0, sizeof (device_name));
12514
12515 cl_ulong global_mem_size;
12516 cl_ulong max_mem_alloc_size;
12517 cl_uint max_clock_frequency;
12518 cl_uint max_compute_units;
12519
12520 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_NAME, sizeof (device_name), &device_name, NULL);
12521 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (global_mem_size), &global_mem_size, NULL);
12522 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL);
12523 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (max_clock_frequency), &max_clock_frequency, NULL);
12524 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
12525
12526 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
12527 {
12528 log_info ("Device #%u: %s, %lu/%lu MB allocatable, %dMhz, %uMCU",
12529 device_all_id + 1,
12530 device_name,
12531 (unsigned int) (max_mem_alloc_size / 1024 / 1024),
12532 (unsigned int) (global_mem_size / 1024 / 1024),
12533 (unsigned int) (max_clock_frequency),
12534 (unsigned int) max_compute_units);
12535 }
12536
12537 devices_cnt++;
12538 }
12539
12540 if (devices_cnt == 0)
12541 {
12542 log_error ("ERROR: No devices left that matches your specification.");
12543
12544 return (-1);
12545 }
12546
12547 data.devices_cnt = devices_cnt;
12548
12549 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
12550 {
12551 log_info ("");
12552 }
12553
12554 /**
12555 * inform the user
12556 */
12557
12558 // gpu temp sanity check
12559
12560 if ((gpu_temp_abort != 0) && (gpu_temp_retain != 0))
12561 {
12562 if (gpu_temp_abort < gpu_temp_retain)
12563 {
12564 log_error ("ERROR: invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain.");
12565
12566 return (-1);
12567 }
12568 }
12569
12570 data.gpu_temp_disable = gpu_temp_disable;
12571 data.gpu_temp_abort = gpu_temp_abort;
12572 data.gpu_temp_retain = gpu_temp_retain;
12573
12574 if (data.quiet == 0)
12575 {
12576 log_info ("Hashes: %u hashes; %u unique digests, %u unique salts", hashes_cnt_orig, digests_cnt, salts_cnt);
12577
12578 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);
12579
12580 if (attack_mode == ATTACK_MODE_STRAIGHT)
12581 {
12582 log_info ("Rules: %u", gpu_rules_cnt);
12583 }
12584
12585 if (opti_type)
12586 {
12587 log_info ("Applicable Optimizers:");
12588
12589 for (uint i = 0; i < 32; i++)
12590 {
12591 const uint opti_bit = 1 << i;
12592
12593 if (opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit));
12594 }
12595 }
12596
12597 /**
12598 * Watchdog and Temperature balance
12599 */
12600
12601 if (gpu_temp_abort == 0)
12602 {
12603 log_info ("Watchdog: Temperature abort trigger disabled");
12604 }
12605 else
12606 {
12607 log_info ("Watchdog: Temperature abort trigger set to %uc", gpu_temp_abort);
12608 }
12609
12610 if (gpu_temp_retain == 0)
12611 {
12612 log_info ("Watchdog: Temperature retain trigger disabled");
12613 }
12614 else
12615 {
12616 log_info ("Watchdog: Temperature retain trigger set to %uc", gpu_temp_retain);
12617 }
12618 }
12619
12620 /**
12621 * devices init
12622 */
12623
12624 int *temp_retain_fanspeed_value = (int *) mycalloc (devices_cnt, sizeof (int));
12625
12626 ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (devices_cnt, sizeof (ADLOD6MemClockState));
12627
12628 int *od_power_control_status = (int *) mycalloc (devices_cnt, sizeof (int));
12629
12630 hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (devices_cnt, sizeof (hc_device_param_t));
12631
12632 data.devices_param = devices_param;
12633
12634 for (uint device_id = 0; device_id < devices_cnt; device_id++)
12635 {
12636 hc_device_param_t *device_param = &data.devices_param[device_id];
12637
12638 cl_device_id device = devices[device_id];
12639
12640 device_param->device = device;
12641
12642 cl_uint max_compute_units = 0;
12643
12644 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
12645
12646 device_param->gpu_processors = max_compute_units;
12647
12648 cl_ulong max_mem_alloc_size = 0;
12649
12650 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL);
12651
12652 device_param->gpu_maxmem_alloc = max_mem_alloc_size;
12653
12654 char tmp[INFOSZ], t1[64];
12655
12656 memset (tmp, 0, sizeof (tmp));
12657
12658 hc_clGetDeviceInfo (device, CL_DEVICE_NAME, sizeof (tmp), &tmp, NULL);
12659
12660 device_param->device_name = mystrdup (tmp);
12661
12662 memset (tmp, 0, sizeof (tmp));
12663
12664 hc_clGetDeviceInfo (device, CL_DEVICE_VERSION, sizeof (tmp), &tmp, NULL);
12665
12666 memset (t1, 0, sizeof (t1));
12667
12668 sscanf (tmp, "%*16s %*16s %*16s (%[^)]16s)", t1);
12669
12670 device_param->device_version = mystrdup (t1);
12671
12672 memset (tmp, 0, sizeof (tmp));
12673
12674 hc_clGetDeviceInfo (device, CL_DRIVER_VERSION, sizeof (tmp), &tmp, NULL);
12675
12676 device_param->driver_version = mystrdup (tmp);
12677
12678 if (vendor_id == VENDOR_ID_AMD)
12679 {
12680 cl_uint gpu_processor_cores = 0;
12681
12682 #define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043
12683
12684 hc_clGetDeviceInfo (device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (gpu_processor_cores), &gpu_processor_cores, NULL);
12685
12686 device_param->gpu_processor_cores = gpu_processor_cores;
12687 }
12688
12689 if (vendor_id == VENDOR_ID_NV)
12690 {
12691 cl_uint kernel_exec_timeout = 0;
12692
12693 #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
12694
12695 hc_clGetDeviceInfo (device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL);
12696
12697 device_param->kernel_exec_timeout = kernel_exec_timeout;
12698
12699 cl_uint gpu_processor_cores = 0;
12700
12701 #define CL_DEVICE_WARP_SIZE_NV 0x4003
12702
12703 hc_clGetDeviceInfo (device, CL_DEVICE_WARP_SIZE_NV, sizeof (gpu_processor_cores), &gpu_processor_cores, NULL);
12704
12705 device_param->gpu_processor_cores = gpu_processor_cores;
12706
12707 cl_uint sm_minor = 0;
12708 cl_uint sm_major = 0;
12709
12710 #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
12711 #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
12712
12713 hc_clGetDeviceInfo (device, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof (sm_minor), &sm_minor, NULL);
12714 hc_clGetDeviceInfo (device, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof (sm_major), &sm_major, NULL);
12715
12716 device_param->sm_minor = sm_minor;
12717 device_param->sm_major = sm_major;
12718 }
12719
12720 /**
12721 * common driver check
12722 */
12723
12724 if (vendor_id == VENDOR_ID_NV)
12725 {
12726 if (device_param->kernel_exec_timeout != 0)
12727 {
12728 if (data.quiet == 0) log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1);
12729 if (data.quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch");
12730 }
12731 }
12732
12733 if (vendor_id == VENDOR_ID_AMD)
12734 {
12735 int catalyst_check = (force == 1) ? 0 : 1;
12736
12737 int catalyst_warn = 0;
12738
12739 int catalyst_broken = 0;
12740
12741 if (catalyst_check == 1)
12742 {
12743 catalyst_warn = 1;
12744
12745 // v14.9 and higher
12746 if ((atoi (device_param->device_version) >= 1573)
12747 && (atoi (device_param->driver_version) >= 1573))
12748 {
12749 catalyst_warn = 0;
12750 }
12751
12752 catalyst_check = 0;
12753 }
12754
12755 if (catalyst_broken == 1)
12756 {
12757 log_error ("");
12758 log_error ("ATTENTION! The installed GPU driver in your system is known to be broken!");
12759 log_error ("It will pass over cracked hashes and does not report them as cracked");
12760 log_error ("You are STRONGLY encouraged not to use it");
12761 log_error ("You can use --force to override this but do not post error reports if you do so");
12762
12763 return (-1);
12764 }
12765
12766 if (catalyst_warn == 1)
12767 {
12768 log_error ("");
12769 log_error ("ATTENTION! Unsupported or incorrect installed GPU driver detected!");
12770 log_error ("You are STRONGLY encouraged to use the official supported GPU driver for good reasons");
12771 log_error ("See oclHashcat's homepage for official supported GPU drivers");
12772 #ifdef _WIN
12773 log_error ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
12774 #endif
12775 log_error ("You can use --force to override this but do not post error reports if you do so");
12776
12777 return (-1);
12778 }
12779 }
12780 }
12781
12782 /*
12783 * Temporary fix:
12784 * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
12785 * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
12786 * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem)
12787 * Driver / ADL bug?
12788 */
12789
12790 if (vendor_id == VENDOR_ID_AMD)
12791 {
12792 if (powertune_enable == 1)
12793 {
12794 hc_thread_mutex_lock (mux_adl);
12795
12796 for (uint i = 0; i < devices_cnt; i++)
12797 {
12798 if (data.hm_device[i].od_version == 6)
12799 {
12800 // set powertune value only
12801
12802 int powertune_supported = 0;
12803
12804 int ADL_rc = 0;
12805
12806 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK)
12807 {
12808 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
12809
12810 return (-1);
12811 }
12812
12813 if (powertune_supported != 0)
12814 {
12815 // powertune set
12816 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
12817
12818 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune)) != ADL_OK)
12819 {
12820 log_error ("ERROR: Failed to get current ADL PowerControl settings");
12821
12822 return (-1);
12823 }
12824
12825 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, powertune.iMaxValue)) != ADL_OK)
12826 {
12827 log_error ("ERROR: Failed to set new ADL PowerControl values");
12828
12829 return (-1);
12830 }
12831 }
12832 }
12833 }
12834
12835 hc_thread_mutex_unlock (mux_adl);
12836 }
12837 }
12838
12839 uint gpu_blocks_all = 0;
12840
12841 for (uint device_id = 0; device_id < devices_cnt; device_id++)
12842 {
12843 /**
12844 * host buffer
12845 */
12846
12847 hc_device_param_t *device_param = &data.devices_param[device_id];
12848
12849 /**
12850 * device properties
12851 */
12852
12853 char *device_name = device_param->device_name;
12854 char *device_version = device_param->device_version;
12855 char *driver_version = device_param->driver_version;
12856
12857 uint gpu_processors = device_param->gpu_processors;
12858
12859 uint gpu_processor_cores = device_param->gpu_processor_cores;
12860
12861 /**
12862 * create context for each device
12863 */
12864
12865 device_param->context = hc_clCreateContext (NULL, 1, &device_param->device, NULL, NULL);
12866
12867 /**
12868 * create command-queue
12869 */
12870
12871 // not support with NV
12872 // device_param->command_queue = hc_clCreateCommandQueueWithProperties (device_param->context, device_param->device, NULL);
12873
12874 device_param->command_queue = hc_clCreateCommandQueue (device_param->context, device_param->device, 0);
12875
12876 /**
12877 * create input buffers on device
12878 */
12879
12880 uint gpu_threads = GPU_THREADS;
12881
12882 // bcrypt
12883 if (hash_mode == 3200) gpu_threads = 8;
12884 if (hash_mode == 9000) gpu_threads = 8;
12885
12886 uint gpu_power = gpu_processors * gpu_threads * gpu_accel;
12887 uint gpu_blocks = gpu_power;
12888
12889 device_param->gpu_threads = gpu_threads;
12890 device_param->gpu_power_user = gpu_power;
12891 device_param->gpu_blocks_user = gpu_blocks;
12892
12893 gpu_blocks_all += gpu_blocks;
12894
12895 uint size_pws = gpu_power * sizeof (pw_t);
12896
12897 uint size_tmps = 4;
12898
12899 switch (hash_mode)
12900 {
12901 case 400: size_tmps = gpu_blocks * sizeof (phpass_tmp_t); break;
12902 case 500: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
12903 case 501: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
12904 case 1600: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
12905 case 1800: size_tmps = gpu_blocks * sizeof (sha512crypt_tmp_t); break;
12906 case 2100: size_tmps = gpu_blocks * sizeof (dcc2_tmp_t); break;
12907 case 2500: size_tmps = gpu_blocks * sizeof (wpa_tmp_t); break;
12908 case 3200: size_tmps = gpu_blocks * sizeof (bcrypt_tmp_t); break;
12909 case 5200: size_tmps = gpu_blocks * sizeof (pwsafe3_tmp_t); break;
12910 case 5800: size_tmps = gpu_blocks * sizeof (androidpin_tmp_t); break;
12911 case 6211:
12912 case 6212:
12913 case 6213: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
12914 case 6221:
12915 case 6222:
12916 case 6223: size_tmps = gpu_blocks * sizeof (tc64_tmp_t); break;
12917 case 6231:
12918 case 6232:
12919 case 6233: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
12920 case 6241:
12921 case 6242:
12922 case 6243: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
12923 case 6300: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
12924 case 6400: size_tmps = gpu_blocks * sizeof (sha256aix_tmp_t); break;
12925 case 6500: size_tmps = gpu_blocks * sizeof (sha512aix_tmp_t); break;
12926 case 6600: size_tmps = gpu_blocks * sizeof (agilekey_tmp_t); break;
12927 case 6700: size_tmps = gpu_blocks * sizeof (sha1aix_tmp_t); break;
12928 case 6800: size_tmps = gpu_blocks * sizeof (lastpass_tmp_t); break;
12929 case 7100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
12930 case 7200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
12931 case 7400: size_tmps = gpu_blocks * sizeof (sha256crypt_tmp_t); break;
12932 case 7900: size_tmps = gpu_blocks * sizeof (drupal7_tmp_t); break;
12933 case 8200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
12934 case 8800: size_tmps = gpu_blocks * sizeof (androidfde_tmp_t); break;
12935 case 8900: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
12936 case 9000: size_tmps = gpu_blocks * sizeof (pwsafe2_tmp_t); break;
12937 case 9100: size_tmps = gpu_blocks * sizeof (lotus8_tmp_t); break;
12938 case 9200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
12939 case 9300: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
12940 case 9400: size_tmps = gpu_blocks * sizeof (office2007_tmp_t); break;
12941 case 9500: size_tmps = gpu_blocks * sizeof (office2010_tmp_t); break;
12942 case 9600: size_tmps = gpu_blocks * sizeof (office2013_tmp_t); break;
12943 case 10000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
12944 case 10200: size_tmps = gpu_blocks * sizeof (cram_md5_t); break;
12945 case 10300: size_tmps = gpu_blocks * sizeof (saph_sha1_tmp_t); break;
12946 case 10500: size_tmps = gpu_blocks * sizeof (pdf14_tmp_t); break;
12947 case 10700: size_tmps = gpu_blocks * sizeof (pdf17l8_tmp_t); break;
12948 case 10900: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
12949 case 11300: size_tmps = gpu_blocks * sizeof (bitcoin_wallet_tmp_t); break;
12950 case 11600: size_tmps = gpu_blocks * sizeof (seven_zip_tmp_t); break;
12951 case 11900: size_tmps = gpu_blocks * sizeof (pbkdf2_md5_tmp_t); break;
12952 case 12000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha1_tmp_t); break;
12953 case 12100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
12954 case 12200: size_tmps = gpu_blocks * sizeof (ecryptfs_tmp_t); break;
12955 case 12300: size_tmps = gpu_blocks * sizeof (oraclet_tmp_t); break;
12956 case 12400: size_tmps = gpu_blocks * sizeof (bsdicrypt_tmp_t); break;
12957 case 12500: size_tmps = gpu_blocks * sizeof (rar3_tmp_t); break;
12958 case 12700: size_tmps = gpu_blocks * sizeof (mywallet_tmp_t); break;
12959 case 12800: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
12960 };
12961
12962 uint size_hooks = 4;
12963
12964 if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23))
12965 {
12966 // insert correct hook size
12967 }
12968
12969 // we can optimize some stuff here...
12970
12971 device_param->size_pws = size_pws;
12972 device_param->size_tmps = size_tmps;
12973 device_param->size_hooks = size_hooks;
12974
12975 uint size_root_css = SP_PW_MAX * sizeof (cs_t);
12976 uint size_markov_css = SP_PW_MAX * CHARSIZ * sizeof (cs_t);
12977
12978 device_param->size_root_css = size_root_css;
12979 device_param->size_markov_css = size_markov_css;
12980
12981 uint size_results = GPU_THREADS * sizeof (uint);
12982
12983 device_param->size_results = size_results;
12984
12985 uint size_rules = gpu_rules_cnt * sizeof (gpu_rule_t);
12986 uint size_rules_c = GPU_RULES * sizeof (gpu_rule_t);
12987 uint size_plains = digests_cnt * sizeof (plain_t);
12988 uint size_salts = salts_cnt * sizeof (salt_t);
12989 uint size_esalts = salts_cnt * esalt_size;
12990
12991 device_param->size_plains = size_plains;
12992 device_param->size_digests = size_digests;
12993 device_param->size_shown = size_shown;
12994 device_param->size_salts = size_salts;
12995
12996 uint size_combs = GPU_COMBS * sizeof (comb_t);
12997 uint size_bfs = GPU_BFS * sizeof (bf_t);
12998 uint size_tm = 32 * sizeof (bs_word_t);
12999
13000 uint64_t size_scryptV = 1;
13001
13002 if ((hash_mode == 8900) || (hash_mode == 9300))
13003 {
13004 uint tmto_start = 0;
13005 uint tmto_stop = 10;
13006
13007 if (scrypt_tmto)
13008 {
13009 tmto_start = scrypt_tmto;
13010 }
13011 else
13012 {
13013 // in case the user did not specify the tmto manually
13014 // use some values known to run best (tested on 290x for AMD and 980ti for NV)
13015 // but set the lower end only in case the user has a gpu with too less memory
13016
13017 if (hash_mode == 8900)
13018 {
13019 if (vendor_id == VENDOR_ID_AMD)
13020 {
13021 tmto_start = 1;
13022 }
13023 else if (vendor_id == VENDOR_ID_NV)
13024 {
13025 tmto_start = 3;
13026 }
13027 }
13028 else if (hash_mode == 9300)
13029 {
13030 if (vendor_id == VENDOR_ID_AMD)
13031 {
13032 tmto_start = 3;
13033 }
13034 else if (vendor_id == VENDOR_ID_NV)
13035 {
13036 tmto_start = 5;
13037 }
13038 }
13039 }
13040
13041 if (quiet == 0) log_info ("");
13042
13043 uint shader_per_mp = 1;
13044
13045 if (vendor_id == VENDOR_ID_AMD)
13046 {
13047 shader_per_mp = 8;
13048 }
13049
13050 if (vendor_id == VENDOR_ID_NV)
13051 {
13052 shader_per_mp = 32;
13053 }
13054
13055 for (uint tmto = tmto_start; tmto < tmto_stop; tmto++)
13056 {
13057 // TODO: in theory the following calculation needs to be done per salt, not global
13058 // we assume all hashes have the same scrypt settings
13059
13060 size_scryptV = (128 * data.salts_buf[0].scrypt_r) * data.salts_buf[0].scrypt_N;
13061
13062 size_scryptV /= 1 << tmto;
13063
13064 size_scryptV *= gpu_processors * gpu_processor_cores * shader_per_mp;
13065
13066 if (size_scryptV > device_param->gpu_maxmem_alloc)
13067 {
13068 if (quiet == 0) log_info ("WARNING: not enough GPU memory allocatable to use --scrypt-tmto %d, increasing...", tmto);
13069
13070 continue;
13071 }
13072
13073 for (uint salts_pos = 0; salts_pos < data.salts_cnt; salts_pos++)
13074 {
13075 data.salts_buf[salts_pos].scrypt_tmto = tmto;
13076 data.salts_buf[salts_pos].scrypt_phy = gpu_processors * gpu_processor_cores * shader_per_mp;
13077 }
13078
13079 break;
13080 }
13081
13082 if (data.salts_buf[0].scrypt_phy == 0)
13083 {
13084 log_error ("ERROR: can't allocate enough GPU memory");
13085
13086 return -1;
13087 }
13088
13089 if (quiet == 0) log_info ("");
13090 if (quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u, mem: %u\n", data.salts_buf[0].scrypt_tmto, size_scryptV);
13091 }
13092
13093 /**
13094 * default building options
13095 */
13096
13097 char build_opts[1024];
13098
13099 // we don't have sm_* on AMD but it doesn't matter
13100
13101 sprintf (build_opts, "-I. -IOpenCL/ -DVENDOR_ID=%d -DCUDA_ARCH=%d", vendor_id, (device_param->sm_major * 100) + device_param->sm_minor);
13102
13103 /**
13104 * main kernel
13105 */
13106
13107 {
13108 /**
13109 * kernel source filename
13110 */
13111
13112 char source_file[256];
13113
13114 memset (source_file, 0, sizeof (source_file));
13115
13116 generate_source_kernel_filename (attack_exec, attack_kern, kern_type, install_dir, source_file);
13117
13118 struct stat sst;
13119
13120 if (stat (source_file, &sst) == -1)
13121 {
13122 log_error ("ERROR: %s: %s", source_file, strerror (errno));
13123
13124 return -1;
13125 }
13126
13127 /**
13128 * kernel cached filename
13129 */
13130
13131 char cached_file[256];
13132
13133 memset (cached_file, 0, sizeof (cached_file));
13134
13135 generate_cached_kernel_filename (attack_exec, attack_kern, kern_type, install_dir, device_name, device_version, driver_version, vendor_id, cached_file);
13136
13137 int cached = 1;
13138
13139 struct stat cst;
13140
13141 if (stat (cached_file, &cst) == -1)
13142 {
13143 cached = 0;
13144 }
13145
13146 /**
13147 * kernel compile or load
13148 */
13149
13150 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
13151
13152 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
13153
13154 if (force_jit_compilation == 0)
13155 {
13156 if (cached == 0)
13157 {
13158 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, cached_file);
13159
13160 load_kernel (source_file, 1, kernel_lengths, kernel_sources);
13161
13162 device_param->program = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
13163
13164 hc_clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
13165
13166 size_t binary_size;
13167
13168 clGetProgramInfo (device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
13169
13170 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
13171
13172 clGetProgramInfo (device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
13173
13174 writeProgramBin (cached_file, binary, binary_size);
13175
13176 local_free (binary);
13177 }
13178 else
13179 {
13180 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size);
13181
13182 load_kernel (cached_file, 1, kernel_lengths, kernel_sources);
13183
13184 device_param->program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
13185
13186 hc_clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
13187 }
13188 }
13189 else
13190 {
13191 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, source_file, sst.st_size);
13192
13193 load_kernel (source_file, 1, kernel_lengths, kernel_sources);
13194
13195 device_param->program = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
13196
13197 if (force_jit_compilation == 1500)
13198 {
13199 sprintf (build_opts, "%s -DDESCRYPT_SALT=%d", build_opts, data.salts_buf[0].salt_buf[0]);
13200 }
13201 else if (force_jit_compilation == 8900)
13202 {
13203 sprintf (build_opts, "%s -DSCRYPT_N=%d -DSCRYPT_R=%d -DSCRYPT_P=%d -DSCRYPT_TMTO=%d", build_opts, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, 1 << data.salts_buf[0].scrypt_tmto);
13204 }
13205
13206 hc_clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
13207 }
13208
13209 local_free (kernel_lengths);
13210 local_free (kernel_sources[0]);
13211 local_free (kernel_sources);
13212
13213 // this is mostly for debug
13214
13215 size_t ret_val_size = 0;
13216
13217 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
13218
13219 if (ret_val_size > 2)
13220 {
13221 char *build_log = (char *) mymalloc (ret_val_size + 1);
13222
13223 memset (build_log, 0, ret_val_size + 1);
13224
13225 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
13226
13227 puts (build_log);
13228
13229 myfree (build_log);
13230 }
13231 }
13232
13233 /**
13234 * word generator kernel
13235 */
13236
13237 if (attack_mode != ATTACK_MODE_STRAIGHT)
13238 {
13239 /**
13240 * kernel mp source filename
13241 */
13242
13243 char source_file[256];
13244
13245 memset (source_file, 0, sizeof (source_file));
13246
13247 generate_source_kernel_mp_filename (opti_type, opts_type, install_dir, source_file);
13248
13249 struct stat sst;
13250
13251 if (stat (source_file, &sst) == -1)
13252 {
13253 log_error ("ERROR: %s: %s", source_file, strerror (errno));
13254
13255 return -1;
13256 }
13257
13258 /**
13259 * kernel mp cached filename
13260 */
13261
13262 char cached_file[256];
13263
13264 memset (cached_file, 0, sizeof (cached_file));
13265
13266 generate_cached_kernel_mp_filename (opti_type, opts_type, install_dir, device_name, device_version, driver_version, vendor_id, cached_file);
13267
13268 int cached = 1;
13269
13270 struct stat cst;
13271
13272 if (stat (cached_file, &cst) == -1)
13273 {
13274 cached = 0;
13275 }
13276
13277 /**
13278 * kernel compile or load
13279 */
13280
13281 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
13282
13283 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
13284
13285 if (cached == 0)
13286 {
13287 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, cached_file);
13288
13289 load_kernel (source_file, 1, kernel_lengths, kernel_sources);
13290
13291 device_param->program_mp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
13292
13293 hc_clBuildProgram (device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL);
13294
13295 size_t binary_size;
13296
13297 clGetProgramInfo (device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
13298
13299 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
13300
13301 clGetProgramInfo (device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
13302
13303 writeProgramBin (cached_file, binary, binary_size);
13304
13305 local_free (binary);
13306 }
13307 else
13308 {
13309 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size);
13310
13311 load_kernel (cached_file, 1, kernel_lengths, kernel_sources);
13312
13313 device_param->program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
13314
13315 hc_clBuildProgram (device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL);
13316 }
13317
13318 local_free (kernel_lengths);
13319 local_free (kernel_sources[0]);
13320 local_free (kernel_sources);
13321
13322 // this is mostly for debug
13323
13324 size_t ret_val_size = 0;
13325
13326 clGetProgramBuildInfo (device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
13327
13328 if (ret_val_size > 2)
13329 {
13330 char *build_log = (char *) mymalloc (ret_val_size + 1);
13331
13332 memset (build_log, 0, ret_val_size + 1);
13333
13334 clGetProgramBuildInfo (device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
13335
13336 puts (build_log);
13337
13338 myfree (build_log);
13339 }
13340 }
13341
13342 /**
13343 * amplifier kernel
13344 */
13345
13346 if (attack_exec == ATTACK_EXEC_ON_GPU)
13347 {
13348
13349 }
13350 else
13351 {
13352 /**
13353 * kernel amp source filename
13354 */
13355
13356 char source_file[256];
13357
13358 memset (source_file, 0, sizeof (source_file));
13359
13360 generate_source_kernel_amp_filename (attack_kern, install_dir, source_file);
13361
13362 struct stat sst;
13363
13364 if (stat (source_file, &sst) == -1)
13365 {
13366 log_error ("ERROR: %s: %s", source_file, strerror (errno));
13367
13368 return -1;
13369 }
13370
13371 /**
13372 * kernel amp cached filename
13373 */
13374
13375 char cached_file[256];
13376
13377 memset (cached_file, 0, sizeof (cached_file));
13378
13379 generate_cached_kernel_amp_filename (attack_kern, install_dir, device_name, device_version, driver_version, vendor_id, cached_file);
13380
13381 int cached = 1;
13382
13383 struct stat cst;
13384
13385 if (stat (cached_file, &cst) == -1)
13386 {
13387 cached = 0;
13388 }
13389
13390 /**
13391 * kernel compile or load
13392 */
13393
13394 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
13395
13396 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
13397
13398 if (cached == 0)
13399 {
13400 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, cached_file);
13401
13402 load_kernel (source_file, 1, kernel_lengths, kernel_sources);
13403
13404 device_param->program_amp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
13405
13406 hc_clBuildProgram (device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL);
13407
13408 size_t binary_size;
13409
13410 clGetProgramInfo (device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
13411
13412 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
13413
13414 clGetProgramInfo (device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
13415
13416 writeProgramBin (cached_file, binary, binary_size);
13417
13418 local_free (binary);
13419 }
13420 else
13421 {
13422 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size);
13423
13424 load_kernel (cached_file, 1, kernel_lengths, kernel_sources);
13425
13426 device_param->program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
13427
13428 hc_clBuildProgram (device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL);
13429 }
13430
13431 local_free (kernel_lengths);
13432 local_free (kernel_sources[0]);
13433 local_free (kernel_sources);
13434
13435 // this is mostly for debug
13436
13437 size_t ret_val_size = 0;
13438
13439 clGetProgramBuildInfo (device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
13440
13441 if (ret_val_size > 2)
13442 {
13443 char *build_log = (char *) mymalloc (ret_val_size + 1);
13444
13445 memset (build_log, 0, ret_val_size + 1);
13446
13447 clGetProgramBuildInfo (device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
13448
13449 puts (build_log);
13450
13451 myfree (build_log);
13452 }
13453 }
13454
13455 /**
13456 * global buffers
13457 */
13458
13459 device_param->d_pws_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
13460 device_param->d_pws_amp_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
13461 device_param->d_tmps = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL);
13462 device_param->d_hooks = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL);
13463 device_param->d_bitmap_s1_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13464 device_param->d_bitmap_s1_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13465 device_param->d_bitmap_s1_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13466 device_param->d_bitmap_s1_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13467 device_param->d_bitmap_s2_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13468 device_param->d_bitmap_s2_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13469 device_param->d_bitmap_s2_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13470 device_param->d_bitmap_s2_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13471 device_param->d_plain_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_plains, NULL);
13472 device_param->d_digests_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_digests, NULL);
13473 device_param->d_digests_shown = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_shown, NULL);
13474 device_param->d_salt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_salts, NULL);
13475 device_param->d_result = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_results, NULL);
13476 device_param->d_scryptV_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_scryptV, NULL);
13477
13478 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_size, bitmap_s1_a, 0, NULL, NULL);
13479 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_size, bitmap_s1_b, 0, NULL, NULL);
13480 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_size, bitmap_s1_c, 0, NULL, NULL);
13481 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_size, bitmap_s1_d, 0, NULL, NULL);
13482 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_size, bitmap_s2_a, 0, NULL, NULL);
13483 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_size, bitmap_s2_b, 0, NULL, NULL);
13484 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_size, bitmap_s2_c, 0, NULL, NULL);
13485 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_size, bitmap_s2_d, 0, NULL, NULL);
13486 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, data.digests_buf, 0, NULL, NULL);
13487 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, data.digests_shown, 0, NULL, NULL);
13488 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, data.salts_buf, 0, NULL, NULL);
13489
13490 run_kernel_bzero (device_param, device_param->d_pws_buf, size_pws);
13491 run_kernel_bzero (device_param, device_param->d_pws_amp_buf, size_pws);
13492 run_kernel_bzero (device_param, device_param->d_tmps, size_tmps);
13493 run_kernel_bzero (device_param, device_param->d_hooks, size_hooks);
13494 run_kernel_bzero (device_param, device_param->d_plain_bufs, size_plains);
13495 run_kernel_bzero (device_param, device_param->d_result, size_results);
13496
13497 /**
13498 * special buffers
13499 */
13500
13501 if (attack_kern == ATTACK_KERN_STRAIGHT)
13502 {
13503 device_param->d_rules = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules, NULL);
13504 device_param->d_rules_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL);
13505
13506 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, gpu_rules_buf, 0, NULL, NULL);
13507
13508 run_kernel_bzero (device_param, device_param->d_rules_c, size_rules_c);
13509 }
13510 else if (attack_kern == ATTACK_KERN_COMBI)
13511 {
13512 device_param->d_combs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
13513 device_param->d_combs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
13514 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
13515 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
13516
13517 run_kernel_bzero (device_param, device_param->d_combs, size_combs);
13518 run_kernel_bzero (device_param, device_param->d_combs_c, size_combs);
13519 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
13520 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
13521 }
13522 else if (attack_kern == ATTACK_KERN_BF)
13523 {
13524 device_param->d_bfs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
13525 device_param->d_bfs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
13526 device_param->d_tm_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_tm, NULL);
13527 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
13528 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
13529
13530 run_kernel_bzero (device_param, device_param->d_bfs, size_bfs);
13531 run_kernel_bzero (device_param, device_param->d_bfs_c, size_bfs);
13532 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
13533 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
13534 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
13535 }
13536
13537 if (size_esalts)
13538 {
13539 device_param->d_esalt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL);
13540
13541 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, data.esalts_buf, 0, NULL, NULL);
13542 }
13543
13544 /**
13545 * main host data
13546 */
13547
13548 uint *result = (uint *) mymalloc (size_results);
13549
13550 memset (result, 0, size_results);
13551
13552 device_param->result = result;
13553
13554 pw_t *pws_buf = (pw_t *) mymalloc (size_pws);
13555
13556 memset (pws_buf, 0, size_pws);
13557
13558 device_param->pws_buf = pws_buf;
13559
13560 pw_cache_t *pw_caches = (pw_cache_t *) mycalloc (64, sizeof (pw_cache_t));
13561
13562 for (int i = 0; i < 64; i++)
13563 {
13564 pw_caches[i].pw_buf.pw_len = i;
13565 pw_caches[i].cnt = 0;
13566 }
13567
13568 device_param->pw_caches = pw_caches;
13569
13570 comb_t *combs_buf = (comb_t *) mycalloc (GPU_COMBS, sizeof (comb_t));
13571
13572 device_param->combs_buf = combs_buf;
13573
13574 void *hooks_buf = mymalloc (size_hooks);
13575
13576 device_param->hooks_buf = hooks_buf;
13577
13578 device_param->pw_transpose = pw_transpose_to_hi1;
13579 device_param->pw_add = pw_add_to_hc1;
13580
13581 /**
13582 * kernel args
13583 */
13584
13585 device_param->kernel_params_buf32[21] = bitmap_mask;
13586 device_param->kernel_params_buf32[22] = bitmap_shift1;
13587 device_param->kernel_params_buf32[23] = bitmap_shift2;
13588 device_param->kernel_params_buf32[24] = 0; // salt_pos
13589 device_param->kernel_params_buf32[25] = 0; // loop_pos
13590 device_param->kernel_params_buf32[26] = 0; // loop_cnt
13591 device_param->kernel_params_buf32[27] = 0; // gpu_rules_cnt
13592 device_param->kernel_params_buf32[28] = 0; // digests_cnt
13593 device_param->kernel_params_buf32[29] = 0; // digests_offset
13594 device_param->kernel_params_buf32[30] = 0; // combs_mode
13595 device_param->kernel_params_buf32[31] = 0; // gid_max
13596
13597 device_param->kernel_params[ 0] = (attack_exec == ATTACK_EXEC_ON_GPU)
13598 ? &device_param->d_pws_buf
13599 : &device_param->d_pws_amp_buf;
13600 device_param->kernel_params[ 1] = &device_param->d_rules_c;
13601 device_param->kernel_params[ 2] = &device_param->d_combs_c;
13602 device_param->kernel_params[ 3] = &device_param->d_bfs_c;
13603 device_param->kernel_params[ 4] = &device_param->d_tmps;
13604 device_param->kernel_params[ 5] = &device_param->d_hooks;
13605 device_param->kernel_params[ 6] = &device_param->d_bitmap_s1_a;
13606 device_param->kernel_params[ 7] = &device_param->d_bitmap_s1_b;
13607 device_param->kernel_params[ 8] = &device_param->d_bitmap_s1_c;
13608 device_param->kernel_params[ 9] = &device_param->d_bitmap_s1_d;
13609 device_param->kernel_params[10] = &device_param->d_bitmap_s2_a;
13610 device_param->kernel_params[11] = &device_param->d_bitmap_s2_b;
13611 device_param->kernel_params[12] = &device_param->d_bitmap_s2_c;
13612 device_param->kernel_params[13] = &device_param->d_bitmap_s2_d;
13613 device_param->kernel_params[14] = &device_param->d_plain_bufs;
13614 device_param->kernel_params[15] = &device_param->d_digests_buf;
13615 device_param->kernel_params[16] = &device_param->d_digests_shown;
13616 device_param->kernel_params[17] = &device_param->d_salt_bufs;
13617 device_param->kernel_params[18] = &device_param->d_esalt_bufs;
13618 device_param->kernel_params[19] = &device_param->d_result;
13619 device_param->kernel_params[20] = &device_param->d_scryptV_buf;
13620 device_param->kernel_params[21] = &device_param->kernel_params_buf32[21];
13621 device_param->kernel_params[22] = &device_param->kernel_params_buf32[22];
13622 device_param->kernel_params[23] = &device_param->kernel_params_buf32[23];
13623 device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
13624 device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
13625 device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
13626 device_param->kernel_params[27] = &device_param->kernel_params_buf32[27];
13627 device_param->kernel_params[28] = &device_param->kernel_params_buf32[28];
13628 device_param->kernel_params[29] = &device_param->kernel_params_buf32[29];
13629 device_param->kernel_params[30] = &device_param->kernel_params_buf32[30];
13630 device_param->kernel_params[31] = &device_param->kernel_params_buf32[31];
13631
13632 device_param->kernel_params_mp_buf64[3] = 0;
13633 device_param->kernel_params_mp_buf32[4] = 0;
13634 device_param->kernel_params_mp_buf32[5] = 0;
13635 device_param->kernel_params_mp_buf32[6] = 0;
13636 device_param->kernel_params_mp_buf32[7] = 0;
13637 device_param->kernel_params_mp_buf32[8] = 0;
13638
13639 device_param->kernel_params_mp[0] = NULL;
13640 device_param->kernel_params_mp[1] = NULL;
13641 device_param->kernel_params_mp[2] = NULL;
13642 device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];
13643 device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4];
13644 device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5];
13645 device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6];
13646 device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7];
13647 device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf32[8];
13648
13649 device_param->kernel_params_mp_l_buf64[3] = 0;
13650 device_param->kernel_params_mp_l_buf32[4] = 0;
13651 device_param->kernel_params_mp_l_buf32[5] = 0;
13652 device_param->kernel_params_mp_l_buf32[6] = 0;
13653 device_param->kernel_params_mp_l_buf32[7] = 0;
13654 device_param->kernel_params_mp_l_buf32[8] = 0;
13655 device_param->kernel_params_mp_l_buf32[9] = 0;
13656
13657 device_param->kernel_params_mp_l[0] = NULL;
13658 device_param->kernel_params_mp_l[1] = NULL;
13659 device_param->kernel_params_mp_l[2] = NULL;
13660 device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3];
13661 device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4];
13662 device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5];
13663 device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6];
13664 device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7];
13665 device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8];
13666 device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf32[9];
13667
13668 device_param->kernel_params_mp_r_buf64[3] = 0;
13669 device_param->kernel_params_mp_r_buf32[4] = 0;
13670 device_param->kernel_params_mp_r_buf32[5] = 0;
13671 device_param->kernel_params_mp_r_buf32[6] = 0;
13672 device_param->kernel_params_mp_r_buf32[7] = 0;
13673 device_param->kernel_params_mp_r_buf32[8] = 0;
13674
13675 device_param->kernel_params_mp_r[0] = NULL;
13676 device_param->kernel_params_mp_r[1] = NULL;
13677 device_param->kernel_params_mp_r[2] = NULL;
13678 device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3];
13679 device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4];
13680 device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5];
13681 device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6];
13682 device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7];
13683 device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf32[8];
13684
13685 device_param->kernel_params_amp_buf32[5] = 0; // combs_mode
13686 device_param->kernel_params_amp_buf32[6] = 0; // gid_max
13687
13688 device_param->kernel_params_amp[0] = &device_param->d_pws_buf;
13689 device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf;
13690 device_param->kernel_params_amp[2] = &device_param->d_rules_c;
13691 device_param->kernel_params_amp[3] = &device_param->d_combs_c;
13692 device_param->kernel_params_amp[4] = &device_param->d_bfs_c;
13693 device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5];
13694 device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf32[6];
13695
13696 device_param->kernel_params_tb[0] = &device_param->d_pws_buf;
13697
13698 device_param->kernel_params_tm[0] = &device_param->d_bfs_c;
13699 device_param->kernel_params_tm[1] = &device_param->d_tm_c;
13700
13701 /**
13702 * kernel name
13703 */
13704
13705 char kernel_name[64];
13706
13707 memset (kernel_name, 0, sizeof (kernel_name));
13708
13709 if (attack_exec == ATTACK_EXEC_ON_GPU)
13710 {
13711 if (opti_type & OPTI_TYPE_SINGLE_HASH)
13712 {
13713 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 4);
13714
13715 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
13716
13717 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 8);
13718
13719 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
13720
13721 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 16);
13722
13723 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
13724 }
13725 else
13726 {
13727 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 4);
13728
13729 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
13730
13731 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 8);
13732
13733 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
13734
13735 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 16);
13736
13737 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
13738 }
13739
13740 if (data.attack_mode == ATTACK_MODE_BF)
13741 {
13742 if (opts_type & OPTS_TYPE_PT_BITSLICE)
13743 {
13744 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tb", kern_type);
13745
13746 device_param->kernel_tb = hc_clCreateKernel (device_param->program, kernel_name);
13747
13748 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tm", kern_type);
13749
13750 device_param->kernel_tm = hc_clCreateKernel (device_param->program, kernel_name);
13751 }
13752 }
13753 }
13754 else
13755 {
13756 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_init", kern_type);
13757
13758 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
13759
13760 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_loop", kern_type);
13761
13762 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
13763
13764 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_comp", kern_type);
13765
13766 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
13767
13768 if (opts_type & OPTS_TYPE_HOOK12)
13769 {
13770 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook12", kern_type);
13771
13772 device_param->kernel12 = hc_clCreateKernel (device_param->program, kernel_name);
13773 }
13774
13775 if (opts_type & OPTS_TYPE_HOOK23)
13776 {
13777 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook23", kern_type);
13778
13779 device_param->kernel23 = hc_clCreateKernel (device_param->program, kernel_name);
13780 }
13781 }
13782
13783 for (uint i = 0; i <= 20; i++)
13784 {
13785 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]);
13786 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]);
13787 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]);
13788
13789 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]);
13790 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]);
13791 }
13792
13793 for (uint i = 21; i <= 31; i++)
13794 {
13795 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]);
13796 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]);
13797 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]);
13798
13799 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]);
13800 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]);
13801 }
13802
13803 if (attack_mode == ATTACK_MODE_BF)
13804 {
13805 device_param->kernel_mp_l = hc_clCreateKernel (device_param->program_mp, "l_markov");
13806 device_param->kernel_mp_r = hc_clCreateKernel (device_param->program_mp, "r_markov");
13807
13808 if (opts_type & OPTS_TYPE_PT_BITSLICE)
13809 {
13810 hc_clSetKernelArg (device_param->kernel_tb, 0, sizeof (cl_mem), device_param->kernel_params_tb[0]);
13811
13812 hc_clSetKernelArg (device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]);
13813 hc_clSetKernelArg (device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]);
13814 }
13815 }
13816 else if (attack_mode == ATTACK_MODE_HYBRID1)
13817 {
13818 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
13819 }
13820 else if (attack_mode == ATTACK_MODE_HYBRID2)
13821 {
13822 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
13823 }
13824
13825 if (attack_exec == ATTACK_EXEC_ON_GPU)
13826 {
13827 // nothing to do
13828 }
13829 else
13830 {
13831 device_param->kernel_amp = hc_clCreateKernel (device_param->program_amp, "amp");
13832 }
13833
13834 if (attack_exec == ATTACK_EXEC_ON_GPU)
13835 {
13836 // nothing to do
13837 }
13838 else
13839 {
13840 for (uint i = 0; i < 5; i++)
13841 {
13842 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]);
13843 }
13844
13845 for (uint i = 5; i < 7; i++)
13846 {
13847 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]);
13848 }
13849 }
13850
13851 /**
13852 * Store initial fanspeed if gpu_temp_retain is enabled
13853 */
13854
13855 int gpu_temp_retain_set = 0;
13856
13857 if (gpu_temp_disable == 0)
13858 {
13859 if (gpu_temp_retain != 0) // VENDOR_ID_AMD implied
13860 {
13861 hc_thread_mutex_lock (mux_adl);
13862
13863 if (data.hm_device[device_id].fan_supported == 1)
13864 {
13865 if (gpu_temp_retain_chgd == 0)
13866 {
13867 uint cur_temp = 0;
13868 uint default_temp = 0;
13869
13870 int ADL_rc = hc_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, (int *) &cur_temp, (int *) &default_temp);
13871
13872 if (ADL_rc == ADL_OK)
13873 {
13874 #define GPU_TEMP_RETAIN_ABORT_DIFF 15
13875
13876 const uint gpu_temp_retain_target = default_temp - GPU_TEMP_RETAIN_ABORT_DIFF;
13877
13878 // special case with multi gpu setups: always use minimum retain
13879
13880 if (gpu_temp_retain_set == 0)
13881 {
13882 gpu_temp_retain = gpu_temp_retain_target;
13883 gpu_temp_retain_set = 1;
13884 }
13885 else
13886 {
13887 gpu_temp_retain = MIN (gpu_temp_retain, gpu_temp_retain_target);
13888 }
13889
13890 if (gpu_temp_abort_chgd == 0) gpu_temp_abort = gpu_temp_retain + GPU_TEMP_RETAIN_ABORT_DIFF;
13891 }
13892 }
13893
13894 const int fan_speed = hm_get_fanspeed_with_device_id (device_id);
13895
13896 temp_retain_fanspeed_value[device_id] = fan_speed;
13897
13898 if (fan_speed == -1)
13899 {
13900 log_info ("WARNING: Failed to get current fan speed settings for gpu number: %i:", device_id + 1);
13901
13902 temp_retain_fanspeed_value[device_id] = 0;
13903 }
13904 }
13905
13906 hc_thread_mutex_unlock (mux_adl);
13907 }
13908 }
13909
13910 /**
13911 * Store original powercontrol/clocks settings, set overdrive 6 performance tuning settings
13912 */
13913
13914 if (powertune_enable == 1) // VENDOR_ID_AMD implied
13915 {
13916 hc_thread_mutex_lock (mux_adl);
13917
13918 if (data.hm_device[device_id].od_version == 6)
13919 {
13920 int ADL_rc;
13921
13922 // check powertune capabilities first, if not available then skip device
13923
13924 int powertune_supported = 0;
13925
13926 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &powertune_supported)) != ADL_OK)
13927 {
13928 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
13929
13930 return (-1);
13931 }
13932
13933 if (powertune_supported != 0)
13934 {
13935 // powercontrol settings
13936
13937 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
13938
13939 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &powertune)) == ADL_OK)
13940 {
13941 ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &od_power_control_status[device_id]);
13942 }
13943
13944 if (ADL_rc != ADL_OK)
13945 {
13946 log_error ("ERROR: Failed to get current ADL PowerControl settings");
13947
13948 return (-1);
13949 }
13950
13951 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, powertune.iMaxValue)) != ADL_OK)
13952 {
13953 log_error ("ERROR: Failed to set new ADL PowerControl values");
13954
13955 return (-1);
13956 }
13957
13958 // clocks
13959
13960 memset (&od_clock_mem_status[device_id], 0, sizeof (ADLOD6MemClockState));
13961
13962 od_clock_mem_status[device_id].state.iNumberOfPerformanceLevels = 2;
13963
13964 if ((ADL_rc = hc_ADL_Overdrive_StateInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &od_clock_mem_status[device_id])) != ADL_OK)
13965 {
13966 log_error ("ERROR: Failed to get ADL memory and engine clock frequency");
13967
13968 return (-1);
13969 }
13970
13971 // Query capabilities only to see if profiles were not "damaged", if so output a warning but do accept the users profile settings
13972
13973 ADLOD6Capabilities caps = {0, 0, 0, {0, 0, 0}, {0, 0, 0}, 0, 0};
13974
13975 if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &caps)) != ADL_OK)
13976 {
13977 log_error ("ERROR: Failed to get ADL device capabilities");
13978
13979 return (-1);
13980 }
13981
13982 int engine_clock_max = caps.sEngineClockRange.iMax * 0.6666;
13983 int memory_clock_max = caps.sMemoryClockRange.iMax * 0.6250;
13984
13985 int warning_trigger_engine = (int) (0.25 * (float) engine_clock_max);
13986 int warning_trigger_memory = (int) (0.25 * (float) memory_clock_max);
13987
13988 int engine_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iEngineClock;
13989 int memory_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock;
13990
13991 // warning if profile has to low max values
13992
13993 if ((engine_clock_max - engine_clock_profile_max) > warning_trigger_engine)
13994 {
13995 log_info ("WARN: the custom profile seems to have too low maximum engine clock values. You therefore may not reach full performance");
13996 }
13997
13998 if ((memory_clock_max - memory_clock_profile_max) > warning_trigger_memory)
13999 {
14000 log_info ("WARN: the custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance");
14001 }
14002
14003 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
14004
14005 performance_state->iNumberOfPerformanceLevels = 2;
14006
14007 performance_state->aLevels[0].iEngineClock = engine_clock_profile_max;
14008 performance_state->aLevels[1].iEngineClock = engine_clock_profile_max;
14009 performance_state->aLevels[0].iMemoryClock = memory_clock_profile_max;
14010 performance_state->aLevels[1].iMemoryClock = memory_clock_profile_max;
14011
14012 if ((ADL_rc = hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
14013 {
14014 log_info ("ERROR: Failed to set ADL performance state");
14015
14016 return (-1);
14017 }
14018
14019 local_free (performance_state);
14020 }
14021 }
14022
14023 hc_thread_mutex_unlock (mux_adl);
14024 }
14025 }
14026
14027 data.gpu_blocks_all = gpu_blocks_all;
14028
14029 if (data.quiet == 0) log_info ("");
14030
14031 /**
14032 * Inform user which algorithm is checked and at which workload setting
14033 */
14034
14035 if (benchmark == 1)
14036 {
14037 quiet = 0;
14038
14039 data.quiet = quiet;
14040
14041 char *hash_type = strhashtype (data.hash_mode); // not a bug
14042
14043 log_info ("Hashtype: %s", hash_type);
14044 log_info ("Workload: %u loops, %u accel", gpu_loops, gpu_accel);
14045 log_info ("");
14046 }
14047
14048 /**
14049 * keep track of the progress
14050 */
14051
14052 data.words_progress_done = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
14053 data.words_progress_rejected = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
14054 data.words_progress_restored = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
14055
14056 /**
14057 * open filehandles
14058 */
14059
14060 #if _WIN
14061 if (_setmode (_fileno (stdin), _O_BINARY) == -1)
14062 {
14063 log_error ("ERROR: %s: %s", "stdin", strerror (errno));
14064
14065 return (-1);
14066 }
14067
14068 if (_setmode (_fileno (stdout), _O_BINARY) == -1)
14069 {
14070 log_error ("ERROR: %s: %s", "stdout", strerror (errno));
14071
14072 return (-1);
14073 }
14074
14075 if (_setmode (_fileno (stderr), _O_BINARY) == -1)
14076 {
14077 log_error ("ERROR: %s: %s", "stderr", strerror (errno));
14078
14079 return (-1);
14080 }
14081 #endif
14082
14083 /**
14084 * dictionary pad
14085 */
14086
14087 segment_size *= (1024 * 1024);
14088
14089 data.segment_size = segment_size;
14090
14091 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
14092
14093 wl_data->buf = (char *) mymalloc (segment_size);
14094 wl_data->avail = segment_size;
14095 wl_data->incr = segment_size;
14096 wl_data->cnt = 0;
14097 wl_data->pos = 0;
14098
14099 uint wordlist_mode = ((optind + 1) < myargc) ? WL_MODE_FILE : WL_MODE_STDIN;
14100
14101 data.wordlist_mode = wordlist_mode;
14102
14103 cs_t *css_buf = NULL;
14104 uint css_cnt = 0;
14105 uint dictcnt = 0;
14106 uint maskcnt = 1;
14107 char **masks = NULL;
14108 char **dictfiles = NULL;
14109
14110 uint mask_from_file = 0;
14111
14112 if (attack_mode == ATTACK_MODE_STRAIGHT)
14113 {
14114 if (wordlist_mode == WL_MODE_FILE)
14115 {
14116 int wls_left = myargc - (optind + 1);
14117
14118 for (int i = 0; i < wls_left; i++)
14119 {
14120 char *l0_filename = myargv[optind + 1 + i];
14121
14122 struct stat l0_stat;
14123
14124 if (stat (l0_filename, &l0_stat) == -1)
14125 {
14126 log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
14127
14128 return (-1);
14129 }
14130
14131 uint is_dir = S_ISDIR (l0_stat.st_mode);
14132
14133 if (is_dir == 0)
14134 {
14135 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14136
14137 dictcnt++;
14138
14139 dictfiles[dictcnt - 1] = l0_filename;
14140 }
14141 else
14142 {
14143 // do not allow --keyspace w/ a directory
14144
14145 if (keyspace == 1)
14146 {
14147 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
14148
14149 return (-1);
14150 }
14151
14152 char **dictionary_files = NULL;
14153
14154 dictionary_files = scan_directory (l0_filename);
14155
14156 if (dictionary_files != NULL)
14157 {
14158 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
14159
14160 for (int d = 0; dictionary_files[d] != NULL; d++)
14161 {
14162 char *l1_filename = dictionary_files[d];
14163
14164 struct stat l1_stat;
14165
14166 if (stat (l1_filename, &l1_stat) == -1)
14167 {
14168 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
14169
14170 return (-1);
14171 }
14172
14173 if (S_ISREG (l1_stat.st_mode))
14174 {
14175 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14176
14177 dictcnt++;
14178
14179 dictfiles[dictcnt - 1] = strdup (l1_filename);
14180 }
14181 }
14182 }
14183
14184 local_free (dictionary_files);
14185 }
14186 }
14187
14188 if (dictcnt < 1)
14189 {
14190 log_error ("ERROR: No usable dictionary file found.");
14191
14192 return (-1);
14193 }
14194 }
14195 else if (wordlist_mode == WL_MODE_STDIN)
14196 {
14197 dictcnt = 1;
14198 }
14199 }
14200 else if (attack_mode == ATTACK_MODE_COMBI)
14201 {
14202 // display
14203
14204 char *dictfile1 = myargv[optind + 1 + 0];
14205 char *dictfile2 = myargv[optind + 1 + 1];
14206
14207 // find the bigger dictionary and use as base
14208
14209 FILE *fp1;
14210 FILE *fp2;
14211
14212 struct stat tmp_stat;
14213
14214 if ((fp1 = fopen (dictfile1, "rb")) == NULL)
14215 {
14216 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
14217
14218 return (-1);
14219 }
14220
14221 if (stat (dictfile1, &tmp_stat) == -1)
14222 {
14223 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
14224
14225 fclose (fp1);
14226
14227 return (-1);
14228 }
14229
14230 if (S_ISDIR (tmp_stat.st_mode))
14231 {
14232 log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno));
14233
14234 fclose (fp1);
14235
14236 return (-1);
14237 }
14238
14239 if ((fp2 = fopen (dictfile2, "rb")) == NULL)
14240 {
14241 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
14242
14243 fclose (fp1);
14244
14245 return (-1);
14246 }
14247
14248 if (stat (dictfile2, &tmp_stat) == -1)
14249 {
14250 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
14251
14252 fclose (fp1);
14253 fclose (fp2);
14254
14255 return (-1);
14256 }
14257
14258 if (S_ISDIR (tmp_stat.st_mode))
14259 {
14260 log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno));
14261
14262 fclose (fp1);
14263 fclose (fp2);
14264
14265 return (-1);
14266 }
14267
14268 data.combs_cnt = 1;
14269
14270 data.quiet = 1;
14271
14272 const uint64_t words1_cnt = count_words (wl_data, fp1, dictfile1, dictstat_base, &dictstat_nmemb);
14273
14274 data.quiet = quiet;
14275
14276 if (words1_cnt == 0)
14277 {
14278 log_error ("ERROR: %s: empty file", dictfile1);
14279
14280 fclose (fp1);
14281 fclose (fp2);
14282
14283 return (-1);
14284 }
14285
14286 data.combs_cnt = 1;
14287
14288 data.quiet = 1;
14289
14290 const uint64_t words2_cnt = count_words (wl_data, fp2, dictfile2, dictstat_base, &dictstat_nmemb);
14291
14292 data.quiet = quiet;
14293
14294 if (words2_cnt == 0)
14295 {
14296 log_error ("ERROR: %s: empty file", dictfile2);
14297
14298 fclose (fp1);
14299 fclose (fp2);
14300
14301 return (-1);
14302 }
14303
14304 fclose (fp1);
14305 fclose (fp2);
14306
14307 data.dictfile = dictfile1;
14308 data.dictfile2 = dictfile2;
14309
14310 if (words1_cnt >= words2_cnt)
14311 {
14312 data.combs_cnt = words2_cnt;
14313 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
14314
14315 dictfiles = &data.dictfile;
14316
14317 dictcnt = 1;
14318 }
14319 else
14320 {
14321 data.combs_cnt = words1_cnt;
14322 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
14323
14324 dictfiles = &data.dictfile2;
14325
14326 dictcnt = 1;
14327
14328 // we also have to switch wordlist related rules!
14329
14330 char *tmpc = data.rule_buf_l;
14331
14332 data.rule_buf_l = data.rule_buf_r;
14333 data.rule_buf_r = tmpc;
14334
14335 int tmpi = data.rule_len_l;
14336
14337 data.rule_len_l = data.rule_len_r;
14338 data.rule_len_r = tmpi;
14339 }
14340 }
14341 else if (attack_mode == ATTACK_MODE_BF)
14342 {
14343 char *mask = NULL;
14344
14345 maskcnt = 0;
14346
14347 if (benchmark == 0)
14348 {
14349 mask = myargv[optind + 1];
14350
14351 masks = (char **) mymalloc (INCR_MASKS * sizeof (char *));
14352
14353 if ((optind + 2) <= myargc)
14354 {
14355 struct stat file_stat;
14356
14357 if (stat (mask, &file_stat) == -1)
14358 {
14359 maskcnt = 1;
14360
14361 masks[maskcnt - 1] = mystrdup (mask);
14362 }
14363 else
14364 {
14365 int wls_left = myargc - (optind + 1);
14366
14367 uint masks_avail = INCR_MASKS;
14368
14369 for (int i = 0; i < wls_left; i++)
14370 {
14371 if (i != 0)
14372 {
14373 mask = myargv[optind + 1 + i];
14374
14375 if (stat (mask, &file_stat) == -1)
14376 {
14377 log_error ("ERROR: %s: %s", mask, strerror (errno));
14378
14379 return (-1);
14380 }
14381 }
14382
14383 uint is_file = S_ISREG (file_stat.st_mode);
14384
14385 if (is_file == 1)
14386 {
14387 FILE *mask_fp;
14388
14389 if ((mask_fp = fopen (mask, "r")) == NULL)
14390 {
14391 log_error ("ERROR: %s: %s", mask, strerror (errno));
14392
14393 return (-1);
14394 }
14395
14396 char line_buf[BUFSIZ];
14397
14398 while (!feof (mask_fp))
14399 {
14400 memset (line_buf, 0, BUFSIZ);
14401
14402 int line_len = fgetl (mask_fp, line_buf);
14403
14404 if (line_len == 0) continue;
14405
14406 if (line_buf[0] == '#') continue;
14407
14408 if (masks_avail == maskcnt)
14409 {
14410 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
14411
14412 masks_avail += INCR_MASKS;
14413 }
14414
14415 masks[maskcnt] = mystrdup (line_buf);
14416
14417 maskcnt++;
14418 }
14419
14420 fclose (mask_fp);
14421 }
14422 else
14423 {
14424 log_error ("ERROR: %s: unsupported file-type", mask);
14425
14426 return (-1);
14427 }
14428 }
14429
14430 mask_from_file = 1;
14431 }
14432 }
14433 else
14434 {
14435 custom_charset_1 = (char *) "?l?d?u";
14436 custom_charset_2 = (char *) "?l?d";
14437 custom_charset_3 = (char *) "?l?d*!$@_";
14438
14439 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
14440 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
14441 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
14442
14443 masks[maskcnt] = mystrdup ("?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d");
14444
14445 wordlist_mode = WL_MODE_MASK;
14446
14447 data.wordlist_mode = wordlist_mode;
14448
14449 increment = 1;
14450
14451 maskcnt = 1;
14452 }
14453 }
14454 else
14455 {
14456 /**
14457 * generate full masks and charsets
14458 */
14459
14460 masks = (char **) mymalloc (sizeof (char *));
14461
14462 switch (hash_mode)
14463 {
14464 case 1731: pw_min = 5;
14465 pw_max = 5;
14466 mask = mystrdup ("?b?b?b?b?b");
14467 break;
14468 case 12500: pw_min = 5;
14469 pw_max = 5;
14470 mask = mystrdup ("?b?b?b?b?b");
14471 break;
14472 default: pw_min = 7;
14473 pw_max = 7;
14474 mask = mystrdup ("?b?b?b?b?b?b?b");
14475 break;
14476 }
14477
14478 maskcnt = 1;
14479
14480 masks[maskcnt - 1] = mystrdup (mask);
14481
14482 wordlist_mode = WL_MODE_MASK;
14483
14484 data.wordlist_mode = wordlist_mode;
14485
14486 increment = 1;
14487 }
14488
14489 dictfiles = (char **) mycalloc (pw_max, sizeof (char *));
14490
14491 if (increment)
14492 {
14493 if (increment_min > pw_min) pw_min = increment_min;
14494
14495 if (increment_max < pw_max) pw_max = increment_max;
14496 }
14497 }
14498 else if (attack_mode == ATTACK_MODE_HYBRID1)
14499 {
14500 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
14501
14502 // display
14503
14504 char *mask = myargv[myargc - 1];
14505
14506 maskcnt = 0;
14507
14508 masks = (char **) mymalloc (1 * sizeof (char *));
14509
14510 // mod
14511
14512 struct stat file_stat;
14513
14514 if (stat (mask, &file_stat) == -1)
14515 {
14516 maskcnt = 1;
14517
14518 masks[maskcnt - 1] = mystrdup (mask);
14519 }
14520 else
14521 {
14522 uint is_file = S_ISREG (file_stat.st_mode);
14523
14524 if (is_file == 1)
14525 {
14526 FILE *mask_fp;
14527
14528 if ((mask_fp = fopen (mask, "r")) == NULL)
14529 {
14530 log_error ("ERROR: %s: %s", mask, strerror (errno));
14531
14532 return (-1);
14533 }
14534
14535 char line_buf[BUFSIZ];
14536
14537 uint masks_avail = 1;
14538
14539 while (!feof (mask_fp))
14540 {
14541 memset (line_buf, 0, BUFSIZ);
14542
14543 int line_len = fgetl (mask_fp, line_buf);
14544
14545 if (line_len == 0) continue;
14546
14547 if (line_buf[0] == '#') continue;
14548
14549 if (masks_avail == maskcnt)
14550 {
14551 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
14552
14553 masks_avail += INCR_MASKS;
14554 }
14555
14556 masks[maskcnt] = mystrdup (line_buf);
14557
14558 maskcnt++;
14559 }
14560
14561 fclose (mask_fp);
14562
14563 mask_from_file = 1;
14564 }
14565 else
14566 {
14567 maskcnt = 1;
14568
14569 masks[maskcnt - 1] = mystrdup (mask);
14570 }
14571 }
14572
14573 // base
14574
14575 int wls_left = myargc - (optind + 2);
14576
14577 for (int i = 0; i < wls_left; i++)
14578 {
14579 char *filename = myargv[optind + 1 + i];
14580
14581 struct stat file_stat;
14582
14583 if (stat (filename, &file_stat) == -1)
14584 {
14585 log_error ("ERROR: %s: %s", filename, strerror (errno));
14586
14587 return (-1);
14588 }
14589
14590 uint is_dir = S_ISDIR (file_stat.st_mode);
14591
14592 if (is_dir == 0)
14593 {
14594 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14595
14596 dictcnt++;
14597
14598 dictfiles[dictcnt - 1] = filename;
14599 }
14600 else
14601 {
14602 // do not allow --keyspace w/ a directory
14603
14604 if (keyspace == 1)
14605 {
14606 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
14607
14608 return (-1);
14609 }
14610
14611 char **dictionary_files = NULL;
14612
14613 dictionary_files = scan_directory (filename);
14614
14615 if (dictionary_files != NULL)
14616 {
14617 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
14618
14619 for (int d = 0; dictionary_files[d] != NULL; d++)
14620 {
14621 char *l1_filename = dictionary_files[d];
14622
14623 struct stat l1_stat;
14624
14625 if (stat (l1_filename, &l1_stat) == -1)
14626 {
14627 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
14628
14629 return (-1);
14630 }
14631
14632 if (S_ISREG (l1_stat.st_mode))
14633 {
14634 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14635
14636 dictcnt++;
14637
14638 dictfiles[dictcnt - 1] = strdup (l1_filename);
14639 }
14640 }
14641 }
14642
14643 local_free (dictionary_files);
14644 }
14645 }
14646
14647 if (dictcnt < 1)
14648 {
14649 log_error ("ERROR: No usable dictionary file found.");
14650
14651 return (-1);
14652 }
14653
14654 if (increment)
14655 {
14656 maskcnt = 0;
14657
14658 uint mask_min = increment_min; // we can't reject smaller masks here
14659 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
14660
14661 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
14662 {
14663 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
14664
14665 if (cur_mask == NULL) break;
14666
14667 masks[maskcnt] = cur_mask;
14668
14669 maskcnt++;
14670
14671 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
14672 }
14673 }
14674 }
14675 else if (attack_mode == ATTACK_MODE_HYBRID2)
14676 {
14677 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
14678
14679 // display
14680
14681 char *mask = myargv[optind + 1 + 0];
14682
14683 maskcnt = 0;
14684
14685 masks = (char **) mymalloc (1 * sizeof (char *));
14686
14687 // mod
14688
14689 struct stat file_stat;
14690
14691 if (stat (mask, &file_stat) == -1)
14692 {
14693 maskcnt = 1;
14694
14695 masks[maskcnt - 1] = mystrdup (mask);
14696 }
14697 else
14698 {
14699 uint is_file = S_ISREG (file_stat.st_mode);
14700
14701 if (is_file == 1)
14702 {
14703 FILE *mask_fp;
14704
14705 if ((mask_fp = fopen (mask, "r")) == NULL)
14706 {
14707 log_error ("ERROR: %s: %s", mask, strerror (errno));
14708
14709 return (-1);
14710 }
14711
14712 char line_buf[BUFSIZ];
14713
14714 uint masks_avail = 1;
14715
14716 while (!feof (mask_fp))
14717 {
14718 memset (line_buf, 0, BUFSIZ);
14719
14720 int line_len = fgetl (mask_fp, line_buf);
14721
14722 if (line_len == 0) continue;
14723
14724 if (line_buf[0] == '#') continue;
14725
14726 if (masks_avail == maskcnt)
14727 {
14728 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
14729
14730 masks_avail += INCR_MASKS;
14731 }
14732
14733 masks[maskcnt] = mystrdup (line_buf);
14734
14735 maskcnt++;
14736 }
14737
14738 fclose (mask_fp);
14739
14740 mask_from_file = 1;
14741 }
14742 else
14743 {
14744 maskcnt = 1;
14745
14746 masks[maskcnt - 1] = mystrdup (mask);
14747 }
14748 }
14749
14750 // base
14751
14752 int wls_left = myargc - (optind + 2);
14753
14754 for (int i = 0; i < wls_left; i++)
14755 {
14756 char *filename = myargv[optind + 2 + i];
14757
14758 struct stat file_stat;
14759
14760 if (stat (filename, &file_stat) == -1)
14761 {
14762 log_error ("ERROR: %s: %s", filename, strerror (errno));
14763
14764 return (-1);
14765 }
14766
14767 uint is_dir = S_ISDIR (file_stat.st_mode);
14768
14769 if (is_dir == 0)
14770 {
14771 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14772
14773 dictcnt++;
14774
14775 dictfiles[dictcnt - 1] = filename;
14776 }
14777 else
14778 {
14779 // do not allow --keyspace w/ a directory
14780
14781 if (keyspace == 1)
14782 {
14783 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
14784
14785 return (-1);
14786 }
14787
14788 char **dictionary_files = NULL;
14789
14790 dictionary_files = scan_directory (filename);
14791
14792 if (dictionary_files != NULL)
14793 {
14794 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
14795
14796 for (int d = 0; dictionary_files[d] != NULL; d++)
14797 {
14798 char *l1_filename = dictionary_files[d];
14799
14800 struct stat l1_stat;
14801
14802 if (stat (l1_filename, &l1_stat) == -1)
14803 {
14804 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
14805
14806 return (-1);
14807 }
14808
14809 if (S_ISREG (l1_stat.st_mode))
14810 {
14811 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14812
14813 dictcnt++;
14814
14815 dictfiles[dictcnt - 1] = strdup (l1_filename);
14816 }
14817 }
14818 }
14819
14820 local_free (dictionary_files);
14821 }
14822 }
14823
14824 if (dictcnt < 1)
14825 {
14826 log_error ("ERROR: No usable dictionary file found.");
14827
14828 return (-1);
14829 }
14830
14831 if (increment)
14832 {
14833 maskcnt = 0;
14834
14835 uint mask_min = increment_min; // we can't reject smaller masks here
14836 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
14837
14838 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
14839 {
14840 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
14841
14842 if (cur_mask == NULL) break;
14843
14844 masks[maskcnt] = cur_mask;
14845
14846 maskcnt++;
14847
14848 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
14849 }
14850 }
14851 }
14852
14853 data.pw_min = pw_min;
14854 data.pw_max = pw_max;
14855
14856 /**
14857 * weak hash check
14858 */
14859
14860 if (weak_hash_threshold >= salts_cnt)
14861 {
14862 if (data.quiet == 0) log_info_nn ("Checking for weak hashes...");
14863
14864 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
14865 {
14866 weak_hash_check (&data.devices_param[0], salt_pos, gpu_loops);
14867 }
14868 }
14869
14870 // Display hack, guarantee that there is at least one \r before real start
14871
14872 if (data.quiet == 0) log_info_nn ("");
14873
14874 /**
14875 * status and monitor threads
14876 */
14877
14878 if (data.devices_status != STATUS_CRACKED) data.devices_status = STATUS_STARTING;
14879
14880 hc_thread_t i_thread = 0;
14881
14882 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
14883 {
14884 hc_thread_create (i_thread, thread_keypress, &benchmark);
14885 }
14886
14887 if (wordlist_mode == WL_MODE_STDIN) data.status = 1;
14888
14889 uint ni_threads_cnt = 0;
14890
14891 hc_thread_t *ni_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
14892
14893 hc_thread_create (ni_threads[ni_threads_cnt], thread_monitor, NULL);
14894
14895 ni_threads_cnt++;
14896
14897 /**
14898 * Outfile remove
14899 */
14900
14901 if (keyspace == 0)
14902 {
14903 if (outfile_check_timer != 0)
14904 {
14905 if (data.outfile_check_directory != NULL)
14906 {
14907 if ((hash_mode != 5200) &&
14908 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
14909 (hash_mode != 9000))
14910 {
14911 hc_thread_create (ni_threads[ni_threads_cnt], thread_outfile_remove, NULL);
14912
14913 ni_threads_cnt++;
14914 }
14915 else
14916 {
14917 outfile_check_timer = 0;
14918 }
14919 }
14920 else
14921 {
14922 outfile_check_timer = 0;
14923 }
14924 }
14925 }
14926
14927 /**
14928 * Inform the user if we got some hashes remove because of the pot file remove feature
14929 */
14930
14931 if (data.quiet == 0)
14932 {
14933 if (potfile_remove_cracks > 0)
14934 {
14935 if (potfile_remove_cracks == 1) log_info ("INFO: removed 1 hash found in pot file\n");
14936 else log_info ("INFO: removed %u hashes found in pot file\n", potfile_remove_cracks);
14937 }
14938 }
14939
14940 data.outfile_check_timer = outfile_check_timer;
14941
14942 /**
14943 * main loop
14944 */
14945
14946 char **induction_dictionaries = NULL;
14947
14948 int induction_dictionaries_cnt = 0;
14949
14950 hcstat_table_t *root_table_buf = NULL;
14951 hcstat_table_t *markov_table_buf = NULL;
14952
14953 uint initial_restore_done = 0;
14954
14955 data.maskcnt = maskcnt;
14956
14957 for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
14958 {
14959 if (data.devices_status == STATUS_CRACKED) break;
14960
14961 data.devices_status = STATUS_INIT;
14962
14963 if (maskpos > rd->maskpos)
14964 {
14965 rd->dictpos = 0;
14966 }
14967
14968 rd->maskpos = maskpos;
14969 data.maskpos = maskpos;
14970
14971 if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2 || attack_mode == ATTACK_MODE_BF)
14972 {
14973 char *mask = masks[maskpos];
14974
14975 if (mask_from_file == 1)
14976 {
14977 if (mask[0] == '\\' && mask[1] == '#') mask++; // escaped comment sign (sharp) "\#"
14978
14979 char *str_ptr;
14980 uint str_pos;
14981
14982 uint mask_offset = 0;
14983
14984 uint separator_cnt;
14985
14986 for (separator_cnt = 0; separator_cnt < 4; separator_cnt++)
14987 {
14988 str_ptr = strstr (mask + mask_offset, ",");
14989
14990 if (str_ptr == NULL) break;
14991
14992 str_pos = str_ptr - mask;
14993
14994 // escaped separator, i.e. "\,"
14995
14996 if (str_pos > 0)
14997 {
14998 if (mask[str_pos - 1] == '\\')
14999 {
15000 separator_cnt --;
15001
15002 mask_offset = str_pos + 1;
15003
15004 continue;
15005 }
15006 }
15007
15008 // reset the offset
15009
15010 mask_offset = 0;
15011
15012 mask[str_pos] = '\0';
15013
15014 switch (separator_cnt)
15015 {
15016 case 0:
15017 mp_reset_usr (mp_usr, 0);
15018
15019 custom_charset_1 = mask;
15020 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
15021 break;
15022
15023 case 1:
15024 mp_reset_usr (mp_usr, 1);
15025
15026 custom_charset_2 = mask;
15027 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
15028 break;
15029
15030 case 2:
15031 mp_reset_usr (mp_usr, 2);
15032
15033 custom_charset_3 = mask;
15034 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
15035 break;
15036
15037 case 3:
15038 mp_reset_usr (mp_usr, 3);
15039
15040 custom_charset_4 = mask;
15041 mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
15042 break;
15043 }
15044
15045 mask = mask + str_pos + 1;
15046 }
15047 }
15048
15049 if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
15050 {
15051 if (maskpos > 0)
15052 {
15053 local_free (css_buf);
15054 local_free (data.root_css_buf);
15055 local_free (data.markov_css_buf);
15056
15057 local_free (masks[maskpos - 1]);
15058 }
15059
15060 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
15061
15062 data.mask = mask;
15063 data.css_cnt = css_cnt;
15064 data.css_buf = css_buf;
15065
15066 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
15067
15068 memset (uniq_tbls, 0, sizeof (uniq_tbls));
15069
15070 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
15071
15072 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
15073 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
15074
15075 sp_setup_tbl (install_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
15076
15077 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
15078
15079 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
15080 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
15081
15082 data.root_css_buf = root_css_buf;
15083 data.markov_css_buf = markov_css_buf;
15084
15085 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
15086
15087 data.combs_cnt = sp_get_sum (0, css_cnt, root_css_buf);
15088
15089 local_free (root_table_buf);
15090 local_free (markov_table_buf);
15091
15092 // args
15093
15094 for (uint device_id = 0; device_id < devices_cnt; device_id++)
15095 {
15096 hc_device_param_t *device_param = &data.devices_param[device_id];
15097
15098 device_param->kernel_params_mp[0] = &device_param->d_combs;
15099 device_param->kernel_params_mp[1] = &device_param->d_root_css_buf;
15100 device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf;
15101
15102 device_param->kernel_params_mp_buf64[3] = 0;
15103 device_param->kernel_params_mp_buf32[4] = css_cnt;
15104 device_param->kernel_params_mp_buf32[5] = 0;
15105 device_param->kernel_params_mp_buf32[6] = 0;
15106 device_param->kernel_params_mp_buf32[7] = 0;
15107
15108 if (attack_mode == ATTACK_MODE_HYBRID1)
15109 {
15110 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_buf32[5] = full01;
15111 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_buf32[5] = full80;
15112 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_buf32[6] = 1;
15113 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_buf32[7] = 1;
15114 }
15115 else if (attack_mode == ATTACK_MODE_HYBRID2)
15116 {
15117 device_param->kernel_params_mp_buf32[5] = 0;
15118 device_param->kernel_params_mp_buf32[6] = 0;
15119 device_param->kernel_params_mp_buf32[7] = 0;
15120 }
15121
15122 for (uint i = 0; i < 3; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]);
15123 for (uint i = 3; i < 4; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]);
15124 for (uint i = 4; i < 8; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]);
15125
15126 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);
15127 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);
15128 }
15129 }
15130 else if (attack_mode == ATTACK_MODE_BF)
15131 {
15132 dictcnt = 0; // number of "sub-masks", i.e. when using incremental mode
15133
15134 if (increment)
15135 {
15136 for (uint i = 0; i < dictcnt; i++)
15137 {
15138 local_free (dictfiles[i]);
15139 }
15140
15141 for (uint pw_len = MAX (1, pw_min); pw_len <= pw_max; pw_len++)
15142 {
15143 char *l1_filename = mp_get_truncated_mask (mask, strlen (mask), pw_len);
15144
15145 if (l1_filename == NULL) break;
15146
15147 dictcnt++;
15148
15149 dictfiles[dictcnt - 1] = l1_filename;
15150 }
15151 }
15152 else
15153 {
15154 dictcnt++;
15155
15156 dictfiles[dictcnt - 1] = mask;
15157 }
15158
15159 if (dictcnt == 0)
15160 {
15161 log_error ("ERROR: Mask is too small");
15162
15163 return (-1);
15164 }
15165 }
15166 }
15167
15168 free (induction_dictionaries);
15169
15170 // induction_dictionaries_cnt = 0; // implied
15171
15172 if (attack_mode != ATTACK_MODE_BF)
15173 {
15174 if (keyspace == 0)
15175 {
15176 induction_dictionaries = scan_directory (induction_directory);
15177
15178 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
15179 }
15180 }
15181
15182 if (induction_dictionaries_cnt)
15183 {
15184 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
15185 }
15186
15187 /**
15188 * prevent the user from using --keyspace together w/ maskfile and or dictfile
15189 */
15190 if (keyspace == 1)
15191 {
15192 if ((maskcnt > 1) || (dictcnt > 1))
15193 {
15194 log_error ("ERROR: --keyspace is not supported with --increment or mask files");
15195
15196 return (-1);
15197 }
15198 }
15199
15200 for (uint dictpos = rd->dictpos; dictpos < dictcnt; )
15201 {
15202 char *subid = logfile_generate_subid ();
15203
15204 data.subid = subid;
15205
15206 logfile_sub_msg ("START");
15207
15208 data.devices_status = STATUS_INIT;
15209
15210 memset (data.words_progress_done, 0, data.salts_cnt * sizeof (uint64_t));
15211 memset (data.words_progress_rejected, 0, data.salts_cnt * sizeof (uint64_t));
15212 memset (data.words_progress_restored, 0, data.salts_cnt * sizeof (uint64_t));
15213
15214 memset (data.cpt_buf, 0, CPT_BUF * sizeof (cpt_t));
15215
15216 data.cpt_pos = 0;
15217
15218 data.cpt_start = time (NULL);
15219
15220 data.cpt_total = 0;
15221
15222 if (data.restore == 0)
15223 {
15224 rd->words_cur = skip;
15225
15226 skip = 0;
15227
15228 data.skip = 0;
15229 }
15230
15231 data.ms_paused = 0;
15232
15233 data.words_cur = rd->words_cur;
15234
15235 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
15236 {
15237 hc_device_param_t *device_param = &data.devices_param[device_id];
15238
15239 device_param->speed_pos = 0;
15240
15241 memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (uint64_t));
15242 memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float));
15243 memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
15244
15245 device_param->gpu_power = device_param->gpu_power_user;
15246 device_param->gpu_blocks = device_param->gpu_blocks_user;
15247
15248 device_param->outerloop_pos = 0;
15249 device_param->outerloop_left = 0;
15250 device_param->innerloop_pos = 0;
15251 device_param->innerloop_left = 0;
15252
15253 // some more resets:
15254
15255 memset (device_param->pw_caches, 0, 64 * sizeof (pw_cache_t));
15256
15257 memset (device_param->pws_buf, 0, device_param->size_pws);
15258
15259 device_param->pw_cnt = 0;
15260 device_param->pws_cnt = 0;
15261
15262 device_param->words_off = 0;
15263 device_param->words_done = 0;
15264 }
15265
15266 data.gpu_blocks_div = 0;
15267
15268 // figure out some workload
15269
15270 if (attack_mode == ATTACK_MODE_STRAIGHT)
15271 {
15272 if (data.wordlist_mode == WL_MODE_FILE)
15273 {
15274 char *dictfile = NULL;
15275
15276 if (induction_dictionaries_cnt)
15277 {
15278 dictfile = induction_dictionaries[0];
15279 }
15280 else
15281 {
15282 dictfile = dictfiles[dictpos];
15283 }
15284
15285 data.dictfile = dictfile;
15286
15287 logfile_sub_string (dictfile);
15288
15289 for (uint i = 0; i < rp_files_cnt; i++)
15290 {
15291 logfile_sub_var_string ("rulefile", rp_files[i]);
15292 }
15293
15294 FILE *fd2 = fopen (dictfile, "rb");
15295
15296 if (fd2 == NULL)
15297 {
15298 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
15299
15300 return (-1);
15301 }
15302
15303 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
15304
15305 fclose (fd2);
15306
15307 if (data.words_cnt == 0)
15308 {
15309 if (data.devices_status == STATUS_CRACKED) break;
15310 if (data.devices_status == STATUS_ABORTED) break;
15311
15312 dictpos++;
15313
15314 continue;
15315 }
15316 }
15317 }
15318 else if (attack_mode == ATTACK_MODE_COMBI)
15319 {
15320 char *dictfile = data.dictfile;
15321 char *dictfile2 = data.dictfile2;
15322
15323 logfile_sub_string (dictfile);
15324 logfile_sub_string (dictfile2);
15325
15326 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
15327 {
15328 FILE *fd2 = fopen (dictfile, "rb");
15329
15330 if (fd2 == NULL)
15331 {
15332 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
15333
15334 return (-1);
15335 }
15336
15337 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
15338
15339 fclose (fd2);
15340 }
15341 else if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
15342 {
15343 FILE *fd2 = fopen (dictfile2, "rb");
15344
15345 if (fd2 == NULL)
15346 {
15347 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
15348
15349 return (-1);
15350 }
15351
15352 data.words_cnt = count_words (wl_data, fd2, dictfile2, dictstat_base, &dictstat_nmemb);
15353
15354 fclose (fd2);
15355 }
15356
15357 if (data.words_cnt == 0)
15358 {
15359 if (data.devices_status == STATUS_CRACKED) break;
15360 if (data.devices_status == STATUS_ABORTED) break;
15361
15362 dictpos++;
15363
15364 continue;
15365 }
15366 }
15367 else if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
15368 {
15369 char *dictfile = NULL;
15370
15371 if (induction_dictionaries_cnt)
15372 {
15373 dictfile = induction_dictionaries[0];
15374 }
15375 else
15376 {
15377 dictfile = dictfiles[dictpos];
15378 }
15379
15380 data.dictfile = dictfile;
15381
15382 char *mask = data.mask;
15383
15384 logfile_sub_string (dictfile);
15385 logfile_sub_string (mask);
15386
15387 FILE *fd2 = fopen (dictfile, "rb");
15388
15389 if (fd2 == NULL)
15390 {
15391 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
15392
15393 return (-1);
15394 }
15395
15396 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
15397
15398 fclose (fd2);
15399
15400 if (data.words_cnt == 0)
15401 {
15402 if (data.devices_status == STATUS_CRACKED) break;
15403 if (data.devices_status == STATUS_ABORTED) break;
15404
15405 dictpos++;
15406
15407 continue;
15408 }
15409 }
15410 else if (attack_mode == ATTACK_MODE_BF)
15411 {
15412 local_free (css_buf);
15413 local_free (data.root_css_buf);
15414 local_free (data.markov_css_buf);
15415
15416 char *mask = dictfiles[dictpos];
15417
15418 logfile_sub_string (mask);
15419
15420 // base
15421
15422 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
15423
15424 if (opts_type & OPTS_TYPE_PT_UNICODE)
15425 {
15426 uint css_cnt_unicode = css_cnt * 2;
15427
15428 cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t));
15429
15430 for (uint i = 0, j = 0; i < css_cnt; i += 1, j += 2)
15431 {
15432 memcpy (&css_buf_unicode[j + 0], &css_buf[i], sizeof (cs_t));
15433
15434 css_buf_unicode[j + 1].cs_buf[0] = 0;
15435 css_buf_unicode[j + 1].cs_len = 1;
15436 }
15437
15438 free (css_buf);
15439
15440 css_buf = css_buf_unicode;
15441 css_cnt = css_cnt_unicode;
15442 }
15443
15444 // check if mask is not too large or too small for pw_min/pw_max (*2 if unicode)
15445
15446 uint mask_min = pw_min;
15447 uint mask_max = pw_max;
15448
15449 if (opts_type & OPTS_TYPE_PT_UNICODE)
15450 {
15451 mask_min *= 2;
15452 mask_max *= 2;
15453 }
15454
15455 if ((css_cnt < mask_min) || (css_cnt > mask_max))
15456 {
15457 if (css_cnt < mask_min)
15458 {
15459 log_info ("WARNING: skipping mask '%s' because it is smaller than the minimum password length", mask);
15460 }
15461
15462 if (css_cnt > mask_max)
15463 {
15464 log_info ("WARNING: skipping mask '%s' because it is larger than the maximum password length", mask);
15465 }
15466
15467 // skip to next mask
15468
15469 dictpos++;
15470
15471 rd->dictpos = dictpos;
15472
15473 logfile_sub_msg ("STOP");
15474
15475 continue;
15476 }
15477
15478 uint save_css_cnt = css_cnt;
15479
15480 if (opti_type & OPTI_TYPE_SINGLE_HASH)
15481 {
15482 if (opti_type & OPTI_TYPE_APPENDED_SALT)
15483 {
15484 uint salt_len = (uint) data.salts_buf[0].salt_len;
15485 char *salt_buf = (char *) data.salts_buf[0].salt_buf;
15486
15487 uint css_cnt_salt = css_cnt + salt_len;
15488
15489 cs_t *css_buf_salt = (cs_t *) mycalloc (css_cnt_salt, sizeof (cs_t));
15490
15491 memcpy (css_buf_salt, css_buf, css_cnt * sizeof (cs_t));
15492
15493 for (uint i = 0, j = css_cnt; i < salt_len; i++, j++)
15494 {
15495 css_buf_salt[j].cs_buf[0] = salt_buf[i];
15496 css_buf_salt[j].cs_len = 1;
15497 }
15498
15499 free (css_buf);
15500
15501 css_buf = css_buf_salt;
15502 css_cnt = css_cnt_salt;
15503 }
15504 }
15505
15506 data.mask = mask;
15507 data.css_cnt = css_cnt;
15508 data.css_buf = css_buf;
15509
15510 if (maskpos > 0 && dictpos == 0) free (masks[maskpos - 1]);
15511
15512 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
15513
15514 memset (uniq_tbls, 0, sizeof (uniq_tbls));
15515
15516 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
15517
15518 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
15519 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
15520
15521 sp_setup_tbl (install_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
15522
15523 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
15524
15525 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
15526 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
15527
15528 data.root_css_buf = root_css_buf;
15529 data.markov_css_buf = markov_css_buf;
15530
15531 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
15532
15533 data.words_cnt = sp_get_sum (0, css_cnt, root_css_buf);
15534
15535 local_free (root_table_buf);
15536 local_free (markov_table_buf);
15537
15538 // copy + args
15539
15540 uint css_cnt_l = css_cnt;
15541 uint css_cnt_r;
15542
15543 if (attack_exec == ATTACK_EXEC_ON_GPU)
15544 {
15545 if (save_css_cnt < 6)
15546 {
15547 css_cnt_r = 1;
15548 }
15549 else if (save_css_cnt == 6)
15550 {
15551 css_cnt_r = 2;
15552 }
15553 else
15554 {
15555 if (opts_type & OPTS_TYPE_PT_UNICODE)
15556 {
15557 if (save_css_cnt == 8 || save_css_cnt == 10)
15558 {
15559 css_cnt_r = 2;
15560 }
15561 else
15562 {
15563 css_cnt_r = 4;
15564 }
15565 }
15566 else
15567 {
15568 if ((css_buf[0].cs_len * css_buf[1].cs_len * css_buf[2].cs_len) > 256)
15569 {
15570 css_cnt_r = 3;
15571 }
15572 else
15573 {
15574 css_cnt_r = 4;
15575 }
15576 }
15577 }
15578 }
15579 else
15580 {
15581 css_cnt_r = 1;
15582
15583 /* unfinished code?
15584 int sum = css_buf[css_cnt_r - 1].cs_len;
15585
15586 for (uint i = 1; i < 4 && i < css_cnt; i++)
15587 {
15588 if (sum > 1) break; // we really don't need alot of amplifier them for slow hashes
15589
15590 css_cnt_r++;
15591
15592 sum *= css_buf[css_cnt_r - 1].cs_len;
15593 }
15594 */
15595 }
15596
15597 css_cnt_l -= css_cnt_r;
15598
15599 data.bfs_cnt = sp_get_sum (0, css_cnt_r, root_css_buf);
15600
15601 for (uint device_id = 0; device_id < devices_cnt; device_id++)
15602 {
15603 hc_device_param_t *device_param = &data.devices_param[device_id];
15604
15605 device_param->kernel_params_mp_l[0] = &device_param->d_pws_buf;
15606 device_param->kernel_params_mp_l[1] = &device_param->d_root_css_buf;
15607 device_param->kernel_params_mp_l[2] = &device_param->d_markov_css_buf;
15608
15609 device_param->kernel_params_mp_l_buf64[3] = 0;
15610 device_param->kernel_params_mp_l_buf32[4] = css_cnt_l;
15611 device_param->kernel_params_mp_l_buf32[5] = css_cnt_r;
15612 device_param->kernel_params_mp_l_buf32[6] = 0;
15613 device_param->kernel_params_mp_l_buf32[7] = 0;
15614 device_param->kernel_params_mp_l_buf32[8] = 0;
15615
15616 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_l_buf32[6] = full01;
15617 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_l_buf32[6] = full80;
15618 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1;
15619 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1;
15620
15621 device_param->kernel_params_mp_r[0] = &device_param->d_bfs;
15622 device_param->kernel_params_mp_r[1] = &device_param->d_root_css_buf;
15623 device_param->kernel_params_mp_r[2] = &device_param->d_markov_css_buf;
15624
15625 device_param->kernel_params_mp_r_buf64[3] = 0;
15626 device_param->kernel_params_mp_r_buf32[4] = css_cnt_r;
15627 device_param->kernel_params_mp_r_buf32[5] = 0;
15628 device_param->kernel_params_mp_r_buf32[6] = 0;
15629 device_param->kernel_params_mp_r_buf32[7] = 0;
15630
15631 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]);
15632 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]);
15633 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]);
15634
15635 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]);
15636 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]);
15637 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]);
15638
15639 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);
15640 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);
15641 }
15642 }
15643
15644 uint64_t words_base = data.words_cnt;
15645
15646 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
15647 {
15648 if (data.gpu_rules_cnt)
15649 {
15650 words_base /= data.gpu_rules_cnt;
15651 }
15652 }
15653 else if (data.attack_kern == ATTACK_KERN_COMBI)
15654 {
15655 if (data.combs_cnt)
15656 {
15657 words_base /= data.combs_cnt;
15658 }
15659 }
15660 else if (data.attack_kern == ATTACK_KERN_BF)
15661 {
15662 if (data.bfs_cnt)
15663 {
15664 words_base /= data.bfs_cnt;
15665 }
15666 }
15667
15668 data.words_base = words_base;
15669
15670 if (keyspace == 1)
15671 {
15672 log_info ("%llu", (unsigned long long int) words_base);
15673
15674 return (0);
15675 }
15676
15677 if (data.words_cur > data.words_base)
15678 {
15679 log_error ("ERROR: restore value greater keyspace");
15680
15681 return (-1);
15682 }
15683
15684 if (data.words_cur)
15685 {
15686 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
15687 {
15688 for (uint i = 0; i < data.salts_cnt; i++)
15689 {
15690 data.words_progress_restored[i] = data.words_cur * data.gpu_rules_cnt;
15691 }
15692 }
15693 else if (data.attack_kern == ATTACK_KERN_COMBI)
15694 {
15695 for (uint i = 0; i < data.salts_cnt; i++)
15696 {
15697 data.words_progress_restored[i] = data.words_cur * data.combs_cnt;
15698 }
15699 }
15700 else if (data.attack_kern == ATTACK_KERN_BF)
15701 {
15702 for (uint i = 0; i < data.salts_cnt; i++)
15703 {
15704 data.words_progress_restored[i] = data.words_cur * data.bfs_cnt;
15705 }
15706 }
15707 }
15708
15709 /*
15710 * Inform user about possible slow speeds
15711 */
15712
15713 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
15714 {
15715 if (data.words_base < gpu_blocks_all)
15716 {
15717 if (quiet == 0)
15718 {
15719 log_info ("");
15720 log_info ("ATTENTION!");
15721 log_info (" The wordlist or mask you are using is too small.");
15722 log_info (" Therefore, oclHashcat is unable to utilize the full parallelization power of your GPU(s).");
15723 log_info (" The cracking speed will drop.");
15724 log_info (" Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
15725 log_info ("");
15726 }
15727 }
15728 }
15729
15730 /*
15731 * Update loopback file
15732 */
15733
15734 if (loopback == 1)
15735 {
15736 time_t now;
15737
15738 time (&now);
15739
15740 uint random_num = get_random_num (0, 9999);
15741
15742 snprintf (loopback_file, loopback_size - 1, "%s/%s.%d_%i", induction_directory, LOOPBACK_FILE, (int) now, random_num);
15743
15744 data.loopback_file = loopback_file;
15745 }
15746
15747 /*
15748 * Update dictionary statistic
15749 */
15750
15751 if (keyspace == 0)
15752 {
15753 dictstat_fp = fopen (dictstat, "wb");
15754
15755 if (dictstat_fp)
15756 {
15757 fwrite (dictstat_base, sizeof (dictstat_t), dictstat_nmemb, dictstat_fp);
15758
15759 fclose (dictstat_fp);
15760 }
15761 }
15762
15763 data.devices_status = STATUS_RUNNING;
15764
15765 if (initial_restore_done == 0)
15766 {
15767 if (data.restore_disable == 0) cycle_restore ();
15768
15769 initial_restore_done = 1;
15770 }
15771
15772 hc_timer_set (&data.timer_running);
15773
15774 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
15775 {
15776 if ((quiet == 0) && (status == 0) && (benchmark == 0))
15777 {
15778 if (quiet == 0) fprintf (stdout, "%s", PROMPT);
15779 if (quiet == 0) fflush (stdout);
15780 }
15781 }
15782 else if (wordlist_mode == WL_MODE_STDIN)
15783 {
15784 if (data.quiet == 0) log_info ("Starting attack in stdin mode...");
15785 if (data.quiet == 0) log_info ("");
15786 }
15787
15788 time_t runtime_start;
15789
15790 time (&runtime_start);
15791
15792 data.runtime_start = runtime_start;
15793
15794 /**
15795 * create cracker threads
15796 */
15797
15798 hc_thread_t *c_threads = (hc_thread_t *) mycalloc (devices_cnt, sizeof (hc_thread_t));
15799
15800 for (uint device_id = 0; device_id < devices_cnt; device_id++)
15801 {
15802 hc_device_param_t *device_param = &devices_param[device_id];
15803
15804 device_param->device_id = device_id;
15805
15806 if (wordlist_mode == WL_MODE_STDIN)
15807 {
15808 hc_thread_create (c_threads[device_id], thread_calc_stdin, device_param);
15809 }
15810 else
15811 {
15812 hc_thread_create (c_threads[device_id], thread_calc, device_param);
15813 }
15814 }
15815
15816 // wait for crack threads to exit
15817
15818 hc_thread_wait (devices_cnt, c_threads);
15819
15820 local_free (c_threads);
15821
15822 data.restore = 0;
15823
15824 // finalize task
15825
15826 logfile_sub_var_uint ("status-after-work", data.devices_status);
15827
15828 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
15829
15830 if (data.devices_status == STATUS_CRACKED) break;
15831 if (data.devices_status == STATUS_ABORTED) break;
15832
15833 if (data.devices_status == STATUS_BYPASS)
15834 {
15835 data.devices_status = STATUS_RUNNING;
15836 }
15837
15838 if (induction_dictionaries_cnt)
15839 {
15840 unlink (induction_dictionaries[0]);
15841 }
15842
15843 free (induction_dictionaries);
15844
15845 if (attack_mode != ATTACK_MODE_BF)
15846 {
15847 induction_dictionaries = scan_directory (induction_directory);
15848
15849 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
15850 }
15851
15852 if (benchmark == 0)
15853 {
15854 if (((dictpos + 1) < dictcnt) || ((maskpos + 1) < maskcnt) || induction_dictionaries_cnt)
15855 {
15856 if (quiet == 0) clear_prompt ();
15857
15858 if (quiet == 0) log_info ("");
15859
15860 if (status == 1)
15861 {
15862 status_display ();
15863 }
15864 else
15865 {
15866 if (quiet == 0) status_display ();
15867 }
15868
15869 if (quiet == 0) log_info ("");
15870 }
15871 }
15872
15873 if (attack_mode == ATTACK_MODE_BF)
15874 {
15875 dictpos++;
15876
15877 rd->dictpos = dictpos;
15878 }
15879 else
15880 {
15881 if (induction_dictionaries_cnt)
15882 {
15883 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
15884 }
15885 else
15886 {
15887 dictpos++;
15888
15889 rd->dictpos = dictpos;
15890 }
15891 }
15892
15893 time_t runtime_stop;
15894
15895 time (&runtime_stop);
15896
15897 data.runtime_stop = runtime_stop;
15898
15899 logfile_sub_uint (runtime_start);
15900 logfile_sub_uint (runtime_stop);
15901
15902 logfile_sub_msg ("STOP");
15903
15904 global_free (subid);
15905 }
15906
15907 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
15908
15909 if (data.devices_status == STATUS_CRACKED) break;
15910 if (data.devices_status == STATUS_ABORTED) break;
15911 if (data.devices_status == STATUS_QUIT) break;
15912
15913 if (data.devices_status == STATUS_BYPASS)
15914 {
15915 data.devices_status = STATUS_RUNNING;
15916 }
15917 }
15918
15919 // 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
15920
15921 if (attack_mode == ATTACK_MODE_STRAIGHT)
15922 {
15923 if (data.wordlist_mode == WL_MODE_FILE)
15924 {
15925 if (data.dictfile == NULL)
15926 {
15927 if (dictfiles != NULL)
15928 {
15929 data.dictfile = dictfiles[0];
15930
15931 hc_timer_set (&data.timer_running);
15932 }
15933 }
15934 }
15935 }
15936 // NOTE: combi is okay because it is already set beforehand
15937 else if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2)
15938 {
15939 if (data.dictfile == NULL)
15940 {
15941 if (dictfiles != NULL)
15942 {
15943 hc_timer_set (&data.timer_running);
15944
15945 data.dictfile = dictfiles[0];
15946 }
15947 }
15948 }
15949 else if (attack_mode == ATTACK_MODE_BF)
15950 {
15951 if (data.mask == NULL)
15952 {
15953 hc_timer_set (&data.timer_running);
15954
15955 data.mask = masks[0];
15956 }
15957 }
15958
15959 if ((data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
15960 {
15961 data.devices_status = STATUS_EXHAUSTED;
15962 }
15963
15964 // if cracked / aborted remove last induction dictionary
15965
15966 for (int file_pos = 0; file_pos < induction_dictionaries_cnt; file_pos++)
15967 {
15968 struct stat induct_stat;
15969
15970 if (stat (induction_dictionaries[file_pos], &induct_stat) == 0)
15971 {
15972 unlink (induction_dictionaries[file_pos]);
15973 }
15974 }
15975
15976 // wait for non-interactive threads
15977
15978 for (uint thread_idx = 0; thread_idx < ni_threads_cnt; thread_idx++)
15979 {
15980 hc_thread_wait (1, &ni_threads[thread_idx]);
15981 }
15982
15983 local_free (ni_threads);
15984
15985 // wait for interactive threads
15986
15987 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
15988 {
15989 hc_thread_wait (1, &i_thread);
15990 }
15991
15992 // we dont need restore file anymore
15993 if (data.restore_disable == 0)
15994 {
15995 if ((data.devices_status == STATUS_EXHAUSTED) || (data.devices_status == STATUS_CRACKED))
15996 {
15997 unlink (eff_restore_file);
15998 unlink (new_restore_file);
15999 }
16000 else
16001 {
16002 cycle_restore ();
16003 }
16004 }
16005
16006 // finally save left hashes
16007
16008 if ((hashlist_mode == HL_MODE_FILE) && (remove == 1) && (data.digests_saved != data.digests_done))
16009 {
16010 save_hash ();
16011 }
16012
16013 /**
16014 * Clean up
16015 */
16016
16017 if (benchmark == 1)
16018 {
16019 status_benchmark ();
16020
16021 log_info ("");
16022 }
16023 else
16024 {
16025 if (quiet == 0) clear_prompt ();
16026
16027 if (quiet == 0) log_info ("");
16028
16029 if (status == 1)
16030 {
16031 status_display ();
16032 }
16033 else
16034 {
16035 if (quiet == 0) status_display ();
16036 }
16037
16038 if (quiet == 0) log_info ("");
16039 }
16040
16041 for (uint device_id = 0; device_id < devices_cnt; device_id++)
16042 {
16043 hc_device_param_t *device_param = &data.devices_param[device_id];
16044
16045 local_free (device_param->result);
16046
16047 local_free (device_param->pw_caches);
16048
16049 local_free (device_param->combs_buf);
16050
16051 local_free (device_param->hooks_buf);
16052
16053 local_free (device_param->device_name);
16054
16055 local_free (device_param->device_version);
16056
16057 local_free (device_param->driver_version);
16058
16059 if (device_param->pws_buf) myfree (device_param->pws_buf);
16060 if (device_param->d_pws_buf) hc_clReleaseMemObject (device_param->d_pws_buf);
16061 if (device_param->d_pws_amp_buf) hc_clReleaseMemObject (device_param->d_pws_amp_buf);
16062 if (device_param->d_rules) hc_clReleaseMemObject (device_param->d_rules);
16063 if (device_param->d_rules_c) hc_clReleaseMemObject (device_param->d_rules_c);
16064 if (device_param->d_combs) hc_clReleaseMemObject (device_param->d_combs);
16065 if (device_param->d_combs_c) hc_clReleaseMemObject (device_param->d_combs_c);
16066 if (device_param->d_bfs) hc_clReleaseMemObject (device_param->d_bfs);
16067 if (device_param->d_bfs_c) hc_clReleaseMemObject (device_param->d_bfs_c);
16068 if (device_param->d_bitmap_s1_a) hc_clReleaseMemObject (device_param->d_bitmap_s1_a);
16069 if (device_param->d_bitmap_s1_b) hc_clReleaseMemObject (device_param->d_bitmap_s1_b);
16070 if (device_param->d_bitmap_s1_c) hc_clReleaseMemObject (device_param->d_bitmap_s1_c);
16071 if (device_param->d_bitmap_s1_d) hc_clReleaseMemObject (device_param->d_bitmap_s1_d);
16072 if (device_param->d_bitmap_s2_a) hc_clReleaseMemObject (device_param->d_bitmap_s2_a);
16073 if (device_param->d_bitmap_s2_b) hc_clReleaseMemObject (device_param->d_bitmap_s2_b);
16074 if (device_param->d_bitmap_s2_c) hc_clReleaseMemObject (device_param->d_bitmap_s2_c);
16075 if (device_param->d_bitmap_s2_d) hc_clReleaseMemObject (device_param->d_bitmap_s2_d);
16076 if (device_param->d_plain_bufs) hc_clReleaseMemObject (device_param->d_plain_bufs);
16077 if (device_param->d_digests_buf) hc_clReleaseMemObject (device_param->d_digests_buf);
16078 if (device_param->d_digests_shown) hc_clReleaseMemObject (device_param->d_digests_shown);
16079 if (device_param->d_salt_bufs) hc_clReleaseMemObject (device_param->d_salt_bufs);
16080 if (device_param->d_esalt_bufs) hc_clReleaseMemObject (device_param->d_esalt_bufs);
16081 if (device_param->d_tmps) hc_clReleaseMemObject (device_param->d_tmps);
16082 if (device_param->d_hooks) hc_clReleaseMemObject (device_param->d_hooks);
16083 if (device_param->d_result) hc_clReleaseMemObject (device_param->d_result);
16084 if (device_param->d_scryptV_buf) hc_clReleaseMemObject (device_param->d_scryptV_buf);
16085 if (device_param->d_root_css_buf) hc_clReleaseMemObject (device_param->d_root_css_buf);
16086 if (device_param->d_markov_css_buf) hc_clReleaseMemObject (device_param->d_markov_css_buf);
16087 if (device_param->d_tm_c) hc_clReleaseMemObject (device_param->d_tm_c);
16088
16089 if (device_param->kernel1) hc_clReleaseKernel (device_param->kernel1);
16090 if (device_param->kernel12) hc_clReleaseKernel (device_param->kernel12);
16091 if (device_param->kernel2) hc_clReleaseKernel (device_param->kernel2);
16092 if (device_param->kernel23) hc_clReleaseKernel (device_param->kernel23);
16093 if (device_param->kernel3) hc_clReleaseKernel (device_param->kernel3);
16094 if (device_param->kernel_mp) hc_clReleaseKernel (device_param->kernel_mp);
16095 if (device_param->kernel_mp_l) hc_clReleaseKernel (device_param->kernel_mp_l);
16096 if (device_param->kernel_mp_r) hc_clReleaseKernel (device_param->kernel_mp_r);
16097 if (device_param->kernel_tb) hc_clReleaseKernel (device_param->kernel_tb);
16098 if (device_param->kernel_tm) hc_clReleaseKernel (device_param->kernel_tm);
16099 if (device_param->kernel_amp) hc_clReleaseKernel (device_param->kernel_amp);
16100
16101 if (device_param->program) hc_clReleaseProgram (device_param->program);
16102 if (device_param->program_mp) hc_clReleaseProgram (device_param->program_mp);
16103 if (device_param->program_amp) hc_clReleaseProgram (device_param->program_amp);
16104 if (device_param->command_queue) hc_clReleaseCommandQueue (device_param->command_queue);
16105 if (device_param->context) hc_clReleaseContext (device_param->context);
16106 }
16107
16108 // reset default fan speed
16109
16110 if (gpu_temp_disable == 0)
16111 {
16112 if (gpu_temp_retain != 0) // VENDOR_ID_AMD is implied here
16113 {
16114 hc_thread_mutex_lock (mux_adl);
16115
16116 for (uint i = 0; i < data.devices_cnt; i++)
16117 {
16118 if (data.hm_device[i].fan_supported == 1)
16119 {
16120 int fanspeed = temp_retain_fanspeed_value[i];
16121
16122 if (fanspeed == -1) continue;
16123
16124 int rc = hm_set_fanspeed_with_device_id_amd (i, fanspeed);
16125
16126 if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", i);
16127 }
16128 }
16129
16130 hc_thread_mutex_unlock (mux_adl);
16131 }
16132 }
16133
16134 // reset power tuning
16135
16136 if (powertune_enable == 1) // VENDOR_ID_AMD is implied here
16137 {
16138 hc_thread_mutex_lock (mux_adl);
16139
16140 for (uint i = 0; i < data.devices_cnt; i++)
16141 {
16142 if (data.hm_device[i].od_version == 6)
16143 {
16144 // check powertune capabilities first, if not available then skip device
16145
16146 int powertune_supported = 0;
16147
16148 if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK)
16149 {
16150 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
16151
16152 return (-1);
16153 }
16154
16155 if (powertune_supported != 0)
16156 {
16157 // powercontrol settings
16158
16159 if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, od_power_control_status[i])) != ADL_OK)
16160 {
16161 log_info ("ERROR: Failed to restore the ADL PowerControl values");
16162
16163 return (-1);
16164 }
16165
16166 // clocks
16167
16168 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
16169
16170 performance_state->iNumberOfPerformanceLevels = 2;
16171
16172 performance_state->aLevels[0].iEngineClock = od_clock_mem_status[i].state.aLevels[0].iEngineClock;
16173 performance_state->aLevels[1].iEngineClock = od_clock_mem_status[i].state.aLevels[1].iEngineClock;
16174 performance_state->aLevels[0].iMemoryClock = od_clock_mem_status[i].state.aLevels[0].iMemoryClock;
16175 performance_state->aLevels[1].iMemoryClock = od_clock_mem_status[i].state.aLevels[1].iMemoryClock;
16176
16177 if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
16178 {
16179 log_info ("ERROR: Failed to restore ADL performance state");
16180
16181 return (-1);
16182 }
16183
16184 local_free (performance_state);
16185 }
16186 }
16187 }
16188
16189 hc_thread_mutex_unlock (mux_adl);
16190 }
16191
16192 if (gpu_temp_disable == 0)
16193 {
16194 if (vendor_id == VENDOR_ID_NV)
16195 {
16196 #ifdef LINUX
16197 hc_NVML_nvmlShutdown (data.hm_dll);
16198 #endif
16199
16200 #ifdef WIN
16201 NvAPI_Unload ();
16202 #endif
16203 }
16204
16205 if (vendor_id == VENDOR_ID_AMD)
16206 {
16207 hc_ADL_Main_Control_Destroy (data.hm_dll);
16208
16209 hm_close (data.hm_dll);
16210 }
16211
16212 #ifdef LINUX
16213 if (vendor_id == VENDOR_ID_NV)
16214 {
16215 hm_close (data.hm_dll);
16216 }
16217 #endif
16218 }
16219
16220 // free memory
16221
16222 local_free (masks);
16223
16224 local_free (dictstat_base);
16225
16226 for (uint pot_pos = 0; pot_pos < pot_cnt; pot_pos++)
16227 {
16228 pot_t *pot_ptr = &pot[pot_pos];
16229
16230 hash_t *hash = &pot_ptr->hash;
16231
16232 local_free (hash->digest);
16233
16234 if (isSalted)
16235 {
16236 local_free (hash->salt);
16237 }
16238 }
16239
16240 local_free (pot);
16241
16242 local_free (all_gpu_rules_cnt);
16243 local_free (all_gpu_rules_buf);
16244
16245 local_free (wl_data->buf);
16246 local_free (wl_data);
16247
16248 local_free (bitmap_s1_a);
16249 local_free (bitmap_s1_b);
16250 local_free (bitmap_s1_c);
16251 local_free (bitmap_s1_d);
16252 local_free (bitmap_s2_a);
16253 local_free (bitmap_s2_b);
16254 local_free (bitmap_s2_c);
16255 local_free (bitmap_s2_d);
16256
16257 local_free (temp_retain_fanspeed_value);
16258 local_free (od_clock_mem_status);
16259 local_free (od_power_control_status);
16260
16261 global_free (devices_param);
16262
16263 global_free (gpu_rules_buf);
16264
16265 global_free (root_css_buf);
16266 global_free (markov_css_buf);
16267
16268 global_free (digests_buf);
16269 global_free (digests_shown);
16270 global_free (digests_shown_tmp);
16271
16272 global_free (salts_buf);
16273 global_free (salts_shown);
16274
16275 global_free (esalts_buf);
16276
16277 global_free (words_progress_done);
16278 global_free (words_progress_rejected);
16279 global_free (words_progress_restored);
16280
16281 if (pot_fp) fclose (pot_fp);
16282
16283 if (data.devices_status == STATUS_QUIT) break;
16284 }
16285
16286 // destroy others mutex
16287
16288 hc_thread_mutex_delete (mux_dispatcher);
16289 hc_thread_mutex_delete (mux_counter);
16290 hc_thread_mutex_delete (mux_display);
16291 hc_thread_mutex_delete (mux_adl);
16292
16293 // free memory
16294
16295 local_free (eff_restore_file);
16296 local_free (new_restore_file);
16297
16298 local_free (rd);
16299
16300 // loopback
16301
16302 local_free (loopback_file);
16303
16304 if (loopback == 1) unlink (loopback_file);
16305
16306 // induction directory
16307
16308 if (induction_dir == NULL)
16309 {
16310 if (attack_mode != ATTACK_MODE_BF)
16311 {
16312 if (rmdir (induction_directory) == -1)
16313 {
16314 if (errno == ENOENT)
16315 {
16316 // good, we can ignore
16317 }
16318 else if (errno == ENOTEMPTY)
16319 {
16320 // good, we can ignore
16321 }
16322 else
16323 {
16324 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
16325
16326 return (-1);
16327 }
16328 }
16329
16330 local_free (induction_directory);
16331 }
16332 }
16333
16334 // outfile-check directory
16335
16336 if (outfile_check_dir == NULL)
16337 {
16338 if (rmdir (outfile_check_directory) == -1)
16339 {
16340 if (errno == ENOENT)
16341 {
16342 // good, we can ignore
16343 }
16344 else if (errno == ENOTEMPTY)
16345 {
16346 // good, we can ignore
16347 }
16348 else
16349 {
16350 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
16351
16352 return (-1);
16353 }
16354 }
16355
16356 local_free (outfile_check_directory);
16357 }
16358
16359 time_t proc_stop;
16360
16361 time (&proc_stop);
16362
16363 logfile_top_uint (proc_start);
16364 logfile_top_uint (proc_stop);
16365
16366 logfile_top_msg ("STOP");
16367
16368 if (quiet == 0) log_info_nn ("Started: %s", ctime (&proc_start));
16369 if (quiet == 0) log_info_nn ("Stopped: %s", ctime (&proc_stop));
16370
16371 if (data.devices_status == STATUS_ABORTED) return 2;
16372 if (data.devices_status == STATUS_QUIT) return 2;
16373 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) return 2;
16374 if (data.devices_status == STATUS_EXHAUSTED) return 1;
16375 if (data.devices_status == STATUS_CRACKED) return 0;
16376
16377 return -1;
16378 }