ec1dd2df1d002d68fd258fb172b76d16f54137be
[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 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 *shared_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", shared_dir, (int) kern_type);
1603 else if (attack_kern == ATTACK_KERN_COMBI)
1604 snprintf (source_file, 255, "%s/OpenCL/m%05d_a1.cl", shared_dir, (int) kern_type);
1605 else if (attack_kern == ATTACK_KERN_BF)
1606 snprintf (source_file, 255, "%s/OpenCL/m%05d_a3.cl", shared_dir, (int) kern_type);
1607 }
1608 else
1609 snprintf (source_file, 255, "%s/OpenCL/m%05d.cl", shared_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 *profile_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", profile_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", profile_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", profile_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", profile_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 *shared_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", shared_dir);
1634 }
1635 else
1636 {
1637 snprintf (source_file, 255, "%s/OpenCL/markov_le.cl", shared_dir);
1638 }
1639 }
1640
1641 static void generate_cached_kernel_mp_filename (const uint opti_type, const uint opts_type, char *profile_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", profile_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", profile_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 *shared_dir, char *source_file)
1654 {
1655 snprintf (source_file, 255, "%s/OpenCL/amp_a%d.cl", shared_dir, attack_kern);
1656 }
1657
1658 static void generate_cached_kernel_amp_filename (const uint attack_kern, char *profile_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", profile_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 needs to be set, always!
5309 */
5310
5311 if (session == NULL) session = (char *) PROGNAME;
5312
5313 /**
5314 * folders, as discussed on https://github.com/hashcat/oclHashcat/issues/20
5315 */
5316
5317 char *exec_path = get_exec_path ();
5318
5319 #ifdef LINUX
5320
5321 char *resolved_install_folder = realpath (INSTALL_FOLDER, NULL);
5322 char *resolved_exec_path = realpath (exec_path, NULL);
5323
5324 char *install_dir = get_install_dir (resolved_exec_path);
5325 char *profile_dir = NULL;
5326 char *session_dir = NULL;
5327 char *shared_dir = NULL;
5328
5329 if (strcmp (install_dir, resolved_install_folder) == 0)
5330 {
5331 struct passwd *pw = getpwuid (getuid ());
5332
5333 const char *homedir = pw->pw_dir;
5334
5335 profile_dir = get_profile_dir (homedir);
5336 session_dir = get_session_dir (profile_dir, session);
5337 shared_dir = strdup (SHARED_FOLDER);
5338
5339 mkdir (profile_dir, 0700);
5340 mkdir (session_dir, 0700);
5341 }
5342 else
5343 {
5344 profile_dir = install_dir;
5345 session_dir = install_dir;
5346 shared_dir = install_dir;
5347 }
5348
5349 myfree (resolved_install_folder);
5350 myfree (resolved_exec_path);
5351
5352 #else
5353
5354 char *install_dir = get_install_dir (exec_path);
5355 char *profile_dir = install_dir;
5356 char *session_dir = install_dir;
5357 char *shared_dir = shared_dir;
5358
5359 #endif
5360
5361 data.install_dir = install_dir;
5362 data.profile_dir = profile_dir;
5363 data.session_dir = session_dir;
5364 data.shared_dir = shared_dir;
5365
5366 myfree (exec_path);
5367
5368 /**
5369 * session
5370 */
5371
5372 size_t session_size = strlen (session_dir) + 1 + strlen (session) + 32;
5373
5374 data.session = session;
5375
5376 char *eff_restore_file = (char *) mymalloc (session_size);
5377 char *new_restore_file = (char *) mymalloc (session_size);
5378
5379 snprintf (eff_restore_file, session_size - 1, "%s/%s.restore", data.session_dir, session);
5380 snprintf (new_restore_file, session_size - 1, "%s/%s.restore.new", data.session_dir, session);
5381
5382 data.eff_restore_file = eff_restore_file;
5383 data.new_restore_file = new_restore_file;
5384
5385 if (((show == 1) || (left == 1)) && (restore == 1))
5386 {
5387 if (show == 1) log_error ("ERROR: Mixing --restore parameter and --show is not supported");
5388 else log_error ("ERROR: Mixing --restore parameter and --left is not supported");
5389
5390 return (-1);
5391 }
5392
5393 // this allows the user to use --show and --left while cracking (i.e. while another instance of oclHashcat is running)
5394 if ((show == 1) || (left == 1))
5395 {
5396 restore_disable = 1;
5397
5398 restore = 0;
5399 }
5400
5401 data.restore_disable = restore_disable;
5402
5403 restore_data_t *rd = init_restore (argc, argv);
5404
5405 data.rd = rd;
5406
5407 /**
5408 * restore file
5409 */
5410
5411 if (restore == 1)
5412 {
5413 read_restore (eff_restore_file, rd);
5414
5415 if (rd->version_bin < RESTORE_MIN)
5416 {
5417 log_error ("ERROR: Incompatible restore-file version");
5418
5419 return (-1);
5420 }
5421
5422 myargc = rd->argc;
5423 myargv = rd->argv;
5424
5425 #ifdef _POSIX
5426 rd->pid = getpid ();
5427 #elif _WIN
5428 rd->pid = GetCurrentProcessId ();
5429 #endif
5430 }
5431
5432 uint hash_mode_chgd = 0;
5433 uint runtime_chgd = 0;
5434 uint gpu_loops_chgd = 0;
5435 uint gpu_accel_chgd = 0;
5436 uint attack_mode_chgd = 0;
5437 uint outfile_format_chgd = 0;
5438 uint rp_gen_seed_chgd = 0;
5439 uint remove_timer_chgd = 0;
5440 uint increment_min_chgd = 0;
5441 uint increment_max_chgd = 0;
5442 uint gpu_temp_abort_chgd = 0;
5443 uint gpu_temp_retain_chgd = 0;
5444
5445 optind = 1;
5446 optopt = 0;
5447 option_index = 0;
5448
5449 while (((c = getopt_long (myargc, myargv, short_options, long_options, &option_index)) != -1) && optopt == 0)
5450 {
5451 switch (c)
5452 {
5453 //case IDX_HELP: usage = 1; break;
5454 //case IDX_VERSION: version = 1; break;
5455 //case IDX_RESTORE: restore = 1; break;
5456 case IDX_QUIET: quiet = 1; break;
5457 //case IDX_SHOW: show = 1; break;
5458 case IDX_SHOW: break;
5459 //case IDX_LEFT: left = 1; break;
5460 case IDX_LEFT: break;
5461 case IDX_USERNAME: username = 1; break;
5462 case IDX_REMOVE: remove = 1; break;
5463 case IDX_REMOVE_TIMER: remove_timer = atoi (optarg);
5464 remove_timer_chgd = 1; break;
5465 case IDX_POTFILE_DISABLE: potfile_disable = 1; break;
5466 case IDX_DEBUG_MODE: debug_mode = atoi (optarg); break;
5467 case IDX_DEBUG_FILE: debug_file = optarg; break;
5468 case IDX_INDUCTION_DIR: induction_dir = optarg; break;
5469 case IDX_OUTFILE_CHECK_DIR: outfile_check_dir = optarg; break;
5470 case IDX_FORCE: force = 1; break;
5471 case IDX_SKIP: skip = atoll (optarg); break;
5472 case IDX_LIMIT: limit = atoll (optarg); break;
5473 case IDX_KEYSPACE: keyspace = 1; break;
5474 case IDX_BENCHMARK: benchmark = 1; break;
5475 case IDX_BENCHMARK_MODE: benchmark_mode = atoi (optarg); break;
5476 case IDX_RESTORE: break;
5477 case IDX_RESTORE_DISABLE: restore_disable = 1; break;
5478 case IDX_STATUS: status = 1; break;
5479 case IDX_STATUS_TIMER: status_timer = atoi (optarg); break;
5480 case IDX_STATUS_AUTOMAT: status_automat = 1; break;
5481 case IDX_LOOPBACK: loopback = 1; break;
5482 case IDX_WEAK_HASH_THRESHOLD:
5483 weak_hash_threshold = atoi (optarg); break;
5484 //case IDX_SESSION: session = optarg; break;
5485 case IDX_SESSION: break;
5486 case IDX_HASH_MODE: hash_mode = atoi (optarg);
5487 hash_mode_chgd = 1; break;
5488 case IDX_RUNTIME: runtime = atoi (optarg);
5489 runtime_chgd = 1; break;
5490 case IDX_ATTACK_MODE: attack_mode = atoi (optarg);
5491 attack_mode_chgd = 1; break;
5492 case IDX_RP_FILE: rp_files[rp_files_cnt++] = optarg; break;
5493 case IDX_RP_GEN: rp_gen = atoi (optarg); break;
5494 case IDX_RP_GEN_FUNC_MIN: rp_gen_func_min = atoi (optarg); break;
5495 case IDX_RP_GEN_FUNC_MAX: rp_gen_func_max = atoi (optarg); break;
5496 case IDX_RP_GEN_SEED: rp_gen_seed = atoi (optarg);
5497 rp_gen_seed_chgd = 1; break;
5498 case IDX_RULE_BUF_L: rule_buf_l = optarg; break;
5499 case IDX_RULE_BUF_R: rule_buf_r = optarg; break;
5500 case IDX_MARKOV_DISABLE: markov_disable = 1; break;
5501 case IDX_MARKOV_CLASSIC: markov_classic = 1; break;
5502 case IDX_MARKOV_THRESHOLD: markov_threshold = atoi (optarg); break;
5503 case IDX_MARKOV_HCSTAT: markov_hcstat = optarg; break;
5504 case IDX_OUTFILE: outfile = optarg; break;
5505 case IDX_OUTFILE_FORMAT: outfile_format = atoi (optarg);
5506 outfile_format_chgd = 1; break;
5507 case IDX_OUTFILE_AUTOHEX_DISABLE:
5508 outfile_autohex = 0; break;
5509 case IDX_OUTFILE_CHECK_TIMER:
5510 outfile_check_timer = atoi (optarg); break;
5511 case IDX_HEX_CHARSET: hex_charset = 1; break;
5512 case IDX_HEX_SALT: hex_salt = 1; break;
5513 case IDX_HEX_WORDLIST: hex_wordlist = 1; break;
5514 case IDX_CPU_AFFINITY: cpu_affinity = optarg; break;
5515 case IDX_GPU_DEVICES: gpu_devices = optarg; break;
5516 case IDX_GPU_PLATFORM: gpu_platform = optarg; break;
5517 case IDX_WORKLOAD_PROFILE: workload_profile = atoi (optarg); break;
5518 case IDX_GPU_ACCEL: gpu_accel = atoi (optarg);
5519 gpu_accel_chgd = 1; break;
5520 case IDX_GPU_LOOPS: gpu_loops = atoi (optarg);
5521 gpu_loops_chgd = 1; break;
5522 case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break;
5523 case IDX_GPU_TEMP_ABORT: gpu_temp_abort_chgd = 1;
5524 gpu_temp_abort = atoi (optarg); break;
5525 case IDX_GPU_TEMP_RETAIN: gpu_temp_retain_chgd = 1;
5526 gpu_temp_retain = atoi (optarg); break;
5527 case IDX_POWERTUNE_ENABLE: powertune_enable = 1; break;
5528 case IDX_LOGFILE_DISABLE: logfile_disable = 1; break;
5529 case IDX_TRUECRYPT_KEYFILES: truecrypt_keyfiles = optarg; break;
5530 case IDX_SEGMENT_SIZE: segment_size = atoi (optarg); break;
5531 case IDX_SCRYPT_TMTO: scrypt_tmto = atoi (optarg); break;
5532 case IDX_SEPARATOR: separator = optarg[0]; break;
5533 case IDX_BITMAP_MIN: bitmap_min = atoi (optarg); break;
5534 case IDX_BITMAP_MAX: bitmap_max = atoi (optarg); break;
5535 case IDX_INCREMENT: increment = 1; break;
5536 case IDX_INCREMENT_MIN: increment_min = atoi (optarg);
5537 increment_min_chgd = 1; break;
5538 case IDX_INCREMENT_MAX: increment_max = atoi (optarg);
5539 increment_max_chgd = 1; break;
5540 case IDX_CUSTOM_CHARSET_1: custom_charset_1 = optarg; break;
5541 case IDX_CUSTOM_CHARSET_2: custom_charset_2 = optarg; break;
5542 case IDX_CUSTOM_CHARSET_3: custom_charset_3 = optarg; break;
5543 case IDX_CUSTOM_CHARSET_4: custom_charset_4 = optarg; break;
5544
5545 default:
5546 log_error ("ERROR: Invalid argument specified");
5547 return (-1);
5548 }
5549 }
5550
5551 if (optopt != 0)
5552 {
5553 log_error ("ERROR: Invalid argument specified");
5554
5555 return (-1);
5556 }
5557
5558 /**
5559 * Inform user things getting started,
5560 * - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
5561 * - we do not need to check algorithm_pos
5562 */
5563
5564 if (quiet == 0)
5565 {
5566 if (benchmark == 1)
5567 {
5568 log_info ("%s v%.2f starting in benchmark-mode...", PROGNAME, (float) VERSION_BIN / 100);
5569
5570 log_info ("");
5571 }
5572 else if (restore == 1)
5573 {
5574 log_info ("%s v%.2f starting in restore-mode...", PROGNAME, (float) VERSION_BIN / 100);
5575
5576 log_info ("");
5577 }
5578 else
5579 {
5580 log_info ("%s v%.2f starting...", PROGNAME, (float) VERSION_BIN / 100);
5581
5582 log_info ("");
5583 }
5584 }
5585
5586 /**
5587 * sanity check
5588 */
5589
5590 if (attack_mode > 7)
5591 {
5592 log_error ("ERROR: Invalid attack-mode specified");
5593
5594 return (-1);
5595 }
5596
5597 if (runtime_chgd && runtime == 0) // just added to remove compiler warnings for runtime_chgd
5598 {
5599 log_error ("ERROR: Invalid runtime specified");
5600
5601 return (-1);
5602 }
5603
5604 if (hash_mode_chgd && hash_mode > 12800) // just added to remove compiler warnings for hash_mode_chgd
5605 {
5606 log_error ("ERROR: Invalid hash-type specified");
5607
5608 return (-1);
5609 }
5610
5611 // renamed hash modes
5612
5613 if (hash_mode_chgd)
5614 {
5615 int n = -1;
5616
5617 switch (hash_mode)
5618 {
5619 case 123: n = 124;
5620 break;
5621 }
5622
5623 if (n >= 0)
5624 {
5625 log_error ("Old -m specified, use -m %d instead", n);
5626
5627 return (-1);
5628 }
5629 }
5630
5631 if (username == 1)
5632 {
5633 if ((hash_mode == 2500) || (hash_mode == 5200) || ((hash_mode >= 6200) && (hash_mode <= 6299)))
5634 {
5635 log_error ("ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (hash_mode));
5636
5637 return (-1);
5638 }
5639 }
5640
5641 if (outfile_format > 16)
5642 {
5643 log_error ("ERROR: Invalid outfile-format specified");
5644
5645 return (-1);
5646 }
5647
5648 if (left == 1)
5649 {
5650 if (outfile_format_chgd == 1)
5651 {
5652 if (outfile_format > 1)
5653 {
5654 log_error ("ERROR: Mixing outfile-format > 1 is not allowed together with left parameter");
5655
5656 return (-1);
5657 }
5658 }
5659 else
5660 {
5661 outfile_format = OUTFILE_FMT_HASH;
5662 }
5663 }
5664
5665 if (show == 1)
5666 {
5667 if (outfile_format_chgd == 1)
5668 {
5669 if ((outfile_format > 7) && (outfile_format < 16))
5670 {
5671 log_error ("ERROR: Mixing outfile-format > 7 is not allowed together with show parameter");
5672
5673 return (-1);
5674 }
5675 }
5676 }
5677
5678 if (increment_min < INCREMENT_MIN)
5679 {
5680 log_error ("ERROR: Invalid increment-min specified");
5681
5682 return (-1);
5683 }
5684
5685 if (increment_max > INCREMENT_MAX)
5686 {
5687 log_error ("ERROR: Invalid increment-max specified");
5688
5689 return (-1);
5690 }
5691
5692 if (increment_min > increment_max)
5693 {
5694 log_error ("ERROR: Invalid increment-min specified");
5695
5696 return (-1);
5697 }
5698
5699 if ((increment == 1) && (attack_mode == ATTACK_MODE_STRAIGHT))
5700 {
5701 log_error ("ERROR: increment is not allowed in attack-mode 0");
5702
5703 return (-1);
5704 }
5705
5706 if ((increment == 0) && (increment_min_chgd == 1))
5707 {
5708 log_error ("ERROR: increment-min is only supported together with increment switch");
5709
5710 return (-1);
5711 }
5712
5713 if ((increment == 0) && (increment_max_chgd == 1))
5714 {
5715 log_error ("ERROR: increment-max is only supported together with increment switch");
5716
5717 return (-1);
5718 }
5719
5720 if (rp_files_cnt && rp_gen)
5721 {
5722 log_error ("ERROR: Use of both rules-file and rules-generate is not supported");
5723
5724 return (-1);
5725 }
5726
5727 if (rp_files_cnt || rp_gen)
5728 {
5729 if (attack_mode != ATTACK_MODE_STRAIGHT)
5730 {
5731 log_error ("ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0");
5732
5733 return (-1);
5734 }
5735 }
5736
5737 if (rp_gen_func_min > rp_gen_func_max)
5738 {
5739 log_error ("ERROR: Invalid rp-gen-func-min specified");
5740
5741 return (-1);
5742 }
5743
5744 if (gpu_accel_chgd == 1)
5745 {
5746 if (workload_profile != WORKLOAD_PROFILE)
5747 {
5748 log_error ("ERROR: gpu-accel parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
5749
5750 return (-1);
5751 }
5752
5753 if (gpu_accel < 1)
5754 {
5755 log_error ("ERROR: Invalid gpu-accel specified");
5756
5757 return (-1);
5758 }
5759
5760 if (gpu_accel > 800)
5761 {
5762 log_error ("ERROR: Invalid gpu-accel specified");
5763
5764 return (-1);
5765 }
5766 }
5767
5768 if (gpu_loops_chgd == 1)
5769 {
5770 if (workload_profile != WORKLOAD_PROFILE)
5771 {
5772 log_error ("ERROR: gpu-loops parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
5773
5774 return (-1);
5775 }
5776
5777 if (gpu_loops < 1)
5778 {
5779 log_error ("ERROR: Invalid gpu-loops specified");
5780
5781 return (-1);
5782 }
5783
5784 if (gpu_loops > 1024)
5785 {
5786 log_error ("ERROR: Invalid gpu-loops specified");
5787
5788 return (-1);
5789 }
5790 }
5791
5792 if (benchmark == 1)
5793 {
5794 if (workload_profile != WORKLOAD_PROFILE)
5795 {
5796 log_error ("ERROR: Using the workload-profile in benchmark mode is not allowed");
5797
5798 return (-1);
5799 }
5800 }
5801
5802 if ((workload_profile < 1) || (workload_profile > 3))
5803 {
5804 log_error ("ERROR: workload-profile %i not available", workload_profile);
5805
5806 return (-1);
5807 }
5808
5809 if (show == 1 || left == 1)
5810 {
5811 attack_mode = ATTACK_MODE_NONE;
5812
5813 if (remove == 1)
5814 {
5815 log_error ("ERROR: Mixing remove parameter not allowed with show parameter or left parameter");
5816
5817 return (-1);
5818 }
5819
5820 if (potfile_disable == 1)
5821 {
5822 log_error ("ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter");
5823
5824 return (-1);
5825 }
5826 }
5827
5828 uint attack_kern = ATTACK_KERN_NONE;
5829
5830 switch (attack_mode)
5831 {
5832 case ATTACK_MODE_STRAIGHT: attack_kern = ATTACK_KERN_STRAIGHT; break;
5833 case ATTACK_MODE_COMBI: attack_kern = ATTACK_KERN_COMBI; break;
5834 case ATTACK_MODE_BF: attack_kern = ATTACK_KERN_BF; break;
5835 case ATTACK_MODE_HYBRID1: attack_kern = ATTACK_KERN_COMBI; break;
5836 case ATTACK_MODE_HYBRID2: attack_kern = ATTACK_KERN_COMBI; break;
5837 }
5838
5839 if (benchmark == 0)
5840 {
5841 if (keyspace == 1)
5842 {
5843 int num_additional_params = 1;
5844
5845 if (attack_kern == ATTACK_KERN_COMBI)
5846 {
5847 num_additional_params = 2;
5848 }
5849
5850 int keyspace_wordlist_specified = myargc - optind - num_additional_params;
5851
5852 if (keyspace_wordlist_specified == 0) optind--;
5853 }
5854
5855 if (attack_kern == ATTACK_KERN_NONE)
5856 {
5857 if ((optind + 1) != myargc)
5858 {
5859 usage_mini_print (myargv[0]);
5860
5861 return (-1);
5862 }
5863 }
5864 else if (attack_kern == ATTACK_KERN_STRAIGHT)
5865 {
5866 if ((optind + 1) > myargc)
5867 {
5868 usage_mini_print (myargv[0]);
5869
5870 return (-1);
5871 }
5872 }
5873 else if (attack_kern == ATTACK_KERN_COMBI)
5874 {
5875 if ((optind + 3) != myargc)
5876 {
5877 usage_mini_print (myargv[0]);
5878
5879 return (-1);
5880 }
5881 }
5882 else if (attack_kern == ATTACK_KERN_BF)
5883 {
5884 if ((optind + 1) > myargc)
5885 {
5886 usage_mini_print (myargv[0]);
5887
5888 return (-1);
5889 }
5890 }
5891 else
5892 {
5893 usage_mini_print (myargv[0]);
5894
5895 return (-1);
5896 }
5897 }
5898 else
5899 {
5900 if (myargv[optind] != 0)
5901 {
5902 log_error ("ERROR: Invalid argument for benchmark mode specified");
5903
5904 return (-1);
5905 }
5906
5907 if (attack_mode_chgd == 1)
5908 {
5909 if (attack_mode != ATTACK_MODE_BF)
5910 {
5911 log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode");
5912
5913 return (-1);
5914 }
5915 }
5916
5917 if (benchmark_mode == 0)
5918 {
5919 // nothing to do
5920 }
5921 else if (benchmark_mode == 1)
5922 {
5923 if (gpu_accel_chgd == 1 || gpu_loops_chgd == 1)
5924 {
5925 log_error ("ERROR: Benchmark-mode 1 does not allow gpu-accel or gpu-loops changed");
5926
5927 return (-1);
5928 }
5929 }
5930 else
5931 {
5932 log_error ("ERROR: Benchmark-mode must be 0 or 1");
5933
5934 return (-1);
5935 }
5936 }
5937
5938 if (skip != 0 && limit != 0)
5939 {
5940 limit += skip;
5941 }
5942
5943 if (keyspace == 1)
5944 {
5945 if (show == 1)
5946 {
5947 log_error ("ERROR: Mixing show parameter not supported with keyspace parameter");
5948
5949 return (-1);
5950 }
5951 else if (left == 1)
5952 {
5953 log_error ("ERROR: Mixing left parameter not supported wiht keyspace parameter");
5954
5955 return (-1);
5956 }
5957
5958 potfile_disable = 1;
5959
5960 restore_disable = 1;
5961
5962 restore = 0;
5963
5964 weak_hash_threshold = 0;
5965
5966 quiet = 1;
5967 }
5968
5969 if (remove_timer_chgd == 1)
5970 {
5971 if (remove == 0)
5972 {
5973 log_error ("ERROR: Parameter remove-timer require parameter remove enabled");
5974
5975 return (-1);
5976 }
5977
5978 if (remove_timer < 1)
5979 {
5980 log_error ("ERROR: Parameter remove-timer must have a value greater than or equal to 1");
5981
5982 return (-1);
5983 }
5984 }
5985
5986 if (loopback == 1)
5987 {
5988 if (attack_mode == ATTACK_MODE_BF)
5989 {
5990 log_error ("ERROR: Parameter loopback not allowed in attack-mode 3");
5991
5992 return (-1);
5993 }
5994 else if (attack_mode == ATTACK_MODE_STRAIGHT)
5995 {
5996 if ((rp_files_cnt == 0) && (rp_gen == 0))
5997 {
5998 log_error ("ERROR: Parameter loopback not allowed without rules-file or rules-generate");
5999
6000 return (-1);
6001 }
6002 }
6003 }
6004
6005 if (debug_mode > 0)
6006 {
6007 if (attack_mode != ATTACK_MODE_STRAIGHT)
6008 {
6009 log_error ("ERROR: Parameter debug-mode option is only available with attack-mode 0");
6010
6011 return (-1);
6012 }
6013
6014 if ((rp_files_cnt == 0) && (rp_gen == 0))
6015 {
6016 log_error ("ERROR: Parameter debug-mode not allowed without rules-file or rules-generate");
6017
6018 return (-1);
6019 }
6020 }
6021
6022 if (debug_mode > 4)
6023 {
6024 log_error ("ERROR: Invalid debug-mode specified");
6025
6026 return (-1);
6027 }
6028
6029 if (debug_file != NULL)
6030 {
6031 if (debug_mode < 1)
6032 {
6033 log_error ("ERROR: Parameter debug-file requires parameter debug-mode to be set");
6034
6035 return (-1);
6036 }
6037 }
6038
6039 if (induction_dir != NULL)
6040 {
6041 if (attack_mode == ATTACK_MODE_BF)
6042 {
6043 log_error ("ERROR: Parameter induction-dir not allowed with brute-force attacks");
6044
6045 return (-1);
6046 }
6047 }
6048
6049 /**
6050 * induction directory
6051 */
6052
6053 char *induction_directory = NULL;
6054
6055 if (attack_mode != ATTACK_MODE_BF)
6056 {
6057 if (induction_dir == NULL)
6058 {
6059 induction_directory = (char *) mymalloc (session_size);
6060
6061 snprintf (induction_directory, session_size - 1, "%s/%s.%s", session_dir, session, INDUCT_DIR);
6062
6063 // create induction folder if it does not already exist
6064
6065 if (keyspace == 0)
6066 {
6067 if (rmdir (induction_directory) == -1)
6068 {
6069 if (errno == ENOENT)
6070 {
6071 // good, we can ignore
6072 }
6073 else if (errno == ENOTEMPTY)
6074 {
6075 char *induction_directory_mv = (char *) mymalloc (session_size);
6076
6077 snprintf (induction_directory_mv, session_size - 1, "%s/%s.induct.%d", session_dir, session, (int) proc_start);
6078
6079 if (rename (induction_directory, induction_directory_mv) != 0)
6080 {
6081 log_error ("ERROR: Rename directory %s to %s: %s", induction_directory, induction_directory_mv, strerror (errno));
6082
6083 return (-1);
6084 }
6085 }
6086 else
6087 {
6088 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6089
6090 return (-1);
6091 }
6092 }
6093
6094 if (mkdir (induction_directory, 0700) == -1)
6095 {
6096 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6097
6098 return (-1);
6099 }
6100 }
6101 }
6102 else
6103 {
6104 induction_directory = induction_dir;
6105 }
6106 }
6107
6108 data.induction_directory = induction_directory;
6109
6110 /**
6111 * loopback
6112 */
6113
6114 size_t loopback_size = strlen (session_dir) + 1 + session_size + strlen (LOOPBACK_FILE) + 12;
6115
6116 char *loopback_file = (char *) mymalloc (loopback_size);
6117
6118 /**
6119 * outfile-check directory
6120 */
6121
6122 char *outfile_check_directory = NULL;
6123
6124 if (outfile_check_dir == NULL)
6125 {
6126 outfile_check_directory = (char *) mymalloc (session_size);
6127
6128 snprintf (outfile_check_directory, session_size - 1, "%s/%s.%s", session_dir, session, OUTFILES_DIR);
6129 }
6130 else
6131 {
6132 outfile_check_directory = outfile_check_dir;
6133 }
6134
6135 data.outfile_check_directory = outfile_check_directory;
6136
6137 if (keyspace == 0)
6138 {
6139 struct stat outfile_check_stat;
6140
6141 if (stat (outfile_check_directory, &outfile_check_stat) == 0)
6142 {
6143 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
6144
6145 if (is_dir == 0)
6146 {
6147 log_error ("ERROR: Directory specified in outfile-check '%s' is not a valid directory", outfile_check_directory);
6148
6149 return (-1);
6150 }
6151 }
6152 else if (outfile_check_dir == NULL)
6153 {
6154 if (mkdir (outfile_check_directory, 0700) == -1)
6155 {
6156 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
6157
6158 return (-1);
6159 }
6160 }
6161 }
6162
6163 /**
6164 * special other stuff
6165 */
6166
6167 if (hash_mode == 9710)
6168 {
6169 outfile_format = 5;
6170 outfile_format_chgd = 1;
6171 }
6172
6173 if (hash_mode == 9810)
6174 {
6175 outfile_format = 5;
6176 outfile_format_chgd = 1;
6177 }
6178
6179 if (hash_mode == 10410)
6180 {
6181 outfile_format = 5;
6182 outfile_format_chgd = 1;
6183 }
6184
6185 /**
6186 * store stuff
6187 */
6188
6189 data.hash_mode = hash_mode;
6190 data.restore = restore;
6191 data.restore_timer = restore_timer;
6192 data.restore_disable = restore_disable;
6193 data.status = status;
6194 data.status_timer = status_timer;
6195 data.status_automat = status_automat;
6196 data.loopback = loopback;
6197 data.runtime = runtime;
6198 data.remove = remove;
6199 data.remove_timer = remove_timer;
6200 data.debug_mode = debug_mode;
6201 data.debug_file = debug_file;
6202 data.username = username;
6203 data.quiet = quiet;
6204 data.outfile = outfile;
6205 data.outfile_format = outfile_format;
6206 data.outfile_autohex = outfile_autohex;
6207 data.hex_charset = hex_charset;
6208 data.hex_salt = hex_salt;
6209 data.hex_wordlist = hex_wordlist;
6210 data.separator = separator;
6211 data.rp_files = rp_files;
6212 data.rp_files_cnt = rp_files_cnt;
6213 data.rp_gen = rp_gen;
6214 data.rp_gen_seed = rp_gen_seed;
6215 data.force = force;
6216 data.benchmark = benchmark;
6217 data.skip = skip;
6218 data.limit = limit;
6219 data.powertune_enable = powertune_enable;
6220 data.logfile_disable = logfile_disable;
6221 data.truecrypt_keyfiles = truecrypt_keyfiles;
6222 data.scrypt_tmto = scrypt_tmto;
6223
6224 /**
6225 * cpu affinity
6226 */
6227
6228 if (cpu_affinity)
6229 {
6230 set_cpu_affinity (cpu_affinity);
6231 }
6232
6233 if (rp_gen_seed_chgd == 0)
6234 {
6235 srand (proc_start);
6236 }
6237 else
6238 {
6239 srand (rp_gen_seed);
6240 }
6241
6242 /**
6243 * logfile init
6244 */
6245
6246 if (logfile_disable == 0)
6247 {
6248 size_t logfile_size = strlen (session) + 32;
6249
6250 char *logfile = (char *) mymalloc (logfile_size);
6251
6252 snprintf (logfile, logfile_size - 1, "%s/%s.log", session_dir, session);
6253
6254 data.logfile = logfile;
6255
6256 char *topid = logfile_generate_topid ();
6257
6258 data.topid = topid;
6259 }
6260
6261 // logfile_append() checks for logfile_disable internally to make it easier from here
6262
6263 #define logfile_top_msg(msg) logfile_append ("%s\t%s", data.topid, (msg));
6264 #define logfile_sub_msg(msg) logfile_append ("%s\t%s\t%s", data.topid, data.subid, (msg));
6265 #define logfile_top_var_uint64(var,val) logfile_append ("%s\t%s\t%llu", data.topid, (var), (val));
6266 #define logfile_sub_var_uint64(var,val) logfile_append ("%s\t%s\t%s\t%llu", data.topid, data.subid, (var), (val));
6267 #define logfile_top_var_uint(var,val) logfile_append ("%s\t%s\t%u", data.topid, (var), (val));
6268 #define logfile_sub_var_uint(var,val) logfile_append ("%s\t%s\t%s\t%u", data.topid, data.subid, (var), (val));
6269 #define logfile_top_var_char(var,val) logfile_append ("%s\t%s\t%c", data.topid, (var), (val));
6270 #define logfile_sub_var_char(var,val) logfile_append ("%s\t%s\t%s\t%c", data.topid, data.subid, (var), (val));
6271 #define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append ("%s\t%s\t%s", data.topid, (var), (val));
6272 #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));
6273
6274 #define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var));
6275 #define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
6276 #define logfile_top_uint(var) logfile_top_var_uint (#var, (var));
6277 #define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var));
6278 #define logfile_top_char(var) logfile_top_var_char (#var, (var));
6279 #define logfile_sub_char(var) logfile_sub_var_char (#var, (var));
6280 #define logfile_top_string(var) logfile_top_var_string (#var, (var));
6281 #define logfile_sub_string(var) logfile_sub_var_string (#var, (var));
6282
6283 logfile_top_msg ("START");
6284
6285 logfile_top_uint (attack_mode);
6286 logfile_top_uint (attack_kern);
6287 logfile_top_uint (benchmark);
6288 logfile_top_uint (benchmark_mode);
6289 logfile_top_uint (bitmap_min);
6290 logfile_top_uint (bitmap_max);
6291 logfile_top_uint (debug_mode);
6292 logfile_top_uint (force);
6293 logfile_top_uint (gpu_accel);
6294 logfile_top_uint (gpu_loops);
6295 logfile_top_uint (gpu_temp_abort);
6296 logfile_top_uint (gpu_temp_disable);
6297 logfile_top_uint (gpu_temp_retain);
6298 logfile_top_uint (hash_mode);
6299 logfile_top_uint (hex_charset);
6300 logfile_top_uint (hex_salt);
6301 logfile_top_uint (hex_wordlist);
6302 logfile_top_uint (increment);
6303 logfile_top_uint (increment_max);
6304 logfile_top_uint (increment_min);
6305 logfile_top_uint (keyspace);
6306 logfile_top_uint (left);
6307 logfile_top_uint (logfile_disable);
6308 logfile_top_uint (loopback);
6309 logfile_top_uint (markov_classic);
6310 logfile_top_uint (markov_disable);
6311 logfile_top_uint (markov_threshold);
6312 logfile_top_uint (outfile_autohex);
6313 logfile_top_uint (outfile_check_timer);
6314 logfile_top_uint (outfile_format);
6315 logfile_top_uint (potfile_disable);
6316 logfile_top_uint (powertune_enable);
6317 logfile_top_uint (scrypt_tmto);
6318 logfile_top_uint (quiet);
6319 logfile_top_uint (remove);
6320 logfile_top_uint (remove_timer);
6321 logfile_top_uint (restore);
6322 logfile_top_uint (restore_disable);
6323 logfile_top_uint (restore_timer);
6324 logfile_top_uint (rp_gen);
6325 logfile_top_uint (rp_gen_func_max);
6326 logfile_top_uint (rp_gen_func_min);
6327 logfile_top_uint (rp_gen_seed);
6328 logfile_top_uint (runtime);
6329 logfile_top_uint (segment_size);
6330 logfile_top_uint (show);
6331 logfile_top_uint (status);
6332 logfile_top_uint (status_automat);
6333 logfile_top_uint (status_timer);
6334 logfile_top_uint (usage);
6335 logfile_top_uint (username);
6336 logfile_top_uint (version);
6337 logfile_top_uint (weak_hash_threshold);
6338 logfile_top_uint (workload_profile);
6339 logfile_top_uint64 (limit);
6340 logfile_top_uint64 (skip);
6341 logfile_top_char (separator);
6342 logfile_top_string (cpu_affinity);
6343 logfile_top_string (custom_charset_1);
6344 logfile_top_string (custom_charset_2);
6345 logfile_top_string (custom_charset_3);
6346 logfile_top_string (custom_charset_4);
6347 logfile_top_string (debug_file);
6348 logfile_top_string (gpu_devices);
6349 logfile_top_string (gpu_platform);
6350 logfile_top_string (induction_dir);
6351 logfile_top_string (markov_hcstat);
6352 logfile_top_string (outfile);
6353 logfile_top_string (outfile_check_dir);
6354 logfile_top_string (rule_buf_l);
6355 logfile_top_string (rule_buf_r);
6356 logfile_top_string (session);
6357 logfile_top_string (truecrypt_keyfiles);
6358
6359 /**
6360 * devices
6361 */
6362
6363 uint gpu_devicemask = devices_to_devicemask (gpu_devices);
6364
6365 /**
6366 * benchmark
6367 */
6368
6369 if (benchmark == 1)
6370 {
6371 /**
6372 * disable useless stuff for benchmark
6373 */
6374
6375 restore_timer = 0;
6376 status_timer = 0;
6377 restore_disable = 1;
6378 potfile_disable = 1;
6379 weak_hash_threshold = 0;
6380
6381 data.restore_timer = restore_timer;
6382 data.status_timer = status_timer;
6383 data.restore_disable = restore_disable;
6384
6385 if (benchmark_mode == 1)
6386 {
6387 markov_disable = 1;
6388 }
6389
6390 /**
6391 * force attack mode to be bruteforce
6392 */
6393
6394 attack_mode = ATTACK_MODE_BF;
6395 attack_kern = ATTACK_KERN_BF;
6396
6397 if (runtime_chgd == 0)
6398 {
6399 runtime = 4;
6400
6401 if (benchmark_mode == 1) runtime = 17;
6402
6403 data.runtime = runtime;
6404 }
6405 }
6406
6407 /**
6408 * config
6409 */
6410
6411 uint hash_type = 0;
6412 uint salt_type = 0;
6413 uint attack_exec = 0;
6414 uint opts_type = 0;
6415 uint kern_type = 0;
6416 uint dgst_size = 0;
6417 uint esalt_size = 0;
6418 uint opti_type = 0;
6419 uint dgst_pos0 = -1;
6420 uint dgst_pos1 = -1;
6421 uint dgst_pos2 = -1;
6422 uint dgst_pos3 = -1;
6423
6424 int (*parse_func) (char *, uint, hash_t *);
6425 int (*sort_by_digest) (const void *, const void *);
6426
6427 uint algorithm_pos = 0;
6428 uint algorithm_max = 1;
6429
6430 uint *algorithms = default_benchmark_algorithms;
6431
6432 if (benchmark == 1 && hash_mode_chgd == 0) algorithm_max = NUM_DEFAULT_BENCHMARK_ALGORITHMS;
6433
6434 for (algorithm_pos = 0; algorithm_pos < algorithm_max; algorithm_pos++)
6435 {
6436 /*
6437 * We need to reset 'rd' in benchmark mode otherwise when the user hits 'bypass'
6438 * the following algos are skipped entirely
6439 */
6440
6441 if (algorithm_pos > 0)
6442 {
6443 local_free (rd);
6444
6445 rd = init_restore (argc, argv);
6446
6447 data.rd = rd;
6448 }
6449
6450 /**
6451 * update hash_mode in case of multihash benchmark
6452 */
6453
6454 if (benchmark == 1)
6455 {
6456 if (hash_mode_chgd == 0)
6457 {
6458 hash_mode = algorithms[algorithm_pos];
6459
6460 data.hash_mode = hash_mode;
6461 }
6462
6463 quiet = 1;
6464
6465 data.quiet = quiet;
6466 }
6467
6468 switch (hash_mode)
6469 {
6470 case 0: hash_type = HASH_TYPE_MD5;
6471 salt_type = SALT_TYPE_NONE;
6472 attack_exec = ATTACK_EXEC_ON_GPU;
6473 opts_type = OPTS_TYPE_PT_GENERATE_LE
6474 | OPTS_TYPE_PT_ADD80
6475 | OPTS_TYPE_PT_ADDBITS14;
6476 kern_type = KERN_TYPE_MD5;
6477 dgst_size = DGST_SIZE_4_4;
6478 parse_func = md5_parse_hash;
6479 sort_by_digest = sort_by_digest_4_4;
6480 opti_type = OPTI_TYPE_ZERO_BYTE
6481 | OPTI_TYPE_PRECOMPUTE_INIT
6482 | OPTI_TYPE_PRECOMPUTE_MERKLE
6483 | OPTI_TYPE_MEET_IN_MIDDLE
6484 | OPTI_TYPE_EARLY_SKIP
6485 | OPTI_TYPE_NOT_ITERATED
6486 | OPTI_TYPE_NOT_SALTED
6487 | OPTI_TYPE_RAW_HASH;
6488 dgst_pos0 = 0;
6489 dgst_pos1 = 3;
6490 dgst_pos2 = 2;
6491 dgst_pos3 = 1;
6492 break;
6493
6494 case 10: hash_type = HASH_TYPE_MD5;
6495 salt_type = SALT_TYPE_INTERN;
6496 attack_exec = ATTACK_EXEC_ON_GPU;
6497 opts_type = OPTS_TYPE_PT_GENERATE_LE
6498 | OPTS_TYPE_ST_ADD80
6499 | OPTS_TYPE_ST_ADDBITS14;
6500 kern_type = KERN_TYPE_MD5_PWSLT;
6501 dgst_size = DGST_SIZE_4_4;
6502 parse_func = md5s_parse_hash;
6503 sort_by_digest = sort_by_digest_4_4;
6504 opti_type = OPTI_TYPE_ZERO_BYTE
6505 | OPTI_TYPE_PRECOMPUTE_INIT
6506 | OPTI_TYPE_PRECOMPUTE_MERKLE
6507 | OPTI_TYPE_MEET_IN_MIDDLE
6508 | OPTI_TYPE_EARLY_SKIP
6509 | OPTI_TYPE_NOT_ITERATED
6510 | OPTI_TYPE_APPENDED_SALT
6511 | OPTI_TYPE_RAW_HASH;
6512 dgst_pos0 = 0;
6513 dgst_pos1 = 3;
6514 dgst_pos2 = 2;
6515 dgst_pos3 = 1;
6516 break;
6517
6518 case 11: hash_type = HASH_TYPE_MD5;
6519 salt_type = SALT_TYPE_INTERN;
6520 attack_exec = ATTACK_EXEC_ON_GPU;
6521 opts_type = OPTS_TYPE_PT_GENERATE_LE
6522 | OPTS_TYPE_ST_ADD80
6523 | OPTS_TYPE_ST_ADDBITS14;
6524 kern_type = KERN_TYPE_MD5_PWSLT;
6525 dgst_size = DGST_SIZE_4_4;
6526 parse_func = joomla_parse_hash;
6527 sort_by_digest = sort_by_digest_4_4;
6528 opti_type = OPTI_TYPE_ZERO_BYTE
6529 | OPTI_TYPE_PRECOMPUTE_INIT
6530 | OPTI_TYPE_PRECOMPUTE_MERKLE
6531 | OPTI_TYPE_MEET_IN_MIDDLE
6532 | OPTI_TYPE_EARLY_SKIP
6533 | OPTI_TYPE_NOT_ITERATED
6534 | OPTI_TYPE_APPENDED_SALT
6535 | OPTI_TYPE_RAW_HASH;
6536 dgst_pos0 = 0;
6537 dgst_pos1 = 3;
6538 dgst_pos2 = 2;
6539 dgst_pos3 = 1;
6540 break;
6541
6542 case 12: hash_type = HASH_TYPE_MD5;
6543 salt_type = SALT_TYPE_INTERN;
6544 attack_exec = ATTACK_EXEC_ON_GPU;
6545 opts_type = OPTS_TYPE_PT_GENERATE_LE
6546 | OPTS_TYPE_ST_ADD80
6547 | OPTS_TYPE_ST_ADDBITS14;
6548 kern_type = KERN_TYPE_MD5_PWSLT;
6549 dgst_size = DGST_SIZE_4_4;
6550 parse_func = postgresql_parse_hash;
6551 sort_by_digest = sort_by_digest_4_4;
6552 opti_type = OPTI_TYPE_ZERO_BYTE
6553 | OPTI_TYPE_PRECOMPUTE_INIT
6554 | OPTI_TYPE_PRECOMPUTE_MERKLE
6555 | OPTI_TYPE_MEET_IN_MIDDLE
6556 | OPTI_TYPE_EARLY_SKIP
6557 | OPTI_TYPE_NOT_ITERATED
6558 | OPTI_TYPE_APPENDED_SALT
6559 | OPTI_TYPE_RAW_HASH;
6560 dgst_pos0 = 0;
6561 dgst_pos1 = 3;
6562 dgst_pos2 = 2;
6563 dgst_pos3 = 1;
6564 break;
6565
6566 case 20: hash_type = HASH_TYPE_MD5;
6567 salt_type = SALT_TYPE_INTERN;
6568 attack_exec = ATTACK_EXEC_ON_GPU;
6569 opts_type = OPTS_TYPE_PT_GENERATE_LE
6570 | OPTS_TYPE_PT_ADD80
6571 | OPTS_TYPE_PT_ADDBITS14;
6572 kern_type = KERN_TYPE_MD5_SLTPW;
6573 dgst_size = DGST_SIZE_4_4;
6574 parse_func = md5s_parse_hash;
6575 sort_by_digest = sort_by_digest_4_4;
6576 opti_type = OPTI_TYPE_ZERO_BYTE
6577 | OPTI_TYPE_PRECOMPUTE_INIT
6578 | OPTI_TYPE_PRECOMPUTE_MERKLE
6579 | OPTI_TYPE_EARLY_SKIP
6580 | OPTI_TYPE_NOT_ITERATED
6581 | OPTI_TYPE_PREPENDED_SALT
6582 | OPTI_TYPE_RAW_HASH;
6583 dgst_pos0 = 0;
6584 dgst_pos1 = 3;
6585 dgst_pos2 = 2;
6586 dgst_pos3 = 1;
6587 break;
6588
6589 case 21: hash_type = HASH_TYPE_MD5;
6590 salt_type = SALT_TYPE_INTERN;
6591 attack_exec = ATTACK_EXEC_ON_GPU;
6592 opts_type = OPTS_TYPE_PT_GENERATE_LE
6593 | OPTS_TYPE_PT_ADD80
6594 | OPTS_TYPE_PT_ADDBITS14;
6595 kern_type = KERN_TYPE_MD5_SLTPW;
6596 dgst_size = DGST_SIZE_4_4;
6597 parse_func = osc_parse_hash;
6598 sort_by_digest = sort_by_digest_4_4;
6599 opti_type = OPTI_TYPE_ZERO_BYTE
6600 | OPTI_TYPE_PRECOMPUTE_INIT
6601 | OPTI_TYPE_PRECOMPUTE_MERKLE
6602 | OPTI_TYPE_EARLY_SKIP
6603 | OPTI_TYPE_NOT_ITERATED
6604 | OPTI_TYPE_PREPENDED_SALT
6605 | OPTI_TYPE_RAW_HASH;
6606 dgst_pos0 = 0;
6607 dgst_pos1 = 3;
6608 dgst_pos2 = 2;
6609 dgst_pos3 = 1;
6610 break;
6611
6612 case 22: hash_type = HASH_TYPE_MD5;
6613 salt_type = SALT_TYPE_EMBEDDED;
6614 attack_exec = ATTACK_EXEC_ON_GPU;
6615 opts_type = OPTS_TYPE_PT_GENERATE_LE
6616 | OPTS_TYPE_PT_ADD80
6617 | OPTS_TYPE_PT_ADDBITS14;
6618 kern_type = KERN_TYPE_MD5_SLTPW;
6619 dgst_size = DGST_SIZE_4_4;
6620 parse_func = netscreen_parse_hash;
6621 sort_by_digest = sort_by_digest_4_4;
6622 opti_type = OPTI_TYPE_ZERO_BYTE
6623 | OPTI_TYPE_PRECOMPUTE_INIT
6624 | OPTI_TYPE_PRECOMPUTE_MERKLE
6625 | OPTI_TYPE_EARLY_SKIP
6626 | OPTI_TYPE_NOT_ITERATED
6627 | OPTI_TYPE_PREPENDED_SALT
6628 | OPTI_TYPE_RAW_HASH;
6629 dgst_pos0 = 0;
6630 dgst_pos1 = 3;
6631 dgst_pos2 = 2;
6632 dgst_pos3 = 1;
6633 break;
6634
6635 case 23: hash_type = HASH_TYPE_MD5;
6636 salt_type = SALT_TYPE_EMBEDDED;
6637 attack_exec = ATTACK_EXEC_ON_GPU;
6638 opts_type = OPTS_TYPE_PT_GENERATE_LE
6639 | OPTS_TYPE_PT_ADD80
6640 | OPTS_TYPE_PT_ADDBITS14;
6641 kern_type = KERN_TYPE_MD5_SLTPW;
6642 dgst_size = DGST_SIZE_4_4;
6643 parse_func = skype_parse_hash;
6644 sort_by_digest = sort_by_digest_4_4;
6645 opti_type = OPTI_TYPE_ZERO_BYTE
6646 | OPTI_TYPE_PRECOMPUTE_INIT
6647 | OPTI_TYPE_PRECOMPUTE_MERKLE
6648 | OPTI_TYPE_EARLY_SKIP
6649 | OPTI_TYPE_NOT_ITERATED
6650 | OPTI_TYPE_PREPENDED_SALT
6651 | OPTI_TYPE_RAW_HASH;
6652 dgst_pos0 = 0;
6653 dgst_pos1 = 3;
6654 dgst_pos2 = 2;
6655 dgst_pos3 = 1;
6656 break;
6657
6658 case 30: hash_type = HASH_TYPE_MD5;
6659 salt_type = SALT_TYPE_INTERN;
6660 attack_exec = ATTACK_EXEC_ON_GPU;
6661 opts_type = OPTS_TYPE_PT_GENERATE_LE
6662 | OPTS_TYPE_PT_UNICODE
6663 | OPTS_TYPE_ST_ADD80
6664 | OPTS_TYPE_ST_ADDBITS14;
6665 kern_type = KERN_TYPE_MD5_PWUSLT;
6666 dgst_size = DGST_SIZE_4_4;
6667 parse_func = md5s_parse_hash;
6668 sort_by_digest = sort_by_digest_4_4;
6669 opti_type = OPTI_TYPE_ZERO_BYTE
6670 | OPTI_TYPE_PRECOMPUTE_INIT
6671 | OPTI_TYPE_PRECOMPUTE_MERKLE
6672 | OPTI_TYPE_MEET_IN_MIDDLE
6673 | OPTI_TYPE_EARLY_SKIP
6674 | OPTI_TYPE_NOT_ITERATED
6675 | OPTI_TYPE_APPENDED_SALT
6676 | OPTI_TYPE_RAW_HASH;
6677 dgst_pos0 = 0;
6678 dgst_pos1 = 3;
6679 dgst_pos2 = 2;
6680 dgst_pos3 = 1;
6681 break;
6682
6683 case 40: hash_type = HASH_TYPE_MD5;
6684 salt_type = SALT_TYPE_INTERN;
6685 attack_exec = ATTACK_EXEC_ON_GPU;
6686 opts_type = OPTS_TYPE_PT_GENERATE_LE
6687 | OPTS_TYPE_PT_ADD80
6688 | OPTS_TYPE_PT_ADDBITS14
6689 | OPTS_TYPE_PT_UNICODE;
6690 kern_type = KERN_TYPE_MD5_SLTPWU;
6691 dgst_size = DGST_SIZE_4_4;
6692 parse_func = md5s_parse_hash;
6693 sort_by_digest = sort_by_digest_4_4;
6694 opti_type = OPTI_TYPE_ZERO_BYTE
6695 | OPTI_TYPE_PRECOMPUTE_INIT
6696 | OPTI_TYPE_PRECOMPUTE_MERKLE
6697 | OPTI_TYPE_EARLY_SKIP
6698 | OPTI_TYPE_NOT_ITERATED
6699 | OPTI_TYPE_PREPENDED_SALT
6700 | OPTI_TYPE_RAW_HASH;
6701 dgst_pos0 = 0;
6702 dgst_pos1 = 3;
6703 dgst_pos2 = 2;
6704 dgst_pos3 = 1;
6705 break;
6706
6707 case 50: hash_type = HASH_TYPE_MD5;
6708 salt_type = SALT_TYPE_INTERN;
6709 attack_exec = ATTACK_EXEC_ON_GPU;
6710 opts_type = OPTS_TYPE_PT_GENERATE_LE
6711 | OPTS_TYPE_ST_ADD80
6712 | OPTS_TYPE_ST_ADDBITS14;
6713 kern_type = KERN_TYPE_HMACMD5_PW;
6714 dgst_size = DGST_SIZE_4_4;
6715 parse_func = hmacmd5_parse_hash;
6716 sort_by_digest = sort_by_digest_4_4;
6717 opti_type = OPTI_TYPE_ZERO_BYTE
6718 | OPTI_TYPE_NOT_ITERATED;
6719 dgst_pos0 = 0;
6720 dgst_pos1 = 3;
6721 dgst_pos2 = 2;
6722 dgst_pos3 = 1;
6723 break;
6724
6725 case 60: hash_type = HASH_TYPE_MD5;
6726 salt_type = SALT_TYPE_INTERN;
6727 attack_exec = ATTACK_EXEC_ON_GPU;
6728 opts_type = OPTS_TYPE_PT_GENERATE_LE
6729 | OPTS_TYPE_PT_ADD80
6730 | OPTS_TYPE_PT_ADDBITS14;
6731 kern_type = KERN_TYPE_HMACMD5_SLT;
6732 dgst_size = DGST_SIZE_4_4;
6733 parse_func = hmacmd5_parse_hash;
6734 sort_by_digest = sort_by_digest_4_4;
6735 opti_type = OPTI_TYPE_ZERO_BYTE
6736 | OPTI_TYPE_NOT_ITERATED;
6737 dgst_pos0 = 0;
6738 dgst_pos1 = 3;
6739 dgst_pos2 = 2;
6740 dgst_pos3 = 1;
6741 break;
6742
6743 case 100: hash_type = HASH_TYPE_SHA1;
6744 salt_type = SALT_TYPE_NONE;
6745 attack_exec = ATTACK_EXEC_ON_GPU;
6746 opts_type = OPTS_TYPE_PT_GENERATE_BE
6747 | OPTS_TYPE_PT_ADD80
6748 | OPTS_TYPE_PT_ADDBITS15;
6749 kern_type = KERN_TYPE_SHA1;
6750 dgst_size = DGST_SIZE_4_5;
6751 parse_func = sha1_parse_hash;
6752 sort_by_digest = sort_by_digest_4_5;
6753 opti_type = OPTI_TYPE_ZERO_BYTE
6754 | OPTI_TYPE_PRECOMPUTE_INIT
6755 | OPTI_TYPE_PRECOMPUTE_MERKLE
6756 | OPTI_TYPE_EARLY_SKIP
6757 | OPTI_TYPE_NOT_ITERATED
6758 | OPTI_TYPE_NOT_SALTED
6759 | OPTI_TYPE_RAW_HASH;
6760 dgst_pos0 = 3;
6761 dgst_pos1 = 4;
6762 dgst_pos2 = 2;
6763 dgst_pos3 = 1;
6764 break;
6765
6766 case 101: hash_type = HASH_TYPE_SHA1;
6767 salt_type = SALT_TYPE_NONE;
6768 attack_exec = ATTACK_EXEC_ON_GPU;
6769 opts_type = OPTS_TYPE_PT_GENERATE_BE
6770 | OPTS_TYPE_PT_ADD80
6771 | OPTS_TYPE_PT_ADDBITS15;
6772 kern_type = KERN_TYPE_SHA1;
6773 dgst_size = DGST_SIZE_4_5;
6774 parse_func = sha1b64_parse_hash;
6775 sort_by_digest = sort_by_digest_4_5;
6776 opti_type = OPTI_TYPE_ZERO_BYTE
6777 | OPTI_TYPE_PRECOMPUTE_INIT
6778 | OPTI_TYPE_PRECOMPUTE_MERKLE
6779 | OPTI_TYPE_EARLY_SKIP
6780 | OPTI_TYPE_NOT_ITERATED
6781 | OPTI_TYPE_NOT_SALTED
6782 | OPTI_TYPE_RAW_HASH;
6783 dgst_pos0 = 3;
6784 dgst_pos1 = 4;
6785 dgst_pos2 = 2;
6786 dgst_pos3 = 1;
6787 break;
6788
6789 case 110: hash_type = HASH_TYPE_SHA1;
6790 salt_type = SALT_TYPE_INTERN;
6791 attack_exec = ATTACK_EXEC_ON_GPU;
6792 opts_type = OPTS_TYPE_PT_GENERATE_BE
6793 | OPTS_TYPE_ST_ADD80
6794 | OPTS_TYPE_ST_ADDBITS15;
6795 kern_type = KERN_TYPE_SHA1_PWSLT;
6796 dgst_size = DGST_SIZE_4_5;
6797 parse_func = sha1s_parse_hash;
6798 sort_by_digest = sort_by_digest_4_5;
6799 opti_type = OPTI_TYPE_ZERO_BYTE
6800 | OPTI_TYPE_PRECOMPUTE_INIT
6801 | OPTI_TYPE_PRECOMPUTE_MERKLE
6802 | OPTI_TYPE_EARLY_SKIP
6803 | OPTI_TYPE_NOT_ITERATED
6804 | OPTI_TYPE_APPENDED_SALT
6805 | OPTI_TYPE_RAW_HASH;
6806 dgst_pos0 = 3;
6807 dgst_pos1 = 4;
6808 dgst_pos2 = 2;
6809 dgst_pos3 = 1;
6810 break;
6811
6812 case 111: hash_type = HASH_TYPE_SHA1;
6813 salt_type = SALT_TYPE_EMBEDDED;
6814 attack_exec = ATTACK_EXEC_ON_GPU;
6815 opts_type = OPTS_TYPE_PT_GENERATE_BE
6816 | OPTS_TYPE_ST_ADD80
6817 | OPTS_TYPE_ST_ADDBITS15;
6818 kern_type = KERN_TYPE_SHA1_PWSLT;
6819 dgst_size = DGST_SIZE_4_5;
6820 parse_func = sha1b64s_parse_hash;
6821 sort_by_digest = sort_by_digest_4_5;
6822 opti_type = OPTI_TYPE_ZERO_BYTE
6823 | OPTI_TYPE_PRECOMPUTE_INIT
6824 | OPTI_TYPE_PRECOMPUTE_MERKLE
6825 | OPTI_TYPE_EARLY_SKIP
6826 | OPTI_TYPE_NOT_ITERATED
6827 | OPTI_TYPE_APPENDED_SALT
6828 | OPTI_TYPE_RAW_HASH;
6829 dgst_pos0 = 3;
6830 dgst_pos1 = 4;
6831 dgst_pos2 = 2;
6832 dgst_pos3 = 1;
6833 break;
6834
6835 case 112: hash_type = HASH_TYPE_SHA1;
6836 salt_type = SALT_TYPE_INTERN;
6837 attack_exec = ATTACK_EXEC_ON_GPU;
6838 opts_type = OPTS_TYPE_PT_GENERATE_BE
6839 | OPTS_TYPE_ST_ADD80
6840 | OPTS_TYPE_ST_ADDBITS15
6841 | OPTS_TYPE_ST_HEX;
6842 kern_type = KERN_TYPE_SHA1_PWSLT;
6843 dgst_size = DGST_SIZE_4_5;
6844 parse_func = oracles_parse_hash;
6845 sort_by_digest = sort_by_digest_4_5;
6846 opti_type = OPTI_TYPE_ZERO_BYTE
6847 | OPTI_TYPE_PRECOMPUTE_INIT
6848 | OPTI_TYPE_PRECOMPUTE_MERKLE
6849 | OPTI_TYPE_EARLY_SKIP
6850 | OPTI_TYPE_NOT_ITERATED
6851 | OPTI_TYPE_APPENDED_SALT
6852 | OPTI_TYPE_RAW_HASH;
6853 dgst_pos0 = 3;
6854 dgst_pos1 = 4;
6855 dgst_pos2 = 2;
6856 dgst_pos3 = 1;
6857 break;
6858
6859 case 120: hash_type = HASH_TYPE_SHA1;
6860 salt_type = SALT_TYPE_INTERN;
6861 attack_exec = ATTACK_EXEC_ON_GPU;
6862 opts_type = OPTS_TYPE_PT_GENERATE_BE
6863 | OPTS_TYPE_PT_ADD80
6864 | OPTS_TYPE_PT_ADDBITS15;
6865 kern_type = KERN_TYPE_SHA1_SLTPW;
6866 dgst_size = DGST_SIZE_4_5;
6867 parse_func = sha1s_parse_hash;
6868 sort_by_digest = sort_by_digest_4_5;
6869 opti_type = OPTI_TYPE_ZERO_BYTE
6870 | OPTI_TYPE_PRECOMPUTE_INIT
6871 | OPTI_TYPE_PRECOMPUTE_MERKLE
6872 | OPTI_TYPE_EARLY_SKIP
6873 | OPTI_TYPE_NOT_ITERATED
6874 | OPTI_TYPE_PREPENDED_SALT
6875 | OPTI_TYPE_RAW_HASH;
6876 dgst_pos0 = 3;
6877 dgst_pos1 = 4;
6878 dgst_pos2 = 2;
6879 dgst_pos3 = 1;
6880 break;
6881
6882 case 121: hash_type = HASH_TYPE_SHA1;
6883 salt_type = SALT_TYPE_INTERN;
6884 attack_exec = ATTACK_EXEC_ON_GPU;
6885 opts_type = OPTS_TYPE_PT_GENERATE_BE
6886 | OPTS_TYPE_PT_ADD80
6887 | OPTS_TYPE_PT_ADDBITS15
6888 | OPTS_TYPE_ST_LOWER;
6889 kern_type = KERN_TYPE_SHA1_SLTPW;
6890 dgst_size = DGST_SIZE_4_5;
6891 parse_func = smf_parse_hash;
6892 sort_by_digest = sort_by_digest_4_5;
6893 opti_type = OPTI_TYPE_ZERO_BYTE
6894 | OPTI_TYPE_PRECOMPUTE_INIT
6895 | OPTI_TYPE_PRECOMPUTE_MERKLE
6896 | OPTI_TYPE_EARLY_SKIP
6897 | OPTI_TYPE_NOT_ITERATED
6898 | OPTI_TYPE_PREPENDED_SALT
6899 | OPTI_TYPE_RAW_HASH;
6900 dgst_pos0 = 3;
6901 dgst_pos1 = 4;
6902 dgst_pos2 = 2;
6903 dgst_pos3 = 1;
6904 break;
6905
6906 case 122: hash_type = HASH_TYPE_SHA1;
6907 salt_type = SALT_TYPE_EMBEDDED;
6908 attack_exec = ATTACK_EXEC_ON_GPU;
6909 opts_type = OPTS_TYPE_PT_GENERATE_BE
6910 | OPTS_TYPE_PT_ADD80
6911 | OPTS_TYPE_PT_ADDBITS15
6912 | OPTS_TYPE_ST_HEX;
6913 kern_type = KERN_TYPE_SHA1_SLTPW;
6914 dgst_size = DGST_SIZE_4_5;
6915 parse_func = osx1_parse_hash;
6916 sort_by_digest = sort_by_digest_4_5;
6917 opti_type = OPTI_TYPE_ZERO_BYTE
6918 | OPTI_TYPE_PRECOMPUTE_INIT
6919 | OPTI_TYPE_PRECOMPUTE_MERKLE
6920 | OPTI_TYPE_EARLY_SKIP
6921 | OPTI_TYPE_NOT_ITERATED
6922 | OPTI_TYPE_PREPENDED_SALT
6923 | OPTI_TYPE_RAW_HASH;
6924 dgst_pos0 = 3;
6925 dgst_pos1 = 4;
6926 dgst_pos2 = 2;
6927 dgst_pos3 = 1;
6928 break;
6929
6930 case 124: hash_type = HASH_TYPE_SHA1;
6931 salt_type = SALT_TYPE_EMBEDDED;
6932 attack_exec = ATTACK_EXEC_ON_GPU;
6933 opts_type = OPTS_TYPE_PT_GENERATE_BE
6934 | OPTS_TYPE_PT_ADD80
6935 | OPTS_TYPE_PT_ADDBITS15;
6936 kern_type = KERN_TYPE_SHA1_SLTPW;
6937 dgst_size = DGST_SIZE_4_5;
6938 parse_func = djangosha1_parse_hash;
6939 sort_by_digest = sort_by_digest_4_5;
6940 opti_type = OPTI_TYPE_ZERO_BYTE
6941 | OPTI_TYPE_PRECOMPUTE_INIT
6942 | OPTI_TYPE_PRECOMPUTE_MERKLE
6943 | OPTI_TYPE_EARLY_SKIP
6944 | OPTI_TYPE_NOT_ITERATED
6945 | OPTI_TYPE_PREPENDED_SALT
6946 | OPTI_TYPE_RAW_HASH;
6947 dgst_pos0 = 3;
6948 dgst_pos1 = 4;
6949 dgst_pos2 = 2;
6950 dgst_pos3 = 1;
6951 break;
6952
6953 case 130: hash_type = HASH_TYPE_SHA1;
6954 salt_type = SALT_TYPE_INTERN;
6955 attack_exec = ATTACK_EXEC_ON_GPU;
6956 opts_type = OPTS_TYPE_PT_GENERATE_BE
6957 | OPTS_TYPE_PT_UNICODE
6958 | OPTS_TYPE_ST_ADD80
6959 | OPTS_TYPE_ST_ADDBITS15;
6960 kern_type = KERN_TYPE_SHA1_PWUSLT;
6961 dgst_size = DGST_SIZE_4_5;
6962 parse_func = sha1s_parse_hash;
6963 sort_by_digest = sort_by_digest_4_5;
6964 opti_type = OPTI_TYPE_ZERO_BYTE
6965 | OPTI_TYPE_PRECOMPUTE_INIT
6966 | OPTI_TYPE_PRECOMPUTE_MERKLE
6967 | OPTI_TYPE_EARLY_SKIP
6968 | OPTI_TYPE_NOT_ITERATED
6969 | OPTI_TYPE_APPENDED_SALT
6970 | OPTI_TYPE_RAW_HASH;
6971 dgst_pos0 = 3;
6972 dgst_pos1 = 4;
6973 dgst_pos2 = 2;
6974 dgst_pos3 = 1;
6975 break;
6976
6977 case 131: hash_type = HASH_TYPE_SHA1;
6978 salt_type = SALT_TYPE_EMBEDDED;
6979 attack_exec = ATTACK_EXEC_ON_GPU;
6980 opts_type = OPTS_TYPE_PT_GENERATE_BE
6981 | OPTS_TYPE_PT_UNICODE
6982 | OPTS_TYPE_PT_UPPER
6983 | OPTS_TYPE_ST_ADD80
6984 | OPTS_TYPE_ST_ADDBITS15
6985 | OPTS_TYPE_ST_HEX;
6986 kern_type = KERN_TYPE_SHA1_PWUSLT;
6987 dgst_size = DGST_SIZE_4_5;
6988 parse_func = mssql2000_parse_hash;
6989 sort_by_digest = sort_by_digest_4_5;
6990 opti_type = OPTI_TYPE_ZERO_BYTE
6991 | OPTI_TYPE_PRECOMPUTE_INIT
6992 | OPTI_TYPE_PRECOMPUTE_MERKLE
6993 | OPTI_TYPE_EARLY_SKIP
6994 | OPTI_TYPE_NOT_ITERATED
6995 | OPTI_TYPE_APPENDED_SALT
6996 | OPTI_TYPE_RAW_HASH;
6997 dgst_pos0 = 3;
6998 dgst_pos1 = 4;
6999 dgst_pos2 = 2;
7000 dgst_pos3 = 1;
7001 break;
7002
7003 case 132: hash_type = HASH_TYPE_SHA1;
7004 salt_type = SALT_TYPE_EMBEDDED;
7005 attack_exec = ATTACK_EXEC_ON_GPU;
7006 opts_type = OPTS_TYPE_PT_GENERATE_BE
7007 | OPTS_TYPE_PT_UNICODE
7008 | OPTS_TYPE_ST_ADD80
7009 | OPTS_TYPE_ST_ADDBITS15
7010 | OPTS_TYPE_ST_HEX;
7011 kern_type = KERN_TYPE_SHA1_PWUSLT;
7012 dgst_size = DGST_SIZE_4_5;
7013 parse_func = mssql2005_parse_hash;
7014 sort_by_digest = sort_by_digest_4_5;
7015 opti_type = OPTI_TYPE_ZERO_BYTE
7016 | OPTI_TYPE_PRECOMPUTE_INIT
7017 | OPTI_TYPE_PRECOMPUTE_MERKLE
7018 | OPTI_TYPE_EARLY_SKIP
7019 | OPTI_TYPE_NOT_ITERATED
7020 | OPTI_TYPE_APPENDED_SALT
7021 | OPTI_TYPE_RAW_HASH;
7022 dgst_pos0 = 3;
7023 dgst_pos1 = 4;
7024 dgst_pos2 = 2;
7025 dgst_pos3 = 1;
7026 break;
7027
7028 case 133: hash_type = HASH_TYPE_SHA1;
7029 salt_type = SALT_TYPE_EMBEDDED;
7030 attack_exec = ATTACK_EXEC_ON_GPU;
7031 opts_type = OPTS_TYPE_PT_GENERATE_BE
7032 | OPTS_TYPE_PT_UNICODE
7033 | OPTS_TYPE_ST_ADD80
7034 | OPTS_TYPE_ST_ADDBITS15;
7035 kern_type = KERN_TYPE_SHA1_PWUSLT;
7036 dgst_size = DGST_SIZE_4_5;
7037 parse_func = peoplesoft_parse_hash;
7038 sort_by_digest = sort_by_digest_4_5;
7039 opti_type = OPTI_TYPE_ZERO_BYTE
7040 | OPTI_TYPE_PRECOMPUTE_INIT
7041 | OPTI_TYPE_PRECOMPUTE_MERKLE
7042 | OPTI_TYPE_EARLY_SKIP
7043 | OPTI_TYPE_NOT_ITERATED
7044 | OPTI_TYPE_APPENDED_SALT
7045 | OPTI_TYPE_RAW_HASH;
7046 dgst_pos0 = 3;
7047 dgst_pos1 = 4;
7048 dgst_pos2 = 2;
7049 dgst_pos3 = 1;
7050 break;
7051
7052 case 140: hash_type = HASH_TYPE_SHA1;
7053 salt_type = SALT_TYPE_INTERN;
7054 attack_exec = ATTACK_EXEC_ON_GPU;
7055 opts_type = OPTS_TYPE_PT_GENERATE_BE
7056 | OPTS_TYPE_PT_ADD80
7057 | OPTS_TYPE_PT_ADDBITS15
7058 | OPTS_TYPE_PT_UNICODE;
7059 kern_type = KERN_TYPE_SHA1_SLTPWU;
7060 dgst_size = DGST_SIZE_4_5;
7061 parse_func = sha1s_parse_hash;
7062 sort_by_digest = sort_by_digest_4_5;
7063 opti_type = OPTI_TYPE_ZERO_BYTE
7064 | OPTI_TYPE_PRECOMPUTE_INIT
7065 | OPTI_TYPE_PRECOMPUTE_MERKLE
7066 | OPTI_TYPE_EARLY_SKIP
7067 | OPTI_TYPE_NOT_ITERATED
7068 | OPTI_TYPE_PREPENDED_SALT
7069 | OPTI_TYPE_RAW_HASH;
7070 dgst_pos0 = 3;
7071 dgst_pos1 = 4;
7072 dgst_pos2 = 2;
7073 dgst_pos3 = 1;
7074 break;
7075
7076 case 141: hash_type = HASH_TYPE_SHA1;
7077 salt_type = SALT_TYPE_EMBEDDED;
7078 attack_exec = ATTACK_EXEC_ON_GPU;
7079 opts_type = OPTS_TYPE_PT_GENERATE_BE
7080 | OPTS_TYPE_PT_ADD80
7081 | OPTS_TYPE_PT_ADDBITS15
7082 | OPTS_TYPE_PT_UNICODE
7083 | OPTS_TYPE_ST_BASE64;
7084 kern_type = KERN_TYPE_SHA1_SLTPWU;
7085 dgst_size = DGST_SIZE_4_5;
7086 parse_func = episerver_parse_hash;
7087 sort_by_digest = sort_by_digest_4_5;
7088 opti_type = OPTI_TYPE_ZERO_BYTE
7089 | OPTI_TYPE_PRECOMPUTE_INIT
7090 | OPTI_TYPE_PRECOMPUTE_MERKLE
7091 | OPTI_TYPE_EARLY_SKIP
7092 | OPTI_TYPE_NOT_ITERATED
7093 | OPTI_TYPE_PREPENDED_SALT
7094 | OPTI_TYPE_RAW_HASH;
7095 dgst_pos0 = 3;
7096 dgst_pos1 = 4;
7097 dgst_pos2 = 2;
7098 dgst_pos3 = 1;
7099 break;
7100
7101 case 150: hash_type = HASH_TYPE_SHA1;
7102 salt_type = SALT_TYPE_INTERN;
7103 attack_exec = ATTACK_EXEC_ON_GPU;
7104 opts_type = OPTS_TYPE_PT_GENERATE_BE
7105 | OPTS_TYPE_ST_ADD80
7106 | OPTS_TYPE_ST_ADDBITS15;
7107 kern_type = KERN_TYPE_HMACSHA1_PW;
7108 dgst_size = DGST_SIZE_4_5;
7109 parse_func = hmacsha1_parse_hash;
7110 sort_by_digest = sort_by_digest_4_5;
7111 opti_type = OPTI_TYPE_ZERO_BYTE
7112 | OPTI_TYPE_NOT_ITERATED;
7113 dgst_pos0 = 3;
7114 dgst_pos1 = 4;
7115 dgst_pos2 = 2;
7116 dgst_pos3 = 1;
7117 break;
7118
7119 case 160: hash_type = HASH_TYPE_SHA1;
7120 salt_type = SALT_TYPE_INTERN;
7121 attack_exec = ATTACK_EXEC_ON_GPU;
7122 opts_type = OPTS_TYPE_PT_GENERATE_BE
7123 | OPTS_TYPE_PT_ADD80
7124 | OPTS_TYPE_PT_ADDBITS15;
7125 kern_type = KERN_TYPE_HMACSHA1_SLT;
7126 dgst_size = DGST_SIZE_4_5;
7127 parse_func = hmacsha1_parse_hash;
7128 sort_by_digest = sort_by_digest_4_5;
7129 opti_type = OPTI_TYPE_ZERO_BYTE
7130 | OPTI_TYPE_NOT_ITERATED;
7131 dgst_pos0 = 3;
7132 dgst_pos1 = 4;
7133 dgst_pos2 = 2;
7134 dgst_pos3 = 1;
7135 break;
7136
7137 case 190: hash_type = HASH_TYPE_SHA1;
7138 salt_type = SALT_TYPE_NONE;
7139 attack_exec = ATTACK_EXEC_ON_GPU;
7140 opts_type = OPTS_TYPE_PT_GENERATE_BE
7141 | OPTS_TYPE_PT_ADD80
7142 | OPTS_TYPE_PT_ADDBITS15;
7143 kern_type = KERN_TYPE_SHA1_LINKEDIN;
7144 dgst_size = DGST_SIZE_4_5;
7145 parse_func = sha1linkedin_parse_hash;
7146 sort_by_digest = sort_by_digest_4_5;
7147 opti_type = OPTI_TYPE_ZERO_BYTE
7148 | OPTI_TYPE_PRECOMPUTE_INIT
7149 | OPTI_TYPE_EARLY_SKIP
7150 | OPTI_TYPE_NOT_ITERATED
7151 | OPTI_TYPE_NOT_SALTED;
7152 dgst_pos0 = 0;
7153 dgst_pos1 = 4;
7154 dgst_pos2 = 3;
7155 dgst_pos3 = 2;
7156 break;
7157
7158 case 200: hash_type = HASH_TYPE_MYSQL;
7159 salt_type = SALT_TYPE_NONE;
7160 attack_exec = ATTACK_EXEC_ON_GPU;
7161 opts_type = 0;
7162 kern_type = KERN_TYPE_MYSQL;
7163 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7164 parse_func = mysql323_parse_hash;
7165 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7166 opti_type = OPTI_TYPE_ZERO_BYTE;
7167 dgst_pos0 = 0;
7168 dgst_pos1 = 1;
7169 dgst_pos2 = 2;
7170 dgst_pos3 = 3;
7171 break;
7172
7173 case 300: hash_type = HASH_TYPE_SHA1;
7174 salt_type = SALT_TYPE_NONE;
7175 attack_exec = ATTACK_EXEC_ON_GPU;
7176 opts_type = OPTS_TYPE_PT_GENERATE_BE
7177 | OPTS_TYPE_PT_ADD80
7178 | OPTS_TYPE_PT_ADDBITS15;
7179 kern_type = KERN_TYPE_MYSQL41;
7180 dgst_size = DGST_SIZE_4_5;
7181 parse_func = sha1_parse_hash;
7182 sort_by_digest = sort_by_digest_4_5;
7183 opti_type = OPTI_TYPE_ZERO_BYTE
7184 | OPTI_TYPE_PRECOMPUTE_INIT
7185 | OPTI_TYPE_PRECOMPUTE_MERKLE
7186 | OPTI_TYPE_EARLY_SKIP
7187 | OPTI_TYPE_NOT_ITERATED
7188 | OPTI_TYPE_NOT_SALTED;
7189 dgst_pos0 = 3;
7190 dgst_pos1 = 4;
7191 dgst_pos2 = 2;
7192 dgst_pos3 = 1;
7193 break;
7194
7195 case 400: hash_type = HASH_TYPE_MD5;
7196 salt_type = SALT_TYPE_EMBEDDED;
7197 attack_exec = ATTACK_EXEC_ON_CPU;
7198 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7199 kern_type = KERN_TYPE_PHPASS;
7200 dgst_size = DGST_SIZE_4_4;
7201 parse_func = phpass_parse_hash;
7202 sort_by_digest = sort_by_digest_4_4;
7203 opti_type = OPTI_TYPE_ZERO_BYTE;
7204 dgst_pos0 = 0;
7205 dgst_pos1 = 1;
7206 dgst_pos2 = 2;
7207 dgst_pos3 = 3;
7208 break;
7209
7210 case 500: hash_type = HASH_TYPE_MD5;
7211 salt_type = SALT_TYPE_EMBEDDED;
7212 attack_exec = ATTACK_EXEC_ON_CPU;
7213 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7214 kern_type = KERN_TYPE_MD5CRYPT;
7215 dgst_size = DGST_SIZE_4_4;
7216 parse_func = md5crypt_parse_hash;
7217 sort_by_digest = sort_by_digest_4_4;
7218 opti_type = OPTI_TYPE_ZERO_BYTE;
7219 dgst_pos0 = 0;
7220 dgst_pos1 = 1;
7221 dgst_pos2 = 2;
7222 dgst_pos3 = 3;
7223 break;
7224
7225 case 501: hash_type = HASH_TYPE_MD5;
7226 salt_type = SALT_TYPE_EMBEDDED;
7227 attack_exec = ATTACK_EXEC_ON_CPU;
7228 opts_type = OPTS_TYPE_PT_GENERATE_LE
7229 | OPTS_TYPE_HASH_COPY;
7230 kern_type = KERN_TYPE_MD5CRYPT;
7231 dgst_size = DGST_SIZE_4_4;
7232 parse_func = juniper_parse_hash;
7233 sort_by_digest = sort_by_digest_4_4;
7234 opti_type = OPTI_TYPE_ZERO_BYTE;
7235 dgst_pos0 = 0;
7236 dgst_pos1 = 1;
7237 dgst_pos2 = 2;
7238 dgst_pos3 = 3;
7239 break;
7240
7241 case 900: hash_type = HASH_TYPE_MD4;
7242 salt_type = SALT_TYPE_NONE;
7243 attack_exec = ATTACK_EXEC_ON_GPU;
7244 opts_type = OPTS_TYPE_PT_GENERATE_LE
7245 | OPTS_TYPE_PT_ADD80
7246 | OPTS_TYPE_PT_ADDBITS14;
7247 kern_type = KERN_TYPE_MD4;
7248 dgst_size = DGST_SIZE_4_4;
7249 parse_func = md4_parse_hash;
7250 sort_by_digest = sort_by_digest_4_4;
7251 opti_type = OPTI_TYPE_ZERO_BYTE
7252 | OPTI_TYPE_PRECOMPUTE_INIT
7253 | OPTI_TYPE_PRECOMPUTE_MERKLE
7254 | OPTI_TYPE_MEET_IN_MIDDLE
7255 | OPTI_TYPE_EARLY_SKIP
7256 | OPTI_TYPE_NOT_ITERATED
7257 | OPTI_TYPE_NOT_SALTED
7258 | OPTI_TYPE_RAW_HASH;
7259 dgst_pos0 = 0;
7260 dgst_pos1 = 3;
7261 dgst_pos2 = 2;
7262 dgst_pos3 = 1;
7263 break;
7264
7265 case 1000: hash_type = HASH_TYPE_MD4;
7266 salt_type = SALT_TYPE_NONE;
7267 attack_exec = ATTACK_EXEC_ON_GPU;
7268 opts_type = OPTS_TYPE_PT_GENERATE_LE
7269 | OPTS_TYPE_PT_ADD80
7270 | OPTS_TYPE_PT_ADDBITS14
7271 | OPTS_TYPE_PT_UNICODE;
7272 kern_type = KERN_TYPE_MD4_PWU;
7273 dgst_size = DGST_SIZE_4_4;
7274 parse_func = md4_parse_hash;
7275 sort_by_digest = sort_by_digest_4_4;
7276 opti_type = OPTI_TYPE_ZERO_BYTE
7277 | OPTI_TYPE_PRECOMPUTE_INIT
7278 | OPTI_TYPE_PRECOMPUTE_MERKLE
7279 | OPTI_TYPE_MEET_IN_MIDDLE
7280 | OPTI_TYPE_EARLY_SKIP
7281 | OPTI_TYPE_NOT_ITERATED
7282 | OPTI_TYPE_NOT_SALTED
7283 | OPTI_TYPE_RAW_HASH;
7284 dgst_pos0 = 0;
7285 dgst_pos1 = 3;
7286 dgst_pos2 = 2;
7287 dgst_pos3 = 1;
7288 break;
7289
7290 case 1100: hash_type = HASH_TYPE_MD4;
7291 salt_type = SALT_TYPE_INTERN;
7292 attack_exec = ATTACK_EXEC_ON_GPU;
7293 opts_type = OPTS_TYPE_PT_GENERATE_LE
7294 | OPTS_TYPE_PT_ADD80
7295 | OPTS_TYPE_PT_ADDBITS14
7296 | OPTS_TYPE_PT_UNICODE
7297 | OPTS_TYPE_ST_ADD80
7298 | OPTS_TYPE_ST_UNICODE
7299 | OPTS_TYPE_ST_LOWER;
7300 kern_type = KERN_TYPE_MD44_PWUSLT;
7301 dgst_size = DGST_SIZE_4_4;
7302 parse_func = dcc_parse_hash;
7303 sort_by_digest = sort_by_digest_4_4;
7304 opti_type = OPTI_TYPE_ZERO_BYTE
7305 | OPTI_TYPE_PRECOMPUTE_INIT
7306 | OPTI_TYPE_PRECOMPUTE_MERKLE
7307 | OPTI_TYPE_EARLY_SKIP
7308 | OPTI_TYPE_NOT_ITERATED;
7309 dgst_pos0 = 0;
7310 dgst_pos1 = 3;
7311 dgst_pos2 = 2;
7312 dgst_pos3 = 1;
7313 break;
7314
7315 case 1400: hash_type = HASH_TYPE_SHA256;
7316 salt_type = SALT_TYPE_NONE;
7317 attack_exec = ATTACK_EXEC_ON_GPU;
7318 opts_type = OPTS_TYPE_PT_GENERATE_BE
7319 | OPTS_TYPE_PT_ADD80
7320 | OPTS_TYPE_PT_ADDBITS15;
7321 kern_type = KERN_TYPE_SHA256;
7322 dgst_size = DGST_SIZE_4_8;
7323 parse_func = sha256_parse_hash;
7324 sort_by_digest = sort_by_digest_4_8;
7325 opti_type = OPTI_TYPE_ZERO_BYTE
7326 | OPTI_TYPE_PRECOMPUTE_INIT
7327 | OPTI_TYPE_PRECOMPUTE_MERKLE
7328 | OPTI_TYPE_EARLY_SKIP
7329 | OPTI_TYPE_NOT_ITERATED
7330 | OPTI_TYPE_NOT_SALTED
7331 | OPTI_TYPE_RAW_HASH;
7332 dgst_pos0 = 3;
7333 dgst_pos1 = 7;
7334 dgst_pos2 = 2;
7335 dgst_pos3 = 6;
7336 break;
7337
7338 case 1410: hash_type = HASH_TYPE_SHA256;
7339 salt_type = SALT_TYPE_INTERN;
7340 attack_exec = ATTACK_EXEC_ON_GPU;
7341 opts_type = OPTS_TYPE_PT_GENERATE_BE
7342 | OPTS_TYPE_ST_ADD80
7343 | OPTS_TYPE_ST_ADDBITS15;
7344 kern_type = KERN_TYPE_SHA256_PWSLT;
7345 dgst_size = DGST_SIZE_4_8;
7346 parse_func = sha256s_parse_hash;
7347 sort_by_digest = sort_by_digest_4_8;
7348 opti_type = OPTI_TYPE_ZERO_BYTE
7349 | OPTI_TYPE_PRECOMPUTE_INIT
7350 | OPTI_TYPE_PRECOMPUTE_MERKLE
7351 | OPTI_TYPE_EARLY_SKIP
7352 | OPTI_TYPE_NOT_ITERATED
7353 | OPTI_TYPE_APPENDED_SALT
7354 | OPTI_TYPE_RAW_HASH;
7355 dgst_pos0 = 3;
7356 dgst_pos1 = 7;
7357 dgst_pos2 = 2;
7358 dgst_pos3 = 6;
7359 break;
7360
7361 case 1420: hash_type = HASH_TYPE_SHA256;
7362 salt_type = SALT_TYPE_INTERN;
7363 attack_exec = ATTACK_EXEC_ON_GPU;
7364 opts_type = OPTS_TYPE_PT_GENERATE_BE
7365 | OPTS_TYPE_PT_ADD80
7366 | OPTS_TYPE_PT_ADDBITS15;
7367 kern_type = KERN_TYPE_SHA256_SLTPW;
7368 dgst_size = DGST_SIZE_4_8;
7369 parse_func = sha256s_parse_hash;
7370 sort_by_digest = sort_by_digest_4_8;
7371 opti_type = OPTI_TYPE_ZERO_BYTE
7372 | OPTI_TYPE_PRECOMPUTE_INIT
7373 | OPTI_TYPE_PRECOMPUTE_MERKLE
7374 | OPTI_TYPE_EARLY_SKIP
7375 | OPTI_TYPE_NOT_ITERATED
7376 | OPTI_TYPE_PREPENDED_SALT
7377 | OPTI_TYPE_RAW_HASH;
7378 dgst_pos0 = 3;
7379 dgst_pos1 = 7;
7380 dgst_pos2 = 2;
7381 dgst_pos3 = 6;
7382 break;
7383
7384 case 1421: hash_type = HASH_TYPE_SHA256;
7385 salt_type = SALT_TYPE_EMBEDDED;
7386 attack_exec = ATTACK_EXEC_ON_GPU;
7387 opts_type = OPTS_TYPE_PT_GENERATE_BE
7388 | OPTS_TYPE_PT_ADD80
7389 | OPTS_TYPE_PT_ADDBITS15;
7390 kern_type = KERN_TYPE_SHA256_SLTPW;
7391 dgst_size = DGST_SIZE_4_8;
7392 parse_func = hmailserver_parse_hash;
7393 sort_by_digest = sort_by_digest_4_8;
7394 opti_type = OPTI_TYPE_ZERO_BYTE
7395 | OPTI_TYPE_PRECOMPUTE_INIT
7396 | OPTI_TYPE_PRECOMPUTE_MERKLE
7397 | OPTI_TYPE_EARLY_SKIP
7398 | OPTI_TYPE_NOT_ITERATED
7399 | OPTI_TYPE_PREPENDED_SALT
7400 | OPTI_TYPE_RAW_HASH;
7401 dgst_pos0 = 3;
7402 dgst_pos1 = 7;
7403 dgst_pos2 = 2;
7404 dgst_pos3 = 6;
7405 break;
7406
7407 case 1430: hash_type = HASH_TYPE_SHA256;
7408 salt_type = SALT_TYPE_INTERN;
7409 attack_exec = ATTACK_EXEC_ON_GPU;
7410 opts_type = OPTS_TYPE_PT_GENERATE_BE
7411 | OPTS_TYPE_PT_UNICODE
7412 | OPTS_TYPE_ST_ADD80
7413 | OPTS_TYPE_ST_ADDBITS15;
7414 kern_type = KERN_TYPE_SHA256_PWUSLT;
7415 dgst_size = DGST_SIZE_4_8;
7416 parse_func = sha256s_parse_hash;
7417 sort_by_digest = sort_by_digest_4_8;
7418 opti_type = OPTI_TYPE_ZERO_BYTE
7419 | OPTI_TYPE_PRECOMPUTE_INIT
7420 | OPTI_TYPE_PRECOMPUTE_MERKLE
7421 | OPTI_TYPE_EARLY_SKIP
7422 | OPTI_TYPE_NOT_ITERATED
7423 | OPTI_TYPE_APPENDED_SALT
7424 | OPTI_TYPE_RAW_HASH;
7425 dgst_pos0 = 3;
7426 dgst_pos1 = 7;
7427 dgst_pos2 = 2;
7428 dgst_pos3 = 6;
7429 break;
7430
7431 case 1440: hash_type = HASH_TYPE_SHA256;
7432 salt_type = SALT_TYPE_INTERN;
7433 attack_exec = ATTACK_EXEC_ON_GPU;
7434 opts_type = OPTS_TYPE_PT_GENERATE_BE
7435 | OPTS_TYPE_PT_ADD80
7436 | OPTS_TYPE_PT_ADDBITS15
7437 | OPTS_TYPE_PT_UNICODE;
7438 kern_type = KERN_TYPE_SHA256_SLTPWU;
7439 dgst_size = DGST_SIZE_4_8;
7440 parse_func = sha256s_parse_hash;
7441 sort_by_digest = sort_by_digest_4_8;
7442 opti_type = OPTI_TYPE_ZERO_BYTE
7443 | OPTI_TYPE_PRECOMPUTE_INIT
7444 | OPTI_TYPE_PRECOMPUTE_MERKLE
7445 | OPTI_TYPE_EARLY_SKIP
7446 | OPTI_TYPE_NOT_ITERATED
7447 | OPTI_TYPE_PREPENDED_SALT
7448 | OPTI_TYPE_RAW_HASH;
7449 dgst_pos0 = 3;
7450 dgst_pos1 = 7;
7451 dgst_pos2 = 2;
7452 dgst_pos3 = 6;
7453 break;
7454
7455 case 1441: hash_type = HASH_TYPE_SHA256;
7456 salt_type = SALT_TYPE_EMBEDDED;
7457 attack_exec = ATTACK_EXEC_ON_GPU;
7458 opts_type = OPTS_TYPE_PT_GENERATE_BE
7459 | OPTS_TYPE_PT_ADD80
7460 | OPTS_TYPE_PT_ADDBITS15
7461 | OPTS_TYPE_PT_UNICODE
7462 | OPTS_TYPE_ST_BASE64;
7463 kern_type = KERN_TYPE_SHA256_SLTPWU;
7464 dgst_size = DGST_SIZE_4_8;
7465 parse_func = episerver4_parse_hash;
7466 sort_by_digest = sort_by_digest_4_8;
7467 opti_type = OPTI_TYPE_ZERO_BYTE
7468 | OPTI_TYPE_PRECOMPUTE_INIT
7469 | OPTI_TYPE_PRECOMPUTE_MERKLE
7470 | OPTI_TYPE_EARLY_SKIP
7471 | OPTI_TYPE_NOT_ITERATED
7472 | OPTI_TYPE_PREPENDED_SALT
7473 | OPTI_TYPE_RAW_HASH;
7474 dgst_pos0 = 3;
7475 dgst_pos1 = 7;
7476 dgst_pos2 = 2;
7477 dgst_pos3 = 6;
7478 break;
7479
7480 case 1450: hash_type = HASH_TYPE_SHA256;
7481 salt_type = SALT_TYPE_INTERN;
7482 attack_exec = ATTACK_EXEC_ON_GPU;
7483 opts_type = OPTS_TYPE_PT_GENERATE_BE
7484 | OPTS_TYPE_ST_ADD80;
7485 kern_type = KERN_TYPE_HMACSHA256_PW;
7486 dgst_size = DGST_SIZE_4_8;
7487 parse_func = hmacsha256_parse_hash;
7488 sort_by_digest = sort_by_digest_4_8;
7489 opti_type = OPTI_TYPE_ZERO_BYTE
7490 | OPTI_TYPE_NOT_ITERATED;
7491 dgst_pos0 = 3;
7492 dgst_pos1 = 7;
7493 dgst_pos2 = 2;
7494 dgst_pos3 = 6;
7495 break;
7496
7497 case 1460: hash_type = HASH_TYPE_SHA256;
7498 salt_type = SALT_TYPE_INTERN;
7499 attack_exec = ATTACK_EXEC_ON_GPU;
7500 opts_type = OPTS_TYPE_PT_GENERATE_BE
7501 | OPTS_TYPE_PT_ADD80
7502 | OPTS_TYPE_PT_ADDBITS15;
7503 kern_type = KERN_TYPE_HMACSHA256_SLT;
7504 dgst_size = DGST_SIZE_4_8;
7505 parse_func = hmacsha256_parse_hash;
7506 sort_by_digest = sort_by_digest_4_8;
7507 opti_type = OPTI_TYPE_ZERO_BYTE
7508 | OPTI_TYPE_NOT_ITERATED;
7509 dgst_pos0 = 3;
7510 dgst_pos1 = 7;
7511 dgst_pos2 = 2;
7512 dgst_pos3 = 6;
7513 break;
7514
7515 case 1500: hash_type = HASH_TYPE_DESCRYPT;
7516 salt_type = SALT_TYPE_EMBEDDED;
7517 attack_exec = ATTACK_EXEC_ON_GPU;
7518 opts_type = OPTS_TYPE_PT_GENERATE_LE
7519 | OPTS_TYPE_PT_BITSLICE;
7520 kern_type = KERN_TYPE_DESCRYPT;
7521 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7522 parse_func = descrypt_parse_hash;
7523 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7524 opti_type = OPTI_TYPE_ZERO_BYTE
7525 | OPTI_TYPE_PRECOMPUTE_PERMUT;
7526 dgst_pos0 = 0;
7527 dgst_pos1 = 1;
7528 dgst_pos2 = 2;
7529 dgst_pos3 = 3;
7530 break;
7531
7532 case 1600: hash_type = HASH_TYPE_MD5;
7533 salt_type = SALT_TYPE_EMBEDDED;
7534 attack_exec = ATTACK_EXEC_ON_CPU;
7535 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7536 kern_type = KERN_TYPE_APR1CRYPT;
7537 dgst_size = DGST_SIZE_4_4;
7538 parse_func = md5apr1_parse_hash;
7539 sort_by_digest = sort_by_digest_4_4;
7540 opti_type = OPTI_TYPE_ZERO_BYTE;
7541 dgst_pos0 = 0;
7542 dgst_pos1 = 1;
7543 dgst_pos2 = 2;
7544 dgst_pos3 = 3;
7545 break;
7546
7547 case 1700: hash_type = HASH_TYPE_SHA512;
7548 salt_type = SALT_TYPE_NONE;
7549 attack_exec = ATTACK_EXEC_ON_GPU;
7550 opts_type = OPTS_TYPE_PT_GENERATE_BE
7551 | OPTS_TYPE_PT_ADD80
7552 | OPTS_TYPE_PT_ADDBITS15;
7553 kern_type = KERN_TYPE_SHA512;
7554 dgst_size = DGST_SIZE_8_8;
7555 parse_func = sha512_parse_hash;
7556 sort_by_digest = sort_by_digest_8_8;
7557 opti_type = OPTI_TYPE_ZERO_BYTE
7558 | OPTI_TYPE_PRECOMPUTE_INIT
7559 | OPTI_TYPE_PRECOMPUTE_MERKLE
7560 | OPTI_TYPE_EARLY_SKIP
7561 | OPTI_TYPE_NOT_ITERATED
7562 | OPTI_TYPE_NOT_SALTED
7563 | OPTI_TYPE_RAW_HASH;
7564 dgst_pos0 = 14;
7565 dgst_pos1 = 15;
7566 dgst_pos2 = 6;
7567 dgst_pos3 = 7;
7568 break;
7569
7570 case 1710: hash_type = HASH_TYPE_SHA512;
7571 salt_type = SALT_TYPE_INTERN;
7572 attack_exec = ATTACK_EXEC_ON_GPU;
7573 opts_type = OPTS_TYPE_PT_GENERATE_BE
7574 | OPTS_TYPE_ST_ADD80
7575 | OPTS_TYPE_ST_ADDBITS15;
7576 kern_type = KERN_TYPE_SHA512_PWSLT;
7577 dgst_size = DGST_SIZE_8_8;
7578 parse_func = sha512s_parse_hash;
7579 sort_by_digest = sort_by_digest_8_8;
7580 opti_type = OPTI_TYPE_ZERO_BYTE
7581 | OPTI_TYPE_PRECOMPUTE_INIT
7582 | OPTI_TYPE_PRECOMPUTE_MERKLE
7583 | OPTI_TYPE_EARLY_SKIP
7584 | OPTI_TYPE_NOT_ITERATED
7585 | OPTI_TYPE_APPENDED_SALT
7586 | OPTI_TYPE_RAW_HASH;
7587 dgst_pos0 = 14;
7588 dgst_pos1 = 15;
7589 dgst_pos2 = 6;
7590 dgst_pos3 = 7;
7591 break;
7592
7593 case 1711: hash_type = HASH_TYPE_SHA512;
7594 salt_type = SALT_TYPE_EMBEDDED;
7595 attack_exec = ATTACK_EXEC_ON_GPU;
7596 opts_type = OPTS_TYPE_PT_GENERATE_BE
7597 | OPTS_TYPE_ST_ADD80
7598 | OPTS_TYPE_ST_ADDBITS15;
7599 kern_type = KERN_TYPE_SHA512_PWSLT;
7600 dgst_size = DGST_SIZE_8_8;
7601 parse_func = sha512b64s_parse_hash;
7602 sort_by_digest = sort_by_digest_8_8;
7603 opti_type = OPTI_TYPE_ZERO_BYTE
7604 | OPTI_TYPE_PRECOMPUTE_INIT
7605 | OPTI_TYPE_PRECOMPUTE_MERKLE
7606 | OPTI_TYPE_EARLY_SKIP
7607 | OPTI_TYPE_NOT_ITERATED
7608 | OPTI_TYPE_APPENDED_SALT
7609 | OPTI_TYPE_RAW_HASH;
7610 dgst_pos0 = 14;
7611 dgst_pos1 = 15;
7612 dgst_pos2 = 6;
7613 dgst_pos3 = 7;
7614 break;
7615
7616 case 1720: hash_type = HASH_TYPE_SHA512;
7617 salt_type = SALT_TYPE_INTERN;
7618 attack_exec = ATTACK_EXEC_ON_GPU;
7619 opts_type = OPTS_TYPE_PT_GENERATE_BE
7620 | OPTS_TYPE_PT_ADD80
7621 | OPTS_TYPE_PT_ADDBITS15;
7622 kern_type = KERN_TYPE_SHA512_SLTPW;
7623 dgst_size = DGST_SIZE_8_8;
7624 parse_func = sha512s_parse_hash;
7625 sort_by_digest = sort_by_digest_8_8;
7626 opti_type = OPTI_TYPE_ZERO_BYTE
7627 | OPTI_TYPE_PRECOMPUTE_INIT
7628 | OPTI_TYPE_PRECOMPUTE_MERKLE
7629 | OPTI_TYPE_EARLY_SKIP
7630 | OPTI_TYPE_NOT_ITERATED
7631 | OPTI_TYPE_PREPENDED_SALT
7632 | OPTI_TYPE_RAW_HASH;
7633 dgst_pos0 = 14;
7634 dgst_pos1 = 15;
7635 dgst_pos2 = 6;
7636 dgst_pos3 = 7;
7637 break;
7638
7639 case 1722: hash_type = HASH_TYPE_SHA512;
7640 salt_type = SALT_TYPE_EMBEDDED;
7641 attack_exec = ATTACK_EXEC_ON_GPU;
7642 opts_type = OPTS_TYPE_PT_GENERATE_BE
7643 | OPTS_TYPE_PT_ADD80
7644 | OPTS_TYPE_PT_ADDBITS15
7645 | OPTS_TYPE_ST_HEX;
7646 kern_type = KERN_TYPE_SHA512_SLTPW;
7647 dgst_size = DGST_SIZE_8_8;
7648 parse_func = osx512_parse_hash;
7649 sort_by_digest = sort_by_digest_8_8;
7650 opti_type = OPTI_TYPE_ZERO_BYTE
7651 | OPTI_TYPE_PRECOMPUTE_INIT
7652 | OPTI_TYPE_PRECOMPUTE_MERKLE
7653 | OPTI_TYPE_EARLY_SKIP
7654 | OPTI_TYPE_NOT_ITERATED
7655 | OPTI_TYPE_PREPENDED_SALT
7656 | OPTI_TYPE_RAW_HASH;
7657 dgst_pos0 = 14;
7658 dgst_pos1 = 15;
7659 dgst_pos2 = 6;
7660 dgst_pos3 = 7;
7661 break;
7662
7663 case 1730: hash_type = HASH_TYPE_SHA512;
7664 salt_type = SALT_TYPE_INTERN;
7665 attack_exec = ATTACK_EXEC_ON_GPU;
7666 opts_type = OPTS_TYPE_PT_GENERATE_BE
7667 | OPTS_TYPE_PT_UNICODE
7668 | OPTS_TYPE_ST_ADD80
7669 | OPTS_TYPE_ST_ADDBITS15;
7670 kern_type = KERN_TYPE_SHA512_PWSLTU;
7671 dgst_size = DGST_SIZE_8_8;
7672 parse_func = sha512s_parse_hash;
7673 sort_by_digest = sort_by_digest_8_8;
7674 opti_type = OPTI_TYPE_ZERO_BYTE
7675 | OPTI_TYPE_PRECOMPUTE_INIT
7676 | OPTI_TYPE_PRECOMPUTE_MERKLE
7677 | OPTI_TYPE_EARLY_SKIP
7678 | OPTI_TYPE_NOT_ITERATED
7679 | OPTI_TYPE_APPENDED_SALT
7680 | OPTI_TYPE_RAW_HASH;
7681 dgst_pos0 = 14;
7682 dgst_pos1 = 15;
7683 dgst_pos2 = 6;
7684 dgst_pos3 = 7;
7685 break;
7686
7687 case 1731: hash_type = HASH_TYPE_SHA512;
7688 salt_type = SALT_TYPE_EMBEDDED;
7689 attack_exec = ATTACK_EXEC_ON_GPU;
7690 opts_type = OPTS_TYPE_PT_GENERATE_BE
7691 | OPTS_TYPE_PT_UNICODE
7692 | OPTS_TYPE_ST_ADD80
7693 | OPTS_TYPE_ST_ADDBITS15
7694 | OPTS_TYPE_ST_HEX;
7695 kern_type = KERN_TYPE_SHA512_PWSLTU;
7696 dgst_size = DGST_SIZE_8_8;
7697 parse_func = mssql2012_parse_hash;
7698 sort_by_digest = sort_by_digest_8_8;
7699 opti_type = OPTI_TYPE_ZERO_BYTE
7700 | OPTI_TYPE_PRECOMPUTE_INIT
7701 | OPTI_TYPE_PRECOMPUTE_MERKLE
7702 | OPTI_TYPE_EARLY_SKIP
7703 | OPTI_TYPE_NOT_ITERATED
7704 | OPTI_TYPE_APPENDED_SALT
7705 | OPTI_TYPE_RAW_HASH;
7706 dgst_pos0 = 14;
7707 dgst_pos1 = 15;
7708 dgst_pos2 = 6;
7709 dgst_pos3 = 7;
7710 break;
7711
7712 case 1740: hash_type = HASH_TYPE_SHA512;
7713 salt_type = SALT_TYPE_INTERN;
7714 attack_exec = ATTACK_EXEC_ON_GPU;
7715 opts_type = OPTS_TYPE_PT_GENERATE_BE
7716 | OPTS_TYPE_PT_ADD80
7717 | OPTS_TYPE_PT_ADDBITS15
7718 | OPTS_TYPE_PT_UNICODE;
7719 kern_type = KERN_TYPE_SHA512_SLTPWU;
7720 dgst_size = DGST_SIZE_8_8;
7721 parse_func = sha512s_parse_hash;
7722 sort_by_digest = sort_by_digest_8_8;
7723 opti_type = OPTI_TYPE_ZERO_BYTE
7724 | OPTI_TYPE_PRECOMPUTE_INIT
7725 | OPTI_TYPE_PRECOMPUTE_MERKLE
7726 | OPTI_TYPE_EARLY_SKIP
7727 | OPTI_TYPE_NOT_ITERATED
7728 | OPTI_TYPE_PREPENDED_SALT
7729 | OPTI_TYPE_RAW_HASH;
7730 dgst_pos0 = 14;
7731 dgst_pos1 = 15;
7732 dgst_pos2 = 6;
7733 dgst_pos3 = 7;
7734 break;
7735
7736 case 1750: hash_type = HASH_TYPE_SHA512;
7737 salt_type = SALT_TYPE_INTERN;
7738 attack_exec = ATTACK_EXEC_ON_GPU;
7739 opts_type = OPTS_TYPE_PT_GENERATE_BE
7740 | OPTS_TYPE_ST_ADD80;
7741 kern_type = KERN_TYPE_HMACSHA512_PW;
7742 dgst_size = DGST_SIZE_8_8;
7743 parse_func = hmacsha512_parse_hash;
7744 sort_by_digest = sort_by_digest_8_8;
7745 opti_type = OPTI_TYPE_ZERO_BYTE
7746 | OPTI_TYPE_NOT_ITERATED;
7747 dgst_pos0 = 14;
7748 dgst_pos1 = 15;
7749 dgst_pos2 = 6;
7750 dgst_pos3 = 7;
7751 break;
7752
7753 case 1760: hash_type = HASH_TYPE_SHA512;
7754 salt_type = SALT_TYPE_INTERN;
7755 attack_exec = ATTACK_EXEC_ON_GPU;
7756 opts_type = OPTS_TYPE_PT_GENERATE_BE
7757 | OPTS_TYPE_PT_ADD80
7758 | OPTS_TYPE_PT_ADDBITS15;
7759 kern_type = KERN_TYPE_HMACSHA512_SLT;
7760 dgst_size = DGST_SIZE_8_8;
7761 parse_func = hmacsha512_parse_hash;
7762 sort_by_digest = sort_by_digest_8_8;
7763 opti_type = OPTI_TYPE_ZERO_BYTE
7764 | OPTI_TYPE_NOT_ITERATED;
7765 dgst_pos0 = 14;
7766 dgst_pos1 = 15;
7767 dgst_pos2 = 6;
7768 dgst_pos3 = 7;
7769 break;
7770
7771 case 1800: hash_type = HASH_TYPE_SHA512;
7772 salt_type = SALT_TYPE_EMBEDDED;
7773 attack_exec = ATTACK_EXEC_ON_CPU;
7774 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
7775 kern_type = KERN_TYPE_SHA512CRYPT;
7776 dgst_size = DGST_SIZE_8_8;
7777 parse_func = sha512crypt_parse_hash;
7778 sort_by_digest = sort_by_digest_8_8;
7779 opti_type = OPTI_TYPE_ZERO_BYTE;
7780 dgst_pos0 = 0;
7781 dgst_pos1 = 1;
7782 dgst_pos2 = 2;
7783 dgst_pos3 = 3;
7784 break;
7785
7786 case 2100: hash_type = HASH_TYPE_DCC2;
7787 salt_type = SALT_TYPE_EMBEDDED;
7788 attack_exec = ATTACK_EXEC_ON_CPU;
7789 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
7790 | OPTS_TYPE_ST_LOWER
7791 | OPTS_TYPE_ST_UNICODE;
7792 kern_type = KERN_TYPE_DCC2;
7793 dgst_size = DGST_SIZE_4_4;
7794 parse_func = dcc2_parse_hash;
7795 sort_by_digest = sort_by_digest_4_4;
7796 opti_type = OPTI_TYPE_ZERO_BYTE;
7797 dgst_pos0 = 0;
7798 dgst_pos1 = 1;
7799 dgst_pos2 = 2;
7800 dgst_pos3 = 3;
7801 break;
7802
7803 case 2400: hash_type = HASH_TYPE_MD5;
7804 salt_type = SALT_TYPE_NONE;
7805 attack_exec = ATTACK_EXEC_ON_GPU;
7806 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7807 kern_type = KERN_TYPE_MD5PIX;
7808 dgst_size = DGST_SIZE_4_4;
7809 parse_func = md5pix_parse_hash;
7810 sort_by_digest = sort_by_digest_4_4;
7811 opti_type = OPTI_TYPE_ZERO_BYTE
7812 | OPTI_TYPE_PRECOMPUTE_INIT
7813 | OPTI_TYPE_PRECOMPUTE_MERKLE
7814 | OPTI_TYPE_EARLY_SKIP
7815 | OPTI_TYPE_NOT_ITERATED
7816 | OPTI_TYPE_NOT_SALTED;
7817 dgst_pos0 = 0;
7818 dgst_pos1 = 3;
7819 dgst_pos2 = 2;
7820 dgst_pos3 = 1;
7821 break;
7822
7823 case 2410: hash_type = HASH_TYPE_MD5;
7824 salt_type = SALT_TYPE_INTERN;
7825 attack_exec = ATTACK_EXEC_ON_GPU;
7826 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7827 kern_type = KERN_TYPE_MD5ASA;
7828 dgst_size = DGST_SIZE_4_4;
7829 parse_func = md5asa_parse_hash;
7830 sort_by_digest = sort_by_digest_4_4;
7831 opti_type = OPTI_TYPE_ZERO_BYTE
7832 | OPTI_TYPE_PRECOMPUTE_INIT
7833 | OPTI_TYPE_PRECOMPUTE_MERKLE
7834 | OPTI_TYPE_EARLY_SKIP
7835 | OPTI_TYPE_NOT_ITERATED;
7836 dgst_pos0 = 0;
7837 dgst_pos1 = 3;
7838 dgst_pos2 = 2;
7839 dgst_pos3 = 1;
7840 break;
7841
7842 case 2500: hash_type = HASH_TYPE_WPA;
7843 salt_type = SALT_TYPE_EMBEDDED;
7844 attack_exec = ATTACK_EXEC_ON_CPU;
7845 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
7846 kern_type = KERN_TYPE_WPA;
7847 dgst_size = DGST_SIZE_4_4;
7848 parse_func = wpa_parse_hash;
7849 sort_by_digest = sort_by_digest_4_4;
7850 opti_type = OPTI_TYPE_ZERO_BYTE;
7851 dgst_pos0 = 0;
7852 dgst_pos1 = 1;
7853 dgst_pos2 = 2;
7854 dgst_pos3 = 3;
7855 break;
7856
7857 case 2600: hash_type = HASH_TYPE_MD5;
7858 salt_type = SALT_TYPE_VIRTUAL;
7859 attack_exec = ATTACK_EXEC_ON_GPU;
7860 opts_type = OPTS_TYPE_PT_GENERATE_LE
7861 | OPTS_TYPE_PT_ADD80
7862 | OPTS_TYPE_PT_ADDBITS14
7863 | OPTS_TYPE_ST_ADD80;
7864 kern_type = KERN_TYPE_MD55_PWSLT1;
7865 dgst_size = DGST_SIZE_4_4;
7866 parse_func = md5md5_parse_hash;
7867 sort_by_digest = sort_by_digest_4_4;
7868 opti_type = OPTI_TYPE_ZERO_BYTE
7869 | OPTI_TYPE_PRECOMPUTE_INIT
7870 | OPTI_TYPE_PRECOMPUTE_MERKLE
7871 | OPTI_TYPE_EARLY_SKIP;
7872 dgst_pos0 = 0;
7873 dgst_pos1 = 3;
7874 dgst_pos2 = 2;
7875 dgst_pos3 = 1;
7876 break;
7877
7878 case 2611: hash_type = HASH_TYPE_MD5;
7879 salt_type = SALT_TYPE_INTERN;
7880 attack_exec = ATTACK_EXEC_ON_GPU;
7881 opts_type = OPTS_TYPE_PT_GENERATE_LE
7882 | OPTS_TYPE_PT_ADD80
7883 | OPTS_TYPE_PT_ADDBITS14
7884 | OPTS_TYPE_ST_ADD80;
7885 kern_type = KERN_TYPE_MD55_PWSLT1;
7886 dgst_size = DGST_SIZE_4_4;
7887 parse_func = vb3_parse_hash;
7888 sort_by_digest = sort_by_digest_4_4;
7889 opti_type = OPTI_TYPE_ZERO_BYTE
7890 | OPTI_TYPE_PRECOMPUTE_INIT
7891 | OPTI_TYPE_PRECOMPUTE_MERKLE
7892 | OPTI_TYPE_EARLY_SKIP;
7893 dgst_pos0 = 0;
7894 dgst_pos1 = 3;
7895 dgst_pos2 = 2;
7896 dgst_pos3 = 1;
7897 break;
7898
7899 case 2612: hash_type = HASH_TYPE_MD5;
7900 salt_type = SALT_TYPE_EMBEDDED;
7901 attack_exec = ATTACK_EXEC_ON_GPU;
7902 opts_type = OPTS_TYPE_PT_GENERATE_LE
7903 | OPTS_TYPE_PT_ADD80
7904 | OPTS_TYPE_PT_ADDBITS14
7905 | OPTS_TYPE_ST_ADD80
7906 | OPTS_TYPE_ST_HEX;
7907 kern_type = KERN_TYPE_MD55_PWSLT1;
7908 dgst_size = DGST_SIZE_4_4;
7909 parse_func = phps_parse_hash;
7910 sort_by_digest = sort_by_digest_4_4;
7911 opti_type = OPTI_TYPE_ZERO_BYTE
7912 | OPTI_TYPE_PRECOMPUTE_INIT
7913 | OPTI_TYPE_PRECOMPUTE_MERKLE
7914 | OPTI_TYPE_EARLY_SKIP;
7915 dgst_pos0 = 0;
7916 dgst_pos1 = 3;
7917 dgst_pos2 = 2;
7918 dgst_pos3 = 1;
7919 break;
7920
7921 case 2711: hash_type = HASH_TYPE_MD5;
7922 salt_type = SALT_TYPE_INTERN;
7923 attack_exec = ATTACK_EXEC_ON_GPU;
7924 opts_type = OPTS_TYPE_PT_GENERATE_LE
7925 | OPTS_TYPE_PT_ADD80
7926 | OPTS_TYPE_PT_ADDBITS14
7927 | OPTS_TYPE_ST_ADD80;
7928 kern_type = KERN_TYPE_MD55_PWSLT2;
7929 dgst_size = DGST_SIZE_4_4;
7930 parse_func = vb30_parse_hash;
7931 sort_by_digest = sort_by_digest_4_4;
7932 opti_type = OPTI_TYPE_ZERO_BYTE
7933 | OPTI_TYPE_PRECOMPUTE_INIT
7934 | OPTI_TYPE_EARLY_SKIP;
7935 dgst_pos0 = 0;
7936 dgst_pos1 = 3;
7937 dgst_pos2 = 2;
7938 dgst_pos3 = 1;
7939 break;
7940
7941 case 2811: hash_type = HASH_TYPE_MD5;
7942 salt_type = SALT_TYPE_INTERN;
7943 attack_exec = ATTACK_EXEC_ON_GPU;
7944 opts_type = OPTS_TYPE_PT_GENERATE_LE
7945 | OPTS_TYPE_PT_ADD80
7946 | OPTS_TYPE_PT_ADDBITS14;
7947 kern_type = KERN_TYPE_MD55_SLTPW;
7948 dgst_size = DGST_SIZE_4_4;
7949 parse_func = ipb2_parse_hash;
7950 sort_by_digest = sort_by_digest_4_4;
7951 opti_type = OPTI_TYPE_ZERO_BYTE
7952 | OPTI_TYPE_PRECOMPUTE_INIT
7953 | OPTI_TYPE_EARLY_SKIP;
7954 dgst_pos0 = 0;
7955 dgst_pos1 = 3;
7956 dgst_pos2 = 2;
7957 dgst_pos3 = 1;
7958 break;
7959
7960 case 3000: hash_type = HASH_TYPE_LM;
7961 salt_type = SALT_TYPE_NONE;
7962 attack_exec = ATTACK_EXEC_ON_GPU;
7963 opts_type = OPTS_TYPE_PT_GENERATE_LE
7964 | OPTS_TYPE_PT_UPPER
7965 | OPTS_TYPE_PT_BITSLICE;
7966 kern_type = KERN_TYPE_LM;
7967 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7968 parse_func = lm_parse_hash;
7969 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7970 opti_type = OPTI_TYPE_ZERO_BYTE
7971 | OPTI_TYPE_PRECOMPUTE_PERMUT;
7972 dgst_pos0 = 0;
7973 dgst_pos1 = 1;
7974 dgst_pos2 = 2;
7975 dgst_pos3 = 3;
7976 break;
7977
7978 case 3100: hash_type = HASH_TYPE_ORACLEH;
7979 salt_type = SALT_TYPE_INTERN;
7980 attack_exec = ATTACK_EXEC_ON_GPU;
7981 opts_type = OPTS_TYPE_PT_GENERATE_LE
7982 | OPTS_TYPE_PT_UPPER
7983 | OPTS_TYPE_ST_UPPER;
7984 kern_type = KERN_TYPE_ORACLEH;
7985 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7986 parse_func = oracleh_parse_hash;
7987 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7988 opti_type = OPTI_TYPE_ZERO_BYTE;
7989 dgst_pos0 = 0;
7990 dgst_pos1 = 1;
7991 dgst_pos2 = 2;
7992 dgst_pos3 = 3;
7993 break;
7994
7995 case 3200: hash_type = HASH_TYPE_BCRYPT;
7996 salt_type = SALT_TYPE_EMBEDDED;
7997 attack_exec = ATTACK_EXEC_ON_CPU;
7998 opts_type = OPTS_TYPE_PT_GENERATE_LE
7999 | OPTS_TYPE_ST_GENERATE_LE;
8000 kern_type = KERN_TYPE_BCRYPT;
8001 dgst_size = DGST_SIZE_4_6;
8002 parse_func = bcrypt_parse_hash;
8003 sort_by_digest = sort_by_digest_4_6;
8004 opti_type = OPTI_TYPE_ZERO_BYTE;
8005 dgst_pos0 = 0;
8006 dgst_pos1 = 1;
8007 dgst_pos2 = 2;
8008 dgst_pos3 = 3;
8009 break;
8010
8011 case 3710: hash_type = HASH_TYPE_MD5;
8012 salt_type = SALT_TYPE_INTERN;
8013 attack_exec = ATTACK_EXEC_ON_GPU;
8014 opts_type = OPTS_TYPE_PT_GENERATE_LE
8015 | OPTS_TYPE_PT_ADD80
8016 | OPTS_TYPE_PT_ADDBITS14;
8017 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8018 dgst_size = DGST_SIZE_4_4;
8019 parse_func = md5s_parse_hash;
8020 sort_by_digest = sort_by_digest_4_4;
8021 opti_type = OPTI_TYPE_ZERO_BYTE
8022 | OPTI_TYPE_PRECOMPUTE_INIT
8023 | OPTI_TYPE_PRECOMPUTE_MERKLE
8024 | OPTI_TYPE_EARLY_SKIP;
8025 dgst_pos0 = 0;
8026 dgst_pos1 = 3;
8027 dgst_pos2 = 2;
8028 dgst_pos3 = 1;
8029 break;
8030
8031 case 3711: hash_type = HASH_TYPE_MD5;
8032 salt_type = SALT_TYPE_EMBEDDED;
8033 attack_exec = ATTACK_EXEC_ON_GPU;
8034 opts_type = OPTS_TYPE_PT_GENERATE_LE
8035 | OPTS_TYPE_PT_ADD80
8036 | OPTS_TYPE_PT_ADDBITS14;
8037 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8038 dgst_size = DGST_SIZE_4_4;
8039 parse_func = mediawiki_b_parse_hash;
8040 sort_by_digest = sort_by_digest_4_4;
8041 opti_type = OPTI_TYPE_ZERO_BYTE
8042 | OPTI_TYPE_PRECOMPUTE_INIT
8043 | OPTI_TYPE_PRECOMPUTE_MERKLE
8044 | OPTI_TYPE_EARLY_SKIP;
8045 dgst_pos0 = 0;
8046 dgst_pos1 = 3;
8047 dgst_pos2 = 2;
8048 dgst_pos3 = 1;
8049 break;
8050
8051 case 3800: hash_type = HASH_TYPE_MD5;
8052 salt_type = SALT_TYPE_INTERN;
8053 attack_exec = ATTACK_EXEC_ON_GPU;
8054 opts_type = OPTS_TYPE_PT_GENERATE_LE
8055 | OPTS_TYPE_ST_ADDBITS14;
8056 kern_type = KERN_TYPE_MD5_SLT_PW_SLT;
8057 dgst_size = DGST_SIZE_4_4;
8058 parse_func = md5s_parse_hash;
8059 sort_by_digest = sort_by_digest_4_4;
8060 opti_type = OPTI_TYPE_ZERO_BYTE
8061 | OPTI_TYPE_PRECOMPUTE_INIT
8062 | OPTI_TYPE_PRECOMPUTE_MERKLE
8063 | OPTI_TYPE_EARLY_SKIP
8064 | OPTI_TYPE_NOT_ITERATED
8065 | OPTI_TYPE_RAW_HASH;
8066 dgst_pos0 = 0;
8067 dgst_pos1 = 3;
8068 dgst_pos2 = 2;
8069 dgst_pos3 = 1;
8070 break;
8071
8072 case 4300: hash_type = HASH_TYPE_MD5;
8073 salt_type = SALT_TYPE_VIRTUAL;
8074 attack_exec = ATTACK_EXEC_ON_GPU;
8075 opts_type = OPTS_TYPE_PT_GENERATE_LE
8076 | OPTS_TYPE_PT_ADD80
8077 | OPTS_TYPE_PT_ADDBITS14
8078 | OPTS_TYPE_ST_ADD80;
8079 kern_type = KERN_TYPE_MD5U5_PWSLT1;
8080 dgst_size = DGST_SIZE_4_4;
8081 parse_func = md5md5_parse_hash;
8082 sort_by_digest = sort_by_digest_4_4;
8083 opti_type = OPTI_TYPE_ZERO_BYTE
8084 | OPTI_TYPE_PRECOMPUTE_INIT
8085 | OPTI_TYPE_PRECOMPUTE_MERKLE
8086 | OPTI_TYPE_EARLY_SKIP;
8087 dgst_pos0 = 0;
8088 dgst_pos1 = 3;
8089 dgst_pos2 = 2;
8090 dgst_pos3 = 1;
8091 break;
8092
8093
8094 case 4400: hash_type = HASH_TYPE_MD5;
8095 salt_type = SALT_TYPE_NONE;
8096 attack_exec = ATTACK_EXEC_ON_GPU;
8097 opts_type = OPTS_TYPE_PT_GENERATE_BE
8098 | OPTS_TYPE_PT_ADD80
8099 | OPTS_TYPE_PT_ADDBITS15;
8100 kern_type = KERN_TYPE_MD5_SHA1;
8101 dgst_size = DGST_SIZE_4_4;
8102 parse_func = md5_parse_hash;
8103 sort_by_digest = sort_by_digest_4_4;
8104 opti_type = OPTI_TYPE_ZERO_BYTE
8105 | OPTI_TYPE_PRECOMPUTE_INIT
8106 | OPTI_TYPE_PRECOMPUTE_MERKLE
8107 | OPTI_TYPE_EARLY_SKIP
8108 | OPTI_TYPE_NOT_ITERATED
8109 | OPTI_TYPE_NOT_SALTED
8110 | OPTI_TYPE_RAW_HASH;
8111 dgst_pos0 = 0;
8112 dgst_pos1 = 3;
8113 dgst_pos2 = 2;
8114 dgst_pos3 = 1;
8115 break;
8116
8117 case 4500: hash_type = HASH_TYPE_SHA1;
8118 salt_type = SALT_TYPE_NONE;
8119 attack_exec = ATTACK_EXEC_ON_GPU;
8120 opts_type = OPTS_TYPE_PT_GENERATE_BE
8121 | OPTS_TYPE_PT_ADD80
8122 | OPTS_TYPE_PT_ADDBITS15;
8123 kern_type = KERN_TYPE_SHA11;
8124 dgst_size = DGST_SIZE_4_5;
8125 parse_func = sha1_parse_hash;
8126 sort_by_digest = sort_by_digest_4_5;
8127 opti_type = OPTI_TYPE_ZERO_BYTE
8128 | OPTI_TYPE_PRECOMPUTE_INIT
8129 | OPTI_TYPE_PRECOMPUTE_MERKLE
8130 | OPTI_TYPE_EARLY_SKIP
8131 | OPTI_TYPE_NOT_SALTED;
8132 dgst_pos0 = 3;
8133 dgst_pos1 = 4;
8134 dgst_pos2 = 2;
8135 dgst_pos3 = 1;
8136 break;
8137
8138 case 4700: hash_type = HASH_TYPE_SHA1;
8139 salt_type = SALT_TYPE_NONE;
8140 attack_exec = ATTACK_EXEC_ON_GPU;
8141 opts_type = OPTS_TYPE_PT_GENERATE_LE
8142 | OPTS_TYPE_PT_ADD80
8143 | OPTS_TYPE_PT_ADDBITS14;
8144 kern_type = KERN_TYPE_SHA1_MD5;
8145 dgst_size = DGST_SIZE_4_5;
8146 parse_func = sha1_parse_hash;
8147 sort_by_digest = sort_by_digest_4_5;
8148 opti_type = OPTI_TYPE_ZERO_BYTE
8149 | OPTI_TYPE_PRECOMPUTE_INIT
8150 | OPTI_TYPE_PRECOMPUTE_MERKLE
8151 | OPTI_TYPE_EARLY_SKIP
8152 | OPTI_TYPE_NOT_ITERATED
8153 | OPTI_TYPE_NOT_SALTED
8154 | OPTI_TYPE_RAW_HASH;
8155 dgst_pos0 = 3;
8156 dgst_pos1 = 4;
8157 dgst_pos2 = 2;
8158 dgst_pos3 = 1;
8159 break;
8160
8161 case 4800: hash_type = HASH_TYPE_MD5;
8162 salt_type = SALT_TYPE_EMBEDDED;
8163 attack_exec = ATTACK_EXEC_ON_GPU;
8164 opts_type = OPTS_TYPE_PT_GENERATE_LE
8165 | OPTS_TYPE_PT_ADDBITS14;
8166 kern_type = KERN_TYPE_MD5_CHAP;
8167 dgst_size = DGST_SIZE_4_4;
8168 parse_func = chap_parse_hash;
8169 sort_by_digest = sort_by_digest_4_4;
8170 opti_type = OPTI_TYPE_ZERO_BYTE
8171 | OPTI_TYPE_PRECOMPUTE_INIT
8172 | OPTI_TYPE_PRECOMPUTE_MERKLE
8173 | OPTI_TYPE_MEET_IN_MIDDLE
8174 | OPTI_TYPE_EARLY_SKIP
8175 | OPTI_TYPE_NOT_ITERATED
8176 | OPTI_TYPE_RAW_HASH;
8177 dgst_pos0 = 0;
8178 dgst_pos1 = 3;
8179 dgst_pos2 = 2;
8180 dgst_pos3 = 1;
8181 break;
8182
8183 case 4900: hash_type = HASH_TYPE_SHA1;
8184 salt_type = SALT_TYPE_INTERN;
8185 attack_exec = ATTACK_EXEC_ON_GPU;
8186 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8187 kern_type = KERN_TYPE_SHA1_SLT_PW_SLT;
8188 dgst_size = DGST_SIZE_4_5;
8189 parse_func = sha1s_parse_hash;
8190 sort_by_digest = sort_by_digest_4_5;
8191 opti_type = OPTI_TYPE_ZERO_BYTE
8192 | OPTI_TYPE_PRECOMPUTE_INIT
8193 | OPTI_TYPE_PRECOMPUTE_MERKLE
8194 | OPTI_TYPE_EARLY_SKIP;
8195 dgst_pos0 = 3;
8196 dgst_pos1 = 4;
8197 dgst_pos2 = 2;
8198 dgst_pos3 = 1;
8199 break;
8200
8201 case 5000: hash_type = HASH_TYPE_KECCAK;
8202 salt_type = SALT_TYPE_EMBEDDED;
8203 attack_exec = ATTACK_EXEC_ON_GPU;
8204 opts_type = OPTS_TYPE_PT_GENERATE_LE
8205 | OPTS_TYPE_PT_ADD01;
8206 kern_type = KERN_TYPE_KECCAK;
8207 dgst_size = DGST_SIZE_8_25;
8208 parse_func = keccak_parse_hash;
8209 sort_by_digest = sort_by_digest_8_25;
8210 opti_type = OPTI_TYPE_ZERO_BYTE
8211 | OPTI_TYPE_RAW_HASH;
8212 dgst_pos0 = 2;
8213 dgst_pos1 = 3;
8214 dgst_pos2 = 4;
8215 dgst_pos3 = 5;
8216 break;
8217
8218 case 5100: hash_type = HASH_TYPE_MD5H;
8219 salt_type = SALT_TYPE_NONE;
8220 attack_exec = ATTACK_EXEC_ON_GPU;
8221 opts_type = OPTS_TYPE_PT_GENERATE_LE
8222 | OPTS_TYPE_PT_ADD80
8223 | OPTS_TYPE_PT_ADDBITS14;
8224 kern_type = KERN_TYPE_MD5H;
8225 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8226 parse_func = md5half_parse_hash;
8227 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8228 opti_type = OPTI_TYPE_ZERO_BYTE
8229 | OPTI_TYPE_RAW_HASH;
8230 dgst_pos0 = 0;
8231 dgst_pos1 = 1;
8232 dgst_pos2 = 2;
8233 dgst_pos3 = 3;
8234 break;
8235
8236 case 5200: hash_type = HASH_TYPE_SHA256;
8237 salt_type = SALT_TYPE_EMBEDDED;
8238 attack_exec = ATTACK_EXEC_ON_CPU;
8239 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8240 kern_type = KERN_TYPE_PSAFE3;
8241 dgst_size = DGST_SIZE_4_8;
8242 parse_func = psafe3_parse_hash;
8243 sort_by_digest = sort_by_digest_4_8;
8244 opti_type = OPTI_TYPE_ZERO_BYTE;
8245 dgst_pos0 = 0;
8246 dgst_pos1 = 1;
8247 dgst_pos2 = 2;
8248 dgst_pos3 = 3;
8249 break;
8250
8251 case 5300: hash_type = HASH_TYPE_MD5;
8252 salt_type = SALT_TYPE_EMBEDDED;
8253 attack_exec = ATTACK_EXEC_ON_GPU;
8254 opts_type = OPTS_TYPE_PT_GENERATE_LE
8255 | OPTS_TYPE_ST_ADD80;
8256 kern_type = KERN_TYPE_IKEPSK_MD5;
8257 dgst_size = DGST_SIZE_4_4;
8258 parse_func = ikepsk_md5_parse_hash;
8259 sort_by_digest = sort_by_digest_4_4;
8260 opti_type = OPTI_TYPE_ZERO_BYTE;
8261 dgst_pos0 = 0;
8262 dgst_pos1 = 3;
8263 dgst_pos2 = 2;
8264 dgst_pos3 = 1;
8265 break;
8266
8267 case 5400: hash_type = HASH_TYPE_SHA1;
8268 salt_type = SALT_TYPE_EMBEDDED;
8269 attack_exec = ATTACK_EXEC_ON_GPU;
8270 opts_type = OPTS_TYPE_PT_GENERATE_BE
8271 | OPTS_TYPE_ST_ADD80;
8272 kern_type = KERN_TYPE_IKEPSK_SHA1;
8273 dgst_size = DGST_SIZE_4_5;
8274 parse_func = ikepsk_sha1_parse_hash;
8275 sort_by_digest = sort_by_digest_4_5;
8276 opti_type = OPTI_TYPE_ZERO_BYTE;
8277 dgst_pos0 = 3;
8278 dgst_pos1 = 4;
8279 dgst_pos2 = 2;
8280 dgst_pos3 = 1;
8281 break;
8282
8283 case 5500: hash_type = HASH_TYPE_NETNTLM;
8284 salt_type = SALT_TYPE_EMBEDDED;
8285 attack_exec = ATTACK_EXEC_ON_GPU;
8286 opts_type = OPTS_TYPE_PT_GENERATE_LE
8287 | OPTS_TYPE_PT_ADD80
8288 | OPTS_TYPE_PT_ADDBITS14
8289 | OPTS_TYPE_PT_UNICODE
8290 | OPTS_TYPE_ST_HEX;
8291 kern_type = KERN_TYPE_NETNTLMv1;
8292 dgst_size = DGST_SIZE_4_4;
8293 parse_func = netntlmv1_parse_hash;
8294 sort_by_digest = sort_by_digest_4_4;
8295 opti_type = OPTI_TYPE_ZERO_BYTE
8296 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8297 dgst_pos0 = 0;
8298 dgst_pos1 = 1;
8299 dgst_pos2 = 2;
8300 dgst_pos3 = 3;
8301 break;
8302
8303 case 5600: hash_type = HASH_TYPE_MD5;
8304 salt_type = SALT_TYPE_EMBEDDED;
8305 attack_exec = ATTACK_EXEC_ON_GPU;
8306 opts_type = OPTS_TYPE_PT_GENERATE_LE
8307 | OPTS_TYPE_PT_ADD80
8308 | OPTS_TYPE_PT_ADDBITS14
8309 | OPTS_TYPE_PT_UNICODE;
8310 kern_type = KERN_TYPE_NETNTLMv2;
8311 dgst_size = DGST_SIZE_4_4;
8312 parse_func = netntlmv2_parse_hash;
8313 sort_by_digest = sort_by_digest_4_4;
8314 opti_type = OPTI_TYPE_ZERO_BYTE;
8315 dgst_pos0 = 0;
8316 dgst_pos1 = 3;
8317 dgst_pos2 = 2;
8318 dgst_pos3 = 1;
8319 break;
8320
8321 case 5700: hash_type = HASH_TYPE_SHA256;
8322 salt_type = SALT_TYPE_NONE;
8323 attack_exec = ATTACK_EXEC_ON_GPU;
8324 opts_type = OPTS_TYPE_PT_GENERATE_BE
8325 | OPTS_TYPE_PT_ADD80
8326 | OPTS_TYPE_PT_ADDBITS15;
8327 kern_type = KERN_TYPE_SHA256;
8328 dgst_size = DGST_SIZE_4_8;
8329 parse_func = cisco4_parse_hash;
8330 sort_by_digest = sort_by_digest_4_8;
8331 opti_type = OPTI_TYPE_ZERO_BYTE
8332 | OPTI_TYPE_PRECOMPUTE_INIT
8333 | OPTI_TYPE_PRECOMPUTE_MERKLE
8334 | OPTI_TYPE_EARLY_SKIP
8335 | OPTI_TYPE_NOT_ITERATED
8336 | OPTI_TYPE_NOT_SALTED
8337 | OPTI_TYPE_RAW_HASH;
8338 dgst_pos0 = 3;
8339 dgst_pos1 = 7;
8340 dgst_pos2 = 2;
8341 dgst_pos3 = 6;
8342 break;
8343
8344 case 5800: hash_type = HASH_TYPE_SHA1;
8345 salt_type = SALT_TYPE_INTERN;
8346 attack_exec = ATTACK_EXEC_ON_CPU;
8347 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
8348 | OPTS_TYPE_ST_ADD80;
8349 kern_type = KERN_TYPE_ANDROIDPIN;
8350 dgst_size = DGST_SIZE_4_5;
8351 parse_func = androidpin_parse_hash;
8352 sort_by_digest = sort_by_digest_4_5;
8353 opti_type = OPTI_TYPE_ZERO_BYTE;
8354 dgst_pos0 = 0;
8355 dgst_pos1 = 1;
8356 dgst_pos2 = 2;
8357 dgst_pos3 = 3;
8358 break;
8359
8360 case 6000: hash_type = HASH_TYPE_RIPEMD160;
8361 salt_type = SALT_TYPE_NONE;
8362 attack_exec = ATTACK_EXEC_ON_GPU;
8363 opts_type = OPTS_TYPE_PT_GENERATE_LE
8364 | OPTS_TYPE_PT_ADD80;
8365 kern_type = KERN_TYPE_RIPEMD160;
8366 dgst_size = DGST_SIZE_4_5;
8367 parse_func = ripemd160_parse_hash;
8368 sort_by_digest = sort_by_digest_4_5;
8369 opti_type = OPTI_TYPE_ZERO_BYTE;
8370 dgst_pos0 = 0;
8371 dgst_pos1 = 1;
8372 dgst_pos2 = 2;
8373 dgst_pos3 = 3;
8374 break;
8375
8376 case 6100: hash_type = HASH_TYPE_WHIRLPOOL;
8377 salt_type = SALT_TYPE_NONE;
8378 attack_exec = ATTACK_EXEC_ON_GPU;
8379 opts_type = OPTS_TYPE_PT_GENERATE_BE
8380 | OPTS_TYPE_PT_ADD80;
8381 kern_type = KERN_TYPE_WHIRLPOOL;
8382 dgst_size = DGST_SIZE_4_16;
8383 parse_func = whirlpool_parse_hash;
8384 sort_by_digest = sort_by_digest_4_16;
8385 opti_type = OPTI_TYPE_ZERO_BYTE;
8386 dgst_pos0 = 0;
8387 dgst_pos1 = 1;
8388 dgst_pos2 = 2;
8389 dgst_pos3 = 3;
8390 break;
8391
8392 case 6211: hash_type = HASH_TYPE_RIPEMD160;
8393 salt_type = SALT_TYPE_EMBEDDED;
8394 attack_exec = ATTACK_EXEC_ON_CPU;
8395 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8396 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
8397 dgst_size = DGST_SIZE_4_5;
8398 parse_func = truecrypt_parse_hash_2k;
8399 sort_by_digest = sort_by_digest_4_5;
8400 opti_type = OPTI_TYPE_ZERO_BYTE;
8401 dgst_pos0 = 0;
8402 dgst_pos1 = 1;
8403 dgst_pos2 = 2;
8404 dgst_pos3 = 3;
8405 break;
8406
8407 case 6212: hash_type = HASH_TYPE_RIPEMD160;
8408 salt_type = SALT_TYPE_EMBEDDED;
8409 attack_exec = ATTACK_EXEC_ON_CPU;
8410 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8411 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
8412 dgst_size = DGST_SIZE_4_5;
8413 parse_func = truecrypt_parse_hash_2k;
8414 sort_by_digest = sort_by_digest_4_5;
8415 opti_type = OPTI_TYPE_ZERO_BYTE;
8416 dgst_pos0 = 0;
8417 dgst_pos1 = 1;
8418 dgst_pos2 = 2;
8419 dgst_pos3 = 3;
8420 break;
8421
8422 case 6213: hash_type = HASH_TYPE_RIPEMD160;
8423 salt_type = SALT_TYPE_EMBEDDED;
8424 attack_exec = ATTACK_EXEC_ON_CPU;
8425 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8426 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
8427 dgst_size = DGST_SIZE_4_5;
8428 parse_func = truecrypt_parse_hash_2k;
8429 sort_by_digest = sort_by_digest_4_5;
8430 opti_type = OPTI_TYPE_ZERO_BYTE;
8431 dgst_pos0 = 0;
8432 dgst_pos1 = 1;
8433 dgst_pos2 = 2;
8434 dgst_pos3 = 3;
8435 break;
8436
8437 case 6221: hash_type = HASH_TYPE_SHA512;
8438 salt_type = SALT_TYPE_EMBEDDED;
8439 attack_exec = ATTACK_EXEC_ON_CPU;
8440 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8441 kern_type = KERN_TYPE_TCSHA512_XTS512;
8442 dgst_size = DGST_SIZE_8_8;
8443 parse_func = truecrypt_parse_hash_1k;
8444 sort_by_digest = sort_by_digest_8_8;
8445 opti_type = OPTI_TYPE_ZERO_BYTE;
8446 dgst_pos0 = 0;
8447 dgst_pos1 = 1;
8448 dgst_pos2 = 2;
8449 dgst_pos3 = 3;
8450 break;
8451
8452 case 6222: hash_type = HASH_TYPE_SHA512;
8453 salt_type = SALT_TYPE_EMBEDDED;
8454 attack_exec = ATTACK_EXEC_ON_CPU;
8455 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8456 kern_type = KERN_TYPE_TCSHA512_XTS1024;
8457 dgst_size = DGST_SIZE_8_8;
8458 parse_func = truecrypt_parse_hash_1k;
8459 sort_by_digest = sort_by_digest_8_8;
8460 opti_type = OPTI_TYPE_ZERO_BYTE;
8461 dgst_pos0 = 0;
8462 dgst_pos1 = 1;
8463 dgst_pos2 = 2;
8464 dgst_pos3 = 3;
8465 break;
8466
8467 case 6223: hash_type = HASH_TYPE_SHA512;
8468 salt_type = SALT_TYPE_EMBEDDED;
8469 attack_exec = ATTACK_EXEC_ON_CPU;
8470 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8471 kern_type = KERN_TYPE_TCSHA512_XTS1536;
8472 dgst_size = DGST_SIZE_8_8;
8473 parse_func = truecrypt_parse_hash_1k;
8474 sort_by_digest = sort_by_digest_8_8;
8475 opti_type = OPTI_TYPE_ZERO_BYTE;
8476 dgst_pos0 = 0;
8477 dgst_pos1 = 1;
8478 dgst_pos2 = 2;
8479 dgst_pos3 = 3;
8480 break;
8481
8482 case 6231: hash_type = HASH_TYPE_WHIRLPOOL;
8483 salt_type = SALT_TYPE_EMBEDDED;
8484 attack_exec = ATTACK_EXEC_ON_CPU;
8485 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8486 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS512;
8487 dgst_size = DGST_SIZE_4_8;
8488 parse_func = truecrypt_parse_hash_1k;
8489 sort_by_digest = sort_by_digest_4_8;
8490 opti_type = OPTI_TYPE_ZERO_BYTE;
8491 dgst_pos0 = 0;
8492 dgst_pos1 = 1;
8493 dgst_pos2 = 2;
8494 dgst_pos3 = 3;
8495 break;
8496
8497 case 6232: hash_type = HASH_TYPE_WHIRLPOOL;
8498 salt_type = SALT_TYPE_EMBEDDED;
8499 attack_exec = ATTACK_EXEC_ON_CPU;
8500 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8501 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1024;
8502 dgst_size = DGST_SIZE_4_8;
8503 parse_func = truecrypt_parse_hash_1k;
8504 sort_by_digest = sort_by_digest_4_8;
8505 opti_type = OPTI_TYPE_ZERO_BYTE;
8506 dgst_pos0 = 0;
8507 dgst_pos1 = 1;
8508 dgst_pos2 = 2;
8509 dgst_pos3 = 3;
8510 break;
8511
8512 case 6233: hash_type = HASH_TYPE_WHIRLPOOL;
8513 salt_type = SALT_TYPE_EMBEDDED;
8514 attack_exec = ATTACK_EXEC_ON_CPU;
8515 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8516 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1536;
8517 dgst_size = DGST_SIZE_4_8;
8518 parse_func = truecrypt_parse_hash_1k;
8519 sort_by_digest = sort_by_digest_4_8;
8520 opti_type = OPTI_TYPE_ZERO_BYTE;
8521 dgst_pos0 = 0;
8522 dgst_pos1 = 1;
8523 dgst_pos2 = 2;
8524 dgst_pos3 = 3;
8525 break;
8526
8527 case 6241: hash_type = HASH_TYPE_RIPEMD160;
8528 salt_type = SALT_TYPE_EMBEDDED;
8529 attack_exec = ATTACK_EXEC_ON_CPU;
8530 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8531 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
8532 dgst_size = DGST_SIZE_4_5;
8533 parse_func = truecrypt_parse_hash_1k;
8534 sort_by_digest = sort_by_digest_4_5;
8535 opti_type = OPTI_TYPE_ZERO_BYTE;
8536 dgst_pos0 = 0;
8537 dgst_pos1 = 1;
8538 dgst_pos2 = 2;
8539 dgst_pos3 = 3;
8540 break;
8541
8542 case 6242: hash_type = HASH_TYPE_RIPEMD160;
8543 salt_type = SALT_TYPE_EMBEDDED;
8544 attack_exec = ATTACK_EXEC_ON_CPU;
8545 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8546 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
8547 dgst_size = DGST_SIZE_4_5;
8548 parse_func = truecrypt_parse_hash_1k;
8549 sort_by_digest = sort_by_digest_4_5;
8550 opti_type = OPTI_TYPE_ZERO_BYTE;
8551 dgst_pos0 = 0;
8552 dgst_pos1 = 1;
8553 dgst_pos2 = 2;
8554 dgst_pos3 = 3;
8555 break;
8556
8557 case 6243: hash_type = HASH_TYPE_RIPEMD160;
8558 salt_type = SALT_TYPE_EMBEDDED;
8559 attack_exec = ATTACK_EXEC_ON_CPU;
8560 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8561 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
8562 dgst_size = DGST_SIZE_4_5;
8563 parse_func = truecrypt_parse_hash_1k;
8564 sort_by_digest = sort_by_digest_4_5;
8565 opti_type = OPTI_TYPE_ZERO_BYTE;
8566 dgst_pos0 = 0;
8567 dgst_pos1 = 1;
8568 dgst_pos2 = 2;
8569 dgst_pos3 = 3;
8570 break;
8571
8572 case 6300: hash_type = HASH_TYPE_MD5;
8573 salt_type = SALT_TYPE_EMBEDDED;
8574 attack_exec = ATTACK_EXEC_ON_CPU;
8575 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8576 kern_type = KERN_TYPE_MD5AIX;
8577 dgst_size = DGST_SIZE_4_4;
8578 parse_func = md5aix_parse_hash;
8579 sort_by_digest = sort_by_digest_4_4;
8580 opti_type = OPTI_TYPE_ZERO_BYTE;
8581 dgst_pos0 = 0;
8582 dgst_pos1 = 1;
8583 dgst_pos2 = 2;
8584 dgst_pos3 = 3;
8585 break;
8586
8587 case 6400: hash_type = HASH_TYPE_SHA256;
8588 salt_type = SALT_TYPE_EMBEDDED;
8589 attack_exec = ATTACK_EXEC_ON_CPU;
8590 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8591 kern_type = KERN_TYPE_SHA256AIX;
8592 dgst_size = DGST_SIZE_4_8;
8593 parse_func = sha256aix_parse_hash;
8594 sort_by_digest = sort_by_digest_4_8;
8595 opti_type = OPTI_TYPE_ZERO_BYTE;
8596 dgst_pos0 = 0;
8597 dgst_pos1 = 1;
8598 dgst_pos2 = 2;
8599 dgst_pos3 = 3;
8600 break;
8601
8602 case 6500: hash_type = HASH_TYPE_SHA512;
8603 salt_type = SALT_TYPE_EMBEDDED;
8604 attack_exec = ATTACK_EXEC_ON_CPU;
8605 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8606 kern_type = KERN_TYPE_SHA512AIX;
8607 dgst_size = DGST_SIZE_8_8;
8608 parse_func = sha512aix_parse_hash;
8609 sort_by_digest = sort_by_digest_8_8;
8610 opti_type = OPTI_TYPE_ZERO_BYTE;
8611 dgst_pos0 = 0;
8612 dgst_pos1 = 1;
8613 dgst_pos2 = 2;
8614 dgst_pos3 = 3;
8615 break;
8616
8617 case 6600: hash_type = HASH_TYPE_AES;
8618 salt_type = SALT_TYPE_EMBEDDED;
8619 attack_exec = ATTACK_EXEC_ON_CPU;
8620 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8621 kern_type = KERN_TYPE_AGILEKEY;
8622 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
8623 parse_func = agilekey_parse_hash;
8624 sort_by_digest = sort_by_digest_4_5;
8625 opti_type = OPTI_TYPE_ZERO_BYTE;
8626 dgst_pos0 = 0;
8627 dgst_pos1 = 1;
8628 dgst_pos2 = 2;
8629 dgst_pos3 = 3;
8630 break;
8631
8632 case 6700: hash_type = HASH_TYPE_SHA1;
8633 salt_type = SALT_TYPE_EMBEDDED;
8634 attack_exec = ATTACK_EXEC_ON_CPU;
8635 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8636 kern_type = KERN_TYPE_SHA1AIX;
8637 dgst_size = DGST_SIZE_4_5;
8638 parse_func = sha1aix_parse_hash;
8639 sort_by_digest = sort_by_digest_4_5;
8640 opti_type = OPTI_TYPE_ZERO_BYTE;
8641 dgst_pos0 = 0;
8642 dgst_pos1 = 1;
8643 dgst_pos2 = 2;
8644 dgst_pos3 = 3;
8645 break;
8646
8647 case 6800: hash_type = HASH_TYPE_AES;
8648 salt_type = SALT_TYPE_EMBEDDED;
8649 attack_exec = ATTACK_EXEC_ON_CPU;
8650 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8651 kern_type = KERN_TYPE_LASTPASS;
8652 dgst_size = DGST_SIZE_4_8; // because kernel uses _SHA256_
8653 parse_func = lastpass_parse_hash;
8654 sort_by_digest = sort_by_digest_4_8;
8655 opti_type = OPTI_TYPE_ZERO_BYTE;
8656 dgst_pos0 = 0;
8657 dgst_pos1 = 1;
8658 dgst_pos2 = 2;
8659 dgst_pos3 = 3;
8660 break;
8661
8662 case 6900: hash_type = HASH_TYPE_GOST;
8663 salt_type = SALT_TYPE_NONE;
8664 attack_exec = ATTACK_EXEC_ON_GPU;
8665 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8666 kern_type = KERN_TYPE_GOST;
8667 dgst_size = DGST_SIZE_4_8;
8668 parse_func = gost_parse_hash;
8669 sort_by_digest = sort_by_digest_4_8;
8670 opti_type = OPTI_TYPE_ZERO_BYTE;
8671 dgst_pos0 = 0;
8672 dgst_pos1 = 1;
8673 dgst_pos2 = 2;
8674 dgst_pos3 = 3;
8675 break;
8676
8677 case 7100: hash_type = HASH_TYPE_SHA512;
8678 salt_type = SALT_TYPE_EMBEDDED;
8679 attack_exec = ATTACK_EXEC_ON_CPU;
8680 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8681 kern_type = KERN_TYPE_PBKDF2_SHA512;
8682 dgst_size = DGST_SIZE_8_16;
8683 parse_func = sha512osx_parse_hash;
8684 sort_by_digest = sort_by_digest_8_16;
8685 opti_type = OPTI_TYPE_ZERO_BYTE;
8686 dgst_pos0 = 0;
8687 dgst_pos1 = 1;
8688 dgst_pos2 = 2;
8689 dgst_pos3 = 3;
8690 break;
8691
8692 case 7200: hash_type = HASH_TYPE_SHA512;
8693 salt_type = SALT_TYPE_EMBEDDED;
8694 attack_exec = ATTACK_EXEC_ON_CPU;
8695 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8696 kern_type = KERN_TYPE_PBKDF2_SHA512;
8697 dgst_size = DGST_SIZE_8_16;
8698 parse_func = sha512grub_parse_hash;
8699 sort_by_digest = sort_by_digest_8_16;
8700 opti_type = OPTI_TYPE_ZERO_BYTE;
8701 dgst_pos0 = 0;
8702 dgst_pos1 = 1;
8703 dgst_pos2 = 2;
8704 dgst_pos3 = 3;
8705 break;
8706
8707 case 7300: hash_type = HASH_TYPE_SHA1;
8708 salt_type = SALT_TYPE_EMBEDDED;
8709 attack_exec = ATTACK_EXEC_ON_GPU;
8710 opts_type = OPTS_TYPE_PT_GENERATE_BE
8711 | OPTS_TYPE_ST_ADD80
8712 | OPTS_TYPE_ST_ADDBITS15;
8713 kern_type = KERN_TYPE_RAKP;
8714 dgst_size = DGST_SIZE_4_5;
8715 parse_func = rakp_parse_hash;
8716 sort_by_digest = sort_by_digest_4_5;
8717 opti_type = OPTI_TYPE_ZERO_BYTE
8718 | OPTI_TYPE_NOT_ITERATED;
8719 dgst_pos0 = 3;
8720 dgst_pos1 = 4;
8721 dgst_pos2 = 2;
8722 dgst_pos3 = 1;
8723 break;
8724
8725 case 7400: hash_type = HASH_TYPE_SHA256;
8726 salt_type = SALT_TYPE_EMBEDDED;
8727 attack_exec = ATTACK_EXEC_ON_CPU;
8728 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8729 kern_type = KERN_TYPE_SHA256CRYPT;
8730 dgst_size = DGST_SIZE_4_8;
8731 parse_func = sha256crypt_parse_hash;
8732 sort_by_digest = sort_by_digest_4_8;
8733 opti_type = OPTI_TYPE_ZERO_BYTE;
8734 dgst_pos0 = 0;
8735 dgst_pos1 = 1;
8736 dgst_pos2 = 2;
8737 dgst_pos3 = 3;
8738 break;
8739
8740 case 7500: hash_type = HASH_TYPE_KRB5PA;
8741 salt_type = SALT_TYPE_EMBEDDED;
8742 attack_exec = ATTACK_EXEC_ON_GPU;
8743 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8744 kern_type = KERN_TYPE_KRB5PA;
8745 dgst_size = DGST_SIZE_4_4;
8746 parse_func = krb5pa_parse_hash;
8747 sort_by_digest = sort_by_digest_4_4;
8748 opti_type = OPTI_TYPE_ZERO_BYTE
8749 | OPTI_TYPE_NOT_ITERATED;
8750 dgst_pos0 = 3;
8751 dgst_pos1 = 7;
8752 dgst_pos2 = 2;
8753 dgst_pos3 = 6;
8754 break;
8755
8756 case 7600: hash_type = HASH_TYPE_SHA1;
8757 salt_type = SALT_TYPE_INTERN;
8758 attack_exec = ATTACK_EXEC_ON_GPU;
8759 opts_type = OPTS_TYPE_PT_GENERATE_BE
8760 | OPTS_TYPE_PT_ADD80
8761 | OPTS_TYPE_PT_ADDBITS15;
8762 kern_type = KERN_TYPE_SHA1_SLT_SHA1_PW;
8763 dgst_size = DGST_SIZE_4_5;
8764 parse_func = redmine_parse_hash;
8765 sort_by_digest = sort_by_digest_4_5;
8766 opti_type = OPTI_TYPE_ZERO_BYTE
8767 | OPTI_TYPE_PRECOMPUTE_INIT
8768 | OPTI_TYPE_EARLY_SKIP
8769 | OPTI_TYPE_NOT_ITERATED
8770 | OPTI_TYPE_PREPENDED_SALT;
8771 dgst_pos0 = 3;
8772 dgst_pos1 = 4;
8773 dgst_pos2 = 2;
8774 dgst_pos3 = 1;
8775 break;
8776
8777 case 7700: hash_type = HASH_TYPE_SAPB;
8778 salt_type = SALT_TYPE_EMBEDDED;
8779 attack_exec = ATTACK_EXEC_ON_GPU;
8780 opts_type = OPTS_TYPE_PT_GENERATE_LE
8781 | OPTS_TYPE_PT_UPPER
8782 | OPTS_TYPE_ST_UPPER;
8783 kern_type = KERN_TYPE_SAPB;
8784 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8785 parse_func = sapb_parse_hash;
8786 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8787 opti_type = OPTI_TYPE_ZERO_BYTE
8788 | OPTI_TYPE_PRECOMPUTE_INIT
8789 | OPTI_TYPE_NOT_ITERATED;
8790 dgst_pos0 = 0;
8791 dgst_pos1 = 1;
8792 dgst_pos2 = 2;
8793 dgst_pos3 = 3;
8794 break;
8795
8796 case 7800: hash_type = HASH_TYPE_SAPG;
8797 salt_type = SALT_TYPE_EMBEDDED;
8798 attack_exec = ATTACK_EXEC_ON_GPU;
8799 opts_type = OPTS_TYPE_PT_GENERATE_BE
8800 | OPTS_TYPE_ST_ADD80
8801 | OPTS_TYPE_ST_UPPER;
8802 kern_type = KERN_TYPE_SAPG;
8803 dgst_size = DGST_SIZE_4_5;
8804 parse_func = sapg_parse_hash;
8805 sort_by_digest = sort_by_digest_4_5;
8806 opti_type = OPTI_TYPE_ZERO_BYTE
8807 | OPTI_TYPE_PRECOMPUTE_INIT
8808 | OPTI_TYPE_NOT_ITERATED;
8809 dgst_pos0 = 3;
8810 dgst_pos1 = 4;
8811 dgst_pos2 = 2;
8812 dgst_pos3 = 1;
8813 break;
8814
8815 case 7900: hash_type = HASH_TYPE_SHA512;
8816 salt_type = SALT_TYPE_EMBEDDED;
8817 attack_exec = ATTACK_EXEC_ON_CPU;
8818 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8819 kern_type = KERN_TYPE_DRUPAL7;
8820 dgst_size = DGST_SIZE_8_8;
8821 parse_func = drupal7_parse_hash;
8822 sort_by_digest = sort_by_digest_8_8;
8823 opti_type = OPTI_TYPE_ZERO_BYTE;
8824 dgst_pos0 = 0;
8825 dgst_pos1 = 1;
8826 dgst_pos2 = 2;
8827 dgst_pos3 = 3;
8828 break;
8829
8830 case 8000: hash_type = HASH_TYPE_SHA256;
8831 salt_type = SALT_TYPE_EMBEDDED;
8832 attack_exec = ATTACK_EXEC_ON_GPU;
8833 opts_type = OPTS_TYPE_PT_GENERATE_BE
8834 | OPTS_TYPE_PT_UNICODE
8835 | OPTS_TYPE_ST_ADD80
8836 | OPTS_TYPE_ST_HEX;
8837 kern_type = KERN_TYPE_SYBASEASE;
8838 dgst_size = DGST_SIZE_4_8;
8839 parse_func = sybasease_parse_hash;
8840 sort_by_digest = sort_by_digest_4_8;
8841 opti_type = OPTI_TYPE_ZERO_BYTE
8842 | OPTI_TYPE_PRECOMPUTE_INIT
8843 | OPTI_TYPE_EARLY_SKIP
8844 | OPTI_TYPE_NOT_ITERATED
8845 | OPTI_TYPE_RAW_HASH;
8846 dgst_pos0 = 3;
8847 dgst_pos1 = 7;
8848 dgst_pos2 = 2;
8849 dgst_pos3 = 6;
8850 break;
8851
8852 case 8100: hash_type = HASH_TYPE_SHA1;
8853 salt_type = SALT_TYPE_EMBEDDED;
8854 attack_exec = ATTACK_EXEC_ON_GPU;
8855 opts_type = OPTS_TYPE_PT_GENERATE_BE;
8856 kern_type = KERN_TYPE_NETSCALER;
8857 dgst_size = DGST_SIZE_4_5;
8858 parse_func = netscaler_parse_hash;
8859 sort_by_digest = sort_by_digest_4_5;
8860 opti_type = OPTI_TYPE_ZERO_BYTE
8861 | OPTI_TYPE_PRECOMPUTE_INIT
8862 | OPTI_TYPE_PRECOMPUTE_MERKLE
8863 | OPTI_TYPE_EARLY_SKIP
8864 | OPTI_TYPE_NOT_ITERATED
8865 | OPTI_TYPE_PREPENDED_SALT
8866 | OPTI_TYPE_RAW_HASH;
8867 dgst_pos0 = 3;
8868 dgst_pos1 = 4;
8869 dgst_pos2 = 2;
8870 dgst_pos3 = 1;
8871 break;
8872
8873 case 8200: hash_type = HASH_TYPE_SHA256;
8874 salt_type = SALT_TYPE_EMBEDDED;
8875 attack_exec = ATTACK_EXEC_ON_CPU;
8876 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8877 kern_type = KERN_TYPE_CLOUDKEY;
8878 dgst_size = DGST_SIZE_4_8;
8879 parse_func = cloudkey_parse_hash;
8880 sort_by_digest = sort_by_digest_4_8;
8881 opti_type = OPTI_TYPE_ZERO_BYTE;
8882 dgst_pos0 = 0;
8883 dgst_pos1 = 1;
8884 dgst_pos2 = 2;
8885 dgst_pos3 = 3;
8886 break;
8887
8888 case 8300: hash_type = HASH_TYPE_SHA1;
8889 salt_type = SALT_TYPE_EMBEDDED;
8890 attack_exec = ATTACK_EXEC_ON_GPU;
8891 opts_type = OPTS_TYPE_PT_GENERATE_LE
8892 | OPTS_TYPE_ST_HEX
8893 | OPTS_TYPE_ST_ADD80;
8894 kern_type = KERN_TYPE_NSEC3;
8895 dgst_size = DGST_SIZE_4_5;
8896 parse_func = nsec3_parse_hash;
8897 sort_by_digest = sort_by_digest_4_5;
8898 opti_type = OPTI_TYPE_ZERO_BYTE;
8899 dgst_pos0 = 3;
8900 dgst_pos1 = 4;
8901 dgst_pos2 = 2;
8902 dgst_pos3 = 1;
8903 break;
8904
8905 case 8400: hash_type = HASH_TYPE_SHA1;
8906 salt_type = SALT_TYPE_INTERN;
8907 attack_exec = ATTACK_EXEC_ON_GPU;
8908 opts_type = OPTS_TYPE_PT_GENERATE_BE
8909 | OPTS_TYPE_PT_ADD80
8910 | OPTS_TYPE_PT_ADDBITS15;
8911 kern_type = KERN_TYPE_WBB3;
8912 dgst_size = DGST_SIZE_4_5;
8913 parse_func = wbb3_parse_hash;
8914 sort_by_digest = sort_by_digest_4_5;
8915 opti_type = OPTI_TYPE_ZERO_BYTE
8916 | OPTI_TYPE_PRECOMPUTE_INIT
8917 | OPTI_TYPE_NOT_ITERATED;
8918 dgst_pos0 = 3;
8919 dgst_pos1 = 4;
8920 dgst_pos2 = 2;
8921 dgst_pos3 = 1;
8922 break;
8923
8924 case 8500: hash_type = HASH_TYPE_DESRACF;
8925 salt_type = SALT_TYPE_EMBEDDED;
8926 attack_exec = ATTACK_EXEC_ON_GPU;
8927 opts_type = OPTS_TYPE_PT_GENERATE_LE
8928 | OPTS_TYPE_ST_UPPER;
8929 kern_type = KERN_TYPE_RACF;
8930 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8931 parse_func = racf_parse_hash;
8932 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8933 opti_type = OPTI_TYPE_ZERO_BYTE
8934 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8935 dgst_pos0 = 0;
8936 dgst_pos1 = 1;
8937 dgst_pos2 = 2;
8938 dgst_pos3 = 3;
8939 break;
8940
8941 case 8600: hash_type = HASH_TYPE_LOTUS5;
8942 salt_type = SALT_TYPE_NONE;
8943 attack_exec = ATTACK_EXEC_ON_GPU;
8944 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8945 kern_type = KERN_TYPE_LOTUS5;
8946 dgst_size = DGST_SIZE_4_4;
8947 parse_func = lotus5_parse_hash;
8948 sort_by_digest = sort_by_digest_4_4;
8949 opti_type = OPTI_TYPE_EARLY_SKIP
8950 | OPTI_TYPE_NOT_ITERATED
8951 | OPTI_TYPE_NOT_SALTED
8952 | OPTI_TYPE_RAW_HASH;
8953 dgst_pos0 = 0;
8954 dgst_pos1 = 1;
8955 dgst_pos2 = 2;
8956 dgst_pos3 = 3;
8957 break;
8958
8959 case 8700: hash_type = HASH_TYPE_LOTUS6;
8960 salt_type = SALT_TYPE_EMBEDDED;
8961 attack_exec = ATTACK_EXEC_ON_GPU;
8962 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8963 kern_type = KERN_TYPE_LOTUS6;
8964 dgst_size = DGST_SIZE_4_4;
8965 parse_func = lotus6_parse_hash;
8966 sort_by_digest = sort_by_digest_4_4;
8967 opti_type = OPTI_TYPE_EARLY_SKIP
8968 | OPTI_TYPE_NOT_ITERATED
8969 | OPTI_TYPE_RAW_HASH;
8970 dgst_pos0 = 0;
8971 dgst_pos1 = 1;
8972 dgst_pos2 = 2;
8973 dgst_pos3 = 3;
8974 break;
8975
8976 case 8800: hash_type = HASH_TYPE_ANDROIDFDE;
8977 salt_type = SALT_TYPE_EMBEDDED;
8978 attack_exec = ATTACK_EXEC_ON_CPU;
8979 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8980 kern_type = KERN_TYPE_ANDROIDFDE;
8981 dgst_size = DGST_SIZE_4_4;
8982 parse_func = androidfde_parse_hash;
8983 sort_by_digest = sort_by_digest_4_4;
8984 opti_type = OPTI_TYPE_ZERO_BYTE;
8985 dgst_pos0 = 0;
8986 dgst_pos1 = 1;
8987 dgst_pos2 = 2;
8988 dgst_pos3 = 3;
8989 break;
8990
8991 case 8900: hash_type = HASH_TYPE_SCRYPT;
8992 salt_type = SALT_TYPE_EMBEDDED;
8993 attack_exec = ATTACK_EXEC_ON_CPU;
8994 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8995 kern_type = KERN_TYPE_SCRYPT;
8996 dgst_size = DGST_SIZE_4_8;
8997 parse_func = scrypt_parse_hash;
8998 sort_by_digest = sort_by_digest_4_8;
8999 opti_type = OPTI_TYPE_ZERO_BYTE;
9000 dgst_pos0 = 0;
9001 dgst_pos1 = 1;
9002 dgst_pos2 = 2;
9003 dgst_pos3 = 3;
9004 break;
9005
9006 case 9000: hash_type = HASH_TYPE_SHA1;
9007 salt_type = SALT_TYPE_EMBEDDED;
9008 attack_exec = ATTACK_EXEC_ON_CPU;
9009 opts_type = OPTS_TYPE_PT_GENERATE_LE
9010 | OPTS_TYPE_ST_GENERATE_LE;
9011 kern_type = KERN_TYPE_PSAFE2;
9012 dgst_size = DGST_SIZE_4_5;
9013 parse_func = psafe2_parse_hash;
9014 sort_by_digest = sort_by_digest_4_5;
9015 opti_type = OPTI_TYPE_ZERO_BYTE;
9016 dgst_pos0 = 0;
9017 dgst_pos1 = 1;
9018 dgst_pos2 = 2;
9019 dgst_pos3 = 3;
9020 break;
9021
9022 case 9100: hash_type = HASH_TYPE_LOTUS8;
9023 salt_type = SALT_TYPE_EMBEDDED;
9024 attack_exec = ATTACK_EXEC_ON_CPU;
9025 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9026 kern_type = KERN_TYPE_LOTUS8;
9027 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9028 parse_func = lotus8_parse_hash;
9029 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9030 opti_type = OPTI_TYPE_ZERO_BYTE;
9031 dgst_pos0 = 0;
9032 dgst_pos1 = 1;
9033 dgst_pos2 = 2;
9034 dgst_pos3 = 3;
9035 break;
9036
9037 case 9200: hash_type = HASH_TYPE_SHA256;
9038 salt_type = SALT_TYPE_EMBEDDED;
9039 attack_exec = ATTACK_EXEC_ON_CPU;
9040 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9041 kern_type = KERN_TYPE_PBKDF2_SHA256;
9042 dgst_size = DGST_SIZE_4_32;
9043 parse_func = cisco8_parse_hash;
9044 sort_by_digest = sort_by_digest_4_32;
9045 opti_type = OPTI_TYPE_ZERO_BYTE;
9046 dgst_pos0 = 0;
9047 dgst_pos1 = 1;
9048 dgst_pos2 = 2;
9049 dgst_pos3 = 3;
9050 break;
9051
9052 case 9300: hash_type = HASH_TYPE_SCRYPT;
9053 salt_type = SALT_TYPE_EMBEDDED;
9054 attack_exec = ATTACK_EXEC_ON_CPU;
9055 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9056 kern_type = KERN_TYPE_SCRYPT;
9057 dgst_size = DGST_SIZE_4_8;
9058 parse_func = cisco9_parse_hash;
9059 sort_by_digest = sort_by_digest_4_8;
9060 opti_type = OPTI_TYPE_ZERO_BYTE;
9061 dgst_pos0 = 0;
9062 dgst_pos1 = 1;
9063 dgst_pos2 = 2;
9064 dgst_pos3 = 3;
9065 break;
9066
9067 case 9400: hash_type = HASH_TYPE_OFFICE2007;
9068 salt_type = SALT_TYPE_EMBEDDED;
9069 attack_exec = ATTACK_EXEC_ON_CPU;
9070 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9071 kern_type = KERN_TYPE_OFFICE2007;
9072 dgst_size = DGST_SIZE_4_4;
9073 parse_func = office2007_parse_hash;
9074 sort_by_digest = sort_by_digest_4_4;
9075 opti_type = OPTI_TYPE_ZERO_BYTE;
9076 dgst_pos0 = 0;
9077 dgst_pos1 = 1;
9078 dgst_pos2 = 2;
9079 dgst_pos3 = 3;
9080 break;
9081
9082 case 9500: hash_type = HASH_TYPE_OFFICE2010;
9083 salt_type = SALT_TYPE_EMBEDDED;
9084 attack_exec = ATTACK_EXEC_ON_CPU;
9085 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9086 kern_type = KERN_TYPE_OFFICE2010;
9087 dgst_size = DGST_SIZE_4_4;
9088 parse_func = office2010_parse_hash;
9089 sort_by_digest = sort_by_digest_4_4;
9090 opti_type = OPTI_TYPE_ZERO_BYTE;
9091 dgst_pos0 = 0;
9092 dgst_pos1 = 1;
9093 dgst_pos2 = 2;
9094 dgst_pos3 = 3;
9095 break;
9096
9097 case 9600: hash_type = HASH_TYPE_OFFICE2013;
9098 salt_type = SALT_TYPE_EMBEDDED;
9099 attack_exec = ATTACK_EXEC_ON_CPU;
9100 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9101 kern_type = KERN_TYPE_OFFICE2013;
9102 dgst_size = DGST_SIZE_4_4;
9103 parse_func = office2013_parse_hash;
9104 sort_by_digest = sort_by_digest_4_4;
9105 opti_type = OPTI_TYPE_ZERO_BYTE;
9106 dgst_pos0 = 0;
9107 dgst_pos1 = 1;
9108 dgst_pos2 = 2;
9109 dgst_pos3 = 3;
9110 break;
9111
9112 case 9700: hash_type = HASH_TYPE_OLDOFFICE01;
9113 salt_type = SALT_TYPE_EMBEDDED;
9114 attack_exec = ATTACK_EXEC_ON_GPU;
9115 opts_type = OPTS_TYPE_PT_GENERATE_LE
9116 | OPTS_TYPE_PT_ADD80
9117 | OPTS_TYPE_PT_UNICODE;
9118 kern_type = KERN_TYPE_OLDOFFICE01;
9119 dgst_size = DGST_SIZE_4_4;
9120 parse_func = oldoffice01_parse_hash;
9121 sort_by_digest = sort_by_digest_4_4;
9122 opti_type = OPTI_TYPE_ZERO_BYTE
9123 | OPTI_TYPE_PRECOMPUTE_INIT
9124 | OPTI_TYPE_NOT_ITERATED;
9125 dgst_pos0 = 0;
9126 dgst_pos1 = 1;
9127 dgst_pos2 = 2;
9128 dgst_pos3 = 3;
9129 break;
9130
9131 case 9710: hash_type = HASH_TYPE_OLDOFFICE01;
9132 salt_type = SALT_TYPE_EMBEDDED;
9133 attack_exec = ATTACK_EXEC_ON_GPU;
9134 opts_type = OPTS_TYPE_PT_GENERATE_LE
9135 | OPTS_TYPE_PT_ADD80;
9136 kern_type = KERN_TYPE_OLDOFFICE01CM1;
9137 dgst_size = DGST_SIZE_4_4;
9138 parse_func = oldoffice01cm1_parse_hash;
9139 sort_by_digest = sort_by_digest_4_4;
9140 opti_type = OPTI_TYPE_ZERO_BYTE
9141 | OPTI_TYPE_PRECOMPUTE_INIT
9142 | OPTI_TYPE_NOT_ITERATED;
9143 dgst_pos0 = 0;
9144 dgst_pos1 = 1;
9145 dgst_pos2 = 2;
9146 dgst_pos3 = 3;
9147 break;
9148
9149 case 9720: hash_type = HASH_TYPE_OLDOFFICE01;
9150 salt_type = SALT_TYPE_EMBEDDED;
9151 attack_exec = ATTACK_EXEC_ON_GPU;
9152 opts_type = OPTS_TYPE_PT_GENERATE_LE
9153 | OPTS_TYPE_PT_ADD80
9154 | OPTS_TYPE_PT_UNICODE
9155 | OPTS_TYPE_PT_NEVERCRACK;
9156 kern_type = KERN_TYPE_OLDOFFICE01CM2;
9157 dgst_size = DGST_SIZE_4_4;
9158 parse_func = oldoffice01cm2_parse_hash;
9159 sort_by_digest = sort_by_digest_4_4;
9160 opti_type = OPTI_TYPE_ZERO_BYTE
9161 | OPTI_TYPE_PRECOMPUTE_INIT
9162 | OPTI_TYPE_NOT_ITERATED;
9163 dgst_pos0 = 0;
9164 dgst_pos1 = 1;
9165 dgst_pos2 = 2;
9166 dgst_pos3 = 3;
9167 break;
9168
9169 case 9800: hash_type = HASH_TYPE_OLDOFFICE34;
9170 salt_type = SALT_TYPE_EMBEDDED;
9171 attack_exec = ATTACK_EXEC_ON_GPU;
9172 opts_type = OPTS_TYPE_PT_GENERATE_BE
9173 | OPTS_TYPE_PT_ADD80
9174 | OPTS_TYPE_PT_UNICODE;
9175 kern_type = KERN_TYPE_OLDOFFICE34;
9176 dgst_size = DGST_SIZE_4_4;
9177 parse_func = oldoffice34_parse_hash;
9178 sort_by_digest = sort_by_digest_4_4;
9179 opti_type = OPTI_TYPE_ZERO_BYTE
9180 | OPTI_TYPE_PRECOMPUTE_INIT
9181 | OPTI_TYPE_NOT_ITERATED;
9182 dgst_pos0 = 0;
9183 dgst_pos1 = 1;
9184 dgst_pos2 = 2;
9185 dgst_pos3 = 3;
9186 break;
9187
9188 case 9810: hash_type = HASH_TYPE_OLDOFFICE34;
9189 salt_type = SALT_TYPE_EMBEDDED;
9190 attack_exec = ATTACK_EXEC_ON_GPU;
9191 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9192 kern_type = KERN_TYPE_OLDOFFICE34CM1;
9193 dgst_size = DGST_SIZE_4_4;
9194 parse_func = oldoffice34cm1_parse_hash;
9195 sort_by_digest = sort_by_digest_4_4;
9196 opti_type = OPTI_TYPE_ZERO_BYTE
9197 | OPTI_TYPE_PRECOMPUTE_INIT
9198 | OPTI_TYPE_NOT_ITERATED;
9199 dgst_pos0 = 0;
9200 dgst_pos1 = 1;
9201 dgst_pos2 = 2;
9202 dgst_pos3 = 3;
9203 break;
9204
9205 case 9820: hash_type = HASH_TYPE_OLDOFFICE34;
9206 salt_type = SALT_TYPE_EMBEDDED;
9207 attack_exec = ATTACK_EXEC_ON_GPU;
9208 opts_type = OPTS_TYPE_PT_GENERATE_BE
9209 | OPTS_TYPE_PT_ADD80
9210 | OPTS_TYPE_PT_UNICODE
9211 | OPTS_TYPE_PT_NEVERCRACK;
9212 kern_type = KERN_TYPE_OLDOFFICE34CM2;
9213 dgst_size = DGST_SIZE_4_4;
9214 parse_func = oldoffice34cm2_parse_hash;
9215 sort_by_digest = sort_by_digest_4_4;
9216 opti_type = OPTI_TYPE_ZERO_BYTE
9217 | OPTI_TYPE_PRECOMPUTE_INIT
9218 | OPTI_TYPE_NOT_ITERATED;
9219 dgst_pos0 = 0;
9220 dgst_pos1 = 1;
9221 dgst_pos2 = 2;
9222 dgst_pos3 = 3;
9223 break;
9224
9225 case 9900: hash_type = HASH_TYPE_MD5;
9226 salt_type = SALT_TYPE_NONE;
9227 attack_exec = ATTACK_EXEC_ON_GPU;
9228 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9229 kern_type = KERN_TYPE_RADMIN2;
9230 dgst_size = DGST_SIZE_4_4;
9231 parse_func = radmin2_parse_hash;
9232 sort_by_digest = sort_by_digest_4_4;
9233 opti_type = OPTI_TYPE_ZERO_BYTE
9234 | OPTI_TYPE_PRECOMPUTE_INIT
9235 | OPTI_TYPE_EARLY_SKIP
9236 | OPTI_TYPE_NOT_ITERATED
9237 | OPTI_TYPE_NOT_SALTED;
9238 dgst_pos0 = 0;
9239 dgst_pos1 = 3;
9240 dgst_pos2 = 2;
9241 dgst_pos3 = 1;
9242 break;
9243
9244 case 10000: hash_type = HASH_TYPE_SHA256;
9245 salt_type = SALT_TYPE_EMBEDDED;
9246 attack_exec = ATTACK_EXEC_ON_CPU;
9247 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9248 kern_type = KERN_TYPE_PBKDF2_SHA256;
9249 dgst_size = DGST_SIZE_4_32;
9250 parse_func = djangopbkdf2_parse_hash;
9251 sort_by_digest = sort_by_digest_4_32;
9252 opti_type = OPTI_TYPE_ZERO_BYTE;
9253 dgst_pos0 = 0;
9254 dgst_pos1 = 1;
9255 dgst_pos2 = 2;
9256 dgst_pos3 = 3;
9257 break;
9258
9259 case 10100: hash_type = HASH_TYPE_SIPHASH;
9260 salt_type = SALT_TYPE_EMBEDDED;
9261 attack_exec = ATTACK_EXEC_ON_GPU;
9262 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9263 kern_type = KERN_TYPE_SIPHASH;
9264 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9265 parse_func = siphash_parse_hash;
9266 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9267 opti_type = OPTI_TYPE_ZERO_BYTE
9268 | OPTI_TYPE_NOT_ITERATED
9269 | OPTI_TYPE_RAW_HASH;
9270 dgst_pos0 = 0;
9271 dgst_pos1 = 1;
9272 dgst_pos2 = 2;
9273 dgst_pos3 = 3;
9274 break;
9275
9276 case 10200: hash_type = HASH_TYPE_MD5;
9277 salt_type = SALT_TYPE_EMBEDDED;
9278 attack_exec = ATTACK_EXEC_ON_GPU;
9279 opts_type = OPTS_TYPE_PT_GENERATE_LE
9280 | OPTS_TYPE_ST_ADD80
9281 | OPTS_TYPE_ST_ADDBITS14;
9282 kern_type = KERN_TYPE_HMACMD5_PW;
9283 dgst_size = DGST_SIZE_4_4;
9284 parse_func = crammd5_parse_hash;
9285 sort_by_digest = sort_by_digest_4_4;
9286 opti_type = OPTI_TYPE_ZERO_BYTE
9287 | OPTI_TYPE_NOT_ITERATED;
9288 dgst_pos0 = 0;
9289 dgst_pos1 = 3;
9290 dgst_pos2 = 2;
9291 dgst_pos3 = 1;
9292 break;
9293
9294 case 10300: hash_type = HASH_TYPE_SHA1;
9295 salt_type = SALT_TYPE_EMBEDDED;
9296 attack_exec = ATTACK_EXEC_ON_CPU;
9297 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9298 kern_type = KERN_TYPE_SAPH_SHA1;
9299 dgst_size = DGST_SIZE_4_5;
9300 parse_func = saph_sha1_parse_hash;
9301 sort_by_digest = sort_by_digest_4_5;
9302 opti_type = OPTI_TYPE_ZERO_BYTE;
9303 dgst_pos0 = 0;
9304 dgst_pos1 = 1;
9305 dgst_pos2 = 2;
9306 dgst_pos3 = 3;
9307 break;
9308
9309 case 10400: hash_type = HASH_TYPE_PDFU16;
9310 salt_type = SALT_TYPE_EMBEDDED;
9311 attack_exec = ATTACK_EXEC_ON_GPU;
9312 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9313 kern_type = KERN_TYPE_PDF11;
9314 dgst_size = DGST_SIZE_4_4;
9315 parse_func = pdf11_parse_hash;
9316 sort_by_digest = sort_by_digest_4_4;
9317 opti_type = OPTI_TYPE_ZERO_BYTE
9318 | OPTI_TYPE_NOT_ITERATED;
9319 dgst_pos0 = 0;
9320 dgst_pos1 = 1;
9321 dgst_pos2 = 2;
9322 dgst_pos3 = 3;
9323 break;
9324
9325 case 10410: hash_type = HASH_TYPE_PDFU16;
9326 salt_type = SALT_TYPE_EMBEDDED;
9327 attack_exec = ATTACK_EXEC_ON_GPU;
9328 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9329 kern_type = KERN_TYPE_PDF11CM1;
9330 dgst_size = DGST_SIZE_4_4;
9331 parse_func = pdf11cm1_parse_hash;
9332 sort_by_digest = sort_by_digest_4_4;
9333 opti_type = OPTI_TYPE_ZERO_BYTE
9334 | OPTI_TYPE_NOT_ITERATED;
9335 dgst_pos0 = 0;
9336 dgst_pos1 = 1;
9337 dgst_pos2 = 2;
9338 dgst_pos3 = 3;
9339 break;
9340
9341 case 10420: hash_type = HASH_TYPE_PDFU16;
9342 salt_type = SALT_TYPE_EMBEDDED;
9343 attack_exec = ATTACK_EXEC_ON_GPU;
9344 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9345 kern_type = KERN_TYPE_PDF11CM2;
9346 dgst_size = DGST_SIZE_4_4;
9347 parse_func = pdf11cm2_parse_hash;
9348 sort_by_digest = sort_by_digest_4_4;
9349 opti_type = OPTI_TYPE_ZERO_BYTE
9350 | OPTI_TYPE_NOT_ITERATED;
9351 dgst_pos0 = 0;
9352 dgst_pos1 = 1;
9353 dgst_pos2 = 2;
9354 dgst_pos3 = 3;
9355 break;
9356
9357 case 10500: hash_type = HASH_TYPE_PDFU16;
9358 salt_type = SALT_TYPE_EMBEDDED;
9359 attack_exec = ATTACK_EXEC_ON_CPU;
9360 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9361 kern_type = KERN_TYPE_PDF14;
9362 dgst_size = DGST_SIZE_4_4;
9363 parse_func = pdf14_parse_hash;
9364 sort_by_digest = sort_by_digest_4_4;
9365 opti_type = OPTI_TYPE_ZERO_BYTE
9366 | OPTI_TYPE_NOT_ITERATED;
9367 dgst_pos0 = 0;
9368 dgst_pos1 = 1;
9369 dgst_pos2 = 2;
9370 dgst_pos3 = 3;
9371 break;
9372
9373 case 10600: hash_type = HASH_TYPE_SHA256;
9374 salt_type = SALT_TYPE_EMBEDDED;
9375 attack_exec = ATTACK_EXEC_ON_GPU;
9376 opts_type = OPTS_TYPE_PT_GENERATE_BE
9377 | OPTS_TYPE_ST_ADD80
9378 | OPTS_TYPE_ST_ADDBITS15
9379 | OPTS_TYPE_HASH_COPY;
9380 kern_type = KERN_TYPE_SHA256_PWSLT;
9381 dgst_size = DGST_SIZE_4_8;
9382 parse_func = pdf17l3_parse_hash;
9383 sort_by_digest = sort_by_digest_4_8;
9384 opti_type = OPTI_TYPE_ZERO_BYTE
9385 | OPTI_TYPE_PRECOMPUTE_INIT
9386 | OPTI_TYPE_PRECOMPUTE_MERKLE
9387 | OPTI_TYPE_EARLY_SKIP
9388 | OPTI_TYPE_NOT_ITERATED
9389 | OPTI_TYPE_APPENDED_SALT
9390 | OPTI_TYPE_RAW_HASH;
9391 dgst_pos0 = 3;
9392 dgst_pos1 = 7;
9393 dgst_pos2 = 2;
9394 dgst_pos3 = 6;
9395 break;
9396
9397 case 10700: hash_type = HASH_TYPE_PDFU32;
9398 salt_type = SALT_TYPE_EMBEDDED;
9399 attack_exec = ATTACK_EXEC_ON_CPU;
9400 opts_type = OPTS_TYPE_PT_GENERATE_LE
9401 | OPTS_TYPE_HASH_COPY;
9402 kern_type = KERN_TYPE_PDF17L8;
9403 dgst_size = DGST_SIZE_4_8;
9404 parse_func = pdf17l8_parse_hash;
9405 sort_by_digest = sort_by_digest_4_8;
9406 opti_type = OPTI_TYPE_ZERO_BYTE
9407 | OPTI_TYPE_NOT_ITERATED;
9408 dgst_pos0 = 0;
9409 dgst_pos1 = 1;
9410 dgst_pos2 = 2;
9411 dgst_pos3 = 3;
9412 break;
9413
9414 case 10800: hash_type = HASH_TYPE_SHA384;
9415 salt_type = SALT_TYPE_NONE;
9416 attack_exec = ATTACK_EXEC_ON_GPU;
9417 opts_type = OPTS_TYPE_PT_GENERATE_BE
9418 | OPTS_TYPE_PT_ADD80
9419 | OPTS_TYPE_PT_ADDBITS15;
9420 kern_type = KERN_TYPE_SHA384;
9421 dgst_size = DGST_SIZE_8_8;
9422 parse_func = sha384_parse_hash;
9423 sort_by_digest = sort_by_digest_8_8;
9424 opti_type = OPTI_TYPE_ZERO_BYTE
9425 | OPTI_TYPE_PRECOMPUTE_INIT
9426 | OPTI_TYPE_PRECOMPUTE_MERKLE
9427 | OPTI_TYPE_EARLY_SKIP
9428 | OPTI_TYPE_NOT_ITERATED
9429 | OPTI_TYPE_NOT_SALTED
9430 | OPTI_TYPE_RAW_HASH;
9431 dgst_pos0 = 6;
9432 dgst_pos1 = 7;
9433 dgst_pos2 = 4;
9434 dgst_pos3 = 5;
9435 break;
9436
9437 case 10900: hash_type = HASH_TYPE_PBKDF2_SHA256;
9438 salt_type = SALT_TYPE_EMBEDDED;
9439 attack_exec = ATTACK_EXEC_ON_CPU;
9440 opts_type = OPTS_TYPE_PT_GENERATE_LE
9441 | OPTS_TYPE_ST_BASE64
9442 | OPTS_TYPE_HASH_COPY;
9443 kern_type = KERN_TYPE_PBKDF2_SHA256;
9444 dgst_size = DGST_SIZE_4_32;
9445 parse_func = pbkdf2_sha256_parse_hash;
9446 sort_by_digest = sort_by_digest_4_32;
9447 opti_type = OPTI_TYPE_ZERO_BYTE;
9448 dgst_pos0 = 0;
9449 dgst_pos1 = 1;
9450 dgst_pos2 = 2;
9451 dgst_pos3 = 3;
9452 break;
9453
9454 case 11000: hash_type = HASH_TYPE_MD5;
9455 salt_type = SALT_TYPE_INTERN;
9456 attack_exec = ATTACK_EXEC_ON_GPU;
9457 opts_type = OPTS_TYPE_PT_GENERATE_LE
9458 | OPTS_TYPE_PT_ADD80;
9459 kern_type = KERN_TYPE_PRESTASHOP;
9460 dgst_size = DGST_SIZE_4_4;
9461 parse_func = prestashop_parse_hash;
9462 sort_by_digest = sort_by_digest_4_4;
9463 opti_type = OPTI_TYPE_ZERO_BYTE
9464 | OPTI_TYPE_PRECOMPUTE_INIT
9465 | OPTI_TYPE_NOT_ITERATED
9466 | OPTI_TYPE_PREPENDED_SALT;
9467 dgst_pos0 = 0;
9468 dgst_pos1 = 3;
9469 dgst_pos2 = 2;
9470 dgst_pos3 = 1;
9471 break;
9472
9473 case 11100: hash_type = HASH_TYPE_MD5;
9474 salt_type = SALT_TYPE_EMBEDDED;
9475 attack_exec = ATTACK_EXEC_ON_GPU;
9476 opts_type = OPTS_TYPE_PT_GENERATE_LE
9477 | OPTS_TYPE_ST_ADD80;
9478 kern_type = KERN_TYPE_POSTGRESQL_AUTH;
9479 dgst_size = DGST_SIZE_4_4;
9480 parse_func = postgresql_auth_parse_hash;
9481 sort_by_digest = sort_by_digest_4_4;
9482 opti_type = OPTI_TYPE_ZERO_BYTE
9483 | OPTI_TYPE_PRECOMPUTE_INIT
9484 | OPTI_TYPE_PRECOMPUTE_MERKLE
9485 | OPTI_TYPE_EARLY_SKIP;
9486 dgst_pos0 = 0;
9487 dgst_pos1 = 3;
9488 dgst_pos2 = 2;
9489 dgst_pos3 = 1;
9490 break;
9491
9492 case 11200: hash_type = HASH_TYPE_SHA1;
9493 salt_type = SALT_TYPE_EMBEDDED;
9494 attack_exec = ATTACK_EXEC_ON_GPU;
9495 opts_type = OPTS_TYPE_PT_GENERATE_BE
9496 | OPTS_TYPE_PT_ADD80
9497 | OPTS_TYPE_ST_HEX;
9498 kern_type = KERN_TYPE_MYSQL_AUTH;
9499 dgst_size = DGST_SIZE_4_5;
9500 parse_func = mysql_auth_parse_hash;
9501 sort_by_digest = sort_by_digest_4_5;
9502 opti_type = OPTI_TYPE_ZERO_BYTE
9503 | OPTI_TYPE_EARLY_SKIP;
9504 dgst_pos0 = 3;
9505 dgst_pos1 = 4;
9506 dgst_pos2 = 2;
9507 dgst_pos3 = 1;
9508 break;
9509
9510 case 11300: hash_type = HASH_TYPE_BITCOIN_WALLET;
9511 salt_type = SALT_TYPE_EMBEDDED;
9512 attack_exec = ATTACK_EXEC_ON_CPU;
9513 opts_type = OPTS_TYPE_PT_GENERATE_LE
9514 | OPTS_TYPE_ST_HEX
9515 | OPTS_TYPE_ST_ADD80;
9516 kern_type = KERN_TYPE_BITCOIN_WALLET;
9517 dgst_size = DGST_SIZE_4_4;
9518 parse_func = bitcoin_wallet_parse_hash;
9519 sort_by_digest = sort_by_digest_4_4;
9520 opti_type = OPTI_TYPE_ZERO_BYTE;
9521 dgst_pos0 = 0;
9522 dgst_pos1 = 1;
9523 dgst_pos2 = 2;
9524 dgst_pos3 = 3;
9525 break;
9526
9527 case 11400: hash_type = HASH_TYPE_MD5;
9528 salt_type = SALT_TYPE_EMBEDDED;
9529 attack_exec = ATTACK_EXEC_ON_GPU;
9530 opts_type = OPTS_TYPE_PT_GENERATE_LE
9531 | OPTS_TYPE_PT_ADD80
9532 | OPTS_TYPE_HASH_COPY;
9533 kern_type = KERN_TYPE_SIP_AUTH;
9534 dgst_size = DGST_SIZE_4_4;
9535 parse_func = sip_auth_parse_hash;
9536 sort_by_digest = sort_by_digest_4_4;
9537 opti_type = OPTI_TYPE_ZERO_BYTE;
9538 dgst_pos0 = 0;
9539 dgst_pos1 = 3;
9540 dgst_pos2 = 2;
9541 dgst_pos3 = 1;
9542 break;
9543
9544 case 11500: hash_type = HASH_TYPE_CRC32;
9545 salt_type = SALT_TYPE_INTERN;
9546 attack_exec = ATTACK_EXEC_ON_GPU;
9547 opts_type = OPTS_TYPE_PT_GENERATE_LE
9548 | OPTS_TYPE_ST_GENERATE_LE
9549 | OPTS_TYPE_ST_HEX;
9550 kern_type = KERN_TYPE_CRC32;
9551 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9552 parse_func = crc32_parse_hash;
9553 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9554 opti_type = OPTI_TYPE_ZERO_BYTE;
9555 dgst_pos0 = 0;
9556 dgst_pos1 = 1;
9557 dgst_pos2 = 2;
9558 dgst_pos3 = 3;
9559 break;
9560
9561 case 11600: hash_type = HASH_TYPE_AES;
9562 salt_type = SALT_TYPE_EMBEDDED;
9563 attack_exec = ATTACK_EXEC_ON_CPU;
9564 opts_type = OPTS_TYPE_PT_GENERATE_LE
9565 | OPTS_TYPE_PT_NEVERCRACK;
9566 kern_type = KERN_TYPE_SEVEN_ZIP;
9567 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9568 parse_func = seven_zip_parse_hash;
9569 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9570 opti_type = OPTI_TYPE_ZERO_BYTE;
9571 dgst_pos0 = 0;
9572 dgst_pos1 = 1;
9573 dgst_pos2 = 2;
9574 dgst_pos3 = 3;
9575 break;
9576
9577 case 11700: hash_type = HASH_TYPE_GOST_2012SBOG_256;
9578 salt_type = SALT_TYPE_NONE;
9579 attack_exec = ATTACK_EXEC_ON_GPU;
9580 opts_type = OPTS_TYPE_PT_GENERATE_LE
9581 | OPTS_TYPE_PT_ADD01;
9582 kern_type = KERN_TYPE_GOST_2012SBOG_256;
9583 dgst_size = DGST_SIZE_4_8;
9584 parse_func = gost2012sbog_256_parse_hash;
9585 sort_by_digest = sort_by_digest_4_8;
9586 opti_type = OPTI_TYPE_ZERO_BYTE;
9587 dgst_pos0 = 0;
9588 dgst_pos1 = 1;
9589 dgst_pos2 = 2;
9590 dgst_pos3 = 3;
9591 break;
9592
9593 case 11800: hash_type = HASH_TYPE_GOST_2012SBOG_512;
9594 salt_type = SALT_TYPE_NONE;
9595 attack_exec = ATTACK_EXEC_ON_GPU;
9596 opts_type = OPTS_TYPE_PT_GENERATE_LE
9597 | OPTS_TYPE_PT_ADD01;
9598 kern_type = KERN_TYPE_GOST_2012SBOG_512;
9599 dgst_size = DGST_SIZE_4_16;
9600 parse_func = gost2012sbog_512_parse_hash;
9601 sort_by_digest = sort_by_digest_4_16;
9602 opti_type = OPTI_TYPE_ZERO_BYTE;
9603 dgst_pos0 = 0;
9604 dgst_pos1 = 1;
9605 dgst_pos2 = 2;
9606 dgst_pos3 = 3;
9607 break;
9608
9609 case 11900: hash_type = HASH_TYPE_PBKDF2_MD5;
9610 salt_type = SALT_TYPE_EMBEDDED;
9611 attack_exec = ATTACK_EXEC_ON_CPU;
9612 opts_type = OPTS_TYPE_PT_GENERATE_LE
9613 | OPTS_TYPE_ST_BASE64
9614 | OPTS_TYPE_HASH_COPY;
9615 kern_type = KERN_TYPE_PBKDF2_MD5;
9616 dgst_size = DGST_SIZE_4_32;
9617 parse_func = pbkdf2_md5_parse_hash;
9618 sort_by_digest = sort_by_digest_4_32;
9619 opti_type = OPTI_TYPE_ZERO_BYTE;
9620 dgst_pos0 = 0;
9621 dgst_pos1 = 1;
9622 dgst_pos2 = 2;
9623 dgst_pos3 = 3;
9624 break;
9625
9626 case 12000: hash_type = HASH_TYPE_PBKDF2_SHA1;
9627 salt_type = SALT_TYPE_EMBEDDED;
9628 attack_exec = ATTACK_EXEC_ON_CPU;
9629 opts_type = OPTS_TYPE_PT_GENERATE_LE
9630 | OPTS_TYPE_ST_BASE64
9631 | OPTS_TYPE_HASH_COPY;
9632 kern_type = KERN_TYPE_PBKDF2_SHA1;
9633 dgst_size = DGST_SIZE_4_32;
9634 parse_func = pbkdf2_sha1_parse_hash;
9635 sort_by_digest = sort_by_digest_4_32;
9636 opti_type = OPTI_TYPE_ZERO_BYTE;
9637 dgst_pos0 = 0;
9638 dgst_pos1 = 1;
9639 dgst_pos2 = 2;
9640 dgst_pos3 = 3;
9641 break;
9642
9643 case 12100: hash_type = HASH_TYPE_PBKDF2_SHA512;
9644 salt_type = SALT_TYPE_EMBEDDED;
9645 attack_exec = ATTACK_EXEC_ON_CPU;
9646 opts_type = OPTS_TYPE_PT_GENERATE_LE
9647 | OPTS_TYPE_ST_BASE64
9648 | OPTS_TYPE_HASH_COPY;
9649 kern_type = KERN_TYPE_PBKDF2_SHA512;
9650 dgst_size = DGST_SIZE_8_16;
9651 parse_func = pbkdf2_sha512_parse_hash;
9652 sort_by_digest = sort_by_digest_8_16;
9653 opti_type = OPTI_TYPE_ZERO_BYTE;
9654 dgst_pos0 = 0;
9655 dgst_pos1 = 1;
9656 dgst_pos2 = 2;
9657 dgst_pos3 = 3;
9658 break;
9659
9660 case 12200: hash_type = HASH_TYPE_ECRYPTFS;
9661 salt_type = SALT_TYPE_EMBEDDED;
9662 attack_exec = ATTACK_EXEC_ON_CPU;
9663 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9664 kern_type = KERN_TYPE_ECRYPTFS;
9665 dgst_size = DGST_SIZE_8_8;
9666 parse_func = ecryptfs_parse_hash;
9667 sort_by_digest = sort_by_digest_8_8;
9668 opti_type = OPTI_TYPE_ZERO_BYTE;
9669 dgst_pos0 = 0;
9670 dgst_pos1 = 1;
9671 dgst_pos2 = 2;
9672 dgst_pos3 = 3;
9673 break;
9674
9675 case 12300: hash_type = HASH_TYPE_ORACLET;
9676 salt_type = SALT_TYPE_EMBEDDED;
9677 attack_exec = ATTACK_EXEC_ON_CPU;
9678 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9679 kern_type = KERN_TYPE_ORACLET;
9680 dgst_size = DGST_SIZE_8_16;
9681 parse_func = oraclet_parse_hash;
9682 sort_by_digest = sort_by_digest_8_16;
9683 opti_type = OPTI_TYPE_ZERO_BYTE;
9684 dgst_pos0 = 0;
9685 dgst_pos1 = 1;
9686 dgst_pos2 = 2;
9687 dgst_pos3 = 3;
9688 break;
9689
9690 case 12400: hash_type = HASH_TYPE_BSDICRYPT;
9691 salt_type = SALT_TYPE_EMBEDDED;
9692 attack_exec = ATTACK_EXEC_ON_CPU;
9693 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9694 kern_type = KERN_TYPE_BSDICRYPT;
9695 dgst_size = DGST_SIZE_4_4;
9696 parse_func = bsdicrypt_parse_hash;
9697 sort_by_digest = sort_by_digest_4_4;
9698 opti_type = OPTI_TYPE_ZERO_BYTE
9699 | OPTI_TYPE_PRECOMPUTE_PERMUT;
9700 dgst_pos0 = 0;
9701 dgst_pos1 = 1;
9702 dgst_pos2 = 2;
9703 dgst_pos3 = 3;
9704 break;
9705
9706 case 12500: hash_type = HASH_TYPE_RAR3HP;
9707 salt_type = SALT_TYPE_EMBEDDED;
9708 attack_exec = ATTACK_EXEC_ON_CPU;
9709 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9710 kern_type = KERN_TYPE_RAR3;
9711 dgst_size = DGST_SIZE_4_4;
9712 parse_func = rar3hp_parse_hash;
9713 sort_by_digest = sort_by_digest_4_4;
9714 opti_type = OPTI_TYPE_ZERO_BYTE;
9715 dgst_pos0 = 0;
9716 dgst_pos1 = 1;
9717 dgst_pos2 = 2;
9718 dgst_pos3 = 3;
9719 break;
9720
9721 case 12600: hash_type = HASH_TYPE_SHA256;
9722 salt_type = SALT_TYPE_INTERN;
9723 attack_exec = ATTACK_EXEC_ON_GPU;
9724 opts_type = OPTS_TYPE_PT_GENERATE_BE
9725 | OPTS_TYPE_PT_ADD80;
9726 kern_type = KERN_TYPE_CF10;
9727 dgst_size = DGST_SIZE_4_8;
9728 parse_func = cf10_parse_hash;
9729 sort_by_digest = sort_by_digest_4_8;
9730 opti_type = OPTI_TYPE_ZERO_BYTE
9731 | OPTI_TYPE_PRECOMPUTE_INIT
9732 | OPTI_TYPE_EARLY_SKIP
9733 | OPTI_TYPE_NOT_ITERATED;
9734 dgst_pos0 = 3;
9735 dgst_pos1 = 7;
9736 dgst_pos2 = 2;
9737 dgst_pos3 = 6;
9738 break;
9739
9740 case 12700: hash_type = HASH_TYPE_AES;
9741 salt_type = SALT_TYPE_EMBEDDED;
9742 attack_exec = ATTACK_EXEC_ON_CPU;
9743 opts_type = OPTS_TYPE_PT_GENERATE_LE
9744 | OPTS_TYPE_HASH_COPY;
9745 kern_type = KERN_TYPE_MYWALLET;
9746 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
9747 parse_func = mywallet_parse_hash;
9748 sort_by_digest = sort_by_digest_4_5;
9749 opti_type = OPTI_TYPE_ZERO_BYTE;
9750 dgst_pos0 = 0;
9751 dgst_pos1 = 1;
9752 dgst_pos2 = 2;
9753 dgst_pos3 = 3;
9754 break;
9755
9756 case 12800: hash_type = HASH_TYPE_PBKDF2_SHA256;
9757 salt_type = SALT_TYPE_EMBEDDED;
9758 attack_exec = ATTACK_EXEC_ON_CPU;
9759 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9760 kern_type = KERN_TYPE_MS_DRSR;
9761 dgst_size = DGST_SIZE_4_8;
9762 parse_func = ms_drsr_parse_hash;
9763 sort_by_digest = sort_by_digest_4_8;
9764 opti_type = OPTI_TYPE_ZERO_BYTE;
9765 dgst_pos0 = 0;
9766 dgst_pos1 = 1;
9767 dgst_pos2 = 2;
9768 dgst_pos3 = 3;
9769 break;
9770
9771 default: usage_mini_print (PROGNAME); return (-1);
9772 }
9773
9774 /**
9775 * transpose
9776 */
9777
9778 data.parse_func = parse_func;
9779
9780 /**
9781 * misc stuff
9782 */
9783
9784 if (hex_salt)
9785 {
9786 if (salt_type == SALT_TYPE_INTERN)
9787 {
9788 opts_type |= OPTS_TYPE_ST_HEX;
9789 }
9790 else
9791 {
9792 log_error ("ERROR: Parameter hex-salt not valid for hash-type %u", hash_mode);
9793
9794 return (-1);
9795 }
9796 }
9797
9798 uint isSalted = ((salt_type == SALT_TYPE_INTERN)
9799 | (salt_type == SALT_TYPE_EXTERN)
9800 | (salt_type == SALT_TYPE_EMBEDDED)
9801 | (salt_type == SALT_TYPE_VIRTUAL));
9802
9803 sort_by_digest = sort_by_digest_p0p1; // overruled by 64 bit digest
9804
9805 data.hash_type = hash_type;
9806 data.attack_mode = attack_mode;
9807 data.attack_kern = attack_kern;
9808 data.attack_exec = attack_exec;
9809 data.kern_type = kern_type;
9810 data.opts_type = opts_type;
9811 data.dgst_size = dgst_size;
9812 data.salt_type = salt_type;
9813 data.isSalted = isSalted;
9814 data.sort_by_digest = sort_by_digest;
9815 data.dgst_pos0 = dgst_pos0;
9816 data.dgst_pos1 = dgst_pos1;
9817 data.dgst_pos2 = dgst_pos2;
9818 data.dgst_pos3 = dgst_pos3;
9819
9820 esalt_size = 0;
9821
9822 switch (hash_mode)
9823 {
9824 case 2500: esalt_size = sizeof (wpa_t); break;
9825 case 5300: esalt_size = sizeof (ikepsk_t); break;
9826 case 5400: esalt_size = sizeof (ikepsk_t); break;
9827 case 5500: esalt_size = sizeof (netntlm_t); break;
9828 case 5600: esalt_size = sizeof (netntlm_t); break;
9829 case 6211:
9830 case 6212:
9831 case 6213:
9832 case 6221:
9833 case 6222:
9834 case 6223:
9835 case 6231:
9836 case 6232:
9837 case 6233:
9838 case 6241:
9839 case 6242:
9840 case 6243: esalt_size = sizeof (tc_t); break;
9841 case 6600: esalt_size = sizeof (agilekey_t); break;
9842 case 7100: esalt_size = sizeof (pbkdf2_sha512_t); break;
9843 case 7200: esalt_size = sizeof (pbkdf2_sha512_t); break;
9844 case 7300: esalt_size = sizeof (rakp_t); break;
9845 case 7500: esalt_size = sizeof (krb5pa_t); break;
9846 case 8200: esalt_size = sizeof (cloudkey_t); break;
9847 case 8800: esalt_size = sizeof (androidfde_t); break;
9848 case 9200: esalt_size = sizeof (pbkdf2_sha256_t); break;
9849 case 9400: esalt_size = sizeof (office2007_t); break;
9850 case 9500: esalt_size = sizeof (office2010_t); break;
9851 case 9600: esalt_size = sizeof (office2013_t); break;
9852 case 9700: esalt_size = sizeof (oldoffice01_t); break;
9853 case 9710: esalt_size = sizeof (oldoffice01_t); break;
9854 case 9720: esalt_size = sizeof (oldoffice01_t); break;
9855 case 9800: esalt_size = sizeof (oldoffice34_t); break;
9856 case 9810: esalt_size = sizeof (oldoffice34_t); break;
9857 case 9820: esalt_size = sizeof (oldoffice34_t); break;
9858 case 10000: esalt_size = sizeof (pbkdf2_sha256_t); break;
9859 case 10200: esalt_size = sizeof (cram_md5_t); break;
9860 case 10400: esalt_size = sizeof (pdf_t); break;
9861 case 10410: esalt_size = sizeof (pdf_t); break;
9862 case 10420: esalt_size = sizeof (pdf_t); break;
9863 case 10500: esalt_size = sizeof (pdf_t); break;
9864 case 10600: esalt_size = sizeof (pdf_t); break;
9865 case 10700: esalt_size = sizeof (pdf_t); break;
9866 case 10900: esalt_size = sizeof (pbkdf2_sha256_t); break;
9867 case 11300: esalt_size = sizeof (bitcoin_wallet_t); break;
9868 case 11400: esalt_size = sizeof (sip_t); break;
9869 case 11600: esalt_size = sizeof (seven_zip_t); break;
9870 case 11900: esalt_size = sizeof (pbkdf2_md5_t); break;
9871 case 12000: esalt_size = sizeof (pbkdf2_sha1_t); break;
9872 case 12100: esalt_size = sizeof (pbkdf2_sha512_t); break;
9873 }
9874
9875 data.esalt_size = esalt_size;
9876
9877 /**
9878 * choose dictionary parser
9879 */
9880
9881 if (hash_type == HASH_TYPE_LM)
9882 {
9883 get_next_word_func = get_next_word_lm;
9884 }
9885 else if (opts_type & OPTS_TYPE_PT_UPPER)
9886 {
9887 get_next_word_func = get_next_word_uc;
9888 }
9889 else
9890 {
9891 get_next_word_func = get_next_word_std;
9892 }
9893
9894 /**
9895 * dictstat
9896 */
9897
9898 dictstat_t *dictstat_base = (dictstat_t *) mycalloc (MAX_DICTSTAT, sizeof (dictstat_t));
9899
9900 #ifdef _POSIX
9901 size_t dictstat_nmemb = 0;
9902 #endif
9903
9904 #ifdef _WIN
9905 uint dictstat_nmemb = 0;
9906 #endif
9907
9908 char dictstat[256];
9909
9910 FILE *dictstat_fp = NULL;
9911
9912 if (keyspace == 0)
9913 {
9914 memset (dictstat, 0, sizeof (dictstat));
9915
9916 snprintf (dictstat, sizeof (dictstat) - 1, "%s/hashcat.dictstat", profile_dir);
9917
9918 dictstat_fp = fopen (dictstat, "rb");
9919
9920 if (dictstat_fp)
9921 {
9922 #ifdef _POSIX
9923 struct stat tmpstat;
9924
9925 fstat (fileno (dictstat_fp), &tmpstat);
9926 #endif
9927
9928 #ifdef _WIN
9929 struct stat64 tmpstat;
9930
9931 _fstat64 (fileno (dictstat_fp), &tmpstat);
9932 #endif
9933
9934 if (tmpstat.st_mtime < COMPTIME)
9935 {
9936 /* with v0.15 the format changed so we have to ensure user is using a good version
9937 since there is no version-header in the dictstat file */
9938
9939 fclose (dictstat_fp);
9940
9941 unlink (dictstat);
9942 }
9943 else
9944 {
9945 while (!feof (dictstat_fp))
9946 {
9947 dictstat_t d;
9948
9949 if (fread (&d, sizeof (dictstat_t), 1, dictstat_fp) == 0) continue;
9950
9951 lsearch (&d, dictstat_base, &dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
9952
9953 if (dictstat_nmemb == (MAX_DICTSTAT - 1000))
9954 {
9955 log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat);
9956
9957 return -1;
9958 }
9959 }
9960
9961 fclose (dictstat_fp);
9962 }
9963 }
9964 }
9965
9966 /**
9967 * potfile
9968 */
9969
9970 char potfile[256];
9971
9972 memset (potfile, 0, sizeof (potfile));
9973
9974 snprintf (potfile, sizeof (potfile) - 1, "%s/%s.pot", session_dir, session);
9975
9976 data.pot_fp = NULL;
9977
9978 FILE *out_fp = NULL;
9979 FILE *pot_fp = NULL;
9980
9981 if (show == 1 || left == 1)
9982 {
9983 pot_fp = fopen (potfile, "rb");
9984
9985 if (pot_fp == NULL)
9986 {
9987 log_error ("ERROR: %s: %s", potfile, strerror (errno));
9988
9989 return (-1);
9990 }
9991
9992 if (outfile != NULL)
9993 {
9994 if ((out_fp = fopen (outfile, "ab")) == NULL)
9995 {
9996 log_error ("ERROR: %s: %s", outfile, strerror (errno));
9997
9998 fclose (pot_fp);
9999
10000 return (-1);
10001 }
10002 }
10003 else
10004 {
10005 out_fp = stdout;
10006 }
10007 }
10008 else
10009 {
10010 if (potfile_disable == 0)
10011 {
10012 pot_fp = fopen (potfile, "ab");
10013
10014 if (pot_fp == NULL)
10015 {
10016 log_error ("ERROR: %s: %s", potfile, strerror (errno));
10017
10018 return (-1);
10019 }
10020
10021 data.pot_fp = pot_fp;
10022 }
10023 }
10024
10025 pot_t *pot = NULL;
10026
10027 uint pot_cnt = 0;
10028 uint pot_avail = 0;
10029
10030 if (show == 1 || left == 1)
10031 {
10032 SUPPRESS_OUTPUT = 1;
10033
10034 pot_avail = count_lines (pot_fp);
10035
10036 rewind (pot_fp);
10037
10038 pot = (pot_t *) mycalloc (pot_avail, sizeof (pot_t));
10039
10040 uint pot_hashes_avail = 0;
10041
10042 uint line_num = 0;
10043
10044 while (!feof (pot_fp))
10045 {
10046 line_num++;
10047
10048 char line_buf[BUFSIZ];
10049
10050 int line_len = fgetl (pot_fp, line_buf);
10051
10052 if (line_len == 0) continue;
10053
10054 char *plain_buf = line_buf + line_len;
10055
10056 pot_t *pot_ptr = &pot[pot_cnt];
10057
10058 hash_t *hashes_buf = &pot_ptr->hash;
10059
10060 // we do not initialize all hashes_buf->digest etc at the beginning, since many lines may not be
10061 // valid lines of this specific hash type (otherwise it would be more waste of memory than gain)
10062
10063 if (pot_cnt == pot_hashes_avail)
10064 {
10065 uint pos = 0;
10066
10067 for (pos = 0; pos < INCR_POT; pos++)
10068 {
10069 if ((pot_cnt + pos) >= pot_avail) break;
10070
10071 pot_t *tmp_pot = &pot[pot_cnt + pos];
10072
10073 hash_t *tmp_hash = &tmp_pot->hash;
10074
10075 tmp_hash->digest = mymalloc (dgst_size);
10076
10077 if (isSalted)
10078 {
10079 tmp_hash->salt = (salt_t *) mymalloc (sizeof (salt_t));
10080 }
10081
10082 if (esalt_size)
10083 {
10084 tmp_hash->esalt = mymalloc (esalt_size);
10085 }
10086
10087 pot_hashes_avail++;
10088 }
10089 }
10090
10091 int plain_len = 0;
10092
10093 int parser_status;
10094
10095 int iter = MAX_CUT_TRIES;
10096
10097 do
10098 {
10099 for (int i = line_len - 1; i; i--, plain_len++, plain_buf--, line_len--)
10100 {
10101 if (line_buf[i] == ':')
10102 {
10103 line_len--;
10104
10105 break;
10106 }
10107 }
10108
10109 if (data.hash_mode != 2500)
10110 {
10111 parser_status = parse_func (line_buf, line_len, hashes_buf);
10112 }
10113 else
10114 {
10115 int max_salt_size = sizeof (hashes_buf->salt->salt_buf);
10116
10117 if (line_len > max_salt_size)
10118 {
10119 parser_status = PARSER_GLOBAL_LENGTH;
10120 }
10121 else
10122 {
10123 memset (&hashes_buf->salt->salt_buf, 0, max_salt_size);
10124
10125 memcpy (&hashes_buf->salt->salt_buf, line_buf, line_len);
10126
10127 hashes_buf->salt->salt_len = line_len;
10128
10129 parser_status = PARSER_OK;
10130 }
10131 }
10132
10133 // if NOT parsed without error, we add the ":" to the plain
10134
10135 if (parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH)
10136 {
10137 plain_len++;
10138 plain_buf--;
10139 }
10140
10141 } while ((parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH) && --iter);
10142
10143 if (parser_status < PARSER_GLOBAL_ZERO)
10144 {
10145 // log_info ("WARNING: Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status));
10146
10147 continue;
10148 }
10149
10150 memcpy (pot_ptr->plain_buf, plain_buf, plain_len);
10151
10152 pot_ptr->plain_len = plain_len;
10153
10154 pot_cnt++;
10155 }
10156
10157 fclose (pot_fp);
10158
10159 SUPPRESS_OUTPUT = 0;
10160
10161 qsort (pot, pot_cnt, sizeof (pot_t), sort_by_pot);
10162 }
10163
10164 /**
10165 * gpu accel and loops auto adjustment
10166 */
10167
10168 if (gpu_accel_chgd == 0) gpu_accel = set_gpu_accel (hash_mode);
10169 if (gpu_loops_chgd == 0) gpu_loops = set_gpu_loops (hash_mode);
10170
10171 if (workload_profile == 1)
10172 {
10173 gpu_loops /= 8;
10174 gpu_accel /= 4;
10175
10176 if (gpu_loops == 0) gpu_loops = 8;
10177 if (gpu_accel == 0) gpu_accel = 2;
10178 }
10179 else if (workload_profile == 3)
10180 {
10181 gpu_loops *= 8;
10182 gpu_accel *= 4;
10183
10184 if (gpu_loops > 1024) gpu_loops = 1024;
10185 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
10186 }
10187
10188 // those hashes *must* run at a specific gpu_loops count because of some optimization inside the kernel
10189
10190 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
10191 {
10192 gpu_loops = 1024;
10193 }
10194
10195 if (hash_mode == 12500)
10196 {
10197 gpu_loops = ROUNDS_RAR3 / 16;
10198 }
10199
10200 data.gpu_accel = gpu_accel;
10201 data.gpu_loops = gpu_loops;
10202
10203 /**
10204 * word len
10205 */
10206
10207 uint pw_min = PW_MIN;
10208 uint pw_max = PW_MAX;
10209
10210 switch (hash_mode)
10211 {
10212 case 400: if (pw_max > 40) pw_max = 40;
10213 break;
10214 case 500: if (pw_max > 16) pw_max = 16;
10215 break;
10216 case 1500: if (pw_max > 8) pw_max = 8;
10217 break;
10218 case 1600: if (pw_max > 16) pw_max = 16;
10219 break;
10220 case 1800: if (pw_max > 16) pw_max = 16;
10221 break;
10222 case 2100: if (pw_max > 16) pw_max = 16;
10223 break;
10224 case 2500: if (pw_min < 8) pw_min = 8;
10225 break;
10226 case 3000: if (pw_max > 7) pw_max = 7;
10227 break;
10228 case 5200: if (pw_max > 24) pw_max = 24;
10229 break;
10230 case 5800: if (pw_max > 16) pw_max = 16;
10231 break;
10232 case 6300: if (pw_max > 16) pw_max = 16;
10233 break;
10234 case 7400: if (pw_max > 16) pw_max = 16;
10235 break;
10236 case 7900: if (pw_max > 48) pw_max = 48;
10237 break;
10238 case 8500: if (pw_max > 8) pw_max = 8;
10239 break;
10240 case 8600: if (pw_max > 16) pw_max = 16;
10241 break;
10242 case 9710: pw_min = 5;
10243 pw_max = 5;
10244 break;
10245 case 9810: pw_min = 5;
10246 pw_max = 5;
10247 break;
10248 case 10410: pw_min = 5;
10249 pw_max = 5;
10250 break;
10251 case 10300: if (pw_max < 3) pw_min = 3;
10252 if (pw_max > 40) pw_max = 40;
10253 break;
10254 case 10500: if (pw_max < 3) pw_min = 3;
10255 if (pw_max > 40) pw_max = 40;
10256 break;
10257 case 10700: if (pw_max > 16) pw_max = 16;
10258 break;
10259 case 11300: if (pw_max > 40) pw_max = 40;
10260 break;
10261 case 12500: if (pw_max > 20) pw_max = 20;
10262 break;
10263 case 12800: if (pw_max > 24) pw_max = 24;
10264 break;
10265 }
10266
10267 if (attack_exec == ATTACK_EXEC_ON_GPU)
10268 {
10269 switch (attack_kern)
10270 {
10271 case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
10272 break;
10273 case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
10274 break;
10275 }
10276 }
10277
10278 /**
10279 * charsets : keep them together for more easy maintainnce
10280 */
10281
10282 cs_t mp_sys[6];
10283 cs_t mp_usr[4];
10284
10285 memset (mp_sys, 0, sizeof (mp_sys));
10286 memset (mp_usr, 0, sizeof (mp_usr));
10287
10288 mp_setup_sys (mp_sys);
10289
10290 if (custom_charset_1) mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
10291 if (custom_charset_2) mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
10292 if (custom_charset_3) mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
10293 if (custom_charset_4) mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
10294
10295 /**
10296 * load hashes, part I: find input mode, count hashes
10297 */
10298
10299 uint hashlist_mode = 0;
10300 uint hashlist_format = HLFMT_HASHCAT;
10301
10302 uint hashes_avail = 0;
10303
10304 if (benchmark == 0)
10305 {
10306 struct stat f;
10307
10308 hashlist_mode = (stat (myargv[optind], &f) == 0) ? HL_MODE_FILE : HL_MODE_ARG;
10309
10310 if ((hash_mode == 2500) ||
10311 (hash_mode == 5200) ||
10312 ((hash_mode >= 6200) && (hash_mode <= 6299)) ||
10313 (hash_mode == 9000))
10314 {
10315 hashlist_mode = HL_MODE_ARG;
10316
10317 char *hashfile = myargv[optind];
10318
10319 data.hashfile = hashfile;
10320
10321 logfile_top_var_string ("target", hashfile);
10322 }
10323
10324 if (hashlist_mode == HL_MODE_ARG)
10325 {
10326 if (hash_mode == 2500)
10327 {
10328 struct stat st;
10329
10330 if (stat (data.hashfile, &st) == -1)
10331 {
10332 log_error ("ERROR: %s: %s", data.hashfile, strerror (errno));
10333
10334 return (-1);
10335 }
10336
10337 hashes_avail = st.st_size / sizeof (hccap_t);
10338 }
10339 else
10340 {
10341 hashes_avail = 1;
10342 }
10343 }
10344 else if (hashlist_mode == HL_MODE_FILE)
10345 {
10346 char *hashfile = myargv[optind];
10347
10348 data.hashfile = hashfile;
10349
10350 logfile_top_var_string ("target", hashfile);
10351
10352 FILE *fp = NULL;
10353
10354 if ((fp = fopen (hashfile, "rb")) == NULL)
10355 {
10356 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
10357
10358 return (-1);
10359 }
10360
10361 if (data.quiet == 0) log_info_nn ("Counting lines in %s", hashfile);
10362
10363 hashes_avail = count_lines (fp);
10364
10365 rewind (fp);
10366
10367 if (hashes_avail == 0)
10368 {
10369 log_error ("ERROR: hashfile is empty or corrupt");
10370
10371 fclose (fp);
10372
10373 return (-1);
10374 }
10375
10376 hashlist_format = hlfmt_detect (fp, 100); // 100 = max numbers to "scan". could be hashes_avail, too
10377
10378 if ((remove == 1) && (hashlist_format != HLFMT_HASHCAT))
10379 {
10380 log_error ("ERROR: remove not supported in native hashfile-format mode");
10381
10382 fclose (fp);
10383
10384 return (-1);
10385 }
10386
10387 fclose (fp);
10388 }
10389 }
10390 else
10391 {
10392 hashlist_mode = HL_MODE_ARG;
10393
10394 hashes_avail = 1;
10395 }
10396
10397 if (hash_mode == 3000) hashes_avail *= 2;
10398
10399 data.hashlist_mode = hashlist_mode;
10400 data.hashlist_format = hashlist_format;
10401
10402 logfile_top_uint (hashlist_mode);
10403 logfile_top_uint (hashlist_format);
10404
10405 /**
10406 * load hashes, part II: allocate required memory, set pointers
10407 */
10408
10409 hash_t *hashes_buf = NULL;
10410 void *digests_buf = NULL;
10411 salt_t *salts_buf = NULL;
10412 void *esalts_buf = NULL;
10413
10414 hashes_buf = (hash_t *) mycalloc (hashes_avail, sizeof (hash_t));
10415
10416 digests_buf = (void *) mycalloc (hashes_avail, dgst_size);
10417
10418 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
10419 {
10420 uint32_t hash_pos;
10421
10422 for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
10423 {
10424 hashinfo_t *hash_info = (hashinfo_t *) mymalloc (sizeof (hashinfo_t));
10425
10426 hashes_buf[hash_pos].hash_info = hash_info;
10427
10428 if (username && (remove || show || left))
10429 {
10430 hash_info->user = (user_t*) mymalloc (sizeof (user_t));
10431 }
10432
10433 if (benchmark)
10434 {
10435 hash_info->orighash = (char *) mymalloc (256);
10436 }
10437 }
10438 }
10439
10440 if (isSalted)
10441 {
10442 salts_buf = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
10443
10444 if (esalt_size)
10445 {
10446 esalts_buf = (void *) mycalloc (hashes_avail, esalt_size);
10447 }
10448 }
10449 else
10450 {
10451 salts_buf = (salt_t *) mycalloc (1, sizeof (salt_t));
10452 }
10453
10454 for (uint hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
10455 {
10456 hashes_buf[hash_pos].digest = ((char *) digests_buf) + (hash_pos * dgst_size);
10457
10458 if (isSalted)
10459 {
10460 hashes_buf[hash_pos].salt = &salts_buf[hash_pos];
10461
10462 if (esalt_size)
10463 {
10464 hashes_buf[hash_pos].esalt = ((char *) esalts_buf) + (hash_pos * esalt_size);
10465 }
10466 }
10467 else
10468 {
10469 hashes_buf[hash_pos].salt = &salts_buf[0];
10470 }
10471 }
10472
10473 /**
10474 * load hashes, part III: parse hashes or generate them if benchmark
10475 */
10476
10477 uint hashes_cnt = 0;
10478
10479 if (benchmark == 0)
10480 {
10481 if (keyspace == 1)
10482 {
10483 // useless to read hash file for keyspace, cheat a little bit w/ optind
10484 }
10485 else if (hashes_avail == 0)
10486 {
10487 }
10488 else if (hashlist_mode == HL_MODE_ARG)
10489 {
10490 char *input_buf = myargv[optind];
10491
10492 uint input_len = strlen (input_buf);
10493
10494 logfile_top_var_string ("target", input_buf);
10495
10496 char *hash_buf = NULL;
10497 int hash_len = 0;
10498
10499 hlfmt_hash (hashlist_format, input_buf, input_len, &hash_buf, &hash_len);
10500
10501 if (hash_len)
10502 {
10503 if (opts_type & OPTS_TYPE_HASH_COPY)
10504 {
10505 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
10506
10507 hash_info_tmp->orighash = mystrdup (hash_buf);
10508 }
10509
10510 if (isSalted)
10511 {
10512 memset (hashes_buf[0].salt, 0, sizeof (salt_t));
10513 }
10514
10515 int parser_status = PARSER_OK;
10516
10517 if (hash_mode == 2500)
10518 {
10519 if (hash_len == 0)
10520 {
10521 log_error ("ERROR: hccap file not specified");
10522
10523 return (-1);
10524 }
10525
10526 hashlist_mode = HL_MODE_FILE;
10527
10528 data.hashlist_mode = hashlist_mode;
10529
10530 FILE *fp = fopen (hash_buf, "rb");
10531
10532 if (fp == NULL)
10533 {
10534 log_error ("ERROR: %s: %s", hash_buf, strerror (errno));
10535
10536 return (-1);
10537 }
10538
10539 if (hashes_avail < 1)
10540 {
10541 log_error ("ERROR: hccap file is empty or corrupt");
10542
10543 fclose (fp);
10544
10545 return (-1);
10546 }
10547
10548 uint hccap_size = sizeof (hccap_t);
10549
10550 char in[hccap_size];
10551
10552 while (!feof (fp))
10553 {
10554 int n = fread (&in, hccap_size, 1, fp);
10555
10556 if (n != 1)
10557 {
10558 if (hashes_cnt < 1) parser_status = PARSER_HCCAP_FILE_SIZE;
10559
10560 break;
10561 }
10562
10563 parser_status = parse_func (in, hccap_size, &hashes_buf[hashes_cnt]);
10564
10565 if (parser_status != PARSER_OK)
10566 {
10567 log_info ("WARNING: Hash '%s': %s", hash_buf, strparser (parser_status));
10568
10569 continue;
10570 }
10571
10572 // hack: append MAC1 and MAC2 s.t. in --show and --left the line matches with the .pot file format (i.e. ESSID:MAC1:MAC2)
10573
10574 if ((show == 1) || (left == 1))
10575 {
10576 salt_t *tmp_salt = hashes_buf[hashes_cnt].salt;
10577
10578 char *salt_ptr = (char *) tmp_salt->salt_buf;
10579
10580 int cur_pos = tmp_salt->salt_len;
10581 int rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
10582
10583 wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt;
10584
10585 unsigned char *pke_ptr = (unsigned char *) wpa->pke;
10586
10587 // do the appending task
10588
10589 snprintf (salt_ptr + cur_pos,
10590 rem_len,
10591 ":%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
10592 pke_ptr[20], pke_ptr[27], pke_ptr[26], pke_ptr[25], pke_ptr[24], pke_ptr[31], // MAC1
10593 pke_ptr[30], pke_ptr[29], pke_ptr[28], pke_ptr[35], pke_ptr[34], pke_ptr[33]); // MAC2
10594
10595
10596 // memset () the remaining part of the salt
10597
10598 cur_pos = tmp_salt->salt_len + 1 + 12 + 1 + 12;
10599 rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
10600
10601 if (rem_len > 0) memset (salt_ptr + cur_pos, 0, rem_len);
10602
10603 tmp_salt->salt_len += 1 + 12 + 1 + 12;
10604 }
10605
10606 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);
10607 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);
10608
10609 hashes_cnt++;
10610 }
10611
10612 fclose (fp);
10613 }
10614 else if (hash_mode == 3000)
10615 {
10616 if (hash_len == 32)
10617 {
10618 parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
10619
10620 hash_t *lm_hash_left = NULL;
10621
10622 if (parser_status == PARSER_OK)
10623 {
10624 lm_hash_left = &hashes_buf[hashes_cnt];
10625
10626 hashes_cnt++;
10627 }
10628 else
10629 {
10630 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
10631 }
10632
10633
10634 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
10635
10636 hash_t *lm_hash_right = NULL;
10637
10638 if (parser_status == PARSER_OK)
10639 {
10640 lm_hash_right = &hashes_buf[hashes_cnt];
10641
10642 hashes_cnt++;
10643 }
10644 else
10645 {
10646 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
10647 }
10648
10649 // show / left
10650
10651 if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
10652 {
10653 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);
10654 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);
10655 }
10656 }
10657 else
10658 {
10659 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
10660
10661 if (parser_status == PARSER_OK)
10662 {
10663 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10664 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10665 }
10666
10667 if (parser_status == PARSER_OK)
10668 {
10669 hashes_cnt++;
10670 }
10671 else
10672 {
10673 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
10674 }
10675 }
10676 }
10677 else
10678 {
10679 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
10680
10681 if (parser_status == PARSER_OK)
10682 {
10683 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10684 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10685 }
10686
10687 if (parser_status == PARSER_OK)
10688 {
10689 hashes_cnt++;
10690 }
10691 else
10692 {
10693 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
10694 }
10695 }
10696 }
10697 }
10698 else if (hashlist_mode == HL_MODE_FILE)
10699 {
10700 char *hashfile = data.hashfile;
10701
10702 FILE *fp;
10703
10704 if ((fp = fopen (hashfile, "rb")) == NULL)
10705 {
10706 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
10707
10708 return (-1);
10709 }
10710
10711 uint line_num = 0;
10712
10713 while (!feof (fp))
10714 {
10715 line_num++;
10716
10717 char line_buf[BUFSIZ];
10718
10719 int line_len = fgetl (fp, line_buf);
10720
10721 if (line_len == 0) continue;
10722
10723 char *hash_buf = NULL;
10724 int hash_len = 0;
10725
10726 hlfmt_hash (hashlist_format, line_buf, line_len, &hash_buf, &hash_len);
10727
10728 if (username)
10729 {
10730 char *user_buf = NULL;
10731 int user_len = 0;
10732
10733 hlfmt_user (hashlist_format, line_buf, line_len, &user_buf, &user_len);
10734
10735 if (remove || show)
10736 {
10737 user_t **user = &hashes_buf[hashes_cnt].hash_info->user;
10738
10739 *user = (user_t *) malloc (sizeof (user_t));
10740
10741 user_t *user_ptr = *user;
10742
10743 if (user_buf != NULL)
10744 {
10745 user_ptr->user_name = mystrdup (user_buf);
10746 }
10747 else
10748 {
10749 user_ptr->user_name = mystrdup ("");
10750 }
10751
10752 user_ptr->user_len = user_len;
10753 }
10754 }
10755
10756 if (opts_type & OPTS_TYPE_HASH_COPY)
10757 {
10758 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
10759
10760 hash_info_tmp->orighash = mystrdup (hash_buf);
10761 }
10762
10763 if (isSalted)
10764 {
10765 memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t));
10766 }
10767
10768 if (hash_mode == 3000)
10769 {
10770 if (hash_len == 32)
10771 {
10772 int parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
10773
10774 if (parser_status < PARSER_GLOBAL_ZERO)
10775 {
10776 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
10777
10778 continue;
10779 }
10780
10781 hash_t *lm_hash_left = &hashes_buf[hashes_cnt];
10782
10783 hashes_cnt++;
10784
10785 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
10786
10787 if (parser_status < PARSER_GLOBAL_ZERO)
10788 {
10789 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
10790
10791 continue;
10792 }
10793
10794 hash_t *lm_hash_right = &hashes_buf[hashes_cnt];
10795
10796 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);
10797
10798 hashes_cnt++;
10799
10800 // show / left
10801
10802 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);
10803 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);
10804 }
10805 else
10806 {
10807 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
10808
10809 if (parser_status < PARSER_GLOBAL_ZERO)
10810 {
10811 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
10812
10813 continue;
10814 }
10815
10816 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);
10817
10818 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10819 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10820
10821 hashes_cnt++;
10822 }
10823 }
10824 else
10825 {
10826 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
10827
10828 if (parser_status < PARSER_GLOBAL_ZERO)
10829 {
10830 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
10831
10832 continue;
10833 }
10834
10835 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);
10836
10837 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10838 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
10839
10840 hashes_cnt++;
10841 }
10842 }
10843
10844 fclose (fp);
10845
10846 if (data.quiet == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
10847
10848 if ((out_fp != NULL) && (out_fp != stdout)) fclose (out_fp);
10849 }
10850 }
10851 else
10852 {
10853 if (isSalted)
10854 {
10855 hashes_buf[0].salt->salt_len = 8;
10856
10857 // special salt handling
10858
10859 switch (hash_mode)
10860 {
10861 case 1500: hashes_buf[0].salt->salt_len = 2;
10862 break;
10863 case 1731: hashes_buf[0].salt->salt_len = 4;
10864 break;
10865 case 2410: hashes_buf[0].salt->salt_len = 4;
10866 break;
10867 case 2500: memcpy (hashes_buf[0].salt->salt_buf, "hashcat.net", 11);
10868 break;
10869 case 3100: hashes_buf[0].salt->salt_len = 1;
10870 break;
10871 case 5000: hashes_buf[0].salt->keccak_mdlen = 32;
10872 break;
10873 case 5800: hashes_buf[0].salt->salt_len = 16;
10874 break;
10875 case 6800: hashes_buf[0].salt->salt_len = 32;
10876 break;
10877 case 8400: hashes_buf[0].salt->salt_len = 40;
10878 break;
10879 case 8800: hashes_buf[0].salt->salt_len = 16;
10880 break;
10881 case 8900: hashes_buf[0].salt->salt_len = 16;
10882 hashes_buf[0].salt->scrypt_N = 1024;
10883 hashes_buf[0].salt->scrypt_r = 1;
10884 hashes_buf[0].salt->scrypt_p = 1;
10885 break;
10886 case 9100: hashes_buf[0].salt->salt_len = 16;
10887 break;
10888 case 9300: hashes_buf[0].salt->salt_len = 14;
10889 hashes_buf[0].salt->scrypt_N = 16384;
10890 hashes_buf[0].salt->scrypt_r = 1;
10891 hashes_buf[0].salt->scrypt_p = 1;
10892 break;
10893 case 9400: hashes_buf[0].salt->salt_len = 16;
10894 break;
10895 case 9500: hashes_buf[0].salt->salt_len = 16;
10896 break;
10897 case 9600: hashes_buf[0].salt->salt_len = 16;
10898 break;
10899 case 9700: hashes_buf[0].salt->salt_len = 16;
10900 break;
10901 case 9710: hashes_buf[0].salt->salt_len = 16;
10902 break;
10903 case 9720: hashes_buf[0].salt->salt_len = 16;
10904 break;
10905 case 9800: hashes_buf[0].salt->salt_len = 16;
10906 break;
10907 case 9810: hashes_buf[0].salt->salt_len = 16;
10908 break;
10909 case 9820: hashes_buf[0].salt->salt_len = 16;
10910 break;
10911 case 10300: hashes_buf[0].salt->salt_len = 12;
10912 break;
10913 case 11500: hashes_buf[0].salt->salt_len = 4;
10914 break;
10915 case 11600: hashes_buf[0].salt->salt_len = 4;
10916 break;
10917 case 12400: hashes_buf[0].salt->salt_len = 4;
10918 break;
10919 case 12500: hashes_buf[0].salt->salt_len = 8;
10920 break;
10921 case 12600: hashes_buf[0].salt->salt_len = 64;
10922 break;
10923 }
10924
10925 // special esalt handling
10926
10927 switch (hash_mode)
10928 {
10929 case 2500: ((wpa_t *) hashes_buf[0].esalt)->eapol_size = 128;
10930 break;
10931 case 5300: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
10932 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
10933 break;
10934 case 5400: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
10935 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
10936 break;
10937 case 5500: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
10938 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
10939 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
10940 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
10941 break;
10942 case 5600: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
10943 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
10944 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
10945 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
10946 break;
10947 case 7300: ((rakp_t *) hashes_buf[0].esalt)->salt_len = 32;
10948 break;
10949 case 10400: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10950 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
10951 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
10952 break;
10953 case 10410: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10954 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
10955 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
10956 break;
10957 case 10420: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10958 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
10959 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
10960 break;
10961 case 10500: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10962 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
10963 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
10964 break;
10965 case 10600: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10966 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
10967 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
10968 break;
10969 case 10700: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
10970 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
10971 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
10972 break;
10973 case 11600: ((seven_zip_t *) hashes_buf[0].esalt)->iv_len = 16;
10974 ((seven_zip_t *) hashes_buf[0].esalt)->data_len = 112;
10975 ((seven_zip_t *) hashes_buf[0].esalt)->unpack_size = 112;
10976 break;
10977 }
10978 }
10979
10980 // set hashfile
10981
10982 switch (hash_mode)
10983 {
10984 case 5200: data.hashfile = mystrdup ("hashcat.psafe3");
10985 break;
10986 case 5300: data.hashfile = mystrdup ("hashcat.ikemd5");
10987 break;
10988 case 5400: data.hashfile = mystrdup ("hashcat.ikesha1");
10989 break;
10990 case 6211:
10991 case 6212:
10992 case 6213:
10993 case 6221:
10994 case 6222:
10995 case 6223:
10996 case 6231:
10997 case 6232:
10998 case 6233:
10999 case 6241:
11000 case 6242:
11001 case 6243: data.hashfile = mystrdup ("hashcat.tc");
11002 break;
11003 case 6600: data.hashfile = mystrdup ("hashcat.agilekey");
11004 break;
11005 case 8200: data.hashfile = mystrdup ("hashcat.cloudkey");
11006 break;
11007 case 9000: data.hashfile = mystrdup ("hashcat.psafe2");
11008 break;
11009 }
11010
11011 // set default iterations
11012
11013 switch (hash_mode)
11014 {
11015 case 400: hashes_buf[0].salt->salt_iter = ROUNDS_PHPASS;
11016 break;
11017 case 500: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11018 break;
11019 case 501: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11020 break;
11021 case 1600: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11022 break;
11023 case 1800: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512CRYPT;
11024 break;
11025 case 2100: hashes_buf[0].salt->salt_iter = ROUNDS_DCC2;
11026 break;
11027 case 2500: hashes_buf[0].salt->salt_iter = ROUNDS_WPA2;
11028 break;
11029 case 3200: hashes_buf[0].salt->salt_iter = ROUNDS_BCRYPT;
11030 break;
11031 case 5200: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE3;
11032 break;
11033 case 5800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDPIN - 1;
11034 break;
11035 case 6211:
11036 case 6212:
11037 case 6213: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_2K;
11038 break;
11039 case 6221:
11040 case 6222:
11041 case 6223: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11042 break;
11043 case 6231:
11044 case 6232:
11045 case 6233: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11046 break;
11047 case 6241:
11048 case 6242:
11049 case 6243: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11050 break;
11051 case 6300: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11052 break;
11053 case 6400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256AIX;
11054 break;
11055 case 6500: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512AIX;
11056 break;
11057 case 6700: hashes_buf[0].salt->salt_iter = ROUNDS_SHA1AIX;
11058 break;
11059 case 6600: hashes_buf[0].salt->salt_iter = ROUNDS_AGILEKEY;
11060 break;
11061 case 6800: hashes_buf[0].salt->salt_iter = ROUNDS_LASTPASS;
11062 break;
11063 case 7100: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512OSX;
11064 break;
11065 case 7200: hashes_buf[0].salt->salt_iter = ROUNDS_GRUB;
11066 break;
11067 case 7400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256CRYPT;
11068 break;
11069 case 7900: hashes_buf[0].salt->salt_iter = ROUNDS_DRUPAL7;
11070 break;
11071 case 8200: hashes_buf[0].salt->salt_iter = ROUNDS_CLOUDKEY;
11072 break;
11073 case 8300: hashes_buf[0].salt->salt_iter = ROUNDS_NSEC3;
11074 break;
11075 case 8800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDFDE;
11076 break;
11077 case 8900: hashes_buf[0].salt->salt_iter = 1;
11078 break;
11079 case 9000: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE2;
11080 break;
11081 case 9100: hashes_buf[0].salt->salt_iter = ROUNDS_LOTUS8;
11082 break;
11083 case 9200: hashes_buf[0].salt->salt_iter = ROUNDS_CISCO8;
11084 break;
11085 case 9300: hashes_buf[0].salt->salt_iter = 1;
11086 break;
11087 case 9400: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2007;
11088 break;
11089 case 9500: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2010;
11090 break;
11091 case 9600: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2013;
11092 break;
11093 case 10000: hashes_buf[0].salt->salt_iter = ROUNDS_DJANGOPBKDF2;
11094 break;
11095 case 10300: hashes_buf[0].salt->salt_iter = ROUNDS_SAPH_SHA1 - 1;
11096 break;
11097 case 10500: hashes_buf[0].salt->salt_iter = ROUNDS_PDF14;
11098 break;
11099 case 10700: hashes_buf[0].salt->salt_iter = ROUNDS_PDF17L8;
11100 break;
11101 case 10900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA256 - 1;
11102 break;
11103 case 11300: hashes_buf[0].salt->salt_iter = ROUNDS_BITCOIN_WALLET - 1;
11104 break;
11105 case 11600: hashes_buf[0].salt->salt_iter = ROUNDS_SEVEN_ZIP;
11106 break;
11107 case 11900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_MD5 - 1;
11108 break;
11109 case 12000: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA1 - 1;
11110 break;
11111 case 12100: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA512 - 1;
11112 break;
11113 case 12200: hashes_buf[0].salt->salt_iter = ROUNDS_ECRYPTFS - 1;
11114 break;
11115 case 12300: hashes_buf[0].salt->salt_iter = ROUNDS_ORACLET - 1;
11116 break;
11117 case 12400: hashes_buf[0].salt->salt_iter = ROUNDS_BSDICRYPT - 1;
11118 break;
11119 case 12500: hashes_buf[0].salt->salt_iter = ROUNDS_RAR3;
11120 break;
11121 case 12700: hashes_buf[0].salt->salt_iter = ROUNDS_MYWALLET;
11122 break;
11123 case 12800: hashes_buf[0].salt->salt_iter = ROUNDS_MS_DRSR - 1;
11124 break;
11125 }
11126
11127 // set special tuning for benchmark-mode 1
11128
11129 if (benchmark_mode == 1)
11130 {
11131 gpu_loops *= 8;
11132 gpu_accel *= 4;
11133
11134 switch (hash_mode)
11135 {
11136 case 400: gpu_loops = ROUNDS_PHPASS;
11137 gpu_accel = 32;
11138 break;
11139 case 500: gpu_loops = ROUNDS_MD5CRYPT;
11140 gpu_accel = 32;
11141 break;
11142 case 501: gpu_loops = ROUNDS_MD5CRYPT;
11143 gpu_accel = 32;
11144 break;
11145 case 1600: gpu_loops = ROUNDS_MD5CRYPT;
11146 gpu_accel = 32;
11147 break;
11148 case 1800: gpu_loops = ROUNDS_SHA512CRYPT;
11149 gpu_accel = 16;
11150 break;
11151 case 2100: gpu_loops = ROUNDS_DCC2;
11152 gpu_accel = 16;
11153 break;
11154 case 2500: gpu_loops = ROUNDS_WPA2;
11155 gpu_accel = 32;
11156 break;
11157 case 3200: gpu_loops = ROUNDS_BCRYPT;
11158 gpu_accel = 8;
11159 break;
11160 case 5200: gpu_loops = ROUNDS_PSAFE3;
11161 gpu_accel = 16;
11162 break;
11163 case 5800: gpu_loops = ROUNDS_ANDROIDPIN;
11164 gpu_accel = 16;
11165 break;
11166 case 6211: gpu_loops = ROUNDS_TRUECRYPT_2K;
11167 gpu_accel = 64;
11168 break;
11169 case 6212: gpu_loops = ROUNDS_TRUECRYPT_2K;
11170 gpu_accel = 32;
11171 break;
11172 case 6213: gpu_loops = ROUNDS_TRUECRYPT_2K;
11173 gpu_accel = 32;
11174 break;
11175 case 6221: gpu_loops = ROUNDS_TRUECRYPT_1K;
11176 gpu_accel = 8;
11177 break;
11178 case 6222: gpu_loops = ROUNDS_TRUECRYPT_1K;
11179 gpu_accel = 8;
11180 break;
11181 case 6223: gpu_loops = ROUNDS_TRUECRYPT_1K;
11182 gpu_accel = 8;
11183 break;
11184 case 6231: gpu_loops = ROUNDS_TRUECRYPT_1K;
11185 gpu_accel = 8;
11186 break;
11187 case 6232: gpu_loops = ROUNDS_TRUECRYPT_1K;
11188 gpu_accel = 8;
11189 break;
11190 case 6233: gpu_loops = ROUNDS_TRUECRYPT_1K;
11191 gpu_accel = 8;
11192 break;
11193 case 6241: gpu_loops = ROUNDS_TRUECRYPT_1K;
11194 gpu_accel = 128;
11195 break;
11196 case 6242: gpu_loops = ROUNDS_TRUECRYPT_1K;
11197 gpu_accel = 64;
11198 break;
11199 case 6243: gpu_loops = ROUNDS_TRUECRYPT_1K;
11200 gpu_accel = 64;
11201 break;
11202 case 6300: gpu_loops = ROUNDS_MD5CRYPT;
11203 gpu_accel = 32;
11204 break;
11205 case 6700: gpu_loops = ROUNDS_SHA1AIX;
11206 gpu_accel = 128;
11207 break;
11208 case 6400: gpu_loops = ROUNDS_SHA256AIX;
11209 gpu_accel = 128;
11210 break;
11211 case 6500: gpu_loops = ROUNDS_SHA512AIX;
11212 gpu_accel = 32;
11213 break;
11214 case 6600: gpu_loops = ROUNDS_AGILEKEY;
11215 gpu_accel = 64;
11216 break;
11217 case 6800: gpu_loops = ROUNDS_LASTPASS;
11218 gpu_accel = 64;
11219 break;
11220 case 7100: gpu_loops = ROUNDS_SHA512OSX;
11221 gpu_accel = 8;
11222 break;
11223 case 7200: gpu_loops = ROUNDS_GRUB;
11224 gpu_accel = 16;
11225 break;
11226 case 7400: gpu_loops = ROUNDS_SHA256CRYPT;
11227 gpu_accel = 8;
11228 break;
11229 case 7900: gpu_loops = ROUNDS_DRUPAL7;
11230 gpu_accel = 8;
11231 break;
11232 case 8200: gpu_loops = ROUNDS_CLOUDKEY;
11233 gpu_accel = 8;
11234 break;
11235 case 8800: gpu_loops = ROUNDS_ANDROIDFDE;
11236 gpu_accel = 32;
11237 break;
11238 case 8900: gpu_loops = 1;
11239 gpu_accel = 64;
11240 break;
11241 case 9000: gpu_loops = ROUNDS_PSAFE2;
11242 gpu_accel = 16;
11243 break;
11244 case 9100: gpu_loops = ROUNDS_LOTUS8;
11245 gpu_accel = 64;
11246 break;
11247 case 9200: gpu_loops = ROUNDS_CISCO8;
11248 gpu_accel = 8;
11249 break;
11250 case 9300: gpu_loops = 1;
11251 gpu_accel = 4;
11252 break;
11253 case 9400: gpu_loops = ROUNDS_OFFICE2007;
11254 gpu_accel = 32;
11255 break;
11256 case 9500: gpu_loops = ROUNDS_OFFICE2010;
11257 gpu_accel = 32;
11258 break;
11259 case 9600: gpu_loops = ROUNDS_OFFICE2013;
11260 gpu_accel = 8;
11261 break;
11262 case 10000: gpu_loops = ROUNDS_DJANGOPBKDF2;
11263 gpu_accel = 8;
11264 break;
11265 case 10300: gpu_loops = ROUNDS_SAPH_SHA1;
11266 gpu_accel = 16;
11267 break;
11268 case 10500: gpu_loops = ROUNDS_PDF14;
11269 gpu_accel = 256;
11270 break;
11271 case 10700: gpu_loops = ROUNDS_PDF17L8;
11272 gpu_accel = 8;
11273 break;
11274 case 10900: gpu_loops = ROUNDS_PBKDF2_SHA256;
11275 gpu_accel = 8;
11276 break;
11277 case 11300: gpu_loops = ROUNDS_BITCOIN_WALLET;
11278 gpu_accel = 8;
11279 break;
11280 case 11600: gpu_loops = ROUNDS_SEVEN_ZIP;
11281 gpu_accel = 8;
11282 break;
11283 case 11900: gpu_loops = ROUNDS_PBKDF2_MD5;
11284 gpu_accel = 8;
11285 break;
11286 case 12000: gpu_loops = ROUNDS_PBKDF2_SHA1;
11287 gpu_accel = 8;
11288 break;
11289 case 12100: gpu_loops = ROUNDS_PBKDF2_SHA512;
11290 gpu_accel = 8;
11291 break;
11292 case 12200: gpu_loops = ROUNDS_ECRYPTFS;
11293 gpu_accel = 8;
11294 break;
11295 case 12300: gpu_loops = ROUNDS_ORACLET;
11296 gpu_accel = 8;
11297 break;
11298 case 12500: gpu_loops = ROUNDS_RAR3;
11299 gpu_accel = 32;
11300 break;
11301 case 12700: gpu_loops = ROUNDS_MYWALLET;
11302 gpu_accel = 512;
11303 break;
11304 case 12800: gpu_loops = ROUNDS_MS_DRSR;
11305 gpu_accel = 512;
11306 break;
11307 }
11308
11309 // some algorithm collide too fast, make that impossible
11310
11311 switch (hash_mode)
11312 {
11313 case 11500: ((uint *) digests_buf)[1] = 1;
11314 break;
11315 }
11316
11317 if (gpu_loops > 1024) gpu_loops = 1024;
11318 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
11319 }
11320
11321 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
11322 {
11323 gpu_loops = 1024;
11324 }
11325
11326 if (hash_mode == 12500)
11327 {
11328 gpu_loops = ROUNDS_RAR3 / 16;
11329 }
11330
11331 data.gpu_accel = gpu_accel;
11332 data.gpu_loops = gpu_loops;
11333
11334 hashes_cnt = 1;
11335 }
11336
11337 if (show == 1 || left == 1)
11338 {
11339 for (uint i = 0; i < pot_cnt; i++)
11340 {
11341 pot_t *pot_ptr = &pot[i];
11342
11343 hash_t *hashes_buf = &pot_ptr->hash;
11344
11345 local_free (hashes_buf->digest);
11346
11347 if (isSalted)
11348 {
11349 local_free (hashes_buf->salt);
11350 }
11351 }
11352
11353 local_free (pot);
11354
11355 if (data.quiet == 0) log_info_nn ("");
11356
11357 return (0);
11358 }
11359
11360 if (keyspace == 0)
11361 {
11362 if (hashes_cnt == 0)
11363 {
11364 log_error ("ERROR: No hashes loaded");
11365
11366 return (-1);
11367 }
11368 }
11369
11370 /**
11371 * Sanity check for hashfile vs outfile (should not point to the same physical file)
11372 */
11373
11374 if (data.outfile != NULL)
11375 {
11376 if (data.hashfile != NULL)
11377 {
11378 #ifdef _POSIX
11379 struct stat tmpstat_outfile;
11380 struct stat tmpstat_hashfile;
11381 #endif
11382
11383 #ifdef _WIN
11384 struct stat64 tmpstat_outfile;
11385 struct stat64 tmpstat_hashfile;
11386 #endif
11387
11388 FILE *tmp_outfile_fp = fopen (data.outfile, "r");
11389
11390 if (tmp_outfile_fp)
11391 {
11392 #ifdef _POSIX
11393 fstat (fileno (tmp_outfile_fp), &tmpstat_outfile);
11394 #endif
11395
11396 #ifdef _WIN
11397 _fstat64 (fileno (tmp_outfile_fp), &tmpstat_outfile);
11398 #endif
11399
11400 fclose (tmp_outfile_fp);
11401 }
11402
11403 FILE *tmp_hashfile_fp = fopen (data.hashfile, "r");
11404
11405 if (tmp_hashfile_fp)
11406 {
11407 #ifdef _POSIX
11408 fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
11409 #endif
11410
11411 #ifdef _WIN
11412 _fstat64 (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
11413 #endif
11414
11415 fclose (tmp_hashfile_fp);
11416 }
11417
11418 if (tmp_outfile_fp && tmp_outfile_fp)
11419 {
11420 tmpstat_outfile.st_mode = 0;
11421 tmpstat_outfile.st_nlink = 0;
11422 tmpstat_outfile.st_uid = 0;
11423 tmpstat_outfile.st_gid = 0;
11424 tmpstat_outfile.st_rdev = 0;
11425 tmpstat_outfile.st_atime = 0;
11426
11427 tmpstat_hashfile.st_mode = 0;
11428 tmpstat_hashfile.st_nlink = 0;
11429 tmpstat_hashfile.st_uid = 0;
11430 tmpstat_hashfile.st_gid = 0;
11431 tmpstat_hashfile.st_rdev = 0;
11432 tmpstat_hashfile.st_atime = 0;
11433
11434 #ifdef _POSIX
11435 tmpstat_outfile.st_blksize = 0;
11436 tmpstat_outfile.st_blocks = 0;
11437
11438 tmpstat_hashfile.st_blksize = 0;
11439 tmpstat_hashfile.st_blocks = 0;
11440 #endif
11441
11442 #ifdef _POSIX
11443 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat)) == 0)
11444 {
11445 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
11446
11447 return (-1);
11448 }
11449 #endif
11450
11451 #ifdef _WIN
11452 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat64)) == 0)
11453 {
11454 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
11455
11456 return (-1);
11457 }
11458 #endif
11459 }
11460 }
11461 }
11462
11463 /**
11464 * Remove duplicates
11465 */
11466
11467 if (data.quiet == 0) log_info_nn ("Removing duplicate hashes...");
11468
11469 if (isSalted)
11470 {
11471 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
11472 }
11473 else
11474 {
11475 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
11476 }
11477
11478 uint hashes_cnt_orig = hashes_cnt;
11479
11480 hashes_cnt = 1;
11481
11482 for (uint hashes_pos = 1; hashes_pos < hashes_cnt_orig; hashes_pos++)
11483 {
11484 if (isSalted)
11485 {
11486 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) == 0)
11487 {
11488 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
11489 }
11490 }
11491 else
11492 {
11493 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
11494 }
11495
11496 if (hashes_pos > hashes_cnt)
11497 {
11498 memcpy (&hashes_buf[hashes_cnt], &hashes_buf[hashes_pos], sizeof (hash_t));
11499 }
11500
11501 hashes_cnt++;
11502 }
11503
11504 /**
11505 * Potfile removes
11506 */
11507
11508 uint potfile_remove_cracks = 0;
11509
11510 if (potfile_disable == 0)
11511 {
11512 hash_t hash_buf;
11513
11514 hash_buf.digest = mymalloc (dgst_size);
11515 hash_buf.salt = NULL;
11516 hash_buf.esalt = NULL;
11517 hash_buf.hash_info = NULL;
11518 hash_buf.cracked = 0;
11519
11520 if (isSalted)
11521 {
11522 hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
11523 }
11524
11525 if (esalt_size)
11526 {
11527 hash_buf.esalt = mymalloc (esalt_size);
11528 }
11529
11530 if (quiet == 0) log_info_nn ("Comparing hashes with potfile entries...");
11531
11532 // no solution for these special hash types (for instane because they use hashfile in output etc)
11533 if ((hash_mode != 5200) &&
11534 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
11535 (hash_mode != 9000))
11536 {
11537 FILE *fp = fopen (potfile, "rb");
11538
11539 if (fp != NULL)
11540 {
11541 while (!feof (fp))
11542 {
11543 char line_buf[BUFSIZ];
11544
11545 memset (line_buf, 0, BUFSIZ);
11546
11547 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
11548
11549 if (ptr == NULL) break;
11550
11551 int line_len = strlen (line_buf);
11552
11553 if (line_len == 0) continue;
11554
11555 int iter = MAX_CUT_TRIES;
11556
11557 for (int i = line_len - 1; i && iter; i--, line_len--)
11558 {
11559 if (line_buf[i] != ':') continue;
11560
11561 if (isSalted)
11562 {
11563 memset (hash_buf.salt, 0, sizeof (salt_t));
11564 }
11565
11566 hash_t *found = NULL;
11567
11568 if (hash_mode == 6800)
11569 {
11570 if (i < 48) // 48 = 12 * uint in salt_buf[]
11571 {
11572 // manipulate salt_buf
11573 memcpy (hash_buf.salt->salt_buf, line_buf, i);
11574
11575 hash_buf.salt->salt_len = i;
11576
11577 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt);
11578 }
11579 }
11580 else if (hash_mode == 2500)
11581 {
11582 if (i < 48) // 48 = 12 * uint in salt_buf[]
11583 {
11584 // here we have in line_buf: ESSID:MAC1:MAC2 (without the plain)
11585 // manipulate salt_buf
11586
11587 // to be safe work with a copy (because of line_len loop, i etc)
11588
11589 char line_buf_cpy[BUFSIZ];
11590 memset (line_buf_cpy, 0, BUFSIZ);
11591
11592 memset (line_buf_cpy, 0, sizeof (line_buf_cpy));
11593
11594 memcpy (line_buf_cpy, line_buf, i);
11595
11596 char *mac2_pos = strrchr (line_buf_cpy, ':');
11597
11598 if (mac2_pos == NULL) continue;
11599
11600 mac2_pos[0] = 0;
11601 mac2_pos++;
11602
11603 if (strlen (mac2_pos) != 12) continue;
11604
11605 char *mac1_pos = strrchr (line_buf_cpy, ':');
11606
11607 if (mac1_pos == NULL) continue;
11608
11609 mac1_pos[0] = 0;
11610 mac1_pos++;
11611
11612 if (strlen (mac1_pos) != 12) continue;
11613
11614 uint essid_length = mac1_pos - line_buf_cpy - 1;
11615
11616 // here we need the ESSID
11617 memcpy (hash_buf.salt->salt_buf, line_buf_cpy, essid_length);
11618
11619 hash_buf.salt->salt_len = essid_length;
11620
11621 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt_hccap);
11622
11623 if (found)
11624 {
11625 wpa_t *wpa = (wpa_t *) found->esalt;
11626
11627 uint pke[25];
11628
11629 char *pke_ptr = (char *) pke;
11630
11631 for (uint i = 0; i < 25; i++)
11632 {
11633 pke[i] = byte_swap_32 (wpa->pke[i]);
11634 }
11635
11636 unsigned char mac1[6];
11637 unsigned char mac2[6];
11638
11639 memcpy (mac1, pke_ptr + 23, 6);
11640 memcpy (mac2, pke_ptr + 29, 6);
11641
11642 // compare hex string(s) vs binary MAC address(es)
11643
11644 for (uint i = 0, j = 0; i < 6; i++, j += 2)
11645 {
11646 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
11647 {
11648 found = NULL;
11649 break;
11650 }
11651 }
11652
11653 // early skip ;)
11654 if (!found) continue;
11655
11656 for (uint i = 0, j = 0; i < 6; i++, j += 2)
11657 {
11658 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
11659 {
11660 found = NULL;
11661 break;
11662 }
11663 }
11664 }
11665 }
11666 }
11667 else
11668 {
11669 int parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
11670
11671 if (parser_status == PARSER_OK)
11672 {
11673 if (isSalted)
11674 {
11675 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
11676 }
11677 else
11678 {
11679 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
11680 }
11681 }
11682 }
11683
11684 if (found == NULL) continue;
11685
11686 if (!found->cracked) potfile_remove_cracks++;
11687
11688 found->cracked = 1;
11689
11690 if (found) break;
11691
11692 iter--;
11693 }
11694 }
11695
11696 fclose (fp);
11697 }
11698 }
11699
11700 if (esalt_size)
11701 {
11702 local_free (hash_buf.esalt);
11703 }
11704
11705 if (isSalted)
11706 {
11707 local_free (hash_buf.salt);
11708 }
11709
11710 local_free (hash_buf.digest);
11711 }
11712
11713 /**
11714 * Now generate all the buffers required for later
11715 */
11716
11717 void *digests_buf_new = (void *) mycalloc (hashes_avail, dgst_size);
11718
11719 salt_t *salts_buf_new = NULL;
11720 void *esalts_buf_new = NULL;
11721
11722 if (isSalted)
11723 {
11724 salts_buf_new = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
11725
11726 if (esalt_size)
11727 {
11728 esalts_buf_new = (void *) mycalloc (hashes_avail, esalt_size);
11729 }
11730 }
11731 else
11732 {
11733 salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t));
11734 }
11735
11736 if (data.quiet == 0) log_info_nn ("Structuring salts for cracking task...");
11737
11738 uint digests_cnt = hashes_cnt;
11739 uint digests_done = 0;
11740
11741 uint size_digests = digests_cnt * dgst_size;
11742 uint size_shown = digests_cnt * sizeof (uint);
11743
11744 uint *digests_shown = (uint *) mymalloc (size_shown);
11745 uint *digests_shown_tmp = (uint *) mymalloc (size_shown);
11746
11747 uint salts_cnt = 0;
11748 uint salts_done = 0;
11749
11750 hashinfo_t **hash_info = NULL;
11751
11752 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11753 {
11754 hash_info = (hashinfo_t**) mymalloc (hashes_cnt * sizeof (hashinfo_t *));
11755
11756 if (username && (remove || show))
11757 {
11758 uint user_pos;
11759
11760 for (user_pos = 0; user_pos < hashes_cnt; user_pos++)
11761 {
11762 hash_info[user_pos] = (hashinfo_t*) mycalloc (hashes_cnt, sizeof (hashinfo_t));
11763
11764 hash_info[user_pos]->user = (user_t*) mymalloc (sizeof (user_t));
11765 }
11766 }
11767 }
11768
11769 uint *salts_shown = (uint *) mymalloc (size_shown);
11770
11771 salt_t *salt_buf;
11772
11773 {
11774 // copied from inner loop
11775
11776 salt_buf = &salts_buf_new[salts_cnt];
11777
11778 memcpy (salt_buf, hashes_buf[0].salt, sizeof (salt_t));
11779
11780 if (esalt_size)
11781 {
11782 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[0].esalt, esalt_size);
11783 }
11784
11785 salt_buf->digests_cnt = 0;
11786 salt_buf->digests_done = 0;
11787 salt_buf->digests_offset = 0;
11788
11789 salts_cnt++;
11790 }
11791
11792 if (hashes_buf[0].cracked == 1)
11793 {
11794 digests_shown[0] = 1;
11795
11796 digests_done++;
11797
11798 salt_buf->digests_done++;
11799 }
11800
11801 salt_buf->digests_cnt++;
11802
11803 memcpy (((char *) digests_buf_new) + (0 * dgst_size), hashes_buf[0].digest, dgst_size);
11804
11805 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11806 {
11807 hash_info[0] = hashes_buf[0].hash_info;
11808 }
11809
11810 // copy from inner loop
11811
11812 for (uint hashes_pos = 1; hashes_pos < hashes_cnt; hashes_pos++)
11813 {
11814 if (isSalted)
11815 {
11816 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) != 0)
11817 {
11818 salt_buf = &salts_buf_new[salts_cnt];
11819
11820 memcpy (salt_buf, hashes_buf[hashes_pos].salt, sizeof (salt_t));
11821
11822 if (esalt_size)
11823 {
11824 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[hashes_pos].esalt, esalt_size);
11825 }
11826
11827 salt_buf->digests_cnt = 0;
11828 salt_buf->digests_done = 0;
11829 salt_buf->digests_offset = hashes_pos;
11830
11831 salts_cnt++;
11832 }
11833 }
11834
11835 if (hashes_buf[hashes_pos].cracked == 1)
11836 {
11837 digests_shown[hashes_pos] = 1;
11838
11839 digests_done++;
11840
11841 salt_buf->digests_done++;
11842 }
11843
11844 salt_buf->digests_cnt++;
11845
11846 memcpy (((char *) digests_buf_new) + (hashes_pos * dgst_size), hashes_buf[hashes_pos].digest, dgst_size);
11847
11848 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11849 {
11850 hash_info[hashes_pos] = hashes_buf[hashes_pos].hash_info;
11851 }
11852 }
11853
11854 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
11855 {
11856 salt_t *salt_buf = &salts_buf_new[salt_pos];
11857
11858 if (salt_buf->digests_done == salt_buf->digests_cnt)
11859 {
11860 salts_shown[salt_pos] = 1;
11861
11862 salts_done++;
11863 }
11864
11865 if (salts_done == salts_cnt) data.devices_status = STATUS_CRACKED;
11866 }
11867
11868 local_free (digests_buf);
11869 local_free (salts_buf);
11870 local_free (esalts_buf);
11871
11872 digests_buf = digests_buf_new;
11873 salts_buf = salts_buf_new;
11874 esalts_buf = esalts_buf_new;
11875
11876 local_free (hashes_buf);
11877
11878 /**
11879 * special modification not set from parser
11880 */
11881
11882 switch (hash_mode)
11883 {
11884 case 6211: salts_buf->truecrypt_mdlen = 1 * 512; break;
11885 case 6212: salts_buf->truecrypt_mdlen = 2 * 512; break;
11886 case 6213: salts_buf->truecrypt_mdlen = 3 * 512; break;
11887 case 6221: salts_buf->truecrypt_mdlen = 1 * 512; break;
11888 case 6222: salts_buf->truecrypt_mdlen = 2 * 512; break;
11889 case 6223: salts_buf->truecrypt_mdlen = 3 * 512; break;
11890 case 6231: salts_buf->truecrypt_mdlen = 1 * 512; break;
11891 case 6232: salts_buf->truecrypt_mdlen = 2 * 512; break;
11892 case 6233: salts_buf->truecrypt_mdlen = 3 * 512; break;
11893 case 6241: salts_buf->truecrypt_mdlen = 1 * 512; break;
11894 case 6242: salts_buf->truecrypt_mdlen = 2 * 512; break;
11895 case 6243: salts_buf->truecrypt_mdlen = 3 * 512; break;
11896 }
11897
11898 if (truecrypt_keyfiles)
11899 {
11900 uint *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf;
11901
11902 char *keyfiles = strdup (truecrypt_keyfiles);
11903
11904 char *keyfile = strtok (keyfiles, ",");
11905
11906 do
11907 {
11908 truecrypt_crc32 (keyfile, (unsigned char *) keyfile_buf);
11909
11910 } while ((keyfile = strtok (NULL, ",")) != NULL);
11911
11912 free (keyfiles);
11913 }
11914
11915 data.digests_cnt = digests_cnt;
11916 data.digests_done = digests_done;
11917 data.digests_buf = digests_buf;
11918 data.digests_shown = digests_shown;
11919 data.digests_shown_tmp = digests_shown_tmp;
11920
11921 data.salts_cnt = salts_cnt;
11922 data.salts_done = salts_done;
11923 data.salts_buf = salts_buf;
11924 data.salts_shown = salts_shown;
11925
11926 data.esalts_buf = esalts_buf;
11927 data.hash_info = hash_info;
11928
11929 /**
11930 * Automatic Optimizers
11931 */
11932
11933 if (salts_cnt == 1)
11934 opti_type |= OPTI_TYPE_SINGLE_SALT;
11935
11936 if (digests_cnt == 1)
11937 opti_type |= OPTI_TYPE_SINGLE_HASH;
11938
11939 if (attack_exec == ATTACK_EXEC_ON_GPU)
11940 opti_type |= OPTI_TYPE_NOT_ITERATED;
11941
11942 if (attack_mode == ATTACK_MODE_BF)
11943 opti_type |= OPTI_TYPE_BRUTE_FORCE;
11944
11945 data.opti_type = opti_type;
11946
11947 if (opti_type & OPTI_TYPE_BRUTE_FORCE)
11948 {
11949 if (opti_type & OPTI_TYPE_SINGLE_HASH)
11950 {
11951 if (opti_type & OPTI_TYPE_APPENDED_SALT)
11952 {
11953 if (opts_type & OPTS_TYPE_ST_ADD80)
11954 {
11955 opts_type &= ~OPTS_TYPE_ST_ADD80;
11956 opts_type |= OPTS_TYPE_PT_ADD80;
11957 }
11958
11959 if (opts_type & OPTS_TYPE_ST_ADDBITS14)
11960 {
11961 opts_type &= ~OPTS_TYPE_ST_ADDBITS14;
11962 opts_type |= OPTS_TYPE_PT_ADDBITS14;
11963 }
11964
11965 if (opts_type & OPTS_TYPE_ST_ADDBITS15)
11966 {
11967 opts_type &= ~OPTS_TYPE_ST_ADDBITS15;
11968 opts_type |= OPTS_TYPE_PT_ADDBITS15;
11969 }
11970 }
11971 }
11972 }
11973
11974 /**
11975 * Some algorithm, like descrypt, can benefit from JIT compilation
11976 */
11977
11978 uint force_jit_compilation = 0;
11979
11980 if (hash_mode == 8900)
11981 {
11982 force_jit_compilation = 8900;
11983 }
11984 else if (hash_mode == 9300)
11985 {
11986 force_jit_compilation = 8900;
11987 }
11988 else if (hash_mode == 1500 && attack_mode == ATTACK_MODE_BF && data.salts_cnt == 1)
11989 {
11990 force_jit_compilation = 1500;
11991 }
11992
11993 /**
11994 * generate bitmap tables
11995 */
11996
11997 const uint bitmap_shift1 = 5;
11998 const uint bitmap_shift2 = 13;
11999
12000 if (bitmap_max < bitmap_min) bitmap_max = bitmap_min;
12001
12002 uint *bitmap_s1_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12003 uint *bitmap_s1_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12004 uint *bitmap_s1_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12005 uint *bitmap_s1_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12006 uint *bitmap_s2_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12007 uint *bitmap_s2_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12008 uint *bitmap_s2_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12009 uint *bitmap_s2_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12010
12011 uint bitmap_bits;
12012 uint bitmap_nums;
12013 uint bitmap_mask;
12014 uint bitmap_size;
12015
12016 for (bitmap_bits = bitmap_min; bitmap_bits < bitmap_max; bitmap_bits++)
12017 {
12018 if (data.quiet == 0) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits);
12019
12020 bitmap_nums = 1 << bitmap_bits;
12021
12022 bitmap_mask = bitmap_nums - 1;
12023
12024 bitmap_size = bitmap_nums * sizeof (uint);
12025
12026 if ((hashes_cnt & bitmap_mask) == hashes_cnt) break;
12027
12028 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;
12029 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;
12030
12031 break;
12032 }
12033
12034 bitmap_nums = 1 << bitmap_bits;
12035
12036 bitmap_mask = bitmap_nums - 1;
12037
12038 bitmap_size = bitmap_nums * sizeof (uint);
12039
12040 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);
12041 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);
12042
12043 /**
12044 * prepare quick rule
12045 */
12046
12047 data.rule_buf_l = rule_buf_l;
12048 data.rule_buf_r = rule_buf_r;
12049
12050 int rule_len_l = (int) strlen (rule_buf_l);
12051 int rule_len_r = (int) strlen (rule_buf_r);
12052
12053 data.rule_len_l = rule_len_l;
12054 data.rule_len_r = rule_len_r;
12055
12056 /**
12057 * load rules
12058 */
12059
12060 uint *all_gpu_rules_cnt = NULL;
12061
12062 gpu_rule_t **all_gpu_rules_buf = NULL;
12063
12064 if (rp_files_cnt)
12065 {
12066 all_gpu_rules_cnt = (uint *) mycalloc (rp_files_cnt, sizeof (uint));
12067
12068 all_gpu_rules_buf = (gpu_rule_t **) mycalloc (rp_files_cnt, sizeof (gpu_rule_t *));
12069 }
12070
12071 char rule_buf[BUFSIZ];
12072
12073 int rule_len = 0;
12074
12075 for (uint i = 0; i < rp_files_cnt; i++)
12076 {
12077 uint gpu_rules_avail = 0;
12078
12079 uint gpu_rules_cnt = 0;
12080
12081 gpu_rule_t *gpu_rules_buf = NULL;
12082
12083 char *rp_file = rp_files[i];
12084
12085 char in[BLOCK_SIZE];
12086 char out[BLOCK_SIZE];
12087
12088 FILE *fp = NULL;
12089
12090 uint rule_line = 0;
12091
12092 if ((fp = fopen (rp_file, "rb")) == NULL)
12093 {
12094 log_error ("ERROR: %s: %s", rp_file, strerror (errno));
12095
12096 return (-1);
12097 }
12098
12099 while (!feof (fp))
12100 {
12101 memset (rule_buf, 0, BUFSIZ);
12102
12103 rule_len = fgetl (fp, rule_buf);
12104
12105 rule_line++;
12106
12107 if (rule_len == 0) continue;
12108
12109 if (rule_buf[0] == '#') continue;
12110
12111 if (gpu_rules_avail == gpu_rules_cnt)
12112 {
12113 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12114
12115 gpu_rules_avail += INCR_RULES;
12116 }
12117
12118 memset (in, 0, BLOCK_SIZE);
12119 memset (out, 0, BLOCK_SIZE);
12120
12121 int result = _old_apply_rule (rule_buf, rule_len, in, 1, out);
12122
12123 if (result == -1)
12124 {
12125 log_info ("WARNING: Skipping invalid or unsupported rule in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12126
12127 continue;
12128 }
12129
12130 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1)
12131 {
12132 log_info ("WARNING: Cannot convert rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12133
12134 memset (&gpu_rules_buf[gpu_rules_cnt], 0, sizeof (gpu_rule_t)); // needs to be cleared otherwise we could have some remaining data
12135
12136 continue;
12137 }
12138
12139 /* its so slow
12140 if (rulefind (&gpu_rules_buf[gpu_rules_cnt], gpu_rules_buf, gpu_rules_cnt, sizeof (gpu_rule_t), sort_by_gpu_rule))
12141 {
12142 log_info ("Duplicate rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12143
12144 continue;
12145 }
12146 */
12147
12148 gpu_rules_cnt++;
12149 }
12150
12151 fclose (fp);
12152
12153 all_gpu_rules_cnt[i] = gpu_rules_cnt;
12154
12155 all_gpu_rules_buf[i] = gpu_rules_buf;
12156 }
12157
12158 /**
12159 * merge rules or automatic rule generator
12160 */
12161
12162 uint gpu_rules_cnt = 0;
12163
12164 gpu_rule_t *gpu_rules_buf = NULL;
12165
12166 if (attack_mode == ATTACK_MODE_STRAIGHT)
12167 {
12168 if (rp_files_cnt)
12169 {
12170 gpu_rules_cnt = 1;
12171
12172 uint *repeats = (uint *) mycalloc (rp_files_cnt + 1, sizeof (uint));
12173
12174 repeats[0] = gpu_rules_cnt;
12175
12176 for (uint i = 0; i < rp_files_cnt; i++)
12177 {
12178 gpu_rules_cnt *= all_gpu_rules_cnt[i];
12179
12180 repeats[i + 1] = gpu_rules_cnt;
12181 }
12182
12183 gpu_rules_buf = (gpu_rule_t *) mycalloc (gpu_rules_cnt, sizeof (gpu_rule_t));
12184
12185 memset (gpu_rules_buf, 0, gpu_rules_cnt * sizeof (gpu_rule_t));
12186
12187 for (uint i = 0; i < gpu_rules_cnt; i++)
12188 {
12189 uint out_pos = 0;
12190
12191 gpu_rule_t *out = &gpu_rules_buf[i];
12192
12193 for (uint j = 0; j < rp_files_cnt; j++)
12194 {
12195 uint in_off = (i / repeats[j]) % all_gpu_rules_cnt[j];
12196 uint in_pos;
12197
12198 gpu_rule_t *in = &all_gpu_rules_buf[j][in_off];
12199
12200 for (in_pos = 0; in->cmds[in_pos]; in_pos++, out_pos++)
12201 {
12202 if (out_pos == RULES_MAX - 1)
12203 {
12204 // log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
12205
12206 break;
12207 }
12208
12209 out->cmds[out_pos] = in->cmds[in_pos];
12210 }
12211 }
12212 }
12213
12214 local_free (repeats);
12215 }
12216 else if (rp_gen)
12217 {
12218 uint gpu_rules_avail = 0;
12219
12220 while (gpu_rules_cnt < rp_gen)
12221 {
12222 if (gpu_rules_avail == gpu_rules_cnt)
12223 {
12224 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12225
12226 gpu_rules_avail += INCR_RULES;
12227 }
12228
12229 memset (rule_buf, 0, BLOCK_SIZE);
12230
12231 rule_len = (int) generate_random_rule (rule_buf, rp_gen_func_min, rp_gen_func_max);
12232
12233 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1) continue;
12234
12235 gpu_rules_cnt++;
12236 }
12237 }
12238 }
12239
12240 /**
12241 * generate NOP rules
12242 */
12243
12244 if (gpu_rules_cnt == 0)
12245 {
12246 gpu_rules_buf = (gpu_rule_t *) mymalloc (sizeof (gpu_rule_t));
12247
12248 gpu_rules_buf[gpu_rules_cnt].cmds[0] = RULE_OP_MANGLE_NOOP;
12249
12250 gpu_rules_cnt++;
12251 }
12252
12253 data.gpu_rules_cnt = gpu_rules_cnt;
12254 data.gpu_rules_buf = gpu_rules_buf;
12255
12256 /**
12257 * platform
12258 */
12259
12260 cl_platform_id CL_platforms[CL_PLATFORMS_MAX];
12261
12262 uint CL_platforms_cnt = 0;
12263
12264 hc_clGetPlatformIDs (CL_PLATFORMS_MAX, CL_platforms, &CL_platforms_cnt);
12265
12266 if (CL_platforms_cnt == 0)
12267 {
12268 log_error ("ERROR: No OpenCL compatible platform found");
12269
12270 return (-1);
12271 }
12272
12273 uint CL_platform_sel = 0;
12274
12275 if (CL_platforms_cnt > 1)
12276 {
12277 if (gpu_platform == NULL)
12278 {
12279 log_error ("ERROR: Too many OpenCL compatible platforms found");
12280 log_error (" Please select a single platform using the --gpu-platform option");
12281 log_error ("");
12282 log_error ("Available OpenCL platforms:");
12283
12284 for (uint i = 0; i < CL_platforms_cnt; i++)
12285 {
12286 char CL_platform_vendor[INFOSZ];
12287
12288 memset (CL_platform_vendor, 0, sizeof (CL_platform_vendor));
12289
12290 hc_clGetPlatformInfo (CL_platforms[i], CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
12291
12292 printf ("* %d = %s\n", i + 1, CL_platform_vendor);
12293 }
12294
12295 return (-1);
12296 }
12297 else
12298 {
12299 CL_platform_sel = atoi (gpu_platform);
12300
12301 if (CL_platform_sel > CL_platforms_cnt)
12302 {
12303 log_error ("ERROR: invalid OpenCL platforms selected");
12304
12305 return (-1);
12306 }
12307
12308 // user does not count with zero
12309
12310 CL_platform_sel -= 1;
12311 }
12312 }
12313
12314 cl_platform_id CL_platform = CL_platforms[CL_platform_sel];
12315
12316 char CL_platform_vendor[INFOSZ];
12317
12318 memset (CL_platform_vendor, 0, sizeof (CL_platform_vendor));
12319
12320 hc_clGetPlatformInfo (CL_platform, CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
12321
12322 uint vendor_id;
12323
12324 if (strcmp (CL_platform_vendor, CL_VENDOR_AMD) == 0)
12325 {
12326 vendor_id = VENDOR_ID_AMD;
12327 }
12328 else if (strcmp (CL_platform_vendor, CL_VENDOR_NV) == 0)
12329 {
12330 vendor_id = VENDOR_ID_NV;
12331
12332 // make sure that we do not directly control the fan for NVidia
12333
12334 gpu_temp_retain = 0;
12335 data.gpu_temp_retain = gpu_temp_retain;
12336 }
12337 else
12338 {
12339 vendor_id = VENDOR_ID_UNKNOWN;
12340 }
12341
12342 if (vendor_id == VENDOR_ID_UNKNOWN)
12343 {
12344 log_error ("Warning: unknown OpenCL vendor '%s' detected", CL_platform_vendor);
12345
12346 gpu_temp_disable = 1;
12347 }
12348
12349 data.vendor_id = vendor_id;
12350
12351 /**
12352 * cached kernel path depends on vendor_id which we don't know, so create it here
12353 */
12354
12355 if (profile_dir != install_dir) // not a bug
12356 {
12357 int vendor_id_folder_size = strlen (profile_dir) + 1 + 7 + 1 + 10 + 1;
12358
12359 char *vendor_id_folder = (char *) mymalloc (vendor_id_folder_size);
12360
12361 snprintf (vendor_id_folder, vendor_id_folder_size - 1, "%s/kernels", profile_dir);
12362
12363 mkdir (vendor_id_folder, 0700);
12364
12365 snprintf (vendor_id_folder, vendor_id_folder_size - 1, "%s/kernels/%d", profile_dir, vendor_id);
12366
12367 mkdir (vendor_id_folder, 0700);
12368
12369 myfree (vendor_id_folder);
12370 }
12371
12372 /**
12373 * devices
12374 */
12375
12376 cl_device_id devices_all[DEVICES_MAX];
12377 cl_device_id devices[DEVICES_MAX];
12378
12379 uint devices_all_cnt = 0;
12380
12381 hc_clGetDeviceIDs (CL_platform, CL_DEVICE_TYPE_GPU, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
12382
12383 int hm_adapters_all = devices_all_cnt;
12384
12385 hm_attrs_t hm_adapter_all[DEVICES_MAX];
12386
12387 memset (hm_adapter_all, 0, sizeof (hm_adapter_all));
12388
12389 if (gpu_temp_disable == 0)
12390 {
12391 if (vendor_id == VENDOR_ID_NV)
12392 {
12393 #ifdef LINUX
12394 HM_LIB hm_dll = hm_init ();
12395
12396 data.hm_dll = hm_dll;
12397
12398 if (hc_NVML_nvmlInit (hm_dll) == NVML_SUCCESS)
12399 {
12400 HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX];
12401
12402 int tmp_in = hm_get_adapter_index_nv (nvGPUHandle);
12403
12404 int tmp_out = 0;
12405
12406 for (int i = 0; i < tmp_in; i++)
12407 {
12408 hm_adapter_all[tmp_out++].adapter_index.nv = nvGPUHandle[i];
12409 }
12410
12411 hm_adapters_all = tmp_out;
12412
12413 for (int i = 0; i < tmp_out; i++)
12414 {
12415 unsigned int speed;
12416
12417 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;
12418 }
12419 }
12420 #endif
12421
12422 #ifdef WIN
12423 if (NvAPI_Initialize () == NVAPI_OK)
12424 {
12425 HM_ADAPTER_NV nvGPUHandle[DEVICES_MAX];
12426
12427 int tmp_in = hm_get_adapter_index_nv (nvGPUHandle);
12428
12429 int tmp_out = 0;
12430
12431 for (int i = 0; i < tmp_in; i++)
12432 {
12433 hm_adapter_all[tmp_out++].adapter_index.nv = nvGPUHandle[i];
12434 }
12435
12436 hm_adapters_all = tmp_out;
12437
12438 for (int i = 0; i < tmp_out; i++)
12439 {
12440 NvU32 speed;
12441
12442 if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index.nv, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
12443 }
12444 }
12445 #endif
12446 }
12447
12448 if (vendor_id == VENDOR_ID_AMD)
12449 {
12450 HM_LIB hm_dll = hm_init ();
12451
12452 data.hm_dll = hm_dll;
12453
12454 if (hc_ADL_Main_Control_Create (hm_dll, ADL_Main_Memory_Alloc, 0) == ADL_OK)
12455 {
12456 // total number of adapters
12457
12458 int hm_adapters_num;
12459
12460 if (get_adapters_num_amd (hm_dll, &hm_adapters_num) != 0) return (-1);
12461
12462 // adapter info
12463
12464 LPAdapterInfo lpAdapterInfo = hm_get_adapter_info_amd (hm_dll, hm_adapters_num);
12465
12466 if (lpAdapterInfo == NULL) return (-1);
12467
12468 // get a list (of ids of) valid/usable adapters
12469
12470 int num_adl_adapters = 0;
12471
12472 uint32_t *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo);
12473
12474 if (num_adl_adapters > 0)
12475 {
12476 hc_thread_mutex_lock (mux_adl);
12477
12478 // hm_get_opencl_busid_devid (hm_adapter_all, devices_all_cnt, devices_all);
12479
12480 hm_get_adapter_index_amd (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
12481
12482 hm_get_overdrive_version (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
12483 hm_check_fanspeed_control (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
12484
12485 hc_thread_mutex_unlock (mux_adl);
12486 }
12487
12488 hm_adapters_all = num_adl_adapters;
12489
12490 myfree (valid_adl_device_list);
12491 myfree (lpAdapterInfo);
12492 }
12493 }
12494 }
12495
12496 if (hm_adapters_all == 0)
12497 {
12498 gpu_temp_disable = 1;
12499 }
12500
12501 if (gpu_temp_disable == 1)
12502 {
12503 gpu_temp_abort = 0;
12504 gpu_temp_retain = 0;
12505 }
12506
12507 /**
12508 * enable custom signal handler(s)
12509 */
12510
12511 if (benchmark == 0)
12512 {
12513 hc_signal (sigHandler_default);
12514 }
12515 else
12516 {
12517 hc_signal (sigHandler_benchmark);
12518 }
12519
12520 /**
12521 * devices mask and properties
12522 */
12523
12524 uint devices_cnt = 0;
12525
12526 for (uint device_all_id = 0; device_all_id < devices_all_cnt; device_all_id++)
12527 {
12528 if (gpu_devicemask)
12529 {
12530 uint device_all_id_mask = 1 << device_all_id;
12531
12532 if ((device_all_id_mask & gpu_devicemask) != device_all_id_mask)
12533 {
12534 if (quiet == 0 && algorithm_pos == 0) log_info ("Device #%d: skipped by user", device_all_id_mask + 1);
12535
12536 continue;
12537 }
12538 }
12539
12540 const uint device_id = devices_cnt;
12541
12542 devices[device_id] = devices_all[device_all_id];
12543
12544 memcpy (&data.hm_device[device_id], &hm_adapter_all[device_all_id], sizeof (hm_attrs_t));
12545
12546 char device_name[INFOSZ];
12547
12548 memset (device_name, 0, sizeof (device_name));
12549
12550 cl_ulong global_mem_size;
12551 cl_ulong max_mem_alloc_size;
12552 cl_uint max_clock_frequency;
12553 cl_uint max_compute_units;
12554
12555 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_NAME, sizeof (device_name), &device_name, NULL);
12556 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (global_mem_size), &global_mem_size, NULL);
12557 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL);
12558 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (max_clock_frequency), &max_clock_frequency, NULL);
12559 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
12560
12561 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
12562 {
12563 log_info ("Device #%u: %s, %lu/%lu MB allocatable, %dMhz, %uMCU",
12564 device_all_id + 1,
12565 device_name,
12566 (unsigned int) (max_mem_alloc_size / 1024 / 1024),
12567 (unsigned int) (global_mem_size / 1024 / 1024),
12568 (unsigned int) (max_clock_frequency),
12569 (unsigned int) max_compute_units);
12570 }
12571
12572 devices_cnt++;
12573 }
12574
12575 if (devices_cnt == 0)
12576 {
12577 log_error ("ERROR: No devices left that matches your specification.");
12578
12579 return (-1);
12580 }
12581
12582 data.devices_cnt = devices_cnt;
12583
12584 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
12585 {
12586 log_info ("");
12587 }
12588
12589 /**
12590 * inform the user
12591 */
12592
12593 // gpu temp sanity check
12594
12595 if ((gpu_temp_abort != 0) && (gpu_temp_retain != 0))
12596 {
12597 if (gpu_temp_abort < gpu_temp_retain)
12598 {
12599 log_error ("ERROR: invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain.");
12600
12601 return (-1);
12602 }
12603 }
12604
12605 data.gpu_temp_disable = gpu_temp_disable;
12606 data.gpu_temp_abort = gpu_temp_abort;
12607 data.gpu_temp_retain = gpu_temp_retain;
12608
12609 if (data.quiet == 0)
12610 {
12611 log_info ("Hashes: %u hashes; %u unique digests, %u unique salts", hashes_cnt_orig, digests_cnt, salts_cnt);
12612
12613 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);
12614
12615 if (attack_mode == ATTACK_MODE_STRAIGHT)
12616 {
12617 log_info ("Rules: %u", gpu_rules_cnt);
12618 }
12619
12620 if (opti_type)
12621 {
12622 log_info ("Applicable Optimizers:");
12623
12624 for (uint i = 0; i < 32; i++)
12625 {
12626 const uint opti_bit = 1 << i;
12627
12628 if (opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit));
12629 }
12630 }
12631
12632 /**
12633 * Watchdog and Temperature balance
12634 */
12635
12636 if (gpu_temp_abort == 0)
12637 {
12638 log_info ("Watchdog: Temperature abort trigger disabled");
12639 }
12640 else
12641 {
12642 log_info ("Watchdog: Temperature abort trigger set to %uc", gpu_temp_abort);
12643 }
12644
12645 if (gpu_temp_retain == 0)
12646 {
12647 log_info ("Watchdog: Temperature retain trigger disabled");
12648 }
12649 else
12650 {
12651 log_info ("Watchdog: Temperature retain trigger set to %uc", gpu_temp_retain);
12652 }
12653 }
12654
12655 /**
12656 * devices init
12657 */
12658
12659 int *temp_retain_fanspeed_value = (int *) mycalloc (devices_cnt, sizeof (int));
12660
12661 ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (devices_cnt, sizeof (ADLOD6MemClockState));
12662
12663 int *od_power_control_status = (int *) mycalloc (devices_cnt, sizeof (int));
12664
12665 hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (devices_cnt, sizeof (hc_device_param_t));
12666
12667 data.devices_param = devices_param;
12668
12669 for (uint device_id = 0; device_id < devices_cnt; device_id++)
12670 {
12671 hc_device_param_t *device_param = &data.devices_param[device_id];
12672
12673 cl_device_id device = devices[device_id];
12674
12675 device_param->device = device;
12676
12677 cl_uint max_compute_units = 0;
12678
12679 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
12680
12681 device_param->gpu_processors = max_compute_units;
12682
12683 cl_ulong max_mem_alloc_size = 0;
12684
12685 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL);
12686
12687 device_param->gpu_maxmem_alloc = max_mem_alloc_size;
12688
12689 char tmp[INFOSZ], t1[64];
12690
12691 memset (tmp, 0, sizeof (tmp));
12692
12693 hc_clGetDeviceInfo (device, CL_DEVICE_NAME, sizeof (tmp), &tmp, NULL);
12694
12695 device_param->device_name = mystrdup (tmp);
12696
12697 memset (tmp, 0, sizeof (tmp));
12698
12699 hc_clGetDeviceInfo (device, CL_DEVICE_VERSION, sizeof (tmp), &tmp, NULL);
12700
12701 memset (t1, 0, sizeof (t1));
12702
12703 sscanf (tmp, "%*16s %*16s %*16s (%[^)]16s)", t1);
12704
12705 device_param->device_version = mystrdup (t1);
12706
12707 memset (tmp, 0, sizeof (tmp));
12708
12709 hc_clGetDeviceInfo (device, CL_DRIVER_VERSION, sizeof (tmp), &tmp, NULL);
12710
12711 device_param->driver_version = mystrdup (tmp);
12712
12713 if (vendor_id == VENDOR_ID_AMD)
12714 {
12715 cl_uint gpu_processor_cores = 0;
12716
12717 #define CL_DEVICE_WAVEFRONT_WIDTH_AMD 0x4043
12718
12719 hc_clGetDeviceInfo (device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (gpu_processor_cores), &gpu_processor_cores, NULL);
12720
12721 device_param->gpu_processor_cores = gpu_processor_cores;
12722 }
12723
12724 if (vendor_id == VENDOR_ID_NV)
12725 {
12726 cl_uint kernel_exec_timeout = 0;
12727
12728 #define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
12729
12730 hc_clGetDeviceInfo (device, CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV, sizeof (kernel_exec_timeout), &kernel_exec_timeout, NULL);
12731
12732 device_param->kernel_exec_timeout = kernel_exec_timeout;
12733
12734 cl_uint gpu_processor_cores = 0;
12735
12736 #define CL_DEVICE_WARP_SIZE_NV 0x4003
12737
12738 hc_clGetDeviceInfo (device, CL_DEVICE_WARP_SIZE_NV, sizeof (gpu_processor_cores), &gpu_processor_cores, NULL);
12739
12740 device_param->gpu_processor_cores = gpu_processor_cores;
12741
12742 cl_uint sm_minor = 0;
12743 cl_uint sm_major = 0;
12744
12745 #define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
12746 #define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
12747
12748 hc_clGetDeviceInfo (device, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, sizeof (sm_minor), &sm_minor, NULL);
12749 hc_clGetDeviceInfo (device, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, sizeof (sm_major), &sm_major, NULL);
12750
12751 device_param->sm_minor = sm_minor;
12752 device_param->sm_major = sm_major;
12753 }
12754
12755 /**
12756 * common driver check
12757 */
12758
12759 if (vendor_id == VENDOR_ID_NV)
12760 {
12761 if (device_param->kernel_exec_timeout != 0)
12762 {
12763 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);
12764 if (data.quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch");
12765 }
12766 }
12767
12768 if (vendor_id == VENDOR_ID_AMD)
12769 {
12770 int catalyst_check = (force == 1) ? 0 : 1;
12771
12772 int catalyst_warn = 0;
12773
12774 int catalyst_broken = 0;
12775
12776 if (catalyst_check == 1)
12777 {
12778 catalyst_warn = 1;
12779
12780 // v14.9 and higher
12781 if ((atoi (device_param->device_version) >= 1573)
12782 && (atoi (device_param->driver_version) >= 1573))
12783 {
12784 catalyst_warn = 0;
12785 }
12786
12787 catalyst_check = 0;
12788 }
12789
12790 if (catalyst_broken == 1)
12791 {
12792 log_error ("");
12793 log_error ("ATTENTION! The installed GPU driver in your system is known to be broken!");
12794 log_error ("It will pass over cracked hashes and does not report them as cracked");
12795 log_error ("You are STRONGLY encouraged not to use it");
12796 log_error ("You can use --force to override this but do not post error reports if you do so");
12797
12798 return (-1);
12799 }
12800
12801 if (catalyst_warn == 1)
12802 {
12803 log_error ("");
12804 log_error ("ATTENTION! Unsupported or incorrect installed GPU driver detected!");
12805 log_error ("You are STRONGLY encouraged to use the official supported GPU driver for good reasons");
12806 log_error ("See oclHashcat's homepage for official supported GPU drivers");
12807 #ifdef _WIN
12808 log_error ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
12809 #endif
12810 log_error ("You can use --force to override this but do not post error reports if you do so");
12811
12812 return (-1);
12813 }
12814 }
12815 }
12816
12817 /*
12818 * Temporary fix:
12819 * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
12820 * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
12821 * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem)
12822 * Driver / ADL bug?
12823 */
12824
12825 if (vendor_id == VENDOR_ID_AMD)
12826 {
12827 if (powertune_enable == 1)
12828 {
12829 hc_thread_mutex_lock (mux_adl);
12830
12831 for (uint i = 0; i < devices_cnt; i++)
12832 {
12833 if (data.hm_device[i].od_version == 6)
12834 {
12835 // set powertune value only
12836
12837 int powertune_supported = 0;
12838
12839 int ADL_rc = 0;
12840
12841 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK)
12842 {
12843 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
12844
12845 return (-1);
12846 }
12847
12848 if (powertune_supported != 0)
12849 {
12850 // powertune set
12851 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
12852
12853 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune)) != ADL_OK)
12854 {
12855 log_error ("ERROR: Failed to get current ADL PowerControl settings");
12856
12857 return (-1);
12858 }
12859
12860 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, powertune.iMaxValue)) != ADL_OK)
12861 {
12862 log_error ("ERROR: Failed to set new ADL PowerControl values");
12863
12864 return (-1);
12865 }
12866 }
12867 }
12868 }
12869
12870 hc_thread_mutex_unlock (mux_adl);
12871 }
12872 }
12873
12874 uint gpu_blocks_all = 0;
12875
12876 for (uint device_id = 0; device_id < devices_cnt; device_id++)
12877 {
12878 /**
12879 * host buffer
12880 */
12881
12882 hc_device_param_t *device_param = &data.devices_param[device_id];
12883
12884 /**
12885 * device properties
12886 */
12887
12888 char *device_name = device_param->device_name;
12889 char *device_version = device_param->device_version;
12890 char *driver_version = device_param->driver_version;
12891
12892 uint gpu_processors = device_param->gpu_processors;
12893
12894 uint gpu_processor_cores = device_param->gpu_processor_cores;
12895
12896 /**
12897 * create context for each device
12898 */
12899
12900 device_param->context = hc_clCreateContext (NULL, 1, &device_param->device, NULL, NULL);
12901
12902 /**
12903 * create command-queue
12904 */
12905
12906 // not support with NV
12907 // device_param->command_queue = hc_clCreateCommandQueueWithProperties (device_param->context, device_param->device, NULL);
12908
12909 device_param->command_queue = hc_clCreateCommandQueue (device_param->context, device_param->device, 0);
12910
12911 /**
12912 * create input buffers on device
12913 */
12914
12915 uint gpu_threads = GPU_THREADS;
12916
12917 // bcrypt
12918 if (hash_mode == 3200) gpu_threads = 8;
12919 if (hash_mode == 9000) gpu_threads = 8;
12920
12921 uint gpu_power = gpu_processors * gpu_threads * gpu_accel;
12922 uint gpu_blocks = gpu_power;
12923
12924 device_param->gpu_threads = gpu_threads;
12925 device_param->gpu_power_user = gpu_power;
12926 device_param->gpu_blocks_user = gpu_blocks;
12927
12928 gpu_blocks_all += gpu_blocks;
12929
12930 uint size_pws = gpu_power * sizeof (pw_t);
12931
12932 uint size_tmps = 4;
12933
12934 switch (hash_mode)
12935 {
12936 case 400: size_tmps = gpu_blocks * sizeof (phpass_tmp_t); break;
12937 case 500: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
12938 case 501: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
12939 case 1600: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
12940 case 1800: size_tmps = gpu_blocks * sizeof (sha512crypt_tmp_t); break;
12941 case 2100: size_tmps = gpu_blocks * sizeof (dcc2_tmp_t); break;
12942 case 2500: size_tmps = gpu_blocks * sizeof (wpa_tmp_t); break;
12943 case 3200: size_tmps = gpu_blocks * sizeof (bcrypt_tmp_t); break;
12944 case 5200: size_tmps = gpu_blocks * sizeof (pwsafe3_tmp_t); break;
12945 case 5800: size_tmps = gpu_blocks * sizeof (androidpin_tmp_t); break;
12946 case 6211:
12947 case 6212:
12948 case 6213: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
12949 case 6221:
12950 case 6222:
12951 case 6223: size_tmps = gpu_blocks * sizeof (tc64_tmp_t); break;
12952 case 6231:
12953 case 6232:
12954 case 6233: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
12955 case 6241:
12956 case 6242:
12957 case 6243: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
12958 case 6300: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
12959 case 6400: size_tmps = gpu_blocks * sizeof (sha256aix_tmp_t); break;
12960 case 6500: size_tmps = gpu_blocks * sizeof (sha512aix_tmp_t); break;
12961 case 6600: size_tmps = gpu_blocks * sizeof (agilekey_tmp_t); break;
12962 case 6700: size_tmps = gpu_blocks * sizeof (sha1aix_tmp_t); break;
12963 case 6800: size_tmps = gpu_blocks * sizeof (lastpass_tmp_t); break;
12964 case 7100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
12965 case 7200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
12966 case 7400: size_tmps = gpu_blocks * sizeof (sha256crypt_tmp_t); break;
12967 case 7900: size_tmps = gpu_blocks * sizeof (drupal7_tmp_t); break;
12968 case 8200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
12969 case 8800: size_tmps = gpu_blocks * sizeof (androidfde_tmp_t); break;
12970 case 8900: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
12971 case 9000: size_tmps = gpu_blocks * sizeof (pwsafe2_tmp_t); break;
12972 case 9100: size_tmps = gpu_blocks * sizeof (lotus8_tmp_t); break;
12973 case 9200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
12974 case 9300: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
12975 case 9400: size_tmps = gpu_blocks * sizeof (office2007_tmp_t); break;
12976 case 9500: size_tmps = gpu_blocks * sizeof (office2010_tmp_t); break;
12977 case 9600: size_tmps = gpu_blocks * sizeof (office2013_tmp_t); break;
12978 case 10000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
12979 case 10200: size_tmps = gpu_blocks * sizeof (cram_md5_t); break;
12980 case 10300: size_tmps = gpu_blocks * sizeof (saph_sha1_tmp_t); break;
12981 case 10500: size_tmps = gpu_blocks * sizeof (pdf14_tmp_t); break;
12982 case 10700: size_tmps = gpu_blocks * sizeof (pdf17l8_tmp_t); break;
12983 case 10900: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
12984 case 11300: size_tmps = gpu_blocks * sizeof (bitcoin_wallet_tmp_t); break;
12985 case 11600: size_tmps = gpu_blocks * sizeof (seven_zip_tmp_t); break;
12986 case 11900: size_tmps = gpu_blocks * sizeof (pbkdf2_md5_tmp_t); break;
12987 case 12000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha1_tmp_t); break;
12988 case 12100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
12989 case 12200: size_tmps = gpu_blocks * sizeof (ecryptfs_tmp_t); break;
12990 case 12300: size_tmps = gpu_blocks * sizeof (oraclet_tmp_t); break;
12991 case 12400: size_tmps = gpu_blocks * sizeof (bsdicrypt_tmp_t); break;
12992 case 12500: size_tmps = gpu_blocks * sizeof (rar3_tmp_t); break;
12993 case 12700: size_tmps = gpu_blocks * sizeof (mywallet_tmp_t); break;
12994 case 12800: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
12995 };
12996
12997 uint size_hooks = 4;
12998
12999 if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23))
13000 {
13001 // insert correct hook size
13002 }
13003
13004 // we can optimize some stuff here...
13005
13006 device_param->size_pws = size_pws;
13007 device_param->size_tmps = size_tmps;
13008 device_param->size_hooks = size_hooks;
13009
13010 uint size_root_css = SP_PW_MAX * sizeof (cs_t);
13011 uint size_markov_css = SP_PW_MAX * CHARSIZ * sizeof (cs_t);
13012
13013 device_param->size_root_css = size_root_css;
13014 device_param->size_markov_css = size_markov_css;
13015
13016 uint size_results = GPU_THREADS * sizeof (uint);
13017
13018 device_param->size_results = size_results;
13019
13020 uint size_rules = gpu_rules_cnt * sizeof (gpu_rule_t);
13021 uint size_rules_c = GPU_RULES * sizeof (gpu_rule_t);
13022 uint size_plains = digests_cnt * sizeof (plain_t);
13023 uint size_salts = salts_cnt * sizeof (salt_t);
13024 uint size_esalts = salts_cnt * esalt_size;
13025
13026 device_param->size_plains = size_plains;
13027 device_param->size_digests = size_digests;
13028 device_param->size_shown = size_shown;
13029 device_param->size_salts = size_salts;
13030
13031 uint size_combs = GPU_COMBS * sizeof (comb_t);
13032 uint size_bfs = GPU_BFS * sizeof (bf_t);
13033 uint size_tm = 32 * sizeof (bs_word_t);
13034
13035 uint64_t size_scryptV = 1;
13036
13037 if ((hash_mode == 8900) || (hash_mode == 9300))
13038 {
13039 uint tmto_start = 0;
13040 uint tmto_stop = 10;
13041
13042 if (scrypt_tmto)
13043 {
13044 tmto_start = scrypt_tmto;
13045 }
13046 else
13047 {
13048 // in case the user did not specify the tmto manually
13049 // use some values known to run best (tested on 290x for AMD and 980ti for NV)
13050 // but set the lower end only in case the user has a gpu with too less memory
13051
13052 if (hash_mode == 8900)
13053 {
13054 if (vendor_id == VENDOR_ID_AMD)
13055 {
13056 tmto_start = 1;
13057 }
13058 else if (vendor_id == VENDOR_ID_NV)
13059 {
13060 tmto_start = 3;
13061 }
13062 }
13063 else if (hash_mode == 9300)
13064 {
13065 if (vendor_id == VENDOR_ID_AMD)
13066 {
13067 tmto_start = 3;
13068 }
13069 else if (vendor_id == VENDOR_ID_NV)
13070 {
13071 tmto_start = 5;
13072 }
13073 }
13074 }
13075
13076 if (quiet == 0) log_info ("");
13077
13078 uint shader_per_mp = 1;
13079
13080 if (vendor_id == VENDOR_ID_AMD)
13081 {
13082 shader_per_mp = 8;
13083 }
13084
13085 if (vendor_id == VENDOR_ID_NV)
13086 {
13087 shader_per_mp = 32;
13088 }
13089
13090 for (uint tmto = tmto_start; tmto < tmto_stop; tmto++)
13091 {
13092 // TODO: in theory the following calculation needs to be done per salt, not global
13093 // we assume all hashes have the same scrypt settings
13094
13095 size_scryptV = (128 * data.salts_buf[0].scrypt_r) * data.salts_buf[0].scrypt_N;
13096
13097 size_scryptV /= 1 << tmto;
13098
13099 size_scryptV *= gpu_processors * gpu_processor_cores * shader_per_mp;
13100
13101 if (size_scryptV > device_param->gpu_maxmem_alloc)
13102 {
13103 if (quiet == 0) log_info ("WARNING: not enough GPU memory allocatable to use --scrypt-tmto %d, increasing...", tmto);
13104
13105 continue;
13106 }
13107
13108 for (uint salts_pos = 0; salts_pos < data.salts_cnt; salts_pos++)
13109 {
13110 data.salts_buf[salts_pos].scrypt_tmto = tmto;
13111 data.salts_buf[salts_pos].scrypt_phy = gpu_processors * gpu_processor_cores * shader_per_mp;
13112 }
13113
13114 break;
13115 }
13116
13117 if (data.salts_buf[0].scrypt_phy == 0)
13118 {
13119 log_error ("ERROR: can't allocate enough GPU memory");
13120
13121 return -1;
13122 }
13123
13124 if (quiet == 0) log_info ("");
13125 if (quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u, mem: %u\n", data.salts_buf[0].scrypt_tmto, size_scryptV);
13126 }
13127
13128 /**
13129 * default building options
13130 */
13131
13132 char build_opts[1024];
13133
13134 // we don't have sm_* on AMD but it doesn't matter
13135
13136 sprintf (build_opts, "-I. -IOpenCL/ -DVENDOR_ID=%d -DCUDA_ARCH=%d", vendor_id, (device_param->sm_major * 100) + device_param->sm_minor);
13137
13138 /**
13139 * main kernel
13140 */
13141
13142 {
13143 /**
13144 * kernel source filename
13145 */
13146
13147 char source_file[256];
13148
13149 memset (source_file, 0, sizeof (source_file));
13150
13151 generate_source_kernel_filename (attack_exec, attack_kern, kern_type, shared_dir, source_file);
13152
13153 struct stat sst;
13154
13155 if (stat (source_file, &sst) == -1)
13156 {
13157 log_error ("ERROR: %s: %s", source_file, strerror (errno));
13158
13159 return -1;
13160 }
13161
13162 /**
13163 * kernel cached filename
13164 */
13165
13166 char cached_file[256];
13167
13168 memset (cached_file, 0, sizeof (cached_file));
13169
13170 generate_cached_kernel_filename (attack_exec, attack_kern, kern_type, profile_dir, device_name, device_version, driver_version, vendor_id, cached_file);
13171
13172 int cached = 1;
13173
13174 struct stat cst;
13175
13176 if (stat (cached_file, &cst) == -1)
13177 {
13178 cached = 0;
13179 }
13180
13181 /**
13182 * kernel compile or load
13183 */
13184
13185 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
13186
13187 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
13188
13189 if (force_jit_compilation == 0)
13190 {
13191 if (cached == 0)
13192 {
13193 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, cached_file);
13194
13195 load_kernel (source_file, 1, kernel_lengths, kernel_sources);
13196
13197 device_param->program = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
13198
13199 hc_clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
13200
13201 size_t binary_size;
13202
13203 clGetProgramInfo (device_param->program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
13204
13205 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
13206
13207 clGetProgramInfo (device_param->program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
13208
13209 writeProgramBin (cached_file, binary, binary_size);
13210
13211 local_free (binary);
13212 }
13213 else
13214 {
13215 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size);
13216
13217 load_kernel (cached_file, 1, kernel_lengths, kernel_sources);
13218
13219 device_param->program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
13220
13221 hc_clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
13222 }
13223 }
13224 else
13225 {
13226 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, source_file, sst.st_size);
13227
13228 load_kernel (source_file, 1, kernel_lengths, kernel_sources);
13229
13230 device_param->program = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
13231
13232 if (force_jit_compilation == 1500)
13233 {
13234 sprintf (build_opts, "%s -DDESCRYPT_SALT=%d", build_opts, data.salts_buf[0].salt_buf[0]);
13235 }
13236 else if (force_jit_compilation == 8900)
13237 {
13238 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);
13239 }
13240
13241 hc_clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
13242 }
13243
13244 local_free (kernel_lengths);
13245 local_free (kernel_sources[0]);
13246 local_free (kernel_sources);
13247
13248 // this is mostly for debug
13249
13250 size_t ret_val_size = 0;
13251
13252 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
13253
13254 if (ret_val_size > 2)
13255 {
13256 char *build_log = (char *) mymalloc (ret_val_size + 1);
13257
13258 memset (build_log, 0, ret_val_size + 1);
13259
13260 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
13261
13262 puts (build_log);
13263
13264 myfree (build_log);
13265 }
13266 }
13267
13268 /**
13269 * word generator kernel
13270 */
13271
13272 if (attack_mode != ATTACK_MODE_STRAIGHT)
13273 {
13274 /**
13275 * kernel mp source filename
13276 */
13277
13278 char source_file[256];
13279
13280 memset (source_file, 0, sizeof (source_file));
13281
13282 generate_source_kernel_mp_filename (opti_type, opts_type, shared_dir, source_file);
13283
13284 struct stat sst;
13285
13286 if (stat (source_file, &sst) == -1)
13287 {
13288 log_error ("ERROR: %s: %s", source_file, strerror (errno));
13289
13290 return -1;
13291 }
13292
13293 /**
13294 * kernel mp cached filename
13295 */
13296
13297 char cached_file[256];
13298
13299 memset (cached_file, 0, sizeof (cached_file));
13300
13301 generate_cached_kernel_mp_filename (opti_type, opts_type, profile_dir, device_name, device_version, driver_version, vendor_id, cached_file);
13302
13303 int cached = 1;
13304
13305 struct stat cst;
13306
13307 if (stat (cached_file, &cst) == -1)
13308 {
13309 cached = 0;
13310 }
13311
13312 /**
13313 * kernel compile or load
13314 */
13315
13316 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
13317
13318 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
13319
13320 if (cached == 0)
13321 {
13322 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, cached_file);
13323
13324 load_kernel (source_file, 1, kernel_lengths, kernel_sources);
13325
13326 device_param->program_mp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
13327
13328 hc_clBuildProgram (device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL);
13329
13330 size_t binary_size;
13331
13332 clGetProgramInfo (device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
13333
13334 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
13335
13336 clGetProgramInfo (device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
13337
13338 writeProgramBin (cached_file, binary, binary_size);
13339
13340 local_free (binary);
13341 }
13342 else
13343 {
13344 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size);
13345
13346 load_kernel (cached_file, 1, kernel_lengths, kernel_sources);
13347
13348 device_param->program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
13349
13350 hc_clBuildProgram (device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL);
13351 }
13352
13353 local_free (kernel_lengths);
13354 local_free (kernel_sources[0]);
13355 local_free (kernel_sources);
13356
13357 // this is mostly for debug
13358
13359 size_t ret_val_size = 0;
13360
13361 clGetProgramBuildInfo (device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
13362
13363 if (ret_val_size > 2)
13364 {
13365 char *build_log = (char *) mymalloc (ret_val_size + 1);
13366
13367 memset (build_log, 0, ret_val_size + 1);
13368
13369 clGetProgramBuildInfo (device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
13370
13371 puts (build_log);
13372
13373 myfree (build_log);
13374 }
13375 }
13376
13377 /**
13378 * amplifier kernel
13379 */
13380
13381 if (attack_exec == ATTACK_EXEC_ON_GPU)
13382 {
13383
13384 }
13385 else
13386 {
13387 /**
13388 * kernel amp source filename
13389 */
13390
13391 char source_file[256];
13392
13393 memset (source_file, 0, sizeof (source_file));
13394
13395 generate_source_kernel_amp_filename (attack_kern, shared_dir, source_file);
13396
13397 struct stat sst;
13398
13399 if (stat (source_file, &sst) == -1)
13400 {
13401 log_error ("ERROR: %s: %s", source_file, strerror (errno));
13402
13403 return -1;
13404 }
13405
13406 /**
13407 * kernel amp cached filename
13408 */
13409
13410 char cached_file[256];
13411
13412 memset (cached_file, 0, sizeof (cached_file));
13413
13414 generate_cached_kernel_amp_filename (attack_kern, profile_dir, device_name, device_version, driver_version, vendor_id, cached_file);
13415
13416 int cached = 1;
13417
13418 struct stat cst;
13419
13420 if (stat (cached_file, &cst) == -1)
13421 {
13422 cached = 0;
13423 }
13424
13425 /**
13426 * kernel compile or load
13427 */
13428
13429 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
13430
13431 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
13432
13433 if (cached == 0)
13434 {
13435 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, cached_file);
13436
13437 load_kernel (source_file, 1, kernel_lengths, kernel_sources);
13438
13439 device_param->program_amp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
13440
13441 hc_clBuildProgram (device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL);
13442
13443 size_t binary_size;
13444
13445 clGetProgramInfo (device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
13446
13447 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
13448
13449 clGetProgramInfo (device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
13450
13451 writeProgramBin (cached_file, binary, binary_size);
13452
13453 local_free (binary);
13454 }
13455 else
13456 {
13457 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size);
13458
13459 load_kernel (cached_file, 1, kernel_lengths, kernel_sources);
13460
13461 device_param->program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
13462
13463 hc_clBuildProgram (device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL);
13464 }
13465
13466 local_free (kernel_lengths);
13467 local_free (kernel_sources[0]);
13468 local_free (kernel_sources);
13469
13470 // this is mostly for debug
13471
13472 size_t ret_val_size = 0;
13473
13474 clGetProgramBuildInfo (device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
13475
13476 if (ret_val_size > 2)
13477 {
13478 char *build_log = (char *) mymalloc (ret_val_size + 1);
13479
13480 memset (build_log, 0, ret_val_size + 1);
13481
13482 clGetProgramBuildInfo (device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
13483
13484 puts (build_log);
13485
13486 myfree (build_log);
13487 }
13488 }
13489
13490 /**
13491 * global buffers
13492 */
13493
13494 device_param->d_pws_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
13495 device_param->d_pws_amp_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
13496 device_param->d_tmps = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL);
13497 device_param->d_hooks = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL);
13498 device_param->d_bitmap_s1_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13499 device_param->d_bitmap_s1_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13500 device_param->d_bitmap_s1_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13501 device_param->d_bitmap_s1_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13502 device_param->d_bitmap_s2_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13503 device_param->d_bitmap_s2_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13504 device_param->d_bitmap_s2_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13505 device_param->d_bitmap_s2_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
13506 device_param->d_plain_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_plains, NULL);
13507 device_param->d_digests_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_digests, NULL);
13508 device_param->d_digests_shown = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_shown, NULL);
13509 device_param->d_salt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_salts, NULL);
13510 device_param->d_result = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_results, NULL);
13511 device_param->d_scryptV_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_scryptV, NULL);
13512
13513 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_size, bitmap_s1_a, 0, NULL, NULL);
13514 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_size, bitmap_s1_b, 0, NULL, NULL);
13515 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_size, bitmap_s1_c, 0, NULL, NULL);
13516 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_size, bitmap_s1_d, 0, NULL, NULL);
13517 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_size, bitmap_s2_a, 0, NULL, NULL);
13518 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_size, bitmap_s2_b, 0, NULL, NULL);
13519 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_size, bitmap_s2_c, 0, NULL, NULL);
13520 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_size, bitmap_s2_d, 0, NULL, NULL);
13521 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, data.digests_buf, 0, NULL, NULL);
13522 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, data.digests_shown, 0, NULL, NULL);
13523 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, data.salts_buf, 0, NULL, NULL);
13524
13525 run_kernel_bzero (device_param, device_param->d_pws_buf, size_pws);
13526 run_kernel_bzero (device_param, device_param->d_pws_amp_buf, size_pws);
13527 run_kernel_bzero (device_param, device_param->d_tmps, size_tmps);
13528 run_kernel_bzero (device_param, device_param->d_hooks, size_hooks);
13529 run_kernel_bzero (device_param, device_param->d_plain_bufs, size_plains);
13530 run_kernel_bzero (device_param, device_param->d_result, size_results);
13531
13532 /**
13533 * special buffers
13534 */
13535
13536 if (attack_kern == ATTACK_KERN_STRAIGHT)
13537 {
13538 device_param->d_rules = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules, NULL);
13539 device_param->d_rules_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL);
13540
13541 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, gpu_rules_buf, 0, NULL, NULL);
13542
13543 run_kernel_bzero (device_param, device_param->d_rules_c, size_rules_c);
13544 }
13545 else if (attack_kern == ATTACK_KERN_COMBI)
13546 {
13547 device_param->d_combs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
13548 device_param->d_combs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
13549 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
13550 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
13551
13552 run_kernel_bzero (device_param, device_param->d_combs, size_combs);
13553 run_kernel_bzero (device_param, device_param->d_combs_c, size_combs);
13554 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
13555 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
13556 }
13557 else if (attack_kern == ATTACK_KERN_BF)
13558 {
13559 device_param->d_bfs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
13560 device_param->d_bfs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
13561 device_param->d_tm_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_tm, NULL);
13562 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
13563 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
13564
13565 run_kernel_bzero (device_param, device_param->d_bfs, size_bfs);
13566 run_kernel_bzero (device_param, device_param->d_bfs_c, size_bfs);
13567 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
13568 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
13569 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
13570 }
13571
13572 if (size_esalts)
13573 {
13574 device_param->d_esalt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL);
13575
13576 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, data.esalts_buf, 0, NULL, NULL);
13577 }
13578
13579 /**
13580 * main host data
13581 */
13582
13583 uint *result = (uint *) mymalloc (size_results);
13584
13585 memset (result, 0, size_results);
13586
13587 device_param->result = result;
13588
13589 pw_t *pws_buf = (pw_t *) mymalloc (size_pws);
13590
13591 memset (pws_buf, 0, size_pws);
13592
13593 device_param->pws_buf = pws_buf;
13594
13595 pw_cache_t *pw_caches = (pw_cache_t *) mycalloc (64, sizeof (pw_cache_t));
13596
13597 for (int i = 0; i < 64; i++)
13598 {
13599 pw_caches[i].pw_buf.pw_len = i;
13600 pw_caches[i].cnt = 0;
13601 }
13602
13603 device_param->pw_caches = pw_caches;
13604
13605 comb_t *combs_buf = (comb_t *) mycalloc (GPU_COMBS, sizeof (comb_t));
13606
13607 device_param->combs_buf = combs_buf;
13608
13609 void *hooks_buf = mymalloc (size_hooks);
13610
13611 device_param->hooks_buf = hooks_buf;
13612
13613 device_param->pw_transpose = pw_transpose_to_hi1;
13614 device_param->pw_add = pw_add_to_hc1;
13615
13616 /**
13617 * kernel args
13618 */
13619
13620 device_param->kernel_params_buf32[21] = bitmap_mask;
13621 device_param->kernel_params_buf32[22] = bitmap_shift1;
13622 device_param->kernel_params_buf32[23] = bitmap_shift2;
13623 device_param->kernel_params_buf32[24] = 0; // salt_pos
13624 device_param->kernel_params_buf32[25] = 0; // loop_pos
13625 device_param->kernel_params_buf32[26] = 0; // loop_cnt
13626 device_param->kernel_params_buf32[27] = 0; // gpu_rules_cnt
13627 device_param->kernel_params_buf32[28] = 0; // digests_cnt
13628 device_param->kernel_params_buf32[29] = 0; // digests_offset
13629 device_param->kernel_params_buf32[30] = 0; // combs_mode
13630 device_param->kernel_params_buf32[31] = 0; // gid_max
13631
13632 device_param->kernel_params[ 0] = (attack_exec == ATTACK_EXEC_ON_GPU)
13633 ? &device_param->d_pws_buf
13634 : &device_param->d_pws_amp_buf;
13635 device_param->kernel_params[ 1] = &device_param->d_rules_c;
13636 device_param->kernel_params[ 2] = &device_param->d_combs_c;
13637 device_param->kernel_params[ 3] = &device_param->d_bfs_c;
13638 device_param->kernel_params[ 4] = &device_param->d_tmps;
13639 device_param->kernel_params[ 5] = &device_param->d_hooks;
13640 device_param->kernel_params[ 6] = &device_param->d_bitmap_s1_a;
13641 device_param->kernel_params[ 7] = &device_param->d_bitmap_s1_b;
13642 device_param->kernel_params[ 8] = &device_param->d_bitmap_s1_c;
13643 device_param->kernel_params[ 9] = &device_param->d_bitmap_s1_d;
13644 device_param->kernel_params[10] = &device_param->d_bitmap_s2_a;
13645 device_param->kernel_params[11] = &device_param->d_bitmap_s2_b;
13646 device_param->kernel_params[12] = &device_param->d_bitmap_s2_c;
13647 device_param->kernel_params[13] = &device_param->d_bitmap_s2_d;
13648 device_param->kernel_params[14] = &device_param->d_plain_bufs;
13649 device_param->kernel_params[15] = &device_param->d_digests_buf;
13650 device_param->kernel_params[16] = &device_param->d_digests_shown;
13651 device_param->kernel_params[17] = &device_param->d_salt_bufs;
13652 device_param->kernel_params[18] = &device_param->d_esalt_bufs;
13653 device_param->kernel_params[19] = &device_param->d_result;
13654 device_param->kernel_params[20] = &device_param->d_scryptV_buf;
13655 device_param->kernel_params[21] = &device_param->kernel_params_buf32[21];
13656 device_param->kernel_params[22] = &device_param->kernel_params_buf32[22];
13657 device_param->kernel_params[23] = &device_param->kernel_params_buf32[23];
13658 device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
13659 device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
13660 device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
13661 device_param->kernel_params[27] = &device_param->kernel_params_buf32[27];
13662 device_param->kernel_params[28] = &device_param->kernel_params_buf32[28];
13663 device_param->kernel_params[29] = &device_param->kernel_params_buf32[29];
13664 device_param->kernel_params[30] = &device_param->kernel_params_buf32[30];
13665 device_param->kernel_params[31] = &device_param->kernel_params_buf32[31];
13666
13667 device_param->kernel_params_mp_buf64[3] = 0;
13668 device_param->kernel_params_mp_buf32[4] = 0;
13669 device_param->kernel_params_mp_buf32[5] = 0;
13670 device_param->kernel_params_mp_buf32[6] = 0;
13671 device_param->kernel_params_mp_buf32[7] = 0;
13672 device_param->kernel_params_mp_buf32[8] = 0;
13673
13674 device_param->kernel_params_mp[0] = NULL;
13675 device_param->kernel_params_mp[1] = NULL;
13676 device_param->kernel_params_mp[2] = NULL;
13677 device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];
13678 device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4];
13679 device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5];
13680 device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6];
13681 device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7];
13682 device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf32[8];
13683
13684 device_param->kernel_params_mp_l_buf64[3] = 0;
13685 device_param->kernel_params_mp_l_buf32[4] = 0;
13686 device_param->kernel_params_mp_l_buf32[5] = 0;
13687 device_param->kernel_params_mp_l_buf32[6] = 0;
13688 device_param->kernel_params_mp_l_buf32[7] = 0;
13689 device_param->kernel_params_mp_l_buf32[8] = 0;
13690 device_param->kernel_params_mp_l_buf32[9] = 0;
13691
13692 device_param->kernel_params_mp_l[0] = NULL;
13693 device_param->kernel_params_mp_l[1] = NULL;
13694 device_param->kernel_params_mp_l[2] = NULL;
13695 device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3];
13696 device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4];
13697 device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5];
13698 device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6];
13699 device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7];
13700 device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8];
13701 device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf32[9];
13702
13703 device_param->kernel_params_mp_r_buf64[3] = 0;
13704 device_param->kernel_params_mp_r_buf32[4] = 0;
13705 device_param->kernel_params_mp_r_buf32[5] = 0;
13706 device_param->kernel_params_mp_r_buf32[6] = 0;
13707 device_param->kernel_params_mp_r_buf32[7] = 0;
13708 device_param->kernel_params_mp_r_buf32[8] = 0;
13709
13710 device_param->kernel_params_mp_r[0] = NULL;
13711 device_param->kernel_params_mp_r[1] = NULL;
13712 device_param->kernel_params_mp_r[2] = NULL;
13713 device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3];
13714 device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4];
13715 device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5];
13716 device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6];
13717 device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7];
13718 device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf32[8];
13719
13720 device_param->kernel_params_amp_buf32[5] = 0; // combs_mode
13721 device_param->kernel_params_amp_buf32[6] = 0; // gid_max
13722
13723 device_param->kernel_params_amp[0] = &device_param->d_pws_buf;
13724 device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf;
13725 device_param->kernel_params_amp[2] = &device_param->d_rules_c;
13726 device_param->kernel_params_amp[3] = &device_param->d_combs_c;
13727 device_param->kernel_params_amp[4] = &device_param->d_bfs_c;
13728 device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5];
13729 device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf32[6];
13730
13731 device_param->kernel_params_tb[0] = &device_param->d_pws_buf;
13732
13733 device_param->kernel_params_tm[0] = &device_param->d_bfs_c;
13734 device_param->kernel_params_tm[1] = &device_param->d_tm_c;
13735
13736 /**
13737 * kernel name
13738 */
13739
13740 char kernel_name[64];
13741
13742 memset (kernel_name, 0, sizeof (kernel_name));
13743
13744 if (attack_exec == ATTACK_EXEC_ON_GPU)
13745 {
13746 if (opti_type & OPTI_TYPE_SINGLE_HASH)
13747 {
13748 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 4);
13749
13750 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
13751
13752 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 8);
13753
13754 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
13755
13756 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 16);
13757
13758 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
13759 }
13760 else
13761 {
13762 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 4);
13763
13764 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
13765
13766 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 8);
13767
13768 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
13769
13770 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 16);
13771
13772 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
13773 }
13774
13775 if (data.attack_mode == ATTACK_MODE_BF)
13776 {
13777 if (opts_type & OPTS_TYPE_PT_BITSLICE)
13778 {
13779 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tb", kern_type);
13780
13781 device_param->kernel_tb = hc_clCreateKernel (device_param->program, kernel_name);
13782
13783 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tm", kern_type);
13784
13785 device_param->kernel_tm = hc_clCreateKernel (device_param->program, kernel_name);
13786 }
13787 }
13788 }
13789 else
13790 {
13791 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_init", kern_type);
13792
13793 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
13794
13795 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_loop", kern_type);
13796
13797 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
13798
13799 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_comp", kern_type);
13800
13801 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
13802
13803 if (opts_type & OPTS_TYPE_HOOK12)
13804 {
13805 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook12", kern_type);
13806
13807 device_param->kernel12 = hc_clCreateKernel (device_param->program, kernel_name);
13808 }
13809
13810 if (opts_type & OPTS_TYPE_HOOK23)
13811 {
13812 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook23", kern_type);
13813
13814 device_param->kernel23 = hc_clCreateKernel (device_param->program, kernel_name);
13815 }
13816 }
13817
13818 for (uint i = 0; i <= 20; i++)
13819 {
13820 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]);
13821 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]);
13822 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]);
13823
13824 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]);
13825 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]);
13826 }
13827
13828 for (uint i = 21; i <= 31; i++)
13829 {
13830 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]);
13831 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]);
13832 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]);
13833
13834 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]);
13835 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]);
13836 }
13837
13838 if (attack_mode == ATTACK_MODE_BF)
13839 {
13840 device_param->kernel_mp_l = hc_clCreateKernel (device_param->program_mp, "l_markov");
13841 device_param->kernel_mp_r = hc_clCreateKernel (device_param->program_mp, "r_markov");
13842
13843 if (opts_type & OPTS_TYPE_PT_BITSLICE)
13844 {
13845 hc_clSetKernelArg (device_param->kernel_tb, 0, sizeof (cl_mem), device_param->kernel_params_tb[0]);
13846
13847 hc_clSetKernelArg (device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]);
13848 hc_clSetKernelArg (device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]);
13849 }
13850 }
13851 else if (attack_mode == ATTACK_MODE_HYBRID1)
13852 {
13853 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
13854 }
13855 else if (attack_mode == ATTACK_MODE_HYBRID2)
13856 {
13857 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
13858 }
13859
13860 if (attack_exec == ATTACK_EXEC_ON_GPU)
13861 {
13862 // nothing to do
13863 }
13864 else
13865 {
13866 device_param->kernel_amp = hc_clCreateKernel (device_param->program_amp, "amp");
13867 }
13868
13869 if (attack_exec == ATTACK_EXEC_ON_GPU)
13870 {
13871 // nothing to do
13872 }
13873 else
13874 {
13875 for (uint i = 0; i < 5; i++)
13876 {
13877 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]);
13878 }
13879
13880 for (uint i = 5; i < 7; i++)
13881 {
13882 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]);
13883 }
13884 }
13885
13886 /**
13887 * Store initial fanspeed if gpu_temp_retain is enabled
13888 */
13889
13890 int gpu_temp_retain_set = 0;
13891
13892 if (gpu_temp_disable == 0)
13893 {
13894 if (gpu_temp_retain != 0) // VENDOR_ID_AMD implied
13895 {
13896 hc_thread_mutex_lock (mux_adl);
13897
13898 if (data.hm_device[device_id].fan_supported == 1)
13899 {
13900 if (gpu_temp_retain_chgd == 0)
13901 {
13902 uint cur_temp = 0;
13903 uint default_temp = 0;
13904
13905 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);
13906
13907 if (ADL_rc == ADL_OK)
13908 {
13909 #define GPU_TEMP_RETAIN_ABORT_DIFF 15
13910
13911 const uint gpu_temp_retain_target = default_temp - GPU_TEMP_RETAIN_ABORT_DIFF;
13912
13913 // special case with multi gpu setups: always use minimum retain
13914
13915 if (gpu_temp_retain_set == 0)
13916 {
13917 gpu_temp_retain = gpu_temp_retain_target;
13918 gpu_temp_retain_set = 1;
13919 }
13920 else
13921 {
13922 gpu_temp_retain = MIN (gpu_temp_retain, gpu_temp_retain_target);
13923 }
13924
13925 if (gpu_temp_abort_chgd == 0) gpu_temp_abort = gpu_temp_retain + GPU_TEMP_RETAIN_ABORT_DIFF;
13926 }
13927 }
13928
13929 const int fan_speed = hm_get_fanspeed_with_device_id (device_id);
13930
13931 temp_retain_fanspeed_value[device_id] = fan_speed;
13932
13933 if (fan_speed == -1)
13934 {
13935 log_info ("WARNING: Failed to get current fan speed settings for gpu number: %i:", device_id + 1);
13936
13937 temp_retain_fanspeed_value[device_id] = 0;
13938 }
13939 }
13940
13941 hc_thread_mutex_unlock (mux_adl);
13942 }
13943 }
13944
13945 /**
13946 * Store original powercontrol/clocks settings, set overdrive 6 performance tuning settings
13947 */
13948
13949 if (powertune_enable == 1) // VENDOR_ID_AMD implied
13950 {
13951 hc_thread_mutex_lock (mux_adl);
13952
13953 if (data.hm_device[device_id].od_version == 6)
13954 {
13955 int ADL_rc;
13956
13957 // check powertune capabilities first, if not available then skip device
13958
13959 int powertune_supported = 0;
13960
13961 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &powertune_supported)) != ADL_OK)
13962 {
13963 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
13964
13965 return (-1);
13966 }
13967
13968 if (powertune_supported != 0)
13969 {
13970 // powercontrol settings
13971
13972 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
13973
13974 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &powertune)) == ADL_OK)
13975 {
13976 ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &od_power_control_status[device_id]);
13977 }
13978
13979 if (ADL_rc != ADL_OK)
13980 {
13981 log_error ("ERROR: Failed to get current ADL PowerControl settings");
13982
13983 return (-1);
13984 }
13985
13986 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index.amd, powertune.iMaxValue)) != ADL_OK)
13987 {
13988 log_error ("ERROR: Failed to set new ADL PowerControl values");
13989
13990 return (-1);
13991 }
13992
13993 // clocks
13994
13995 memset (&od_clock_mem_status[device_id], 0, sizeof (ADLOD6MemClockState));
13996
13997 od_clock_mem_status[device_id].state.iNumberOfPerformanceLevels = 2;
13998
13999 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)
14000 {
14001 log_error ("ERROR: Failed to get ADL memory and engine clock frequency");
14002
14003 return (-1);
14004 }
14005
14006 // Query capabilities only to see if profiles were not "damaged", if so output a warning but do accept the users profile settings
14007
14008 ADLOD6Capabilities caps = {0, 0, 0, {0, 0, 0}, {0, 0, 0}, 0, 0};
14009
14010 if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index.amd, &caps)) != ADL_OK)
14011 {
14012 log_error ("ERROR: Failed to get ADL device capabilities");
14013
14014 return (-1);
14015 }
14016
14017 int engine_clock_max = caps.sEngineClockRange.iMax * 0.6666;
14018 int memory_clock_max = caps.sMemoryClockRange.iMax * 0.6250;
14019
14020 int warning_trigger_engine = (int) (0.25 * (float) engine_clock_max);
14021 int warning_trigger_memory = (int) (0.25 * (float) memory_clock_max);
14022
14023 int engine_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iEngineClock;
14024 int memory_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock;
14025
14026 // warning if profile has to low max values
14027
14028 if ((engine_clock_max - engine_clock_profile_max) > warning_trigger_engine)
14029 {
14030 log_info ("WARN: the custom profile seems to have too low maximum engine clock values. You therefore may not reach full performance");
14031 }
14032
14033 if ((memory_clock_max - memory_clock_profile_max) > warning_trigger_memory)
14034 {
14035 log_info ("WARN: the custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance");
14036 }
14037
14038 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
14039
14040 performance_state->iNumberOfPerformanceLevels = 2;
14041
14042 performance_state->aLevels[0].iEngineClock = engine_clock_profile_max;
14043 performance_state->aLevels[1].iEngineClock = engine_clock_profile_max;
14044 performance_state->aLevels[0].iMemoryClock = memory_clock_profile_max;
14045 performance_state->aLevels[1].iMemoryClock = memory_clock_profile_max;
14046
14047 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)
14048 {
14049 log_info ("ERROR: Failed to set ADL performance state");
14050
14051 return (-1);
14052 }
14053
14054 local_free (performance_state);
14055 }
14056 }
14057
14058 hc_thread_mutex_unlock (mux_adl);
14059 }
14060 }
14061
14062 data.gpu_blocks_all = gpu_blocks_all;
14063
14064 if (data.quiet == 0) log_info ("");
14065
14066 /**
14067 * Inform user which algorithm is checked and at which workload setting
14068 */
14069
14070 if (benchmark == 1)
14071 {
14072 quiet = 0;
14073
14074 data.quiet = quiet;
14075
14076 char *hash_type = strhashtype (data.hash_mode); // not a bug
14077
14078 log_info ("Hashtype: %s", hash_type);
14079 log_info ("Workload: %u loops, %u accel", gpu_loops, gpu_accel);
14080 log_info ("");
14081 }
14082
14083 /**
14084 * keep track of the progress
14085 */
14086
14087 data.words_progress_done = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
14088 data.words_progress_rejected = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
14089 data.words_progress_restored = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
14090
14091 /**
14092 * open filehandles
14093 */
14094
14095 #if _WIN
14096 if (_setmode (_fileno (stdin), _O_BINARY) == -1)
14097 {
14098 log_error ("ERROR: %s: %s", "stdin", strerror (errno));
14099
14100 return (-1);
14101 }
14102
14103 if (_setmode (_fileno (stdout), _O_BINARY) == -1)
14104 {
14105 log_error ("ERROR: %s: %s", "stdout", strerror (errno));
14106
14107 return (-1);
14108 }
14109
14110 if (_setmode (_fileno (stderr), _O_BINARY) == -1)
14111 {
14112 log_error ("ERROR: %s: %s", "stderr", strerror (errno));
14113
14114 return (-1);
14115 }
14116 #endif
14117
14118 /**
14119 * dictionary pad
14120 */
14121
14122 segment_size *= (1024 * 1024);
14123
14124 data.segment_size = segment_size;
14125
14126 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
14127
14128 wl_data->buf = (char *) mymalloc (segment_size);
14129 wl_data->avail = segment_size;
14130 wl_data->incr = segment_size;
14131 wl_data->cnt = 0;
14132 wl_data->pos = 0;
14133
14134 uint wordlist_mode = ((optind + 1) < myargc) ? WL_MODE_FILE : WL_MODE_STDIN;
14135
14136 data.wordlist_mode = wordlist_mode;
14137
14138 cs_t *css_buf = NULL;
14139 uint css_cnt = 0;
14140 uint dictcnt = 0;
14141 uint maskcnt = 1;
14142 char **masks = NULL;
14143 char **dictfiles = NULL;
14144
14145 uint mask_from_file = 0;
14146
14147 if (attack_mode == ATTACK_MODE_STRAIGHT)
14148 {
14149 if (wordlist_mode == WL_MODE_FILE)
14150 {
14151 int wls_left = myargc - (optind + 1);
14152
14153 for (int i = 0; i < wls_left; i++)
14154 {
14155 char *l0_filename = myargv[optind + 1 + i];
14156
14157 struct stat l0_stat;
14158
14159 if (stat (l0_filename, &l0_stat) == -1)
14160 {
14161 log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
14162
14163 return (-1);
14164 }
14165
14166 uint is_dir = S_ISDIR (l0_stat.st_mode);
14167
14168 if (is_dir == 0)
14169 {
14170 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14171
14172 dictcnt++;
14173
14174 dictfiles[dictcnt - 1] = l0_filename;
14175 }
14176 else
14177 {
14178 // do not allow --keyspace w/ a directory
14179
14180 if (keyspace == 1)
14181 {
14182 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
14183
14184 return (-1);
14185 }
14186
14187 char **dictionary_files = NULL;
14188
14189 dictionary_files = scan_directory (l0_filename);
14190
14191 if (dictionary_files != NULL)
14192 {
14193 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
14194
14195 for (int d = 0; dictionary_files[d] != NULL; d++)
14196 {
14197 char *l1_filename = dictionary_files[d];
14198
14199 struct stat l1_stat;
14200
14201 if (stat (l1_filename, &l1_stat) == -1)
14202 {
14203 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
14204
14205 return (-1);
14206 }
14207
14208 if (S_ISREG (l1_stat.st_mode))
14209 {
14210 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14211
14212 dictcnt++;
14213
14214 dictfiles[dictcnt - 1] = strdup (l1_filename);
14215 }
14216 }
14217 }
14218
14219 local_free (dictionary_files);
14220 }
14221 }
14222
14223 if (dictcnt < 1)
14224 {
14225 log_error ("ERROR: No usable dictionary file found.");
14226
14227 return (-1);
14228 }
14229 }
14230 else if (wordlist_mode == WL_MODE_STDIN)
14231 {
14232 dictcnt = 1;
14233 }
14234 }
14235 else if (attack_mode == ATTACK_MODE_COMBI)
14236 {
14237 // display
14238
14239 char *dictfile1 = myargv[optind + 1 + 0];
14240 char *dictfile2 = myargv[optind + 1 + 1];
14241
14242 // find the bigger dictionary and use as base
14243
14244 FILE *fp1;
14245 FILE *fp2;
14246
14247 struct stat tmp_stat;
14248
14249 if ((fp1 = fopen (dictfile1, "rb")) == NULL)
14250 {
14251 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
14252
14253 return (-1);
14254 }
14255
14256 if (stat (dictfile1, &tmp_stat) == -1)
14257 {
14258 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
14259
14260 fclose (fp1);
14261
14262 return (-1);
14263 }
14264
14265 if (S_ISDIR (tmp_stat.st_mode))
14266 {
14267 log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno));
14268
14269 fclose (fp1);
14270
14271 return (-1);
14272 }
14273
14274 if ((fp2 = fopen (dictfile2, "rb")) == NULL)
14275 {
14276 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
14277
14278 fclose (fp1);
14279
14280 return (-1);
14281 }
14282
14283 if (stat (dictfile2, &tmp_stat) == -1)
14284 {
14285 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
14286
14287 fclose (fp1);
14288 fclose (fp2);
14289
14290 return (-1);
14291 }
14292
14293 if (S_ISDIR (tmp_stat.st_mode))
14294 {
14295 log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno));
14296
14297 fclose (fp1);
14298 fclose (fp2);
14299
14300 return (-1);
14301 }
14302
14303 data.combs_cnt = 1;
14304
14305 data.quiet = 1;
14306
14307 const uint64_t words1_cnt = count_words (wl_data, fp1, dictfile1, dictstat_base, &dictstat_nmemb);
14308
14309 data.quiet = quiet;
14310
14311 if (words1_cnt == 0)
14312 {
14313 log_error ("ERROR: %s: empty file", dictfile1);
14314
14315 fclose (fp1);
14316 fclose (fp2);
14317
14318 return (-1);
14319 }
14320
14321 data.combs_cnt = 1;
14322
14323 data.quiet = 1;
14324
14325 const uint64_t words2_cnt = count_words (wl_data, fp2, dictfile2, dictstat_base, &dictstat_nmemb);
14326
14327 data.quiet = quiet;
14328
14329 if (words2_cnt == 0)
14330 {
14331 log_error ("ERROR: %s: empty file", dictfile2);
14332
14333 fclose (fp1);
14334 fclose (fp2);
14335
14336 return (-1);
14337 }
14338
14339 fclose (fp1);
14340 fclose (fp2);
14341
14342 data.dictfile = dictfile1;
14343 data.dictfile2 = dictfile2;
14344
14345 if (words1_cnt >= words2_cnt)
14346 {
14347 data.combs_cnt = words2_cnt;
14348 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
14349
14350 dictfiles = &data.dictfile;
14351
14352 dictcnt = 1;
14353 }
14354 else
14355 {
14356 data.combs_cnt = words1_cnt;
14357 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
14358
14359 dictfiles = &data.dictfile2;
14360
14361 dictcnt = 1;
14362
14363 // we also have to switch wordlist related rules!
14364
14365 char *tmpc = data.rule_buf_l;
14366
14367 data.rule_buf_l = data.rule_buf_r;
14368 data.rule_buf_r = tmpc;
14369
14370 int tmpi = data.rule_len_l;
14371
14372 data.rule_len_l = data.rule_len_r;
14373 data.rule_len_r = tmpi;
14374 }
14375 }
14376 else if (attack_mode == ATTACK_MODE_BF)
14377 {
14378 char *mask = NULL;
14379
14380 maskcnt = 0;
14381
14382 if (benchmark == 0)
14383 {
14384 mask = myargv[optind + 1];
14385
14386 masks = (char **) mymalloc (INCR_MASKS * sizeof (char *));
14387
14388 if ((optind + 2) <= myargc)
14389 {
14390 struct stat file_stat;
14391
14392 if (stat (mask, &file_stat) == -1)
14393 {
14394 maskcnt = 1;
14395
14396 masks[maskcnt - 1] = mystrdup (mask);
14397 }
14398 else
14399 {
14400 int wls_left = myargc - (optind + 1);
14401
14402 uint masks_avail = INCR_MASKS;
14403
14404 for (int i = 0; i < wls_left; i++)
14405 {
14406 if (i != 0)
14407 {
14408 mask = myargv[optind + 1 + i];
14409
14410 if (stat (mask, &file_stat) == -1)
14411 {
14412 log_error ("ERROR: %s: %s", mask, strerror (errno));
14413
14414 return (-1);
14415 }
14416 }
14417
14418 uint is_file = S_ISREG (file_stat.st_mode);
14419
14420 if (is_file == 1)
14421 {
14422 FILE *mask_fp;
14423
14424 if ((mask_fp = fopen (mask, "r")) == NULL)
14425 {
14426 log_error ("ERROR: %s: %s", mask, strerror (errno));
14427
14428 return (-1);
14429 }
14430
14431 char line_buf[BUFSIZ];
14432
14433 while (!feof (mask_fp))
14434 {
14435 memset (line_buf, 0, BUFSIZ);
14436
14437 int line_len = fgetl (mask_fp, line_buf);
14438
14439 if (line_len == 0) continue;
14440
14441 if (line_buf[0] == '#') continue;
14442
14443 if (masks_avail == maskcnt)
14444 {
14445 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
14446
14447 masks_avail += INCR_MASKS;
14448 }
14449
14450 masks[maskcnt] = mystrdup (line_buf);
14451
14452 maskcnt++;
14453 }
14454
14455 fclose (mask_fp);
14456 }
14457 else
14458 {
14459 log_error ("ERROR: %s: unsupported file-type", mask);
14460
14461 return (-1);
14462 }
14463 }
14464
14465 mask_from_file = 1;
14466 }
14467 }
14468 else
14469 {
14470 custom_charset_1 = (char *) "?l?d?u";
14471 custom_charset_2 = (char *) "?l?d";
14472 custom_charset_3 = (char *) "?l?d*!$@_";
14473
14474 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
14475 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
14476 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
14477
14478 masks[maskcnt] = mystrdup ("?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d");
14479
14480 wordlist_mode = WL_MODE_MASK;
14481
14482 data.wordlist_mode = wordlist_mode;
14483
14484 increment = 1;
14485
14486 maskcnt = 1;
14487 }
14488 }
14489 else
14490 {
14491 /**
14492 * generate full masks and charsets
14493 */
14494
14495 masks = (char **) mymalloc (sizeof (char *));
14496
14497 switch (hash_mode)
14498 {
14499 case 1731: pw_min = 5;
14500 pw_max = 5;
14501 mask = mystrdup ("?b?b?b?b?b");
14502 break;
14503 case 12500: pw_min = 5;
14504 pw_max = 5;
14505 mask = mystrdup ("?b?b?b?b?b");
14506 break;
14507 default: pw_min = 7;
14508 pw_max = 7;
14509 mask = mystrdup ("?b?b?b?b?b?b?b");
14510 break;
14511 }
14512
14513 maskcnt = 1;
14514
14515 masks[maskcnt - 1] = mystrdup (mask);
14516
14517 wordlist_mode = WL_MODE_MASK;
14518
14519 data.wordlist_mode = wordlist_mode;
14520
14521 increment = 1;
14522 }
14523
14524 dictfiles = (char **) mycalloc (pw_max, sizeof (char *));
14525
14526 if (increment)
14527 {
14528 if (increment_min > pw_min) pw_min = increment_min;
14529
14530 if (increment_max < pw_max) pw_max = increment_max;
14531 }
14532 }
14533 else if (attack_mode == ATTACK_MODE_HYBRID1)
14534 {
14535 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
14536
14537 // display
14538
14539 char *mask = myargv[myargc - 1];
14540
14541 maskcnt = 0;
14542
14543 masks = (char **) mymalloc (1 * sizeof (char *));
14544
14545 // mod
14546
14547 struct stat file_stat;
14548
14549 if (stat (mask, &file_stat) == -1)
14550 {
14551 maskcnt = 1;
14552
14553 masks[maskcnt - 1] = mystrdup (mask);
14554 }
14555 else
14556 {
14557 uint is_file = S_ISREG (file_stat.st_mode);
14558
14559 if (is_file == 1)
14560 {
14561 FILE *mask_fp;
14562
14563 if ((mask_fp = fopen (mask, "r")) == NULL)
14564 {
14565 log_error ("ERROR: %s: %s", mask, strerror (errno));
14566
14567 return (-1);
14568 }
14569
14570 char line_buf[BUFSIZ];
14571
14572 uint masks_avail = 1;
14573
14574 while (!feof (mask_fp))
14575 {
14576 memset (line_buf, 0, BUFSIZ);
14577
14578 int line_len = fgetl (mask_fp, line_buf);
14579
14580 if (line_len == 0) continue;
14581
14582 if (line_buf[0] == '#') continue;
14583
14584 if (masks_avail == maskcnt)
14585 {
14586 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
14587
14588 masks_avail += INCR_MASKS;
14589 }
14590
14591 masks[maskcnt] = mystrdup (line_buf);
14592
14593 maskcnt++;
14594 }
14595
14596 fclose (mask_fp);
14597
14598 mask_from_file = 1;
14599 }
14600 else
14601 {
14602 maskcnt = 1;
14603
14604 masks[maskcnt - 1] = mystrdup (mask);
14605 }
14606 }
14607
14608 // base
14609
14610 int wls_left = myargc - (optind + 2);
14611
14612 for (int i = 0; i < wls_left; i++)
14613 {
14614 char *filename = myargv[optind + 1 + i];
14615
14616 struct stat file_stat;
14617
14618 if (stat (filename, &file_stat) == -1)
14619 {
14620 log_error ("ERROR: %s: %s", filename, strerror (errno));
14621
14622 return (-1);
14623 }
14624
14625 uint is_dir = S_ISDIR (file_stat.st_mode);
14626
14627 if (is_dir == 0)
14628 {
14629 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14630
14631 dictcnt++;
14632
14633 dictfiles[dictcnt - 1] = filename;
14634 }
14635 else
14636 {
14637 // do not allow --keyspace w/ a directory
14638
14639 if (keyspace == 1)
14640 {
14641 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
14642
14643 return (-1);
14644 }
14645
14646 char **dictionary_files = NULL;
14647
14648 dictionary_files = scan_directory (filename);
14649
14650 if (dictionary_files != NULL)
14651 {
14652 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
14653
14654 for (int d = 0; dictionary_files[d] != NULL; d++)
14655 {
14656 char *l1_filename = dictionary_files[d];
14657
14658 struct stat l1_stat;
14659
14660 if (stat (l1_filename, &l1_stat) == -1)
14661 {
14662 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
14663
14664 return (-1);
14665 }
14666
14667 if (S_ISREG (l1_stat.st_mode))
14668 {
14669 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14670
14671 dictcnt++;
14672
14673 dictfiles[dictcnt - 1] = strdup (l1_filename);
14674 }
14675 }
14676 }
14677
14678 local_free (dictionary_files);
14679 }
14680 }
14681
14682 if (dictcnt < 1)
14683 {
14684 log_error ("ERROR: No usable dictionary file found.");
14685
14686 return (-1);
14687 }
14688
14689 if (increment)
14690 {
14691 maskcnt = 0;
14692
14693 uint mask_min = increment_min; // we can't reject smaller masks here
14694 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
14695
14696 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
14697 {
14698 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
14699
14700 if (cur_mask == NULL) break;
14701
14702 masks[maskcnt] = cur_mask;
14703
14704 maskcnt++;
14705
14706 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
14707 }
14708 }
14709 }
14710 else if (attack_mode == ATTACK_MODE_HYBRID2)
14711 {
14712 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
14713
14714 // display
14715
14716 char *mask = myargv[optind + 1 + 0];
14717
14718 maskcnt = 0;
14719
14720 masks = (char **) mymalloc (1 * sizeof (char *));
14721
14722 // mod
14723
14724 struct stat file_stat;
14725
14726 if (stat (mask, &file_stat) == -1)
14727 {
14728 maskcnt = 1;
14729
14730 masks[maskcnt - 1] = mystrdup (mask);
14731 }
14732 else
14733 {
14734 uint is_file = S_ISREG (file_stat.st_mode);
14735
14736 if (is_file == 1)
14737 {
14738 FILE *mask_fp;
14739
14740 if ((mask_fp = fopen (mask, "r")) == NULL)
14741 {
14742 log_error ("ERROR: %s: %s", mask, strerror (errno));
14743
14744 return (-1);
14745 }
14746
14747 char line_buf[BUFSIZ];
14748
14749 uint masks_avail = 1;
14750
14751 while (!feof (mask_fp))
14752 {
14753 memset (line_buf, 0, BUFSIZ);
14754
14755 int line_len = fgetl (mask_fp, line_buf);
14756
14757 if (line_len == 0) continue;
14758
14759 if (line_buf[0] == '#') continue;
14760
14761 if (masks_avail == maskcnt)
14762 {
14763 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
14764
14765 masks_avail += INCR_MASKS;
14766 }
14767
14768 masks[maskcnt] = mystrdup (line_buf);
14769
14770 maskcnt++;
14771 }
14772
14773 fclose (mask_fp);
14774
14775 mask_from_file = 1;
14776 }
14777 else
14778 {
14779 maskcnt = 1;
14780
14781 masks[maskcnt - 1] = mystrdup (mask);
14782 }
14783 }
14784
14785 // base
14786
14787 int wls_left = myargc - (optind + 2);
14788
14789 for (int i = 0; i < wls_left; i++)
14790 {
14791 char *filename = myargv[optind + 2 + i];
14792
14793 struct stat file_stat;
14794
14795 if (stat (filename, &file_stat) == -1)
14796 {
14797 log_error ("ERROR: %s: %s", filename, strerror (errno));
14798
14799 return (-1);
14800 }
14801
14802 uint is_dir = S_ISDIR (file_stat.st_mode);
14803
14804 if (is_dir == 0)
14805 {
14806 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14807
14808 dictcnt++;
14809
14810 dictfiles[dictcnt - 1] = filename;
14811 }
14812 else
14813 {
14814 // do not allow --keyspace w/ a directory
14815
14816 if (keyspace == 1)
14817 {
14818 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
14819
14820 return (-1);
14821 }
14822
14823 char **dictionary_files = NULL;
14824
14825 dictionary_files = scan_directory (filename);
14826
14827 if (dictionary_files != NULL)
14828 {
14829 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
14830
14831 for (int d = 0; dictionary_files[d] != NULL; d++)
14832 {
14833 char *l1_filename = dictionary_files[d];
14834
14835 struct stat l1_stat;
14836
14837 if (stat (l1_filename, &l1_stat) == -1)
14838 {
14839 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
14840
14841 return (-1);
14842 }
14843
14844 if (S_ISREG (l1_stat.st_mode))
14845 {
14846 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
14847
14848 dictcnt++;
14849
14850 dictfiles[dictcnt - 1] = strdup (l1_filename);
14851 }
14852 }
14853 }
14854
14855 local_free (dictionary_files);
14856 }
14857 }
14858
14859 if (dictcnt < 1)
14860 {
14861 log_error ("ERROR: No usable dictionary file found.");
14862
14863 return (-1);
14864 }
14865
14866 if (increment)
14867 {
14868 maskcnt = 0;
14869
14870 uint mask_min = increment_min; // we can't reject smaller masks here
14871 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
14872
14873 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
14874 {
14875 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
14876
14877 if (cur_mask == NULL) break;
14878
14879 masks[maskcnt] = cur_mask;
14880
14881 maskcnt++;
14882
14883 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
14884 }
14885 }
14886 }
14887
14888 data.pw_min = pw_min;
14889 data.pw_max = pw_max;
14890
14891 /**
14892 * weak hash check
14893 */
14894
14895 if (weak_hash_threshold >= salts_cnt)
14896 {
14897 if (data.quiet == 0) log_info_nn ("Checking for weak hashes...");
14898
14899 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
14900 {
14901 weak_hash_check (&data.devices_param[0], salt_pos, gpu_loops);
14902 }
14903 }
14904
14905 // Display hack, guarantee that there is at least one \r before real start
14906
14907 if (data.quiet == 0) log_info_nn ("");
14908
14909 /**
14910 * status and monitor threads
14911 */
14912
14913 if (data.devices_status != STATUS_CRACKED) data.devices_status = STATUS_STARTING;
14914
14915 hc_thread_t i_thread = 0;
14916
14917 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
14918 {
14919 hc_thread_create (i_thread, thread_keypress, &benchmark);
14920 }
14921
14922 if (wordlist_mode == WL_MODE_STDIN) data.status = 1;
14923
14924 uint ni_threads_cnt = 0;
14925
14926 hc_thread_t *ni_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
14927
14928 hc_thread_create (ni_threads[ni_threads_cnt], thread_monitor, NULL);
14929
14930 ni_threads_cnt++;
14931
14932 /**
14933 * Outfile remove
14934 */
14935
14936 if (keyspace == 0)
14937 {
14938 if (outfile_check_timer != 0)
14939 {
14940 if (data.outfile_check_directory != NULL)
14941 {
14942 if ((hash_mode != 5200) &&
14943 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
14944 (hash_mode != 9000))
14945 {
14946 hc_thread_create (ni_threads[ni_threads_cnt], thread_outfile_remove, NULL);
14947
14948 ni_threads_cnt++;
14949 }
14950 else
14951 {
14952 outfile_check_timer = 0;
14953 }
14954 }
14955 else
14956 {
14957 outfile_check_timer = 0;
14958 }
14959 }
14960 }
14961
14962 /**
14963 * Inform the user if we got some hashes remove because of the pot file remove feature
14964 */
14965
14966 if (data.quiet == 0)
14967 {
14968 if (potfile_remove_cracks > 0)
14969 {
14970 if (potfile_remove_cracks == 1) log_info ("INFO: removed 1 hash found in pot file\n");
14971 else log_info ("INFO: removed %u hashes found in pot file\n", potfile_remove_cracks);
14972 }
14973 }
14974
14975 data.outfile_check_timer = outfile_check_timer;
14976
14977 /**
14978 * main loop
14979 */
14980
14981 char **induction_dictionaries = NULL;
14982
14983 int induction_dictionaries_cnt = 0;
14984
14985 hcstat_table_t *root_table_buf = NULL;
14986 hcstat_table_t *markov_table_buf = NULL;
14987
14988 uint initial_restore_done = 0;
14989
14990 data.maskcnt = maskcnt;
14991
14992 for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
14993 {
14994 if (data.devices_status == STATUS_CRACKED) break;
14995
14996 data.devices_status = STATUS_INIT;
14997
14998 if (maskpos > rd->maskpos)
14999 {
15000 rd->dictpos = 0;
15001 }
15002
15003 rd->maskpos = maskpos;
15004 data.maskpos = maskpos;
15005
15006 if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2 || attack_mode == ATTACK_MODE_BF)
15007 {
15008 char *mask = masks[maskpos];
15009
15010 if (mask_from_file == 1)
15011 {
15012 if (mask[0] == '\\' && mask[1] == '#') mask++; // escaped comment sign (sharp) "\#"
15013
15014 char *str_ptr;
15015 uint str_pos;
15016
15017 uint mask_offset = 0;
15018
15019 uint separator_cnt;
15020
15021 for (separator_cnt = 0; separator_cnt < 4; separator_cnt++)
15022 {
15023 str_ptr = strstr (mask + mask_offset, ",");
15024
15025 if (str_ptr == NULL) break;
15026
15027 str_pos = str_ptr - mask;
15028
15029 // escaped separator, i.e. "\,"
15030
15031 if (str_pos > 0)
15032 {
15033 if (mask[str_pos - 1] == '\\')
15034 {
15035 separator_cnt --;
15036
15037 mask_offset = str_pos + 1;
15038
15039 continue;
15040 }
15041 }
15042
15043 // reset the offset
15044
15045 mask_offset = 0;
15046
15047 mask[str_pos] = '\0';
15048
15049 switch (separator_cnt)
15050 {
15051 case 0:
15052 mp_reset_usr (mp_usr, 0);
15053
15054 custom_charset_1 = mask;
15055 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
15056 break;
15057
15058 case 1:
15059 mp_reset_usr (mp_usr, 1);
15060
15061 custom_charset_2 = mask;
15062 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
15063 break;
15064
15065 case 2:
15066 mp_reset_usr (mp_usr, 2);
15067
15068 custom_charset_3 = mask;
15069 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
15070 break;
15071
15072 case 3:
15073 mp_reset_usr (mp_usr, 3);
15074
15075 custom_charset_4 = mask;
15076 mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
15077 break;
15078 }
15079
15080 mask = mask + str_pos + 1;
15081 }
15082 }
15083
15084 if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
15085 {
15086 if (maskpos > 0)
15087 {
15088 local_free (css_buf);
15089 local_free (data.root_css_buf);
15090 local_free (data.markov_css_buf);
15091
15092 local_free (masks[maskpos - 1]);
15093 }
15094
15095 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
15096
15097 data.mask = mask;
15098 data.css_cnt = css_cnt;
15099 data.css_buf = css_buf;
15100
15101 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
15102
15103 memset (uniq_tbls, 0, sizeof (uniq_tbls));
15104
15105 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
15106
15107 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
15108 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
15109
15110 sp_setup_tbl (shared_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
15111
15112 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
15113
15114 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
15115 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
15116
15117 data.root_css_buf = root_css_buf;
15118 data.markov_css_buf = markov_css_buf;
15119
15120 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
15121
15122 data.combs_cnt = sp_get_sum (0, css_cnt, root_css_buf);
15123
15124 local_free (root_table_buf);
15125 local_free (markov_table_buf);
15126
15127 // args
15128
15129 for (uint device_id = 0; device_id < devices_cnt; device_id++)
15130 {
15131 hc_device_param_t *device_param = &data.devices_param[device_id];
15132
15133 device_param->kernel_params_mp[0] = &device_param->d_combs;
15134 device_param->kernel_params_mp[1] = &device_param->d_root_css_buf;
15135 device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf;
15136
15137 device_param->kernel_params_mp_buf64[3] = 0;
15138 device_param->kernel_params_mp_buf32[4] = css_cnt;
15139 device_param->kernel_params_mp_buf32[5] = 0;
15140 device_param->kernel_params_mp_buf32[6] = 0;
15141 device_param->kernel_params_mp_buf32[7] = 0;
15142
15143 if (attack_mode == ATTACK_MODE_HYBRID1)
15144 {
15145 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_buf32[5] = full01;
15146 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_buf32[5] = full80;
15147 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_buf32[6] = 1;
15148 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_buf32[7] = 1;
15149 }
15150 else if (attack_mode == ATTACK_MODE_HYBRID2)
15151 {
15152 device_param->kernel_params_mp_buf32[5] = 0;
15153 device_param->kernel_params_mp_buf32[6] = 0;
15154 device_param->kernel_params_mp_buf32[7] = 0;
15155 }
15156
15157 for (uint i = 0; i < 3; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]);
15158 for (uint i = 3; i < 4; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]);
15159 for (uint i = 4; i < 8; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]);
15160
15161 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);
15162 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);
15163 }
15164 }
15165 else if (attack_mode == ATTACK_MODE_BF)
15166 {
15167 dictcnt = 0; // number of "sub-masks", i.e. when using incremental mode
15168
15169 if (increment)
15170 {
15171 for (uint i = 0; i < dictcnt; i++)
15172 {
15173 local_free (dictfiles[i]);
15174 }
15175
15176 for (uint pw_len = MAX (1, pw_min); pw_len <= pw_max; pw_len++)
15177 {
15178 char *l1_filename = mp_get_truncated_mask (mask, strlen (mask), pw_len);
15179
15180 if (l1_filename == NULL) break;
15181
15182 dictcnt++;
15183
15184 dictfiles[dictcnt - 1] = l1_filename;
15185 }
15186 }
15187 else
15188 {
15189 dictcnt++;
15190
15191 dictfiles[dictcnt - 1] = mask;
15192 }
15193
15194 if (dictcnt == 0)
15195 {
15196 log_error ("ERROR: Mask is too small");
15197
15198 return (-1);
15199 }
15200 }
15201 }
15202
15203 free (induction_dictionaries);
15204
15205 // induction_dictionaries_cnt = 0; // implied
15206
15207 if (attack_mode != ATTACK_MODE_BF)
15208 {
15209 if (keyspace == 0)
15210 {
15211 induction_dictionaries = scan_directory (induction_directory);
15212
15213 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
15214 }
15215 }
15216
15217 if (induction_dictionaries_cnt)
15218 {
15219 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
15220 }
15221
15222 /**
15223 * prevent the user from using --keyspace together w/ maskfile and or dictfile
15224 */
15225 if (keyspace == 1)
15226 {
15227 if ((maskcnt > 1) || (dictcnt > 1))
15228 {
15229 log_error ("ERROR: --keyspace is not supported with --increment or mask files");
15230
15231 return (-1);
15232 }
15233 }
15234
15235 for (uint dictpos = rd->dictpos; dictpos < dictcnt; )
15236 {
15237 char *subid = logfile_generate_subid ();
15238
15239 data.subid = subid;
15240
15241 logfile_sub_msg ("START");
15242
15243 data.devices_status = STATUS_INIT;
15244
15245 memset (data.words_progress_done, 0, data.salts_cnt * sizeof (uint64_t));
15246 memset (data.words_progress_rejected, 0, data.salts_cnt * sizeof (uint64_t));
15247 memset (data.words_progress_restored, 0, data.salts_cnt * sizeof (uint64_t));
15248
15249 memset (data.cpt_buf, 0, CPT_BUF * sizeof (cpt_t));
15250
15251 data.cpt_pos = 0;
15252
15253 data.cpt_start = time (NULL);
15254
15255 data.cpt_total = 0;
15256
15257 if (data.restore == 0)
15258 {
15259 rd->words_cur = skip;
15260
15261 skip = 0;
15262
15263 data.skip = 0;
15264 }
15265
15266 data.ms_paused = 0;
15267
15268 data.words_cur = rd->words_cur;
15269
15270 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
15271 {
15272 hc_device_param_t *device_param = &data.devices_param[device_id];
15273
15274 device_param->speed_pos = 0;
15275
15276 memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (uint64_t));
15277 memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float));
15278 memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
15279
15280 device_param->gpu_power = device_param->gpu_power_user;
15281 device_param->gpu_blocks = device_param->gpu_blocks_user;
15282
15283 device_param->outerloop_pos = 0;
15284 device_param->outerloop_left = 0;
15285 device_param->innerloop_pos = 0;
15286 device_param->innerloop_left = 0;
15287
15288 // some more resets:
15289
15290 memset (device_param->pw_caches, 0, 64 * sizeof (pw_cache_t));
15291
15292 memset (device_param->pws_buf, 0, device_param->size_pws);
15293
15294 device_param->pw_cnt = 0;
15295 device_param->pws_cnt = 0;
15296
15297 device_param->words_off = 0;
15298 device_param->words_done = 0;
15299 }
15300
15301 data.gpu_blocks_div = 0;
15302
15303 // figure out some workload
15304
15305 if (attack_mode == ATTACK_MODE_STRAIGHT)
15306 {
15307 if (data.wordlist_mode == WL_MODE_FILE)
15308 {
15309 char *dictfile = NULL;
15310
15311 if (induction_dictionaries_cnt)
15312 {
15313 dictfile = induction_dictionaries[0];
15314 }
15315 else
15316 {
15317 dictfile = dictfiles[dictpos];
15318 }
15319
15320 data.dictfile = dictfile;
15321
15322 logfile_sub_string (dictfile);
15323
15324 for (uint i = 0; i < rp_files_cnt; i++)
15325 {
15326 logfile_sub_var_string ("rulefile", rp_files[i]);
15327 }
15328
15329 FILE *fd2 = fopen (dictfile, "rb");
15330
15331 if (fd2 == NULL)
15332 {
15333 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
15334
15335 return (-1);
15336 }
15337
15338 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
15339
15340 fclose (fd2);
15341
15342 if (data.words_cnt == 0)
15343 {
15344 if (data.devices_status == STATUS_CRACKED) break;
15345 if (data.devices_status == STATUS_ABORTED) break;
15346
15347 dictpos++;
15348
15349 continue;
15350 }
15351 }
15352 }
15353 else if (attack_mode == ATTACK_MODE_COMBI)
15354 {
15355 char *dictfile = data.dictfile;
15356 char *dictfile2 = data.dictfile2;
15357
15358 logfile_sub_string (dictfile);
15359 logfile_sub_string (dictfile2);
15360
15361 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
15362 {
15363 FILE *fd2 = fopen (dictfile, "rb");
15364
15365 if (fd2 == NULL)
15366 {
15367 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
15368
15369 return (-1);
15370 }
15371
15372 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
15373
15374 fclose (fd2);
15375 }
15376 else if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
15377 {
15378 FILE *fd2 = fopen (dictfile2, "rb");
15379
15380 if (fd2 == NULL)
15381 {
15382 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
15383
15384 return (-1);
15385 }
15386
15387 data.words_cnt = count_words (wl_data, fd2, dictfile2, dictstat_base, &dictstat_nmemb);
15388
15389 fclose (fd2);
15390 }
15391
15392 if (data.words_cnt == 0)
15393 {
15394 if (data.devices_status == STATUS_CRACKED) break;
15395 if (data.devices_status == STATUS_ABORTED) break;
15396
15397 dictpos++;
15398
15399 continue;
15400 }
15401 }
15402 else if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
15403 {
15404 char *dictfile = NULL;
15405
15406 if (induction_dictionaries_cnt)
15407 {
15408 dictfile = induction_dictionaries[0];
15409 }
15410 else
15411 {
15412 dictfile = dictfiles[dictpos];
15413 }
15414
15415 data.dictfile = dictfile;
15416
15417 char *mask = data.mask;
15418
15419 logfile_sub_string (dictfile);
15420 logfile_sub_string (mask);
15421
15422 FILE *fd2 = fopen (dictfile, "rb");
15423
15424 if (fd2 == NULL)
15425 {
15426 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
15427
15428 return (-1);
15429 }
15430
15431 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
15432
15433 fclose (fd2);
15434
15435 if (data.words_cnt == 0)
15436 {
15437 if (data.devices_status == STATUS_CRACKED) break;
15438 if (data.devices_status == STATUS_ABORTED) break;
15439
15440 dictpos++;
15441
15442 continue;
15443 }
15444 }
15445 else if (attack_mode == ATTACK_MODE_BF)
15446 {
15447 local_free (css_buf);
15448 local_free (data.root_css_buf);
15449 local_free (data.markov_css_buf);
15450
15451 char *mask = dictfiles[dictpos];
15452
15453 logfile_sub_string (mask);
15454
15455 // base
15456
15457 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
15458
15459 if (opts_type & OPTS_TYPE_PT_UNICODE)
15460 {
15461 uint css_cnt_unicode = css_cnt * 2;
15462
15463 cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t));
15464
15465 for (uint i = 0, j = 0; i < css_cnt; i += 1, j += 2)
15466 {
15467 memcpy (&css_buf_unicode[j + 0], &css_buf[i], sizeof (cs_t));
15468
15469 css_buf_unicode[j + 1].cs_buf[0] = 0;
15470 css_buf_unicode[j + 1].cs_len = 1;
15471 }
15472
15473 free (css_buf);
15474
15475 css_buf = css_buf_unicode;
15476 css_cnt = css_cnt_unicode;
15477 }
15478
15479 // check if mask is not too large or too small for pw_min/pw_max (*2 if unicode)
15480
15481 uint mask_min = pw_min;
15482 uint mask_max = pw_max;
15483
15484 if (opts_type & OPTS_TYPE_PT_UNICODE)
15485 {
15486 mask_min *= 2;
15487 mask_max *= 2;
15488 }
15489
15490 if ((css_cnt < mask_min) || (css_cnt > mask_max))
15491 {
15492 if (css_cnt < mask_min)
15493 {
15494 log_info ("WARNING: skipping mask '%s' because it is smaller than the minimum password length", mask);
15495 }
15496
15497 if (css_cnt > mask_max)
15498 {
15499 log_info ("WARNING: skipping mask '%s' because it is larger than the maximum password length", mask);
15500 }
15501
15502 // skip to next mask
15503
15504 dictpos++;
15505
15506 rd->dictpos = dictpos;
15507
15508 logfile_sub_msg ("STOP");
15509
15510 continue;
15511 }
15512
15513 uint save_css_cnt = css_cnt;
15514
15515 if (opti_type & OPTI_TYPE_SINGLE_HASH)
15516 {
15517 if (opti_type & OPTI_TYPE_APPENDED_SALT)
15518 {
15519 uint salt_len = (uint) data.salts_buf[0].salt_len;
15520 char *salt_buf = (char *) data.salts_buf[0].salt_buf;
15521
15522 uint css_cnt_salt = css_cnt + salt_len;
15523
15524 cs_t *css_buf_salt = (cs_t *) mycalloc (css_cnt_salt, sizeof (cs_t));
15525
15526 memcpy (css_buf_salt, css_buf, css_cnt * sizeof (cs_t));
15527
15528 for (uint i = 0, j = css_cnt; i < salt_len; i++, j++)
15529 {
15530 css_buf_salt[j].cs_buf[0] = salt_buf[i];
15531 css_buf_salt[j].cs_len = 1;
15532 }
15533
15534 free (css_buf);
15535
15536 css_buf = css_buf_salt;
15537 css_cnt = css_cnt_salt;
15538 }
15539 }
15540
15541 data.mask = mask;
15542 data.css_cnt = css_cnt;
15543 data.css_buf = css_buf;
15544
15545 if (maskpos > 0 && dictpos == 0) free (masks[maskpos - 1]);
15546
15547 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
15548
15549 memset (uniq_tbls, 0, sizeof (uniq_tbls));
15550
15551 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
15552
15553 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
15554 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
15555
15556 sp_setup_tbl (shared_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
15557
15558 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
15559
15560 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
15561 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
15562
15563 data.root_css_buf = root_css_buf;
15564 data.markov_css_buf = markov_css_buf;
15565
15566 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
15567
15568 data.words_cnt = sp_get_sum (0, css_cnt, root_css_buf);
15569
15570 local_free (root_table_buf);
15571 local_free (markov_table_buf);
15572
15573 // copy + args
15574
15575 uint css_cnt_l = css_cnt;
15576 uint css_cnt_r;
15577
15578 if (attack_exec == ATTACK_EXEC_ON_GPU)
15579 {
15580 if (save_css_cnt < 6)
15581 {
15582 css_cnt_r = 1;
15583 }
15584 else if (save_css_cnt == 6)
15585 {
15586 css_cnt_r = 2;
15587 }
15588 else
15589 {
15590 if (opts_type & OPTS_TYPE_PT_UNICODE)
15591 {
15592 if (save_css_cnt == 8 || save_css_cnt == 10)
15593 {
15594 css_cnt_r = 2;
15595 }
15596 else
15597 {
15598 css_cnt_r = 4;
15599 }
15600 }
15601 else
15602 {
15603 if ((css_buf[0].cs_len * css_buf[1].cs_len * css_buf[2].cs_len) > 256)
15604 {
15605 css_cnt_r = 3;
15606 }
15607 else
15608 {
15609 css_cnt_r = 4;
15610 }
15611 }
15612 }
15613 }
15614 else
15615 {
15616 css_cnt_r = 1;
15617
15618 /* unfinished code?
15619 int sum = css_buf[css_cnt_r - 1].cs_len;
15620
15621 for (uint i = 1; i < 4 && i < css_cnt; i++)
15622 {
15623 if (sum > 1) break; // we really don't need alot of amplifier them for slow hashes
15624
15625 css_cnt_r++;
15626
15627 sum *= css_buf[css_cnt_r - 1].cs_len;
15628 }
15629 */
15630 }
15631
15632 css_cnt_l -= css_cnt_r;
15633
15634 data.bfs_cnt = sp_get_sum (0, css_cnt_r, root_css_buf);
15635
15636 for (uint device_id = 0; device_id < devices_cnt; device_id++)
15637 {
15638 hc_device_param_t *device_param = &data.devices_param[device_id];
15639
15640 device_param->kernel_params_mp_l[0] = &device_param->d_pws_buf;
15641 device_param->kernel_params_mp_l[1] = &device_param->d_root_css_buf;
15642 device_param->kernel_params_mp_l[2] = &device_param->d_markov_css_buf;
15643
15644 device_param->kernel_params_mp_l_buf64[3] = 0;
15645 device_param->kernel_params_mp_l_buf32[4] = css_cnt_l;
15646 device_param->kernel_params_mp_l_buf32[5] = css_cnt_r;
15647 device_param->kernel_params_mp_l_buf32[6] = 0;
15648 device_param->kernel_params_mp_l_buf32[7] = 0;
15649 device_param->kernel_params_mp_l_buf32[8] = 0;
15650
15651 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_l_buf32[6] = full01;
15652 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_l_buf32[6] = full80;
15653 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1;
15654 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1;
15655
15656 device_param->kernel_params_mp_r[0] = &device_param->d_bfs;
15657 device_param->kernel_params_mp_r[1] = &device_param->d_root_css_buf;
15658 device_param->kernel_params_mp_r[2] = &device_param->d_markov_css_buf;
15659
15660 device_param->kernel_params_mp_r_buf64[3] = 0;
15661 device_param->kernel_params_mp_r_buf32[4] = css_cnt_r;
15662 device_param->kernel_params_mp_r_buf32[5] = 0;
15663 device_param->kernel_params_mp_r_buf32[6] = 0;
15664 device_param->kernel_params_mp_r_buf32[7] = 0;
15665
15666 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]);
15667 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]);
15668 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]);
15669
15670 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]);
15671 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]);
15672 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]);
15673
15674 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);
15675 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);
15676 }
15677 }
15678
15679 uint64_t words_base = data.words_cnt;
15680
15681 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
15682 {
15683 if (data.gpu_rules_cnt)
15684 {
15685 words_base /= data.gpu_rules_cnt;
15686 }
15687 }
15688 else if (data.attack_kern == ATTACK_KERN_COMBI)
15689 {
15690 if (data.combs_cnt)
15691 {
15692 words_base /= data.combs_cnt;
15693 }
15694 }
15695 else if (data.attack_kern == ATTACK_KERN_BF)
15696 {
15697 if (data.bfs_cnt)
15698 {
15699 words_base /= data.bfs_cnt;
15700 }
15701 }
15702
15703 data.words_base = words_base;
15704
15705 if (keyspace == 1)
15706 {
15707 log_info ("%llu", (unsigned long long int) words_base);
15708
15709 return (0);
15710 }
15711
15712 if (data.words_cur > data.words_base)
15713 {
15714 log_error ("ERROR: restore value greater keyspace");
15715
15716 return (-1);
15717 }
15718
15719 if (data.words_cur)
15720 {
15721 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
15722 {
15723 for (uint i = 0; i < data.salts_cnt; i++)
15724 {
15725 data.words_progress_restored[i] = data.words_cur * data.gpu_rules_cnt;
15726 }
15727 }
15728 else if (data.attack_kern == ATTACK_KERN_COMBI)
15729 {
15730 for (uint i = 0; i < data.salts_cnt; i++)
15731 {
15732 data.words_progress_restored[i] = data.words_cur * data.combs_cnt;
15733 }
15734 }
15735 else if (data.attack_kern == ATTACK_KERN_BF)
15736 {
15737 for (uint i = 0; i < data.salts_cnt; i++)
15738 {
15739 data.words_progress_restored[i] = data.words_cur * data.bfs_cnt;
15740 }
15741 }
15742 }
15743
15744 /*
15745 * Inform user about possible slow speeds
15746 */
15747
15748 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
15749 {
15750 if (data.words_base < gpu_blocks_all)
15751 {
15752 if (quiet == 0)
15753 {
15754 log_info ("");
15755 log_info ("ATTENTION!");
15756 log_info (" The wordlist or mask you are using is too small.");
15757 log_info (" Therefore, oclHashcat is unable to utilize the full parallelization power of your GPU(s).");
15758 log_info (" The cracking speed will drop.");
15759 log_info (" Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
15760 log_info ("");
15761 }
15762 }
15763 }
15764
15765 /*
15766 * Update loopback file
15767 */
15768
15769 if (loopback == 1)
15770 {
15771 time_t now;
15772
15773 time (&now);
15774
15775 uint random_num = get_random_num (0, 9999);
15776
15777 snprintf (loopback_file, loopback_size - 1, "%s/%s.%d_%i", induction_directory, LOOPBACK_FILE, (int) now, random_num);
15778
15779 data.loopback_file = loopback_file;
15780 }
15781
15782 /*
15783 * Update dictionary statistic
15784 */
15785
15786 if (keyspace == 0)
15787 {
15788 dictstat_fp = fopen (dictstat, "wb");
15789
15790 if (dictstat_fp)
15791 {
15792 fwrite (dictstat_base, sizeof (dictstat_t), dictstat_nmemb, dictstat_fp);
15793
15794 fclose (dictstat_fp);
15795 }
15796 }
15797
15798 data.devices_status = STATUS_RUNNING;
15799
15800 if (initial_restore_done == 0)
15801 {
15802 if (data.restore_disable == 0) cycle_restore ();
15803
15804 initial_restore_done = 1;
15805 }
15806
15807 hc_timer_set (&data.timer_running);
15808
15809 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
15810 {
15811 if ((quiet == 0) && (status == 0) && (benchmark == 0))
15812 {
15813 if (quiet == 0) fprintf (stdout, "%s", PROMPT);
15814 if (quiet == 0) fflush (stdout);
15815 }
15816 }
15817 else if (wordlist_mode == WL_MODE_STDIN)
15818 {
15819 if (data.quiet == 0) log_info ("Starting attack in stdin mode...");
15820 if (data.quiet == 0) log_info ("");
15821 }
15822
15823 time_t runtime_start;
15824
15825 time (&runtime_start);
15826
15827 data.runtime_start = runtime_start;
15828
15829 /**
15830 * create cracker threads
15831 */
15832
15833 hc_thread_t *c_threads = (hc_thread_t *) mycalloc (devices_cnt, sizeof (hc_thread_t));
15834
15835 for (uint device_id = 0; device_id < devices_cnt; device_id++)
15836 {
15837 hc_device_param_t *device_param = &devices_param[device_id];
15838
15839 device_param->device_id = device_id;
15840
15841 if (wordlist_mode == WL_MODE_STDIN)
15842 {
15843 hc_thread_create (c_threads[device_id], thread_calc_stdin, device_param);
15844 }
15845 else
15846 {
15847 hc_thread_create (c_threads[device_id], thread_calc, device_param);
15848 }
15849 }
15850
15851 // wait for crack threads to exit
15852
15853 hc_thread_wait (devices_cnt, c_threads);
15854
15855 local_free (c_threads);
15856
15857 data.restore = 0;
15858
15859 // finalize task
15860
15861 logfile_sub_var_uint ("status-after-work", data.devices_status);
15862
15863 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
15864
15865 if (data.devices_status == STATUS_CRACKED) break;
15866 if (data.devices_status == STATUS_ABORTED) break;
15867
15868 if (data.devices_status == STATUS_BYPASS)
15869 {
15870 data.devices_status = STATUS_RUNNING;
15871 }
15872
15873 if (induction_dictionaries_cnt)
15874 {
15875 unlink (induction_dictionaries[0]);
15876 }
15877
15878 free (induction_dictionaries);
15879
15880 if (attack_mode != ATTACK_MODE_BF)
15881 {
15882 induction_dictionaries = scan_directory (induction_directory);
15883
15884 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
15885 }
15886
15887 if (benchmark == 0)
15888 {
15889 if (((dictpos + 1) < dictcnt) || ((maskpos + 1) < maskcnt) || induction_dictionaries_cnt)
15890 {
15891 if (quiet == 0) clear_prompt ();
15892
15893 if (quiet == 0) log_info ("");
15894
15895 if (status == 1)
15896 {
15897 status_display ();
15898 }
15899 else
15900 {
15901 if (quiet == 0) status_display ();
15902 }
15903
15904 if (quiet == 0) log_info ("");
15905 }
15906 }
15907
15908 if (attack_mode == ATTACK_MODE_BF)
15909 {
15910 dictpos++;
15911
15912 rd->dictpos = dictpos;
15913 }
15914 else
15915 {
15916 if (induction_dictionaries_cnt)
15917 {
15918 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
15919 }
15920 else
15921 {
15922 dictpos++;
15923
15924 rd->dictpos = dictpos;
15925 }
15926 }
15927
15928 time_t runtime_stop;
15929
15930 time (&runtime_stop);
15931
15932 data.runtime_stop = runtime_stop;
15933
15934 logfile_sub_uint (runtime_start);
15935 logfile_sub_uint (runtime_stop);
15936
15937 logfile_sub_msg ("STOP");
15938
15939 global_free (subid);
15940 }
15941
15942 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) check_checkpoint ();
15943
15944 if (data.devices_status == STATUS_CRACKED) break;
15945 if (data.devices_status == STATUS_ABORTED) break;
15946 if (data.devices_status == STATUS_QUIT) break;
15947
15948 if (data.devices_status == STATUS_BYPASS)
15949 {
15950 data.devices_status = STATUS_RUNNING;
15951 }
15952 }
15953
15954 // 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
15955
15956 if (attack_mode == ATTACK_MODE_STRAIGHT)
15957 {
15958 if (data.wordlist_mode == WL_MODE_FILE)
15959 {
15960 if (data.dictfile == NULL)
15961 {
15962 if (dictfiles != NULL)
15963 {
15964 data.dictfile = dictfiles[0];
15965
15966 hc_timer_set (&data.timer_running);
15967 }
15968 }
15969 }
15970 }
15971 // NOTE: combi is okay because it is already set beforehand
15972 else if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2)
15973 {
15974 if (data.dictfile == NULL)
15975 {
15976 if (dictfiles != NULL)
15977 {
15978 hc_timer_set (&data.timer_running);
15979
15980 data.dictfile = dictfiles[0];
15981 }
15982 }
15983 }
15984 else if (attack_mode == ATTACK_MODE_BF)
15985 {
15986 if (data.mask == NULL)
15987 {
15988 hc_timer_set (&data.timer_running);
15989
15990 data.mask = masks[0];
15991 }
15992 }
15993
15994 if ((data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
15995 {
15996 data.devices_status = STATUS_EXHAUSTED;
15997 }
15998
15999 // if cracked / aborted remove last induction dictionary
16000
16001 for (int file_pos = 0; file_pos < induction_dictionaries_cnt; file_pos++)
16002 {
16003 struct stat induct_stat;
16004
16005 if (stat (induction_dictionaries[file_pos], &induct_stat) == 0)
16006 {
16007 unlink (induction_dictionaries[file_pos]);
16008 }
16009 }
16010
16011 // wait for non-interactive threads
16012
16013 for (uint thread_idx = 0; thread_idx < ni_threads_cnt; thread_idx++)
16014 {
16015 hc_thread_wait (1, &ni_threads[thread_idx]);
16016 }
16017
16018 local_free (ni_threads);
16019
16020 // wait for interactive threads
16021
16022 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
16023 {
16024 hc_thread_wait (1, &i_thread);
16025 }
16026
16027 // we dont need restore file anymore
16028 if (data.restore_disable == 0)
16029 {
16030 if ((data.devices_status == STATUS_EXHAUSTED) || (data.devices_status == STATUS_CRACKED))
16031 {
16032 unlink (eff_restore_file);
16033 unlink (new_restore_file);
16034 }
16035 else
16036 {
16037 cycle_restore ();
16038 }
16039 }
16040
16041 // finally save left hashes
16042
16043 if ((hashlist_mode == HL_MODE_FILE) && (remove == 1) && (data.digests_saved != data.digests_done))
16044 {
16045 save_hash ();
16046 }
16047
16048 /**
16049 * Clean up
16050 */
16051
16052 if (benchmark == 1)
16053 {
16054 status_benchmark ();
16055
16056 log_info ("");
16057 }
16058 else
16059 {
16060 if (quiet == 0) clear_prompt ();
16061
16062 if (quiet == 0) log_info ("");
16063
16064 if (status == 1)
16065 {
16066 status_display ();
16067 }
16068 else
16069 {
16070 if (quiet == 0) status_display ();
16071 }
16072
16073 if (quiet == 0) log_info ("");
16074 }
16075
16076 for (uint device_id = 0; device_id < devices_cnt; device_id++)
16077 {
16078 hc_device_param_t *device_param = &data.devices_param[device_id];
16079
16080 local_free (device_param->result);
16081
16082 local_free (device_param->pw_caches);
16083
16084 local_free (device_param->combs_buf);
16085
16086 local_free (device_param->hooks_buf);
16087
16088 local_free (device_param->device_name);
16089
16090 local_free (device_param->device_version);
16091
16092 local_free (device_param->driver_version);
16093
16094 if (device_param->pws_buf) myfree (device_param->pws_buf);
16095 if (device_param->d_pws_buf) hc_clReleaseMemObject (device_param->d_pws_buf);
16096 if (device_param->d_pws_amp_buf) hc_clReleaseMemObject (device_param->d_pws_amp_buf);
16097 if (device_param->d_rules) hc_clReleaseMemObject (device_param->d_rules);
16098 if (device_param->d_rules_c) hc_clReleaseMemObject (device_param->d_rules_c);
16099 if (device_param->d_combs) hc_clReleaseMemObject (device_param->d_combs);
16100 if (device_param->d_combs_c) hc_clReleaseMemObject (device_param->d_combs_c);
16101 if (device_param->d_bfs) hc_clReleaseMemObject (device_param->d_bfs);
16102 if (device_param->d_bfs_c) hc_clReleaseMemObject (device_param->d_bfs_c);
16103 if (device_param->d_bitmap_s1_a) hc_clReleaseMemObject (device_param->d_bitmap_s1_a);
16104 if (device_param->d_bitmap_s1_b) hc_clReleaseMemObject (device_param->d_bitmap_s1_b);
16105 if (device_param->d_bitmap_s1_c) hc_clReleaseMemObject (device_param->d_bitmap_s1_c);
16106 if (device_param->d_bitmap_s1_d) hc_clReleaseMemObject (device_param->d_bitmap_s1_d);
16107 if (device_param->d_bitmap_s2_a) hc_clReleaseMemObject (device_param->d_bitmap_s2_a);
16108 if (device_param->d_bitmap_s2_b) hc_clReleaseMemObject (device_param->d_bitmap_s2_b);
16109 if (device_param->d_bitmap_s2_c) hc_clReleaseMemObject (device_param->d_bitmap_s2_c);
16110 if (device_param->d_bitmap_s2_d) hc_clReleaseMemObject (device_param->d_bitmap_s2_d);
16111 if (device_param->d_plain_bufs) hc_clReleaseMemObject (device_param->d_plain_bufs);
16112 if (device_param->d_digests_buf) hc_clReleaseMemObject (device_param->d_digests_buf);
16113 if (device_param->d_digests_shown) hc_clReleaseMemObject (device_param->d_digests_shown);
16114 if (device_param->d_salt_bufs) hc_clReleaseMemObject (device_param->d_salt_bufs);
16115 if (device_param->d_esalt_bufs) hc_clReleaseMemObject (device_param->d_esalt_bufs);
16116 if (device_param->d_tmps) hc_clReleaseMemObject (device_param->d_tmps);
16117 if (device_param->d_hooks) hc_clReleaseMemObject (device_param->d_hooks);
16118 if (device_param->d_result) hc_clReleaseMemObject (device_param->d_result);
16119 if (device_param->d_scryptV_buf) hc_clReleaseMemObject (device_param->d_scryptV_buf);
16120 if (device_param->d_root_css_buf) hc_clReleaseMemObject (device_param->d_root_css_buf);
16121 if (device_param->d_markov_css_buf) hc_clReleaseMemObject (device_param->d_markov_css_buf);
16122 if (device_param->d_tm_c) hc_clReleaseMemObject (device_param->d_tm_c);
16123
16124 if (device_param->kernel1) hc_clReleaseKernel (device_param->kernel1);
16125 if (device_param->kernel12) hc_clReleaseKernel (device_param->kernel12);
16126 if (device_param->kernel2) hc_clReleaseKernel (device_param->kernel2);
16127 if (device_param->kernel23) hc_clReleaseKernel (device_param->kernel23);
16128 if (device_param->kernel3) hc_clReleaseKernel (device_param->kernel3);
16129 if (device_param->kernel_mp) hc_clReleaseKernel (device_param->kernel_mp);
16130 if (device_param->kernel_mp_l) hc_clReleaseKernel (device_param->kernel_mp_l);
16131 if (device_param->kernel_mp_r) hc_clReleaseKernel (device_param->kernel_mp_r);
16132 if (device_param->kernel_tb) hc_clReleaseKernel (device_param->kernel_tb);
16133 if (device_param->kernel_tm) hc_clReleaseKernel (device_param->kernel_tm);
16134 if (device_param->kernel_amp) hc_clReleaseKernel (device_param->kernel_amp);
16135
16136 if (device_param->program) hc_clReleaseProgram (device_param->program);
16137 if (device_param->program_mp) hc_clReleaseProgram (device_param->program_mp);
16138 if (device_param->program_amp) hc_clReleaseProgram (device_param->program_amp);
16139 if (device_param->command_queue) hc_clReleaseCommandQueue (device_param->command_queue);
16140 if (device_param->context) hc_clReleaseContext (device_param->context);
16141 }
16142
16143 // reset default fan speed
16144
16145 if (gpu_temp_disable == 0)
16146 {
16147 if (gpu_temp_retain != 0) // VENDOR_ID_AMD is implied here
16148 {
16149 hc_thread_mutex_lock (mux_adl);
16150
16151 for (uint i = 0; i < data.devices_cnt; i++)
16152 {
16153 if (data.hm_device[i].fan_supported == 1)
16154 {
16155 int fanspeed = temp_retain_fanspeed_value[i];
16156
16157 if (fanspeed == -1) continue;
16158
16159 int rc = hm_set_fanspeed_with_device_id_amd (i, fanspeed);
16160
16161 if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", i);
16162 }
16163 }
16164
16165 hc_thread_mutex_unlock (mux_adl);
16166 }
16167 }
16168
16169 // reset power tuning
16170
16171 if (powertune_enable == 1) // VENDOR_ID_AMD is implied here
16172 {
16173 hc_thread_mutex_lock (mux_adl);
16174
16175 for (uint i = 0; i < data.devices_cnt; i++)
16176 {
16177 if (data.hm_device[i].od_version == 6)
16178 {
16179 // check powertune capabilities first, if not available then skip device
16180
16181 int powertune_supported = 0;
16182
16183 if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index.amd, &powertune_supported)) != ADL_OK)
16184 {
16185 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
16186
16187 return (-1);
16188 }
16189
16190 if (powertune_supported != 0)
16191 {
16192 // powercontrol settings
16193
16194 if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, od_power_control_status[i])) != ADL_OK)
16195 {
16196 log_info ("ERROR: Failed to restore the ADL PowerControl values");
16197
16198 return (-1);
16199 }
16200
16201 // clocks
16202
16203 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
16204
16205 performance_state->iNumberOfPerformanceLevels = 2;
16206
16207 performance_state->aLevels[0].iEngineClock = od_clock_mem_status[i].state.aLevels[0].iEngineClock;
16208 performance_state->aLevels[1].iEngineClock = od_clock_mem_status[i].state.aLevels[1].iEngineClock;
16209 performance_state->aLevels[0].iMemoryClock = od_clock_mem_status[i].state.aLevels[0].iMemoryClock;
16210 performance_state->aLevels[1].iMemoryClock = od_clock_mem_status[i].state.aLevels[1].iMemoryClock;
16211
16212 if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index.amd, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
16213 {
16214 log_info ("ERROR: Failed to restore ADL performance state");
16215
16216 return (-1);
16217 }
16218
16219 local_free (performance_state);
16220 }
16221 }
16222 }
16223
16224 hc_thread_mutex_unlock (mux_adl);
16225 }
16226
16227 if (gpu_temp_disable == 0)
16228 {
16229 if (vendor_id == VENDOR_ID_NV)
16230 {
16231 #ifdef LINUX
16232 hc_NVML_nvmlShutdown (data.hm_dll);
16233 #endif
16234
16235 #ifdef WIN
16236 NvAPI_Unload ();
16237 #endif
16238 }
16239
16240 if (vendor_id == VENDOR_ID_AMD)
16241 {
16242 hc_ADL_Main_Control_Destroy (data.hm_dll);
16243
16244 hm_close (data.hm_dll);
16245 }
16246
16247 #ifdef LINUX
16248 if (vendor_id == VENDOR_ID_NV)
16249 {
16250 hm_close (data.hm_dll);
16251 }
16252 #endif
16253 }
16254
16255 // free memory
16256
16257 local_free (masks);
16258
16259 local_free (dictstat_base);
16260
16261 for (uint pot_pos = 0; pot_pos < pot_cnt; pot_pos++)
16262 {
16263 pot_t *pot_ptr = &pot[pot_pos];
16264
16265 hash_t *hash = &pot_ptr->hash;
16266
16267 local_free (hash->digest);
16268
16269 if (isSalted)
16270 {
16271 local_free (hash->salt);
16272 }
16273 }
16274
16275 local_free (pot);
16276
16277 local_free (all_gpu_rules_cnt);
16278 local_free (all_gpu_rules_buf);
16279
16280 local_free (wl_data->buf);
16281 local_free (wl_data);
16282
16283 local_free (bitmap_s1_a);
16284 local_free (bitmap_s1_b);
16285 local_free (bitmap_s1_c);
16286 local_free (bitmap_s1_d);
16287 local_free (bitmap_s2_a);
16288 local_free (bitmap_s2_b);
16289 local_free (bitmap_s2_c);
16290 local_free (bitmap_s2_d);
16291
16292 local_free (temp_retain_fanspeed_value);
16293 local_free (od_clock_mem_status);
16294 local_free (od_power_control_status);
16295
16296 global_free (devices_param);
16297
16298 global_free (gpu_rules_buf);
16299
16300 global_free (root_css_buf);
16301 global_free (markov_css_buf);
16302
16303 global_free (digests_buf);
16304 global_free (digests_shown);
16305 global_free (digests_shown_tmp);
16306
16307 global_free (salts_buf);
16308 global_free (salts_shown);
16309
16310 global_free (esalts_buf);
16311
16312 global_free (words_progress_done);
16313 global_free (words_progress_rejected);
16314 global_free (words_progress_restored);
16315
16316 if (pot_fp) fclose (pot_fp);
16317
16318 if (data.devices_status == STATUS_QUIT) break;
16319 }
16320
16321 // destroy others mutex
16322
16323 hc_thread_mutex_delete (mux_dispatcher);
16324 hc_thread_mutex_delete (mux_counter);
16325 hc_thread_mutex_delete (mux_display);
16326 hc_thread_mutex_delete (mux_adl);
16327
16328 // free memory
16329
16330 local_free (eff_restore_file);
16331 local_free (new_restore_file);
16332
16333 local_free (rd);
16334
16335 // loopback
16336
16337 local_free (loopback_file);
16338
16339 if (loopback == 1) unlink (loopback_file);
16340
16341 // induction directory
16342
16343 if (induction_dir == NULL)
16344 {
16345 if (attack_mode != ATTACK_MODE_BF)
16346 {
16347 if (rmdir (induction_directory) == -1)
16348 {
16349 if (errno == ENOENT)
16350 {
16351 // good, we can ignore
16352 }
16353 else if (errno == ENOTEMPTY)
16354 {
16355 // good, we can ignore
16356 }
16357 else
16358 {
16359 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
16360
16361 return (-1);
16362 }
16363 }
16364
16365 local_free (induction_directory);
16366 }
16367 }
16368
16369 // outfile-check directory
16370
16371 if (outfile_check_dir == NULL)
16372 {
16373 if (rmdir (outfile_check_directory) == -1)
16374 {
16375 if (errno == ENOENT)
16376 {
16377 // good, we can ignore
16378 }
16379 else if (errno == ENOTEMPTY)
16380 {
16381 // good, we can ignore
16382 }
16383 else
16384 {
16385 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
16386
16387 return (-1);
16388 }
16389 }
16390
16391 local_free (outfile_check_directory);
16392 }
16393
16394 time_t proc_stop;
16395
16396 time (&proc_stop);
16397
16398 logfile_top_uint (proc_start);
16399 logfile_top_uint (proc_stop);
16400
16401 logfile_top_msg ("STOP");
16402
16403 if (quiet == 0) log_info_nn ("Started: %s", ctime (&proc_start));
16404 if (quiet == 0) log_info_nn ("Stopped: %s", ctime (&proc_stop));
16405
16406 if (data.devices_status == STATUS_ABORTED) return 2;
16407 if (data.devices_status == STATUS_QUIT) return 2;
16408 if (data.devices_status == STATUS_STOP_AT_CHECKPOINT) return 2;
16409 if (data.devices_status == STATUS_EXHAUSTED) return 1;
16410 if (data.devices_status == STATUS_CRACKED) return 0;
16411
16412 return -1;
16413 }