It's important to release a fixed version of v2.00 because of the issue #1 even if...
[hashcat.git] / src / oclHashcat.c
1 /**
2 * Author......: Jens Steube <jens.steube@gmail.com>
3 * License.....: MIT
4 */
5
6 #include <common.h>
7 #include <shared.h>
8 #include <rp_gpu_on_cpu.h>
9
10 #include <getopt.h>
11
12 #ifdef _CUDA
13 const char *PROGNAME = "cudaHashcat";
14 #elif _OCL
15 const char *PROGNAME = "oclHashcat";
16 #endif
17
18 const char *VERSION_TXT = "2.01";
19 const uint VERSION_BIN = 201;
20 const uint RESTORE_MIN = 200;
21
22 #define INCR_RULES 10000
23 #define INCR_SALTS 100000
24 #define INCR_MASKS 1000
25 #define INCR_POT 1000
26
27 // comment-out for kernel source mode
28
29 #define BINARY_KERNEL
30
31 #define USAGE 0
32 #define VERSION 0
33 #define QUIET 0
34 #define MARKOV_THRESHOLD 0
35 #define MARKOV_DISABLE 0
36 #define MARKOV_CLASSIC 0
37 #define BENCHMARK 0
38 #define BENCHMARK_MODE 1
39 #define RESTORE 0
40 #define RESTORE_TIMER 60
41 #define RESTORE_DISABLE 0
42 #define STATUS 0
43 #define STATUS_TIMER 10
44 #define STATUS_AUTOMAT 0
45 #define LOOPBACK 0
46 #define WEAK_HASH_THRESHOLD 100
47 #define SHOW 0
48 #define LEFT 0
49 #define USERNAME 0
50 #define REMOVE 0
51 #define REMOVE_TIMER 60
52 #define SKIP 0
53 #define LIMIT 0
54 #define KEYSPACE 0
55 #define POTFILE_DISABLE 0
56 #define DEBUG_MODE 0
57 #define RP_GEN 0
58 #define RP_GEN_FUNC_MIN 1
59 #define RP_GEN_FUNC_MAX 4
60 #define RP_GEN_SEED 0
61 #define RULE_BUF_L ":"
62 #define RULE_BUF_R ":"
63 #define FORCE 0
64 #define RUNTIME 0
65 #define HEX_CHARSET 0
66 #define HEX_SALT 0
67 #define HEX_WORDLIST 0
68 #define OUTFILE_FORMAT 3
69 #define OUTFILE_AUTOHEX 1
70 #define OUTFILE_CHECK_TIMER 5
71 #define ATTACK_MODE 0
72 #define HASH_MODE 0
73 #define SEGMENT_SIZE 32
74 #define INCREMENT 0
75 #define INCREMENT_MIN 1
76 #define INCREMENT_MAX PW_MAX
77 #define SEPARATOR ':'
78 #define BITMAP_MIN 16
79 #define BITMAP_MAX 24
80 #define GPU_ASYNC 0
81 #define GPU_TEMP_DISABLE 0
82 #define GPU_TEMP_ABORT 90
83 #define GPU_TEMP_RETAIN 80
84 #define WORKLOAD_PROFILE 2
85 #define GPU_ACCEL 0
86 #define GPU_LOOPS 0
87 #define GPU_RULES 1024
88 #define GPU_COMBS 1024
89 #define GPU_BFS 1024
90 #define GPU_THREADS_AMD 64
91 #define GPU_THREADS_NV 256
92 #define POWERTUNE_ENABLE 0
93 #define LOGFILE_DISABLE 0
94 #define SCRYPT_TMTO 0
95
96 #define VECT_SIZE_1 1
97 #define VECT_SIZE_2 2
98 #define VECT_SIZE_4 4
99 #define VECT_SIZE_8 8
100
101 #define WL_MODE_STDIN 1
102 #define WL_MODE_FILE 2
103 #define WL_MODE_MASK 3
104
105 #define HL_MODE_FILE 4
106 #define HL_MODE_ARG 5
107
108 #define HLFMT_HASHCAT 0
109 #define HLFMT_PWDUMP 1
110 #define HLFMT_PASSWD 2
111 #define HLFMT_SHADOW 3
112 #define HLFMT_DCC 4
113 #define HLFMT_DCC2 5
114 #define HLFMT_NETNTLM1 7
115 #define HLFMT_NETNTLM2 8
116 #define HLFMT_NSLDAP 9
117 #define HLFMT_NSLDAPS 10
118 #define HLFMTS_CNT 11
119
120 #define ATTACK_MODE_STRAIGHT 0
121 #define ATTACK_MODE_COMBI 1
122 #define ATTACK_MODE_TOGGLE 2
123 #define ATTACK_MODE_BF 3
124 #define ATTACK_MODE_PERM 4
125 #define ATTACK_MODE_TABLE 5
126 #define ATTACK_MODE_HYBRID1 6
127 #define ATTACK_MODE_HYBRID2 7
128 #define ATTACK_MODE_NONE 100
129
130 #define ATTACK_KERN_STRAIGHT 0
131 #define ATTACK_KERN_COMBI 1
132 #define ATTACK_KERN_BF 3
133 #define ATTACK_KERN_NONE 100
134
135 #define ATTACK_EXEC_ON_CPU 10
136 #define ATTACK_EXEC_ON_GPU 11
137
138 #define COMBINATOR_MODE_BASE_LEFT 10001
139 #define COMBINATOR_MODE_BASE_RIGHT 10002
140
141 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
142 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
143
144 #define MAX_CUT_TRIES 4
145
146 #define MAX_DICTSTAT 10000
147
148 #define NUM_DEFAULT_BENCHMARK_ALGORITHMS 128
149
150 #define global_free(attr) \
151 { \
152 myfree ((void *) data.attr); \
153 \
154 data.attr = NULL; \
155 }
156
157 #define local_free(attr) \
158 { \
159 myfree ((void *) attr); \
160 \
161 attr = NULL; \
162 }
163
164 static uint default_benchmark_algorithms[NUM_DEFAULT_BENCHMARK_ALGORITHMS] =
165 {
166 900,
167 0,
168 5100,
169 100,
170 1400,
171 10800,
172 1700,
173 5000,
174 10100,
175 6000,
176 6100,
177 6900,
178 11700,
179 11800,
180 400,
181 8900,
182 11900,
183 12000,
184 10900,
185 12100,
186 23,
187 2500,
188 5300,
189 5400,
190 5500,
191 5600,
192 7300,
193 7500,
194 8300,
195 11100,
196 11200,
197 11400,
198 121,
199 2611,
200 2711,
201 2811,
202 8400,
203 11,
204 2612,
205 7900,
206 21,
207 11000,
208 124,
209 10000,
210 3711,
211 7600,
212 12,
213 131,
214 132,
215 1731,
216 200,
217 300,
218 3100,
219 112,
220 12300,
221 8000,
222 141,
223 1441,
224 1600,
225 12600,
226 1421,
227 101,
228 111,
229 1711,
230 3000,
231 1000,
232 1100,
233 2100,
234 12800,
235 1500,
236 12400,
237 500,
238 3200,
239 7400,
240 1800,
241 122,
242 1722,
243 7100,
244 6300,
245 6700,
246 6400,
247 6500,
248 2400,
249 2410,
250 5700,
251 9200,
252 9300,
253 22,
254 501,
255 5800,
256 8100,
257 8500,
258 7200,
259 9900,
260 7700,
261 7800,
262 10300,
263 8600,
264 8700,
265 9100,
266 133,
267 11600,
268 12500,
269 6211,
270 6221,
271 6231,
272 6241,
273 8800,
274 12200,
275 9700,
276 9710,
277 9800,
278 9810,
279 9400,
280 9500,
281 9600,
282 10400,
283 10410,
284 10500,
285 10600,
286 10700,
287 9000,
288 5200,
289 6800,
290 6600,
291 8200,
292 11300,
293 12700
294 };
295
296 /**
297 * types
298 */
299
300 static void (*get_next_word_func) (char *, uint32_t, uint32_t *, uint32_t *);
301
302 /**
303 * globals
304 */
305
306 static unsigned int full01 = 0x01010101;
307 static unsigned int full80 = 0x80808080;
308
309 int SUPPRESS_OUTPUT = 0;
310
311 hc_thread_mutex_t mux_adl;
312 hc_thread_mutex_t mux_counter;
313 hc_thread_mutex_t mux_dispatcher;
314 hc_thread_mutex_t mux_display;
315
316 hc_global_data_t data;
317
318 const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [q]uit => ";
319
320 const char *USAGE_MINI[] =
321 {
322 "Usage: %s [options]... hash|hashfile|hccapfile [dictionary|mask|directory]...",
323 "",
324 "Try --help for more help.",
325 NULL
326 };
327
328 const char *USAGE_BIG[] =
329 {
330 "%s, advanced password recovery",
331 "",
332 "Usage: %s [options]... hash|hashfile|hccapfile [dictionary|mask|directory]...",
333 "",
334 "=======",
335 "Options",
336 "=======",
337 "",
338 "* General:",
339 "",
340 " -m, --hash-type=NUM Hash-type, see references below",
341 " -a, --attack-mode=NUM Attack-mode, see references below",
342 " -V, --version Print version",
343 " -h, --help Print help",
344 " --quiet Suppress output",
345 "",
346 "* Benchmark:",
347 "",
348 " -b, --benchmark Run benchmark",
349 " --benchmark-mode=NUM Benchmark-mode, see references below",
350 "",
351 "* Misc:",
352 "",
353 " --hex-charset Assume charset is given in hex",
354 " --hex-salt Assume salt is given in hex",
355 " --hex-wordlist Assume words in wordlist is given in hex",
356 " --force Ignore warnings",
357 " --status Enable automatic update of the status-screen",
358 " --status-timer=NUM Seconds between status-screen update",
359 " --status-automat Display the status view in a machine readable format",
360 " --loopback Add new plains to induct directory",
361 " --weak-hash-threshold=NUM Threshold when to stop checking for weak hashes, default is 100 salts",
362 "",
363 "* Markov:",
364 "",
365 " --markov-hcstat=FILE Specify hcstat file to use, default is hashcat.hcstat",
366 " --markov-disable Disables markov-chains, emulates classic brute-force",
367 " --markov-classic Enables classic markov-chains, no per-position enhancement",
368 " -t, --markov-threshold=NUM Threshold when to stop accepting new markov-chains",
369 "",
370 "* Session:",
371 "",
372 " --runtime=NUM Abort session after NUM seconds of runtime",
373 " --session=STR Define specific session name",
374 " --restore Restore session from --session",
375 " --restore-disable Do not write restore file",
376 "",
377 "* Files:",
378 "",
379 " -o, --outfile=FILE Define outfile for recovered hash",
380 " --outfile-format=NUM Define outfile-format for recovered hash, see references below",
381 " --outfile-autohex-disable Disable the use of $HEX[] in output plains",
382 " --outfile-check-timer=NUM Seconds between outfile checks",
383 " -p, --separator=CHAR Separator char for hashlists and outfile",
384 " --show Show cracked passwords only",
385 " --left Show un-cracked passwords only",
386 " --username Enable ignoring of usernames in hashfile (recommended: also use --show)",
387 " --remove Enable remove of hash once it is cracked",
388 " --remove-timer=NUM Update input hash file each NUM seconds",
389 " --potfile-disable Do not write potfile",
390 " --debug-mode=NUM Defines the debug mode (hybrid only by using rules), see references below",
391 " --debug-file=FILE Output file for debugging rules (see also --debug-mode)",
392 " --induction-dir=FOLDER Specify induction directory to use, default is $session.induct",
393 " --outfile-check-dir=FOLDER Specify the outfile directory which should be monitored, default is $session.outfiles",
394 " --logfile-disable Disable the logfile",
395 " --truecrypt-keyfiles=FILE Keyfiles used, seperate with comma",
396 "",
397 "* Resources:",
398 "",
399 " -c, --segment-size=NUM Size in MB to cache from the wordfile",
400 " --bitmap-min=NUM Minimum number of bits allowed for bitmaps",
401 " --bitmap-max=NUM Maximum number of bits allowed for bitmaps",
402 " --cpu-affinity=STR Locks to CPU devices, seperate with comma",
403 " --gpu-async Use non-blocking async calls (NV only)",
404 " -d, --gpu-devices=STR Devices to use, separate with comma",
405 " -w, --workload-profile=NUM Enable a specific workload profile, see references below",
406 " -n, --gpu-accel=NUM Workload tuning: 1, 8, 40, 80, 160",
407 " -u, --gpu-loops=NUM Workload fine-tuning: 8 - 1024",
408 " --gpu-temp-disable Disable temperature and fanspeed readings and triggers",
409 " --gpu-temp-abort=NUM Abort session if GPU temperature reaches NUM degrees celsius",
410 " --gpu-temp-retain=NUM Try to retain GPU temperature at NUM degrees celsius (AMD only)",
411 " --powertune-enable Enable automatic power tuning option (AMD OverDrive 6 only)",
412 " --scrypt-tmto=NUM Manually override automatically calculated TMTO value for scrypt",
413 "",
414 "* Distributed:",
415 "",
416 " -s, --skip=NUM Skip number of words",
417 " -l, --limit=NUM Limit number of words",
418 " --keyspace Show keyspace base:mod values and quit",
419 "",
420 "* Rules:",
421 "",
422 " -j, --rule-left=RULE Single rule applied to each word from left dict",
423 " -k, --rule-right=RULE Single rule applied to each word from right dict",
424 " -r, --rules-file=FILE Rules-file, multi use: -r 1.rule -r 2.rule",
425 " -g, --generate-rules=NUM Generate NUM random rules",
426 " --generate-rules-func-min=NUM Force NUM functions per random rule min",
427 " --generate-rules-func-max=NUM Force NUM functions per random rule max",
428 " --generate-rules-seed=NUM Force RNG seed to NUM",
429 "",
430 "* Custom charsets:",
431 "",
432 " -1, --custom-charset1=CS User-defined charsets",
433 " -2, --custom-charset2=CS Example:",
434 " -3, --custom-charset3=CS --custom-charset1=?dabcdef : sets charset ?1 to 0123456789abcdef",
435 " -4, --custom-charset4=CS -2 mycharset.hcchr : sets charset ?2 to chars contained in file",
436 "",
437 "* Increment:",
438 "",
439 " -i, --increment Enable increment mode",
440 " --increment-min=NUM Start incrementing at NUM",
441 " --increment-max=NUM Stop incrementing at NUM",
442 "",
443 "==========",
444 "References",
445 "==========",
446 "",
447 "* Workload Profile:",
448 "",
449 " 1 = Reduced performance profile (low latency desktop)",
450 " 2 = Default performance profile",
451 " 3 = Tuned performance profile (high latency desktop)",
452 "",
453 "* Benchmark Settings:",
454 "",
455 " 0 = Manual Tuning",
456 " 1 = Performance Tuning, default",
457 "",
458 "* Outfile Formats:",
459 "",
460 " 1 = hash[:salt]",
461 " 2 = plain",
462 " 3 = hash[:salt]:plain",
463 " 4 = hex_plain",
464 " 5 = hash[:salt]:hex_plain",
465 " 6 = plain:hex_plain",
466 " 7 = hash[:salt]:plain:hex_plain",
467 " 8 = crackpos",
468 " 9 = hash[:salt]:crackpos",
469 " 10 = plain:crackpos",
470 " 11 = hash[:salt]:plain:crackpos",
471 " 12 = hex_plain:crackpos",
472 " 13 = hash[:salt]:hex_plain:crackpos",
473 " 14 = plain:hex_plain:crackpos",
474 " 15 = hash[:salt]:plain:hex_plain:crackpos",
475 "",
476 "* Debug mode output formats (for hybrid mode only, by using rules):",
477 "",
478 " 1 = save finding rule",
479 " 2 = save original word",
480 " 3 = save original word and finding rule",
481 " 4 = save original word, finding rule and modified plain",
482 "",
483 "* Built-in charsets:",
484 "",
485 " ?l = abcdefghijklmnopqrstuvwxyz",
486 " ?u = ABCDEFGHIJKLMNOPQRSTUVWXYZ",
487 " ?d = 0123456789",
488 " ?s = !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
489 " ?a = ?l?u?d?s",
490 " ?b = 0x00 - 0xff",
491 "",
492 "* Attack modes:",
493 "",
494 " 0 = Straight",
495 " 1 = Combination",
496 " 3 = Brute-force",
497 " 6 = Hybrid dict + mask",
498 " 7 = Hybrid mask + dict",
499 "",
500 "* Hash types:",
501 "",
502 "[[ Roll-your-own: Raw Hashes ]]",
503 "",
504 " 900 = MD4",
505 " 0 = MD5",
506 " 5100 = Half MD5",
507 " 100 = SHA1",
508 " 10800 = SHA-384",
509 " 1400 = SHA-256",
510 " 1700 = SHA-512",
511 " 5000 = SHA-3(Keccak)",
512 " 10100 = SipHash",
513 " 6000 = RipeMD160",
514 " 6100 = Whirlpool",
515 " 6900 = GOST R 34.11-94",
516 " 11700 = GOST R 34.11-2012 (Streebog) 256-bit",
517 " 11800 = GOST R 34.11-2012 (Streebog) 512-bit",
518 "",
519 "[[ Roll-your-own: Iterated and / or Salted Hashes ]]",
520 "",
521 " 10 = md5($pass.$salt)",
522 " 20 = md5($salt.$pass)",
523 " 30 = md5(unicode($pass).$salt)",
524 " 40 = md5($salt.unicode($pass))",
525 " 3800 = md5($salt.$pass.$salt)",
526 " 3710 = md5($salt.md5($pass))",
527 " 2600 = md5(md5($pass)",
528 " 4300 = md5(strtoupper(md5($pass)))",
529 " 4400 = md5(sha1($pass))",
530 " 110 = sha1($pass.$salt)",
531 " 120 = sha1($salt.$pass)",
532 " 130 = sha1(unicode($pass).$salt)",
533 " 140 = sha1($salt.unicode($pass))",
534 " 4500 = sha1(sha1($pass)",
535 " 4700 = sha1(md5($pass))",
536 " 4900 = sha1($salt.$pass.$salt)",
537 " 1410 = sha256($pass.$salt)",
538 " 1420 = sha256($salt.$pass)",
539 " 1430 = sha256(unicode($pass).$salt)",
540 " 1440 = sha256($salt.unicode($pass))",
541 " 1710 = sha512($pass.$salt)",
542 " 1720 = sha512($salt.$pass)",
543 " 1730 = sha512(unicode($pass).$salt)",
544 " 1740 = sha512($salt.unicode($pass))",
545 "",
546 "[[ Roll-your-own: Authenticated Hashes ]]",
547 "",
548 " 50 = HMAC-MD5 (key = $pass)",
549 " 60 = HMAC-MD5 (key = $salt)",
550 " 150 = HMAC-SHA1 (key = $pass)",
551 " 160 = HMAC-SHA1 (key = $salt)",
552 " 1450 = HMAC-SHA256 (key = $pass)",
553 " 1460 = HMAC-SHA256 (key = $salt)",
554 " 1750 = HMAC-SHA512 (key = $pass)",
555 " 1760 = HMAC-SHA512 (key = $salt)",
556 "",
557 "[[ Generic KDF ]]",
558 "",
559 " 400 = phpass",
560 " 8900 = scrypt",
561 " 11900 = PBKDF2-HMAC-MD5",
562 " 12000 = PBKDF2-HMAC-SHA1",
563 " 10900 = PBKDF2-HMAC-SHA256",
564 " 12100 = PBKDF2-HMAC-SHA512",
565 "",
566 "[[ Network protocols, Challenge-Response ]]",
567 "",
568 " 23 = Skype",
569 " 2500 = WPA/WPA2",
570 " 4800 = iSCSI CHAP authentication, MD5(Chap)",
571 " 5300 = IKE-PSK MD5",
572 " 5400 = IKE-PSK SHA1",
573 " 5500 = NetNTLMv1",
574 " 5500 = NetNTLMv1 + ESS",
575 " 5600 = NetNTLMv2",
576 " 7300 = IPMI2 RAKP HMAC-SHA1",
577 " 7500 = Kerberos 5 AS-REQ Pre-Auth etype 23",
578 " 8300 = DNSSEC (NSEC3)",
579 " 10200 = Cram MD5",
580 " 11100 = PostgreSQL Challenge-Response Authentication (MD5)",
581 " 11200 = MySQL Challenge-Response Authentication (SHA1)",
582 " 11400 = SIP digest authentication (MD5)",
583 "",
584 "[[ Forums, CMS, E-Commerce, Frameworks, Middleware, Wiki, Management ]]",
585 "",
586 " 121 = SMF (Simple Machines Forum)",
587 " 400 = phpBB3",
588 " 2611 = vBulletin < v3.8.5",
589 " 2711 = vBulletin > v3.8.5",
590 " 2811 = MyBB",
591 " 2811 = IPB (Invison Power Board)",
592 " 8400 = WBB3 (Woltlab Burning Board)",
593 " 11 = Joomla < 2.5.18",
594 " 400 = Joomla > 2.5.18",
595 " 400 = Wordpress",
596 " 2612 = PHPS",
597 " 7900 = Drupal7",
598 " 21 = osCommerce",
599 " 21 = xt:Commerce",
600 " 11000 = PrestaShop",
601 " 124 = Django (SHA-1)",
602 " 10000 = Django (PBKDF2-SHA256)",
603 " 3711 = Mediawiki B type",
604 " 7600 = Redmine",
605 "",
606 "[[ Database Server ]]",
607 "",
608 " 12 = PostgreSQL",
609 " 131 = MSSQL(2000)",
610 " 132 = MSSQL(2005)",
611 " 1731 = MSSQL(2012)",
612 " 1731 = MSSQL(2014)",
613 " 200 = MySQL323",
614 " 300 = MySQL4.1/MySQL5",
615 " 3100 = Oracle H: Type (Oracle 7+)",
616 " 112 = Oracle S: Type (Oracle 11+)",
617 " 12300 = Oracle T: Type (Oracle 12+)",
618 " 8000 = Sybase ASE",
619 "",
620 "[[ HTTP, SMTP, LDAP Server]]",
621 "",
622 " 141 = EPiServer 6.x < v4",
623 " 1441 = EPiServer 6.x > v4",
624 " 1600 = Apache $apr1$",
625 " 12600 = ColdFusion 10+",
626 " 1421 = hMailServer",
627 " 101 = nsldap, SHA-1(Base64), Netscape LDAP SHA",
628 " 111 = nsldaps, SSHA-1(Base64), Netscape LDAP SSHA",
629 " 1711 = SSHA-512(Base64), LDAP {SSHA512}",
630 "",
631 "[[ Checksums ]]",
632 "",
633 " 11500 = CRC32",
634 "",
635 "[[ Operating-Systems ]]",
636 "",
637 " 3000 = LM",
638 " 1000 = NTLM",
639 " 1100 = Domain Cached Credentials (DCC), MS Cache",
640 " 2100 = Domain Cached Credentials 2 (DCC2), MS Cache 2",
641 " 12800 = MS-AzureSync PBKDF2-HMAC-SHA256",
642 " 1500 = descrypt, DES(Unix), Traditional DES",
643 " 12400 = BSDiCrypt, Extended DES",
644 " 500 = md5crypt $1$, MD5(Unix)",
645 " 3200 = bcrypt $2*$, Blowfish(Unix)",
646 " 7400 = sha256crypt $5$, SHA256(Unix)",
647 " 1800 = sha512crypt $6$, SHA512(Unix)",
648 " 122 = OSX v10.4",
649 " 122 = OSX v10.5",
650 " 122 = OSX v10.6",
651 " 1722 = OSX v10.7",
652 " 7100 = OSX v10.8",
653 " 7100 = OSX v10.9",
654 " 7100 = OSX v10.10",
655 " 6300 = AIX {smd5}",
656 " 6700 = AIX {ssha1}",
657 " 6400 = AIX {ssha256}",
658 " 6500 = AIX {ssha512}",
659 " 2400 = Cisco-PIX",
660 " 2410 = Cisco-ASA",
661 " 500 = Cisco-IOS $1$",
662 " 5700 = Cisco-IOS $4$",
663 " 9200 = Cisco-IOS $8$",
664 " 9300 = Cisco-IOS $9$",
665 " 22 = Juniper Netscreen/SSG (ScreenOS)",
666 " 501 = Juniper IVE",
667 " 5800 = Android PIN",
668 " 8100 = Citrix Netscaler",
669 " 8500 = RACF",
670 " 7200 = GRUB 2",
671 " 9900 = Radmin2",
672 "",
673 "[[ Enterprise Application Software (EAS) ]]",
674 "",
675 " 7700 = SAP CODVN B (BCODE)",
676 " 7800 = SAP CODVN F/G (PASSCODE)",
677 " 10300 = SAP CODVN H (PWDSALTEDHASH) iSSHA-1",
678 " 8600 = Lotus Notes/Domino 5",
679 " 8700 = Lotus Notes/Domino 6",
680 " 9100 = Lotus Notes/Domino 8",
681 " 133 = PeopleSoft",
682 "",
683 "[[ Archives ]]",
684 "",
685 " 11600 = 7-Zip",
686 " 12500 = RAR3-hp",
687 "",
688 "[[ Full-Disk encryptions (FDE) ]]",
689 "",
690 " 62XY = TrueCrypt 5.0+",
691 " X = 1 = PBKDF2-HMAC-RipeMD160",
692 " X = 2 = PBKDF2-HMAC-SHA512",
693 " X = 3 = PBKDF2-HMAC-Whirlpool",
694 " X = 4 = PBKDF2-HMAC-RipeMD160 + boot-mode",
695 " Y = 1 = XTS 512 bit (Ciphers: AES or Serpent or Twofish)",
696 " Y = 2 = XTS 1024 bit (Ciphers: AES or Serpent or Twofish or AES-Twofish or Serpent-AES or Twofish-Serpent)",
697 " Y = 3 = XTS 1536 bit (Ciphers: All)",
698 " 8800 = Android FDE < v4.3",
699 " 12200 = eCryptfs",
700 "",
701 "[[ Documents ]]",
702 "",
703 " 9700 = MS Office <= 2003 MD5 + RC4, oldoffice$0, oldoffice$1",
704 " 9710 = MS Office <= 2003 MD5 + RC4, collider-mode #1",
705 " 9720 = MS Office <= 2003 MD5 + RC4, collider-mode #2",
706 " 9800 = MS Office <= 2003 SHA1 + RC4, oldoffice$3, oldoffice$4",
707 " 9810 = MS Office <= 2003 SHA1 + RC4, collider-mode #1",
708 " 9820 = MS Office <= 2003 SHA1 + RC4, collider-mode #2",
709 " 9400 = MS Office 2007",
710 " 9500 = MS Office 2010",
711 " 9600 = MS Office 2013",
712 " 10400 = PDF 1.1 - 1.3 (Acrobat 2 - 4)",
713 " 10410 = PDF 1.1 - 1.3 (Acrobat 2 - 4) + collider-mode #1",
714 " 10420 = PDF 1.1 - 1.3 (Acrobat 2 - 4) + collider-mode #2",
715 " 10500 = PDF 1.4 - 1.6 (Acrobat 5 - 8)",
716 " 10600 = PDF 1.7 Level 3 (Acrobat 9)",
717 " 10700 = PDF 1.7 Level 8 (Acrobat 10 - 11)",
718 "",
719 "[[ Password Managers ]]",
720 "",
721 " 9000 = Password Safe v2",
722 " 5200 = Password Safe v3",
723 " 6800 = Lastpass",
724 " 6600 = 1Password, agilekeychain",
725 " 8200 = 1Password, cloudkeychain",
726 " 11300 = Bitcoin/Litecoin wallet.dat",
727 " 12700 = Blockchain, My Wallet",
728 "",
729 NULL
730 };
731
732 /**
733 * oclHashcat specific functions
734 */
735
736 void status_display_automat ()
737 {
738 FILE *out = stdout;
739
740 fprintf (out, "STATUS\t%u\t", data.devices_status);
741
742 /**
743 * speed new
744 */
745
746 fprintf (out, "SPEED\t");
747
748 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
749 {
750 hc_device_param_t *device_param = &data.devices_param[device_id];
751
752 uint64_t speed_cnt = 0;
753 float speed_ms = 0;
754
755 for (int i = 0; i < SPEED_CACHE; i++)
756 {
757 float rec_ms;
758
759 hc_timer_get (device_param->speed_rec[i], rec_ms);
760
761 if (rec_ms > SPEED_MAXAGE) continue;
762
763 speed_cnt += device_param->speed_cnt[i];
764 speed_ms += device_param->speed_ms[i];
765 }
766
767 speed_cnt /= SPEED_CACHE;
768 speed_ms /= SPEED_CACHE;
769
770 fprintf (out, "%llu\t%f\t", (unsigned long long int) speed_cnt, speed_ms);
771 }
772
773 /**
774 * words_cur
775 */
776
777 uint64_t words_cur = get_lowest_words_done ();
778
779 fprintf (out, "CURKU\t%llu\t", (unsigned long long int) words_cur);
780
781 /**
782 * counter
783 */
784
785 uint salts_left = data.salts_cnt - data.salts_done;
786
787 if (salts_left == 0) salts_left = 1;
788
789 uint64_t progress_total = data.words_cnt * salts_left;
790
791 uint64_t all_done = 0;
792 uint64_t all_rejected = 0;
793 uint64_t all_restored = 0;
794
795 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
796 {
797 if (salts_left > 1)
798 {
799 // otherwise the final cracked status shows 0/XXX progress
800
801 if (data.salts_shown[salt_pos] == 1) continue;
802 }
803
804 all_done += data.words_progress_done[salt_pos];
805 all_rejected += data.words_progress_rejected[salt_pos];
806 all_restored += data.words_progress_restored[salt_pos];
807 }
808
809 uint64_t progress_cur = all_restored + all_done + all_rejected;
810 uint64_t progress_end = progress_total;
811
812 uint64_t progress_skip = 0;
813
814 if (data.skip)
815 {
816 progress_skip = MIN (data.skip, data.words_base) * salts_left;
817
818 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.gpu_rules_cnt;
819 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt;
820 else if (data.attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt;
821 }
822
823 if (data.limit)
824 {
825 progress_end = MIN (data.limit, data.words_base) * salts_left;
826
827 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.gpu_rules_cnt;
828 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt;
829 else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
830 }
831
832 uint64_t progress_cur_relative_skip = progress_cur - progress_skip;
833 uint64_t progress_end_relative_skip = progress_end - progress_skip;
834
835 fprintf (out, "PROGRESS\t%llu\t%llu\t", (unsigned long long int) progress_cur_relative_skip, (unsigned long long int) progress_end_relative_skip);
836
837 /**
838 * cracks
839 */
840
841 fprintf (out, "RECHASH\t%u\t%u\t", data.digests_done, data.digests_cnt);
842 fprintf (out, "RECSALT\t%u\t%u\t", data.salts_done, data.salts_cnt);
843
844 /**
845 * temperature
846 */
847
848 if (data.gpu_temp_disable == 0)
849 {
850 fprintf (out, "TEMP\t");
851
852 hc_thread_mutex_lock (mux_adl);
853
854 for (uint i = 0; i < data.devices_cnt; i++)
855 {
856 int temp = hm_get_temperature_with_device_id (i);
857
858 fprintf (out, "%d\t", temp);
859 }
860
861 hc_thread_mutex_unlock (mux_adl);
862 }
863
864 #ifdef _WIN
865 fputc ('\r', out);
866 fputc ('\n', out);
867 #endif
868
869 #ifdef _POSIX
870 fputc ('\n', out);
871 #endif
872
873 fflush (out);
874 }
875
876 void status_display ()
877 {
878 if (data.devices_status == STATUS_INIT) return;
879 if (data.devices_status == STATUS_STARTING) return;
880 if (data.devices_status == STATUS_BYPASS) return;
881
882 if (data.status_automat == 1)
883 {
884 status_display_automat ();
885
886 return;
887 }
888
889 char tmp_buf[1000];
890
891 uint tmp_len = 0;
892
893 log_info ("Session.Name...: %s", data.session);
894
895 char *status_type = strstatus (data.devices_status);
896
897 uint hash_mode = data.hash_mode;
898
899 char *hash_type = strhashtype (hash_mode); // not a bug
900
901 log_info ("Status.........: %s", status_type);
902
903 /**
904 * show rules
905 */
906
907 if (data.rp_files_cnt)
908 {
909 uint i;
910
911 for (i = 0, tmp_len = 0; i < data.rp_files_cnt - 1 && tmp_len < sizeof (tmp_buf); i++)
912 {
913 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s), ", data.rp_files[i]);
914 }
915
916 snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", data.rp_files[i]);
917
918 log_info ("Rules.Type.....: %s", tmp_buf);
919
920 tmp_len = 0;
921 }
922
923 if (data.rp_gen)
924 {
925 log_info ("Rules.Type.....: Generated (%u)", data.rp_gen);
926
927 if (data.rp_gen_seed)
928 {
929 log_info ("Rules.Seed.....: %u", data.rp_gen_seed);
930 }
931 }
932
933 /**
934 * show input
935 */
936
937 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
938 {
939 if (data.wordlist_mode == WL_MODE_FILE)
940 {
941 if (data.dictfile != NULL) log_info ("Input.Mode.....: File (%s)", data.dictfile);
942 }
943 else if (data.wordlist_mode == WL_MODE_STDIN)
944 {
945 log_info ("Input.Mode.....: Pipe");
946 }
947 }
948 else if (data.attack_mode == ATTACK_MODE_COMBI)
949 {
950 if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
951 if (data.dictfile2 != NULL) log_info ("Input.Right....: File (%s)", data.dictfile2);
952 }
953 else if (data.attack_mode == ATTACK_MODE_BF)
954 {
955 char *mask = data.mask;
956
957 if (mask != NULL)
958 {
959 uint mask_len = data.css_cnt;
960
961 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "Mask (%s)", mask);
962
963 if (mask_len > 0)
964 {
965 if (data.opti_type & OPTI_TYPE_SINGLE_HASH)
966 {
967 if (data.opti_type & OPTI_TYPE_APPENDED_SALT)
968 {
969 mask_len -= data.salts_buf[0].salt_len;
970 }
971 }
972
973 if (data.opts_type & OPTS_TYPE_PT_UNICODE) mask_len /= 2;
974
975 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " [%i]", mask_len);
976 }
977
978 if (data.maskcnt > 1)
979 {
980 float mask_percentage = (float) data.maskpos / (float) data.maskcnt;
981
982 tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100);
983 }
984
985 log_info ("Input.Mode.....: %s", tmp_buf);
986 }
987
988 tmp_len = 0;
989 }
990 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
991 {
992 if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
993 if (data.mask != NULL) log_info ("Input.Right....: Mask (%s) [%i]", data.mask, data.css_cnt);
994 }
995 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
996 {
997 if (data.mask != NULL) log_info ("Input.Left.....: Mask (%s) [%i]", data.mask, data.css_cnt);
998 if (data.dictfile != NULL) log_info ("Input.Right....: File (%s)", data.dictfile);
999 }
1000
1001 if (data.digests_cnt == 1)
1002 {
1003 if (data.hash_mode == 2500)
1004 {
1005 wpa_t *wpa = (wpa_t *) data.esalts_buf;
1006
1007 uint pke[25];
1008
1009 char *pke_ptr = (char *) pke;
1010
1011 for (uint i = 0; i < 25; i++)
1012 {
1013 pke[i] = byte_swap_32 (wpa->pke[i]);
1014 }
1015
1016 char mac1[6];
1017 char mac2[6];
1018
1019 memcpy (mac1, pke_ptr + 23, 6);
1020 memcpy (mac2, pke_ptr + 29, 6);
1021
1022 log_info ("Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)",
1023 (char *) data.salts_buf[0].salt_buf,
1024 mac1[0] & 0xff,
1025 mac1[1] & 0xff,
1026 mac1[2] & 0xff,
1027 mac1[3] & 0xff,
1028 mac1[4] & 0xff,
1029 mac1[5] & 0xff,
1030 mac2[0] & 0xff,
1031 mac2[1] & 0xff,
1032 mac2[2] & 0xff,
1033 mac2[3] & 0xff,
1034 mac2[4] & 0xff,
1035 mac2[5] & 0xff);
1036 }
1037 else if (data.hash_mode == 5200)
1038 {
1039 log_info ("Hash.Target....: File (%s)", data.hashfile);
1040 }
1041 else if (data.hash_mode == 9000)
1042 {
1043 log_info ("Hash.Target....: File (%s)", data.hashfile);
1044 }
1045 else if ((data.hash_mode >= 6200) && (data.hash_mode <= 6299))
1046 {
1047 log_info ("Hash.Target....: File (%s)", data.hashfile);
1048 }
1049 else
1050 {
1051 char out_buf[4096];
1052
1053 ascii_digest (out_buf, 0, 0);
1054
1055 // limit length
1056 if (strlen (out_buf) > 40)
1057 {
1058 out_buf[41] = '.';
1059 out_buf[42] = '.';
1060 out_buf[43] = '.';
1061 out_buf[44] = 0;
1062 }
1063
1064 log_info ("Hash.Target....: %s", out_buf);
1065 }
1066 }
1067 else
1068 {
1069 if (data.hash_mode == 3000)
1070 {
1071 char out_buf1[4096];
1072 char out_buf2[4096];
1073
1074 ascii_digest (out_buf1, 0, 0);
1075 ascii_digest (out_buf2, 0, 1);
1076
1077 log_info ("Hash.Target....: %s, %s", out_buf1, out_buf2);
1078 }
1079 else
1080 {
1081 log_info ("Hash.Target....: File (%s)", data.hashfile);
1082 }
1083 }
1084
1085 log_info ("Hash.Type......: %s", hash_type);
1086
1087 /**
1088 * speed new
1089 */
1090
1091 uint64_t speed_cnt[DEVICES_MAX];
1092 float speed_ms[DEVICES_MAX];
1093
1094 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1095 {
1096 hc_device_param_t *device_param = &data.devices_param[device_id];
1097
1098 // we need to clear values (set to 0) because in case the gpu does
1099 // not get new candidates it idles around but speed display would
1100 // show it as working.
1101 // if we instantly set it to 0 after reading it happens that the
1102 // speed can be shown as zero if the users refreshs to fast.
1103 // therefore, we add a timestamp when a stat was recorded and if its
1104 // to old we will not use it
1105
1106 speed_cnt[device_id] = 0;
1107 speed_ms[device_id] = 0;
1108
1109 for (int i = 0; i < SPEED_CACHE; i++)
1110 {
1111 float rec_ms;
1112
1113 hc_timer_get (device_param->speed_rec[i], rec_ms);
1114
1115 if (rec_ms > SPEED_MAXAGE) continue;
1116
1117 speed_cnt[device_id] += device_param->speed_cnt[i];
1118 speed_ms[device_id] += device_param->speed_ms[i];
1119 }
1120
1121 speed_cnt[device_id] /= SPEED_CACHE;
1122 speed_ms[device_id] /= SPEED_CACHE;
1123 }
1124
1125 float hashes_all_ms = 0;
1126
1127 float hashes_dev_ms[DEVICES_MAX];
1128
1129 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1130 {
1131 hashes_dev_ms[device_id] = 0;
1132
1133 if (speed_ms[device_id])
1134 {
1135 hashes_dev_ms[device_id] = speed_cnt[device_id] / speed_ms[device_id];
1136
1137 hashes_all_ms += hashes_dev_ms[device_id];
1138 }
1139 }
1140
1141 /**
1142 * timers
1143 */
1144
1145 float ms_running = 0;
1146
1147 hc_timer_get (data.timer_running, ms_running);
1148
1149 float ms_paused = data.ms_paused;
1150
1151 if (data.devices_status == STATUS_PAUSED)
1152 {
1153 float ms_paused_tmp = 0;
1154
1155 hc_timer_get (data.timer_paused, ms_paused_tmp);
1156
1157 ms_paused += ms_paused_tmp;
1158 }
1159
1160 #ifdef WIN
1161
1162 __time64_t sec_run = ms_running / 1000;
1163
1164 #else
1165
1166 time_t sec_run = ms_running / 1000;
1167
1168 #endif
1169
1170 if (sec_run)
1171 {
1172 char display_run[32];
1173
1174 struct tm tm_run;
1175
1176 struct tm *tmp;
1177
1178 #ifdef WIN
1179
1180 tmp = _gmtime64 (&sec_run);
1181
1182 #else
1183
1184 tmp = gmtime (&sec_run);
1185
1186 #endif
1187
1188 if (tmp != NULL)
1189 {
1190 memcpy (&tm_run, tmp, sizeof (struct tm));
1191
1192 format_timer_display (&tm_run, display_run, sizeof (tm_run));
1193
1194 char *start = ctime (&data.proc_start);
1195
1196 size_t start_len = strlen (start);
1197
1198 if (start[start_len - 1] == '\n') start[start_len - 1] = 0;
1199 if (start[start_len - 2] == '\r') start[start_len - 2] = 0;
1200
1201 log_info ("Time.Started...: %s (%s)", start, display_run);
1202 }
1203 }
1204 else
1205 {
1206 log_info ("Time.Started...: 0 secs");
1207 }
1208
1209 /**
1210 * counters
1211 */
1212
1213 uint salts_left = data.salts_cnt - data.salts_done;
1214
1215 if (salts_left == 0) salts_left = 1;
1216
1217 uint64_t progress_total = data.words_cnt * salts_left;
1218
1219 uint64_t all_done = 0;
1220 uint64_t all_rejected = 0;
1221 uint64_t all_restored = 0;
1222
1223 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
1224 {
1225 if (salts_left > 1)
1226 {
1227 // otherwise the final cracked status shows 0/XXX progress
1228
1229 if (data.salts_shown[salt_pos] == 1) continue;
1230 }
1231
1232 all_done += data.words_progress_done[salt_pos];
1233 all_rejected += data.words_progress_rejected[salt_pos];
1234 all_restored += data.words_progress_restored[salt_pos];
1235 }
1236
1237 uint64_t progress_cur = all_restored + all_done + all_rejected;
1238 uint64_t progress_end = progress_total;
1239
1240 uint64_t progress_skip = 0;
1241
1242 if (data.skip)
1243 {
1244 progress_skip = MIN (data.skip, data.words_base) * salts_left;
1245
1246 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= data.gpu_rules_cnt;
1247 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt;
1248 else if (data.attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt;
1249 }
1250
1251 if (data.limit)
1252 {
1253 progress_end = MIN (data.limit, data.words_base) * salts_left;
1254
1255 if (data.attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= data.gpu_rules_cnt;
1256 else if (data.attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt;
1257 else if (data.attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
1258 }
1259
1260 uint64_t progress_cur_relative_skip = progress_cur - progress_skip;
1261 uint64_t progress_end_relative_skip = progress_end - progress_skip;
1262
1263 float speed_ms_real = ms_running - ms_paused;
1264 uint64_t speed_plains_real = all_done;
1265
1266 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1267 {
1268 if (data.devices_status != STATUS_CRACKED)
1269 {
1270 uint64_t words_per_ms = 0;
1271
1272 if (speed_plains_real && speed_ms_real)
1273 {
1274 words_per_ms = speed_plains_real / speed_ms_real;
1275 }
1276
1277 #ifdef WIN
1278 __time64_t sec_etc = 0;
1279 #else
1280 time_t sec_etc = 0;
1281 #endif
1282
1283 if (words_per_ms)
1284 {
1285 uint64_t progress_left_relative_skip = progress_end_relative_skip - progress_cur_relative_skip;
1286
1287 uint64_t ms_left = progress_left_relative_skip / words_per_ms;
1288
1289 sec_etc = ms_left / 1000;
1290 }
1291
1292 if (sec_etc == 0)
1293 {
1294 log_info ("Time.Estimated.: 0 secs");
1295 }
1296 else if ((uint64_t) sec_etc > ETC_MAX)
1297 {
1298 log_info ("Time.Estimated.: > 10 Years");
1299 }
1300 else
1301 {
1302 char display_etc[32];
1303
1304 struct tm tm_etc;
1305
1306 struct tm *tmp;
1307
1308 #ifdef WIN
1309
1310 tmp = _gmtime64 (&sec_etc);
1311
1312 #else
1313
1314 tmp = gmtime (&sec_etc);
1315
1316 #endif
1317
1318 if (tmp != NULL)
1319 {
1320 memcpy (&tm_etc, tmp, sizeof (tm_etc));
1321
1322 format_timer_display (&tm_etc, display_etc, sizeof (display_etc));
1323
1324 time_t now;
1325
1326 time (&now);
1327
1328 now += sec_etc;
1329
1330 char *etc = ctime (&now);
1331
1332 size_t etc_len = strlen (etc);
1333
1334 if (etc[etc_len - 1] == '\n') etc[etc_len - 1] = 0;
1335 if (etc[etc_len - 2] == '\r') etc[etc_len - 2] = 0;
1336
1337 log_info ("Time.Estimated.: %s (%s)", etc, display_etc);
1338 }
1339 }
1340 }
1341 }
1342
1343 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1344 {
1345 char display_dev_cur[16];
1346
1347 memset (display_dev_cur, 0, sizeof (display_dev_cur));
1348
1349 strncpy (display_dev_cur, "0.00", 4);
1350
1351 format_speed_display (hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur));
1352
1353 log_info ("Speed.GPU.#%d...: %9sH/s", device_id + 1, display_dev_cur);
1354 }
1355
1356 char display_all_cur[16];
1357
1358 memset (display_all_cur, 0, sizeof (display_all_cur));
1359
1360 strncpy (display_all_cur, "0.00", 4);
1361
1362 format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur));
1363
1364 if (data.devices_cnt > 1) log_info ("Speed.GPU.#*...: %9sH/s", display_all_cur);
1365
1366 const float digests_percent = (float) data.digests_done / data.digests_cnt;
1367 const float salts_percent = (float) data.salts_done / data.salts_cnt;
1368
1369 log_info ("Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", data.digests_done, data.digests_cnt, digests_percent * 100, data.salts_done, data.salts_cnt, salts_percent * 100);
1370
1371 // crack-per-time
1372
1373 if (data.digests_cnt > 100)
1374 {
1375 time_t now = time (NULL);
1376
1377 int cpt_cur_min = 0;
1378 int cpt_cur_hour = 0;
1379 int cpt_cur_day = 0;
1380
1381 for (int i = 0; i < CPT_BUF; i++)
1382 {
1383 const uint cracked = data.cpt_buf[i].cracked;
1384 const time_t timestamp = data.cpt_buf[i].timestamp;
1385
1386 if ((timestamp + 60) > now)
1387 {
1388 cpt_cur_min += cracked;
1389 }
1390
1391 if ((timestamp + 3600) > now)
1392 {
1393 cpt_cur_hour += cracked;
1394 }
1395
1396 if ((timestamp + 86400) > now)
1397 {
1398 cpt_cur_day += cracked;
1399 }
1400 }
1401
1402 float cpt_avg_min = (float) data.cpt_total / ((speed_ms_real / 1000) / 60);
1403 float cpt_avg_hour = (float) data.cpt_total / ((speed_ms_real / 1000) / 3600);
1404 float cpt_avg_day = (float) data.cpt_total / ((speed_ms_real / 1000) / 86400);
1405
1406 if ((data.cpt_start + 86400) < now)
1407 {
1408 log_info ("Recovered/Time.: CUR:%llu,%llu,%llu AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1409 cpt_cur_min,
1410 cpt_cur_hour,
1411 cpt_cur_day,
1412 cpt_avg_min,
1413 cpt_avg_hour,
1414 cpt_avg_day);
1415 }
1416 else if ((data.cpt_start + 3600) < now)
1417 {
1418 log_info ("Recovered/Time.: CUR:%llu,%llu,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1419 cpt_cur_min,
1420 cpt_cur_hour,
1421 cpt_avg_min,
1422 cpt_avg_hour,
1423 cpt_avg_day);
1424 }
1425 else if ((data.cpt_start + 60) < now)
1426 {
1427 log_info ("Recovered/Time.: CUR:%llu,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1428 cpt_cur_min,
1429 cpt_avg_min,
1430 cpt_avg_hour,
1431 cpt_avg_day);
1432 }
1433 else
1434 {
1435 log_info ("Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
1436 cpt_avg_min,
1437 cpt_avg_hour,
1438 cpt_avg_day);
1439 }
1440 }
1441
1442 // Restore point
1443
1444 uint64_t restore_point = get_lowest_words_done ();
1445
1446 uint64_t restore_total = data.words_base;
1447
1448 float percent_restore = 0;
1449
1450 if (restore_total != 0) percent_restore = (float) restore_point / (float) restore_total;
1451
1452 if (progress_end_relative_skip)
1453 {
1454 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1455 {
1456 float percent_finished = (float) progress_cur_relative_skip / (float) progress_end_relative_skip;
1457 float percent_rejected = 0.0;
1458
1459 if (progress_cur)
1460 {
1461 percent_rejected = (float) (all_rejected) / (float) progress_cur;
1462 }
1463
1464 log_info ("Progress.......: %llu/%llu (%.02f%%)", (unsigned long long int) progress_cur_relative_skip, (unsigned long long int) progress_end_relative_skip, percent_finished * 100);
1465 log_info ("Rejected.......: %llu/%llu (%.02f%%)", (unsigned long long int) all_rejected, (unsigned long long int) progress_cur_relative_skip, percent_rejected * 100);
1466
1467 if (data.restore_disable == 0)
1468 {
1469 if (percent_finished != 1)
1470 {
1471 log_info ("Restore.Point..: %llu/%llu (%.02f%%)", (unsigned long long int) restore_point, (unsigned long long int) restore_total, percent_restore * 100);
1472 }
1473 }
1474 }
1475 }
1476 else
1477 {
1478 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
1479 {
1480 log_info ("Progress.......: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1481 log_info ("Rejected.......: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1482
1483 if (data.restore_disable == 0)
1484 {
1485 log_info ("Restore point..: %llu/%llu (%.02f%%)", (uint64_t) 0, (uint64_t) 0, (float) 100);
1486 }
1487 }
1488 else
1489 {
1490 log_info ("Progress.......: %llu", (unsigned long long int) progress_cur_relative_skip);
1491 log_info ("Rejected.......: %llu", (unsigned long long int) all_rejected);
1492
1493 // --restore not allowed if stdin is used -- really? why?
1494
1495 //if (data.restore_disable == 0)
1496 //{
1497 // log_info ("Restore point..: %llu", (unsigned long long int) restore_point);
1498 //}
1499 }
1500 }
1501
1502 if (data.gpu_temp_disable == 0)
1503 {
1504 hc_thread_mutex_lock (mux_adl);
1505
1506 for (uint i = 0; i < data.devices_cnt; i++)
1507 {
1508 if (data.hm_device[i].fan_supported == 1)
1509 {
1510 const int temperature = hm_get_temperature_with_device_id (i);
1511 const int utilization = hm_get_utilization_with_device_id (i);
1512 const int fanspeed = hm_get_fanspeed_with_device_id (i);
1513
1514 #ifdef _OCL
1515 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed);
1516 #else
1517 #ifdef LINUX
1518 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2d%% Fan", i + 1, utilization, temperature, fanspeed);
1519 #else
1520 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, %2drpm Fan", i + 1, utilization, temperature, fanspeed);
1521 #endif
1522 #endif
1523 }
1524 else
1525 {
1526 const int temperature = hm_get_temperature_with_device_id (i);
1527 const int utilization = hm_get_utilization_with_device_id (i);
1528
1529 log_info ("HWMon.GPU.#%d...: %2d%% Util, %2dc Temp, N/A Fan", i + 1, utilization, temperature);
1530 }
1531 }
1532
1533 hc_thread_mutex_unlock (mux_adl);
1534 }
1535 }
1536
1537 static void status_benchmark ()
1538 {
1539 if (data.devices_status == STATUS_INIT) return;
1540 if (data.devices_status == STATUS_STARTING) return;
1541
1542 if (data.words_cnt == 0) return;
1543
1544 uint64_t speed_cnt[DEVICES_MAX];
1545 float speed_ms[DEVICES_MAX];
1546
1547 uint device_id;
1548
1549 for (device_id = 0; device_id < data.devices_cnt; device_id++)
1550 {
1551 hc_device_param_t *device_param = &data.devices_param[device_id];
1552
1553 speed_cnt[device_id] = 0;
1554 speed_ms[device_id] = 0;
1555
1556 for (int i = 0; i < SPEED_CACHE; i++)
1557 {
1558 speed_cnt[device_id] += device_param->speed_cnt[i];
1559 speed_ms[device_id] += device_param->speed_ms[i];
1560 }
1561
1562 speed_cnt[device_id] /= SPEED_CACHE;
1563 speed_ms[device_id] /= SPEED_CACHE;
1564 }
1565
1566 float hashes_all_ms = 0;
1567
1568 float hashes_dev_ms[DEVICES_MAX];
1569
1570 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1571 {
1572 hashes_dev_ms[device_id] = 0;
1573
1574 if (speed_ms[device_id])
1575 {
1576 hashes_dev_ms[device_id] = speed_cnt[device_id] / speed_ms[device_id];
1577
1578 hashes_all_ms += hashes_dev_ms[device_id];
1579 }
1580 }
1581
1582 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
1583 {
1584 char display_dev_cur[16];
1585
1586 memset (display_dev_cur, 0, sizeof (display_dev_cur));
1587
1588 strncpy (display_dev_cur, "0.00", 4);
1589
1590 format_speed_display (hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur));
1591
1592 log_info ("Speed.GPU.#%d.: %9sH/s", device_id + 1, display_dev_cur);
1593 }
1594
1595 char display_all_cur[16];
1596
1597 memset (display_all_cur, 0, sizeof (display_all_cur));
1598
1599 strncpy (display_all_cur, "0.00", 4);
1600
1601 format_speed_display (hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur));
1602
1603 if (data.devices_cnt > 1) log_info ("Speed.GPU.#*.: %9sH/s", display_all_cur);
1604 }
1605
1606 /**
1607 * oclHashcat -only- functions
1608 */
1609
1610 static uint convert_from_hex (char *line_buf, const uint line_len)
1611 {
1612 if (line_len & 1) return (line_len); // not in hex
1613
1614 if (data.hex_wordlist == 1)
1615 {
1616 uint i;
1617 uint j;
1618
1619 for (i = 0, j = 0; j < line_len; i += 1, j += 2)
1620 {
1621 line_buf[i] = hex_to_char (&line_buf[j]);
1622 }
1623
1624 memset (line_buf + i, 0, line_len - i);
1625
1626 return (i);
1627 }
1628 else if (line_len >= 6) // $HEX[] = 6
1629 {
1630 if (line_buf[0] != '$') return (line_len);
1631 if (line_buf[1] != 'H') return (line_len);
1632 if (line_buf[2] != 'E') return (line_len);
1633 if (line_buf[3] != 'X') return (line_len);
1634 if (line_buf[4] != '[') return (line_len);
1635 if (line_buf[line_len - 1] != ']') return (line_len);
1636
1637 uint i;
1638 uint j;
1639
1640 for (i = 0, j = 5; j < line_len - 1; i += 1, j += 2)
1641 {
1642 line_buf[i] = hex_to_char (&line_buf[j]);
1643 }
1644
1645 memset (line_buf + i, 0, line_len - i);
1646
1647 return (i);
1648 }
1649
1650 return (line_len);
1651 }
1652
1653 static uint count_lines (FILE *fd)
1654 {
1655 uint cnt = 0;
1656
1657 char *buf = (char *) mymalloc (BUFSIZ);
1658
1659 size_t nread_tmp = 0;
1660
1661 char *ptr = buf;
1662
1663 while (!feof (fd))
1664 {
1665 size_t nread = fread (buf, sizeof (char), BUFSIZ, fd);
1666 nread_tmp = nread;
1667
1668 if (nread < 1) continue;
1669
1670 ptr = buf;
1671
1672 do
1673 {
1674 if (*ptr++ == '\n') cnt++;
1675
1676 } while (nread--);
1677 }
1678
1679 // special case (if last line did not contain a newline char ... at the very end of the file)
1680
1681 if (nread_tmp > 3)
1682 {
1683 ptr -= 2;
1684
1685 if (*ptr != '\n')
1686 {
1687 ptr--;
1688
1689 if (*ptr != '\n') // needed ? different on windows systems?
1690 {
1691 cnt++;
1692 }
1693 }
1694 }
1695
1696 myfree (buf);
1697
1698 return cnt;
1699 }
1700
1701 static void clear_prompt ()
1702 {
1703 fputc ('\r', stdout);
1704
1705 for (size_t i = 0; i < strlen (PROMPT); i++)
1706 {
1707 fputc (' ', stdout);
1708 }
1709
1710 fputc ('\r', stdout);
1711
1712 fflush (stdout);
1713 }
1714
1715 static void gidd_to_pw_t (hc_device_param_t *device_param, const uint64_t gidd, pw_t *pw)
1716 {
1717 #ifdef _CUDA
1718 hc_cuCtxPushCurrent (device_param->context);
1719
1720 hc_cuMemcpyDtoH (pw, device_param->d_pws_buf + (gidd * sizeof (pw_t)), sizeof (pw_t));
1721
1722 hc_cuCtxPopCurrent (&device_param->context);
1723
1724 #elif _OCL
1725 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, gidd * sizeof (pw_t), sizeof (pw_t), pw, 0, NULL, NULL);
1726
1727 #endif
1728 }
1729
1730 static void check_hash (hc_device_param_t *device_param, const uint salt_pos, const uint digest_pos)
1731 {
1732 char *outfile = data.outfile;
1733 uint quiet = data.quiet;
1734 FILE *pot_fp = data.pot_fp;
1735 uint loopback = data.loopback;
1736 uint debug_mode = data.debug_mode;
1737 char *debug_file = data.debug_file;
1738
1739 char debug_rule_buf[BLOCK_SIZE];
1740 int debug_rule_len = 0; // -1 error
1741 uint debug_plain_len = 0;
1742
1743 unsigned char debug_plain_ptr[BLOCK_SIZE];
1744
1745 // hash
1746
1747 char out_buf[4096]; memset (out_buf, 0, sizeof (out_buf));
1748
1749 ascii_digest (out_buf, salt_pos, digest_pos);
1750
1751 uint idx = data.salts_buf[salt_pos].digests_offset + digest_pos;
1752
1753 // plain
1754
1755 plain_t plain;
1756
1757 #ifdef _CUDA
1758 hc_cuCtxPushCurrent (device_param->context);
1759
1760 hc_cuMemcpyDtoH (&plain, device_param->d_plain_bufs + (idx * sizeof (plain_t)), sizeof (plain_t));
1761
1762 hc_cuCtxPopCurrent (&device_param->context);
1763 #elif _OCL
1764 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, idx * sizeof (plain_t), sizeof (plain_t), &plain, 0, NULL, NULL);
1765 #endif
1766
1767 uint gidvid = plain.gidvid;
1768 uint il_pos = plain.il_pos;
1769
1770 uint64_t crackpos = device_param->words_off;
1771
1772 uint plain_buf[16];
1773
1774 unsigned char *plain_ptr = (unsigned char *) plain_buf;
1775 unsigned int plain_len = 0;
1776
1777 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
1778 {
1779 uint64_t gidd = gidvid / device_param->gpu_vector_width;
1780 uint64_t gidm = gidvid % device_param->gpu_vector_width;
1781
1782 pw_t pw;
1783
1784 gidd_to_pw_t (device_param, gidd, &pw);
1785
1786 for (int i = 0, j = gidm; i < 16; i++, j += device_param->gpu_vector_width)
1787 {
1788 plain_buf[i] = pw.hi1[0][j];
1789 }
1790
1791 plain_len = pw.pw_len;
1792
1793 const uint off = device_param->innerloop_pos + il_pos;
1794
1795 if (debug_mode > 0)
1796 {
1797 debug_rule_len = 0;
1798
1799 // save rule
1800 if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4))
1801 {
1802 memset (debug_rule_buf, 0, sizeof (debug_rule_buf));
1803
1804 debug_rule_len = gpu_rule_to_cpu_rule (debug_rule_buf, &data.gpu_rules_buf[off]);
1805 }
1806
1807 // save plain
1808 if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4))
1809 {
1810 memset (debug_plain_ptr, 0, sizeof (debug_plain_ptr));
1811
1812 memcpy (debug_plain_ptr, plain_ptr, plain_len);
1813
1814 debug_plain_len = plain_len;
1815 }
1816 }
1817
1818 plain_len = apply_rules (data.gpu_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], plain_len);
1819
1820 crackpos += gidvid;
1821 crackpos *= data.gpu_rules_cnt;
1822 crackpos += device_param->innerloop_pos + il_pos;
1823
1824 if (plain_len > data.pw_max) plain_len = data.pw_max;
1825 }
1826 else if (data.attack_mode == ATTACK_MODE_COMBI)
1827 {
1828 uint64_t gidd = gidvid / device_param->gpu_vector_width;
1829 uint64_t gidm = gidvid % device_param->gpu_vector_width;
1830
1831 pw_t pw;
1832
1833 gidd_to_pw_t (device_param, gidd, &pw);
1834
1835 for (int i = 0, j = gidm; i < 16; i++, j += device_param->gpu_vector_width)
1836 {
1837 plain_buf[i] = pw.hi1[0][j];
1838 }
1839
1840 plain_len = pw.pw_len;
1841
1842 char *comb_buf = (char *) device_param->combs_buf[il_pos].i;
1843 uint comb_len = device_param->combs_buf[il_pos].pw_len;
1844
1845 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
1846 {
1847 memcpy (plain_ptr + plain_len, comb_buf, comb_len);
1848 }
1849 else
1850 {
1851 memmove (plain_ptr + comb_len, plain_ptr, plain_len);
1852
1853 memcpy (plain_ptr, comb_buf, comb_len);
1854 }
1855
1856 plain_len += comb_len;
1857
1858 crackpos += gidvid;
1859 crackpos *= data.combs_cnt;
1860 crackpos += device_param->innerloop_pos + il_pos;
1861
1862 if (data.pw_max != PW_DICTMAX1)
1863 {
1864 if (plain_len > data.pw_max) plain_len = data.pw_max;
1865 }
1866 }
1867 else if (data.attack_mode == ATTACK_MODE_BF)
1868 {
1869 uint64_t l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid;
1870 uint64_t r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos;
1871
1872 uint l_start = device_param->kernel_params_mp_l_buf32[5];
1873 uint r_start = device_param->kernel_params_mp_r_buf32[5];
1874
1875 uint l_stop = device_param->kernel_params_mp_l_buf32[4];
1876 uint r_stop = device_param->kernel_params_mp_r_buf32[4];
1877
1878 sp_exec (l_off, (char *) plain_ptr + l_start, data.root_css_buf, data.markov_css_buf, l_start, l_start + l_stop);
1879 sp_exec (r_off, (char *) plain_ptr + r_start, data.root_css_buf, data.markov_css_buf, r_start, r_start + r_stop);
1880
1881 plain_len = data.css_cnt;
1882
1883 crackpos += gidvid;
1884 crackpos *= data.bfs_cnt;
1885 crackpos += device_param->innerloop_pos + il_pos;
1886 }
1887 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
1888 {
1889 uint64_t gidd = gidvid / device_param->gpu_vector_width;
1890 uint64_t gidm = gidvid % device_param->gpu_vector_width;
1891
1892 pw_t pw;
1893
1894 gidd_to_pw_t (device_param, gidd, &pw);
1895
1896 for (int i = 0, j = gidm; i < 16; i++, j += device_param->gpu_vector_width)
1897 {
1898 plain_buf[i] = pw.hi1[0][j];
1899 }
1900
1901 plain_len = pw.pw_len;
1902
1903 uint64_t off = device_param->kernel_params_mp_buf64[3] + il_pos;
1904
1905 uint start = 0;
1906 uint stop = device_param->kernel_params_mp_buf32[4];
1907
1908 sp_exec (off, (char *) plain_ptr + plain_len, data.root_css_buf, data.markov_css_buf, start, start + stop);
1909
1910 plain_len += start + stop;
1911
1912 crackpos += gidvid;
1913 crackpos *= data.combs_cnt;
1914 crackpos += device_param->innerloop_pos + il_pos;
1915
1916 if (data.pw_max != PW_DICTMAX1)
1917 {
1918 if (plain_len > data.pw_max) plain_len = data.pw_max;
1919 }
1920 }
1921 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
1922 {
1923 uint64_t gidd = gidvid / device_param->gpu_vector_width;
1924 uint64_t gidm = gidvid % device_param->gpu_vector_width;
1925
1926 pw_t pw;
1927
1928 gidd_to_pw_t (device_param, gidd, &pw);
1929
1930 for (int i = 0, j = gidm; i < 16; i++, j += device_param->gpu_vector_width)
1931 {
1932 plain_buf[i] = pw.hi1[0][j];
1933 }
1934
1935 plain_len = pw.pw_len;
1936
1937 uint64_t off = device_param->kernel_params_mp_buf64[3] + il_pos;
1938
1939 uint start = 0;
1940 uint stop = device_param->kernel_params_mp_buf32[4];
1941
1942 memmove (plain_ptr + stop, plain_ptr, plain_len);
1943
1944 sp_exec (off, (char *) plain_ptr, data.root_css_buf, data.markov_css_buf, start, start + stop);
1945
1946 plain_len += start + stop;
1947
1948 crackpos += gidvid;
1949 crackpos *= data.combs_cnt;
1950 crackpos += device_param->innerloop_pos + il_pos;
1951
1952 if (data.pw_max != PW_DICTMAX1)
1953 {
1954 if (plain_len > data.pw_max) plain_len = data.pw_max;
1955 }
1956 }
1957
1958 if (data.opti_type & OPTI_TYPE_BRUTE_FORCE) // lots of optimizations can happen here
1959 {
1960 if (data.opti_type & OPTI_TYPE_SINGLE_HASH)
1961 {
1962 if (data.opti_type & OPTI_TYPE_APPENDED_SALT)
1963 {
1964 plain_len = plain_len - data.salts_buf[0].salt_len;
1965 }
1966 }
1967
1968 if (data.opts_type & OPTS_TYPE_PT_UNICODE)
1969 {
1970 for (uint i = 0, j = 0; i < plain_len; i += 2, j += 1)
1971 {
1972 plain_ptr[j] = plain_ptr[i];
1973 }
1974
1975 plain_len = plain_len / 2;
1976 }
1977 }
1978
1979 // if enabled, update also the potfile
1980
1981 if (pot_fp)
1982 {
1983 fprintf (pot_fp, "%s:", out_buf);
1984
1985 format_plain (pot_fp, plain_ptr, plain_len, 1);
1986
1987 fputc ('\n', pot_fp);
1988
1989 fflush (pot_fp);
1990 }
1991
1992 // outfile
1993
1994 FILE *out_fp = NULL;
1995
1996 if (outfile != NULL)
1997 {
1998 if ((out_fp = fopen (outfile, "ab")) == NULL)
1999 {
2000 log_error ("ERROR: %s: %s", outfile, strerror (errno));
2001
2002 out_fp = stdout;
2003 }
2004 }
2005 else
2006 {
2007 out_fp = stdout;
2008
2009 if (quiet == 0) clear_prompt ();
2010 }
2011
2012 format_output (out_fp, out_buf, plain_ptr, plain_len, crackpos, NULL, 0);
2013
2014 if (outfile != NULL)
2015 {
2016 if (out_fp != stdout)
2017 {
2018 fclose (out_fp);
2019 }
2020 }
2021 else
2022 {
2023 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
2024 {
2025 if ((data.devices_status != STATUS_CRACKED) && (data.status != 1))
2026 {
2027 if (quiet == 0) fprintf (stdout, "%s", PROMPT);
2028 if (quiet == 0) fflush (stdout);
2029 }
2030 }
2031 }
2032
2033 // loopback
2034
2035 if (loopback)
2036 {
2037 char *loopback_file = data.loopback_file;
2038
2039 FILE *fb_fp = NULL;
2040
2041 if ((fb_fp = fopen (loopback_file, "ab")) != NULL)
2042 {
2043 format_plain (fb_fp, plain_ptr, plain_len, 1);
2044
2045 fputc ('\n', fb_fp);
2046
2047 fclose (fb_fp);
2048 }
2049 }
2050
2051 // (rule) debug mode
2052
2053 // the next check implies that:
2054 // - (data.attack_mode == ATTACK_MODE_STRAIGHT)
2055 // - debug_mode > 0
2056
2057 if ((debug_plain_len > 0) || (debug_rule_len > 0))
2058 {
2059 if (debug_rule_len < 0) debug_rule_len = 0;
2060
2061 if ((quiet == 0) && (debug_file == NULL)) clear_prompt ();
2062
2063 format_debug (debug_file, debug_mode, debug_plain_ptr, debug_plain_len, plain_ptr, plain_len, debug_rule_buf, debug_rule_len);
2064
2065 if ((quiet == 0) && (debug_file == NULL))
2066 {
2067 fprintf (stdout, "%s", PROMPT);
2068 fflush (stdout);
2069 }
2070 }
2071 }
2072
2073 static void check_cracked (hc_device_param_t *device_param, const uint salt_pos)
2074 {
2075 salt_t *salt_buf = &data.salts_buf[salt_pos];
2076
2077 int found = 0;
2078
2079 #ifdef _CUDA
2080
2081 hc_cuCtxPushCurrent (device_param->context);
2082
2083 hc_cuMemcpyDtoH (device_param->result, device_param->d_result, device_param->size_results);
2084
2085 hc_cuCtxPopCurrent (&device_param->context);
2086
2087 for (uint i = 0; i < GPU_THREADS_NV; i++) if (device_param->result[i] == 1) found = 1;
2088
2089 #elif _OCL
2090
2091 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_result, CL_TRUE, 0, device_param->size_results, device_param->result, 0, NULL, NULL);
2092
2093 for (uint i = 0; i < GPU_THREADS_AMD; i++) if (device_param->result[i] == 1) found = 1;
2094
2095 #endif
2096
2097 if (found == 1)
2098 {
2099 // display hack (for weak hashes etc, it could be that there is still something to clear on the current line)
2100
2101 log_info_nn ("");
2102
2103 #ifdef _CUDA
2104
2105 hc_cuCtxPushCurrent (device_param->context);
2106
2107 hc_cuMemcpyDtoH (&data.digests_shown_tmp[salt_buf->digests_offset], device_param->d_digests_shown + (salt_buf->digests_offset * sizeof (uint)), salt_buf->digests_cnt * sizeof (uint));
2108
2109 hc_cuCtxPopCurrent (&device_param->context);
2110
2111 #elif _OCL
2112
2113 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (uint), salt_buf->digests_cnt * sizeof (uint), &data.digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL);
2114
2115 #endif
2116
2117 uint cpt_cracked = 0;
2118
2119 for (uint digest_pos = 0; digest_pos < salt_buf->digests_cnt; digest_pos++)
2120 {
2121 uint idx = salt_buf->digests_offset + digest_pos;
2122
2123 if (data.digests_shown_tmp[idx] == 0) continue;
2124
2125 if (data.digests_shown[idx] == 1) continue;
2126
2127 if ((data.opts_type & OPTS_TYPE_PT_NEVERCRACK) == 0)
2128 {
2129 data.digests_shown[idx] = 1;
2130
2131 data.digests_done++;
2132
2133 cpt_cracked++;
2134
2135 salt_buf->digests_done++;
2136
2137 if (salt_buf->digests_done == salt_buf->digests_cnt)
2138 {
2139 data.salts_shown[salt_pos] = 1;
2140
2141 data.salts_done++;
2142 }
2143 }
2144
2145 if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
2146
2147 check_hash (device_param, salt_pos, digest_pos);
2148 }
2149
2150 if (cpt_cracked > 0)
2151 {
2152 data.cpt_buf[data.cpt_pos].timestamp = time (NULL);
2153 data.cpt_buf[data.cpt_pos].cracked = cpt_cracked;
2154
2155 data.cpt_pos++;
2156
2157 data.cpt_total += cpt_cracked;
2158
2159 if (data.cpt_pos == CPT_BUF) data.cpt_pos = 0;
2160 }
2161
2162 if (data.opts_type & OPTS_TYPE_PT_NEVERCRACK)
2163 {
2164 // we need to reset cracked state on the gpu
2165 // otherwise host thinks again and again the hash was cracked
2166 // and returns invalid password each time
2167
2168 memset (data.digests_shown_tmp, 0, salt_buf->digests_cnt * sizeof (uint));
2169
2170 #ifdef _CUDA
2171
2172 hc_cuCtxPushCurrent (device_param->context);
2173
2174 hc_cuMemsetD8 (device_param->d_digests_shown + (salt_buf->digests_offset * sizeof (uint)), 0, salt_buf->digests_cnt * sizeof (uint));
2175
2176 hc_cuCtxPopCurrent (&device_param->context);
2177
2178 #elif _OCL
2179
2180 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (uint), salt_buf->digests_cnt * sizeof (uint), &data.digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL);
2181
2182 #endif
2183 }
2184
2185 #ifdef _CUDA
2186
2187 hc_cuCtxPushCurrent (device_param->context);
2188
2189 hc_cuMemsetD8 (device_param->d_result, 0, device_param->size_results);
2190
2191 hc_cuCtxPopCurrent (&device_param->context);
2192
2193 #elif _OCL
2194
2195 memset (device_param->result, 0, device_param->size_results);
2196
2197 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_result, CL_TRUE, 0, device_param->size_results, device_param->result, 0, NULL, NULL);
2198
2199 #endif
2200 }
2201 }
2202
2203 static void save_hash ()
2204 {
2205 char *hashfile = data.hashfile;
2206
2207 char new_hashfile[256];
2208 char old_hashfile[256];
2209
2210 memset (new_hashfile, 0, sizeof (new_hashfile));
2211 memset (old_hashfile, 0, sizeof (old_hashfile));
2212
2213 snprintf (new_hashfile, 255, "%s.new", hashfile);
2214 snprintf (old_hashfile, 255, "%s.old", hashfile);
2215
2216 unlink (new_hashfile);
2217
2218 char separator = data.separator;
2219
2220 FILE *fp = fopen (new_hashfile, "wb");
2221
2222 if (fp == NULL)
2223 {
2224 log_error ("ERROR: %s: %s", new_hashfile, strerror (errno));
2225
2226 exit (-1);
2227 }
2228
2229 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
2230 {
2231 if (data.salts_shown[salt_pos] == 1) continue;
2232
2233 salt_t *salt_buf = &data.salts_buf[salt_pos];
2234
2235 for (uint digest_pos = 0; digest_pos < salt_buf->digests_cnt; digest_pos++)
2236 {
2237 uint idx = salt_buf->digests_offset + digest_pos;
2238
2239 if (data.digests_shown[idx] == 1) continue;
2240
2241 if (data.hash_mode != 2500)
2242 {
2243 char out_buf[4096];
2244
2245 memset (out_buf, 0, sizeof (out_buf));
2246
2247 if (data.username == 1)
2248 {
2249 user_t *user = data.hash_info[idx]->user;
2250
2251 uint i;
2252
2253 for (i = 0; i < user->user_len; i++) fputc (user->user_name[i], fp);
2254
2255 fputc (separator, fp);
2256 }
2257
2258 ascii_digest (out_buf, salt_pos, digest_pos);
2259
2260 fputs (out_buf, fp);
2261
2262 log_out (fp, "");
2263 }
2264 else
2265 {
2266 hccap_t hccap;
2267
2268 to_hccap_t (&hccap, salt_pos, digest_pos);
2269
2270 fwrite (&hccap, sizeof (hccap_t), 1, fp);
2271 }
2272 }
2273 }
2274
2275 fflush (fp);
2276
2277 fclose (fp);
2278
2279 unlink (old_hashfile);
2280
2281 if (rename (hashfile, old_hashfile) != 0)
2282 {
2283 log_error ("ERROR: Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno));
2284
2285 exit (-1);
2286 }
2287
2288 unlink (hashfile);
2289
2290 if (rename (new_hashfile, hashfile) != 0)
2291 {
2292 log_error ("ERROR: Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno));
2293
2294 exit (-1);
2295 }
2296
2297 unlink (old_hashfile);
2298 }
2299
2300 static float find_gpu_blocks_div (const uint64_t total_left, const uint gpu_blocks_all)
2301 {
2302 // function called only in case gpu_blocks_all > words_left)
2303
2304 float gpu_blocks_div = (float) (total_left) / gpu_blocks_all;
2305
2306 gpu_blocks_div += gpu_blocks_div / 100;
2307
2308 uint32_t gpu_blocks_new = (uint32_t) (gpu_blocks_all * gpu_blocks_div);
2309
2310 while (gpu_blocks_new < total_left)
2311 {
2312 gpu_blocks_div += gpu_blocks_div / 100;
2313
2314 gpu_blocks_new = (uint32_t) (gpu_blocks_all * gpu_blocks_div);
2315 }
2316
2317 if (data.quiet == 0)
2318 {
2319 clear_prompt ();
2320
2321 log_info ("");
2322
2323 log_info ("INFO: approaching final keyspace, workload adjusted");
2324
2325 log_info ("");
2326
2327 fprintf (stdout, "%s", PROMPT);
2328
2329 fflush (stdout);
2330 }
2331
2332 if ((gpu_blocks_all * gpu_blocks_div) < 8) return 1;
2333
2334 return gpu_blocks_div;
2335 }
2336
2337 static void run_kernel (const uint kern_run, hc_device_param_t *device_param, const uint num)
2338 {
2339 // uint gpu_vector_width = device_param->gpu_vector_width;
2340
2341 // uint num_elements = mydivc32 (num, gpu_vector_width);
2342
2343 uint num_elements = num;
2344
2345 device_param->kernel_params_buf32[30] = data.combs_mode;
2346 device_param->kernel_params_buf32[31] = num;
2347
2348 uint gpu_threads = device_param->gpu_threads;
2349
2350 while (num_elements % gpu_threads) num_elements++;
2351
2352 #ifdef _CUDA
2353 CUfunction function = NULL;
2354
2355 switch (kern_run)
2356 {
2357 case KERN_RUN_1: function = device_param->function1; break;
2358 case KERN_RUN_12: function = device_param->function12; break;
2359 case KERN_RUN_2: function = device_param->function2; break;
2360 case KERN_RUN_23: function = device_param->function23; break;
2361 case KERN_RUN_3: function = device_param->function3; break;
2362 }
2363
2364 num_elements /= gpu_threads;
2365
2366 hc_cuCtxPushCurrent (device_param->context);
2367
2368 hc_cuLaunchKernel (function, num_elements, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, device_param->kernel_params, NULL);
2369
2370 hc_cuStreamSynchronize (device_param->stream);
2371
2372 hc_cuCtxPopCurrent (&device_param->context);
2373
2374 #elif _OCL
2375
2376 cl_kernel kernel = NULL;
2377
2378 switch (kern_run)
2379 {
2380 case KERN_RUN_1: kernel = device_param->kernel1; break;
2381 case KERN_RUN_12: kernel = device_param->kernel12; break;
2382 case KERN_RUN_2: kernel = device_param->kernel2; break;
2383 case KERN_RUN_23: kernel = device_param->kernel23; break;
2384 case KERN_RUN_3: kernel = device_param->kernel3; break;
2385 }
2386
2387 hc_clSetKernelArg (kernel, 21, sizeof (cl_uint), device_param->kernel_params[21]);
2388 hc_clSetKernelArg (kernel, 22, sizeof (cl_uint), device_param->kernel_params[22]);
2389 hc_clSetKernelArg (kernel, 23, sizeof (cl_uint), device_param->kernel_params[23]);
2390 hc_clSetKernelArg (kernel, 24, sizeof (cl_uint), device_param->kernel_params[24]);
2391 hc_clSetKernelArg (kernel, 25, sizeof (cl_uint), device_param->kernel_params[25]);
2392 hc_clSetKernelArg (kernel, 26, sizeof (cl_uint), device_param->kernel_params[26]);
2393 hc_clSetKernelArg (kernel, 27, sizeof (cl_uint), device_param->kernel_params[27]);
2394 hc_clSetKernelArg (kernel, 28, sizeof (cl_uint), device_param->kernel_params[28]);
2395 hc_clSetKernelArg (kernel, 29, sizeof (cl_uint), device_param->kernel_params[29]);
2396 hc_clSetKernelArg (kernel, 30, sizeof (cl_uint), device_param->kernel_params[30]);
2397 hc_clSetKernelArg (kernel, 31, sizeof (cl_uint), device_param->kernel_params[31]);
2398
2399 if ((data.opts_type & OPTS_TYPE_PT_BITSLICE) && (data.attack_mode == ATTACK_MODE_BF))
2400 {
2401 const size_t global_work_size[3] = { num_elements, 32, 1 };
2402 const size_t local_work_size[3] = { gpu_threads / 32, 32, 1 };
2403
2404 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 2, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2405 }
2406 else
2407 {
2408 const size_t global_work_size[3] = { num_elements, 1, 1 };
2409 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2410
2411 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2412 }
2413
2414 hc_clFlush (device_param->command_queue);
2415
2416 hc_clFinish (device_param->command_queue);
2417
2418 #endif
2419 }
2420
2421 static void run_kernel_mp (const uint kern_run, hc_device_param_t *device_param, const uint num)
2422 {
2423 // uint gpu_vector_width = device_param->gpu_vector_width;
2424
2425 // uint num_elements = mydivc32 (num, gpu_vector_width);
2426
2427 uint num_elements = num;
2428
2429 switch (kern_run)
2430 {
2431 case KERN_RUN_MP: device_param->kernel_params_mp_buf32[8] = num; break;
2432 case KERN_RUN_MP_R: device_param->kernel_params_mp_r_buf32[8] = num; break;
2433 case KERN_RUN_MP_L: device_param->kernel_params_mp_l_buf32[9] = num; break;
2434 }
2435
2436 // causes problems with special threads like in bcrypt
2437 // const uint gpu_threads = device_param->gpu_threads;
2438
2439 #ifdef _CUDA
2440
2441 const uint gpu_threads = GPU_THREADS_NV;
2442
2443 while (num_elements % gpu_threads) num_elements++;
2444
2445 CUfunction function = NULL;
2446
2447 switch (kern_run)
2448 {
2449 case KERN_RUN_MP: function = device_param->function_mp; break;
2450 case KERN_RUN_MP_R: function = device_param->function_mp_r; break;
2451 case KERN_RUN_MP_L: function = device_param->function_mp_l; break;
2452 }
2453
2454 void **kernel_params = NULL;
2455
2456 switch (kern_run)
2457 {
2458 case KERN_RUN_MP: kernel_params = device_param->kernel_params_mp; break;
2459 case KERN_RUN_MP_R: kernel_params = device_param->kernel_params_mp_r; break;
2460 case KERN_RUN_MP_L: kernel_params = device_param->kernel_params_mp_l; break;
2461 }
2462
2463 num_elements /= gpu_threads;
2464
2465 hc_cuCtxPushCurrent (device_param->context);
2466
2467 hc_cuLaunchKernel (function, num_elements, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, kernel_params, NULL);
2468
2469 hc_cuStreamSynchronize (device_param->stream);
2470
2471 hc_cuCtxPopCurrent (&device_param->context);
2472
2473 #elif _OCL
2474
2475 const uint gpu_threads = GPU_THREADS_AMD;
2476
2477 while (num_elements % gpu_threads) num_elements++;
2478
2479 cl_kernel kernel = NULL;
2480
2481 switch (kern_run)
2482 {
2483 case KERN_RUN_MP: kernel = device_param->kernel_mp; break;
2484 case KERN_RUN_MP_R: kernel = device_param->kernel_mp_r; break;
2485 case KERN_RUN_MP_L: kernel = device_param->kernel_mp_l; break;
2486 }
2487
2488 switch (kern_run)
2489 {
2490 case KERN_RUN_MP: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp[3]);
2491 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp[4]);
2492 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp[5]);
2493 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp[6]);
2494 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp[7]);
2495 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp[8]);
2496 break;
2497 case KERN_RUN_MP_R: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_r[3]);
2498 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_r[4]);
2499 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_r[5]);
2500 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_r[6]);
2501 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_r[7]);
2502 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_r[8]);
2503 break;
2504 case KERN_RUN_MP_L: hc_clSetKernelArg (kernel, 3, sizeof (cl_ulong), device_param->kernel_params_mp_l[3]);
2505 hc_clSetKernelArg (kernel, 4, sizeof (cl_uint), device_param->kernel_params_mp_l[4]);
2506 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_mp_l[5]);
2507 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_mp_l[6]);
2508 hc_clSetKernelArg (kernel, 7, sizeof (cl_uint), device_param->kernel_params_mp_l[7]);
2509 hc_clSetKernelArg (kernel, 8, sizeof (cl_uint), device_param->kernel_params_mp_l[8]);
2510 hc_clSetKernelArg (kernel, 9, sizeof (cl_uint), device_param->kernel_params_mp_l[9]);
2511 break;
2512 }
2513
2514 const size_t global_work_size[3] = { num_elements, 1, 1 };
2515 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2516
2517 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2518
2519 hc_clFlush (device_param->command_queue);
2520
2521 hc_clFinish (device_param->command_queue);
2522
2523 #endif
2524 }
2525
2526 static void run_kernel_tb (hc_device_param_t *device_param, const uint num)
2527 {
2528 uint num_elements = num;
2529
2530 uint gpu_threads = device_param->gpu_threads;
2531
2532 while (num_elements % gpu_threads) num_elements++;
2533
2534 #ifdef _CUDA
2535
2536 CUfunction function = device_param->function_tb;
2537
2538 void **kernel_params = device_param->kernel_params_tb;
2539
2540 hc_cuCtxPushCurrent (device_param->context);
2541
2542 hc_cuLaunchKernel (function, num_elements / gpu_threads, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, kernel_params, NULL);
2543
2544 hc_cuStreamSynchronize (device_param->stream);
2545
2546 hc_cuCtxPopCurrent (&device_param->context);
2547
2548 #elif _OCL
2549
2550 cl_kernel kernel = device_param->kernel_tb;
2551
2552 const size_t global_work_size[3] = { num_elements, 1, 1 };
2553 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2554
2555 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2556
2557 hc_clFlush (device_param->command_queue);
2558
2559 hc_clFinish (device_param->command_queue);
2560
2561 #endif
2562 }
2563
2564 static void run_kernel_tm (hc_device_param_t *device_param)
2565 {
2566 const uint num_elements = 1024; // fixed
2567
2568 const uint gpu_threads = 32;
2569
2570 #ifdef _CUDA
2571
2572 CUfunction function = device_param->function_tm;
2573
2574 void **kernel_params = device_param->kernel_params_tm;
2575
2576 hc_cuCtxPushCurrent (device_param->context);
2577
2578 hc_cuLaunchKernel (function, num_elements / gpu_threads, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, kernel_params, NULL);
2579
2580 hc_cuStreamSynchronize (device_param->stream);
2581
2582 hc_cuCtxPopCurrent (&device_param->context);
2583
2584 #elif _OCL
2585
2586 cl_kernel kernel = device_param->kernel_tm;
2587
2588 const size_t global_work_size[3] = { num_elements, 1, 1 };
2589 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2590
2591 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2592
2593 hc_clFlush (device_param->command_queue);
2594
2595 hc_clFinish (device_param->command_queue);
2596
2597 #endif
2598 }
2599
2600 static void run_kernel_amp (hc_device_param_t *device_param, const uint num)
2601 {
2602 // uint gpu_vector_width = device_param->gpu_vector_width;
2603
2604 // uint num_elements = mydivc32 (num, gpu_vector_width);
2605
2606 uint num_elements = num;
2607
2608 device_param->kernel_params_amp_buf32[5] = data.combs_mode;
2609 device_param->kernel_params_amp_buf32[6] = num_elements;
2610
2611 // causes problems with special threads like in bcrypt
2612 // const uint gpu_threads = device_param->gpu_threads;
2613
2614 #ifdef _CUDA
2615
2616 const uint gpu_threads = GPU_THREADS_NV;
2617
2618 while (num_elements % gpu_threads) num_elements++;
2619
2620 CUfunction function = device_param->function_amp;
2621
2622 void **kernel_params = device_param->kernel_params_amp;
2623
2624 num_elements /= gpu_threads;
2625
2626 hc_cuCtxPushCurrent (device_param->context);
2627
2628 hc_cuLaunchKernel (function, num_elements, 1, 1, gpu_threads, 1, 1, 0, device_param->stream, kernel_params, NULL);
2629
2630 hc_cuStreamSynchronize (device_param->stream);
2631
2632 hc_cuCtxPopCurrent (&device_param->context);
2633
2634 #elif _OCL
2635
2636 const uint gpu_threads = GPU_THREADS_AMD;
2637
2638 while (num_elements % gpu_threads) num_elements++;
2639
2640 cl_kernel kernel = device_param->kernel_amp;
2641
2642 hc_clSetKernelArg (kernel, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]);
2643 hc_clSetKernelArg (kernel, 6, sizeof (cl_uint), device_param->kernel_params_amp[6]);
2644
2645 const size_t global_work_size[3] = { num_elements, 1, 1 };
2646 const size_t local_work_size[3] = { gpu_threads, 1, 1 };
2647
2648 hc_clEnqueueNDRangeKernel (device_param->command_queue, kernel, 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
2649
2650 hc_clFlush (device_param->command_queue);
2651
2652 hc_clFinish (device_param->command_queue);
2653
2654 #endif
2655 }
2656
2657 #ifdef _OCL
2658 static void run_kernel_bzero (hc_device_param_t *device_param, cl_mem buf, const uint size)
2659 {
2660 const cl_uchar zero = 0;
2661
2662 hc_clEnqueueFillBuffer (device_param->command_queue, buf, &zero, sizeof (cl_uchar), 0, size, 0, NULL, NULL);
2663 }
2664 #elif _CUDA
2665 static void run_kernel_bzero (hc_device_param_t *device_param, CUdeviceptr buf, const uint size)
2666 {
2667 hc_cuCtxPushCurrent (device_param->context);
2668
2669 hc_cuMemsetD8 (buf, 0, size);
2670
2671 hc_cuCtxPopCurrent (&device_param->context);
2672 }
2673 #endif
2674
2675 static int run_rule_engine (const int rule_len, const char *rule_buf)
2676 {
2677 if (rule_len == 0)
2678 {
2679 return 0;
2680 }
2681 else if (rule_len == 1)
2682 {
2683 if (rule_buf[0] == RULE_OP_MANGLE_NOOP) return 0;
2684 }
2685
2686 return 1;
2687 }
2688
2689 static void run_copy (hc_device_param_t *device_param, const uint pws_cnt)
2690 {
2691 #ifdef _CUDA
2692 hc_cuCtxPushCurrent (device_param->context);
2693 #endif
2694
2695 // clear some leftovers from previous run (maskfiles, etc)
2696
2697 #ifdef _CUDA
2698 if (device_param->c_bfs != 0) // should be only true in this specific case: if (data.attack_kern == ATTACK_KERN_BF)
2699 {
2700 hc_cuMemsetD8 (device_param->c_bfs, 0, device_param->c_bytes);
2701 }
2702 #endif
2703
2704 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
2705 {
2706 #ifdef _CUDA
2707 hc_cuMemcpyHtoD (device_param->d_pws_buf, device_param->pws_buf, pws_cnt * sizeof (pw_t));
2708 #elif _OCL
2709 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
2710 #endif
2711 }
2712 else if (data.attack_kern == ATTACK_KERN_COMBI)
2713 {
2714 #ifdef _CUDA
2715 hc_cuMemcpyHtoD (device_param->d_pws_buf, device_param->pws_buf, pws_cnt * sizeof (pw_t));
2716 #elif _OCL
2717 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
2718 #endif
2719 }
2720 else if (data.attack_kern == ATTACK_KERN_BF)
2721 {
2722 const uint64_t off = device_param->words_off;
2723
2724 device_param->kernel_params_mp_l_buf64[3] = off;
2725
2726 run_kernel_mp (KERN_RUN_MP_L, device_param, pws_cnt);
2727 }
2728
2729 #ifdef _CUDA
2730 hc_cuCtxPopCurrent (&device_param->context);
2731 #endif
2732 }
2733
2734 static void run_cracker (hc_device_param_t *device_param, const uint pw_cnt, const uint pws_cnt)
2735 {
2736 const uint gpu_loops = data.gpu_loops;
2737
2738 // init speed timer
2739
2740 uint speed_pos = device_param->speed_pos;
2741
2742 #ifdef _POSIX
2743 if (device_param->timer_speed.tv_sec == 0)
2744 {
2745 hc_timer_set (&device_param->timer_speed);
2746 }
2747 #endif
2748
2749 #ifdef _WIN
2750 if (device_param->timer_speed.QuadPart == 0)
2751 {
2752 hc_timer_set (&device_param->timer_speed);
2753 }
2754 #endif
2755
2756 // find higest password length, this is for optimization stuff
2757
2758 uint highest_pw_len = 0;
2759
2760 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
2761 {
2762 }
2763 else if (data.attack_kern == ATTACK_KERN_COMBI)
2764 {
2765 }
2766 else if (data.attack_kern == ATTACK_KERN_BF)
2767 {
2768 highest_pw_len = device_param->kernel_params_mp_l_buf32[4]
2769 + device_param->kernel_params_mp_l_buf32[5];
2770 }
2771
2772 // bitslice optimization stuff
2773
2774 if (data.attack_mode == ATTACK_MODE_BF)
2775 {
2776 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
2777 {
2778 run_kernel_tb (device_param, pws_cnt);
2779 }
2780 }
2781
2782 // iteration type
2783
2784 uint innerloop_step = 0;
2785 uint innerloop_cnt = 0;
2786
2787 if (data.attack_exec == ATTACK_EXEC_ON_GPU) innerloop_step = gpu_loops;
2788 else innerloop_step = 1;
2789
2790 if (data.attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = data.gpu_rules_cnt;
2791 else if (data.attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = data.combs_cnt;
2792 else if (data.attack_kern == ATTACK_KERN_BF) innerloop_cnt = data.bfs_cnt;
2793
2794 // loop start: most outer loop = salt iteration, then innerloops (if multi)
2795
2796 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
2797 {
2798 while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
2799
2800 if (data.devices_status == STATUS_CRACKED) break;
2801 if (data.devices_status == STATUS_ABORTED) break;
2802 if (data.devices_status == STATUS_QUIT) break;
2803 if (data.devices_status == STATUS_BYPASS) break;
2804
2805 if (data.salts_shown[salt_pos] == 1) continue;
2806
2807 salt_t *salt_buf = &data.salts_buf[salt_pos];
2808
2809 device_param->kernel_params_buf32[24] = salt_pos;
2810 device_param->kernel_params_buf32[28] = salt_buf->digests_cnt;
2811 device_param->kernel_params_buf32[29] = salt_buf->digests_offset;
2812
2813 FILE *combs_fp = device_param->combs_fp;
2814
2815 if (data.attack_mode == ATTACK_MODE_COMBI)
2816 {
2817 rewind (combs_fp);
2818 }
2819
2820 // innerloops
2821
2822 for (uint innerloop_pos = 0; innerloop_pos < innerloop_cnt; innerloop_pos += innerloop_step)
2823 {
2824 while (data.devices_status == STATUS_PAUSED) hc_sleep (1);
2825
2826 if (data.devices_status == STATUS_CRACKED) break;
2827 if (data.devices_status == STATUS_ABORTED) break;
2828 if (data.devices_status == STATUS_QUIT) break;
2829 if (data.devices_status == STATUS_BYPASS) break;
2830
2831 uint innerloop_left = innerloop_cnt - innerloop_pos;
2832
2833 if (innerloop_left > innerloop_step) innerloop_left = innerloop_step;
2834
2835 device_param->innerloop_pos = innerloop_pos;
2836 device_param->innerloop_left = innerloop_left;
2837
2838 device_param->kernel_params_buf32[27] = innerloop_left;
2839
2840 if (innerloop_left == 0) continue;
2841
2842 // initialize amplifiers
2843
2844 if (data.attack_mode == ATTACK_MODE_COMBI)
2845 {
2846 char line_buf[BUFSIZ];
2847
2848 uint i = 0;
2849
2850 while (i < innerloop_left)
2851 {
2852 if (feof (combs_fp)) break;
2853
2854 int line_len = fgetl (combs_fp, line_buf);
2855
2856 if (line_len >= PW_MAX1) continue;
2857
2858 line_len = convert_from_hex (line_buf, line_len);
2859
2860 char *line_buf_new = line_buf;
2861
2862 if (run_rule_engine (data.rule_len_r, data.rule_buf_r))
2863 {
2864 char rule_buf_out[BLOCK_SIZE];
2865
2866 memset (rule_buf_out, 0, sizeof (rule_buf_out));
2867
2868 int rule_len_out = _old_apply_rule (data.rule_buf_r, data.rule_len_r, line_buf, line_len, rule_buf_out);
2869
2870 if (rule_len_out < 0)
2871 {
2872 data.words_progress_rejected[salt_pos] += pw_cnt;
2873
2874 continue;
2875 }
2876
2877 line_len = rule_len_out;
2878
2879 line_buf_new = rule_buf_out;
2880 }
2881
2882 line_len = MIN (line_len, PW_DICTMAX);
2883
2884 char *ptr = (char *) device_param->combs_buf[i].i;
2885
2886 memcpy (ptr, line_buf_new, line_len);
2887
2888 memset (ptr + line_len, 0, PW_DICTMAX1 - line_len);
2889
2890 if (data.opts_type & OPTS_TYPE_PT_UPPER)
2891 {
2892 uppercase (ptr, line_len);
2893 }
2894
2895 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
2896 {
2897 if (data.opts_type & OPTS_TYPE_PT_ADD80)
2898 {
2899 ptr[line_len] = 0x80;
2900 }
2901
2902 if (data.opts_type & OPTS_TYPE_PT_ADD01)
2903 {
2904 ptr[line_len] = 0x01;
2905 }
2906 }
2907
2908 device_param->combs_buf[i].pw_len = line_len;
2909
2910 i++;
2911 }
2912
2913 for (uint j = i; j < innerloop_left; j++)
2914 {
2915 device_param->combs_buf[j].i[0] = 0;
2916 device_param->combs_buf[j].i[1] = 0;
2917 device_param->combs_buf[j].i[2] = 0;
2918 device_param->combs_buf[j].i[3] = 0;
2919 device_param->combs_buf[j].i[4] = 0;
2920 device_param->combs_buf[j].i[5] = 0;
2921 device_param->combs_buf[j].i[6] = 0;
2922 device_param->combs_buf[j].i[7] = 0;
2923
2924 device_param->combs_buf[j].pw_len = 0;
2925 }
2926
2927 innerloop_left = i;
2928 }
2929 else if (data.attack_mode == ATTACK_MODE_BF)
2930 {
2931 uint64_t off = innerloop_pos;
2932
2933 device_param->kernel_params_mp_r_buf64[3] = off;
2934
2935 const uint gpu_vector_width = device_param->gpu_vector_width;
2936
2937 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2938
2939 run_kernel_mp (KERN_RUN_MP_R, device_param, innerloop_left_d);
2940 }
2941 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
2942 {
2943 uint64_t off = innerloop_pos;
2944
2945 device_param->kernel_params_mp_buf64[3] = off;
2946
2947 const uint gpu_vector_width = device_param->gpu_vector_width;
2948
2949 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2950
2951 run_kernel_mp (KERN_RUN_MP, device_param, innerloop_left_d);
2952 }
2953 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
2954 {
2955 uint64_t off = innerloop_pos;
2956
2957 device_param->kernel_params_mp_buf64[3] = off;
2958
2959 const uint gpu_vector_width = device_param->gpu_vector_width;
2960
2961 const uint innerloop_left_d = mydivc32 (innerloop_left, gpu_vector_width);
2962
2963 run_kernel_mp (KERN_RUN_MP, device_param, innerloop_left_d);
2964 }
2965
2966 // copy amplifiers
2967
2968 #ifdef _CUDA
2969 hc_cuCtxPushCurrent (device_param->context);
2970
2971 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
2972 {
2973 hc_cuMemcpyDtoD (device_param->c_rules, device_param->d_rules + (innerloop_pos * sizeof (gpu_rule_t)), innerloop_left * sizeof (gpu_rule_t));
2974 }
2975 else if (data.attack_mode == ATTACK_MODE_COMBI)
2976 {
2977 hc_cuMemcpyHtoD (device_param->c_combs, device_param->combs_buf, innerloop_left * sizeof (comb_t));
2978 }
2979 else if (data.attack_mode == ATTACK_MODE_BF)
2980 {
2981 hc_cuMemcpyDtoD (device_param->c_bfs, device_param->d_bfs, innerloop_left * sizeof (bf_t));
2982 }
2983 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
2984 {
2985 hc_cuMemcpyDtoD (device_param->c_combs, device_param->d_combs, innerloop_left * sizeof (comb_t));
2986 }
2987 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
2988 {
2989 hc_cuMemcpyDtoD (device_param->c_combs, device_param->d_combs, innerloop_left * sizeof (comb_t));
2990 }
2991
2992 hc_cuCtxPopCurrent (&device_param->context);
2993
2994 #elif _OCL
2995 if (data.attack_mode == ATTACK_MODE_STRAIGHT)
2996 {
2997 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);
2998 }
2999 else if (data.attack_mode == ATTACK_MODE_COMBI)
3000 {
3001 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);
3002 }
3003 else if (data.attack_mode == ATTACK_MODE_BF)
3004 {
3005 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);
3006 }
3007 else if (data.attack_mode == ATTACK_MODE_HYBRID1)
3008 {
3009 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);
3010 }
3011 else if (data.attack_mode == ATTACK_MODE_HYBRID2)
3012 {
3013 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (comb_t), 0, NULL, NULL);
3014 }
3015
3016 #endif
3017
3018 if (data.attack_exec == ATTACK_EXEC_ON_GPU)
3019 {
3020 if (data.attack_mode == ATTACK_MODE_BF)
3021 {
3022 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
3023 {
3024 const uint size_tm = 32 * sizeof (bs_word_t);
3025
3026 #ifdef _CUDA
3027 run_kernel_bzero (device_param, device_param->d_tm, size_tm);
3028 #elif _OCL
3029 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
3030 #endif
3031
3032 run_kernel_tm (device_param);
3033
3034 #ifdef _CUDA
3035 hc_cuCtxPushCurrent (device_param->context);
3036
3037 hc_cuMemcpyDtoD (device_param->c_tm, device_param->d_tm, size_tm);
3038
3039 hc_cuCtxPopCurrent (&device_param->context);
3040 #elif _OCL
3041 hc_clEnqueueCopyBuffer (device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL);
3042 #endif
3043 }
3044 }
3045
3046 if (highest_pw_len < 16)
3047 {
3048 run_kernel (KERN_RUN_1, device_param, pws_cnt);
3049 }
3050 else if (highest_pw_len < 32)
3051 {
3052 run_kernel (KERN_RUN_2, device_param, pws_cnt);
3053 }
3054 else
3055 {
3056 run_kernel (KERN_RUN_3, device_param, pws_cnt);
3057 }
3058 }
3059 else
3060 {
3061 run_kernel_amp (device_param, pws_cnt);
3062
3063 run_kernel (KERN_RUN_1, device_param, pws_cnt);
3064
3065 if (data.opts_type & OPTS_TYPE_HOOK12)
3066 {
3067 run_kernel (KERN_RUN_12, device_param, pws_cnt);
3068 }
3069
3070 uint iter = salt_buf->salt_iter;
3071
3072 for (uint loop_pos = 0; loop_pos < iter; loop_pos += gpu_loops)
3073 {
3074 uint loop_left = iter - loop_pos;
3075
3076 loop_left = MIN (loop_left, gpu_loops);
3077
3078 device_param->kernel_params_buf32[25] = loop_pos;
3079 device_param->kernel_params_buf32[26] = loop_left;
3080
3081 run_kernel (KERN_RUN_2, device_param, pws_cnt);
3082
3083 if (data.devices_status == STATUS_CRACKED) break;
3084 if (data.devices_status == STATUS_ABORTED) break;
3085 if (data.devices_status == STATUS_QUIT) break;
3086 }
3087
3088 if (data.opts_type & OPTS_TYPE_HOOK23)
3089 {
3090 run_kernel (KERN_RUN_23, device_param, pws_cnt);
3091
3092 #ifdef _CUDA
3093 hc_cuCtxPushCurrent (device_param->context);
3094
3095 hc_cuMemcpyDtoH (device_param->hooks_buf, device_param->d_hooks, device_param->size_hooks);
3096
3097 hc_cuCtxPopCurrent (&device_param->context);
3098 #elif _OCL
3099 hc_clEnqueueReadBuffer (device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL);
3100 #endif
3101
3102 // do something with data
3103
3104
3105 #ifdef _CUDA
3106 hc_cuCtxPushCurrent (device_param->context);
3107
3108 hc_cuMemcpyHtoD (device_param->d_hooks, device_param->hooks_buf, device_param->size_hooks);
3109
3110 hc_cuCtxPopCurrent (&device_param->context);
3111 #elif _OCL
3112 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL);
3113 #endif
3114 }
3115
3116 run_kernel (KERN_RUN_3, device_param, pws_cnt);
3117 }
3118
3119 if (data.devices_status == STATUS_CRACKED) break;
3120 if (data.devices_status == STATUS_ABORTED) break;
3121 if (data.devices_status == STATUS_QUIT) break;
3122
3123 /**
3124 * result
3125 */
3126
3127 hc_thread_mutex_lock (mux_display);
3128
3129 check_cracked (device_param, salt_pos);
3130
3131 hc_thread_mutex_unlock (mux_display);
3132
3133 /**
3134 * progress
3135 */
3136
3137 uint64_t perf_sum_all = (uint64_t) pw_cnt * (uint64_t) innerloop_left;
3138
3139 hc_thread_mutex_lock (mux_counter);
3140
3141 data.words_progress_done[salt_pos] += perf_sum_all;
3142
3143 hc_thread_mutex_unlock (mux_counter);
3144
3145 /**
3146 * speed
3147 */
3148
3149 float speed_ms;
3150
3151 hc_timer_get (device_param->timer_speed, speed_ms);
3152
3153 hc_timer_set (&device_param->timer_speed);
3154
3155 hc_thread_mutex_lock (mux_display);
3156
3157 device_param->speed_cnt[speed_pos] = perf_sum_all;
3158
3159 device_param->speed_ms[speed_pos] = speed_ms;
3160
3161 device_param->speed_rec[speed_pos] = device_param->timer_speed;
3162
3163 hc_thread_mutex_unlock (mux_display);
3164
3165 speed_pos++;
3166
3167 if (speed_pos == SPEED_CACHE)
3168 {
3169 speed_pos = 0;
3170 }
3171 }
3172 }
3173
3174 device_param->speed_pos = speed_pos;
3175 }
3176
3177 static void load_segment (wl_data_t *wl_data, FILE *fd)
3178 {
3179 // NOTE: use (never changing) ->incr here instead of ->avail otherwise the buffer gets bigger and bigger
3180
3181 wl_data->pos = 0;
3182
3183 wl_data->cnt = fread (wl_data->buf, 1, wl_data->incr - 1000, fd);
3184
3185 wl_data->buf[wl_data->cnt] = 0;
3186
3187 if (wl_data->cnt == 0) return;
3188
3189 if (wl_data->buf[wl_data->cnt - 1] == '\n') return;
3190
3191 while (!feof (fd))
3192 {
3193 if (wl_data->cnt == wl_data->avail)
3194 {
3195 wl_data->buf = (char *) myrealloc (wl_data->buf, wl_data->avail, wl_data->incr);
3196
3197 wl_data->avail += wl_data->incr;
3198 }
3199
3200 const int c = fgetc (fd);
3201
3202 if (c == EOF) break;
3203
3204 wl_data->buf[wl_data->cnt] = (char) c;
3205
3206 wl_data->cnt++;
3207
3208 if (c == '\n') break;
3209 }
3210
3211 // ensure stream ends with a newline
3212
3213 if (wl_data->buf[wl_data->cnt - 1] != '\n')
3214 {
3215 wl_data->cnt++;
3216
3217 wl_data->buf[wl_data->cnt - 1] = '\n';
3218 }
3219
3220 return;
3221 }
3222
3223 static void get_next_word_lm (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3224 {
3225 char *ptr = buf;
3226
3227 for (uint32_t i = 0; i < sz; i++, ptr++)
3228 {
3229 if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
3230
3231 if (i == 7)
3232 {
3233 *off = i;
3234 *len = i;
3235
3236 return;
3237 }
3238
3239 if (*ptr != '\n') continue;
3240
3241 *off = i + 1;
3242
3243 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3244
3245 *len = i;
3246
3247 return;
3248 }
3249
3250 *off = sz;
3251 *len = sz;
3252 }
3253
3254 static void get_next_word_uc (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3255 {
3256 char *ptr = buf;
3257
3258 for (uint32_t i = 0; i < sz; i++, ptr++)
3259 {
3260 if (*ptr >= 'a' && *ptr <= 'z') *ptr -= 0x20;
3261
3262 if (*ptr != '\n') continue;
3263
3264 *off = i + 1;
3265
3266 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3267
3268 *len = i;
3269
3270 return;
3271 }
3272
3273 *off = sz;
3274 *len = sz;
3275 }
3276
3277 static void get_next_word_std (char *buf, uint32_t sz, uint32_t *len, uint32_t *off)
3278 {
3279 char *ptr = buf;
3280
3281 for (uint32_t i = 0; i < sz; i++, ptr++)
3282 {
3283 if (*ptr != '\n') continue;
3284
3285 *off = i + 1;
3286
3287 if ((i > 0) && (buf[i - 1] == '\r')) i--;
3288
3289 *len = i;
3290
3291 return;
3292 }
3293
3294 *off = sz;
3295 *len = sz;
3296 }
3297
3298 static void get_next_word (wl_data_t *wl_data, FILE *fd, char **out_buf, uint *out_len)
3299 {
3300 while (wl_data->pos < wl_data->cnt)
3301 {
3302 uint off;
3303 uint len;
3304
3305 char *ptr = wl_data->buf + wl_data->pos;
3306
3307 get_next_word_func (ptr, wl_data->cnt - wl_data->pos, &len, &off);
3308
3309 wl_data->pos += off;
3310
3311 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3312 {
3313 char rule_buf_out[BLOCK_SIZE];
3314
3315 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3316
3317 int rule_len_out = -1;
3318
3319 if (len < BLOCK_SIZE)
3320 {
3321 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, ptr, len, rule_buf_out);
3322 }
3323
3324 if (rule_len_out < 0)
3325 {
3326 continue;
3327 }
3328
3329 if (rule_len_out > PW_MAX)
3330 {
3331 continue;
3332 }
3333 }
3334 else
3335 {
3336 if (len > PW_MAX)
3337 {
3338 continue;
3339 }
3340 }
3341
3342 *out_buf = ptr;
3343 *out_len = len;
3344
3345 return;
3346 }
3347
3348 if (feof (fd))
3349 {
3350 fprintf (stderr, "bug!!\n");
3351
3352 return;
3353 }
3354
3355 load_segment (wl_data, fd);
3356
3357 get_next_word (wl_data, fd, out_buf, out_len);
3358 }
3359
3360 #ifdef _POSIX
3361 static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, size_t *dictstat_nmemb)
3362 #endif
3363
3364 #ifdef _WIN
3365 static uint64_t count_words (wl_data_t *wl_data, FILE *fd, char *dictfile, dictstat_t *dictstat_base, uint *dictstat_nmemb)
3366 #endif
3367 {
3368 hc_signal (NULL);
3369
3370 dictstat_t d;
3371
3372 d.cnt = 0;
3373
3374 #ifdef _POSIX
3375 fstat (fileno (fd), &d.stat);
3376 #endif
3377
3378 #ifdef _WIN
3379 _fstat64 (fileno (fd), &d.stat);
3380 #endif
3381
3382 d.stat.st_mode = 0;
3383 d.stat.st_nlink = 0;
3384 d.stat.st_uid = 0;
3385 d.stat.st_gid = 0;
3386 d.stat.st_rdev = 0;
3387 d.stat.st_atime = 0;
3388
3389 #ifdef _POSIX
3390 d.stat.st_blksize = 0;
3391 d.stat.st_blocks = 0;
3392 #endif
3393
3394 if (d.stat.st_size == 0) return 0;
3395
3396 dictstat_t *d_cache = (dictstat_t *) lfind (&d, dictstat_base, dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
3397
3398 if (run_rule_engine (data.rule_len_l, data.rule_buf_l) == 0)
3399 {
3400 if (d_cache)
3401 {
3402 uint64_t cnt = d_cache->cnt;
3403
3404 uint64_t keyspace = cnt;
3405
3406 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
3407 {
3408 keyspace *= data.gpu_rules_cnt;
3409 }
3410 else if (data.attack_kern == ATTACK_KERN_COMBI)
3411 {
3412 keyspace *= data.combs_cnt;
3413 }
3414
3415 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);
3416 if (data.quiet == 0) log_info ("");
3417
3418 hc_signal (sigHandler_default);
3419
3420 return (keyspace);
3421 }
3422 }
3423
3424 time_t now = 0;
3425 time_t prev = 0;
3426
3427 uint64_t comp = 0;
3428 uint64_t cnt = 0;
3429 uint64_t cnt2 = 0;
3430
3431 while (!feof (fd))
3432 {
3433 load_segment (wl_data, fd);
3434
3435 comp += wl_data->cnt;
3436
3437 uint32_t i = 0;
3438
3439 while (i < wl_data->cnt)
3440 {
3441 uint32_t len;
3442 uint32_t off;
3443
3444 get_next_word_func (wl_data->buf + i, wl_data->cnt - i, &len, &off);
3445
3446 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
3447 {
3448 char rule_buf_out[BLOCK_SIZE];
3449
3450 memset (rule_buf_out, 0, sizeof (rule_buf_out));
3451
3452 int rule_len_out = -1;
3453
3454 if (len < BLOCK_SIZE)
3455 {
3456 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, wl_data->buf + i, len, rule_buf_out);
3457 }
3458
3459 if (rule_len_out < 0)
3460 {
3461 len = PW_MAX1;
3462 }
3463 else
3464 {
3465 len = rule_len_out;
3466 }
3467 }
3468
3469 if (len < PW_MAX1)
3470 {
3471 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
3472 {
3473 cnt += data.gpu_rules_cnt;
3474 }
3475 else if (data.attack_kern == ATTACK_KERN_COMBI)
3476 {
3477 cnt += data.combs_cnt;
3478 }
3479
3480 d.cnt++;
3481 }
3482
3483 i += off;
3484
3485 cnt2++;
3486 }
3487
3488 time (&now);
3489
3490 if ((now - prev) == 0) continue;
3491
3492 float percent = (float) comp / (float) d.stat.st_size;
3493
3494 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);
3495
3496 time (&prev);
3497 }
3498
3499 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);
3500 if (data.quiet == 0) log_info ("");
3501
3502 lsearch (&d, dictstat_base, dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
3503
3504 hc_signal (sigHandler_default);
3505
3506 return (cnt);
3507 }
3508
3509 static uint get_gpu_vector_width (const uint hash_mode, const uint attack_mode, const uint attack_exec, const uint opti_type, const uint vliw)
3510 {
3511 uint gpu_vector_width = 0;
3512
3513 if ((attack_mode == ATTACK_MODE_BF) && (attack_exec == ATTACK_EXEC_ON_GPU) && (opti_type & OPTI_TYPE_SCALAR_MODE))
3514 {
3515 return VECT_SIZE_1;
3516 }
3517
3518 #ifdef _CUDA
3519 if ((attack_mode == ATTACK_MODE_STRAIGHT) && (attack_exec == ATTACK_EXEC_ON_GPU))
3520 {
3521 return VECT_SIZE_1;
3522 }
3523
3524 if (vliw == 1)
3525 {
3526 switch (hash_mode)
3527 {
3528 default: gpu_vector_width = VECT_SIZE_1; break;
3529 }
3530 }
3531 else if (vliw == 2)
3532 {
3533 switch (hash_mode)
3534 {
3535 case 0: gpu_vector_width = VECT_SIZE_4; break;
3536 case 10: gpu_vector_width = VECT_SIZE_4; break;
3537 case 11: gpu_vector_width = VECT_SIZE_4; break;
3538 case 12: gpu_vector_width = VECT_SIZE_4; break;
3539 case 20: gpu_vector_width = VECT_SIZE_4; break;
3540 case 21: gpu_vector_width = VECT_SIZE_4; break;
3541 case 22: gpu_vector_width = VECT_SIZE_4; break;
3542 case 23: gpu_vector_width = VECT_SIZE_4; break;
3543 case 30: gpu_vector_width = VECT_SIZE_4; break;
3544 case 40: gpu_vector_width = VECT_SIZE_4; break;
3545 case 50: gpu_vector_width = VECT_SIZE_4; break;
3546 case 60: gpu_vector_width = VECT_SIZE_4; break;
3547 case 100: gpu_vector_width = VECT_SIZE_4; break;
3548 case 101: gpu_vector_width = VECT_SIZE_4; break;
3549 case 110: gpu_vector_width = VECT_SIZE_4; break;
3550 case 111: gpu_vector_width = VECT_SIZE_4; break;
3551 case 112: gpu_vector_width = VECT_SIZE_4; break;
3552 case 120: gpu_vector_width = VECT_SIZE_4; break;
3553 case 121: gpu_vector_width = VECT_SIZE_4; break;
3554 case 122: gpu_vector_width = VECT_SIZE_4; break;
3555 case 124: gpu_vector_width = VECT_SIZE_4; break;
3556 case 130: gpu_vector_width = VECT_SIZE_4; break;
3557 case 131: gpu_vector_width = VECT_SIZE_4; break;
3558 case 132: gpu_vector_width = VECT_SIZE_4; break;
3559 case 133: gpu_vector_width = VECT_SIZE_4; break;
3560 case 140: gpu_vector_width = VECT_SIZE_4; break;
3561 case 141: gpu_vector_width = VECT_SIZE_4; break;
3562 case 150: gpu_vector_width = VECT_SIZE_4; break;
3563 case 160: gpu_vector_width = VECT_SIZE_4; break;
3564 case 190: gpu_vector_width = VECT_SIZE_4; break;
3565 case 200: gpu_vector_width = VECT_SIZE_4; break;
3566 case 400: gpu_vector_width = VECT_SIZE_2; break;
3567 case 500: gpu_vector_width = VECT_SIZE_2; break;
3568 case 501: gpu_vector_width = VECT_SIZE_2; break;
3569 case 900: gpu_vector_width = VECT_SIZE_4; break;
3570 case 1000: gpu_vector_width = VECT_SIZE_4; break;
3571 case 1100: gpu_vector_width = VECT_SIZE_4; break;
3572 case 2400: gpu_vector_width = VECT_SIZE_4; break;
3573 case 2410: gpu_vector_width = VECT_SIZE_4; break;
3574 case 2600: gpu_vector_width = VECT_SIZE_4; break;
3575 case 2611: gpu_vector_width = VECT_SIZE_4; break;
3576 case 2612: gpu_vector_width = VECT_SIZE_4; break;
3577 case 2711: gpu_vector_width = VECT_SIZE_4; break;
3578 case 2811: gpu_vector_width = VECT_SIZE_4; break;
3579 case 3710: gpu_vector_width = VECT_SIZE_4; break;
3580 case 3800: gpu_vector_width = VECT_SIZE_4; break;
3581 case 3711: gpu_vector_width = VECT_SIZE_4; break;
3582 case 4300: gpu_vector_width = VECT_SIZE_4; break;
3583 case 4800: gpu_vector_width = VECT_SIZE_4; break;
3584 case 4900: gpu_vector_width = VECT_SIZE_4; break;
3585 case 5100: gpu_vector_width = VECT_SIZE_4; break;
3586 case 9900: gpu_vector_width = VECT_SIZE_4; break;
3587 case 10200: gpu_vector_width = VECT_SIZE_4; break;
3588 case 11000: gpu_vector_width = VECT_SIZE_4; break;
3589 case 11500: gpu_vector_width = VECT_SIZE_4; break;
3590
3591 default: gpu_vector_width = VECT_SIZE_1; break;
3592 }
3593 }
3594 #endif
3595
3596 #ifdef _OCL
3597 if (vliw == 1)
3598 {
3599 switch (hash_mode)
3600 {
3601 default: gpu_vector_width = VECT_SIZE_1; break;
3602 }
3603 }
3604 else if (vliw == 4)
3605 {
3606 switch (hash_mode)
3607 {
3608 case 150: gpu_vector_width = VECT_SIZE_2; break;
3609 case 160: gpu_vector_width = VECT_SIZE_2; break;
3610 case 300: gpu_vector_width = VECT_SIZE_2; break;
3611 case 1400: gpu_vector_width = VECT_SIZE_2; break;
3612 case 1410: gpu_vector_width = VECT_SIZE_2; break;
3613 case 1420: gpu_vector_width = VECT_SIZE_2; break;
3614 case 1421: gpu_vector_width = VECT_SIZE_2; break;
3615 case 1430: gpu_vector_width = VECT_SIZE_2; break;
3616 case 1440: gpu_vector_width = VECT_SIZE_2; break;
3617 case 1441: gpu_vector_width = VECT_SIZE_2; break;
3618 case 1450: gpu_vector_width = VECT_SIZE_1; break;
3619 case 1460: gpu_vector_width = VECT_SIZE_2; break;
3620 case 1500: gpu_vector_width = VECT_SIZE_1; break;
3621 case 1700: gpu_vector_width = VECT_SIZE_1; break;
3622 case 1710: gpu_vector_width = VECT_SIZE_1; break;
3623 case 1711: gpu_vector_width = VECT_SIZE_1; break;
3624 case 1720: gpu_vector_width = VECT_SIZE_1; break;
3625 case 1722: gpu_vector_width = VECT_SIZE_1; break;
3626 case 1730: gpu_vector_width = VECT_SIZE_1; break;
3627 case 1731: gpu_vector_width = VECT_SIZE_1; break;
3628 case 1740: gpu_vector_width = VECT_SIZE_1; break;
3629 case 1750: gpu_vector_width = VECT_SIZE_1; break;
3630 case 1760: gpu_vector_width = VECT_SIZE_1; break;
3631 case 1800: gpu_vector_width = VECT_SIZE_1; break;
3632 case 2100: gpu_vector_width = VECT_SIZE_2; break;
3633 case 2500: gpu_vector_width = VECT_SIZE_2; break;
3634 case 3000: gpu_vector_width = VECT_SIZE_1; break;
3635 case 3100: gpu_vector_width = VECT_SIZE_2; break;
3636 case 3200: gpu_vector_width = VECT_SIZE_1; break;
3637 case 5000: gpu_vector_width = VECT_SIZE_1; break;
3638 case 5200: gpu_vector_width = VECT_SIZE_2; break;
3639 case 5600: gpu_vector_width = VECT_SIZE_2; break;
3640 case 5700: gpu_vector_width = VECT_SIZE_2; break;
3641 case 6100: gpu_vector_width = VECT_SIZE_2; break;
3642 case 6211:
3643 case 6212:
3644 case 6213:
3645 case 6221:
3646 case 6222:
3647 case 6223:
3648 case 6231:
3649 case 6232:
3650 case 6233:
3651 case 6241:
3652 case 6242:
3653 case 6243: gpu_vector_width = VECT_SIZE_1; break;
3654 case 6400: gpu_vector_width = VECT_SIZE_1; break;
3655 case 6500: gpu_vector_width = VECT_SIZE_1; break;
3656 case 6600: gpu_vector_width = VECT_SIZE_1; break;
3657 case 6700: gpu_vector_width = VECT_SIZE_2; break;
3658 case 6800: gpu_vector_width = VECT_SIZE_1; break;
3659 case 6900: gpu_vector_width = VECT_SIZE_1; break;
3660 case 7100: gpu_vector_width = VECT_SIZE_1; break;
3661 case 7200: gpu_vector_width = VECT_SIZE_1; break;
3662 case 7300: gpu_vector_width = VECT_SIZE_1; break;
3663 case 7400: gpu_vector_width = VECT_SIZE_1; break;
3664 case 7500: gpu_vector_width = VECT_SIZE_1; break;
3665 case 7700: gpu_vector_width = VECT_SIZE_1; break;
3666 case 7800: gpu_vector_width = VECT_SIZE_1; break;
3667 case 7900: gpu_vector_width = VECT_SIZE_1; break;
3668 case 8000: gpu_vector_width = VECT_SIZE_2; break;
3669 case 8200: gpu_vector_width = VECT_SIZE_1; break;
3670 case 8500: gpu_vector_width = VECT_SIZE_2; break;
3671 case 8700: gpu_vector_width = VECT_SIZE_2; break;
3672 case 8800: gpu_vector_width = VECT_SIZE_1; break;
3673 case 8900: gpu_vector_width = VECT_SIZE_1; break;
3674 case 9000: gpu_vector_width = VECT_SIZE_1; break;
3675 case 9100: gpu_vector_width = VECT_SIZE_1; break;
3676 case 9200: gpu_vector_width = VECT_SIZE_1; break;
3677 case 9300: gpu_vector_width = VECT_SIZE_1; break;
3678 case 9400: gpu_vector_width = VECT_SIZE_1; break;
3679 case 9500: gpu_vector_width = VECT_SIZE_1; break;
3680 case 9600: gpu_vector_width = VECT_SIZE_1; break;
3681 case 9700: gpu_vector_width = VECT_SIZE_1; break;
3682 case 9710: gpu_vector_width = VECT_SIZE_1; break;
3683 case 9720: gpu_vector_width = VECT_SIZE_2; break;
3684 case 9800: gpu_vector_width = VECT_SIZE_1; break;
3685 case 9810: gpu_vector_width = VECT_SIZE_1; break;
3686 case 9820: gpu_vector_width = VECT_SIZE_2; break;
3687 case 10000: gpu_vector_width = VECT_SIZE_1; break;
3688 case 10100: gpu_vector_width = VECT_SIZE_1; break;
3689 case 10400: gpu_vector_width = VECT_SIZE_1; break;
3690 case 10410: gpu_vector_width = VECT_SIZE_1; break;
3691 case 10420: gpu_vector_width = VECT_SIZE_2; break;
3692 case 10500: gpu_vector_width = VECT_SIZE_1; break;
3693 case 10600: gpu_vector_width = VECT_SIZE_2; break;
3694 case 10700: gpu_vector_width = VECT_SIZE_1; break;
3695 case 10800: gpu_vector_width = VECT_SIZE_1; break;
3696 case 10900: gpu_vector_width = VECT_SIZE_1; break;
3697 case 11100: gpu_vector_width = VECT_SIZE_2; break;
3698 case 11200: gpu_vector_width = VECT_SIZE_2; break;
3699 case 11300: gpu_vector_width = VECT_SIZE_1; break;
3700 case 11400: gpu_vector_width = VECT_SIZE_1; break;
3701 case 11600: gpu_vector_width = VECT_SIZE_1; break;
3702 case 11700: gpu_vector_width = VECT_SIZE_1; break;
3703 case 11800: gpu_vector_width = VECT_SIZE_1; break;
3704 case 11900: gpu_vector_width = VECT_SIZE_1; break;
3705 case 12000: gpu_vector_width = VECT_SIZE_1; break;
3706 case 12100: gpu_vector_width = VECT_SIZE_1; break;
3707 case 12200: gpu_vector_width = VECT_SIZE_1; break;
3708 case 12300: gpu_vector_width = VECT_SIZE_1; break;
3709 case 12500: gpu_vector_width = VECT_SIZE_1; break;
3710 case 12700: gpu_vector_width = VECT_SIZE_1; break;
3711 case 12800: gpu_vector_width = VECT_SIZE_1; break;
3712
3713 default: gpu_vector_width = VECT_SIZE_4; break;
3714 }
3715 }
3716 else if (vliw == 5)
3717 {
3718 switch (hash_mode)
3719 {
3720 case 150: gpu_vector_width = VECT_SIZE_2; break;
3721 case 160: gpu_vector_width = VECT_SIZE_2; break;
3722 case 300: gpu_vector_width = VECT_SIZE_2; break;
3723 case 1400: gpu_vector_width = VECT_SIZE_2; break;
3724 case 1410: gpu_vector_width = VECT_SIZE_2; break;
3725 case 1420: gpu_vector_width = VECT_SIZE_2; break;
3726 case 1421: gpu_vector_width = VECT_SIZE_2; break;
3727 case 1430: gpu_vector_width = VECT_SIZE_2; break;
3728 case 1440: gpu_vector_width = VECT_SIZE_2; break;
3729 case 1441: gpu_vector_width = VECT_SIZE_2; break;
3730 case 1450: gpu_vector_width = VECT_SIZE_1; break;
3731 case 1460: gpu_vector_width = VECT_SIZE_2; break;
3732 case 1500: gpu_vector_width = VECT_SIZE_1; break;
3733 case 1700: gpu_vector_width = VECT_SIZE_1; break;
3734 case 1710: gpu_vector_width = VECT_SIZE_1; break;
3735 case 1711: gpu_vector_width = VECT_SIZE_1; break;
3736 case 1720: gpu_vector_width = VECT_SIZE_1; break;
3737 case 1722: gpu_vector_width = VECT_SIZE_1; break;
3738 case 1730: gpu_vector_width = VECT_SIZE_1; break;
3739 case 1731: gpu_vector_width = VECT_SIZE_1; break;
3740 case 1740: gpu_vector_width = VECT_SIZE_1; break;
3741 case 1750: gpu_vector_width = VECT_SIZE_1; break;
3742 case 1760: gpu_vector_width = VECT_SIZE_1; break;
3743 case 1800: gpu_vector_width = VECT_SIZE_1; break;
3744 case 2100: gpu_vector_width = VECT_SIZE_2; break;
3745 case 2500: gpu_vector_width = VECT_SIZE_2; break;
3746 case 3000: gpu_vector_width = VECT_SIZE_1; break;
3747 case 3100: gpu_vector_width = VECT_SIZE_2; break;
3748 case 3200: gpu_vector_width = VECT_SIZE_1; break;
3749 case 5000: gpu_vector_width = VECT_SIZE_1; break;
3750 case 5200: gpu_vector_width = VECT_SIZE_2; break;
3751 case 5400: gpu_vector_width = VECT_SIZE_2; break;
3752 case 5600: gpu_vector_width = VECT_SIZE_2; break;
3753 case 5700: gpu_vector_width = VECT_SIZE_2; break;
3754 case 6100: gpu_vector_width = VECT_SIZE_2; break;
3755 case 6211:
3756 case 6212:
3757 case 6213:
3758 case 6221:
3759 case 6222:
3760 case 6223:
3761 case 6231:
3762 case 6232:
3763 case 6233:
3764 case 6241:
3765 case 6242:
3766 case 6243: gpu_vector_width = VECT_SIZE_1; break;
3767 case 6400: gpu_vector_width = VECT_SIZE_1; break;
3768 case 6500: gpu_vector_width = VECT_SIZE_1; break;
3769 case 6600: gpu_vector_width = VECT_SIZE_1; break;
3770 case 6700: gpu_vector_width = VECT_SIZE_2; break;
3771 case 6800: gpu_vector_width = VECT_SIZE_1; break;
3772 case 6900: gpu_vector_width = VECT_SIZE_1; break;
3773 case 7100: gpu_vector_width = VECT_SIZE_1; break;
3774 case 7200: gpu_vector_width = VECT_SIZE_1; break;
3775 case 7300: gpu_vector_width = VECT_SIZE_1; break;
3776 case 7400: gpu_vector_width = VECT_SIZE_1; break;
3777 case 7500: gpu_vector_width = VECT_SIZE_1; break;
3778 case 7700: gpu_vector_width = VECT_SIZE_1; break;
3779 case 7800: gpu_vector_width = VECT_SIZE_1; break;
3780 case 7900: gpu_vector_width = VECT_SIZE_1; break;
3781 case 8000: gpu_vector_width = VECT_SIZE_2; break;
3782 case 8200: gpu_vector_width = VECT_SIZE_1; break;
3783 case 8300: gpu_vector_width = VECT_SIZE_2; break;
3784 case 8400: gpu_vector_width = VECT_SIZE_2; break;
3785 case 8500: gpu_vector_width = VECT_SIZE_2; break;
3786 case 8700: gpu_vector_width = VECT_SIZE_2; break;
3787 case 8800: gpu_vector_width = VECT_SIZE_1; break;
3788 case 8900: gpu_vector_width = VECT_SIZE_1; break;
3789 case 9000: gpu_vector_width = VECT_SIZE_1; break;
3790 case 9100: gpu_vector_width = VECT_SIZE_1; break;
3791 case 9200: gpu_vector_width = VECT_SIZE_1; break;
3792 case 9300: gpu_vector_width = VECT_SIZE_1; break;
3793 case 9400: gpu_vector_width = VECT_SIZE_1; break;
3794 case 9500: gpu_vector_width = VECT_SIZE_1; break;
3795 case 9600: gpu_vector_width = VECT_SIZE_1; break;
3796 case 9700: gpu_vector_width = VECT_SIZE_1; break;
3797 case 9710: gpu_vector_width = VECT_SIZE_1; break;
3798 case 9720: gpu_vector_width = VECT_SIZE_2; break;
3799 case 9800: gpu_vector_width = VECT_SIZE_1; break;
3800 case 9810: gpu_vector_width = VECT_SIZE_1; break;
3801 case 9820: gpu_vector_width = VECT_SIZE_2; break;
3802 case 10000: gpu_vector_width = VECT_SIZE_1; break;
3803 case 10100: gpu_vector_width = VECT_SIZE_1; break;
3804 case 10400: gpu_vector_width = VECT_SIZE_1; break;
3805 case 10410: gpu_vector_width = VECT_SIZE_1; break;
3806 case 10420: gpu_vector_width = VECT_SIZE_2; break;
3807 case 10500: gpu_vector_width = VECT_SIZE_1; break;
3808 case 10600: gpu_vector_width = VECT_SIZE_2; break;
3809 case 10700: gpu_vector_width = VECT_SIZE_1; break;
3810 case 10800: gpu_vector_width = VECT_SIZE_1; break;
3811 case 10900: gpu_vector_width = VECT_SIZE_1; break;
3812 case 11100: gpu_vector_width = VECT_SIZE_2; break;
3813 case 11200: gpu_vector_width = VECT_SIZE_2; break;
3814 case 11300: gpu_vector_width = VECT_SIZE_1; break;
3815 case 11400: gpu_vector_width = VECT_SIZE_1; break;
3816 case 11600: gpu_vector_width = VECT_SIZE_1; break;
3817 case 11700: gpu_vector_width = VECT_SIZE_1; break;
3818 case 11800: gpu_vector_width = VECT_SIZE_1; break;
3819 case 11900: gpu_vector_width = VECT_SIZE_1; break;
3820 case 12000: gpu_vector_width = VECT_SIZE_1; break;
3821 case 12100: gpu_vector_width = VECT_SIZE_1; break;
3822 case 12200: gpu_vector_width = VECT_SIZE_1; break;
3823 case 12300: gpu_vector_width = VECT_SIZE_1; break;
3824 case 12500: gpu_vector_width = VECT_SIZE_1; break;
3825 case 12700: gpu_vector_width = VECT_SIZE_1; break;
3826 case 12800: gpu_vector_width = VECT_SIZE_1; break;
3827
3828 default: gpu_vector_width = VECT_SIZE_4; break;
3829 }
3830 }
3831 #endif
3832
3833 return gpu_vector_width;
3834 }
3835
3836 static void pw_transpose_to_hi1 (const pw_t *p1, pw_t *p2)
3837 {
3838 memcpy (p2->hi1, p1->hi1, 64 * sizeof (uint));
3839 }
3840
3841 static void pw_transpose_to_hi2 (const pw_t *p1, pw_t *p2)
3842 {
3843 p2->hi2[0][ 0] = p1->hi2[0][ 0];
3844 p2->hi2[0][ 2] = p1->hi2[0][ 1];
3845 p2->hi2[0][ 4] = p1->hi2[0][ 2];
3846 p2->hi2[0][ 6] = p1->hi2[0][ 3];
3847 p2->hi2[0][ 8] = p1->hi2[0][ 4];
3848 p2->hi2[0][10] = p1->hi2[0][ 5];
3849 p2->hi2[0][12] = p1->hi2[0][ 6];
3850 p2->hi2[0][14] = p1->hi2[0][ 7];
3851 p2->hi2[0][16] = p1->hi2[0][ 8];
3852 p2->hi2[0][18] = p1->hi2[0][ 9];
3853 p2->hi2[0][20] = p1->hi2[0][10];
3854 p2->hi2[0][22] = p1->hi2[0][11];
3855 p2->hi2[0][24] = p1->hi2[0][12];
3856 p2->hi2[0][26] = p1->hi2[0][13];
3857 p2->hi2[0][28] = p1->hi2[0][14];
3858 p2->hi2[0][30] = p1->hi2[0][15];
3859 p2->hi2[1][ 0] = p1->hi2[0][16];
3860 p2->hi2[1][ 2] = p1->hi2[0][17];
3861 p2->hi2[1][ 4] = p1->hi2[0][18];
3862 p2->hi2[1][ 6] = p1->hi2[0][19];
3863 p2->hi2[1][ 8] = p1->hi2[0][20];
3864 p2->hi2[1][10] = p1->hi2[0][21];
3865 p2->hi2[1][12] = p1->hi2[0][22];
3866 p2->hi2[1][14] = p1->hi2[0][23];
3867 p2->hi2[1][16] = p1->hi2[0][24];
3868 p2->hi2[1][18] = p1->hi2[0][25];
3869 p2->hi2[1][20] = p1->hi2[0][26];
3870 p2->hi2[1][22] = p1->hi2[0][27];
3871 p2->hi2[1][24] = p1->hi2[0][28];
3872 p2->hi2[1][26] = p1->hi2[0][29];
3873 p2->hi2[1][28] = p1->hi2[0][30];
3874 p2->hi2[1][30] = p1->hi2[0][31];
3875
3876 p2->hi2[0][ 1] = p1->hi2[1][ 0];
3877 p2->hi2[0][ 3] = p1->hi2[1][ 1];
3878 p2->hi2[0][ 5] = p1->hi2[1][ 2];
3879 p2->hi2[0][ 7] = p1->hi2[1][ 3];
3880 p2->hi2[0][ 9] = p1->hi2[1][ 4];
3881 p2->hi2[0][11] = p1->hi2[1][ 5];
3882 p2->hi2[0][13] = p1->hi2[1][ 6];
3883 p2->hi2[0][15] = p1->hi2[1][ 7];
3884 p2->hi2[0][17] = p1->hi2[1][ 8];
3885 p2->hi2[0][19] = p1->hi2[1][ 9];
3886 p2->hi2[0][21] = p1->hi2[1][10];
3887 p2->hi2[0][23] = p1->hi2[1][11];
3888 p2->hi2[0][25] = p1->hi2[1][12];
3889 p2->hi2[0][27] = p1->hi2[1][13];
3890 p2->hi2[0][29] = p1->hi2[1][14];
3891 p2->hi2[0][31] = p1->hi2[1][15];
3892 p2->hi2[1][ 1] = p1->hi2[1][16];
3893 p2->hi2[1][ 3] = p1->hi2[1][17];
3894 p2->hi2[1][ 5] = p1->hi2[1][18];
3895 p2->hi2[1][ 7] = p1->hi2[1][19];
3896 p2->hi2[1][ 9] = p1->hi2[1][20];
3897 p2->hi2[1][11] = p1->hi2[1][21];
3898 p2->hi2[1][13] = p1->hi2[1][22];
3899 p2->hi2[1][15] = p1->hi2[1][23];
3900 p2->hi2[1][17] = p1->hi2[1][24];
3901 p2->hi2[1][19] = p1->hi2[1][25];
3902 p2->hi2[1][21] = p1->hi2[1][26];
3903 p2->hi2[1][23] = p1->hi2[1][27];
3904 p2->hi2[1][25] = p1->hi2[1][28];
3905 p2->hi2[1][27] = p1->hi2[1][29];
3906 p2->hi2[1][29] = p1->hi2[1][30];
3907 p2->hi2[1][31] = p1->hi2[1][31];
3908 }
3909
3910 static void pw_transpose_to_hi4 (const pw_t *p1, pw_t *p2)
3911 {
3912 p2->hi4[0][ 0] = p1->hi4[0][ 0];
3913 p2->hi4[0][ 4] = p1->hi4[0][ 1];
3914 p2->hi4[0][ 8] = p1->hi4[0][ 2];
3915 p2->hi4[0][12] = p1->hi4[0][ 3];
3916 p2->hi4[1][ 0] = p1->hi4[0][ 4];
3917 p2->hi4[1][ 4] = p1->hi4[0][ 5];
3918 p2->hi4[1][ 8] = p1->hi4[0][ 6];
3919 p2->hi4[1][12] = p1->hi4[0][ 7];
3920 p2->hi4[2][ 0] = p1->hi4[0][ 8];
3921 p2->hi4[2][ 4] = p1->hi4[0][ 9];
3922 p2->hi4[2][ 8] = p1->hi4[0][10];
3923 p2->hi4[2][12] = p1->hi4[0][11];
3924 p2->hi4[3][ 0] = p1->hi4[0][12];
3925 p2->hi4[3][ 4] = p1->hi4[0][13];
3926 p2->hi4[3][ 8] = p1->hi4[0][14];
3927 p2->hi4[3][12] = p1->hi4[0][15];
3928
3929 p2->hi4[0][ 1] = p1->hi4[1][ 0];
3930 p2->hi4[0][ 5] = p1->hi4[1][ 1];
3931 p2->hi4[0][ 9] = p1->hi4[1][ 2];
3932 p2->hi4[0][13] = p1->hi4[1][ 3];
3933 p2->hi4[1][ 1] = p1->hi4[1][ 4];
3934 p2->hi4[1][ 5] = p1->hi4[1][ 5];
3935 p2->hi4[1][ 9] = p1->hi4[1][ 6];
3936 p2->hi4[1][13] = p1->hi4[1][ 7];
3937 p2->hi4[2][ 1] = p1->hi4[1][ 8];
3938 p2->hi4[2][ 5] = p1->hi4[1][ 9];
3939 p2->hi4[2][ 9] = p1->hi4[1][10];
3940 p2->hi4[2][13] = p1->hi4[1][11];
3941 p2->hi4[3][ 1] = p1->hi4[1][12];
3942 p2->hi4[3][ 5] = p1->hi4[1][13];
3943 p2->hi4[3][ 9] = p1->hi4[1][14];
3944 p2->hi4[3][13] = p1->hi4[1][15];
3945
3946 p2->hi4[0][ 2] = p1->hi4[2][ 0];
3947 p2->hi4[0][ 6] = p1->hi4[2][ 1];
3948 p2->hi4[0][10] = p1->hi4[2][ 2];
3949 p2->hi4[0][14] = p1->hi4[2][ 3];
3950 p2->hi4[1][ 2] = p1->hi4[2][ 4];
3951 p2->hi4[1][ 6] = p1->hi4[2][ 5];
3952 p2->hi4[1][10] = p1->hi4[2][ 6];
3953 p2->hi4[1][14] = p1->hi4[2][ 7];
3954 p2->hi4[2][ 2] = p1->hi4[2][ 8];
3955 p2->hi4[2][ 6] = p1->hi4[2][ 9];
3956 p2->hi4[2][10] = p1->hi4[2][10];
3957 p2->hi4[2][14] = p1->hi4[2][11];
3958 p2->hi4[3][ 2] = p1->hi4[2][12];
3959 p2->hi4[3][ 6] = p1->hi4[2][13];
3960 p2->hi4[3][10] = p1->hi4[2][14];
3961 p2->hi4[3][14] = p1->hi4[2][15];
3962
3963 p2->hi4[0][ 3] = p1->hi4[3][ 0];
3964 p2->hi4[0][ 7] = p1->hi4[3][ 1];
3965 p2->hi4[0][11] = p1->hi4[3][ 2];
3966 p2->hi4[0][15] = p1->hi4[3][ 3];
3967 p2->hi4[1][ 3] = p1->hi4[3][ 4];
3968 p2->hi4[1][ 7] = p1->hi4[3][ 5];
3969 p2->hi4[1][11] = p1->hi4[3][ 6];
3970 p2->hi4[1][15] = p1->hi4[3][ 7];
3971 p2->hi4[2][ 3] = p1->hi4[3][ 8];
3972 p2->hi4[2][ 7] = p1->hi4[3][ 9];
3973 p2->hi4[2][11] = p1->hi4[3][10];
3974 p2->hi4[2][15] = p1->hi4[3][11];
3975 p2->hi4[3][ 3] = p1->hi4[3][12];
3976 p2->hi4[3][ 7] = p1->hi4[3][13];
3977 p2->hi4[3][11] = p1->hi4[3][14];
3978 p2->hi4[3][15] = p1->hi4[3][15];
3979 }
3980
3981 static uint pw_add_to_hc1 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
3982 {
3983 if (data.devices_status == STATUS_BYPASS) return 0;
3984
3985 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
3986
3987 uint cache_cnt = pw_cache->cnt;
3988
3989 uint8_t *pw_hc1 = pw_cache->pw_buf.hc1[cache_cnt];
3990
3991 memcpy (pw_hc1, pw_buf, pw_len);
3992
3993 memset (pw_hc1 + pw_len, 0, 256 - pw_len);
3994
3995 uint pws_cnt = device_param->pws_cnt;
3996
3997 cache_cnt++;
3998
3999 if (cache_cnt == VECT_SIZE_1)
4000 {
4001 pw_t *pw = device_param->pws_buf + pws_cnt;
4002
4003 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4004
4005 pw->pw_len = pw_len;
4006
4007 pws_cnt++;
4008
4009 device_param->pws_cnt = pws_cnt;
4010 device_param->pw_cnt = pws_cnt * 1;
4011
4012 cache_cnt = 0;
4013 }
4014
4015 pw_cache->cnt = cache_cnt;
4016
4017 return pws_cnt;
4018 }
4019
4020 static uint pw_add_to_hc2 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
4021 {
4022 if (data.devices_status == STATUS_BYPASS) return 0;
4023
4024 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
4025
4026 uint cache_cnt = pw_cache->cnt;
4027
4028 uint8_t *pw_hc2 = pw_cache->pw_buf.hc2[cache_cnt];
4029
4030 memcpy (pw_hc2, pw_buf, pw_len);
4031
4032 memset (pw_hc2 + pw_len, 0, 128 - pw_len);
4033
4034 uint pws_cnt = device_param->pws_cnt;
4035
4036 cache_cnt++;
4037
4038 if (cache_cnt == VECT_SIZE_2)
4039 {
4040 pw_t *pw = device_param->pws_buf + pws_cnt;
4041
4042 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4043
4044 pw->pw_len = pw_len;
4045
4046 pws_cnt++;
4047
4048 device_param->pws_cnt = pws_cnt;
4049 device_param->pw_cnt = pws_cnt * 2;
4050
4051 cache_cnt = 0;
4052 }
4053
4054 pw_cache->cnt = cache_cnt;
4055
4056 return pws_cnt;
4057 }
4058
4059 static uint pw_add_to_hc4 (hc_device_param_t *device_param, const uint8_t *pw_buf, const uint pw_len)
4060 {
4061 if (data.devices_status == STATUS_BYPASS) return 0;
4062
4063 pw_cache_t *pw_cache = device_param->pw_caches + pw_len;
4064
4065 uint cache_cnt = pw_cache->cnt;
4066
4067 uint8_t *pw_hc4 = pw_cache->pw_buf.hc4[cache_cnt];
4068
4069 memcpy (pw_hc4, pw_buf, pw_len);
4070
4071 memset (pw_hc4 + pw_len, 0, 64 - pw_len);
4072
4073 uint pws_cnt = device_param->pws_cnt;
4074
4075 cache_cnt++;
4076
4077 if (cache_cnt == VECT_SIZE_4)
4078 {
4079 pw_t *pw = device_param->pws_buf + pws_cnt;
4080
4081 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4082
4083 pw->pw_len = pw_len;
4084
4085 pws_cnt++;
4086
4087 device_param->pws_cnt = pws_cnt;
4088 device_param->pw_cnt = pws_cnt * 4;
4089
4090 cache_cnt = 0;
4091 }
4092
4093 pw_cache->cnt = cache_cnt;
4094
4095 return pws_cnt;
4096 }
4097
4098 static void *thread_monitor (void *p)
4099 {
4100 uint runtime_check = 0;
4101 uint remove_check = 0;
4102 uint status_check = 0;
4103 uint hwmon_check = 0;
4104 uint restore_check = 0;
4105
4106 uint restore_left = data.restore_timer;
4107 uint remove_left = data.remove_timer;
4108 uint status_left = data.status_timer;
4109
4110 #ifdef _OCL
4111 #ifndef OSX
4112
4113 int *fan_speed_chgd = (int *) mycalloc (data.devices_cnt, sizeof (int));
4114
4115 // temperature controller "loopback" values
4116
4117 int *temp_diff_old = (int *) mycalloc (data.devices_cnt, sizeof (int));
4118 int *temp_diff_sum = (int *) mycalloc (data.devices_cnt, sizeof (int));
4119
4120 int temp_threshold = 1; // degrees celcius
4121
4122 int fan_speed_min = 15; // in percentage
4123 int fan_speed_max = 100;
4124
4125 time_t last_temp_check_time;
4126
4127 #endif
4128 #endif
4129
4130 uint sleep_time = 1;
4131
4132 if (data.runtime)
4133 runtime_check = 1;
4134
4135 if (data.restore_timer)
4136 restore_check = 1;
4137
4138 if ((data.remove == 1) && (data.hashlist_mode == HL_MODE_FILE))
4139 remove_check = 1;
4140
4141 if (data.status == 1)
4142 status_check = 1;
4143
4144 if (data.gpu_temp_disable == 0)
4145 {
4146 #ifdef _OCL
4147 #ifndef OSX
4148 time (&last_temp_check_time);
4149 #endif
4150 #endif
4151
4152 hwmon_check = 1;
4153 }
4154
4155 if ((runtime_check == 0) && (remove_check == 0) && (status_check == 0) && (hwmon_check == 0) && (restore_check == 0))
4156 {
4157 return (p);
4158 }
4159
4160 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4161 {
4162 hc_sleep (sleep_time);
4163
4164 if (data.devices_status != STATUS_RUNNING) continue;
4165
4166 if (hwmon_check == 1)
4167 {
4168 hc_thread_mutex_lock (mux_adl);
4169
4170 #ifdef _OCL
4171 #ifndef OSX
4172
4173 time_t temp_check_time;
4174
4175 time (&temp_check_time);
4176
4177 uint Ta = temp_check_time - last_temp_check_time; // set Ta = sleep_time; is not good enough (see --remove etc)
4178
4179 if (Ta == 0) Ta = 1;
4180
4181 #endif
4182 #endif
4183
4184 for (uint i = 0; i < data.devices_cnt; i++)
4185 {
4186 const int temperature = hm_get_temperature_with_device_id (i);
4187
4188 if (temperature > (int) data.gpu_temp_abort)
4189 {
4190 log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", i + 1);
4191
4192 if (data.devices_status != STATUS_QUIT) myabort ();
4193
4194 break;
4195 }
4196
4197 #ifdef _OCL
4198 #ifndef OSX
4199
4200 const int gpu_temp_retain = data.gpu_temp_retain;
4201
4202 if (gpu_temp_retain)
4203 {
4204 if (data.hm_device[i].fan_supported == 1)
4205 {
4206 int temp_cur = temperature;
4207
4208 int temp_diff_new = gpu_temp_retain - temp_cur;
4209
4210 temp_diff_sum[i] = temp_diff_sum[i] + temp_diff_new;
4211
4212 // calculate Ta value (time difference in seconds between the last check and this check)
4213
4214 last_temp_check_time = temp_check_time;
4215
4216 float Kp = 1.8;
4217 float Ki = 0.005;
4218 float Kd = 6;
4219
4220 // PID controller (3-term controller: proportional - Kp, integral - Ki, derivative - Kd)
4221
4222 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);
4223
4224 if (abs (fan_diff_required) >= temp_threshold)
4225 {
4226 const int fan_speed_cur = hm_get_fanspeed_with_device_id (i);
4227
4228 int fan_speed_level = fan_speed_cur;
4229
4230 if (fan_speed_chgd[i] == 0) fan_speed_level = temp_cur;
4231
4232 int fan_speed_new = fan_speed_level - fan_diff_required;
4233
4234 if (fan_speed_new > fan_speed_max) fan_speed_new = fan_speed_max;
4235 if (fan_speed_new < fan_speed_min) fan_speed_new = fan_speed_min;
4236
4237 if (fan_speed_new != fan_speed_cur)
4238 {
4239 int freely_change_fan_speed = (fan_speed_chgd[i] == 1);
4240 int fan_speed_must_change = (fan_speed_new > fan_speed_cur);
4241
4242 if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1))
4243 {
4244 hm_set_fanspeed_with_device_id (i, fan_speed_new);
4245
4246 fan_speed_chgd[i] = 1;
4247 }
4248
4249 temp_diff_old[i] = temp_diff_new;
4250 }
4251 }
4252 }
4253 }
4254
4255 #endif
4256 #endif
4257 }
4258
4259 hc_thread_mutex_unlock (mux_adl);
4260 }
4261
4262 if (restore_check == 1)
4263 {
4264 restore_left--;
4265
4266 if (restore_left == 0)
4267 {
4268 if (data.restore_disable == 0) cycle_restore ();
4269
4270 restore_left = data.restore_timer;
4271 }
4272 }
4273
4274 if ((runtime_check == 1) && (data.runtime_start > 0))
4275 {
4276 time_t runtime_cur;
4277
4278 time (&runtime_cur);
4279
4280 int runtime_left = data.runtime_start + data.runtime - runtime_cur;
4281
4282 if (runtime_left <= 0)
4283 {
4284 if (data.benchmark == 0)
4285 {
4286 if (data.quiet == 0) log_info ("\nNOTE: Runtime limit reached, aborting...\n");
4287 }
4288
4289 if (data.devices_status != STATUS_QUIT) myabort ();
4290 }
4291 }
4292
4293 if (remove_check == 1)
4294 {
4295 remove_left--;
4296
4297 if (remove_left == 0)
4298 {
4299 if (data.digests_saved != data.digests_done)
4300 {
4301 data.digests_saved = data.digests_done;
4302
4303 save_hash ();
4304 }
4305
4306 remove_left = data.remove_timer;
4307 }
4308 }
4309
4310 if (status_check == 1)
4311 {
4312 status_left--;
4313
4314 if (status_left == 0)
4315 {
4316 hc_thread_mutex_lock (mux_display);
4317
4318 if (data.quiet == 0) clear_prompt ();
4319
4320 if (data.quiet == 0) log_info ("");
4321
4322 status_display ();
4323
4324 if (data.quiet == 0) log_info ("");
4325
4326 hc_thread_mutex_unlock (mux_display);
4327
4328 status_left = data.status_timer;
4329 }
4330 }
4331 }
4332
4333 #ifdef _OCL
4334 #ifndef OSX
4335 myfree (fan_speed_chgd);
4336
4337 myfree (temp_diff_old);
4338 myfree (temp_diff_sum);
4339 #endif
4340 #endif
4341
4342 p = NULL;
4343
4344 return (p);
4345 }
4346
4347 static void *thread_outfile_remove (void *p)
4348 {
4349 // some hash-dependent constants
4350 char *outfile_dir = data.outfile_check_directory;
4351 uint dgst_size = data.dgst_size;
4352 uint isSalted = data.isSalted;
4353 uint esalt_size = data.esalt_size;
4354 uint hash_mode = data.hash_mode;
4355
4356 uint outfile_check_timer = data.outfile_check_timer;
4357
4358 char separator = data.separator;
4359
4360 // some hash-dependent functions
4361 int (*sort_by_digest) (const void *, const void *) = data.sort_by_digest;
4362 int (*parse_func) (char *, uint, hash_t *) = data.parse_func;
4363
4364 // buffers
4365 hash_t hash_buf;
4366
4367 memset (&hash_buf, 0, sizeof (hash_buf));
4368
4369 hash_buf.digest = mymalloc (dgst_size);
4370
4371 if (isSalted) hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
4372
4373 if (esalt_size) hash_buf.esalt = (void *) mymalloc (esalt_size);
4374
4375 uint digest_buf[64];
4376
4377 outfile_data_t *out_info = NULL;
4378
4379 char **out_files = NULL;
4380
4381 time_t folder_mtime = 0;
4382
4383 int out_cnt = 0;
4384
4385 uint check_left = outfile_check_timer; // or 1 if we want to check it at startup
4386
4387 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4388 {
4389 hc_sleep (1);
4390
4391 if (data.devices_status != STATUS_RUNNING) continue;
4392
4393 check_left--;
4394
4395 if (check_left == 0)
4396 {
4397 struct stat outfile_check_stat;
4398
4399 if (stat (outfile_dir, &outfile_check_stat) == 0)
4400 {
4401 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
4402
4403 if (is_dir == 1)
4404 {
4405 if (outfile_check_stat.st_mtime > folder_mtime)
4406 {
4407 char **out_files_new = scan_directory (outfile_dir);
4408
4409 int out_cnt_new = count_dictionaries (out_files_new);
4410
4411 outfile_data_t *out_info_new = NULL;
4412
4413 if (out_cnt_new > 0)
4414 {
4415 out_info_new = (outfile_data_t *) mycalloc (out_cnt_new, sizeof (outfile_data_t));
4416
4417 for (int i = 0; i < out_cnt_new; i++)
4418 {
4419 out_info_new[i].file_name = out_files_new[i];
4420
4421 // check if there are files that we have seen/checked before (and not changed)
4422
4423 for (int j = 0; j < out_cnt; j++)
4424 {
4425 if (strcmp (out_info[j].file_name, out_info_new[i].file_name) == 0)
4426 {
4427 struct stat outfile_stat;
4428
4429 if (stat (out_info_new[i].file_name, &outfile_stat) == 0)
4430 {
4431 if (outfile_stat.st_ctime == out_info[j].ctime)
4432 {
4433 out_info_new[i].ctime = out_info[j].ctime;
4434 out_info_new[i].seek = out_info[j].seek;
4435 }
4436 }
4437 }
4438 }
4439 }
4440 }
4441
4442 local_free (out_info);
4443 local_free (out_files);
4444
4445 out_files = out_files_new;
4446 out_cnt = out_cnt_new;
4447 out_info = out_info_new;
4448
4449 folder_mtime = outfile_check_stat.st_mtime;
4450 }
4451
4452 for (int j = 0; j < out_cnt; j++)
4453 {
4454 FILE *fp = fopen (out_info[j].file_name, "rb");
4455
4456 if (fp != NULL)
4457 {
4458 //hc_thread_mutex_lock (mux_display);
4459
4460 #ifdef _POSIX
4461 struct stat outfile_stat;
4462
4463 fstat (fileno (fp), &outfile_stat);
4464 #endif
4465
4466 #ifdef _WIN
4467 struct stat64 outfile_stat;
4468
4469 _fstat64 (fileno (fp), &outfile_stat);
4470 #endif
4471
4472 if (outfile_stat.st_ctime > out_info[j].ctime)
4473 {
4474 out_info[j].ctime = outfile_stat.st_ctime;
4475 out_info[j].seek = 0;
4476 }
4477
4478 fseek (fp, out_info[j].seek, SEEK_SET);
4479
4480 while (!feof (fp))
4481 {
4482 char line_buf[BUFSIZ];
4483
4484 memset (line_buf, 0, BUFSIZ);
4485
4486 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
4487
4488 if (ptr == NULL) break;
4489
4490 int line_len = strlen (line_buf);
4491
4492 if (line_len <= 0) continue;
4493
4494 int iter = MAX_CUT_TRIES;
4495
4496 for (uint i = line_len - 1; i && iter; i--, line_len--)
4497 {
4498 if (line_buf[i] != separator) continue;
4499
4500 int parser_status = PARSER_OK;
4501
4502 if ((hash_mode != 2500) && (hash_mode != 6800))
4503 {
4504 parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
4505 }
4506
4507 uint found = 0;
4508
4509 if (parser_status == PARSER_OK)
4510 {
4511 for (uint salt_pos = 0; (found == 0) && (salt_pos < data.salts_cnt); salt_pos++)
4512 {
4513 if (data.salts_shown[salt_pos] == 1) continue;
4514
4515 salt_t *salt_buf = &data.salts_buf[salt_pos];
4516
4517 for (uint digest_pos = 0; (found == 0) && (digest_pos < salt_buf->digests_cnt); digest_pos++)
4518 {
4519 uint idx = salt_buf->digests_offset + digest_pos;
4520
4521 if (data.digests_shown[idx] == 1) continue;
4522
4523 uint cracked = 0;
4524
4525 if (hash_mode == 6800)
4526 {
4527 if (i == salt_buf->salt_len)
4528 {
4529 cracked = (memcmp (line_buf, salt_buf->salt_buf, salt_buf->salt_len) == 0);
4530 }
4531 }
4532 else if (hash_mode == 2500)
4533 {
4534 // BSSID : MAC1 : MAC2 (:plain)
4535 if (i == (salt_buf->salt_len + 1 + 12 + 1 + 12))
4536 {
4537 cracked = (memcmp (line_buf, salt_buf->salt_buf, salt_buf->salt_len) == 0);
4538
4539 if (!cracked) continue;
4540
4541 // now compare MAC1 and MAC2 too, since we have this additional info
4542 char *mac1_pos = line_buf + salt_buf->salt_len + 1;
4543 char *mac2_pos = mac1_pos + 12 + 1;
4544
4545 wpa_t *wpas = (wpa_t *) data.esalts_buf;
4546 wpa_t *wpa = &wpas[salt_pos];
4547
4548 uint pke[25];
4549
4550 char *pke_ptr = (char *) pke;
4551
4552 for (uint i = 0; i < 25; i++)
4553 {
4554 pke[i] = byte_swap_32 (wpa->pke[i]);
4555 }
4556
4557 unsigned char mac1[6];
4558 unsigned char mac2[6];
4559
4560 memcpy (mac1, pke_ptr + 23, 6);
4561 memcpy (mac2, pke_ptr + 29, 6);
4562
4563 // compare hex string(s) vs binary MAC address(es)
4564
4565 for (uint i = 0, j = 0; i < 6; i++, j += 2)
4566 {
4567 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
4568 {
4569 cracked = 0;
4570 break;
4571 }
4572 }
4573
4574 // early skip ;)
4575 if (!cracked) continue;
4576
4577 for (uint i = 0, j = 0; i < 6; i++, j += 2)
4578 {
4579 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
4580 {
4581 cracked = 0;
4582 break;
4583 }
4584 }
4585 }
4586 }
4587 else
4588 {
4589 char *digests_buf_ptr = (char *) data.digests_buf;
4590
4591 memcpy (digest_buf, digests_buf_ptr + (data.salts_buf[salt_pos].digests_offset * dgst_size) + (digest_pos * dgst_size), dgst_size);
4592
4593 cracked = (sort_by_digest (digest_buf, hash_buf.digest) == 0);
4594 }
4595
4596 if (cracked == 1)
4597 {
4598 found = 1;
4599
4600 data.digests_shown[idx] = 1;
4601
4602 data.digests_done++;
4603
4604 salt_buf->digests_done++;
4605
4606 if (salt_buf->digests_done == salt_buf->digests_cnt)
4607 {
4608 data.salts_shown[salt_pos] = 1;
4609
4610 data.salts_done++;
4611
4612 if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
4613 }
4614 }
4615 }
4616
4617 if (data.devices_status == STATUS_CRACKED) break;
4618 }
4619 }
4620
4621 if (found) break;
4622
4623 if (data.devices_status == STATUS_CRACKED) break;
4624
4625 iter--;
4626 }
4627
4628 if (data.devices_status == STATUS_CRACKED) break;
4629 }
4630
4631 out_info[j].seek = ftell (fp);
4632
4633 //hc_thread_mutex_unlock (mux_display);
4634
4635 fclose (fp);
4636 }
4637 }
4638 }
4639 }
4640
4641 check_left = outfile_check_timer;
4642 }
4643 }
4644
4645 if (esalt_size) local_free (hash_buf.esalt);
4646
4647 if (isSalted) local_free (hash_buf.salt);
4648
4649 local_free (hash_buf.digest);
4650
4651 local_free (out_info);
4652
4653 local_free (out_files);
4654
4655 p = NULL;
4656
4657 return (p);
4658 }
4659
4660 static uint get_work (hc_device_param_t *device_param, const uint64_t max)
4661 {
4662 hc_thread_mutex_lock (mux_dispatcher);
4663
4664 const uint64_t words_cur = data.words_cur;
4665 const uint64_t words_base = (data.limit == 0) ? data.words_base : data.limit;
4666
4667 device_param->words_off = words_cur;
4668
4669 const uint64_t words_left = words_base - words_cur;
4670
4671 if (data.gpu_blocks_all > words_left)
4672 {
4673 if (data.gpu_blocks_div == 0)
4674 {
4675 data.gpu_blocks_div = find_gpu_blocks_div (words_left, data.gpu_blocks_all);
4676 }
4677 }
4678
4679 if (data.gpu_blocks_div)
4680 {
4681 if (device_param->gpu_blocks == device_param->gpu_blocks_user)
4682 {
4683 const uint32_t gpu_blocks_new = (float) device_param->gpu_blocks * data.gpu_blocks_div;
4684 const uint32_t gpu_power_new = gpu_blocks_new / device_param->gpu_vector_width;
4685
4686 if (gpu_blocks_new < device_param->gpu_blocks)
4687 {
4688 device_param->gpu_blocks = gpu_blocks_new;
4689 device_param->gpu_power = gpu_power_new;
4690 }
4691 }
4692 }
4693
4694 const uint gpu_blocks = device_param->gpu_blocks;
4695
4696 uint work = MIN (words_left, gpu_blocks);
4697
4698 work = MIN (work, max);
4699
4700 data.words_cur += work;
4701
4702 hc_thread_mutex_unlock (mux_dispatcher);
4703
4704 return work;
4705 }
4706
4707 static void *thread_calc_stdin (void *p)
4708 {
4709 hc_device_param_t *device_param = (hc_device_param_t *) p;
4710
4711 const uint attack_kern = data.attack_kern;
4712
4713 const uint gpu_blocks = device_param->gpu_blocks;
4714
4715 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4716 {
4717 hc_thread_mutex_lock (mux_dispatcher);
4718
4719 if (feof (stdin) != 0)
4720 {
4721 hc_thread_mutex_unlock (mux_dispatcher);
4722
4723 break;
4724 }
4725
4726 uint words_cur = 0;
4727
4728 while (words_cur < gpu_blocks)
4729 {
4730 char buf[BUFSIZ];
4731
4732 char *line_buf = fgets (buf, sizeof (buf), stdin);
4733
4734 if (line_buf == NULL) break;
4735
4736 uint line_len = in_superchop (line_buf);
4737
4738 line_len = convert_from_hex (line_buf, line_len);
4739
4740 // post-process rule engine
4741
4742 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
4743 {
4744 char rule_buf_out[BLOCK_SIZE];
4745
4746 memset (rule_buf_out, 0, sizeof (rule_buf_out));
4747
4748 int rule_len_out = -1;
4749
4750 if (line_len < BLOCK_SIZE)
4751 {
4752 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, line_buf, line_len, rule_buf_out);
4753 }
4754
4755 if (rule_len_out < 0) continue;
4756
4757 line_buf = rule_buf_out;
4758 line_len = rule_len_out;
4759 }
4760
4761 if (line_len > PW_MAX)
4762 {
4763 continue;
4764 }
4765
4766 if (attack_kern == ATTACK_KERN_STRAIGHT)
4767 {
4768 if ((line_len < data.pw_min) || (line_len > data.pw_max))
4769 {
4770 hc_thread_mutex_lock (mux_counter);
4771
4772 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4773 {
4774 data.words_progress_rejected[salt_pos] += data.gpu_rules_cnt;
4775 }
4776
4777 hc_thread_mutex_unlock (mux_counter);
4778
4779 continue;
4780 }
4781 }
4782 else if (attack_kern == ATTACK_KERN_COMBI)
4783 {
4784 // do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
4785 // since we still need to combine the plains
4786
4787 if (line_len > data.pw_max)
4788 {
4789 hc_thread_mutex_lock (mux_counter);
4790
4791 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
4792 {
4793 data.words_progress_rejected[salt_pos] += data.combs_cnt;
4794 }
4795
4796 hc_thread_mutex_unlock (mux_counter);
4797
4798 continue;
4799 }
4800 }
4801
4802 device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
4803
4804 words_cur++;
4805
4806 if (data.devices_status == STATUS_CRACKED) break;
4807 if (data.devices_status == STATUS_ABORTED) break;
4808 if (data.devices_status == STATUS_QUIT) break;
4809 if (data.devices_status == STATUS_BYPASS) break;
4810 }
4811
4812 hc_thread_mutex_unlock (mux_dispatcher);
4813
4814 if (data.devices_status == STATUS_CRACKED) break;
4815 if (data.devices_status == STATUS_ABORTED) break;
4816 if (data.devices_status == STATUS_QUIT) break;
4817 if (data.devices_status == STATUS_BYPASS) break;
4818
4819 // we need 2 flushing because we have two independant caches and it can occur
4820 // that one buffer is already at threshold plus for that length also exists
4821 // more data in the 2nd buffer so it would overflow
4822
4823 // flush session 1
4824
4825 {
4826 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4827 {
4828 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4829
4830 const uint pw_cache_cnt = pw_cache->cnt;
4831
4832 if (pw_cache_cnt == 0) continue;
4833
4834 pw_cache->cnt = 0;
4835
4836 uint pws_cnt = device_param->pws_cnt;
4837
4838 pw_t *pw = device_param->pws_buf + pws_cnt;
4839
4840 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4841
4842 pw->pw_len = pw_len;
4843
4844 uint pw_cnt = device_param->pw_cnt;
4845
4846 pw_cnt += pw_cache_cnt;
4847
4848 device_param->pw_cnt = pw_cnt;
4849
4850 pws_cnt++;
4851
4852 device_param->pws_cnt = pws_cnt;
4853
4854 if (pws_cnt == device_param->gpu_power_user) break;
4855 }
4856
4857 const uint pw_cnt = device_param->pw_cnt;
4858 const uint pws_cnt = device_param->pws_cnt;
4859
4860 if (pws_cnt)
4861 {
4862 run_copy (device_param, pws_cnt);
4863
4864 run_cracker (device_param, pw_cnt, pws_cnt);
4865
4866 device_param->pw_cnt = 0;
4867 device_param->pws_cnt = 0;
4868 }
4869 }
4870
4871 // flush session 2
4872
4873 {
4874 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
4875 {
4876 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
4877
4878 const uint pw_cache_cnt = pw_cache->cnt;
4879
4880 if (pw_cache_cnt == 0) continue;
4881
4882 pw_cache->cnt = 0;
4883
4884 uint pws_cnt = device_param->pws_cnt;
4885
4886 pw_t *pw = device_param->pws_buf + pws_cnt;
4887
4888 device_param->pw_transpose (&pw_cache->pw_buf, pw);
4889
4890 pw->pw_len = pw_len;
4891
4892 uint pw_cnt = device_param->pw_cnt;
4893
4894 pw_cnt += pw_cache_cnt;
4895
4896 device_param->pw_cnt = pw_cnt;
4897
4898 pws_cnt++;
4899
4900 device_param->pws_cnt = pws_cnt;
4901 }
4902
4903 const uint pw_cnt = device_param->pw_cnt;
4904 const uint pws_cnt = device_param->pws_cnt;
4905
4906 if (pws_cnt)
4907 {
4908 run_copy (device_param, pws_cnt);
4909
4910 run_cracker (device_param, pw_cnt, pws_cnt);
4911
4912 device_param->pw_cnt = 0;
4913 device_param->pws_cnt = 0;
4914 }
4915 }
4916 }
4917
4918 return NULL;
4919 }
4920
4921 static void *thread_calc (void *p)
4922 {
4923 hc_device_param_t *device_param = (hc_device_param_t *) p;
4924
4925 const uint attack_mode = data.attack_mode;
4926 const uint attack_kern = data.attack_kern;
4927
4928 if (attack_mode == ATTACK_MODE_BF)
4929 {
4930 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
4931 {
4932 const uint work = get_work (device_param, -1);
4933
4934 if (work == 0) break;
4935
4936 const uint64_t words_off = device_param->words_off;
4937 const uint64_t words_fin = words_off + work;
4938
4939 const uint gpu_vector_width = device_param->gpu_vector_width;
4940
4941 const uint pw_cnt = work;
4942 const uint pws_cnt = mydivc32 (work, gpu_vector_width);
4943
4944 device_param->pw_cnt = pw_cnt;
4945 device_param->pws_cnt = pws_cnt;
4946
4947 if (pws_cnt)
4948 {
4949 run_copy (device_param, pws_cnt);
4950
4951 run_cracker (device_param, pw_cnt, pws_cnt);
4952
4953 device_param->pw_cnt = 0;
4954 device_param->pws_cnt = 0;
4955 }
4956
4957 if (data.devices_status == STATUS_CRACKED) break;
4958 if (data.devices_status == STATUS_ABORTED) break;
4959 if (data.devices_status == STATUS_QUIT) break;
4960 if (data.devices_status == STATUS_BYPASS) break;
4961
4962 device_param->words_done = words_fin;
4963 }
4964 }
4965 else
4966 {
4967 const uint segment_size = data.segment_size;
4968
4969 char *dictfile = data.dictfile;
4970
4971 if (attack_mode == ATTACK_MODE_COMBI)
4972 {
4973 if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
4974 {
4975 dictfile = data.dictfile2;
4976 }
4977 }
4978
4979 FILE *fd = fopen (dictfile, "rb");
4980
4981 if (fd == NULL)
4982 {
4983 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
4984
4985 return NULL;
4986 }
4987
4988 if (attack_mode == ATTACK_MODE_COMBI)
4989 {
4990 const uint combs_mode = data.combs_mode;
4991
4992 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
4993 {
4994 const char *dictfilec = data.dictfile2;
4995
4996 FILE *combs_fp = fopen (dictfilec, "rb");
4997
4998 if (combs_fp == NULL)
4999 {
5000 log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
5001
5002 fclose (fd);
5003
5004 return NULL;
5005 }
5006
5007 device_param->combs_fp = combs_fp;
5008 }
5009 else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
5010 {
5011 const char *dictfilec = data.dictfile;
5012
5013 FILE *combs_fp = fopen (dictfilec, "rb");
5014
5015 if (combs_fp == NULL)
5016 {
5017 log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
5018
5019 fclose (fd);
5020
5021 return NULL;
5022 }
5023
5024 device_param->combs_fp = combs_fp;
5025 }
5026 }
5027
5028 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
5029
5030 wl_data->buf = (char *) mymalloc (segment_size);
5031 wl_data->avail = segment_size;
5032 wl_data->incr = segment_size;
5033 wl_data->cnt = 0;
5034 wl_data->pos = 0;
5035
5036 uint64_t words_cur = 0;
5037
5038 while ((data.devices_status != STATUS_EXHAUSTED) && (data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
5039 {
5040 uint64_t words_off = 0;
5041 uint64_t words_fin = 0;
5042
5043 uint64_t max = -1;
5044
5045 while (max)
5046 {
5047 const uint work = get_work (device_param, max);
5048
5049 if (work == 0) break;
5050
5051 words_off = device_param->words_off;
5052 words_fin = words_off + work;
5053
5054 char *line_buf;
5055 uint line_len;
5056
5057 for ( ; words_cur < words_off; words_cur++) get_next_word (wl_data, fd, &line_buf, &line_len);
5058
5059 max = 0;
5060
5061 for ( ; words_cur < words_fin; words_cur++)
5062 {
5063 get_next_word (wl_data, fd, &line_buf, &line_len);
5064
5065 line_len = convert_from_hex (line_buf, line_len);
5066
5067 // post-process rule engine
5068
5069 if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
5070 {
5071 char rule_buf_out[BLOCK_SIZE];
5072
5073 memset (rule_buf_out, 0, sizeof (rule_buf_out));
5074
5075 int rule_len_out = -1;
5076
5077 if (line_len < BLOCK_SIZE)
5078 {
5079 rule_len_out = _old_apply_rule (data.rule_buf_l, data.rule_len_l, line_buf, line_len, rule_buf_out);
5080 }
5081
5082 if (rule_len_out < 0) continue;
5083
5084 line_buf = rule_buf_out;
5085 line_len = rule_len_out;
5086 }
5087
5088 if (attack_kern == ATTACK_KERN_STRAIGHT)
5089 {
5090 if ((line_len < data.pw_min) || (line_len > data.pw_max))
5091 {
5092 max++;
5093
5094 hc_thread_mutex_lock (mux_counter);
5095
5096 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
5097 {
5098 data.words_progress_rejected[salt_pos] += data.gpu_rules_cnt;
5099 }
5100
5101 hc_thread_mutex_unlock (mux_counter);
5102
5103 continue;
5104 }
5105 }
5106 else if (attack_kern == ATTACK_KERN_COMBI)
5107 {
5108 // do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
5109 // since we still need to combine the plains
5110
5111 if (line_len > data.pw_max)
5112 {
5113 max++;
5114
5115 hc_thread_mutex_lock (mux_counter);
5116
5117 for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
5118 {
5119 data.words_progress_rejected[salt_pos] += data.combs_cnt;
5120 }
5121
5122 hc_thread_mutex_unlock (mux_counter);
5123
5124 continue;
5125 }
5126 }
5127
5128 device_param->pw_add (device_param, (uint8_t *) line_buf, line_len);
5129
5130 if (data.devices_status == STATUS_CRACKED) break;
5131 if (data.devices_status == STATUS_ABORTED) break;
5132 if (data.devices_status == STATUS_QUIT) break;
5133 if (data.devices_status == STATUS_BYPASS) break;
5134 }
5135
5136 if (data.devices_status == STATUS_CRACKED) break;
5137 if (data.devices_status == STATUS_ABORTED) break;
5138 if (data.devices_status == STATUS_QUIT) break;
5139 if (data.devices_status == STATUS_BYPASS) break;
5140 }
5141
5142 if (data.devices_status == STATUS_CRACKED) break;
5143 if (data.devices_status == STATUS_ABORTED) break;
5144 if (data.devices_status == STATUS_QUIT) break;
5145 if (data.devices_status == STATUS_BYPASS) break;
5146
5147 // we need 2 flushing because we have two independant caches and it can occur
5148 // that one buffer is already at threshold plus for that length also exists
5149 // more data in the 2nd buffer so it would overflow
5150
5151 //
5152 // flush session 1
5153 //
5154
5155 {
5156 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
5157 {
5158 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
5159
5160 const uint pw_cache_cnt = pw_cache->cnt;
5161
5162 if (pw_cache_cnt == 0) continue;
5163
5164 pw_cache->cnt = 0;
5165
5166 uint pws_cnt = device_param->pws_cnt;
5167
5168 pw_t *pw = device_param->pws_buf + pws_cnt;
5169
5170 device_param->pw_transpose (&pw_cache->pw_buf, pw);
5171
5172 pw->pw_len = pw_len;
5173
5174 uint pw_cnt = device_param->pw_cnt;
5175
5176 pw_cnt += pw_cache_cnt;
5177
5178 device_param->pw_cnt = pw_cnt;
5179
5180 pws_cnt++;
5181
5182 device_param->pws_cnt = pws_cnt;
5183
5184 if (pws_cnt == device_param->gpu_power_user) break;
5185 }
5186
5187 const uint pw_cnt = device_param->pw_cnt;
5188 const uint pws_cnt = device_param->pws_cnt;
5189
5190 if (pws_cnt)
5191 {
5192 run_copy (device_param, pws_cnt);
5193
5194 run_cracker (device_param, pw_cnt, pws_cnt);
5195
5196 device_param->pw_cnt = 0;
5197 device_param->pws_cnt = 0;
5198 }
5199
5200 if (data.devices_status == STATUS_CRACKED) break;
5201 if (data.devices_status == STATUS_ABORTED) break;
5202 if (data.devices_status == STATUS_QUIT) break;
5203 if (data.devices_status == STATUS_BYPASS) break;
5204 }
5205
5206 //
5207 // flush session 2
5208 //
5209
5210 {
5211 for (int pw_len = 0; pw_len < PW_MAX1; pw_len++)
5212 {
5213 pw_cache_t *pw_cache = &device_param->pw_caches[pw_len];
5214
5215 const uint pw_cache_cnt = pw_cache->cnt;
5216
5217 if (pw_cache_cnt == 0) continue;
5218
5219 pw_cache->cnt = 0;
5220
5221 uint pws_cnt = device_param->pws_cnt;
5222
5223 pw_t *pw = device_param->pws_buf + pws_cnt;
5224
5225 device_param->pw_transpose (&pw_cache->pw_buf, pw);
5226
5227 pw->pw_len = pw_len;
5228
5229 uint pw_cnt = device_param->pw_cnt;
5230
5231 pw_cnt += pw_cache_cnt;
5232
5233 device_param->pw_cnt = pw_cnt;
5234
5235 pws_cnt++;
5236
5237 device_param->pws_cnt = pws_cnt;
5238 }
5239
5240 const uint pw_cnt = device_param->pw_cnt;
5241 const uint pws_cnt = device_param->pws_cnt;
5242
5243 if (pws_cnt)
5244 {
5245 run_copy (device_param, pws_cnt);
5246
5247 run_cracker (device_param, pw_cnt, pws_cnt);
5248
5249 device_param->pw_cnt = 0;
5250 device_param->pws_cnt = 0;
5251 }
5252
5253 if (data.devices_status == STATUS_CRACKED) break;
5254 if (data.devices_status == STATUS_ABORTED) break;
5255 if (data.devices_status == STATUS_QUIT) break;
5256 if (data.devices_status == STATUS_BYPASS) break;
5257 }
5258
5259 if (words_fin == 0) break;
5260
5261 device_param->words_done = words_fin;
5262 }
5263
5264 if (attack_mode == ATTACK_MODE_COMBI)
5265 {
5266 fclose (device_param->combs_fp);
5267 }
5268
5269 free (wl_data->buf);
5270 free (wl_data);
5271
5272 fclose (fd);
5273 }
5274
5275 return NULL;
5276 }
5277
5278 static void weak_hash_check (hc_device_param_t *device_param, const uint salt_pos, const uint gpu_loops)
5279 {
5280 #ifdef _CUDA
5281 hc_cuCtxPushCurrent (device_param->context);
5282 #endif
5283
5284 salt_t *salt_buf = &data.salts_buf[salt_pos];
5285
5286 device_param->kernel_params_buf32[24] = salt_pos;
5287 device_param->kernel_params_buf32[27] = 1;
5288 device_param->kernel_params_buf32[28] = salt_buf->digests_cnt;
5289 device_param->kernel_params_buf32[29] = salt_buf->digests_offset;
5290 device_param->kernel_params_buf32[30] = 0;
5291 device_param->kernel_params_buf32[31] = 1;
5292
5293 char *dictfile_old = data.dictfile;
5294 char *dictfile2_old = data.dictfile2;
5295 char *mask_old = data.mask;
5296
5297 const char *weak_hash_check = "weak-hash-check";
5298
5299 data.dictfile = (char *) weak_hash_check;
5300 data.dictfile2 = (char *) weak_hash_check;
5301 data.mask = (char *) weak_hash_check;
5302
5303 /**
5304 * run the kernel
5305 */
5306
5307 if (data.attack_exec == ATTACK_EXEC_ON_GPU)
5308 {
5309 run_kernel (KERN_RUN_1, device_param, 1);
5310 }
5311 else
5312 {
5313 run_kernel (KERN_RUN_1, device_param, 1);
5314
5315 const uint iter = salt_buf->salt_iter;
5316
5317 for (uint loop_pos = 0; loop_pos < iter; loop_pos += gpu_loops)
5318 {
5319 uint loop_left = iter - loop_pos;
5320
5321 loop_left = MIN (loop_left, gpu_loops);
5322
5323 device_param->kernel_params_buf32[25] = loop_pos;
5324 device_param->kernel_params_buf32[26] = loop_left;
5325
5326 run_kernel (KERN_RUN_2, device_param, 1);
5327 }
5328
5329 run_kernel (KERN_RUN_3, device_param, 1);
5330 }
5331
5332 /**
5333 * result
5334 */
5335
5336 check_cracked (device_param, salt_pos);
5337
5338 /**
5339 * cleanup
5340 */
5341
5342 device_param->kernel_params_buf32[24] = 0;
5343 device_param->kernel_params_buf32[25] = 0;
5344 device_param->kernel_params_buf32[26] = 0;
5345 device_param->kernel_params_buf32[27] = 0;
5346 device_param->kernel_params_buf32[28] = 0;
5347 device_param->kernel_params_buf32[29] = 0;
5348 device_param->kernel_params_buf32[30] = 0;
5349 device_param->kernel_params_buf32[31] = 0;
5350
5351 data.dictfile = dictfile_old;
5352 data.dictfile2 = dictfile2_old;
5353 data.mask = mask_old;
5354
5355 #ifdef _CUDA
5356 hc_cuCtxPopCurrent (&device_param->context);
5357 #endif
5358 }
5359
5360 // hlfmt hashcat
5361
5362 static void hlfmt_hash_hashcat (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5363 {
5364 if (data.username == 0)
5365 {
5366 *hashbuf_pos = line_buf;
5367 *hashbuf_len = line_len;
5368 }
5369 else
5370 {
5371 char *pos = line_buf;
5372 int len = line_len;
5373
5374 for (int i = 0; i < line_len; i++, pos++, len--)
5375 {
5376 if (line_buf[i] == data.separator)
5377 {
5378 pos++;
5379
5380 len--;
5381
5382 break;
5383 }
5384 }
5385
5386 *hashbuf_pos = pos;
5387 *hashbuf_len = len;
5388 }
5389 }
5390
5391 static void hlfmt_user_hashcat (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5392 {
5393 char *pos = NULL;
5394 int len = 0;
5395
5396 int sep_cnt = 0;
5397
5398 for (int i = 0; i < line_len; i++)
5399 {
5400 if (line_buf[i] == data.separator)
5401 {
5402 sep_cnt++;
5403
5404 continue;
5405 }
5406
5407 if (sep_cnt == 0)
5408 {
5409 if (pos == NULL) pos = line_buf + i;
5410
5411 len++;
5412 }
5413 }
5414
5415 *userbuf_pos = pos;
5416 *userbuf_len = len;
5417 }
5418
5419 // hlfmt pwdump
5420
5421 static int hlfmt_detect_pwdump (char line_buf[BUFSIZ], int line_len)
5422 {
5423 int sep_cnt = 0;
5424
5425 int sep2_len = 0;
5426 int sep3_len = 0;
5427
5428 for (int i = 0; i < line_len; i++)
5429 {
5430 if (line_buf[i] == ':')
5431 {
5432 sep_cnt++;
5433
5434 continue;
5435 }
5436
5437 if (sep_cnt == 2) sep2_len++;
5438 if (sep_cnt == 3) sep3_len++;
5439 }
5440
5441 if ((sep_cnt == 6) && ((sep2_len == 32) || (sep3_len == 32))) return 1;
5442
5443 return 0;
5444 }
5445
5446 static void hlfmt_hash_pwdump (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5447 {
5448 char *pos = NULL;
5449 int len = 0;
5450
5451 int sep_cnt = 0;
5452
5453 for (int i = 0; i < line_len; i++)
5454 {
5455 if (line_buf[i] == ':')
5456 {
5457 sep_cnt++;
5458
5459 continue;
5460 }
5461
5462 if (data.hash_mode == 1000)
5463 {
5464 if (sep_cnt == 3)
5465 {
5466 if (pos == NULL) pos = line_buf + i;
5467
5468 len++;
5469 }
5470 }
5471 else if (data.hash_mode == 3000)
5472 {
5473 if (sep_cnt == 2)
5474 {
5475 if (pos == NULL) pos = line_buf + i;
5476
5477 len++;
5478 }
5479 }
5480 }
5481
5482 *hashbuf_pos = pos;
5483 *hashbuf_len = len;
5484 }
5485
5486 static void hlfmt_user_pwdump (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5487 {
5488 char *pos = NULL;
5489 int len = 0;
5490
5491 int sep_cnt = 0;
5492
5493 for (int i = 0; i < line_len; i++)
5494 {
5495 if (line_buf[i] == ':')
5496 {
5497 sep_cnt++;
5498
5499 continue;
5500 }
5501
5502 if (sep_cnt == 0)
5503 {
5504 if (pos == NULL) pos = line_buf + i;
5505
5506 len++;
5507 }
5508 }
5509
5510 *userbuf_pos = pos;
5511 *userbuf_len = len;
5512 }
5513
5514 // hlfmt passwd
5515
5516 static int hlfmt_detect_passwd (char line_buf[BUFSIZ], int line_len)
5517 {
5518 int sep_cnt = 0;
5519
5520 char sep5_first = 0;
5521 char sep6_first = 0;
5522
5523 for (int i = 0; i < line_len; i++)
5524 {
5525 if (line_buf[i] == ':')
5526 {
5527 sep_cnt++;
5528
5529 continue;
5530 }
5531
5532 if (sep_cnt == 5) if (sep5_first == 0) sep5_first = line_buf[i];
5533 if (sep_cnt == 6) if (sep6_first == 0) sep6_first = line_buf[i];
5534 }
5535
5536 if ((sep_cnt == 6) && ((sep5_first == '/') || (sep6_first == '/'))) return 1;
5537
5538 return 0;
5539 }
5540
5541 static void hlfmt_hash_passwd (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5542 {
5543 char *pos = NULL;
5544 int len = 0;
5545
5546 int sep_cnt = 0;
5547
5548 for (int i = 0; i < line_len; i++)
5549 {
5550 if (line_buf[i] == ':')
5551 {
5552 sep_cnt++;
5553
5554 continue;
5555 }
5556
5557 if (sep_cnt == 1)
5558 {
5559 if (pos == NULL) pos = line_buf + i;
5560
5561 len++;
5562 }
5563 }
5564
5565 *hashbuf_pos = pos;
5566 *hashbuf_len = len;
5567 }
5568
5569 static void hlfmt_user_passwd (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5570 {
5571 char *pos = NULL;
5572 int len = 0;
5573
5574 int sep_cnt = 0;
5575
5576 for (int i = 0; i < line_len; i++)
5577 {
5578 if (line_buf[i] == ':')
5579 {
5580 sep_cnt++;
5581
5582 continue;
5583 }
5584
5585 if (sep_cnt == 0)
5586 {
5587 if (pos == NULL) pos = line_buf + i;
5588
5589 len++;
5590 }
5591 }
5592
5593 *userbuf_pos = pos;
5594 *userbuf_len = len;
5595 }
5596
5597 // hlfmt shadow
5598
5599 static int hlfmt_detect_shadow (char line_buf[BUFSIZ], int line_len)
5600 {
5601 int sep_cnt = 0;
5602
5603 for (int i = 0; i < line_len; i++)
5604 {
5605 if (line_buf[i] == ':') sep_cnt++;
5606 }
5607
5608 if (sep_cnt == 8) return 1;
5609
5610 return 0;
5611 }
5612
5613 static void hlfmt_hash_shadow (char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5614 {
5615 hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len);
5616 }
5617
5618 static void hlfmt_user_shadow (char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5619 {
5620 hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len);
5621 }
5622
5623 // hlfmt main
5624
5625 static void hlfmt_hash (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **hashbuf_pos, int *hashbuf_len)
5626 {
5627 switch (hashfile_format)
5628 {
5629 case HLFMT_HASHCAT: hlfmt_hash_hashcat (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5630 case HLFMT_PWDUMP: hlfmt_hash_pwdump (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5631 case HLFMT_PASSWD: hlfmt_hash_passwd (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5632 case HLFMT_SHADOW: hlfmt_hash_shadow (line_buf, line_len, hashbuf_pos, hashbuf_len); break;
5633 }
5634 }
5635
5636 static void hlfmt_user (uint hashfile_format, char line_buf[BUFSIZ], int line_len, char **userbuf_pos, int *userbuf_len)
5637 {
5638 switch (hashfile_format)
5639 {
5640 case HLFMT_HASHCAT: hlfmt_user_hashcat (line_buf, line_len, userbuf_pos, userbuf_len); break;
5641 case HLFMT_PWDUMP: hlfmt_user_pwdump (line_buf, line_len, userbuf_pos, userbuf_len); break;
5642 case HLFMT_PASSWD: hlfmt_user_passwd (line_buf, line_len, userbuf_pos, userbuf_len); break;
5643 case HLFMT_SHADOW: hlfmt_user_shadow (line_buf, line_len, userbuf_pos, userbuf_len); break;
5644 }
5645 }
5646
5647 static uint hlfmt_detect (FILE *fp, uint max_check)
5648 {
5649 // Exception: those formats are wrongly detected as HLFMT_SHADOW, prevent it
5650
5651 if (data.hash_mode == 5300) return HLFMT_HASHCAT;
5652 if (data.hash_mode == 5400) return HLFMT_HASHCAT;
5653
5654 uint *formats_cnt = (uint *) mycalloc (HLFMTS_CNT, sizeof (uint));
5655
5656 uint num_check = 0;
5657
5658 while (!feof (fp))
5659 {
5660 char line_buf[BUFSIZ];
5661
5662 int line_len = fgetl (fp, line_buf);
5663
5664 if (line_len == 0) continue;
5665
5666 if (hlfmt_detect_pwdump (line_buf, line_len)) formats_cnt[HLFMT_PWDUMP]++;
5667 if (hlfmt_detect_passwd (line_buf, line_len)) formats_cnt[HLFMT_PASSWD]++;
5668 if (hlfmt_detect_shadow (line_buf, line_len)) formats_cnt[HLFMT_SHADOW]++;
5669
5670 if (num_check == max_check) break;
5671
5672 num_check++;
5673 }
5674
5675 uint hashlist_format = HLFMT_HASHCAT;
5676
5677 for (int i = 1; i < HLFMTS_CNT; i++)
5678 {
5679 if (formats_cnt[i - 1] >= formats_cnt[i]) continue;
5680
5681 hashlist_format = i;
5682 }
5683
5684 free (formats_cnt);
5685
5686 return hashlist_format;
5687 }
5688
5689 /**
5690 * main
5691 */
5692
5693 #ifdef _OCL
5694 void *__stdcall ADL_Main_Memory_Alloc (const int iSize)
5695 {
5696 return mymalloc (iSize);
5697 }
5698 #endif
5699
5700 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)
5701 {
5702 uint64_t collisions = 0;
5703
5704 const uint dgst_pos0 = data.dgst_pos0;
5705 const uint dgst_pos1 = data.dgst_pos1;
5706 const uint dgst_pos2 = data.dgst_pos2;
5707 const uint dgst_pos3 = data.dgst_pos3;
5708
5709 memset (bitmap_a, 0, bitmap_size);
5710 memset (bitmap_b, 0, bitmap_size);
5711 memset (bitmap_c, 0, bitmap_size);
5712 memset (bitmap_d, 0, bitmap_size);
5713
5714 for (uint i = 0; i < digests_cnt; i++)
5715 {
5716 uint *digest_ptr = (uint *) digests_buf_ptr;
5717
5718 digests_buf_ptr += dgst_size;
5719
5720 const uint val0 = 1 << (digest_ptr[dgst_pos0] & 0x1f);
5721 const uint val1 = 1 << (digest_ptr[dgst_pos1] & 0x1f);
5722 const uint val2 = 1 << (digest_ptr[dgst_pos2] & 0x1f);
5723 const uint val3 = 1 << (digest_ptr[dgst_pos3] & 0x1f);
5724
5725 const uint idx0 = (digest_ptr[dgst_pos0] >> dgst_shifts) & bitmap_mask;
5726 const uint idx1 = (digest_ptr[dgst_pos1] >> dgst_shifts) & bitmap_mask;
5727 const uint idx2 = (digest_ptr[dgst_pos2] >> dgst_shifts) & bitmap_mask;
5728 const uint idx3 = (digest_ptr[dgst_pos3] >> dgst_shifts) & bitmap_mask;
5729
5730 if (bitmap_a[idx0] & val0) collisions++;
5731 if (bitmap_b[idx1] & val1) collisions++;
5732 if (bitmap_c[idx2] & val2) collisions++;
5733 if (bitmap_d[idx3] & val3) collisions++;
5734
5735 bitmap_a[idx0] |= val0;
5736 bitmap_b[idx1] |= val1;
5737 bitmap_c[idx2] |= val2;
5738 bitmap_d[idx3] |= val3;
5739
5740 if (collisions >= collisions_max) return 0x7fffffff;
5741 }
5742
5743 return collisions;
5744 }
5745
5746 int main (int argc, char **argv)
5747 {
5748 /**
5749 * To help users a bit
5750 */
5751
5752 char *compute = getenv ("COMPUTE");
5753
5754 if (compute)
5755 {
5756 char display[100];
5757
5758 snprintf (display, sizeof (display) - 1, "DISPLAY=%s", compute);
5759
5760 putenv (display);
5761 }
5762 else
5763 {
5764 if (getenv ("DISPLAY") == NULL)
5765 putenv ((char *) "DISPLAY=:0");
5766 }
5767
5768 /*
5769 if (getenv ("GPU_MAX_ALLOC_PERCENT") == NULL)
5770 putenv ((char *) "GPU_MAX_ALLOC_PERCENT=100");
5771
5772 if (getenv ("GPU_USE_SYNC_OBJECTS") == NULL)
5773 putenv ((char *) "GPU_USE_SYNC_OBJECTS=1");
5774 */
5775
5776 /**
5777 * Real init
5778 */
5779
5780 memset (&data, 0, sizeof (hc_global_data_t));
5781
5782 time_t proc_start;
5783
5784 time (&proc_start);
5785
5786 data.proc_start = proc_start;
5787
5788 int myargc = argc;
5789 char **myargv = argv;
5790
5791 hc_thread_mutex_init (mux_dispatcher);
5792 hc_thread_mutex_init (mux_counter);
5793 hc_thread_mutex_init (mux_display);
5794 hc_thread_mutex_init (mux_adl);
5795
5796 /**
5797 * commandline parameters
5798 */
5799
5800 uint usage = USAGE;
5801 uint version = VERSION;
5802 uint quiet = QUIET;
5803 uint benchmark = BENCHMARK;
5804 uint benchmark_mode = BENCHMARK_MODE;
5805 uint show = SHOW;
5806 uint left = LEFT;
5807 uint username = USERNAME;
5808 uint remove = REMOVE;
5809 uint remove_timer = REMOVE_TIMER;
5810 uint64_t skip = SKIP;
5811 uint64_t limit = LIMIT;
5812 uint keyspace = KEYSPACE;
5813 uint potfile_disable = POTFILE_DISABLE;
5814 uint debug_mode = DEBUG_MODE;
5815 char *debug_file = NULL;
5816 char *induction_dir = NULL;
5817 char *outfile_check_dir = NULL;
5818 uint force = FORCE;
5819 uint runtime = RUNTIME;
5820 uint hash_mode = HASH_MODE;
5821 uint attack_mode = ATTACK_MODE;
5822 uint markov_disable = MARKOV_DISABLE;
5823 uint markov_classic = MARKOV_CLASSIC;
5824 uint markov_threshold = MARKOV_THRESHOLD;
5825 char *markov_hcstat = NULL;
5826 char *outfile = NULL;
5827 uint outfile_format = OUTFILE_FORMAT;
5828 uint outfile_autohex = OUTFILE_AUTOHEX;
5829 uint outfile_check_timer = OUTFILE_CHECK_TIMER;
5830 uint restore = RESTORE;
5831 uint restore_timer = RESTORE_TIMER;
5832 uint restore_disable = RESTORE_DISABLE;
5833 uint status = STATUS;
5834 uint status_timer = STATUS_TIMER;
5835 uint status_automat = STATUS_AUTOMAT;
5836 uint loopback = LOOPBACK;
5837 uint weak_hash_threshold = WEAK_HASH_THRESHOLD;
5838 char *session = NULL;
5839 uint hex_charset = HEX_CHARSET;
5840 uint hex_salt = HEX_SALT;
5841 uint hex_wordlist = HEX_WORDLIST;
5842 uint rp_gen = RP_GEN;
5843 uint rp_gen_func_min = RP_GEN_FUNC_MIN;
5844 uint rp_gen_func_max = RP_GEN_FUNC_MAX;
5845 uint rp_gen_seed = RP_GEN_SEED;
5846 char *rule_buf_l = (char *) RULE_BUF_L;
5847 char *rule_buf_r = (char *) RULE_BUF_R;
5848 uint increment = INCREMENT;
5849 uint increment_min = INCREMENT_MIN;
5850 uint increment_max = INCREMENT_MAX;
5851 char *cpu_affinity = NULL;
5852 uint gpu_async = GPU_ASYNC;
5853 char *gpu_devices = NULL;
5854 char *truecrypt_keyfiles = NULL;
5855 uint workload_profile = WORKLOAD_PROFILE;
5856 uint gpu_accel = GPU_ACCEL;
5857 uint gpu_loops = GPU_LOOPS;
5858 uint gpu_temp_disable = GPU_TEMP_DISABLE;
5859 uint gpu_temp_abort = GPU_TEMP_ABORT;
5860 uint gpu_temp_retain = GPU_TEMP_RETAIN;
5861 uint powertune_enable = POWERTUNE_ENABLE;
5862 uint logfile_disable = LOGFILE_DISABLE;
5863 uint segment_size = SEGMENT_SIZE;
5864 uint scrypt_tmto = SCRYPT_TMTO;
5865 char separator = SEPARATOR;
5866 uint bitmap_min = BITMAP_MIN;
5867 uint bitmap_max = BITMAP_MAX;
5868 char *custom_charset_1 = NULL;
5869 char *custom_charset_2 = NULL;
5870 char *custom_charset_3 = NULL;
5871 char *custom_charset_4 = NULL;
5872
5873 #define IDX_HELP 'h'
5874 #define IDX_VERSION 'V'
5875 #define IDX_VERSION_LOWER 'v'
5876 #define IDX_QUIET 0xff02
5877 #define IDX_SHOW 0xff03
5878 #define IDX_LEFT 0xff04
5879 #define IDX_REMOVE 0xff05
5880 #define IDX_REMOVE_TIMER 0xff37
5881 #define IDX_SKIP 's'
5882 #define IDX_LIMIT 'l'
5883 #define IDX_KEYSPACE 0xff35
5884 #define IDX_POTFILE_DISABLE 0xff06
5885 #define IDX_DEBUG_MODE 0xff43
5886 #define IDX_DEBUG_FILE 0xff44
5887 #define IDX_INDUCTION_DIR 0xff46
5888 #define IDX_OUTFILE_CHECK_DIR 0xff47
5889 #define IDX_USERNAME 0xff07
5890 #define IDX_FORCE 0xff08
5891 #define IDX_RUNTIME 0xff09
5892 #define IDX_BENCHMARK 'b'
5893 #define IDX_BENCHMARK_MODE 0xff32
5894 #define IDX_HASH_MODE 'm'
5895 #define IDX_ATTACK_MODE 'a'
5896 #define IDX_RP_FILE 'r'
5897 #define IDX_RP_GEN 'g'
5898 #define IDX_RP_GEN_FUNC_MIN 0xff10
5899 #define IDX_RP_GEN_FUNC_MAX 0xff11
5900 #define IDX_RP_GEN_SEED 0xff34
5901 #define IDX_RULE_BUF_L 'j'
5902 #define IDX_RULE_BUF_R 'k'
5903 #define IDX_INCREMENT 'i'
5904 #define IDX_INCREMENT_MIN 0xff12
5905 #define IDX_INCREMENT_MAX 0xff13
5906 #define IDX_OUTFILE 'o'
5907 #define IDX_OUTFILE_FORMAT 0xff14
5908 #define IDX_OUTFILE_AUTOHEX_DISABLE 0xff39
5909 #define IDX_OUTFILE_CHECK_TIMER 0xff45
5910 #define IDX_RESTORE 0xff15
5911 #define IDX_RESTORE_DISABLE 0xff27
5912 #define IDX_STATUS 0xff17
5913 #define IDX_STATUS_TIMER 0xff18
5914 #define IDX_STATUS_AUTOMAT 0xff50
5915 #define IDX_LOOPBACK 0xff38
5916 #define IDX_WEAK_HASH_THRESHOLD 0xff42
5917 #define IDX_SESSION 0xff19
5918 #define IDX_HEX_CHARSET 0xff20
5919 #define IDX_HEX_SALT 0xff21
5920 #define IDX_HEX_WORDLIST 0xff40
5921 #define IDX_MARKOV_DISABLE 0xff22
5922 #define IDX_MARKOV_CLASSIC 0xff23
5923 #define IDX_MARKOV_THRESHOLD 't'
5924 #define IDX_MARKOV_HCSTAT 0xff24
5925 #define IDX_CPU_AFFINITY 0xff25
5926 #define IDX_GPU_ASYNC 0xff26
5927 #define IDX_GPU_DEVICES 'd'
5928 #define IDX_WORKLOAD_PROFILE 'w'
5929 #define IDX_GPU_ACCEL 'n'
5930 #define IDX_GPU_LOOPS 'u'
5931 #define IDX_GPU_TEMP_DISABLE 0xff29
5932 #define IDX_GPU_TEMP_ABORT 0xff30
5933 #define IDX_GPU_TEMP_RETAIN 0xff31
5934 #define IDX_POWERTUNE_ENABLE 0xff41
5935 #define IDX_LOGFILE_DISABLE 0xff51
5936 #define IDX_TRUECRYPT_KEYFILES 0xff52
5937 #define IDX_SCRYPT_TMTO 0xff61
5938 #define IDX_SEGMENT_SIZE 'c'
5939 #define IDX_SEPARATOR 'p'
5940 #define IDX_BITMAP_MIN 0xff70
5941 #define IDX_BITMAP_MAX 0xff71
5942 #define IDX_CUSTOM_CHARSET_1 '1'
5943 #define IDX_CUSTOM_CHARSET_2 '2'
5944 #define IDX_CUSTOM_CHARSET_3 '3'
5945 #define IDX_CUSTOM_CHARSET_4 '4'
5946
5947 char short_options[] = "hVvm:a:r:j:k:g:o:t:d:n:u:c:p:s:l:1:2:3:4:ibw:";
5948
5949 struct option long_options[] =
5950 {
5951 {"help", no_argument, 0, IDX_HELP},
5952 {"version", no_argument, 0, IDX_VERSION},
5953 {"quiet", no_argument, 0, IDX_QUIET},
5954 {"show", no_argument, 0, IDX_SHOW},
5955 {"left", no_argument, 0, IDX_LEFT},
5956 {"username", no_argument, 0, IDX_USERNAME},
5957 {"remove", no_argument, 0, IDX_REMOVE},
5958 {"remove-timer", required_argument, 0, IDX_REMOVE_TIMER},
5959 {"skip", required_argument, 0, IDX_SKIP},
5960 {"limit", required_argument, 0, IDX_LIMIT},
5961 {"keyspace", no_argument, 0, IDX_KEYSPACE},
5962 {"potfile-disable", no_argument, 0, IDX_POTFILE_DISABLE},
5963 {"debug-mode", required_argument, 0, IDX_DEBUG_MODE},
5964 {"debug-file", required_argument, 0, IDX_DEBUG_FILE},
5965 {"induction-dir", required_argument, 0, IDX_INDUCTION_DIR},
5966 {"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR},
5967 {"force", no_argument, 0, IDX_FORCE},
5968 {"benchmark", no_argument, 0, IDX_BENCHMARK},
5969 {"benchmark-mode", required_argument, 0, IDX_BENCHMARK_MODE},
5970 {"restore", no_argument, 0, IDX_RESTORE},
5971 {"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE},
5972 {"status", no_argument, 0, IDX_STATUS},
5973 {"status-timer", required_argument, 0, IDX_STATUS_TIMER},
5974 {"status-automat", no_argument, 0, IDX_STATUS_AUTOMAT},
5975 {"loopback", no_argument, 0, IDX_LOOPBACK},
5976 {"weak-hash-threshold",
5977 required_argument, 0, IDX_WEAK_HASH_THRESHOLD},
5978 {"session", required_argument, 0, IDX_SESSION},
5979 {"runtime", required_argument, 0, IDX_RUNTIME},
5980 {"generate-rules", required_argument, 0, IDX_RP_GEN},
5981 {"generate-rules-func-min",
5982 required_argument, 0, IDX_RP_GEN_FUNC_MIN},
5983 {"generate-rules-func-max",
5984 required_argument, 0, IDX_RP_GEN_FUNC_MAX},
5985 {"generate-rules-seed",
5986 required_argument, 0, IDX_RP_GEN_SEED},
5987 {"rule-left", required_argument, 0, IDX_RULE_BUF_L},
5988 {"rule-right", required_argument, 0, IDX_RULE_BUF_R},
5989 {"hash-type", required_argument, 0, IDX_HASH_MODE},
5990 {"attack-mode", required_argument, 0, IDX_ATTACK_MODE},
5991 {"rules-file", required_argument, 0, IDX_RP_FILE},
5992 {"outfile", required_argument, 0, IDX_OUTFILE},
5993 {"outfile-format", required_argument, 0, IDX_OUTFILE_FORMAT},
5994 {"outfile-autohex-disable",
5995 no_argument, 0, IDX_OUTFILE_AUTOHEX_DISABLE},
5996 {"outfile-check-timer",
5997 required_argument, 0, IDX_OUTFILE_CHECK_TIMER},
5998 {"hex-charset", no_argument, 0, IDX_HEX_CHARSET},
5999 {"hex-salt", no_argument, 0, IDX_HEX_SALT},
6000 {"hex-wordlist", no_argument, 0, IDX_HEX_WORDLIST},
6001 {"markov-disable", no_argument, 0, IDX_MARKOV_DISABLE},
6002 {"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC},
6003 {"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD},
6004 {"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT},
6005 {"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
6006 {"gpu-async", no_argument, 0, IDX_GPU_ASYNC},
6007 {"gpu-devices", required_argument, 0, IDX_GPU_DEVICES},
6008 {"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE},
6009 {"gpu-accel", required_argument, 0, IDX_GPU_ACCEL},
6010 {"gpu-loops", required_argument, 0, IDX_GPU_LOOPS},
6011 {"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE},
6012 {"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
6013 {"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
6014 {"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
6015 {"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
6016 {"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
6017 {"segment-size", required_argument, 0, IDX_SEGMENT_SIZE},
6018 {"scrypt-tmto", required_argument, 0, IDX_SCRYPT_TMTO},
6019 // deprecated
6020 {"seperator", required_argument, 0, IDX_SEPARATOR},
6021 {"separator", required_argument, 0, IDX_SEPARATOR},
6022 {"bitmap-min", required_argument, 0, IDX_BITMAP_MIN},
6023 {"bitmap-max", required_argument, 0, IDX_BITMAP_MAX},
6024 {"increment", no_argument, 0, IDX_INCREMENT},
6025 {"increment-min", required_argument, 0, IDX_INCREMENT_MIN},
6026 {"increment-max", required_argument, 0, IDX_INCREMENT_MAX},
6027 {"custom-charset1", required_argument, 0, IDX_CUSTOM_CHARSET_1},
6028 {"custom-charset2", required_argument, 0, IDX_CUSTOM_CHARSET_2},
6029 {"custom-charset3", required_argument, 0, IDX_CUSTOM_CHARSET_3},
6030 {"custom-charset4", required_argument, 0, IDX_CUSTOM_CHARSET_4},
6031
6032 {0, 0, 0, 0}
6033 };
6034
6035 uint rp_files_cnt = 0;
6036
6037 char **rp_files = (char **) mycalloc (argc, sizeof (char *));
6038
6039 int option_index;
6040 int c;
6041
6042 optind = 1;
6043 optopt = 0;
6044 option_index = 0;
6045
6046 while (((c = getopt_long (argc, argv, short_options, long_options, &option_index)) != -1) && optopt == 0)
6047 {
6048 switch (c)
6049 {
6050 case IDX_HELP: usage = 1; break;
6051 case IDX_VERSION:
6052 case IDX_VERSION_LOWER: version = 1; break;
6053 case IDX_RESTORE: restore = 1; break;
6054 case IDX_SESSION: session = optarg; break;
6055 case IDX_SHOW: show = 1; break;
6056 case IDX_LEFT: left = 1; break;
6057 case '?': return (-1);
6058 }
6059 }
6060
6061 if (optopt != 0)
6062 {
6063 log_error ("ERROR: Invalid argument specified");
6064
6065 return (-1);
6066 }
6067
6068 /**
6069 * exit functions
6070 */
6071
6072 if (version)
6073 {
6074 log_info (VERSION_TXT);
6075
6076 return (0);
6077 }
6078
6079 if (usage)
6080 {
6081 usage_big_print (PROGNAME);
6082
6083 return (0);
6084 }
6085
6086 /**
6087 * session
6088 */
6089
6090 if (session == NULL) session = (char *) PROGNAME;
6091
6092 size_t session_size = strlen (session) + 32;
6093
6094 data.session = session;
6095
6096 char *eff_restore_file = (char *) mymalloc (session_size);
6097 char *new_restore_file = (char *) mymalloc (session_size);
6098
6099 snprintf (eff_restore_file, session_size - 1, "%s.restore", session);
6100 snprintf (new_restore_file, session_size - 1, "%s.restore.new", session);
6101
6102 data.eff_restore_file = eff_restore_file;
6103 data.new_restore_file = new_restore_file;
6104
6105 if (((show == 1) || (left == 1)) && (restore == 1))
6106 {
6107 if (show == 1) log_error ("ERROR: Mixing --restore parameter and --show is not supported");
6108 else log_error ("ERROR: Mixing --restore parameter and --left is not supported");
6109
6110 return (-1);
6111 }
6112
6113 // this allows the user to use --show and --left while cracking (i.e. while another instance of oclHashcat is running)
6114 if ((show == 1) || (left == 1))
6115 {
6116 restore_disable = 1;
6117
6118 restore = 0;
6119 }
6120
6121 data.restore_disable = restore_disable;
6122
6123 restore_data_t *rd = init_restore (argc, argv);
6124
6125 data.rd = rd;
6126
6127 /**
6128 * restore file
6129 */
6130
6131 if (restore == 1)
6132 {
6133 read_restore (eff_restore_file, rd);
6134
6135 if (rd->version_bin < RESTORE_MIN)
6136 {
6137 log_error ("ERROR: Incompatible restore-file version");
6138
6139 return (-1);
6140 }
6141
6142 myargc = rd->argc;
6143 myargv = rd->argv;
6144
6145 #ifdef _POSIX
6146 rd->pid = getpid ();
6147 #elif _WIN
6148 rd->pid = GetCurrentProcessId ();
6149 #endif
6150 }
6151
6152 uint hash_mode_chgd = 0;
6153 uint runtime_chgd = 0;
6154 uint gpu_loops_chgd = 0;
6155 uint gpu_accel_chgd = 0;
6156 uint attack_mode_chgd = 0;
6157 uint outfile_format_chgd = 0;
6158 uint rp_gen_seed_chgd = 0;
6159 uint remove_timer_chgd = 0;
6160 uint increment_min_chgd = 0;
6161 uint increment_max_chgd = 0;
6162
6163 #if _OCL
6164 uint gpu_temp_abort_chgd = 0;
6165 uint gpu_temp_retain_chgd = 0;
6166 #endif
6167
6168 optind = 1;
6169 optopt = 0;
6170 option_index = 0;
6171
6172 while (((c = getopt_long (myargc, myargv, short_options, long_options, &option_index)) != -1) && optopt == 0)
6173 {
6174 switch (c)
6175 {
6176 //case IDX_HELP: usage = 1; break;
6177 //case IDX_VERSION: version = 1; break;
6178 //case IDX_RESTORE: restore = 1; break;
6179 case IDX_QUIET: quiet = 1; break;
6180 //case IDX_SHOW: show = 1; break;
6181 case IDX_SHOW: break;
6182 //case IDX_LEFT: left = 1; break;
6183 case IDX_LEFT: break;
6184 case IDX_USERNAME: username = 1; break;
6185 case IDX_REMOVE: remove = 1; break;
6186 case IDX_REMOVE_TIMER: remove_timer = atoi (optarg);
6187 remove_timer_chgd = 1; break;
6188 case IDX_POTFILE_DISABLE: potfile_disable = 1; break;
6189 case IDX_DEBUG_MODE: debug_mode = atoi (optarg); break;
6190 case IDX_DEBUG_FILE: debug_file = optarg; break;
6191 case IDX_INDUCTION_DIR: induction_dir = optarg; break;
6192 case IDX_OUTFILE_CHECK_DIR: outfile_check_dir = optarg; break;
6193 case IDX_FORCE: force = 1; break;
6194 case IDX_SKIP: skip = atoll (optarg); break;
6195 case IDX_LIMIT: limit = atoll (optarg); break;
6196 case IDX_KEYSPACE: keyspace = 1; break;
6197 case IDX_BENCHMARK: benchmark = 1; break;
6198 case IDX_BENCHMARK_MODE: benchmark_mode = atoi (optarg); break;
6199 case IDX_RESTORE: break;
6200 case IDX_RESTORE_DISABLE: restore_disable = 1; break;
6201 case IDX_STATUS: status = 1; break;
6202 case IDX_STATUS_TIMER: status_timer = atoi (optarg); break;
6203 case IDX_STATUS_AUTOMAT: status_automat = 1; break;
6204 case IDX_LOOPBACK: loopback = 1; break;
6205 case IDX_WEAK_HASH_THRESHOLD:
6206 weak_hash_threshold = atoi (optarg); break;
6207 //case IDX_SESSION: session = optarg; break;
6208 case IDX_SESSION: break;
6209 case IDX_HASH_MODE: hash_mode = atoi (optarg);
6210 hash_mode_chgd = 1; break;
6211 case IDX_RUNTIME: runtime = atoi (optarg);
6212 runtime_chgd = 1; break;
6213 case IDX_ATTACK_MODE: attack_mode = atoi (optarg);
6214 attack_mode_chgd = 1; break;
6215 case IDX_RP_FILE: rp_files[rp_files_cnt++] = optarg; break;
6216 case IDX_RP_GEN: rp_gen = atoi (optarg); break;
6217 case IDX_RP_GEN_FUNC_MIN: rp_gen_func_min = atoi (optarg); break;
6218 case IDX_RP_GEN_FUNC_MAX: rp_gen_func_max = atoi (optarg); break;
6219 case IDX_RP_GEN_SEED: rp_gen_seed = atoi (optarg);
6220 rp_gen_seed_chgd = 1; break;
6221 case IDX_RULE_BUF_L: rule_buf_l = optarg; break;
6222 case IDX_RULE_BUF_R: rule_buf_r = optarg; break;
6223 case IDX_MARKOV_DISABLE: markov_disable = 1; break;
6224 case IDX_MARKOV_CLASSIC: markov_classic = 1; break;
6225 case IDX_MARKOV_THRESHOLD: markov_threshold = atoi (optarg); break;
6226 case IDX_MARKOV_HCSTAT: markov_hcstat = optarg; break;
6227 case IDX_OUTFILE: outfile = optarg; break;
6228 case IDX_OUTFILE_FORMAT: outfile_format = atoi (optarg);
6229 outfile_format_chgd = 1; break;
6230 case IDX_OUTFILE_AUTOHEX_DISABLE:
6231 outfile_autohex = 0; break;
6232 case IDX_OUTFILE_CHECK_TIMER:
6233 outfile_check_timer = atoi (optarg); break;
6234 case IDX_HEX_CHARSET: hex_charset = 1; break;
6235 case IDX_HEX_SALT: hex_salt = 1; break;
6236 case IDX_HEX_WORDLIST: hex_wordlist = 1; break;
6237 case IDX_CPU_AFFINITY: cpu_affinity = optarg; break;
6238 case IDX_GPU_ASYNC: gpu_async = 1; break;
6239 case IDX_GPU_DEVICES: gpu_devices = optarg; break;
6240 case IDX_WORKLOAD_PROFILE: workload_profile = atoi (optarg); break;
6241 case IDX_GPU_ACCEL: gpu_accel = atoi (optarg);
6242 gpu_accel_chgd = 1; break;
6243 case IDX_GPU_LOOPS: gpu_loops = atoi (optarg);
6244 gpu_loops_chgd = 1; break;
6245 case IDX_GPU_TEMP_DISABLE: gpu_temp_disable = 1; break;
6246 case IDX_GPU_TEMP_ABORT:
6247 #if _OCL
6248 gpu_temp_abort_chgd = 1;
6249 #endif
6250 gpu_temp_abort = atoi (optarg); break;
6251 case IDX_GPU_TEMP_RETAIN:
6252 #if _OCL
6253 gpu_temp_retain_chgd = 1;
6254 #endif
6255 gpu_temp_retain = atoi (optarg); break;
6256 case IDX_POWERTUNE_ENABLE: powertune_enable = 1; break;
6257 case IDX_LOGFILE_DISABLE: logfile_disable = 1; break;
6258 case IDX_TRUECRYPT_KEYFILES: truecrypt_keyfiles = optarg; break;
6259 case IDX_SEGMENT_SIZE: segment_size = atoi (optarg); break;
6260 case IDX_SCRYPT_TMTO: scrypt_tmto = atoi (optarg); break;
6261 case IDX_SEPARATOR: separator = optarg[0]; break;
6262 case IDX_BITMAP_MIN: bitmap_min = atoi (optarg); break;
6263 case IDX_BITMAP_MAX: bitmap_max = atoi (optarg); break;
6264 case IDX_INCREMENT: increment = 1; break;
6265 case IDX_INCREMENT_MIN: increment_min = atoi (optarg);
6266 increment_min_chgd = 1; break;
6267 case IDX_INCREMENT_MAX: increment_max = atoi (optarg);
6268 increment_max_chgd = 1; break;
6269 case IDX_CUSTOM_CHARSET_1: custom_charset_1 = optarg; break;
6270 case IDX_CUSTOM_CHARSET_2: custom_charset_2 = optarg; break;
6271 case IDX_CUSTOM_CHARSET_3: custom_charset_3 = optarg; break;
6272 case IDX_CUSTOM_CHARSET_4: custom_charset_4 = optarg; break;
6273
6274 default:
6275 log_error ("ERROR: Invalid argument specified");
6276 return (-1);
6277 }
6278 }
6279
6280 if (optopt != 0)
6281 {
6282 log_error ("ERROR: Invalid argument specified");
6283
6284 return (-1);
6285 }
6286
6287 /**
6288 * Inform user things getting started,
6289 * - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
6290 * - we do not need to check algorithm_pos
6291 */
6292
6293 if (quiet == 0)
6294 {
6295 if (benchmark == 1)
6296 {
6297 log_info ("%s v%.2f starting in benchmark-mode...", PROGNAME, (float) VERSION_BIN / 100);
6298
6299 log_info ("");
6300 }
6301 else if (restore == 1)
6302 {
6303 log_info ("%s v%.2f starting in restore-mode...", PROGNAME, (float) VERSION_BIN / 100);
6304
6305 log_info ("");
6306 }
6307 else
6308 {
6309 log_info ("%s v%.2f starting...", PROGNAME, (float) VERSION_BIN / 100);
6310
6311 log_info ("");
6312 }
6313 }
6314
6315 /**
6316 * sanity check
6317 */
6318
6319 if (attack_mode > 7)
6320 {
6321 log_error ("ERROR: Invalid attack-mode specified");
6322
6323 return (-1);
6324 }
6325
6326 if (runtime_chgd && runtime == 0) // just added to remove compiler warnings for runtime_chgd
6327 {
6328 log_error ("ERROR: Invalid runtime specified");
6329
6330 return (-1);
6331 }
6332
6333 if (hash_mode_chgd && hash_mode > 12800) // just added to remove compiler warnings for hash_mode_chgd
6334 {
6335 log_error ("ERROR: Invalid hash-type specified");
6336
6337 return (-1);
6338 }
6339
6340 // renamed hash modes
6341
6342 if (hash_mode_chgd)
6343 {
6344 int n = -1;
6345
6346 switch (hash_mode)
6347 {
6348 case 123: n = 124;
6349 break;
6350 }
6351
6352 if (n >= 0)
6353 {
6354 log_error ("Old -m specified, use -m %d instead", n);
6355
6356 return (-1);
6357 }
6358 }
6359
6360 if (username == 1)
6361 {
6362 if ((hash_mode == 2500) || (hash_mode == 5200) || ((hash_mode >= 6200) && (hash_mode <= 6299)))
6363 {
6364 log_error ("ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (hash_mode));
6365
6366 return (-1);
6367 }
6368 }
6369
6370 if (outfile_format > 16)
6371 {
6372 log_error ("ERROR: Invalid outfile-format specified");
6373
6374 return (-1);
6375 }
6376
6377 if (left == 1)
6378 {
6379 if (outfile_format_chgd == 1)
6380 {
6381 if (outfile_format > 1)
6382 {
6383 log_error ("ERROR: Mixing outfile-format > 1 is not allowed together with left parameter");
6384
6385 return (-1);
6386 }
6387 }
6388 else
6389 {
6390 outfile_format = OUTFILE_FMT_HASH;
6391 }
6392 }
6393
6394 if (show == 1)
6395 {
6396 if (outfile_format_chgd == 1)
6397 {
6398 if ((outfile_format > 7) && (outfile_format < 16))
6399 {
6400 log_error ("ERROR: Mixing outfile-format > 7 is not allowed together with show parameter");
6401
6402 return (-1);
6403 }
6404 }
6405 }
6406
6407 if (increment_min < INCREMENT_MIN)
6408 {
6409 log_error ("ERROR: Invalid increment-min specified");
6410
6411 return (-1);
6412 }
6413
6414 if (increment_max > INCREMENT_MAX)
6415 {
6416 log_error ("ERROR: Invalid increment-max specified");
6417
6418 return (-1);
6419 }
6420
6421 if (increment_min > increment_max)
6422 {
6423 log_error ("ERROR: Invalid increment-min specified");
6424
6425 return (-1);
6426 }
6427
6428 if ((increment == 1) && (attack_mode == ATTACK_MODE_STRAIGHT))
6429 {
6430 log_error ("ERROR: increment is not allowed in attack-mode 0");
6431
6432 return (-1);
6433 }
6434
6435 if ((increment == 0) && (increment_min_chgd == 1))
6436 {
6437 log_error ("ERROR: increment-min is only supported together with increment switch");
6438
6439 return (-1);
6440 }
6441
6442 if ((increment == 0) && (increment_max_chgd == 1))
6443 {
6444 log_error ("ERROR: increment-max is only supported together with increment switch");
6445
6446 return (-1);
6447 }
6448
6449 if (rp_files_cnt && rp_gen)
6450 {
6451 log_error ("ERROR: Use of both rules-file and rules-generate is not supported");
6452
6453 return (-1);
6454 }
6455
6456 if (rp_files_cnt || rp_gen)
6457 {
6458 if (attack_mode != ATTACK_MODE_STRAIGHT)
6459 {
6460 log_error ("ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0");
6461
6462 return (-1);
6463 }
6464 }
6465
6466 if (rp_gen_func_min > rp_gen_func_max)
6467 {
6468 log_error ("ERROR: Invalid rp-gen-func-min specified");
6469
6470 return (-1);
6471 }
6472
6473 if (gpu_accel_chgd == 1)
6474 {
6475 if (workload_profile != WORKLOAD_PROFILE)
6476 {
6477 log_error ("ERROR: gpu-accel parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
6478
6479 return (-1);
6480 }
6481
6482 if (gpu_accel < 1)
6483 {
6484 log_error ("ERROR: Invalid gpu-accel specified");
6485
6486 return (-1);
6487 }
6488
6489 if (gpu_accel > 800)
6490 {
6491 log_error ("ERROR: Invalid gpu-accel specified");
6492
6493 return (-1);
6494 }
6495 }
6496
6497 if (gpu_loops_chgd == 1)
6498 {
6499 if (workload_profile != WORKLOAD_PROFILE)
6500 {
6501 log_error ("ERROR: gpu-loops parameter can only be set when workload-profile %i is used", WORKLOAD_PROFILE);
6502
6503 return (-1);
6504 }
6505
6506 if (gpu_loops < 1)
6507 {
6508 log_error ("ERROR: Invalid gpu-loops specified");
6509
6510 return (-1);
6511 }
6512
6513 if (gpu_loops > 1024)
6514 {
6515 log_error ("ERROR: Invalid gpu-loops specified");
6516
6517 return (-1);
6518 }
6519 }
6520
6521 if (benchmark == 1)
6522 {
6523 if (workload_profile != WORKLOAD_PROFILE)
6524 {
6525 log_error ("ERROR: Using the workload-profile in benchmark mode is not allowed");
6526
6527 return (-1);
6528 }
6529 }
6530
6531 if ((workload_profile < 1) || (workload_profile > 3))
6532 {
6533 log_error ("ERROR: workload-profile %i not available", workload_profile);
6534
6535 return (-1);
6536 }
6537
6538 if (show == 1 || left == 1)
6539 {
6540 attack_mode = ATTACK_MODE_NONE;
6541
6542 if (remove == 1)
6543 {
6544 log_error ("ERROR: Mixing remove parameter not allowed with show parameter or left parameter");
6545
6546 return (-1);
6547 }
6548
6549 if (potfile_disable == 1)
6550 {
6551 log_error ("ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter");
6552
6553 return (-1);
6554 }
6555 }
6556
6557 uint attack_kern = ATTACK_KERN_NONE;
6558
6559 switch (attack_mode)
6560 {
6561 case ATTACK_MODE_STRAIGHT: attack_kern = ATTACK_KERN_STRAIGHT; break;
6562 case ATTACK_MODE_COMBI: attack_kern = ATTACK_KERN_COMBI; break;
6563 case ATTACK_MODE_BF: attack_kern = ATTACK_KERN_BF; break;
6564 case ATTACK_MODE_HYBRID1: attack_kern = ATTACK_KERN_COMBI; break;
6565 case ATTACK_MODE_HYBRID2: attack_kern = ATTACK_KERN_COMBI; break;
6566 }
6567
6568 if (benchmark == 0)
6569 {
6570 if (keyspace == 1)
6571 {
6572 int num_additional_params = 1;
6573
6574 if (attack_kern == ATTACK_KERN_COMBI)
6575 {
6576 num_additional_params = 2;
6577 }
6578
6579 int keyspace_wordlist_specified = myargc - optind - num_additional_params;
6580
6581 if (keyspace_wordlist_specified == 0) optind--;
6582 }
6583
6584 if (attack_kern == ATTACK_KERN_NONE)
6585 {
6586 if ((optind + 1) != myargc)
6587 {
6588 usage_mini_print (myargv[0]);
6589
6590 return (-1);
6591 }
6592 }
6593 else if (attack_kern == ATTACK_KERN_STRAIGHT)
6594 {
6595 if ((optind + 1) > myargc)
6596 {
6597 usage_mini_print (myargv[0]);
6598
6599 return (-1);
6600 }
6601 }
6602 else if (attack_kern == ATTACK_KERN_COMBI)
6603 {
6604 if ((optind + 3) != myargc)
6605 {
6606 usage_mini_print (myargv[0]);
6607
6608 return (-1);
6609 }
6610 }
6611 else if (attack_kern == ATTACK_KERN_BF)
6612 {
6613 if ((optind + 1) > myargc)
6614 {
6615 usage_mini_print (myargv[0]);
6616
6617 return (-1);
6618 }
6619 }
6620 else
6621 {
6622 usage_mini_print (myargv[0]);
6623
6624 return (-1);
6625 }
6626 }
6627 else
6628 {
6629 if (myargv[optind] != 0)
6630 {
6631 log_error ("ERROR: Invalid argument for benchmark mode specified");
6632
6633 return (-1);
6634 }
6635
6636 if (attack_mode_chgd == 1)
6637 {
6638 if (attack_mode != ATTACK_MODE_BF)
6639 {
6640 log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode");
6641
6642 return (-1);
6643 }
6644 }
6645
6646 if (benchmark_mode == 0)
6647 {
6648 // nothing to do
6649 }
6650 else if (benchmark_mode == 1)
6651 {
6652 if (gpu_accel_chgd == 1 || gpu_loops_chgd == 1)
6653 {
6654 log_error ("ERROR: Benchmark-mode 1 does not allow gpu-accel or gpu-loops changed");
6655
6656 return (-1);
6657 }
6658 }
6659 else
6660 {
6661 log_error ("ERROR: Benchmark-mode must be 0 or 1");
6662
6663 return (-1);
6664 }
6665 }
6666
6667 if (skip != 0 && limit != 0)
6668 {
6669 limit += skip;
6670 }
6671
6672 if (keyspace == 1)
6673 {
6674 if (show == 1)
6675 {
6676 log_error ("ERROR: Mixing show parameter not supported with keyspace parameter");
6677
6678 return (-1);
6679 }
6680 else if (left == 1)
6681 {
6682 log_error ("ERROR: Mixing left parameter not supported wiht keyspace parameter");
6683
6684 return (-1);
6685 }
6686
6687 potfile_disable = 1;
6688
6689 restore_disable = 1;
6690
6691 restore = 0;
6692
6693 weak_hash_threshold = 0;
6694
6695 quiet = 1;
6696 }
6697
6698 if (remove_timer_chgd == 1)
6699 {
6700 if (remove == 0)
6701 {
6702 log_error ("ERROR: Parameter remove-timer require parameter remove enabled");
6703
6704 return (-1);
6705 }
6706
6707 if (remove_timer < 1)
6708 {
6709 log_error ("ERROR: Parameter remove-timer must have a value greater than or equal to 1");
6710
6711 return (-1);
6712 }
6713 }
6714
6715 if (loopback == 1)
6716 {
6717 if (attack_mode == ATTACK_MODE_BF)
6718 {
6719 log_error ("ERROR: Parameter loopback not allowed in attack-mode 3");
6720
6721 return (-1);
6722 }
6723 else if (attack_mode == ATTACK_MODE_STRAIGHT)
6724 {
6725 if ((rp_files_cnt == 0) && (rp_gen == 0))
6726 {
6727 log_error ("ERROR: Parameter loopback not allowed without rules-file or rules-generate");
6728
6729 return (-1);
6730 }
6731 }
6732 }
6733
6734 if (debug_mode > 0)
6735 {
6736 if (attack_mode != ATTACK_MODE_STRAIGHT)
6737 {
6738 log_error ("ERROR: Parameter debug-mode option is only available with attack-mode 0");
6739
6740 return (-1);
6741 }
6742
6743 if ((rp_files_cnt == 0) && (rp_gen == 0))
6744 {
6745 log_error ("ERROR: Parameter debug-mode not allowed without rules-file or rules-generate");
6746
6747 return (-1);
6748 }
6749 }
6750
6751 if (debug_mode > 4)
6752 {
6753 log_error ("ERROR: Invalid debug-mode specified");
6754
6755 return (-1);
6756 }
6757
6758 if (debug_file != NULL)
6759 {
6760 if (debug_mode < 1)
6761 {
6762 log_error ("ERROR: Parameter debug-file requires parameter debug-mode to be set");
6763
6764 return (-1);
6765 }
6766 }
6767
6768 if (induction_dir != NULL)
6769 {
6770 if (attack_mode == ATTACK_MODE_BF)
6771 {
6772 log_error ("ERROR: Parameter induction-dir not allowed with brute-force attacks");
6773
6774 return (-1);
6775 }
6776 }
6777
6778 /**
6779 * induction directory
6780 */
6781
6782 char *induction_directory = NULL;
6783
6784 if (attack_mode != ATTACK_MODE_BF)
6785 {
6786 if (induction_dir == NULL)
6787 {
6788 induction_directory = (char *) mymalloc (session_size);
6789
6790 snprintf (induction_directory, session_size - 1, "%s.%s", session, INDUCT_DIR);
6791
6792 // create induction folder if it does not already exist
6793
6794 if (keyspace == 0)
6795 {
6796 if (rmdir (induction_directory) == -1)
6797 {
6798 if (errno == ENOENT)
6799 {
6800 // good, we can ignore
6801 }
6802 else if (errno == ENOTEMPTY)
6803 {
6804 char *induction_directory_mv = (char *) mymalloc (session_size);
6805
6806 snprintf (induction_directory_mv, session_size - 1, "%s.induct.%d", session, (int) proc_start);
6807
6808 if (rename (induction_directory, induction_directory_mv) != 0)
6809 {
6810 log_error ("ERROR: Rename directory %s to %s: %s", induction_directory, induction_directory_mv, strerror (errno));
6811
6812 return (-1);
6813 }
6814 }
6815 else
6816 {
6817 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6818
6819 return (-1);
6820 }
6821 }
6822
6823 #ifdef _WIN
6824 #define mkdir(name,mode) mkdir (name)
6825 #endif
6826
6827 if (mkdir (induction_directory, 0700) == -1)
6828 {
6829 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
6830
6831 return (-1);
6832 }
6833 }
6834 }
6835 else
6836 {
6837 induction_directory = induction_dir;
6838 }
6839 }
6840
6841 data.induction_directory = induction_directory;
6842
6843 /**
6844 * loopback
6845 */
6846
6847 size_t loopback_size = session_size + strlen (LOOPBACK_FILE) + 12;
6848
6849 char *loopback_file = (char *) mymalloc (loopback_size);
6850
6851 /**
6852 * outfile-check directory
6853 */
6854
6855 char *outfile_check_directory = NULL;
6856
6857 if (outfile_check_dir == NULL)
6858 {
6859 outfile_check_directory = (char *) mymalloc (session_size);
6860
6861 snprintf (outfile_check_directory, session_size - 1, "%s.%s", session, OUTFILES_DIR);
6862 }
6863 else
6864 {
6865 outfile_check_directory = outfile_check_dir;
6866 }
6867
6868 data.outfile_check_directory = outfile_check_directory;
6869
6870 if (keyspace == 0)
6871 {
6872 struct stat outfile_check_stat;
6873
6874 if (stat (outfile_check_directory, &outfile_check_stat) == 0)
6875 {
6876 uint is_dir = S_ISDIR (outfile_check_stat.st_mode);
6877
6878 if (is_dir == 0)
6879 {
6880 log_error ("ERROR: Directory specified in outfile-check '%s' is not a valid directory", outfile_check_directory);
6881
6882 return (-1);
6883 }
6884 }
6885 else if (outfile_check_dir == NULL)
6886 {
6887 #ifdef _WIN
6888 #define mkdir(name,mode) mkdir (name)
6889 #endif
6890
6891 if (mkdir (outfile_check_directory, 0700) == -1)
6892 {
6893 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
6894
6895 return (-1);
6896 }
6897 }
6898 }
6899
6900 /**
6901 * special other stuff
6902 */
6903
6904 if (hash_mode == 9710)
6905 {
6906 outfile_format = 5;
6907 outfile_format_chgd = 1;
6908 }
6909
6910 if (hash_mode == 9810)
6911 {
6912 outfile_format = 5;
6913 outfile_format_chgd = 1;
6914 }
6915
6916 if (hash_mode == 10410)
6917 {
6918 outfile_format = 5;
6919 outfile_format_chgd = 1;
6920 }
6921
6922 /**
6923 * store stuff
6924 */
6925
6926 data.hash_mode = hash_mode;
6927 data.restore = restore;
6928 data.restore_timer = restore_timer;
6929 data.restore_disable = restore_disable;
6930 data.status = status;
6931 data.status_timer = status_timer;
6932 data.status_automat = status_automat;
6933 data.loopback = loopback;
6934 data.runtime = runtime;
6935 data.remove = remove;
6936 data.remove_timer = remove_timer;
6937 data.debug_mode = debug_mode;
6938 data.debug_file = debug_file;
6939 data.username = username;
6940 data.quiet = quiet;
6941 data.outfile = outfile;
6942 data.outfile_format = outfile_format;
6943 data.outfile_autohex = outfile_autohex;
6944 data.hex_charset = hex_charset;
6945 data.hex_salt = hex_salt;
6946 data.hex_wordlist = hex_wordlist;
6947 data.separator = separator;
6948 data.rp_files = rp_files;
6949 data.rp_files_cnt = rp_files_cnt;
6950 data.rp_gen = rp_gen;
6951 data.rp_gen_seed = rp_gen_seed;
6952 data.force = force;
6953 data.benchmark = benchmark;
6954 data.skip = skip;
6955 data.limit = limit;
6956 data.powertune_enable = powertune_enable;
6957 data.logfile_disable = logfile_disable;
6958 data.truecrypt_keyfiles = truecrypt_keyfiles;
6959 data.scrypt_tmto = scrypt_tmto;
6960
6961 /**
6962 * install_dir
6963 */
6964
6965 char *install_dir = get_install_dir (myargv[0]);
6966
6967 data.install_dir = install_dir;
6968
6969 /**
6970 * cpu affinity
6971 */
6972
6973 if (cpu_affinity)
6974 {
6975 set_cpu_affinity (cpu_affinity);
6976 }
6977
6978 if (rp_gen_seed_chgd == 0)
6979 {
6980 srand (proc_start);
6981 }
6982 else
6983 {
6984 srand (rp_gen_seed);
6985 }
6986
6987 /**
6988 * logfile init
6989 */
6990
6991 if (logfile_disable == 0)
6992 {
6993 size_t logfile_size = strlen (session) + 32;
6994
6995 char *logfile = (char *) mymalloc (logfile_size);
6996
6997 snprintf (logfile, logfile_size - 1, "%s.log", session);
6998
6999 data.logfile = logfile;
7000
7001 char *topid = logfile_generate_topid ();
7002
7003 data.topid = topid;
7004 }
7005
7006 // logfile_append() checks for logfile_disable internally to make it easier from here
7007
7008 #define logfile_top_msg(msg) logfile_append ("%s\t%s", data.topid, (msg));
7009 #define logfile_sub_msg(msg) logfile_append ("%s\t%s\t%s", data.topid, data.subid, (msg));
7010 #define logfile_top_var_uint64(var,val) logfile_append ("%s\t%s\t%llu", data.topid, (var), (val));
7011 #define logfile_sub_var_uint64(var,val) logfile_append ("%s\t%s\t%s\t%llu", data.topid, data.subid, (var), (val));
7012 #define logfile_top_var_uint(var,val) logfile_append ("%s\t%s\t%u", data.topid, (var), (val));
7013 #define logfile_sub_var_uint(var,val) logfile_append ("%s\t%s\t%s\t%u", data.topid, data.subid, (var), (val));
7014 #define logfile_top_var_char(var,val) logfile_append ("%s\t%s\t%c", data.topid, (var), (val));
7015 #define logfile_sub_var_char(var,val) logfile_append ("%s\t%s\t%s\t%c", data.topid, data.subid, (var), (val));
7016 #define logfile_top_var_string(var,val) if ((val) != NULL) logfile_append ("%s\t%s\t%s", data.topid, (var), (val));
7017 #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));
7018
7019 #define logfile_top_uint64(var) logfile_top_var_uint64 (#var, (var));
7020 #define logfile_sub_uint64(var) logfile_sub_var_uint64 (#var, (var));
7021 #define logfile_top_uint(var) logfile_top_var_uint (#var, (var));
7022 #define logfile_sub_uint(var) logfile_sub_var_uint (#var, (var));
7023 #define logfile_top_char(var) logfile_top_var_char (#var, (var));
7024 #define logfile_sub_char(var) logfile_sub_var_char (#var, (var));
7025 #define logfile_top_string(var) logfile_top_var_string (#var, (var));
7026 #define logfile_sub_string(var) logfile_sub_var_string (#var, (var));
7027
7028 logfile_top_msg ("START");
7029
7030 logfile_top_uint (attack_mode);
7031 logfile_top_uint (attack_kern);
7032 logfile_top_uint (benchmark);
7033 logfile_top_uint (benchmark_mode);
7034 logfile_top_uint (bitmap_min);
7035 logfile_top_uint (bitmap_max);
7036 logfile_top_uint (debug_mode);
7037 logfile_top_uint (force);
7038 logfile_top_uint (gpu_accel);
7039 logfile_top_uint (gpu_async);
7040 logfile_top_uint (gpu_loops);
7041 logfile_top_uint (gpu_temp_abort);
7042 logfile_top_uint (gpu_temp_disable);
7043 logfile_top_uint (gpu_temp_retain);
7044 logfile_top_uint (hash_mode);
7045 logfile_top_uint (hex_charset);
7046 logfile_top_uint (hex_salt);
7047 logfile_top_uint (hex_wordlist);
7048 logfile_top_uint (increment);
7049 logfile_top_uint (increment_max);
7050 logfile_top_uint (increment_min);
7051 logfile_top_uint (keyspace);
7052 logfile_top_uint (left);
7053 logfile_top_uint (logfile_disable);
7054 logfile_top_uint (loopback);
7055 logfile_top_uint (markov_classic);
7056 logfile_top_uint (markov_disable);
7057 logfile_top_uint (markov_threshold);
7058 logfile_top_uint (outfile_autohex);
7059 logfile_top_uint (outfile_check_timer);
7060 logfile_top_uint (outfile_format);
7061 logfile_top_uint (potfile_disable);
7062 logfile_top_uint (powertune_enable);
7063 logfile_top_uint (scrypt_tmto);
7064 logfile_top_uint (quiet);
7065 logfile_top_uint (remove);
7066 logfile_top_uint (remove_timer);
7067 logfile_top_uint (restore);
7068 logfile_top_uint (restore_disable);
7069 logfile_top_uint (restore_timer);
7070 logfile_top_uint (rp_gen);
7071 logfile_top_uint (rp_gen_func_max);
7072 logfile_top_uint (rp_gen_func_min);
7073 logfile_top_uint (rp_gen_seed);
7074 logfile_top_uint (runtime);
7075 logfile_top_uint (segment_size);
7076 logfile_top_uint (show);
7077 logfile_top_uint (status);
7078 logfile_top_uint (status_automat);
7079 logfile_top_uint (status_timer);
7080 logfile_top_uint (usage);
7081 logfile_top_uint (username);
7082 logfile_top_uint (version);
7083 logfile_top_uint (weak_hash_threshold);
7084 logfile_top_uint (workload_profile);
7085 logfile_top_uint64 (limit);
7086 logfile_top_uint64 (skip);
7087 logfile_top_char (separator);
7088 logfile_top_string (cpu_affinity);
7089 logfile_top_string (custom_charset_1);
7090 logfile_top_string (custom_charset_2);
7091 logfile_top_string (custom_charset_3);
7092 logfile_top_string (custom_charset_4);
7093 logfile_top_string (debug_file);
7094 logfile_top_string (gpu_devices);
7095 logfile_top_string (induction_dir);
7096 logfile_top_string (markov_hcstat);
7097 logfile_top_string (outfile);
7098 logfile_top_string (outfile_check_dir);
7099 logfile_top_string (rule_buf_l);
7100 logfile_top_string (rule_buf_r);
7101 logfile_top_string (session);
7102 logfile_top_string (truecrypt_keyfiles);
7103
7104 /**
7105 * devices
7106 */
7107
7108 uint gpu_devicemask = devices_to_devicemask (gpu_devices);
7109
7110 /**
7111 * benchmark
7112 */
7113
7114 if (benchmark == 1)
7115 {
7116 /**
7117 * disable useless stuff for benchmark
7118 */
7119
7120 restore_timer = 0;
7121 status_timer = 0;
7122 restore_disable = 1;
7123 potfile_disable = 1;
7124 weak_hash_threshold = 0;
7125
7126 data.restore_timer = restore_timer;
7127 data.status_timer = status_timer;
7128 data.restore_disable = restore_disable;
7129
7130 if (benchmark_mode == 1)
7131 {
7132 markov_disable = 1;
7133 }
7134
7135 /**
7136 * force attack mode to be bruteforce
7137 */
7138
7139 attack_mode = ATTACK_MODE_BF;
7140 attack_kern = ATTACK_KERN_BF;
7141
7142 if (runtime_chgd == 0)
7143 {
7144 runtime = 4;
7145
7146 if (benchmark_mode == 1) runtime = 17;
7147
7148 data.runtime = runtime;
7149 }
7150 }
7151
7152 /**
7153 * config
7154 */
7155
7156 uint hash_type = 0;
7157 uint salt_type = 0;
7158 uint attack_exec = 0;
7159 uint opts_type = 0;
7160 uint kern_type = 0;
7161 uint dgst_size = 0;
7162 uint esalt_size = 0;
7163 uint opti_type = 0;
7164 uint dgst_pos0 = -1;
7165 uint dgst_pos1 = -1;
7166 uint dgst_pos2 = -1;
7167 uint dgst_pos3 = -1;
7168
7169 int (*parse_func) (char *, uint, hash_t *);
7170 int (*sort_by_digest) (const void *, const void *);
7171
7172 uint algorithm_pos = 0;
7173 uint algorithm_max = 1;
7174
7175 uint *algorithms = default_benchmark_algorithms;
7176
7177 if (benchmark == 1 && hash_mode_chgd == 0) algorithm_max = NUM_DEFAULT_BENCHMARK_ALGORITHMS;
7178
7179 for (algorithm_pos = 0; algorithm_pos < algorithm_max; algorithm_pos++)
7180 {
7181 /*
7182 * We need to reset 'rd' in benchmark mode otherwise when the user hits 'bypass'
7183 * the following algos are skipped entirely
7184 */
7185
7186 if (algorithm_pos > 0)
7187 {
7188 local_free (rd);
7189
7190 rd = init_restore (argc, argv);
7191
7192 data.rd = rd;
7193 }
7194
7195 /**
7196 * update hash_mode in case of multihash benchmark
7197 */
7198
7199 if (benchmark == 1)
7200 {
7201 if (hash_mode_chgd == 0)
7202 {
7203 hash_mode = algorithms[algorithm_pos];
7204
7205 data.hash_mode = hash_mode;
7206 }
7207
7208 quiet = 1;
7209
7210 data.quiet = quiet;
7211 }
7212
7213 switch (hash_mode)
7214 {
7215 case 0: hash_type = HASH_TYPE_MD5;
7216 salt_type = SALT_TYPE_NONE;
7217 attack_exec = ATTACK_EXEC_ON_GPU;
7218 opts_type = OPTS_TYPE_PT_GENERATE_LE
7219 | OPTS_TYPE_PT_ADD80
7220 | OPTS_TYPE_PT_ADDBITS14;
7221 kern_type = KERN_TYPE_MD5;
7222 dgst_size = DGST_SIZE_4_4;
7223 parse_func = md5_parse_hash;
7224 sort_by_digest = sort_by_digest_4_4;
7225 opti_type = OPTI_TYPE_ZERO_BYTE
7226 | OPTI_TYPE_PRECOMPUTE_INIT
7227 | OPTI_TYPE_PRECOMPUTE_MERKLE
7228 | OPTI_TYPE_SCALAR_MODE
7229 | OPTI_TYPE_MEET_IN_MIDDLE
7230 | OPTI_TYPE_EARLY_SKIP
7231 | OPTI_TYPE_NOT_ITERATED
7232 | OPTI_TYPE_NOT_SALTED
7233 | OPTI_TYPE_RAW_HASH;
7234 dgst_pos0 = 0;
7235 dgst_pos1 = 3;
7236 dgst_pos2 = 2;
7237 dgst_pos3 = 1;
7238 break;
7239
7240 case 10: hash_type = HASH_TYPE_MD5;
7241 salt_type = SALT_TYPE_INTERN;
7242 attack_exec = ATTACK_EXEC_ON_GPU;
7243 opts_type = OPTS_TYPE_PT_GENERATE_LE
7244 | OPTS_TYPE_ST_ADD80
7245 | OPTS_TYPE_ST_ADDBITS14;
7246 kern_type = KERN_TYPE_MD5_PWSLT;
7247 dgst_size = DGST_SIZE_4_4;
7248 parse_func = md5s_parse_hash;
7249 sort_by_digest = sort_by_digest_4_4;
7250 opti_type = OPTI_TYPE_ZERO_BYTE
7251 | OPTI_TYPE_PRECOMPUTE_INIT
7252 | OPTI_TYPE_PRECOMPUTE_MERKLE
7253 | OPTI_TYPE_SCALAR_MODE
7254 | OPTI_TYPE_MEET_IN_MIDDLE
7255 | OPTI_TYPE_EARLY_SKIP
7256 | OPTI_TYPE_NOT_ITERATED
7257 | OPTI_TYPE_APPENDED_SALT
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 11: hash_type = HASH_TYPE_MD5;
7266 salt_type = SALT_TYPE_INTERN;
7267 attack_exec = ATTACK_EXEC_ON_GPU;
7268 opts_type = OPTS_TYPE_PT_GENERATE_LE
7269 | OPTS_TYPE_ST_ADD80
7270 | OPTS_TYPE_ST_ADDBITS14;
7271 kern_type = KERN_TYPE_MD5_PWSLT;
7272 dgst_size = DGST_SIZE_4_4;
7273 parse_func = joomla_parse_hash;
7274 sort_by_digest = sort_by_digest_4_4;
7275 opti_type = OPTI_TYPE_ZERO_BYTE
7276 | OPTI_TYPE_PRECOMPUTE_INIT
7277 | OPTI_TYPE_PRECOMPUTE_MERKLE
7278 | OPTI_TYPE_SCALAR_MODE
7279 | OPTI_TYPE_MEET_IN_MIDDLE
7280 | OPTI_TYPE_EARLY_SKIP
7281 | OPTI_TYPE_NOT_ITERATED
7282 | OPTI_TYPE_APPENDED_SALT
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 12: hash_type = HASH_TYPE_MD5;
7291 salt_type = SALT_TYPE_INTERN;
7292 attack_exec = ATTACK_EXEC_ON_GPU;
7293 opts_type = OPTS_TYPE_PT_GENERATE_LE
7294 | OPTS_TYPE_ST_ADD80
7295 | OPTS_TYPE_ST_ADDBITS14;
7296 kern_type = KERN_TYPE_MD5_PWSLT;
7297 dgst_size = DGST_SIZE_4_4;
7298 parse_func = postgresql_parse_hash;
7299 sort_by_digest = sort_by_digest_4_4;
7300 opti_type = OPTI_TYPE_ZERO_BYTE
7301 | OPTI_TYPE_PRECOMPUTE_INIT
7302 | OPTI_TYPE_PRECOMPUTE_MERKLE
7303 | OPTI_TYPE_SCALAR_MODE
7304 | OPTI_TYPE_MEET_IN_MIDDLE
7305 | OPTI_TYPE_EARLY_SKIP
7306 | OPTI_TYPE_NOT_ITERATED
7307 | OPTI_TYPE_APPENDED_SALT
7308 | OPTI_TYPE_RAW_HASH;
7309 dgst_pos0 = 0;
7310 dgst_pos1 = 3;
7311 dgst_pos2 = 2;
7312 dgst_pos3 = 1;
7313 break;
7314
7315 case 20: hash_type = HASH_TYPE_MD5;
7316 salt_type = SALT_TYPE_INTERN;
7317 attack_exec = ATTACK_EXEC_ON_GPU;
7318 opts_type = OPTS_TYPE_PT_GENERATE_LE
7319 | OPTS_TYPE_PT_ADD80
7320 | OPTS_TYPE_PT_ADDBITS14;
7321 kern_type = KERN_TYPE_MD5_SLTPW;
7322 dgst_size = DGST_SIZE_4_4;
7323 parse_func = md5s_parse_hash;
7324 sort_by_digest = sort_by_digest_4_4;
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_PREPENDED_SALT
7331 | OPTI_TYPE_RAW_HASH;
7332 dgst_pos0 = 0;
7333 dgst_pos1 = 3;
7334 dgst_pos2 = 2;
7335 dgst_pos3 = 1;
7336 break;
7337
7338 case 21: hash_type = HASH_TYPE_MD5;
7339 salt_type = SALT_TYPE_INTERN;
7340 attack_exec = ATTACK_EXEC_ON_GPU;
7341 opts_type = OPTS_TYPE_PT_GENERATE_LE
7342 | OPTS_TYPE_PT_ADD80
7343 | OPTS_TYPE_PT_ADDBITS14;
7344 kern_type = KERN_TYPE_MD5_SLTPW;
7345 dgst_size = DGST_SIZE_4_4;
7346 parse_func = osc_parse_hash;
7347 sort_by_digest = sort_by_digest_4_4;
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_PREPENDED_SALT
7354 | OPTI_TYPE_RAW_HASH;
7355 dgst_pos0 = 0;
7356 dgst_pos1 = 3;
7357 dgst_pos2 = 2;
7358 dgst_pos3 = 1;
7359 break;
7360
7361 case 22: hash_type = HASH_TYPE_MD5;
7362 salt_type = SALT_TYPE_EMBEDDED;
7363 attack_exec = ATTACK_EXEC_ON_GPU;
7364 opts_type = OPTS_TYPE_PT_GENERATE_LE
7365 | OPTS_TYPE_PT_ADD80
7366 | OPTS_TYPE_PT_ADDBITS14;
7367 kern_type = KERN_TYPE_MD5_SLTPW;
7368 dgst_size = DGST_SIZE_4_4;
7369 parse_func = netscreen_parse_hash;
7370 sort_by_digest = sort_by_digest_4_4;
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 = 0;
7379 dgst_pos1 = 3;
7380 dgst_pos2 = 2;
7381 dgst_pos3 = 1;
7382 break;
7383
7384 case 23: hash_type = HASH_TYPE_MD5;
7385 salt_type = SALT_TYPE_EMBEDDED;
7386 attack_exec = ATTACK_EXEC_ON_GPU;
7387 opts_type = OPTS_TYPE_PT_GENERATE_LE
7388 | OPTS_TYPE_PT_ADD80
7389 | OPTS_TYPE_PT_ADDBITS14;
7390 kern_type = KERN_TYPE_MD5_SLTPW;
7391 dgst_size = DGST_SIZE_4_4;
7392 parse_func = skype_parse_hash;
7393 sort_by_digest = sort_by_digest_4_4;
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 = 0;
7402 dgst_pos1 = 3;
7403 dgst_pos2 = 2;
7404 dgst_pos3 = 1;
7405 break;
7406
7407 case 30: hash_type = HASH_TYPE_MD5;
7408 salt_type = SALT_TYPE_INTERN;
7409 attack_exec = ATTACK_EXEC_ON_GPU;
7410 opts_type = OPTS_TYPE_PT_GENERATE_LE
7411 | OPTS_TYPE_PT_UNICODE
7412 | OPTS_TYPE_ST_ADD80
7413 | OPTS_TYPE_ST_ADDBITS14;
7414 kern_type = KERN_TYPE_MD5_PWUSLT;
7415 dgst_size = DGST_SIZE_4_4;
7416 parse_func = md5s_parse_hash;
7417 sort_by_digest = sort_by_digest_4_4;
7418 opti_type = OPTI_TYPE_ZERO_BYTE
7419 | OPTI_TYPE_PRECOMPUTE_INIT
7420 | OPTI_TYPE_PRECOMPUTE_MERKLE
7421 | OPTI_TYPE_SCALAR_MODE
7422 | OPTI_TYPE_MEET_IN_MIDDLE
7423 | OPTI_TYPE_EARLY_SKIP
7424 | OPTI_TYPE_NOT_ITERATED
7425 | OPTI_TYPE_APPENDED_SALT
7426 | OPTI_TYPE_RAW_HASH;
7427 dgst_pos0 = 0;
7428 dgst_pos1 = 3;
7429 dgst_pos2 = 2;
7430 dgst_pos3 = 1;
7431 break;
7432
7433 case 40: hash_type = HASH_TYPE_MD5;
7434 salt_type = SALT_TYPE_INTERN;
7435 attack_exec = ATTACK_EXEC_ON_GPU;
7436 opts_type = OPTS_TYPE_PT_GENERATE_LE
7437 | OPTS_TYPE_PT_ADD80
7438 | OPTS_TYPE_PT_ADDBITS14
7439 | OPTS_TYPE_PT_UNICODE;
7440 kern_type = KERN_TYPE_MD5_SLTPWU;
7441 dgst_size = DGST_SIZE_4_4;
7442 parse_func = md5s_parse_hash;
7443 sort_by_digest = sort_by_digest_4_4;
7444 opti_type = OPTI_TYPE_ZERO_BYTE
7445 | OPTI_TYPE_PRECOMPUTE_INIT
7446 | OPTI_TYPE_PRECOMPUTE_MERKLE
7447 | OPTI_TYPE_EARLY_SKIP
7448 | OPTI_TYPE_NOT_ITERATED
7449 | OPTI_TYPE_PREPENDED_SALT
7450 | OPTI_TYPE_RAW_HASH;
7451 dgst_pos0 = 0;
7452 dgst_pos1 = 3;
7453 dgst_pos2 = 2;
7454 dgst_pos3 = 1;
7455 break;
7456
7457 case 50: hash_type = HASH_TYPE_MD5;
7458 salt_type = SALT_TYPE_INTERN;
7459 attack_exec = ATTACK_EXEC_ON_GPU;
7460 opts_type = OPTS_TYPE_PT_GENERATE_LE
7461 | OPTS_TYPE_ST_ADD80
7462 | OPTS_TYPE_ST_ADDBITS14;
7463 kern_type = KERN_TYPE_HMACMD5_PW;
7464 dgst_size = DGST_SIZE_4_4;
7465 parse_func = hmacmd5_parse_hash;
7466 sort_by_digest = sort_by_digest_4_4;
7467 opti_type = OPTI_TYPE_ZERO_BYTE
7468 | OPTI_TYPE_NOT_ITERATED;
7469 dgst_pos0 = 0;
7470 dgst_pos1 = 3;
7471 dgst_pos2 = 2;
7472 dgst_pos3 = 1;
7473 break;
7474
7475 case 60: hash_type = HASH_TYPE_MD5;
7476 salt_type = SALT_TYPE_INTERN;
7477 attack_exec = ATTACK_EXEC_ON_GPU;
7478 opts_type = OPTS_TYPE_PT_GENERATE_LE
7479 | OPTS_TYPE_PT_ADD80
7480 | OPTS_TYPE_PT_ADDBITS14;
7481 kern_type = KERN_TYPE_HMACMD5_SLT;
7482 dgst_size = DGST_SIZE_4_4;
7483 parse_func = hmacmd5_parse_hash;
7484 sort_by_digest = sort_by_digest_4_4;
7485 opti_type = OPTI_TYPE_ZERO_BYTE
7486 | OPTI_TYPE_NOT_ITERATED;
7487 dgst_pos0 = 0;
7488 dgst_pos1 = 3;
7489 dgst_pos2 = 2;
7490 dgst_pos3 = 1;
7491 break;
7492
7493 case 100: hash_type = HASH_TYPE_SHA1;
7494 salt_type = SALT_TYPE_NONE;
7495 attack_exec = ATTACK_EXEC_ON_GPU;
7496 opts_type = OPTS_TYPE_PT_GENERATE_BE
7497 | OPTS_TYPE_PT_ADD80
7498 | OPTS_TYPE_PT_ADDBITS15;
7499 kern_type = KERN_TYPE_SHA1;
7500 dgst_size = DGST_SIZE_4_5;
7501 parse_func = sha1_parse_hash;
7502 sort_by_digest = sort_by_digest_4_5;
7503 opti_type = OPTI_TYPE_ZERO_BYTE
7504 | OPTI_TYPE_PRECOMPUTE_INIT
7505 | OPTI_TYPE_PRECOMPUTE_MERKLE
7506 | OPTI_TYPE_SCALAR_MODE
7507 | OPTI_TYPE_EARLY_SKIP
7508 | OPTI_TYPE_NOT_ITERATED
7509 | OPTI_TYPE_NOT_SALTED
7510 | OPTI_TYPE_RAW_HASH;
7511 dgst_pos0 = 3;
7512 dgst_pos1 = 4;
7513 dgst_pos2 = 2;
7514 dgst_pos3 = 1;
7515 break;
7516
7517 case 101: hash_type = HASH_TYPE_SHA1;
7518 salt_type = SALT_TYPE_NONE;
7519 attack_exec = ATTACK_EXEC_ON_GPU;
7520 opts_type = OPTS_TYPE_PT_GENERATE_BE
7521 | OPTS_TYPE_PT_ADD80
7522 | OPTS_TYPE_PT_ADDBITS15;
7523 kern_type = KERN_TYPE_SHA1;
7524 dgst_size = DGST_SIZE_4_5;
7525 parse_func = sha1b64_parse_hash;
7526 sort_by_digest = sort_by_digest_4_5;
7527 opti_type = OPTI_TYPE_ZERO_BYTE
7528 | OPTI_TYPE_PRECOMPUTE_INIT
7529 | OPTI_TYPE_PRECOMPUTE_MERKLE
7530 | OPTI_TYPE_SCALAR_MODE
7531 | OPTI_TYPE_EARLY_SKIP
7532 | OPTI_TYPE_NOT_ITERATED
7533 | OPTI_TYPE_NOT_SALTED
7534 | OPTI_TYPE_RAW_HASH;
7535 dgst_pos0 = 3;
7536 dgst_pos1 = 4;
7537 dgst_pos2 = 2;
7538 dgst_pos3 = 1;
7539 break;
7540
7541 case 110: hash_type = HASH_TYPE_SHA1;
7542 salt_type = SALT_TYPE_INTERN;
7543 attack_exec = ATTACK_EXEC_ON_GPU;
7544 opts_type = OPTS_TYPE_PT_GENERATE_BE
7545 | OPTS_TYPE_ST_ADD80
7546 | OPTS_TYPE_ST_ADDBITS15;
7547 kern_type = KERN_TYPE_SHA1_PWSLT;
7548 dgst_size = DGST_SIZE_4_5;
7549 parse_func = sha1s_parse_hash;
7550 sort_by_digest = sort_by_digest_4_5;
7551 opti_type = OPTI_TYPE_ZERO_BYTE
7552 | OPTI_TYPE_PRECOMPUTE_INIT
7553 | OPTI_TYPE_PRECOMPUTE_MERKLE
7554 | OPTI_TYPE_SCALAR_MODE
7555 | OPTI_TYPE_EARLY_SKIP
7556 | OPTI_TYPE_NOT_ITERATED
7557 | OPTI_TYPE_APPENDED_SALT
7558 | OPTI_TYPE_RAW_HASH;
7559 dgst_pos0 = 3;
7560 dgst_pos1 = 4;
7561 dgst_pos2 = 2;
7562 dgst_pos3 = 1;
7563 break;
7564
7565 case 111: hash_type = HASH_TYPE_SHA1;
7566 salt_type = SALT_TYPE_EMBEDDED;
7567 attack_exec = ATTACK_EXEC_ON_GPU;
7568 opts_type = OPTS_TYPE_PT_GENERATE_BE
7569 | OPTS_TYPE_ST_ADD80
7570 | OPTS_TYPE_ST_ADDBITS15;
7571 kern_type = KERN_TYPE_SHA1_PWSLT;
7572 dgst_size = DGST_SIZE_4_5;
7573 parse_func = sha1b64s_parse_hash;
7574 sort_by_digest = sort_by_digest_4_5;
7575 opti_type = OPTI_TYPE_ZERO_BYTE
7576 | OPTI_TYPE_PRECOMPUTE_INIT
7577 | OPTI_TYPE_PRECOMPUTE_MERKLE
7578 | OPTI_TYPE_SCALAR_MODE
7579 | OPTI_TYPE_EARLY_SKIP
7580 | OPTI_TYPE_NOT_ITERATED
7581 | OPTI_TYPE_APPENDED_SALT
7582 | OPTI_TYPE_RAW_HASH;
7583 dgst_pos0 = 3;
7584 dgst_pos1 = 4;
7585 dgst_pos2 = 2;
7586 dgst_pos3 = 1;
7587 break;
7588
7589 case 112: hash_type = HASH_TYPE_SHA1;
7590 salt_type = SALT_TYPE_INTERN;
7591 attack_exec = ATTACK_EXEC_ON_GPU;
7592 opts_type = OPTS_TYPE_PT_GENERATE_BE
7593 | OPTS_TYPE_ST_ADD80
7594 | OPTS_TYPE_ST_ADDBITS15
7595 | OPTS_TYPE_ST_HEX;
7596 kern_type = KERN_TYPE_SHA1_PWSLT;
7597 dgst_size = DGST_SIZE_4_5;
7598 parse_func = oracles_parse_hash;
7599 sort_by_digest = sort_by_digest_4_5;
7600 opti_type = OPTI_TYPE_ZERO_BYTE
7601 | OPTI_TYPE_PRECOMPUTE_INIT
7602 | OPTI_TYPE_PRECOMPUTE_MERKLE
7603 | OPTI_TYPE_SCALAR_MODE
7604 | OPTI_TYPE_EARLY_SKIP
7605 | OPTI_TYPE_NOT_ITERATED
7606 | OPTI_TYPE_APPENDED_SALT
7607 | OPTI_TYPE_RAW_HASH;
7608 dgst_pos0 = 3;
7609 dgst_pos1 = 4;
7610 dgst_pos2 = 2;
7611 dgst_pos3 = 1;
7612 break;
7613
7614 case 120: hash_type = HASH_TYPE_SHA1;
7615 salt_type = SALT_TYPE_INTERN;
7616 attack_exec = ATTACK_EXEC_ON_GPU;
7617 opts_type = OPTS_TYPE_PT_GENERATE_BE
7618 | OPTS_TYPE_PT_ADD80
7619 | OPTS_TYPE_PT_ADDBITS15;
7620 kern_type = KERN_TYPE_SHA1_SLTPW;
7621 dgst_size = DGST_SIZE_4_5;
7622 parse_func = sha1s_parse_hash;
7623 sort_by_digest = sort_by_digest_4_5;
7624 opti_type = OPTI_TYPE_ZERO_BYTE
7625 | OPTI_TYPE_PRECOMPUTE_INIT
7626 | OPTI_TYPE_PRECOMPUTE_MERKLE
7627 | OPTI_TYPE_EARLY_SKIP
7628 | OPTI_TYPE_NOT_ITERATED
7629 | OPTI_TYPE_PREPENDED_SALT
7630 | OPTI_TYPE_RAW_HASH;
7631 dgst_pos0 = 3;
7632 dgst_pos1 = 4;
7633 dgst_pos2 = 2;
7634 dgst_pos3 = 1;
7635 break;
7636
7637 case 121: hash_type = HASH_TYPE_SHA1;
7638 salt_type = SALT_TYPE_INTERN;
7639 attack_exec = ATTACK_EXEC_ON_GPU;
7640 opts_type = OPTS_TYPE_PT_GENERATE_BE
7641 | OPTS_TYPE_PT_ADD80
7642 | OPTS_TYPE_PT_ADDBITS15
7643 | OPTS_TYPE_ST_LOWER;
7644 kern_type = KERN_TYPE_SHA1_SLTPW;
7645 dgst_size = DGST_SIZE_4_5;
7646 parse_func = smf_parse_hash;
7647 sort_by_digest = sort_by_digest_4_5;
7648 opti_type = OPTI_TYPE_ZERO_BYTE
7649 | OPTI_TYPE_PRECOMPUTE_INIT
7650 | OPTI_TYPE_PRECOMPUTE_MERKLE
7651 | OPTI_TYPE_EARLY_SKIP
7652 | OPTI_TYPE_NOT_ITERATED
7653 | OPTI_TYPE_PREPENDED_SALT
7654 | OPTI_TYPE_RAW_HASH;
7655 dgst_pos0 = 3;
7656 dgst_pos1 = 4;
7657 dgst_pos2 = 2;
7658 dgst_pos3 = 1;
7659 break;
7660
7661 case 122: hash_type = HASH_TYPE_SHA1;
7662 salt_type = SALT_TYPE_EMBEDDED;
7663 attack_exec = ATTACK_EXEC_ON_GPU;
7664 opts_type = OPTS_TYPE_PT_GENERATE_BE
7665 | OPTS_TYPE_PT_ADD80
7666 | OPTS_TYPE_PT_ADDBITS15
7667 | OPTS_TYPE_ST_HEX;
7668 kern_type = KERN_TYPE_SHA1_SLTPW;
7669 dgst_size = DGST_SIZE_4_5;
7670 parse_func = osx1_parse_hash;
7671 sort_by_digest = sort_by_digest_4_5;
7672 opti_type = OPTI_TYPE_ZERO_BYTE
7673 | OPTI_TYPE_PRECOMPUTE_INIT
7674 | OPTI_TYPE_PRECOMPUTE_MERKLE
7675 | OPTI_TYPE_EARLY_SKIP
7676 | OPTI_TYPE_NOT_ITERATED
7677 | OPTI_TYPE_PREPENDED_SALT
7678 | OPTI_TYPE_RAW_HASH;
7679 dgst_pos0 = 3;
7680 dgst_pos1 = 4;
7681 dgst_pos2 = 2;
7682 dgst_pos3 = 1;
7683 break;
7684
7685 case 124: hash_type = HASH_TYPE_SHA1;
7686 salt_type = SALT_TYPE_EMBEDDED;
7687 attack_exec = ATTACK_EXEC_ON_GPU;
7688 opts_type = OPTS_TYPE_PT_GENERATE_BE
7689 | OPTS_TYPE_PT_ADD80
7690 | OPTS_TYPE_PT_ADDBITS15;
7691 kern_type = KERN_TYPE_SHA1_SLTPW;
7692 dgst_size = DGST_SIZE_4_5;
7693 parse_func = djangosha1_parse_hash;
7694 sort_by_digest = sort_by_digest_4_5;
7695 opti_type = OPTI_TYPE_ZERO_BYTE
7696 | OPTI_TYPE_PRECOMPUTE_INIT
7697 | OPTI_TYPE_PRECOMPUTE_MERKLE
7698 | OPTI_TYPE_EARLY_SKIP
7699 | OPTI_TYPE_NOT_ITERATED
7700 | OPTI_TYPE_PREPENDED_SALT
7701 | OPTI_TYPE_RAW_HASH;
7702 dgst_pos0 = 3;
7703 dgst_pos1 = 4;
7704 dgst_pos2 = 2;
7705 dgst_pos3 = 1;
7706 break;
7707
7708 case 130: hash_type = HASH_TYPE_SHA1;
7709 salt_type = SALT_TYPE_INTERN;
7710 attack_exec = ATTACK_EXEC_ON_GPU;
7711 opts_type = OPTS_TYPE_PT_GENERATE_BE
7712 | OPTS_TYPE_PT_UNICODE
7713 | OPTS_TYPE_ST_ADD80
7714 | OPTS_TYPE_ST_ADDBITS15;
7715 kern_type = KERN_TYPE_SHA1_PWUSLT;
7716 dgst_size = DGST_SIZE_4_5;
7717 parse_func = sha1s_parse_hash;
7718 sort_by_digest = sort_by_digest_4_5;
7719 opti_type = OPTI_TYPE_ZERO_BYTE
7720 | OPTI_TYPE_PRECOMPUTE_INIT
7721 | OPTI_TYPE_PRECOMPUTE_MERKLE
7722 | OPTI_TYPE_SCALAR_MODE
7723 | OPTI_TYPE_EARLY_SKIP
7724 | OPTI_TYPE_NOT_ITERATED
7725 | OPTI_TYPE_APPENDED_SALT
7726 | OPTI_TYPE_RAW_HASH;
7727 dgst_pos0 = 3;
7728 dgst_pos1 = 4;
7729 dgst_pos2 = 2;
7730 dgst_pos3 = 1;
7731 break;
7732
7733 case 131: hash_type = HASH_TYPE_SHA1;
7734 salt_type = SALT_TYPE_EMBEDDED;
7735 attack_exec = ATTACK_EXEC_ON_GPU;
7736 opts_type = OPTS_TYPE_PT_GENERATE_BE
7737 | OPTS_TYPE_PT_UNICODE
7738 | OPTS_TYPE_PT_UPPER
7739 | OPTS_TYPE_ST_ADD80
7740 | OPTS_TYPE_ST_ADDBITS15
7741 | OPTS_TYPE_ST_HEX;
7742 kern_type = KERN_TYPE_SHA1_PWUSLT;
7743 dgst_size = DGST_SIZE_4_5;
7744 parse_func = mssql2000_parse_hash;
7745 sort_by_digest = sort_by_digest_4_5;
7746 opti_type = OPTI_TYPE_ZERO_BYTE
7747 | OPTI_TYPE_PRECOMPUTE_INIT
7748 | OPTI_TYPE_PRECOMPUTE_MERKLE
7749 | OPTI_TYPE_SCALAR_MODE
7750 | OPTI_TYPE_EARLY_SKIP
7751 | OPTI_TYPE_NOT_ITERATED
7752 | OPTI_TYPE_APPENDED_SALT
7753 | OPTI_TYPE_RAW_HASH;
7754 dgst_pos0 = 3;
7755 dgst_pos1 = 4;
7756 dgst_pos2 = 2;
7757 dgst_pos3 = 1;
7758 break;
7759
7760 case 132: hash_type = HASH_TYPE_SHA1;
7761 salt_type = SALT_TYPE_EMBEDDED;
7762 attack_exec = ATTACK_EXEC_ON_GPU;
7763 opts_type = OPTS_TYPE_PT_GENERATE_BE
7764 | OPTS_TYPE_PT_UNICODE
7765 | OPTS_TYPE_ST_ADD80
7766 | OPTS_TYPE_ST_ADDBITS15
7767 | OPTS_TYPE_ST_HEX;
7768 kern_type = KERN_TYPE_SHA1_PWUSLT;
7769 dgst_size = DGST_SIZE_4_5;
7770 parse_func = mssql2005_parse_hash;
7771 sort_by_digest = sort_by_digest_4_5;
7772 opti_type = OPTI_TYPE_ZERO_BYTE
7773 | OPTI_TYPE_PRECOMPUTE_INIT
7774 | OPTI_TYPE_PRECOMPUTE_MERKLE
7775 | OPTI_TYPE_SCALAR_MODE
7776 | OPTI_TYPE_EARLY_SKIP
7777 | OPTI_TYPE_NOT_ITERATED
7778 | OPTI_TYPE_APPENDED_SALT
7779 | OPTI_TYPE_RAW_HASH;
7780 dgst_pos0 = 3;
7781 dgst_pos1 = 4;
7782 dgst_pos2 = 2;
7783 dgst_pos3 = 1;
7784 break;
7785
7786 case 133: hash_type = HASH_TYPE_SHA1;
7787 salt_type = SALT_TYPE_EMBEDDED;
7788 attack_exec = ATTACK_EXEC_ON_GPU;
7789 opts_type = OPTS_TYPE_PT_GENERATE_BE
7790 | OPTS_TYPE_PT_UNICODE
7791 | OPTS_TYPE_ST_ADD80
7792 | OPTS_TYPE_ST_ADDBITS15;
7793 kern_type = KERN_TYPE_SHA1_PWUSLT;
7794 dgst_size = DGST_SIZE_4_5;
7795 parse_func = peoplesoft_parse_hash;
7796 sort_by_digest = sort_by_digest_4_5;
7797 opti_type = OPTI_TYPE_ZERO_BYTE
7798 | OPTI_TYPE_PRECOMPUTE_INIT
7799 | OPTI_TYPE_PRECOMPUTE_MERKLE
7800 | OPTI_TYPE_SCALAR_MODE
7801 | OPTI_TYPE_EARLY_SKIP
7802 | OPTI_TYPE_NOT_ITERATED
7803 | OPTI_TYPE_APPENDED_SALT
7804 | OPTI_TYPE_RAW_HASH;
7805 dgst_pos0 = 3;
7806 dgst_pos1 = 4;
7807 dgst_pos2 = 2;
7808 dgst_pos3 = 1;
7809 break;
7810
7811 case 140: hash_type = HASH_TYPE_SHA1;
7812 salt_type = SALT_TYPE_INTERN;
7813 attack_exec = ATTACK_EXEC_ON_GPU;
7814 opts_type = OPTS_TYPE_PT_GENERATE_BE
7815 | OPTS_TYPE_PT_ADD80
7816 | OPTS_TYPE_PT_ADDBITS15
7817 | OPTS_TYPE_PT_UNICODE;
7818 kern_type = KERN_TYPE_SHA1_SLTPWU;
7819 dgst_size = DGST_SIZE_4_5;
7820 parse_func = sha1s_parse_hash;
7821 sort_by_digest = sort_by_digest_4_5;
7822 opti_type = OPTI_TYPE_ZERO_BYTE
7823 | OPTI_TYPE_PRECOMPUTE_INIT
7824 | OPTI_TYPE_PRECOMPUTE_MERKLE
7825 | OPTI_TYPE_EARLY_SKIP
7826 | OPTI_TYPE_NOT_ITERATED
7827 | OPTI_TYPE_PREPENDED_SALT
7828 | OPTI_TYPE_RAW_HASH;
7829 dgst_pos0 = 3;
7830 dgst_pos1 = 4;
7831 dgst_pos2 = 2;
7832 dgst_pos3 = 1;
7833 break;
7834
7835 case 141: hash_type = HASH_TYPE_SHA1;
7836 salt_type = SALT_TYPE_EMBEDDED;
7837 attack_exec = ATTACK_EXEC_ON_GPU;
7838 opts_type = OPTS_TYPE_PT_GENERATE_BE
7839 | OPTS_TYPE_PT_ADD80
7840 | OPTS_TYPE_PT_ADDBITS15
7841 | OPTS_TYPE_PT_UNICODE
7842 | OPTS_TYPE_ST_BASE64;
7843 kern_type = KERN_TYPE_SHA1_SLTPWU;
7844 dgst_size = DGST_SIZE_4_5;
7845 parse_func = episerver_parse_hash;
7846 sort_by_digest = sort_by_digest_4_5;
7847 opti_type = OPTI_TYPE_ZERO_BYTE
7848 | OPTI_TYPE_PRECOMPUTE_INIT
7849 | OPTI_TYPE_PRECOMPUTE_MERKLE
7850 | OPTI_TYPE_EARLY_SKIP
7851 | OPTI_TYPE_NOT_ITERATED
7852 | OPTI_TYPE_PREPENDED_SALT
7853 | OPTI_TYPE_RAW_HASH;
7854 dgst_pos0 = 3;
7855 dgst_pos1 = 4;
7856 dgst_pos2 = 2;
7857 dgst_pos3 = 1;
7858 break;
7859
7860 case 150: hash_type = HASH_TYPE_SHA1;
7861 salt_type = SALT_TYPE_INTERN;
7862 attack_exec = ATTACK_EXEC_ON_GPU;
7863 opts_type = OPTS_TYPE_PT_GENERATE_BE
7864 | OPTS_TYPE_ST_ADD80
7865 | OPTS_TYPE_ST_ADDBITS15;
7866 kern_type = KERN_TYPE_HMACSHA1_PW;
7867 dgst_size = DGST_SIZE_4_5;
7868 parse_func = hmacsha1_parse_hash;
7869 sort_by_digest = sort_by_digest_4_5;
7870 opti_type = OPTI_TYPE_ZERO_BYTE
7871 | OPTI_TYPE_NOT_ITERATED;
7872 dgst_pos0 = 3;
7873 dgst_pos1 = 4;
7874 dgst_pos2 = 2;
7875 dgst_pos3 = 1;
7876 break;
7877
7878 case 160: hash_type = HASH_TYPE_SHA1;
7879 salt_type = SALT_TYPE_INTERN;
7880 attack_exec = ATTACK_EXEC_ON_GPU;
7881 opts_type = OPTS_TYPE_PT_GENERATE_BE
7882 | OPTS_TYPE_PT_ADD80
7883 | OPTS_TYPE_PT_ADDBITS15;
7884 kern_type = KERN_TYPE_HMACSHA1_SLT;
7885 dgst_size = DGST_SIZE_4_5;
7886 parse_func = hmacsha1_parse_hash;
7887 sort_by_digest = sort_by_digest_4_5;
7888 opti_type = OPTI_TYPE_ZERO_BYTE
7889 | OPTI_TYPE_NOT_ITERATED;
7890 dgst_pos0 = 3;
7891 dgst_pos1 = 4;
7892 dgst_pos2 = 2;
7893 dgst_pos3 = 1;
7894 break;
7895
7896 case 190: hash_type = HASH_TYPE_SHA1;
7897 salt_type = SALT_TYPE_NONE;
7898 attack_exec = ATTACK_EXEC_ON_GPU;
7899 opts_type = OPTS_TYPE_PT_GENERATE_BE
7900 | OPTS_TYPE_PT_ADD80
7901 | OPTS_TYPE_PT_ADDBITS15;
7902 kern_type = KERN_TYPE_SHA1_LINKEDIN;
7903 dgst_size = DGST_SIZE_4_5;
7904 parse_func = sha1linkedin_parse_hash;
7905 sort_by_digest = sort_by_digest_4_5;
7906 opti_type = OPTI_TYPE_ZERO_BYTE
7907 | OPTI_TYPE_PRECOMPUTE_INIT
7908 | OPTI_TYPE_SCALAR_MODE
7909 | OPTI_TYPE_EARLY_SKIP
7910 | OPTI_TYPE_NOT_ITERATED
7911 | OPTI_TYPE_NOT_SALTED;
7912 dgst_pos0 = 0;
7913 dgst_pos1 = 4;
7914 dgst_pos2 = 3;
7915 dgst_pos3 = 2;
7916 break;
7917
7918 case 200: hash_type = HASH_TYPE_MYSQL;
7919 salt_type = SALT_TYPE_NONE;
7920 attack_exec = ATTACK_EXEC_ON_GPU;
7921 opts_type = 0;
7922 kern_type = KERN_TYPE_MYSQL;
7923 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
7924 parse_func = mysql323_parse_hash;
7925 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
7926 opti_type = OPTI_TYPE_ZERO_BYTE
7927 | OPTI_TYPE_SCALAR_MODE;
7928 dgst_pos0 = 0;
7929 dgst_pos1 = 1;
7930 dgst_pos2 = 2;
7931 dgst_pos3 = 3;
7932 break;
7933
7934 case 300: hash_type = HASH_TYPE_SHA1;
7935 salt_type = SALT_TYPE_NONE;
7936 attack_exec = ATTACK_EXEC_ON_GPU;
7937 opts_type = OPTS_TYPE_PT_GENERATE_BE
7938 | OPTS_TYPE_PT_ADD80
7939 | OPTS_TYPE_PT_ADDBITS15;
7940 kern_type = KERN_TYPE_MYSQL41;
7941 dgst_size = DGST_SIZE_4_5;
7942 parse_func = sha1_parse_hash;
7943 sort_by_digest = sort_by_digest_4_5;
7944 opti_type = OPTI_TYPE_ZERO_BYTE
7945 | OPTI_TYPE_PRECOMPUTE_INIT
7946 | OPTI_TYPE_PRECOMPUTE_MERKLE
7947 | OPTI_TYPE_SCALAR_MODE
7948 | OPTI_TYPE_EARLY_SKIP
7949 | OPTI_TYPE_NOT_ITERATED
7950 | OPTI_TYPE_NOT_SALTED;
7951 dgst_pos0 = 3;
7952 dgst_pos1 = 4;
7953 dgst_pos2 = 2;
7954 dgst_pos3 = 1;
7955 break;
7956
7957 case 400: hash_type = HASH_TYPE_MD5;
7958 salt_type = SALT_TYPE_EMBEDDED;
7959 attack_exec = ATTACK_EXEC_ON_CPU;
7960 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7961 kern_type = KERN_TYPE_PHPASS;
7962 dgst_size = DGST_SIZE_4_4;
7963 parse_func = phpass_parse_hash;
7964 sort_by_digest = sort_by_digest_4_4;
7965 opti_type = OPTI_TYPE_ZERO_BYTE;
7966 dgst_pos0 = 0;
7967 dgst_pos1 = 1;
7968 dgst_pos2 = 2;
7969 dgst_pos3 = 3;
7970 break;
7971
7972 case 500: hash_type = HASH_TYPE_MD5;
7973 salt_type = SALT_TYPE_EMBEDDED;
7974 attack_exec = ATTACK_EXEC_ON_CPU;
7975 opts_type = OPTS_TYPE_PT_GENERATE_LE;
7976 kern_type = KERN_TYPE_MD5CRYPT;
7977 dgst_size = DGST_SIZE_4_4;
7978 parse_func = md5crypt_parse_hash;
7979 sort_by_digest = sort_by_digest_4_4;
7980 opti_type = OPTI_TYPE_ZERO_BYTE;
7981 dgst_pos0 = 0;
7982 dgst_pos1 = 1;
7983 dgst_pos2 = 2;
7984 dgst_pos3 = 3;
7985 break;
7986
7987 case 501: hash_type = HASH_TYPE_MD5;
7988 salt_type = SALT_TYPE_EMBEDDED;
7989 attack_exec = ATTACK_EXEC_ON_CPU;
7990 opts_type = OPTS_TYPE_PT_GENERATE_LE
7991 | OPTS_TYPE_HASH_COPY;
7992 kern_type = KERN_TYPE_MD5CRYPT;
7993 dgst_size = DGST_SIZE_4_4;
7994 parse_func = juniper_parse_hash;
7995 sort_by_digest = sort_by_digest_4_4;
7996 opti_type = OPTI_TYPE_ZERO_BYTE;
7997 dgst_pos0 = 0;
7998 dgst_pos1 = 1;
7999 dgst_pos2 = 2;
8000 dgst_pos3 = 3;
8001 break;
8002
8003 case 900: hash_type = HASH_TYPE_MD4;
8004 salt_type = SALT_TYPE_NONE;
8005 attack_exec = ATTACK_EXEC_ON_GPU;
8006 opts_type = OPTS_TYPE_PT_GENERATE_LE
8007 | OPTS_TYPE_PT_ADD80
8008 | OPTS_TYPE_PT_ADDBITS14;
8009 kern_type = KERN_TYPE_MD4;
8010 dgst_size = DGST_SIZE_4_4;
8011 parse_func = md4_parse_hash;
8012 sort_by_digest = sort_by_digest_4_4;
8013 opti_type = OPTI_TYPE_ZERO_BYTE
8014 | OPTI_TYPE_PRECOMPUTE_INIT
8015 | OPTI_TYPE_PRECOMPUTE_MERKLE
8016 | OPTI_TYPE_SCALAR_MODE
8017 | OPTI_TYPE_MEET_IN_MIDDLE
8018 | OPTI_TYPE_EARLY_SKIP
8019 | OPTI_TYPE_NOT_ITERATED
8020 | OPTI_TYPE_NOT_SALTED
8021 | OPTI_TYPE_RAW_HASH;
8022 dgst_pos0 = 0;
8023 dgst_pos1 = 3;
8024 dgst_pos2 = 2;
8025 dgst_pos3 = 1;
8026 break;
8027
8028 case 1000: hash_type = HASH_TYPE_MD4;
8029 salt_type = SALT_TYPE_NONE;
8030 attack_exec = ATTACK_EXEC_ON_GPU;
8031 opts_type = OPTS_TYPE_PT_GENERATE_LE
8032 | OPTS_TYPE_PT_ADD80
8033 | OPTS_TYPE_PT_ADDBITS14
8034 | OPTS_TYPE_PT_UNICODE;
8035 kern_type = KERN_TYPE_MD4_PWU;
8036 dgst_size = DGST_SIZE_4_4;
8037 parse_func = md4_parse_hash;
8038 sort_by_digest = sort_by_digest_4_4;
8039 opti_type = OPTI_TYPE_ZERO_BYTE
8040 | OPTI_TYPE_PRECOMPUTE_INIT
8041 | OPTI_TYPE_PRECOMPUTE_MERKLE
8042 | OPTI_TYPE_SCALAR_MODE
8043 | OPTI_TYPE_MEET_IN_MIDDLE
8044 | OPTI_TYPE_EARLY_SKIP
8045 | OPTI_TYPE_NOT_ITERATED
8046 | OPTI_TYPE_NOT_SALTED
8047 | OPTI_TYPE_RAW_HASH;
8048 dgst_pos0 = 0;
8049 dgst_pos1 = 3;
8050 dgst_pos2 = 2;
8051 dgst_pos3 = 1;
8052 break;
8053
8054 case 1100: hash_type = HASH_TYPE_MD4;
8055 salt_type = SALT_TYPE_INTERN;
8056 attack_exec = ATTACK_EXEC_ON_GPU;
8057 opts_type = OPTS_TYPE_PT_GENERATE_LE
8058 | OPTS_TYPE_PT_ADD80
8059 | OPTS_TYPE_PT_ADDBITS14
8060 | OPTS_TYPE_PT_UNICODE
8061 | OPTS_TYPE_ST_ADD80
8062 | OPTS_TYPE_ST_UNICODE
8063 | OPTS_TYPE_ST_LOWER;
8064 kern_type = KERN_TYPE_MD44_PWUSLT;
8065 dgst_size = DGST_SIZE_4_4;
8066 parse_func = dcc_parse_hash;
8067 sort_by_digest = sort_by_digest_4_4;
8068 opti_type = OPTI_TYPE_ZERO_BYTE
8069 | OPTI_TYPE_PRECOMPUTE_INIT
8070 | OPTI_TYPE_PRECOMPUTE_MERKLE
8071 | OPTI_TYPE_SCALAR_MODE
8072 | OPTI_TYPE_EARLY_SKIP
8073 | OPTI_TYPE_NOT_ITERATED;
8074 dgst_pos0 = 0;
8075 dgst_pos1 = 3;
8076 dgst_pos2 = 2;
8077 dgst_pos3 = 1;
8078 break;
8079
8080 case 1400: hash_type = HASH_TYPE_SHA256;
8081 salt_type = SALT_TYPE_NONE;
8082 attack_exec = ATTACK_EXEC_ON_GPU;
8083 opts_type = OPTS_TYPE_PT_GENERATE_BE
8084 | OPTS_TYPE_PT_ADD80
8085 | OPTS_TYPE_PT_ADDBITS15;
8086 kern_type = KERN_TYPE_SHA256;
8087 dgst_size = DGST_SIZE_4_8;
8088 parse_func = sha256_parse_hash;
8089 sort_by_digest = sort_by_digest_4_8;
8090 opti_type = OPTI_TYPE_ZERO_BYTE
8091 | OPTI_TYPE_PRECOMPUTE_INIT
8092 | OPTI_TYPE_PRECOMPUTE_MERKLE
8093 | OPTI_TYPE_SCALAR_MODE
8094 | OPTI_TYPE_EARLY_SKIP
8095 | OPTI_TYPE_NOT_ITERATED
8096 | OPTI_TYPE_NOT_SALTED
8097 | OPTI_TYPE_RAW_HASH;
8098 dgst_pos0 = 3;
8099 dgst_pos1 = 7;
8100 dgst_pos2 = 2;
8101 dgst_pos3 = 6;
8102 break;
8103
8104 case 1410: hash_type = HASH_TYPE_SHA256;
8105 salt_type = SALT_TYPE_INTERN;
8106 attack_exec = ATTACK_EXEC_ON_GPU;
8107 opts_type = OPTS_TYPE_PT_GENERATE_BE
8108 | OPTS_TYPE_ST_ADD80
8109 | OPTS_TYPE_ST_ADDBITS15;
8110 kern_type = KERN_TYPE_SHA256_PWSLT;
8111 dgst_size = DGST_SIZE_4_8;
8112 parse_func = sha256s_parse_hash;
8113 sort_by_digest = sort_by_digest_4_8;
8114 opti_type = OPTI_TYPE_ZERO_BYTE
8115 | OPTI_TYPE_PRECOMPUTE_INIT
8116 | OPTI_TYPE_PRECOMPUTE_MERKLE
8117 | OPTI_TYPE_SCALAR_MODE
8118 | OPTI_TYPE_EARLY_SKIP
8119 | OPTI_TYPE_NOT_ITERATED
8120 | OPTI_TYPE_APPENDED_SALT
8121 | OPTI_TYPE_RAW_HASH;
8122 dgst_pos0 = 3;
8123 dgst_pos1 = 7;
8124 dgst_pos2 = 2;
8125 dgst_pos3 = 6;
8126 break;
8127
8128 case 1420: hash_type = HASH_TYPE_SHA256;
8129 salt_type = SALT_TYPE_INTERN;
8130 attack_exec = ATTACK_EXEC_ON_GPU;
8131 opts_type = OPTS_TYPE_PT_GENERATE_BE
8132 | OPTS_TYPE_PT_ADD80
8133 | OPTS_TYPE_PT_ADDBITS15;
8134 kern_type = KERN_TYPE_SHA256_SLTPW;
8135 dgst_size = DGST_SIZE_4_8;
8136 parse_func = sha256s_parse_hash;
8137 sort_by_digest = sort_by_digest_4_8;
8138 opti_type = OPTI_TYPE_ZERO_BYTE
8139 | OPTI_TYPE_PRECOMPUTE_INIT
8140 | OPTI_TYPE_PRECOMPUTE_MERKLE
8141 | OPTI_TYPE_EARLY_SKIP
8142 | OPTI_TYPE_NOT_ITERATED
8143 | OPTI_TYPE_PREPENDED_SALT
8144 | OPTI_TYPE_RAW_HASH;
8145 dgst_pos0 = 3;
8146 dgst_pos1 = 7;
8147 dgst_pos2 = 2;
8148 dgst_pos3 = 6;
8149 break;
8150
8151 case 1421: hash_type = HASH_TYPE_SHA256;
8152 salt_type = SALT_TYPE_EMBEDDED;
8153 attack_exec = ATTACK_EXEC_ON_GPU;
8154 opts_type = OPTS_TYPE_PT_GENERATE_BE
8155 | OPTS_TYPE_PT_ADD80
8156 | OPTS_TYPE_PT_ADDBITS15;
8157 kern_type = KERN_TYPE_SHA256_SLTPW;
8158 dgst_size = DGST_SIZE_4_8;
8159 parse_func = hmailserver_parse_hash;
8160 sort_by_digest = sort_by_digest_4_8;
8161 opti_type = OPTI_TYPE_ZERO_BYTE
8162 | OPTI_TYPE_PRECOMPUTE_INIT
8163 | OPTI_TYPE_PRECOMPUTE_MERKLE
8164 | OPTI_TYPE_EARLY_SKIP
8165 | OPTI_TYPE_NOT_ITERATED
8166 | OPTI_TYPE_PREPENDED_SALT
8167 | OPTI_TYPE_RAW_HASH;
8168 dgst_pos0 = 3;
8169 dgst_pos1 = 7;
8170 dgst_pos2 = 2;
8171 dgst_pos3 = 6;
8172 break;
8173
8174 case 1430: hash_type = HASH_TYPE_SHA256;
8175 salt_type = SALT_TYPE_INTERN;
8176 attack_exec = ATTACK_EXEC_ON_GPU;
8177 opts_type = OPTS_TYPE_PT_GENERATE_BE
8178 | OPTS_TYPE_PT_UNICODE
8179 | OPTS_TYPE_ST_ADD80
8180 | OPTS_TYPE_ST_ADDBITS15;
8181 kern_type = KERN_TYPE_SHA256_PWUSLT;
8182 dgst_size = DGST_SIZE_4_8;
8183 parse_func = sha256s_parse_hash;
8184 sort_by_digest = sort_by_digest_4_8;
8185 opti_type = OPTI_TYPE_ZERO_BYTE
8186 | OPTI_TYPE_PRECOMPUTE_INIT
8187 | OPTI_TYPE_PRECOMPUTE_MERKLE
8188 | OPTI_TYPE_SCALAR_MODE
8189 | OPTI_TYPE_EARLY_SKIP
8190 | OPTI_TYPE_NOT_ITERATED
8191 | OPTI_TYPE_APPENDED_SALT
8192 | OPTI_TYPE_RAW_HASH;
8193 dgst_pos0 = 3;
8194 dgst_pos1 = 7;
8195 dgst_pos2 = 2;
8196 dgst_pos3 = 6;
8197 break;
8198
8199 case 1440: hash_type = HASH_TYPE_SHA256;
8200 salt_type = SALT_TYPE_INTERN;
8201 attack_exec = ATTACK_EXEC_ON_GPU;
8202 opts_type = OPTS_TYPE_PT_GENERATE_BE
8203 | OPTS_TYPE_PT_ADD80
8204 | OPTS_TYPE_PT_ADDBITS15
8205 | OPTS_TYPE_PT_UNICODE;
8206 kern_type = KERN_TYPE_SHA256_SLTPWU;
8207 dgst_size = DGST_SIZE_4_8;
8208 parse_func = sha256s_parse_hash;
8209 sort_by_digest = sort_by_digest_4_8;
8210 opti_type = OPTI_TYPE_ZERO_BYTE
8211 | OPTI_TYPE_PRECOMPUTE_INIT
8212 | OPTI_TYPE_PRECOMPUTE_MERKLE
8213 | OPTI_TYPE_EARLY_SKIP
8214 | OPTI_TYPE_NOT_ITERATED
8215 | OPTI_TYPE_PREPENDED_SALT
8216 | OPTI_TYPE_RAW_HASH;
8217 dgst_pos0 = 3;
8218 dgst_pos1 = 7;
8219 dgst_pos2 = 2;
8220 dgst_pos3 = 6;
8221 break;
8222
8223 case 1441: hash_type = HASH_TYPE_SHA256;
8224 salt_type = SALT_TYPE_EMBEDDED;
8225 attack_exec = ATTACK_EXEC_ON_GPU;
8226 opts_type = OPTS_TYPE_PT_GENERATE_BE
8227 | OPTS_TYPE_PT_ADD80
8228 | OPTS_TYPE_PT_ADDBITS15
8229 | OPTS_TYPE_PT_UNICODE
8230 | OPTS_TYPE_ST_BASE64;
8231 kern_type = KERN_TYPE_SHA256_SLTPWU;
8232 dgst_size = DGST_SIZE_4_8;
8233 parse_func = episerver4_parse_hash;
8234 sort_by_digest = sort_by_digest_4_8;
8235 opti_type = OPTI_TYPE_ZERO_BYTE
8236 | OPTI_TYPE_PRECOMPUTE_INIT
8237 | OPTI_TYPE_PRECOMPUTE_MERKLE
8238 | OPTI_TYPE_EARLY_SKIP
8239 | OPTI_TYPE_NOT_ITERATED
8240 | OPTI_TYPE_PREPENDED_SALT
8241 | OPTI_TYPE_RAW_HASH;
8242 dgst_pos0 = 3;
8243 dgst_pos1 = 7;
8244 dgst_pos2 = 2;
8245 dgst_pos3 = 6;
8246 break;
8247
8248 case 1450: hash_type = HASH_TYPE_SHA256;
8249 salt_type = SALT_TYPE_INTERN;
8250 attack_exec = ATTACK_EXEC_ON_GPU;
8251 opts_type = OPTS_TYPE_PT_GENERATE_BE
8252 | OPTS_TYPE_ST_ADD80;
8253 kern_type = KERN_TYPE_HMACSHA256_PW;
8254 dgst_size = DGST_SIZE_4_8;
8255 parse_func = hmacsha256_parse_hash;
8256 sort_by_digest = sort_by_digest_4_8;
8257 opti_type = OPTI_TYPE_ZERO_BYTE
8258 | OPTI_TYPE_NOT_ITERATED;
8259 dgst_pos0 = 3;
8260 dgst_pos1 = 7;
8261 dgst_pos2 = 2;
8262 dgst_pos3 = 6;
8263 break;
8264
8265 case 1460: hash_type = HASH_TYPE_SHA256;
8266 salt_type = SALT_TYPE_INTERN;
8267 attack_exec = ATTACK_EXEC_ON_GPU;
8268 opts_type = OPTS_TYPE_PT_GENERATE_BE
8269 | OPTS_TYPE_PT_ADD80
8270 | OPTS_TYPE_PT_ADDBITS15;
8271 kern_type = KERN_TYPE_HMACSHA256_SLT;
8272 dgst_size = DGST_SIZE_4_8;
8273 parse_func = hmacsha256_parse_hash;
8274 sort_by_digest = sort_by_digest_4_8;
8275 opti_type = OPTI_TYPE_ZERO_BYTE
8276 | OPTI_TYPE_NOT_ITERATED;
8277 dgst_pos0 = 3;
8278 dgst_pos1 = 7;
8279 dgst_pos2 = 2;
8280 dgst_pos3 = 6;
8281 break;
8282
8283 case 1500: hash_type = HASH_TYPE_DESCRYPT;
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_BITSLICE;
8288 kern_type = KERN_TYPE_DESCRYPT;
8289 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8290 parse_func = descrypt_parse_hash;
8291 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8292 opti_type = OPTI_TYPE_ZERO_BYTE
8293 | OPTI_TYPE_SCALAR_MODE
8294 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8295 dgst_pos0 = 0;
8296 dgst_pos1 = 1;
8297 dgst_pos2 = 2;
8298 dgst_pos3 = 3;
8299 break;
8300
8301 case 1600: hash_type = HASH_TYPE_MD5;
8302 salt_type = SALT_TYPE_EMBEDDED;
8303 attack_exec = ATTACK_EXEC_ON_CPU;
8304 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8305 kern_type = KERN_TYPE_APR1CRYPT;
8306 dgst_size = DGST_SIZE_4_4;
8307 parse_func = md5apr1_parse_hash;
8308 sort_by_digest = sort_by_digest_4_4;
8309 opti_type = OPTI_TYPE_ZERO_BYTE;
8310 dgst_pos0 = 0;
8311 dgst_pos1 = 1;
8312 dgst_pos2 = 2;
8313 dgst_pos3 = 3;
8314 break;
8315
8316 case 1700: hash_type = HASH_TYPE_SHA512;
8317 salt_type = SALT_TYPE_NONE;
8318 attack_exec = ATTACK_EXEC_ON_GPU;
8319 opts_type = OPTS_TYPE_PT_GENERATE_BE
8320 | OPTS_TYPE_PT_ADD80
8321 | OPTS_TYPE_PT_ADDBITS15;
8322 kern_type = KERN_TYPE_SHA512;
8323 dgst_size = DGST_SIZE_8_8;
8324 parse_func = sha512_parse_hash;
8325 sort_by_digest = sort_by_digest_8_8;
8326 opti_type = OPTI_TYPE_ZERO_BYTE
8327 | OPTI_TYPE_PRECOMPUTE_INIT
8328 | OPTI_TYPE_PRECOMPUTE_MERKLE
8329 | OPTI_TYPE_SCALAR_MODE
8330 | OPTI_TYPE_EARLY_SKIP
8331 | OPTI_TYPE_NOT_ITERATED
8332 | OPTI_TYPE_NOT_SALTED
8333 | OPTI_TYPE_RAW_HASH;
8334 dgst_pos0 = 14;
8335 dgst_pos1 = 15;
8336 dgst_pos2 = 6;
8337 dgst_pos3 = 7;
8338 break;
8339
8340 case 1710: hash_type = HASH_TYPE_SHA512;
8341 salt_type = SALT_TYPE_INTERN;
8342 attack_exec = ATTACK_EXEC_ON_GPU;
8343 opts_type = OPTS_TYPE_PT_GENERATE_BE
8344 | OPTS_TYPE_ST_ADD80
8345 | OPTS_TYPE_ST_ADDBITS15;
8346 kern_type = KERN_TYPE_SHA512_PWSLT;
8347 dgst_size = DGST_SIZE_8_8;
8348 parse_func = sha512s_parse_hash;
8349 sort_by_digest = sort_by_digest_8_8;
8350 opti_type = OPTI_TYPE_ZERO_BYTE
8351 | OPTI_TYPE_PRECOMPUTE_INIT
8352 | OPTI_TYPE_PRECOMPUTE_MERKLE
8353 | OPTI_TYPE_SCALAR_MODE
8354 | OPTI_TYPE_EARLY_SKIP
8355 | OPTI_TYPE_NOT_ITERATED
8356 | OPTI_TYPE_APPENDED_SALT
8357 | OPTI_TYPE_RAW_HASH;
8358 dgst_pos0 = 14;
8359 dgst_pos1 = 15;
8360 dgst_pos2 = 6;
8361 dgst_pos3 = 7;
8362 break;
8363
8364 case 1711: hash_type = HASH_TYPE_SHA512;
8365 salt_type = SALT_TYPE_EMBEDDED;
8366 attack_exec = ATTACK_EXEC_ON_GPU;
8367 opts_type = OPTS_TYPE_PT_GENERATE_BE
8368 | OPTS_TYPE_ST_ADD80
8369 | OPTS_TYPE_ST_ADDBITS15;
8370 kern_type = KERN_TYPE_SHA512_PWSLT;
8371 dgst_size = DGST_SIZE_8_8;
8372 parse_func = sha512b64s_parse_hash;
8373 sort_by_digest = sort_by_digest_8_8;
8374 opti_type = OPTI_TYPE_ZERO_BYTE
8375 | OPTI_TYPE_PRECOMPUTE_INIT
8376 | OPTI_TYPE_PRECOMPUTE_MERKLE
8377 | OPTI_TYPE_SCALAR_MODE
8378 | OPTI_TYPE_EARLY_SKIP
8379 | OPTI_TYPE_NOT_ITERATED
8380 | OPTI_TYPE_APPENDED_SALT
8381 | OPTI_TYPE_RAW_HASH;
8382 dgst_pos0 = 14;
8383 dgst_pos1 = 15;
8384 dgst_pos2 = 6;
8385 dgst_pos3 = 7;
8386 break;
8387
8388 case 1720: hash_type = HASH_TYPE_SHA512;
8389 salt_type = SALT_TYPE_INTERN;
8390 attack_exec = ATTACK_EXEC_ON_GPU;
8391 opts_type = OPTS_TYPE_PT_GENERATE_BE
8392 | OPTS_TYPE_PT_ADD80
8393 | OPTS_TYPE_PT_ADDBITS15;
8394 kern_type = KERN_TYPE_SHA512_SLTPW;
8395 dgst_size = DGST_SIZE_8_8;
8396 parse_func = sha512s_parse_hash;
8397 sort_by_digest = sort_by_digest_8_8;
8398 opti_type = OPTI_TYPE_ZERO_BYTE
8399 | OPTI_TYPE_PRECOMPUTE_INIT
8400 | OPTI_TYPE_PRECOMPUTE_MERKLE
8401 | OPTI_TYPE_EARLY_SKIP
8402 | OPTI_TYPE_NOT_ITERATED
8403 | OPTI_TYPE_PREPENDED_SALT
8404 | OPTI_TYPE_RAW_HASH;
8405 dgst_pos0 = 14;
8406 dgst_pos1 = 15;
8407 dgst_pos2 = 6;
8408 dgst_pos3 = 7;
8409 break;
8410
8411 case 1722: hash_type = HASH_TYPE_SHA512;
8412 salt_type = SALT_TYPE_EMBEDDED;
8413 attack_exec = ATTACK_EXEC_ON_GPU;
8414 opts_type = OPTS_TYPE_PT_GENERATE_BE
8415 | OPTS_TYPE_PT_ADD80
8416 | OPTS_TYPE_PT_ADDBITS15
8417 | OPTS_TYPE_ST_HEX;
8418 kern_type = KERN_TYPE_SHA512_SLTPW;
8419 dgst_size = DGST_SIZE_8_8;
8420 parse_func = osx512_parse_hash;
8421 sort_by_digest = sort_by_digest_8_8;
8422 opti_type = OPTI_TYPE_ZERO_BYTE
8423 | OPTI_TYPE_PRECOMPUTE_INIT
8424 | OPTI_TYPE_PRECOMPUTE_MERKLE
8425 | OPTI_TYPE_EARLY_SKIP
8426 | OPTI_TYPE_NOT_ITERATED
8427 | OPTI_TYPE_PREPENDED_SALT
8428 | OPTI_TYPE_RAW_HASH;
8429 dgst_pos0 = 14;
8430 dgst_pos1 = 15;
8431 dgst_pos2 = 6;
8432 dgst_pos3 = 7;
8433 break;
8434
8435 case 1730: hash_type = HASH_TYPE_SHA512;
8436 salt_type = SALT_TYPE_INTERN;
8437 attack_exec = ATTACK_EXEC_ON_GPU;
8438 opts_type = OPTS_TYPE_PT_GENERATE_BE
8439 | OPTS_TYPE_PT_UNICODE
8440 | OPTS_TYPE_ST_ADD80
8441 | OPTS_TYPE_ST_ADDBITS15;
8442 kern_type = KERN_TYPE_SHA512_PWSLTU;
8443 dgst_size = DGST_SIZE_8_8;
8444 parse_func = sha512s_parse_hash;
8445 sort_by_digest = sort_by_digest_8_8;
8446 opti_type = OPTI_TYPE_ZERO_BYTE
8447 | OPTI_TYPE_PRECOMPUTE_INIT
8448 | OPTI_TYPE_PRECOMPUTE_MERKLE
8449 | OPTI_TYPE_SCALAR_MODE
8450 | OPTI_TYPE_EARLY_SKIP
8451 | OPTI_TYPE_NOT_ITERATED
8452 | OPTI_TYPE_APPENDED_SALT
8453 | OPTI_TYPE_RAW_HASH;
8454 dgst_pos0 = 14;
8455 dgst_pos1 = 15;
8456 dgst_pos2 = 6;
8457 dgst_pos3 = 7;
8458 break;
8459
8460 case 1731: hash_type = HASH_TYPE_SHA512;
8461 salt_type = SALT_TYPE_EMBEDDED;
8462 attack_exec = ATTACK_EXEC_ON_GPU;
8463 opts_type = OPTS_TYPE_PT_GENERATE_BE
8464 | OPTS_TYPE_PT_UNICODE
8465 | OPTS_TYPE_ST_ADD80
8466 | OPTS_TYPE_ST_ADDBITS15
8467 | OPTS_TYPE_ST_HEX;
8468 kern_type = KERN_TYPE_SHA512_PWSLTU;
8469 dgst_size = DGST_SIZE_8_8;
8470 parse_func = mssql2012_parse_hash;
8471 sort_by_digest = sort_by_digest_8_8;
8472 opti_type = OPTI_TYPE_ZERO_BYTE
8473 | OPTI_TYPE_PRECOMPUTE_INIT
8474 | OPTI_TYPE_PRECOMPUTE_MERKLE
8475 | OPTI_TYPE_SCALAR_MODE
8476 | OPTI_TYPE_EARLY_SKIP
8477 | OPTI_TYPE_NOT_ITERATED
8478 | OPTI_TYPE_APPENDED_SALT
8479 | OPTI_TYPE_RAW_HASH;
8480 dgst_pos0 = 14;
8481 dgst_pos1 = 15;
8482 dgst_pos2 = 6;
8483 dgst_pos3 = 7;
8484 break;
8485
8486 case 1740: hash_type = HASH_TYPE_SHA512;
8487 salt_type = SALT_TYPE_INTERN;
8488 attack_exec = ATTACK_EXEC_ON_GPU;
8489 opts_type = OPTS_TYPE_PT_GENERATE_BE
8490 | OPTS_TYPE_PT_ADD80
8491 | OPTS_TYPE_PT_ADDBITS15
8492 | OPTS_TYPE_PT_UNICODE;
8493 kern_type = KERN_TYPE_SHA512_SLTPWU;
8494 dgst_size = DGST_SIZE_8_8;
8495 parse_func = sha512s_parse_hash;
8496 sort_by_digest = sort_by_digest_8_8;
8497 opti_type = OPTI_TYPE_ZERO_BYTE
8498 | OPTI_TYPE_PRECOMPUTE_INIT
8499 | OPTI_TYPE_PRECOMPUTE_MERKLE
8500 | OPTI_TYPE_EARLY_SKIP
8501 | OPTI_TYPE_NOT_ITERATED
8502 | OPTI_TYPE_PREPENDED_SALT
8503 | OPTI_TYPE_RAW_HASH;
8504 dgst_pos0 = 14;
8505 dgst_pos1 = 15;
8506 dgst_pos2 = 6;
8507 dgst_pos3 = 7;
8508 break;
8509
8510 case 1750: hash_type = HASH_TYPE_SHA512;
8511 salt_type = SALT_TYPE_INTERN;
8512 attack_exec = ATTACK_EXEC_ON_GPU;
8513 opts_type = OPTS_TYPE_PT_GENERATE_BE
8514 | OPTS_TYPE_ST_ADD80;
8515 kern_type = KERN_TYPE_HMACSHA512_PW;
8516 dgst_size = DGST_SIZE_8_8;
8517 parse_func = hmacsha512_parse_hash;
8518 sort_by_digest = sort_by_digest_8_8;
8519 opti_type = OPTI_TYPE_ZERO_BYTE
8520 | OPTI_TYPE_NOT_ITERATED;
8521 dgst_pos0 = 14;
8522 dgst_pos1 = 15;
8523 dgst_pos2 = 6;
8524 dgst_pos3 = 7;
8525 break;
8526
8527 case 1760: hash_type = HASH_TYPE_SHA512;
8528 salt_type = SALT_TYPE_INTERN;
8529 attack_exec = ATTACK_EXEC_ON_GPU;
8530 opts_type = OPTS_TYPE_PT_GENERATE_BE
8531 | OPTS_TYPE_PT_ADD80
8532 | OPTS_TYPE_PT_ADDBITS15;
8533 kern_type = KERN_TYPE_HMACSHA512_SLT;
8534 dgst_size = DGST_SIZE_8_8;
8535 parse_func = hmacsha512_parse_hash;
8536 sort_by_digest = sort_by_digest_8_8;
8537 opti_type = OPTI_TYPE_ZERO_BYTE
8538 | OPTI_TYPE_NOT_ITERATED;
8539 dgst_pos0 = 14;
8540 dgst_pos1 = 15;
8541 dgst_pos2 = 6;
8542 dgst_pos3 = 7;
8543 break;
8544
8545 case 1800: hash_type = HASH_TYPE_SHA512;
8546 salt_type = SALT_TYPE_EMBEDDED;
8547 attack_exec = ATTACK_EXEC_ON_CPU;
8548 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8549 kern_type = KERN_TYPE_SHA512CRYPT;
8550 dgst_size = DGST_SIZE_8_8;
8551 parse_func = sha512crypt_parse_hash;
8552 sort_by_digest = sort_by_digest_8_8;
8553 opti_type = OPTI_TYPE_ZERO_BYTE;
8554 dgst_pos0 = 0;
8555 dgst_pos1 = 1;
8556 dgst_pos2 = 2;
8557 dgst_pos3 = 3;
8558 break;
8559
8560 case 2100: hash_type = HASH_TYPE_DCC2;
8561 salt_type = SALT_TYPE_EMBEDDED;
8562 attack_exec = ATTACK_EXEC_ON_CPU;
8563 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
8564 | OPTS_TYPE_ST_LOWER
8565 | OPTS_TYPE_ST_UNICODE;
8566 kern_type = KERN_TYPE_DCC2;
8567 dgst_size = DGST_SIZE_4_4;
8568 parse_func = dcc2_parse_hash;
8569 sort_by_digest = sort_by_digest_4_4;
8570 opti_type = OPTI_TYPE_ZERO_BYTE;
8571 dgst_pos0 = 0;
8572 dgst_pos1 = 1;
8573 dgst_pos2 = 2;
8574 dgst_pos3 = 3;
8575 break;
8576
8577 case 2400: hash_type = HASH_TYPE_MD5;
8578 salt_type = SALT_TYPE_NONE;
8579 attack_exec = ATTACK_EXEC_ON_GPU;
8580 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8581 kern_type = KERN_TYPE_MD5PIX;
8582 dgst_size = DGST_SIZE_4_4;
8583 parse_func = md5pix_parse_hash;
8584 sort_by_digest = sort_by_digest_4_4;
8585 opti_type = OPTI_TYPE_ZERO_BYTE
8586 | OPTI_TYPE_PRECOMPUTE_INIT
8587 | OPTI_TYPE_PRECOMPUTE_MERKLE
8588 | OPTI_TYPE_SCALAR_MODE
8589 | OPTI_TYPE_EARLY_SKIP
8590 | OPTI_TYPE_NOT_ITERATED
8591 | OPTI_TYPE_NOT_SALTED;
8592 dgst_pos0 = 0;
8593 dgst_pos1 = 3;
8594 dgst_pos2 = 2;
8595 dgst_pos3 = 1;
8596 break;
8597
8598 case 2410: hash_type = HASH_TYPE_MD5;
8599 salt_type = SALT_TYPE_INTERN;
8600 attack_exec = ATTACK_EXEC_ON_GPU;
8601 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8602 kern_type = KERN_TYPE_MD5ASA;
8603 dgst_size = DGST_SIZE_4_4;
8604 parse_func = md5asa_parse_hash;
8605 sort_by_digest = sort_by_digest_4_4;
8606 opti_type = OPTI_TYPE_ZERO_BYTE
8607 | OPTI_TYPE_PRECOMPUTE_INIT
8608 | OPTI_TYPE_PRECOMPUTE_MERKLE
8609 | OPTI_TYPE_SCALAR_MODE
8610 | OPTI_TYPE_EARLY_SKIP
8611 | OPTI_TYPE_NOT_ITERATED;
8612 dgst_pos0 = 0;
8613 dgst_pos1 = 3;
8614 dgst_pos2 = 2;
8615 dgst_pos3 = 1;
8616 break;
8617
8618 case 2500: hash_type = HASH_TYPE_WPA;
8619 salt_type = SALT_TYPE_EMBEDDED;
8620 attack_exec = ATTACK_EXEC_ON_CPU;
8621 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
8622 kern_type = KERN_TYPE_WPA;
8623 dgst_size = DGST_SIZE_4_4;
8624 parse_func = wpa_parse_hash;
8625 sort_by_digest = sort_by_digest_4_4;
8626 opti_type = OPTI_TYPE_ZERO_BYTE;
8627 dgst_pos0 = 0;
8628 dgst_pos1 = 1;
8629 dgst_pos2 = 2;
8630 dgst_pos3 = 3;
8631 break;
8632
8633 case 2600: hash_type = HASH_TYPE_MD5;
8634 salt_type = SALT_TYPE_VIRTUAL;
8635 attack_exec = ATTACK_EXEC_ON_GPU;
8636 opts_type = OPTS_TYPE_PT_GENERATE_LE
8637 | OPTS_TYPE_PT_ADD80
8638 | OPTS_TYPE_PT_ADDBITS14
8639 | OPTS_TYPE_ST_ADD80;
8640 kern_type = KERN_TYPE_MD55_PWSLT1;
8641 dgst_size = DGST_SIZE_4_4;
8642 parse_func = md5md5_parse_hash;
8643 sort_by_digest = sort_by_digest_4_4;
8644 opti_type = OPTI_TYPE_ZERO_BYTE
8645 | OPTI_TYPE_PRECOMPUTE_INIT
8646 | OPTI_TYPE_PRECOMPUTE_MERKLE
8647 | OPTI_TYPE_EARLY_SKIP;
8648 dgst_pos0 = 0;
8649 dgst_pos1 = 3;
8650 dgst_pos2 = 2;
8651 dgst_pos3 = 1;
8652 break;
8653
8654 case 2611: hash_type = HASH_TYPE_MD5;
8655 salt_type = SALT_TYPE_INTERN;
8656 attack_exec = ATTACK_EXEC_ON_GPU;
8657 opts_type = OPTS_TYPE_PT_GENERATE_LE
8658 | OPTS_TYPE_PT_ADD80
8659 | OPTS_TYPE_PT_ADDBITS14
8660 | OPTS_TYPE_ST_ADD80;
8661 kern_type = KERN_TYPE_MD55_PWSLT1;
8662 dgst_size = DGST_SIZE_4_4;
8663 parse_func = vb3_parse_hash;
8664 sort_by_digest = sort_by_digest_4_4;
8665 opti_type = OPTI_TYPE_ZERO_BYTE
8666 | OPTI_TYPE_PRECOMPUTE_INIT
8667 | OPTI_TYPE_PRECOMPUTE_MERKLE
8668 | OPTI_TYPE_EARLY_SKIP;
8669 dgst_pos0 = 0;
8670 dgst_pos1 = 3;
8671 dgst_pos2 = 2;
8672 dgst_pos3 = 1;
8673 break;
8674
8675 case 2612: hash_type = HASH_TYPE_MD5;
8676 salt_type = SALT_TYPE_EMBEDDED;
8677 attack_exec = ATTACK_EXEC_ON_GPU;
8678 opts_type = OPTS_TYPE_PT_GENERATE_LE
8679 | OPTS_TYPE_PT_ADD80
8680 | OPTS_TYPE_PT_ADDBITS14
8681 | OPTS_TYPE_ST_ADD80
8682 | OPTS_TYPE_ST_HEX;
8683 kern_type = KERN_TYPE_MD55_PWSLT1;
8684 dgst_size = DGST_SIZE_4_4;
8685 parse_func = phps_parse_hash;
8686 sort_by_digest = sort_by_digest_4_4;
8687 opti_type = OPTI_TYPE_ZERO_BYTE
8688 | OPTI_TYPE_PRECOMPUTE_INIT
8689 | OPTI_TYPE_PRECOMPUTE_MERKLE
8690 | OPTI_TYPE_EARLY_SKIP;
8691 dgst_pos0 = 0;
8692 dgst_pos1 = 3;
8693 dgst_pos2 = 2;
8694 dgst_pos3 = 1;
8695 break;
8696
8697 case 2711: hash_type = HASH_TYPE_MD5;
8698 salt_type = SALT_TYPE_INTERN;
8699 attack_exec = ATTACK_EXEC_ON_GPU;
8700 opts_type = OPTS_TYPE_PT_GENERATE_LE
8701 | OPTS_TYPE_PT_ADD80
8702 | OPTS_TYPE_PT_ADDBITS14
8703 | OPTS_TYPE_ST_ADD80;
8704 kern_type = KERN_TYPE_MD55_PWSLT2;
8705 dgst_size = DGST_SIZE_4_4;
8706 parse_func = vb30_parse_hash;
8707 sort_by_digest = sort_by_digest_4_4;
8708 opti_type = OPTI_TYPE_ZERO_BYTE
8709 | OPTI_TYPE_PRECOMPUTE_INIT
8710 | OPTI_TYPE_EARLY_SKIP;
8711 dgst_pos0 = 0;
8712 dgst_pos1 = 3;
8713 dgst_pos2 = 2;
8714 dgst_pos3 = 1;
8715 break;
8716
8717 case 2811: hash_type = HASH_TYPE_MD5;
8718 salt_type = SALT_TYPE_INTERN;
8719 attack_exec = ATTACK_EXEC_ON_GPU;
8720 opts_type = OPTS_TYPE_PT_GENERATE_LE
8721 | OPTS_TYPE_PT_ADD80
8722 | OPTS_TYPE_PT_ADDBITS14;
8723 kern_type = KERN_TYPE_MD55_SLTPW;
8724 dgst_size = DGST_SIZE_4_4;
8725 parse_func = ipb2_parse_hash;
8726 sort_by_digest = sort_by_digest_4_4;
8727 opti_type = OPTI_TYPE_ZERO_BYTE
8728 | OPTI_TYPE_PRECOMPUTE_INIT
8729 | OPTI_TYPE_EARLY_SKIP;
8730 dgst_pos0 = 0;
8731 dgst_pos1 = 3;
8732 dgst_pos2 = 2;
8733 dgst_pos3 = 1;
8734 break;
8735
8736 case 3000: hash_type = HASH_TYPE_LM;
8737 salt_type = SALT_TYPE_NONE;
8738 attack_exec = ATTACK_EXEC_ON_GPU;
8739 opts_type = OPTS_TYPE_PT_GENERATE_LE
8740 | OPTS_TYPE_PT_UPPER
8741 | OPTS_TYPE_PT_BITSLICE;
8742 kern_type = KERN_TYPE_LM;
8743 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8744 parse_func = lm_parse_hash;
8745 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8746 opti_type = OPTI_TYPE_ZERO_BYTE
8747 | OPTI_TYPE_SCALAR_MODE
8748 | OPTI_TYPE_PRECOMPUTE_PERMUT;
8749 dgst_pos0 = 0;
8750 dgst_pos1 = 1;
8751 dgst_pos2 = 2;
8752 dgst_pos3 = 3;
8753 break;
8754
8755 case 3100: hash_type = HASH_TYPE_ORACLEH;
8756 salt_type = SALT_TYPE_INTERN;
8757 attack_exec = ATTACK_EXEC_ON_GPU;
8758 opts_type = OPTS_TYPE_PT_GENERATE_LE
8759 | OPTS_TYPE_PT_UPPER
8760 | OPTS_TYPE_ST_UPPER;
8761 kern_type = KERN_TYPE_ORACLEH;
8762 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
8763 parse_func = oracleh_parse_hash;
8764 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
8765 opti_type = OPTI_TYPE_ZERO_BYTE
8766 | OPTI_TYPE_SCALAR_MODE;
8767 dgst_pos0 = 0;
8768 dgst_pos1 = 1;
8769 dgst_pos2 = 2;
8770 dgst_pos3 = 3;
8771 break;
8772
8773 case 3200: hash_type = HASH_TYPE_BCRYPT;
8774 salt_type = SALT_TYPE_EMBEDDED;
8775 attack_exec = ATTACK_EXEC_ON_CPU;
8776 opts_type = OPTS_TYPE_PT_GENERATE_LE
8777 | OPTS_TYPE_ST_GENERATE_LE;
8778 kern_type = KERN_TYPE_BCRYPT;
8779 dgst_size = DGST_SIZE_4_6;
8780 parse_func = bcrypt_parse_hash;
8781 sort_by_digest = sort_by_digest_4_6;
8782 opti_type = OPTI_TYPE_ZERO_BYTE;
8783 dgst_pos0 = 0;
8784 dgst_pos1 = 1;
8785 dgst_pos2 = 2;
8786 dgst_pos3 = 3;
8787 break;
8788
8789 case 3710: hash_type = HASH_TYPE_MD5;
8790 salt_type = SALT_TYPE_INTERN;
8791 attack_exec = ATTACK_EXEC_ON_GPU;
8792 opts_type = OPTS_TYPE_PT_GENERATE_LE
8793 | OPTS_TYPE_PT_ADD80
8794 | OPTS_TYPE_PT_ADDBITS14;
8795 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8796 dgst_size = DGST_SIZE_4_4;
8797 parse_func = md5s_parse_hash;
8798 sort_by_digest = sort_by_digest_4_4;
8799 opti_type = OPTI_TYPE_ZERO_BYTE
8800 | OPTI_TYPE_PRECOMPUTE_INIT
8801 | OPTI_TYPE_PRECOMPUTE_MERKLE
8802 | OPTI_TYPE_EARLY_SKIP;
8803 dgst_pos0 = 0;
8804 dgst_pos1 = 3;
8805 dgst_pos2 = 2;
8806 dgst_pos3 = 1;
8807 break;
8808
8809 case 3711: hash_type = HASH_TYPE_MD5;
8810 salt_type = SALT_TYPE_EMBEDDED;
8811 attack_exec = ATTACK_EXEC_ON_GPU;
8812 opts_type = OPTS_TYPE_PT_GENERATE_LE
8813 | OPTS_TYPE_PT_ADD80
8814 | OPTS_TYPE_PT_ADDBITS14;
8815 kern_type = KERN_TYPE_MD5_SLT_MD5_PW;
8816 dgst_size = DGST_SIZE_4_4;
8817 parse_func = mediawiki_b_parse_hash;
8818 sort_by_digest = sort_by_digest_4_4;
8819 opti_type = OPTI_TYPE_ZERO_BYTE
8820 | OPTI_TYPE_PRECOMPUTE_INIT
8821 | OPTI_TYPE_PRECOMPUTE_MERKLE
8822 | OPTI_TYPE_EARLY_SKIP;
8823 dgst_pos0 = 0;
8824 dgst_pos1 = 3;
8825 dgst_pos2 = 2;
8826 dgst_pos3 = 1;
8827 break;
8828
8829 case 3800: hash_type = HASH_TYPE_MD5;
8830 salt_type = SALT_TYPE_INTERN;
8831 attack_exec = ATTACK_EXEC_ON_GPU;
8832 opts_type = OPTS_TYPE_PT_GENERATE_LE
8833 | OPTS_TYPE_ST_ADDBITS14;
8834 kern_type = KERN_TYPE_MD5_SLT_PW_SLT;
8835 dgst_size = DGST_SIZE_4_4;
8836 parse_func = md5s_parse_hash;
8837 sort_by_digest = sort_by_digest_4_4;
8838 opti_type = OPTI_TYPE_ZERO_BYTE
8839 | OPTI_TYPE_PRECOMPUTE_INIT
8840 | OPTI_TYPE_PRECOMPUTE_MERKLE
8841 | OPTI_TYPE_EARLY_SKIP
8842 | OPTI_TYPE_NOT_ITERATED
8843 | OPTI_TYPE_RAW_HASH;
8844 dgst_pos0 = 0;
8845 dgst_pos1 = 3;
8846 dgst_pos2 = 2;
8847 dgst_pos3 = 1;
8848 break;
8849
8850 case 4300: hash_type = HASH_TYPE_MD5;
8851 salt_type = SALT_TYPE_VIRTUAL;
8852 attack_exec = ATTACK_EXEC_ON_GPU;
8853 opts_type = OPTS_TYPE_PT_GENERATE_LE
8854 | OPTS_TYPE_PT_ADD80
8855 | OPTS_TYPE_PT_ADDBITS14
8856 | OPTS_TYPE_ST_ADD80;
8857 kern_type = KERN_TYPE_MD5U5_PWSLT1;
8858 dgst_size = DGST_SIZE_4_4;
8859 parse_func = md5md5_parse_hash;
8860 sort_by_digest = sort_by_digest_4_4;
8861 opti_type = OPTI_TYPE_ZERO_BYTE
8862 | OPTI_TYPE_PRECOMPUTE_INIT
8863 | OPTI_TYPE_PRECOMPUTE_MERKLE
8864 | OPTI_TYPE_EARLY_SKIP;
8865 dgst_pos0 = 0;
8866 dgst_pos1 = 3;
8867 dgst_pos2 = 2;
8868 dgst_pos3 = 1;
8869 break;
8870
8871
8872 case 4400: hash_type = HASH_TYPE_MD5;
8873 salt_type = SALT_TYPE_NONE;
8874 attack_exec = ATTACK_EXEC_ON_GPU;
8875 opts_type = OPTS_TYPE_PT_GENERATE_BE
8876 | OPTS_TYPE_PT_ADD80
8877 | OPTS_TYPE_PT_ADDBITS15;
8878 kern_type = KERN_TYPE_MD5_SHA1;
8879 dgst_size = DGST_SIZE_4_4;
8880 parse_func = md5_parse_hash;
8881 sort_by_digest = sort_by_digest_4_4;
8882 opti_type = OPTI_TYPE_ZERO_BYTE
8883 | OPTI_TYPE_PRECOMPUTE_INIT
8884 | OPTI_TYPE_PRECOMPUTE_MERKLE
8885 | OPTI_TYPE_EARLY_SKIP
8886 | OPTI_TYPE_NOT_ITERATED
8887 | OPTI_TYPE_NOT_SALTED
8888 | OPTI_TYPE_RAW_HASH;
8889 dgst_pos0 = 0;
8890 dgst_pos1 = 3;
8891 dgst_pos2 = 2;
8892 dgst_pos3 = 1;
8893 break;
8894
8895 case 4500: hash_type = HASH_TYPE_SHA1;
8896 salt_type = SALT_TYPE_NONE;
8897 attack_exec = ATTACK_EXEC_ON_GPU;
8898 opts_type = OPTS_TYPE_PT_GENERATE_BE
8899 | OPTS_TYPE_PT_ADD80
8900 | OPTS_TYPE_PT_ADDBITS15;
8901 kern_type = KERN_TYPE_SHA11;
8902 dgst_size = DGST_SIZE_4_5;
8903 parse_func = sha1_parse_hash;
8904 sort_by_digest = sort_by_digest_4_5;
8905 opti_type = OPTI_TYPE_ZERO_BYTE
8906 | OPTI_TYPE_PRECOMPUTE_INIT
8907 | OPTI_TYPE_PRECOMPUTE_MERKLE
8908 | OPTI_TYPE_EARLY_SKIP
8909 | OPTI_TYPE_NOT_SALTED;
8910 dgst_pos0 = 3;
8911 dgst_pos1 = 4;
8912 dgst_pos2 = 2;
8913 dgst_pos3 = 1;
8914 break;
8915
8916 case 4700: hash_type = HASH_TYPE_SHA1;
8917 salt_type = SALT_TYPE_NONE;
8918 attack_exec = ATTACK_EXEC_ON_GPU;
8919 opts_type = OPTS_TYPE_PT_GENERATE_LE
8920 | OPTS_TYPE_PT_ADD80
8921 | OPTS_TYPE_PT_ADDBITS14;
8922 kern_type = KERN_TYPE_SHA1_MD5;
8923 dgst_size = DGST_SIZE_4_5;
8924 parse_func = sha1_parse_hash;
8925 sort_by_digest = sort_by_digest_4_5;
8926 opti_type = OPTI_TYPE_ZERO_BYTE
8927 | OPTI_TYPE_PRECOMPUTE_INIT
8928 | OPTI_TYPE_PRECOMPUTE_MERKLE
8929 | OPTI_TYPE_EARLY_SKIP
8930 | OPTI_TYPE_NOT_ITERATED
8931 | OPTI_TYPE_NOT_SALTED
8932 | OPTI_TYPE_RAW_HASH;
8933 dgst_pos0 = 3;
8934 dgst_pos1 = 4;
8935 dgst_pos2 = 2;
8936 dgst_pos3 = 1;
8937 break;
8938
8939 case 4800: hash_type = HASH_TYPE_MD5;
8940 salt_type = SALT_TYPE_EMBEDDED;
8941 attack_exec = ATTACK_EXEC_ON_GPU;
8942 opts_type = OPTS_TYPE_PT_GENERATE_LE
8943 | OPTS_TYPE_PT_ADDBITS14;
8944 kern_type = KERN_TYPE_MD5_CHAP;
8945 dgst_size = DGST_SIZE_4_4;
8946 parse_func = chap_parse_hash;
8947 sort_by_digest = sort_by_digest_4_4;
8948 opti_type = OPTI_TYPE_ZERO_BYTE
8949 | OPTI_TYPE_PRECOMPUTE_INIT
8950 | OPTI_TYPE_PRECOMPUTE_MERKLE
8951 | OPTI_TYPE_MEET_IN_MIDDLE
8952 | OPTI_TYPE_EARLY_SKIP
8953 | OPTI_TYPE_NOT_ITERATED
8954 | OPTI_TYPE_RAW_HASH;
8955 dgst_pos0 = 0;
8956 dgst_pos1 = 3;
8957 dgst_pos2 = 2;
8958 dgst_pos3 = 1;
8959 break;
8960
8961 case 4900: hash_type = HASH_TYPE_SHA1;
8962 salt_type = SALT_TYPE_INTERN;
8963 attack_exec = ATTACK_EXEC_ON_GPU;
8964 opts_type = OPTS_TYPE_PT_GENERATE_LE;
8965 kern_type = KERN_TYPE_SHA1_SLT_PW_SLT;
8966 dgst_size = DGST_SIZE_4_5;
8967 parse_func = sha1s_parse_hash;
8968 sort_by_digest = sort_by_digest_4_5;
8969 opti_type = OPTI_TYPE_ZERO_BYTE
8970 | OPTI_TYPE_PRECOMPUTE_INIT
8971 | OPTI_TYPE_PRECOMPUTE_MERKLE
8972 | OPTI_TYPE_EARLY_SKIP;
8973 dgst_pos0 = 3;
8974 dgst_pos1 = 4;
8975 dgst_pos2 = 2;
8976 dgst_pos3 = 1;
8977 break;
8978
8979 case 5000: hash_type = HASH_TYPE_KECCAK;
8980 salt_type = SALT_TYPE_EMBEDDED;
8981 attack_exec = ATTACK_EXEC_ON_GPU;
8982 opts_type = OPTS_TYPE_PT_GENERATE_LE
8983 | OPTS_TYPE_PT_ADD01;
8984 kern_type = KERN_TYPE_KECCAK;
8985 dgst_size = DGST_SIZE_8_25;
8986 parse_func = keccak_parse_hash;
8987 sort_by_digest = sort_by_digest_8_25;
8988 opti_type = OPTI_TYPE_ZERO_BYTE
8989 | OPTI_TYPE_RAW_HASH;
8990 dgst_pos0 = 2;
8991 dgst_pos1 = 3;
8992 dgst_pos2 = 4;
8993 dgst_pos3 = 5;
8994 break;
8995
8996 case 5100: hash_type = HASH_TYPE_MD5H;
8997 salt_type = SALT_TYPE_NONE;
8998 attack_exec = ATTACK_EXEC_ON_GPU;
8999 opts_type = OPTS_TYPE_PT_GENERATE_LE
9000 | OPTS_TYPE_PT_ADD80
9001 | OPTS_TYPE_PT_ADDBITS14;
9002 kern_type = KERN_TYPE_MD5H;
9003 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9004 parse_func = md5half_parse_hash;
9005 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9006 opti_type = OPTI_TYPE_ZERO_BYTE
9007 | OPTI_TYPE_RAW_HASH;
9008 dgst_pos0 = 0;
9009 dgst_pos1 = 1;
9010 dgst_pos2 = 2;
9011 dgst_pos3 = 3;
9012 break;
9013
9014 case 5200: hash_type = HASH_TYPE_SHA256;
9015 salt_type = SALT_TYPE_EMBEDDED;
9016 attack_exec = ATTACK_EXEC_ON_CPU;
9017 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9018 kern_type = KERN_TYPE_PSAFE3;
9019 dgst_size = DGST_SIZE_4_8;
9020 parse_func = psafe3_parse_hash;
9021 sort_by_digest = sort_by_digest_4_8;
9022 opti_type = OPTI_TYPE_ZERO_BYTE;
9023 dgst_pos0 = 0;
9024 dgst_pos1 = 1;
9025 dgst_pos2 = 2;
9026 dgst_pos3 = 3;
9027 break;
9028
9029 case 5300: hash_type = HASH_TYPE_MD5;
9030 salt_type = SALT_TYPE_EMBEDDED;
9031 attack_exec = ATTACK_EXEC_ON_GPU;
9032 opts_type = OPTS_TYPE_PT_GENERATE_LE
9033 | OPTS_TYPE_ST_ADD80;
9034 kern_type = KERN_TYPE_IKEPSK_MD5;
9035 dgst_size = DGST_SIZE_4_4;
9036 parse_func = ikepsk_md5_parse_hash;
9037 sort_by_digest = sort_by_digest_4_4;
9038 opti_type = OPTI_TYPE_ZERO_BYTE;
9039 dgst_pos0 = 0;
9040 dgst_pos1 = 3;
9041 dgst_pos2 = 2;
9042 dgst_pos3 = 1;
9043 break;
9044
9045 case 5400: hash_type = HASH_TYPE_SHA1;
9046 salt_type = SALT_TYPE_EMBEDDED;
9047 attack_exec = ATTACK_EXEC_ON_GPU;
9048 opts_type = OPTS_TYPE_PT_GENERATE_BE
9049 | OPTS_TYPE_ST_ADD80;
9050 kern_type = KERN_TYPE_IKEPSK_SHA1;
9051 dgst_size = DGST_SIZE_4_5;
9052 parse_func = ikepsk_sha1_parse_hash;
9053 sort_by_digest = sort_by_digest_4_5;
9054 opti_type = OPTI_TYPE_ZERO_BYTE;
9055 dgst_pos0 = 3;
9056 dgst_pos1 = 4;
9057 dgst_pos2 = 2;
9058 dgst_pos3 = 1;
9059 break;
9060
9061 case 5500: hash_type = HASH_TYPE_NETNTLM;
9062 salt_type = SALT_TYPE_EMBEDDED;
9063 attack_exec = ATTACK_EXEC_ON_GPU;
9064 opts_type = OPTS_TYPE_PT_GENERATE_LE
9065 | OPTS_TYPE_PT_ADD80
9066 | OPTS_TYPE_PT_ADDBITS14
9067 | OPTS_TYPE_PT_UNICODE
9068 | OPTS_TYPE_ST_HEX;
9069 kern_type = KERN_TYPE_NETNTLMv1;
9070 dgst_size = DGST_SIZE_4_4;
9071 parse_func = netntlmv1_parse_hash;
9072 sort_by_digest = sort_by_digest_4_4;
9073 opti_type = OPTI_TYPE_ZERO_BYTE
9074 | OPTI_TYPE_SCALAR_MODE
9075 | OPTI_TYPE_PRECOMPUTE_PERMUT;
9076 dgst_pos0 = 0;
9077 dgst_pos1 = 1;
9078 dgst_pos2 = 2;
9079 dgst_pos3 = 3;
9080 break;
9081
9082 case 5600: hash_type = HASH_TYPE_MD5;
9083 salt_type = SALT_TYPE_EMBEDDED;
9084 attack_exec = ATTACK_EXEC_ON_GPU;
9085 opts_type = OPTS_TYPE_PT_GENERATE_LE
9086 | OPTS_TYPE_PT_ADD80
9087 | OPTS_TYPE_PT_ADDBITS14
9088 | OPTS_TYPE_PT_UNICODE;
9089 kern_type = KERN_TYPE_NETNTLMv2;
9090 dgst_size = DGST_SIZE_4_4;
9091 parse_func = netntlmv2_parse_hash;
9092 sort_by_digest = sort_by_digest_4_4;
9093 opti_type = OPTI_TYPE_ZERO_BYTE;
9094 dgst_pos0 = 0;
9095 dgst_pos1 = 3;
9096 dgst_pos2 = 2;
9097 dgst_pos3 = 1;
9098 break;
9099
9100 case 5700: hash_type = HASH_TYPE_SHA256;
9101 salt_type = SALT_TYPE_NONE;
9102 attack_exec = ATTACK_EXEC_ON_GPU;
9103 opts_type = OPTS_TYPE_PT_GENERATE_BE
9104 | OPTS_TYPE_PT_ADD80
9105 | OPTS_TYPE_PT_ADDBITS15;
9106 kern_type = KERN_TYPE_SHA256;
9107 dgst_size = DGST_SIZE_4_8;
9108 parse_func = cisco4_parse_hash;
9109 sort_by_digest = sort_by_digest_4_8;
9110 opti_type = OPTI_TYPE_ZERO_BYTE
9111 | OPTI_TYPE_PRECOMPUTE_INIT
9112 | OPTI_TYPE_PRECOMPUTE_MERKLE
9113 | OPTI_TYPE_SCALAR_MODE
9114 | OPTI_TYPE_EARLY_SKIP
9115 | OPTI_TYPE_NOT_ITERATED
9116 | OPTI_TYPE_NOT_SALTED
9117 | OPTI_TYPE_RAW_HASH;
9118 dgst_pos0 = 3;
9119 dgst_pos1 = 7;
9120 dgst_pos2 = 2;
9121 dgst_pos3 = 6;
9122 break;
9123
9124 case 5800: hash_type = HASH_TYPE_SHA1;
9125 salt_type = SALT_TYPE_INTERN;
9126 attack_exec = ATTACK_EXEC_ON_CPU;
9127 opts_type = OPTS_TYPE_PT_GENERATE_LE // should be OPTS_TYPE_PT_GENERATE_BE
9128 | OPTS_TYPE_ST_ADD80;
9129 kern_type = KERN_TYPE_ANDROIDPIN;
9130 dgst_size = DGST_SIZE_4_5;
9131 parse_func = androidpin_parse_hash;
9132 sort_by_digest = sort_by_digest_4_5;
9133 opti_type = OPTI_TYPE_ZERO_BYTE;
9134 dgst_pos0 = 0;
9135 dgst_pos1 = 1;
9136 dgst_pos2 = 2;
9137 dgst_pos3 = 3;
9138 break;
9139
9140 case 6000: hash_type = HASH_TYPE_RIPEMD160;
9141 salt_type = SALT_TYPE_NONE;
9142 attack_exec = ATTACK_EXEC_ON_GPU;
9143 opts_type = OPTS_TYPE_PT_GENERATE_LE
9144 | OPTS_TYPE_PT_ADD80;
9145 kern_type = KERN_TYPE_RIPEMD160;
9146 dgst_size = DGST_SIZE_4_5;
9147 parse_func = ripemd160_parse_hash;
9148 sort_by_digest = sort_by_digest_4_5;
9149 opti_type = OPTI_TYPE_ZERO_BYTE;
9150 dgst_pos0 = 0;
9151 dgst_pos1 = 1;
9152 dgst_pos2 = 2;
9153 dgst_pos3 = 3;
9154 break;
9155
9156 case 6100: hash_type = HASH_TYPE_WHIRLPOOL;
9157 salt_type = SALT_TYPE_NONE;
9158 attack_exec = ATTACK_EXEC_ON_GPU;
9159 opts_type = OPTS_TYPE_PT_GENERATE_BE
9160 | OPTS_TYPE_PT_ADD80;
9161 kern_type = KERN_TYPE_WHIRLPOOL;
9162 dgst_size = DGST_SIZE_4_16;
9163 parse_func = whirlpool_parse_hash;
9164 sort_by_digest = sort_by_digest_4_16;
9165 opti_type = OPTI_TYPE_ZERO_BYTE;
9166 dgst_pos0 = 0;
9167 dgst_pos1 = 1;
9168 dgst_pos2 = 2;
9169 dgst_pos3 = 3;
9170 break;
9171
9172 case 6211: hash_type = HASH_TYPE_RIPEMD160;
9173 salt_type = SALT_TYPE_EMBEDDED;
9174 attack_exec = ATTACK_EXEC_ON_CPU;
9175 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9176 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
9177 dgst_size = DGST_SIZE_4_5;
9178 parse_func = truecrypt_parse_hash_2k;
9179 sort_by_digest = sort_by_digest_4_5;
9180 opti_type = OPTI_TYPE_ZERO_BYTE;
9181 dgst_pos0 = 0;
9182 dgst_pos1 = 1;
9183 dgst_pos2 = 2;
9184 dgst_pos3 = 3;
9185 break;
9186
9187 case 6212: hash_type = HASH_TYPE_RIPEMD160;
9188 salt_type = SALT_TYPE_EMBEDDED;
9189 attack_exec = ATTACK_EXEC_ON_CPU;
9190 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9191 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
9192 dgst_size = DGST_SIZE_4_5;
9193 parse_func = truecrypt_parse_hash_2k;
9194 sort_by_digest = sort_by_digest_4_5;
9195 opti_type = OPTI_TYPE_ZERO_BYTE;
9196 dgst_pos0 = 0;
9197 dgst_pos1 = 1;
9198 dgst_pos2 = 2;
9199 dgst_pos3 = 3;
9200 break;
9201
9202 case 6213: hash_type = HASH_TYPE_RIPEMD160;
9203 salt_type = SALT_TYPE_EMBEDDED;
9204 attack_exec = ATTACK_EXEC_ON_CPU;
9205 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9206 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
9207 dgst_size = DGST_SIZE_4_5;
9208 parse_func = truecrypt_parse_hash_2k;
9209 sort_by_digest = sort_by_digest_4_5;
9210 opti_type = OPTI_TYPE_ZERO_BYTE;
9211 dgst_pos0 = 0;
9212 dgst_pos1 = 1;
9213 dgst_pos2 = 2;
9214 dgst_pos3 = 3;
9215 break;
9216
9217 case 6221: hash_type = HASH_TYPE_SHA512;
9218 salt_type = SALT_TYPE_EMBEDDED;
9219 attack_exec = ATTACK_EXEC_ON_CPU;
9220 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9221 kern_type = KERN_TYPE_TCSHA512_XTS512;
9222 dgst_size = DGST_SIZE_8_8;
9223 parse_func = truecrypt_parse_hash_1k;
9224 sort_by_digest = sort_by_digest_8_8;
9225 opti_type = OPTI_TYPE_ZERO_BYTE;
9226 dgst_pos0 = 0;
9227 dgst_pos1 = 1;
9228 dgst_pos2 = 2;
9229 dgst_pos3 = 3;
9230 break;
9231
9232 case 6222: hash_type = HASH_TYPE_SHA512;
9233 salt_type = SALT_TYPE_EMBEDDED;
9234 attack_exec = ATTACK_EXEC_ON_CPU;
9235 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9236 kern_type = KERN_TYPE_TCSHA512_XTS1024;
9237 dgst_size = DGST_SIZE_8_8;
9238 parse_func = truecrypt_parse_hash_1k;
9239 sort_by_digest = sort_by_digest_8_8;
9240 opti_type = OPTI_TYPE_ZERO_BYTE;
9241 dgst_pos0 = 0;
9242 dgst_pos1 = 1;
9243 dgst_pos2 = 2;
9244 dgst_pos3 = 3;
9245 break;
9246
9247 case 6223: hash_type = HASH_TYPE_SHA512;
9248 salt_type = SALT_TYPE_EMBEDDED;
9249 attack_exec = ATTACK_EXEC_ON_CPU;
9250 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9251 kern_type = KERN_TYPE_TCSHA512_XTS1536;
9252 dgst_size = DGST_SIZE_8_8;
9253 parse_func = truecrypt_parse_hash_1k;
9254 sort_by_digest = sort_by_digest_8_8;
9255 opti_type = OPTI_TYPE_ZERO_BYTE;
9256 dgst_pos0 = 0;
9257 dgst_pos1 = 1;
9258 dgst_pos2 = 2;
9259 dgst_pos3 = 3;
9260 break;
9261
9262 case 6231: hash_type = HASH_TYPE_WHIRLPOOL;
9263 salt_type = SALT_TYPE_EMBEDDED;
9264 attack_exec = ATTACK_EXEC_ON_CPU;
9265 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9266 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS512;
9267 dgst_size = DGST_SIZE_4_8;
9268 parse_func = truecrypt_parse_hash_1k;
9269 sort_by_digest = sort_by_digest_4_8;
9270 opti_type = OPTI_TYPE_ZERO_BYTE;
9271 dgst_pos0 = 0;
9272 dgst_pos1 = 1;
9273 dgst_pos2 = 2;
9274 dgst_pos3 = 3;
9275 break;
9276
9277 case 6232: hash_type = HASH_TYPE_WHIRLPOOL;
9278 salt_type = SALT_TYPE_EMBEDDED;
9279 attack_exec = ATTACK_EXEC_ON_CPU;
9280 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9281 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1024;
9282 dgst_size = DGST_SIZE_4_8;
9283 parse_func = truecrypt_parse_hash_1k;
9284 sort_by_digest = sort_by_digest_4_8;
9285 opti_type = OPTI_TYPE_ZERO_BYTE;
9286 dgst_pos0 = 0;
9287 dgst_pos1 = 1;
9288 dgst_pos2 = 2;
9289 dgst_pos3 = 3;
9290 break;
9291
9292 case 6233: hash_type = HASH_TYPE_WHIRLPOOL;
9293 salt_type = SALT_TYPE_EMBEDDED;
9294 attack_exec = ATTACK_EXEC_ON_CPU;
9295 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9296 kern_type = KERN_TYPE_TCWHIRLPOOL_XTS1536;
9297 dgst_size = DGST_SIZE_4_8;
9298 parse_func = truecrypt_parse_hash_1k;
9299 sort_by_digest = sort_by_digest_4_8;
9300 opti_type = OPTI_TYPE_ZERO_BYTE;
9301 dgst_pos0 = 0;
9302 dgst_pos1 = 1;
9303 dgst_pos2 = 2;
9304 dgst_pos3 = 3;
9305 break;
9306
9307 case 6241: hash_type = HASH_TYPE_RIPEMD160;
9308 salt_type = SALT_TYPE_EMBEDDED;
9309 attack_exec = ATTACK_EXEC_ON_CPU;
9310 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9311 kern_type = KERN_TYPE_TCRIPEMD160_XTS512;
9312 dgst_size = DGST_SIZE_4_5;
9313 parse_func = truecrypt_parse_hash_1k;
9314 sort_by_digest = sort_by_digest_4_5;
9315 opti_type = OPTI_TYPE_ZERO_BYTE;
9316 dgst_pos0 = 0;
9317 dgst_pos1 = 1;
9318 dgst_pos2 = 2;
9319 dgst_pos3 = 3;
9320 break;
9321
9322 case 6242: hash_type = HASH_TYPE_RIPEMD160;
9323 salt_type = SALT_TYPE_EMBEDDED;
9324 attack_exec = ATTACK_EXEC_ON_CPU;
9325 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9326 kern_type = KERN_TYPE_TCRIPEMD160_XTS1024;
9327 dgst_size = DGST_SIZE_4_5;
9328 parse_func = truecrypt_parse_hash_1k;
9329 sort_by_digest = sort_by_digest_4_5;
9330 opti_type = OPTI_TYPE_ZERO_BYTE;
9331 dgst_pos0 = 0;
9332 dgst_pos1 = 1;
9333 dgst_pos2 = 2;
9334 dgst_pos3 = 3;
9335 break;
9336
9337 case 6243: hash_type = HASH_TYPE_RIPEMD160;
9338 salt_type = SALT_TYPE_EMBEDDED;
9339 attack_exec = ATTACK_EXEC_ON_CPU;
9340 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9341 kern_type = KERN_TYPE_TCRIPEMD160_XTS1536;
9342 dgst_size = DGST_SIZE_4_5;
9343 parse_func = truecrypt_parse_hash_1k;
9344 sort_by_digest = sort_by_digest_4_5;
9345 opti_type = OPTI_TYPE_ZERO_BYTE;
9346 dgst_pos0 = 0;
9347 dgst_pos1 = 1;
9348 dgst_pos2 = 2;
9349 dgst_pos3 = 3;
9350 break;
9351
9352 case 6300: hash_type = HASH_TYPE_MD5;
9353 salt_type = SALT_TYPE_EMBEDDED;
9354 attack_exec = ATTACK_EXEC_ON_CPU;
9355 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9356 kern_type = KERN_TYPE_MD5AIX;
9357 dgst_size = DGST_SIZE_4_4;
9358 parse_func = md5aix_parse_hash;
9359 sort_by_digest = sort_by_digest_4_4;
9360 opti_type = OPTI_TYPE_ZERO_BYTE;
9361 dgst_pos0 = 0;
9362 dgst_pos1 = 1;
9363 dgst_pos2 = 2;
9364 dgst_pos3 = 3;
9365 break;
9366
9367 case 6400: hash_type = HASH_TYPE_SHA256;
9368 salt_type = SALT_TYPE_EMBEDDED;
9369 attack_exec = ATTACK_EXEC_ON_CPU;
9370 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9371 kern_type = KERN_TYPE_SHA256AIX;
9372 dgst_size = DGST_SIZE_4_8;
9373 parse_func = sha256aix_parse_hash;
9374 sort_by_digest = sort_by_digest_4_8;
9375 opti_type = OPTI_TYPE_ZERO_BYTE;
9376 dgst_pos0 = 0;
9377 dgst_pos1 = 1;
9378 dgst_pos2 = 2;
9379 dgst_pos3 = 3;
9380 break;
9381
9382 case 6500: hash_type = HASH_TYPE_SHA512;
9383 salt_type = SALT_TYPE_EMBEDDED;
9384 attack_exec = ATTACK_EXEC_ON_CPU;
9385 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9386 kern_type = KERN_TYPE_SHA512AIX;
9387 dgst_size = DGST_SIZE_8_8;
9388 parse_func = sha512aix_parse_hash;
9389 sort_by_digest = sort_by_digest_8_8;
9390 opti_type = OPTI_TYPE_ZERO_BYTE;
9391 dgst_pos0 = 0;
9392 dgst_pos1 = 1;
9393 dgst_pos2 = 2;
9394 dgst_pos3 = 3;
9395 break;
9396
9397 case 6600: hash_type = HASH_TYPE_AES;
9398 salt_type = SALT_TYPE_EMBEDDED;
9399 attack_exec = ATTACK_EXEC_ON_CPU;
9400 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9401 kern_type = KERN_TYPE_AGILEKEY;
9402 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
9403 parse_func = agilekey_parse_hash;
9404 sort_by_digest = sort_by_digest_4_5;
9405 opti_type = OPTI_TYPE_ZERO_BYTE;
9406 dgst_pos0 = 0;
9407 dgst_pos1 = 1;
9408 dgst_pos2 = 2;
9409 dgst_pos3 = 3;
9410 break;
9411
9412 case 6700: hash_type = HASH_TYPE_SHA1;
9413 salt_type = SALT_TYPE_EMBEDDED;
9414 attack_exec = ATTACK_EXEC_ON_CPU;
9415 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9416 kern_type = KERN_TYPE_SHA1AIX;
9417 dgst_size = DGST_SIZE_4_5;
9418 parse_func = sha1aix_parse_hash;
9419 sort_by_digest = sort_by_digest_4_5;
9420 opti_type = OPTI_TYPE_ZERO_BYTE;
9421 dgst_pos0 = 0;
9422 dgst_pos1 = 1;
9423 dgst_pos2 = 2;
9424 dgst_pos3 = 3;
9425 break;
9426
9427 case 6800: hash_type = HASH_TYPE_AES;
9428 salt_type = SALT_TYPE_EMBEDDED;
9429 attack_exec = ATTACK_EXEC_ON_CPU;
9430 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9431 kern_type = KERN_TYPE_LASTPASS;
9432 dgst_size = DGST_SIZE_4_8; // because kernel uses _SHA256_
9433 parse_func = lastpass_parse_hash;
9434 sort_by_digest = sort_by_digest_4_8;
9435 opti_type = OPTI_TYPE_ZERO_BYTE;
9436 dgst_pos0 = 0;
9437 dgst_pos1 = 1;
9438 dgst_pos2 = 2;
9439 dgst_pos3 = 3;
9440 break;
9441
9442 case 6900: hash_type = HASH_TYPE_GOST;
9443 salt_type = SALT_TYPE_NONE;
9444 attack_exec = ATTACK_EXEC_ON_GPU;
9445 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9446 kern_type = KERN_TYPE_GOST;
9447 dgst_size = DGST_SIZE_4_8;
9448 parse_func = gost_parse_hash;
9449 sort_by_digest = sort_by_digest_4_8;
9450 opti_type = OPTI_TYPE_ZERO_BYTE;
9451 dgst_pos0 = 0;
9452 dgst_pos1 = 1;
9453 dgst_pos2 = 2;
9454 dgst_pos3 = 3;
9455 break;
9456
9457 case 7100: hash_type = HASH_TYPE_SHA512;
9458 salt_type = SALT_TYPE_EMBEDDED;
9459 attack_exec = ATTACK_EXEC_ON_CPU;
9460 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9461 kern_type = KERN_TYPE_PBKDF2_SHA512;
9462 dgst_size = DGST_SIZE_8_16;
9463 parse_func = sha512osx_parse_hash;
9464 sort_by_digest = sort_by_digest_8_16;
9465 opti_type = OPTI_TYPE_ZERO_BYTE;
9466 dgst_pos0 = 0;
9467 dgst_pos1 = 1;
9468 dgst_pos2 = 2;
9469 dgst_pos3 = 3;
9470 break;
9471
9472 case 7200: hash_type = HASH_TYPE_SHA512;
9473 salt_type = SALT_TYPE_EMBEDDED;
9474 attack_exec = ATTACK_EXEC_ON_CPU;
9475 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9476 kern_type = KERN_TYPE_PBKDF2_SHA512;
9477 dgst_size = DGST_SIZE_8_16;
9478 parse_func = sha512grub_parse_hash;
9479 sort_by_digest = sort_by_digest_8_16;
9480 opti_type = OPTI_TYPE_ZERO_BYTE;
9481 dgst_pos0 = 0;
9482 dgst_pos1 = 1;
9483 dgst_pos2 = 2;
9484 dgst_pos3 = 3;
9485 break;
9486
9487 case 7300: hash_type = HASH_TYPE_SHA1;
9488 salt_type = SALT_TYPE_EMBEDDED;
9489 attack_exec = ATTACK_EXEC_ON_GPU;
9490 opts_type = OPTS_TYPE_PT_GENERATE_BE
9491 | OPTS_TYPE_ST_ADD80
9492 | OPTS_TYPE_ST_ADDBITS15;
9493 kern_type = KERN_TYPE_RAKP;
9494 dgst_size = DGST_SIZE_4_5;
9495 parse_func = rakp_parse_hash;
9496 sort_by_digest = sort_by_digest_4_5;
9497 opti_type = OPTI_TYPE_ZERO_BYTE
9498 | OPTI_TYPE_NOT_ITERATED;
9499 dgst_pos0 = 3;
9500 dgst_pos1 = 4;
9501 dgst_pos2 = 2;
9502 dgst_pos3 = 1;
9503 break;
9504
9505 case 7400: hash_type = HASH_TYPE_SHA256;
9506 salt_type = SALT_TYPE_EMBEDDED;
9507 attack_exec = ATTACK_EXEC_ON_CPU;
9508 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9509 kern_type = KERN_TYPE_SHA256CRYPT;
9510 dgst_size = DGST_SIZE_4_8;
9511 parse_func = sha256crypt_parse_hash;
9512 sort_by_digest = sort_by_digest_4_8;
9513 opti_type = OPTI_TYPE_ZERO_BYTE;
9514 dgst_pos0 = 0;
9515 dgst_pos1 = 1;
9516 dgst_pos2 = 2;
9517 dgst_pos3 = 3;
9518 break;
9519
9520 case 7500: hash_type = HASH_TYPE_KRB5PA;
9521 salt_type = SALT_TYPE_EMBEDDED;
9522 attack_exec = ATTACK_EXEC_ON_GPU;
9523 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9524 kern_type = KERN_TYPE_KRB5PA;
9525 dgst_size = DGST_SIZE_4_4;
9526 parse_func = krb5pa_parse_hash;
9527 sort_by_digest = sort_by_digest_4_4;
9528 opti_type = OPTI_TYPE_ZERO_BYTE
9529 | OPTI_TYPE_NOT_ITERATED;
9530 dgst_pos0 = 3;
9531 dgst_pos1 = 7;
9532 dgst_pos2 = 2;
9533 dgst_pos3 = 6;
9534 break;
9535
9536 case 7600: hash_type = HASH_TYPE_SHA1;
9537 salt_type = SALT_TYPE_INTERN;
9538 attack_exec = ATTACK_EXEC_ON_GPU;
9539 opts_type = OPTS_TYPE_PT_GENERATE_BE
9540 | OPTS_TYPE_PT_ADD80
9541 | OPTS_TYPE_PT_ADDBITS15;
9542 kern_type = KERN_TYPE_SHA1_SLT_SHA1_PW;
9543 dgst_size = DGST_SIZE_4_5;
9544 parse_func = redmine_parse_hash;
9545 sort_by_digest = sort_by_digest_4_5;
9546 opti_type = OPTI_TYPE_ZERO_BYTE
9547 | OPTI_TYPE_PRECOMPUTE_INIT
9548 | OPTI_TYPE_EARLY_SKIP
9549 | OPTI_TYPE_NOT_ITERATED
9550 | OPTI_TYPE_PREPENDED_SALT;
9551 dgst_pos0 = 3;
9552 dgst_pos1 = 4;
9553 dgst_pos2 = 2;
9554 dgst_pos3 = 1;
9555 break;
9556
9557 case 7700: hash_type = HASH_TYPE_SAPB;
9558 salt_type = SALT_TYPE_EMBEDDED;
9559 attack_exec = ATTACK_EXEC_ON_GPU;
9560 opts_type = OPTS_TYPE_PT_GENERATE_LE
9561 | OPTS_TYPE_PT_UPPER
9562 | OPTS_TYPE_ST_UPPER;
9563 kern_type = KERN_TYPE_SAPB;
9564 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9565 parse_func = sapb_parse_hash;
9566 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9567 opti_type = OPTI_TYPE_ZERO_BYTE
9568 | OPTI_TYPE_PRECOMPUTE_INIT
9569 | OPTI_TYPE_NOT_ITERATED;
9570 dgst_pos0 = 0;
9571 dgst_pos1 = 1;
9572 dgst_pos2 = 2;
9573 dgst_pos3 = 3;
9574 break;
9575
9576 case 7800: hash_type = HASH_TYPE_SAPG;
9577 salt_type = SALT_TYPE_EMBEDDED;
9578 attack_exec = ATTACK_EXEC_ON_GPU;
9579 opts_type = OPTS_TYPE_PT_GENERATE_BE
9580 | OPTS_TYPE_ST_ADD80
9581 | OPTS_TYPE_ST_UPPER;
9582 kern_type = KERN_TYPE_SAPG;
9583 dgst_size = DGST_SIZE_4_5;
9584 parse_func = sapg_parse_hash;
9585 sort_by_digest = sort_by_digest_4_5;
9586 opti_type = OPTI_TYPE_ZERO_BYTE
9587 | OPTI_TYPE_PRECOMPUTE_INIT
9588 | OPTI_TYPE_NOT_ITERATED;
9589 dgst_pos0 = 3;
9590 dgst_pos1 = 4;
9591 dgst_pos2 = 2;
9592 dgst_pos3 = 1;
9593 break;
9594
9595 case 7900: hash_type = HASH_TYPE_SHA512;
9596 salt_type = SALT_TYPE_EMBEDDED;
9597 attack_exec = ATTACK_EXEC_ON_CPU;
9598 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9599 kern_type = KERN_TYPE_DRUPAL7;
9600 dgst_size = DGST_SIZE_8_8;
9601 parse_func = drupal7_parse_hash;
9602 sort_by_digest = sort_by_digest_8_8;
9603 opti_type = OPTI_TYPE_ZERO_BYTE;
9604 dgst_pos0 = 0;
9605 dgst_pos1 = 1;
9606 dgst_pos2 = 2;
9607 dgst_pos3 = 3;
9608 break;
9609
9610 case 8000: hash_type = HASH_TYPE_SHA256;
9611 salt_type = SALT_TYPE_EMBEDDED;
9612 attack_exec = ATTACK_EXEC_ON_GPU;
9613 opts_type = OPTS_TYPE_PT_GENERATE_BE
9614 | OPTS_TYPE_PT_UNICODE
9615 | OPTS_TYPE_ST_ADD80
9616 | OPTS_TYPE_ST_HEX;
9617 kern_type = KERN_TYPE_SYBASEASE;
9618 dgst_size = DGST_SIZE_4_8;
9619 parse_func = sybasease_parse_hash;
9620 sort_by_digest = sort_by_digest_4_8;
9621 opti_type = OPTI_TYPE_ZERO_BYTE
9622 | OPTI_TYPE_PRECOMPUTE_INIT
9623 | OPTI_TYPE_SCALAR_MODE
9624 | OPTI_TYPE_EARLY_SKIP
9625 | OPTI_TYPE_NOT_ITERATED
9626 | OPTI_TYPE_RAW_HASH;
9627 dgst_pos0 = 3;
9628 dgst_pos1 = 7;
9629 dgst_pos2 = 2;
9630 dgst_pos3 = 6;
9631 break;
9632
9633 case 8100: hash_type = HASH_TYPE_SHA1;
9634 salt_type = SALT_TYPE_EMBEDDED;
9635 attack_exec = ATTACK_EXEC_ON_GPU;
9636 opts_type = OPTS_TYPE_PT_GENERATE_BE;
9637 kern_type = KERN_TYPE_NETSCALER;
9638 dgst_size = DGST_SIZE_4_5;
9639 parse_func = netscaler_parse_hash;
9640 sort_by_digest = sort_by_digest_4_5;
9641 opti_type = OPTI_TYPE_ZERO_BYTE
9642 | OPTI_TYPE_PRECOMPUTE_INIT
9643 | OPTI_TYPE_PRECOMPUTE_MERKLE
9644 | OPTI_TYPE_EARLY_SKIP
9645 | OPTI_TYPE_NOT_ITERATED
9646 | OPTI_TYPE_PREPENDED_SALT
9647 | OPTI_TYPE_RAW_HASH;
9648 dgst_pos0 = 3;
9649 dgst_pos1 = 4;
9650 dgst_pos2 = 2;
9651 dgst_pos3 = 1;
9652 break;
9653
9654 case 8200: hash_type = HASH_TYPE_SHA256;
9655 salt_type = SALT_TYPE_EMBEDDED;
9656 attack_exec = ATTACK_EXEC_ON_CPU;
9657 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9658 kern_type = KERN_TYPE_CLOUDKEY;
9659 dgst_size = DGST_SIZE_4_8;
9660 parse_func = cloudkey_parse_hash;
9661 sort_by_digest = sort_by_digest_4_8;
9662 opti_type = OPTI_TYPE_ZERO_BYTE;
9663 dgst_pos0 = 0;
9664 dgst_pos1 = 1;
9665 dgst_pos2 = 2;
9666 dgst_pos3 = 3;
9667 break;
9668
9669 case 8300: hash_type = HASH_TYPE_SHA1;
9670 salt_type = SALT_TYPE_EMBEDDED;
9671 attack_exec = ATTACK_EXEC_ON_GPU;
9672 opts_type = OPTS_TYPE_PT_GENERATE_LE
9673 | OPTS_TYPE_ST_HEX
9674 | OPTS_TYPE_ST_ADD80;
9675 kern_type = KERN_TYPE_NSEC3;
9676 dgst_size = DGST_SIZE_4_5;
9677 parse_func = nsec3_parse_hash;
9678 sort_by_digest = sort_by_digest_4_5;
9679 opti_type = OPTI_TYPE_ZERO_BYTE;
9680 dgst_pos0 = 3;
9681 dgst_pos1 = 4;
9682 dgst_pos2 = 2;
9683 dgst_pos3 = 1;
9684 break;
9685
9686 case 8400: hash_type = HASH_TYPE_SHA1;
9687 salt_type = SALT_TYPE_INTERN;
9688 attack_exec = ATTACK_EXEC_ON_GPU;
9689 opts_type = OPTS_TYPE_PT_GENERATE_BE
9690 | OPTS_TYPE_PT_ADD80
9691 | OPTS_TYPE_PT_ADDBITS15;
9692 kern_type = KERN_TYPE_WBB3;
9693 dgst_size = DGST_SIZE_4_5;
9694 parse_func = wbb3_parse_hash;
9695 sort_by_digest = sort_by_digest_4_5;
9696 opti_type = OPTI_TYPE_ZERO_BYTE
9697 | OPTI_TYPE_PRECOMPUTE_INIT
9698 | OPTI_TYPE_NOT_ITERATED;
9699 dgst_pos0 = 3;
9700 dgst_pos1 = 4;
9701 dgst_pos2 = 2;
9702 dgst_pos3 = 1;
9703 break;
9704
9705 case 8500: hash_type = HASH_TYPE_DESRACF;
9706 salt_type = SALT_TYPE_EMBEDDED;
9707 attack_exec = ATTACK_EXEC_ON_GPU;
9708 opts_type = OPTS_TYPE_PT_GENERATE_LE
9709 | OPTS_TYPE_ST_UPPER;
9710 kern_type = KERN_TYPE_RACF;
9711 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9712 parse_func = racf_parse_hash;
9713 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9714 opti_type = OPTI_TYPE_ZERO_BYTE
9715 | OPTI_TYPE_SCALAR_MODE
9716 | OPTI_TYPE_PRECOMPUTE_PERMUT;
9717 dgst_pos0 = 0;
9718 dgst_pos1 = 1;
9719 dgst_pos2 = 2;
9720 dgst_pos3 = 3;
9721 break;
9722
9723 case 8600: hash_type = HASH_TYPE_LOTUS5;
9724 salt_type = SALT_TYPE_NONE;
9725 attack_exec = ATTACK_EXEC_ON_GPU;
9726 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9727 kern_type = KERN_TYPE_LOTUS5;
9728 dgst_size = DGST_SIZE_4_4;
9729 parse_func = lotus5_parse_hash;
9730 sort_by_digest = sort_by_digest_4_4;
9731 opti_type = OPTI_TYPE_SCALAR_MODE
9732 | OPTI_TYPE_EARLY_SKIP
9733 | OPTI_TYPE_NOT_ITERATED
9734 | OPTI_TYPE_NOT_SALTED
9735 | OPTI_TYPE_RAW_HASH;
9736 dgst_pos0 = 0;
9737 dgst_pos1 = 1;
9738 dgst_pos2 = 2;
9739 dgst_pos3 = 3;
9740 break;
9741
9742 case 8700: hash_type = HASH_TYPE_LOTUS6;
9743 salt_type = SALT_TYPE_EMBEDDED;
9744 attack_exec = ATTACK_EXEC_ON_GPU;
9745 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9746 kern_type = KERN_TYPE_LOTUS6;
9747 dgst_size = DGST_SIZE_4_4;
9748 parse_func = lotus6_parse_hash;
9749 sort_by_digest = sort_by_digest_4_4;
9750 opti_type = OPTI_TYPE_SCALAR_MODE
9751 | OPTI_TYPE_EARLY_SKIP
9752 | OPTI_TYPE_NOT_ITERATED
9753 | OPTI_TYPE_RAW_HASH;
9754 dgst_pos0 = 0;
9755 dgst_pos1 = 1;
9756 dgst_pos2 = 2;
9757 dgst_pos3 = 3;
9758 break;
9759
9760 case 8800: hash_type = HASH_TYPE_ANDROIDFDE;
9761 salt_type = SALT_TYPE_EMBEDDED;
9762 attack_exec = ATTACK_EXEC_ON_CPU;
9763 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9764 kern_type = KERN_TYPE_ANDROIDFDE;
9765 dgst_size = DGST_SIZE_4_4;
9766 parse_func = androidfde_parse_hash;
9767 sort_by_digest = sort_by_digest_4_4;
9768 opti_type = OPTI_TYPE_ZERO_BYTE;
9769 dgst_pos0 = 0;
9770 dgst_pos1 = 1;
9771 dgst_pos2 = 2;
9772 dgst_pos3 = 3;
9773 break;
9774
9775 case 8900: hash_type = HASH_TYPE_SCRYPT;
9776 salt_type = SALT_TYPE_EMBEDDED;
9777 attack_exec = ATTACK_EXEC_ON_CPU;
9778 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9779 kern_type = KERN_TYPE_SCRYPT;
9780 dgst_size = DGST_SIZE_4_8;
9781 parse_func = scrypt_parse_hash;
9782 sort_by_digest = sort_by_digest_4_8;
9783 opti_type = OPTI_TYPE_ZERO_BYTE;
9784 dgst_pos0 = 0;
9785 dgst_pos1 = 1;
9786 dgst_pos2 = 2;
9787 dgst_pos3 = 3;
9788 break;
9789
9790 case 9000: hash_type = HASH_TYPE_SHA1;
9791 salt_type = SALT_TYPE_EMBEDDED;
9792 attack_exec = ATTACK_EXEC_ON_CPU;
9793 opts_type = OPTS_TYPE_PT_GENERATE_LE
9794 | OPTS_TYPE_ST_GENERATE_LE;
9795 kern_type = KERN_TYPE_PSAFE2;
9796 dgst_size = DGST_SIZE_4_5;
9797 parse_func = psafe2_parse_hash;
9798 sort_by_digest = sort_by_digest_4_5;
9799 opti_type = OPTI_TYPE_ZERO_BYTE;
9800 dgst_pos0 = 0;
9801 dgst_pos1 = 1;
9802 dgst_pos2 = 2;
9803 dgst_pos3 = 3;
9804 break;
9805
9806 case 9100: hash_type = HASH_TYPE_LOTUS8;
9807 salt_type = SALT_TYPE_EMBEDDED;
9808 attack_exec = ATTACK_EXEC_ON_CPU;
9809 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9810 kern_type = KERN_TYPE_LOTUS8;
9811 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
9812 parse_func = lotus8_parse_hash;
9813 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
9814 opti_type = OPTI_TYPE_ZERO_BYTE;
9815 dgst_pos0 = 0;
9816 dgst_pos1 = 1;
9817 dgst_pos2 = 2;
9818 dgst_pos3 = 3;
9819 break;
9820
9821 case 9200: hash_type = HASH_TYPE_SHA256;
9822 salt_type = SALT_TYPE_EMBEDDED;
9823 attack_exec = ATTACK_EXEC_ON_CPU;
9824 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
9825 kern_type = KERN_TYPE_PBKDF2_SHA256;
9826 dgst_size = DGST_SIZE_4_32;
9827 parse_func = cisco8_parse_hash;
9828 sort_by_digest = sort_by_digest_4_32;
9829 opti_type = OPTI_TYPE_ZERO_BYTE;
9830 dgst_pos0 = 0;
9831 dgst_pos1 = 1;
9832 dgst_pos2 = 2;
9833 dgst_pos3 = 3;
9834 break;
9835
9836 case 9300: hash_type = HASH_TYPE_SCRYPT;
9837 salt_type = SALT_TYPE_EMBEDDED;
9838 attack_exec = ATTACK_EXEC_ON_CPU;
9839 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9840 kern_type = KERN_TYPE_SCRYPT;
9841 dgst_size = DGST_SIZE_4_8;
9842 parse_func = cisco9_parse_hash;
9843 sort_by_digest = sort_by_digest_4_8;
9844 opti_type = OPTI_TYPE_ZERO_BYTE;
9845 dgst_pos0 = 0;
9846 dgst_pos1 = 1;
9847 dgst_pos2 = 2;
9848 dgst_pos3 = 3;
9849 break;
9850
9851 case 9400: hash_type = HASH_TYPE_OFFICE2007;
9852 salt_type = SALT_TYPE_EMBEDDED;
9853 attack_exec = ATTACK_EXEC_ON_CPU;
9854 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9855 kern_type = KERN_TYPE_OFFICE2007;
9856 dgst_size = DGST_SIZE_4_4;
9857 parse_func = office2007_parse_hash;
9858 sort_by_digest = sort_by_digest_4_4;
9859 opti_type = OPTI_TYPE_ZERO_BYTE;
9860 dgst_pos0 = 0;
9861 dgst_pos1 = 1;
9862 dgst_pos2 = 2;
9863 dgst_pos3 = 3;
9864 break;
9865
9866 case 9500: hash_type = HASH_TYPE_OFFICE2010;
9867 salt_type = SALT_TYPE_EMBEDDED;
9868 attack_exec = ATTACK_EXEC_ON_CPU;
9869 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9870 kern_type = KERN_TYPE_OFFICE2010;
9871 dgst_size = DGST_SIZE_4_4;
9872 parse_func = office2010_parse_hash;
9873 sort_by_digest = sort_by_digest_4_4;
9874 opti_type = OPTI_TYPE_ZERO_BYTE;
9875 dgst_pos0 = 0;
9876 dgst_pos1 = 1;
9877 dgst_pos2 = 2;
9878 dgst_pos3 = 3;
9879 break;
9880
9881 case 9600: hash_type = HASH_TYPE_OFFICE2013;
9882 salt_type = SALT_TYPE_EMBEDDED;
9883 attack_exec = ATTACK_EXEC_ON_CPU;
9884 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9885 kern_type = KERN_TYPE_OFFICE2013;
9886 dgst_size = DGST_SIZE_4_4;
9887 parse_func = office2013_parse_hash;
9888 sort_by_digest = sort_by_digest_4_4;
9889 opti_type = OPTI_TYPE_ZERO_BYTE;
9890 dgst_pos0 = 0;
9891 dgst_pos1 = 1;
9892 dgst_pos2 = 2;
9893 dgst_pos3 = 3;
9894 break;
9895
9896 case 9700: hash_type = HASH_TYPE_OLDOFFICE01;
9897 salt_type = SALT_TYPE_EMBEDDED;
9898 attack_exec = ATTACK_EXEC_ON_GPU;
9899 opts_type = OPTS_TYPE_PT_GENERATE_LE
9900 | OPTS_TYPE_PT_ADD80
9901 | OPTS_TYPE_PT_UNICODE;
9902 kern_type = KERN_TYPE_OLDOFFICE01;
9903 dgst_size = DGST_SIZE_4_4;
9904 parse_func = oldoffice01_parse_hash;
9905 sort_by_digest = sort_by_digest_4_4;
9906 opti_type = OPTI_TYPE_ZERO_BYTE
9907 | OPTI_TYPE_PRECOMPUTE_INIT
9908 | OPTI_TYPE_NOT_ITERATED;
9909 dgst_pos0 = 0;
9910 dgst_pos1 = 1;
9911 dgst_pos2 = 2;
9912 dgst_pos3 = 3;
9913 break;
9914
9915 case 9710: hash_type = HASH_TYPE_OLDOFFICE01;
9916 salt_type = SALT_TYPE_EMBEDDED;
9917 attack_exec = ATTACK_EXEC_ON_GPU;
9918 opts_type = OPTS_TYPE_PT_GENERATE_LE
9919 | OPTS_TYPE_PT_ADD80;
9920 kern_type = KERN_TYPE_OLDOFFICE01CM1;
9921 dgst_size = DGST_SIZE_4_4;
9922 parse_func = oldoffice01cm1_parse_hash;
9923 sort_by_digest = sort_by_digest_4_4;
9924 opti_type = OPTI_TYPE_ZERO_BYTE
9925 | OPTI_TYPE_PRECOMPUTE_INIT
9926 | OPTI_TYPE_NOT_ITERATED;
9927 dgst_pos0 = 0;
9928 dgst_pos1 = 1;
9929 dgst_pos2 = 2;
9930 dgst_pos3 = 3;
9931 break;
9932
9933 case 9720: hash_type = HASH_TYPE_OLDOFFICE01;
9934 salt_type = SALT_TYPE_EMBEDDED;
9935 attack_exec = ATTACK_EXEC_ON_GPU;
9936 opts_type = OPTS_TYPE_PT_GENERATE_LE
9937 | OPTS_TYPE_PT_ADD80
9938 | OPTS_TYPE_PT_UNICODE
9939 | OPTS_TYPE_PT_NEVERCRACK;
9940 kern_type = KERN_TYPE_OLDOFFICE01CM2;
9941 dgst_size = DGST_SIZE_4_4;
9942 parse_func = oldoffice01cm2_parse_hash;
9943 sort_by_digest = sort_by_digest_4_4;
9944 opti_type = OPTI_TYPE_ZERO_BYTE
9945 | OPTI_TYPE_PRECOMPUTE_INIT
9946 | OPTI_TYPE_NOT_ITERATED;
9947 dgst_pos0 = 0;
9948 dgst_pos1 = 1;
9949 dgst_pos2 = 2;
9950 dgst_pos3 = 3;
9951 break;
9952
9953 case 9800: hash_type = HASH_TYPE_OLDOFFICE34;
9954 salt_type = SALT_TYPE_EMBEDDED;
9955 attack_exec = ATTACK_EXEC_ON_GPU;
9956 opts_type = OPTS_TYPE_PT_GENERATE_BE
9957 | OPTS_TYPE_PT_ADD80
9958 | OPTS_TYPE_PT_UNICODE;
9959 kern_type = KERN_TYPE_OLDOFFICE34;
9960 dgst_size = DGST_SIZE_4_4;
9961 parse_func = oldoffice34_parse_hash;
9962 sort_by_digest = sort_by_digest_4_4;
9963 opti_type = OPTI_TYPE_ZERO_BYTE
9964 | OPTI_TYPE_PRECOMPUTE_INIT
9965 | OPTI_TYPE_NOT_ITERATED;
9966 dgst_pos0 = 0;
9967 dgst_pos1 = 1;
9968 dgst_pos2 = 2;
9969 dgst_pos3 = 3;
9970 break;
9971
9972 case 9810: hash_type = HASH_TYPE_OLDOFFICE34;
9973 salt_type = SALT_TYPE_EMBEDDED;
9974 attack_exec = ATTACK_EXEC_ON_GPU;
9975 opts_type = OPTS_TYPE_PT_GENERATE_LE;
9976 kern_type = KERN_TYPE_OLDOFFICE34CM1;
9977 dgst_size = DGST_SIZE_4_4;
9978 parse_func = oldoffice34cm1_parse_hash;
9979 sort_by_digest = sort_by_digest_4_4;
9980 opti_type = OPTI_TYPE_ZERO_BYTE
9981 | OPTI_TYPE_PRECOMPUTE_INIT
9982 | OPTI_TYPE_NOT_ITERATED;
9983 dgst_pos0 = 0;
9984 dgst_pos1 = 1;
9985 dgst_pos2 = 2;
9986 dgst_pos3 = 3;
9987 break;
9988
9989 case 9820: hash_type = HASH_TYPE_OLDOFFICE34;
9990 salt_type = SALT_TYPE_EMBEDDED;
9991 attack_exec = ATTACK_EXEC_ON_GPU;
9992 opts_type = OPTS_TYPE_PT_GENERATE_BE
9993 | OPTS_TYPE_PT_ADD80
9994 | OPTS_TYPE_PT_UNICODE
9995 | OPTS_TYPE_PT_NEVERCRACK;
9996 kern_type = KERN_TYPE_OLDOFFICE34CM2;
9997 dgst_size = DGST_SIZE_4_4;
9998 parse_func = oldoffice34cm2_parse_hash;
9999 sort_by_digest = sort_by_digest_4_4;
10000 opti_type = OPTI_TYPE_ZERO_BYTE
10001 | OPTI_TYPE_PRECOMPUTE_INIT
10002 | OPTI_TYPE_NOT_ITERATED;
10003 dgst_pos0 = 0;
10004 dgst_pos1 = 1;
10005 dgst_pos2 = 2;
10006 dgst_pos3 = 3;
10007 break;
10008
10009 case 9900: hash_type = HASH_TYPE_MD5;
10010 salt_type = SALT_TYPE_NONE;
10011 attack_exec = ATTACK_EXEC_ON_GPU;
10012 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10013 kern_type = KERN_TYPE_RADMIN2;
10014 dgst_size = DGST_SIZE_4_4;
10015 parse_func = radmin2_parse_hash;
10016 sort_by_digest = sort_by_digest_4_4;
10017 opti_type = OPTI_TYPE_ZERO_BYTE
10018 | OPTI_TYPE_PRECOMPUTE_INIT
10019 | OPTI_TYPE_SCALAR_MODE
10020 | OPTI_TYPE_EARLY_SKIP
10021 | OPTI_TYPE_NOT_ITERATED
10022 | OPTI_TYPE_NOT_SALTED;
10023 dgst_pos0 = 0;
10024 dgst_pos1 = 3;
10025 dgst_pos2 = 2;
10026 dgst_pos3 = 1;
10027 break;
10028
10029 case 10000: hash_type = HASH_TYPE_SHA256;
10030 salt_type = SALT_TYPE_EMBEDDED;
10031 attack_exec = ATTACK_EXEC_ON_CPU;
10032 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
10033 kern_type = KERN_TYPE_PBKDF2_SHA256;
10034 dgst_size = DGST_SIZE_4_32;
10035 parse_func = djangopbkdf2_parse_hash;
10036 sort_by_digest = sort_by_digest_4_32;
10037 opti_type = OPTI_TYPE_ZERO_BYTE;
10038 dgst_pos0 = 0;
10039 dgst_pos1 = 1;
10040 dgst_pos2 = 2;
10041 dgst_pos3 = 3;
10042 break;
10043
10044 case 10100: hash_type = HASH_TYPE_SIPHASH;
10045 salt_type = SALT_TYPE_EMBEDDED;
10046 attack_exec = ATTACK_EXEC_ON_GPU;
10047 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10048 kern_type = KERN_TYPE_SIPHASH;
10049 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10050 parse_func = siphash_parse_hash;
10051 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10052 opti_type = OPTI_TYPE_ZERO_BYTE
10053 | OPTI_TYPE_SCALAR_MODE
10054 | OPTI_TYPE_NOT_ITERATED
10055 | OPTI_TYPE_RAW_HASH;
10056 dgst_pos0 = 0;
10057 dgst_pos1 = 1;
10058 dgst_pos2 = 2;
10059 dgst_pos3 = 3;
10060 break;
10061
10062 case 10200: hash_type = HASH_TYPE_MD5;
10063 salt_type = SALT_TYPE_EMBEDDED;
10064 attack_exec = ATTACK_EXEC_ON_GPU;
10065 opts_type = OPTS_TYPE_PT_GENERATE_LE
10066 | OPTS_TYPE_ST_ADD80
10067 | OPTS_TYPE_ST_ADDBITS14;
10068 kern_type = KERN_TYPE_HMACMD5_PW;
10069 dgst_size = DGST_SIZE_4_4;
10070 parse_func = crammd5_parse_hash;
10071 sort_by_digest = sort_by_digest_4_4;
10072 opti_type = OPTI_TYPE_ZERO_BYTE
10073 | OPTI_TYPE_NOT_ITERATED;
10074 dgst_pos0 = 0;
10075 dgst_pos1 = 3;
10076 dgst_pos2 = 2;
10077 dgst_pos3 = 1;
10078 break;
10079
10080 case 10300: hash_type = HASH_TYPE_SHA1;
10081 salt_type = SALT_TYPE_EMBEDDED;
10082 attack_exec = ATTACK_EXEC_ON_CPU;
10083 opts_type = OPTS_TYPE_PT_GENERATE_LE; // should be OPTS_TYPE_PT_GENERATE_BE
10084 kern_type = KERN_TYPE_SAPH_SHA1;
10085 dgst_size = DGST_SIZE_4_5;
10086 parse_func = saph_sha1_parse_hash;
10087 sort_by_digest = sort_by_digest_4_5;
10088 opti_type = OPTI_TYPE_ZERO_BYTE;
10089 dgst_pos0 = 0;
10090 dgst_pos1 = 1;
10091 dgst_pos2 = 2;
10092 dgst_pos3 = 3;
10093 break;
10094
10095 case 10400: hash_type = HASH_TYPE_PDFU16;
10096 salt_type = SALT_TYPE_EMBEDDED;
10097 attack_exec = ATTACK_EXEC_ON_GPU;
10098 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10099 kern_type = KERN_TYPE_PDF11;
10100 dgst_size = DGST_SIZE_4_4;
10101 parse_func = pdf11_parse_hash;
10102 sort_by_digest = sort_by_digest_4_4;
10103 opti_type = OPTI_TYPE_ZERO_BYTE
10104 | OPTI_TYPE_NOT_ITERATED;
10105 dgst_pos0 = 0;
10106 dgst_pos1 = 1;
10107 dgst_pos2 = 2;
10108 dgst_pos3 = 3;
10109 break;
10110
10111 case 10410: hash_type = HASH_TYPE_PDFU16;
10112 salt_type = SALT_TYPE_EMBEDDED;
10113 attack_exec = ATTACK_EXEC_ON_GPU;
10114 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10115 kern_type = KERN_TYPE_PDF11CM1;
10116 dgst_size = DGST_SIZE_4_4;
10117 parse_func = pdf11cm1_parse_hash;
10118 sort_by_digest = sort_by_digest_4_4;
10119 opti_type = OPTI_TYPE_ZERO_BYTE
10120 | OPTI_TYPE_NOT_ITERATED;
10121 dgst_pos0 = 0;
10122 dgst_pos1 = 1;
10123 dgst_pos2 = 2;
10124 dgst_pos3 = 3;
10125 break;
10126
10127 case 10420: hash_type = HASH_TYPE_PDFU16;
10128 salt_type = SALT_TYPE_EMBEDDED;
10129 attack_exec = ATTACK_EXEC_ON_GPU;
10130 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10131 kern_type = KERN_TYPE_PDF11CM2;
10132 dgst_size = DGST_SIZE_4_4;
10133 parse_func = pdf11cm2_parse_hash;
10134 sort_by_digest = sort_by_digest_4_4;
10135 opti_type = OPTI_TYPE_ZERO_BYTE
10136 | OPTI_TYPE_NOT_ITERATED;
10137 dgst_pos0 = 0;
10138 dgst_pos1 = 1;
10139 dgst_pos2 = 2;
10140 dgst_pos3 = 3;
10141 break;
10142
10143 case 10500: hash_type = HASH_TYPE_PDFU16;
10144 salt_type = SALT_TYPE_EMBEDDED;
10145 attack_exec = ATTACK_EXEC_ON_CPU;
10146 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10147 kern_type = KERN_TYPE_PDF14;
10148 dgst_size = DGST_SIZE_4_4;
10149 parse_func = pdf14_parse_hash;
10150 sort_by_digest = sort_by_digest_4_4;
10151 opti_type = OPTI_TYPE_ZERO_BYTE
10152 | OPTI_TYPE_NOT_ITERATED;
10153 dgst_pos0 = 0;
10154 dgst_pos1 = 1;
10155 dgst_pos2 = 2;
10156 dgst_pos3 = 3;
10157 break;
10158
10159 case 10600: hash_type = HASH_TYPE_SHA256;
10160 salt_type = SALT_TYPE_EMBEDDED;
10161 attack_exec = ATTACK_EXEC_ON_GPU;
10162 opts_type = OPTS_TYPE_PT_GENERATE_BE
10163 | OPTS_TYPE_ST_ADD80
10164 | OPTS_TYPE_ST_ADDBITS15
10165 | OPTS_TYPE_HASH_COPY;
10166 kern_type = KERN_TYPE_SHA256_PWSLT;
10167 dgst_size = DGST_SIZE_4_8;
10168 parse_func = pdf17l3_parse_hash;
10169 sort_by_digest = sort_by_digest_4_8;
10170 opti_type = OPTI_TYPE_ZERO_BYTE
10171 | OPTI_TYPE_PRECOMPUTE_INIT
10172 | OPTI_TYPE_PRECOMPUTE_MERKLE
10173 | OPTI_TYPE_SCALAR_MODE
10174 | OPTI_TYPE_EARLY_SKIP
10175 | OPTI_TYPE_NOT_ITERATED
10176 | OPTI_TYPE_APPENDED_SALT
10177 | OPTI_TYPE_RAW_HASH;
10178 dgst_pos0 = 3;
10179 dgst_pos1 = 7;
10180 dgst_pos2 = 2;
10181 dgst_pos3 = 6;
10182 break;
10183
10184 case 10700: hash_type = HASH_TYPE_PDFU32;
10185 salt_type = SALT_TYPE_EMBEDDED;
10186 attack_exec = ATTACK_EXEC_ON_CPU;
10187 opts_type = OPTS_TYPE_PT_GENERATE_LE
10188 | OPTS_TYPE_HASH_COPY;
10189 kern_type = KERN_TYPE_PDF17L8;
10190 dgst_size = DGST_SIZE_4_8;
10191 parse_func = pdf17l8_parse_hash;
10192 sort_by_digest = sort_by_digest_4_8;
10193 opti_type = OPTI_TYPE_ZERO_BYTE
10194 | OPTI_TYPE_NOT_ITERATED;
10195 dgst_pos0 = 0;
10196 dgst_pos1 = 1;
10197 dgst_pos2 = 2;
10198 dgst_pos3 = 3;
10199 break;
10200
10201 case 10800: hash_type = HASH_TYPE_SHA384;
10202 salt_type = SALT_TYPE_NONE;
10203 attack_exec = ATTACK_EXEC_ON_GPU;
10204 opts_type = OPTS_TYPE_PT_GENERATE_BE
10205 | OPTS_TYPE_PT_ADD80
10206 | OPTS_TYPE_PT_ADDBITS15;
10207 kern_type = KERN_TYPE_SHA384;
10208 dgst_size = DGST_SIZE_8_8;
10209 parse_func = sha384_parse_hash;
10210 sort_by_digest = sort_by_digest_8_8;
10211 opti_type = OPTI_TYPE_ZERO_BYTE
10212 | OPTI_TYPE_PRECOMPUTE_INIT
10213 | OPTI_TYPE_PRECOMPUTE_MERKLE
10214 | OPTI_TYPE_SCALAR_MODE
10215 | OPTI_TYPE_EARLY_SKIP
10216 | OPTI_TYPE_NOT_ITERATED
10217 | OPTI_TYPE_NOT_SALTED
10218 | OPTI_TYPE_RAW_HASH;
10219 dgst_pos0 = 6;
10220 dgst_pos1 = 7;
10221 dgst_pos2 = 4;
10222 dgst_pos3 = 5;
10223 break;
10224
10225 case 10900: hash_type = HASH_TYPE_PBKDF2_SHA256;
10226 salt_type = SALT_TYPE_EMBEDDED;
10227 attack_exec = ATTACK_EXEC_ON_CPU;
10228 opts_type = OPTS_TYPE_PT_GENERATE_LE
10229 | OPTS_TYPE_ST_BASE64
10230 | OPTS_TYPE_HASH_COPY;
10231 kern_type = KERN_TYPE_PBKDF2_SHA256;
10232 dgst_size = DGST_SIZE_4_32;
10233 parse_func = pbkdf2_sha256_parse_hash;
10234 sort_by_digest = sort_by_digest_4_32;
10235 opti_type = OPTI_TYPE_ZERO_BYTE;
10236 dgst_pos0 = 0;
10237 dgst_pos1 = 1;
10238 dgst_pos2 = 2;
10239 dgst_pos3 = 3;
10240 break;
10241
10242 case 11000: hash_type = HASH_TYPE_MD5;
10243 salt_type = SALT_TYPE_INTERN;
10244 attack_exec = ATTACK_EXEC_ON_GPU;
10245 opts_type = OPTS_TYPE_PT_GENERATE_LE
10246 | OPTS_TYPE_PT_ADD80;
10247 kern_type = KERN_TYPE_PRESTASHOP;
10248 dgst_size = DGST_SIZE_4_4;
10249 parse_func = prestashop_parse_hash;
10250 sort_by_digest = sort_by_digest_4_4;
10251 opti_type = OPTI_TYPE_ZERO_BYTE
10252 | OPTI_TYPE_PRECOMPUTE_INIT
10253 | OPTI_TYPE_NOT_ITERATED
10254 | OPTI_TYPE_PREPENDED_SALT;
10255 dgst_pos0 = 0;
10256 dgst_pos1 = 3;
10257 dgst_pos2 = 2;
10258 dgst_pos3 = 1;
10259 break;
10260
10261 case 11100: hash_type = HASH_TYPE_MD5;
10262 salt_type = SALT_TYPE_EMBEDDED;
10263 attack_exec = ATTACK_EXEC_ON_GPU;
10264 opts_type = OPTS_TYPE_PT_GENERATE_LE
10265 | OPTS_TYPE_ST_ADD80;
10266 kern_type = KERN_TYPE_POSTGRESQL_AUTH;
10267 dgst_size = DGST_SIZE_4_4;
10268 parse_func = postgresql_auth_parse_hash;
10269 sort_by_digest = sort_by_digest_4_4;
10270 opti_type = OPTI_TYPE_ZERO_BYTE
10271 | OPTI_TYPE_PRECOMPUTE_INIT
10272 | OPTI_TYPE_PRECOMPUTE_MERKLE
10273 | OPTI_TYPE_EARLY_SKIP;
10274 dgst_pos0 = 0;
10275 dgst_pos1 = 3;
10276 dgst_pos2 = 2;
10277 dgst_pos3 = 1;
10278 break;
10279
10280 case 11200: hash_type = HASH_TYPE_SHA1;
10281 salt_type = SALT_TYPE_EMBEDDED;
10282 attack_exec = ATTACK_EXEC_ON_GPU;
10283 opts_type = OPTS_TYPE_PT_GENERATE_BE
10284 | OPTS_TYPE_PT_ADD80
10285 | OPTS_TYPE_ST_HEX;
10286 kern_type = KERN_TYPE_MYSQL_AUTH;
10287 dgst_size = DGST_SIZE_4_5;
10288 parse_func = mysql_auth_parse_hash;
10289 sort_by_digest = sort_by_digest_4_5;
10290 opti_type = OPTI_TYPE_ZERO_BYTE
10291 | OPTI_TYPE_EARLY_SKIP;
10292 dgst_pos0 = 3;
10293 dgst_pos1 = 4;
10294 dgst_pos2 = 2;
10295 dgst_pos3 = 1;
10296 break;
10297
10298 case 11300: hash_type = HASH_TYPE_BITCOIN_WALLET;
10299 salt_type = SALT_TYPE_EMBEDDED;
10300 attack_exec = ATTACK_EXEC_ON_CPU;
10301 opts_type = OPTS_TYPE_PT_GENERATE_LE
10302 | OPTS_TYPE_ST_HEX
10303 | OPTS_TYPE_ST_ADD80;
10304 kern_type = KERN_TYPE_BITCOIN_WALLET;
10305 dgst_size = DGST_SIZE_4_4;
10306 parse_func = bitcoin_wallet_parse_hash;
10307 sort_by_digest = sort_by_digest_4_4;
10308 opti_type = OPTI_TYPE_ZERO_BYTE;
10309 dgst_pos0 = 0;
10310 dgst_pos1 = 1;
10311 dgst_pos2 = 2;
10312 dgst_pos3 = 3;
10313 break;
10314
10315 case 11400: hash_type = HASH_TYPE_MD5;
10316 salt_type = SALT_TYPE_EMBEDDED;
10317 attack_exec = ATTACK_EXEC_ON_GPU;
10318 opts_type = OPTS_TYPE_PT_GENERATE_LE
10319 | OPTS_TYPE_PT_ADD80
10320 | OPTS_TYPE_HASH_COPY;
10321 kern_type = KERN_TYPE_SIP_AUTH;
10322 dgst_size = DGST_SIZE_4_4;
10323 parse_func = sip_auth_parse_hash;
10324 sort_by_digest = sort_by_digest_4_4;
10325 opti_type = OPTI_TYPE_ZERO_BYTE;
10326 dgst_pos0 = 0;
10327 dgst_pos1 = 3;
10328 dgst_pos2 = 2;
10329 dgst_pos3 = 1;
10330 break;
10331
10332 case 11500: hash_type = HASH_TYPE_CRC32;
10333 salt_type = SALT_TYPE_INTERN;
10334 attack_exec = ATTACK_EXEC_ON_GPU;
10335 opts_type = OPTS_TYPE_PT_GENERATE_LE
10336 | OPTS_TYPE_ST_GENERATE_LE
10337 | OPTS_TYPE_ST_HEX;
10338 kern_type = KERN_TYPE_CRC32;
10339 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10340 parse_func = crc32_parse_hash;
10341 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10342 opti_type = OPTI_TYPE_ZERO_BYTE
10343 | OPTI_TYPE_SCALAR_MODE;
10344 dgst_pos0 = 0;
10345 dgst_pos1 = 1;
10346 dgst_pos2 = 2;
10347 dgst_pos3 = 3;
10348 break;
10349
10350 case 11600: hash_type = HASH_TYPE_AES;
10351 salt_type = SALT_TYPE_EMBEDDED;
10352 attack_exec = ATTACK_EXEC_ON_CPU;
10353 opts_type = OPTS_TYPE_PT_GENERATE_LE
10354 | OPTS_TYPE_PT_NEVERCRACK;
10355 kern_type = KERN_TYPE_SEVEN_ZIP;
10356 dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
10357 parse_func = seven_zip_parse_hash;
10358 sort_by_digest = sort_by_digest_4_4; // originally sort_by_digest_4_2
10359 opti_type = OPTI_TYPE_ZERO_BYTE;
10360 dgst_pos0 = 0;
10361 dgst_pos1 = 1;
10362 dgst_pos2 = 2;
10363 dgst_pos3 = 3;
10364 break;
10365
10366 case 11700: hash_type = HASH_TYPE_GOST_2012SBOG_256;
10367 salt_type = SALT_TYPE_NONE;
10368 attack_exec = ATTACK_EXEC_ON_GPU;
10369 opts_type = OPTS_TYPE_PT_GENERATE_LE
10370 | OPTS_TYPE_PT_ADD01;
10371 kern_type = KERN_TYPE_GOST_2012SBOG_256;
10372 dgst_size = DGST_SIZE_4_8;
10373 parse_func = gost2012sbog_256_parse_hash;
10374 sort_by_digest = sort_by_digest_4_8;
10375 opti_type = OPTI_TYPE_ZERO_BYTE;
10376 dgst_pos0 = 0;
10377 dgst_pos1 = 1;
10378 dgst_pos2 = 2;
10379 dgst_pos3 = 3;
10380 break;
10381
10382 case 11800: hash_type = HASH_TYPE_GOST_2012SBOG_512;
10383 salt_type = SALT_TYPE_NONE;
10384 attack_exec = ATTACK_EXEC_ON_GPU;
10385 opts_type = OPTS_TYPE_PT_GENERATE_LE
10386 | OPTS_TYPE_PT_ADD01;
10387 kern_type = KERN_TYPE_GOST_2012SBOG_512;
10388 dgst_size = DGST_SIZE_4_16;
10389 parse_func = gost2012sbog_512_parse_hash;
10390 sort_by_digest = sort_by_digest_4_16;
10391 opti_type = OPTI_TYPE_ZERO_BYTE;
10392 dgst_pos0 = 0;
10393 dgst_pos1 = 1;
10394 dgst_pos2 = 2;
10395 dgst_pos3 = 3;
10396 break;
10397
10398 case 11900: hash_type = HASH_TYPE_PBKDF2_MD5;
10399 salt_type = SALT_TYPE_EMBEDDED;
10400 attack_exec = ATTACK_EXEC_ON_CPU;
10401 opts_type = OPTS_TYPE_PT_GENERATE_LE
10402 | OPTS_TYPE_ST_BASE64
10403 | OPTS_TYPE_HASH_COPY;
10404 kern_type = KERN_TYPE_PBKDF2_MD5;
10405 dgst_size = DGST_SIZE_4_32;
10406 parse_func = pbkdf2_md5_parse_hash;
10407 sort_by_digest = sort_by_digest_4_32;
10408 opti_type = OPTI_TYPE_ZERO_BYTE;
10409 dgst_pos0 = 0;
10410 dgst_pos1 = 1;
10411 dgst_pos2 = 2;
10412 dgst_pos3 = 3;
10413 break;
10414
10415 case 12000: hash_type = HASH_TYPE_PBKDF2_SHA1;
10416 salt_type = SALT_TYPE_EMBEDDED;
10417 attack_exec = ATTACK_EXEC_ON_CPU;
10418 opts_type = OPTS_TYPE_PT_GENERATE_LE
10419 | OPTS_TYPE_ST_BASE64
10420 | OPTS_TYPE_HASH_COPY;
10421 kern_type = KERN_TYPE_PBKDF2_SHA1;
10422 dgst_size = DGST_SIZE_4_32;
10423 parse_func = pbkdf2_sha1_parse_hash;
10424 sort_by_digest = sort_by_digest_4_32;
10425 opti_type = OPTI_TYPE_ZERO_BYTE;
10426 dgst_pos0 = 0;
10427 dgst_pos1 = 1;
10428 dgst_pos2 = 2;
10429 dgst_pos3 = 3;
10430 break;
10431
10432 case 12100: hash_type = HASH_TYPE_PBKDF2_SHA512;
10433 salt_type = SALT_TYPE_EMBEDDED;
10434 attack_exec = ATTACK_EXEC_ON_CPU;
10435 opts_type = OPTS_TYPE_PT_GENERATE_LE
10436 | OPTS_TYPE_ST_BASE64
10437 | OPTS_TYPE_HASH_COPY;
10438 kern_type = KERN_TYPE_PBKDF2_SHA512;
10439 dgst_size = DGST_SIZE_8_16;
10440 parse_func = pbkdf2_sha512_parse_hash;
10441 sort_by_digest = sort_by_digest_8_16;
10442 opti_type = OPTI_TYPE_ZERO_BYTE;
10443 dgst_pos0 = 0;
10444 dgst_pos1 = 1;
10445 dgst_pos2 = 2;
10446 dgst_pos3 = 3;
10447 break;
10448
10449 case 12200: hash_type = HASH_TYPE_ECRYPTFS;
10450 salt_type = SALT_TYPE_EMBEDDED;
10451 attack_exec = ATTACK_EXEC_ON_CPU;
10452 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10453 kern_type = KERN_TYPE_ECRYPTFS;
10454 dgst_size = DGST_SIZE_8_8;
10455 parse_func = ecryptfs_parse_hash;
10456 sort_by_digest = sort_by_digest_8_8;
10457 opti_type = OPTI_TYPE_ZERO_BYTE;
10458 dgst_pos0 = 0;
10459 dgst_pos1 = 1;
10460 dgst_pos2 = 2;
10461 dgst_pos3 = 3;
10462 break;
10463
10464 case 12300: hash_type = HASH_TYPE_ORACLET;
10465 salt_type = SALT_TYPE_EMBEDDED;
10466 attack_exec = ATTACK_EXEC_ON_CPU;
10467 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10468 kern_type = KERN_TYPE_ORACLET;
10469 dgst_size = DGST_SIZE_8_16;
10470 parse_func = oraclet_parse_hash;
10471 sort_by_digest = sort_by_digest_8_16;
10472 opti_type = OPTI_TYPE_ZERO_BYTE;
10473 dgst_pos0 = 0;
10474 dgst_pos1 = 1;
10475 dgst_pos2 = 2;
10476 dgst_pos3 = 3;
10477 break;
10478
10479 case 12400: hash_type = HASH_TYPE_BSDICRYPT;
10480 salt_type = SALT_TYPE_EMBEDDED;
10481 attack_exec = ATTACK_EXEC_ON_CPU;
10482 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10483 kern_type = KERN_TYPE_BSDICRYPT;
10484 dgst_size = DGST_SIZE_4_4;
10485 parse_func = bsdicrypt_parse_hash;
10486 sort_by_digest = sort_by_digest_4_4;
10487 opti_type = OPTI_TYPE_ZERO_BYTE
10488 | OPTI_TYPE_PRECOMPUTE_PERMUT;
10489 dgst_pos0 = 0;
10490 dgst_pos1 = 1;
10491 dgst_pos2 = 2;
10492 dgst_pos3 = 3;
10493 break;
10494
10495 case 12500: hash_type = HASH_TYPE_RAR3HP;
10496 salt_type = SALT_TYPE_EMBEDDED;
10497 attack_exec = ATTACK_EXEC_ON_CPU;
10498 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10499 kern_type = KERN_TYPE_RAR3;
10500 dgst_size = DGST_SIZE_4_4;
10501 parse_func = rar3hp_parse_hash;
10502 sort_by_digest = sort_by_digest_4_4;
10503 opti_type = OPTI_TYPE_ZERO_BYTE;
10504 dgst_pos0 = 0;
10505 dgst_pos1 = 1;
10506 dgst_pos2 = 2;
10507 dgst_pos3 = 3;
10508 break;
10509
10510 case 12600: hash_type = HASH_TYPE_SHA256;
10511 salt_type = SALT_TYPE_INTERN;
10512 attack_exec = ATTACK_EXEC_ON_GPU;
10513 opts_type = OPTS_TYPE_PT_GENERATE_BE
10514 | OPTS_TYPE_PT_ADD80;
10515 kern_type = KERN_TYPE_CF10;
10516 dgst_size = DGST_SIZE_4_8;
10517 parse_func = cf10_parse_hash;
10518 sort_by_digest = sort_by_digest_4_8;
10519 opti_type = OPTI_TYPE_ZERO_BYTE
10520 | OPTI_TYPE_PRECOMPUTE_INIT
10521 | OPTI_TYPE_EARLY_SKIP
10522 | OPTI_TYPE_NOT_ITERATED;
10523 dgst_pos0 = 3;
10524 dgst_pos1 = 7;
10525 dgst_pos2 = 2;
10526 dgst_pos3 = 6;
10527 break;
10528
10529 case 12700: hash_type = HASH_TYPE_AES;
10530 salt_type = SALT_TYPE_EMBEDDED;
10531 attack_exec = ATTACK_EXEC_ON_CPU;
10532 opts_type = OPTS_TYPE_PT_GENERATE_LE
10533 | OPTS_TYPE_HASH_COPY;
10534 kern_type = KERN_TYPE_MYWALLET;
10535 dgst_size = DGST_SIZE_4_5; // because kernel uses _SHA1_
10536 parse_func = mywallet_parse_hash;
10537 sort_by_digest = sort_by_digest_4_5;
10538 opti_type = OPTI_TYPE_ZERO_BYTE;
10539 dgst_pos0 = 0;
10540 dgst_pos1 = 1;
10541 dgst_pos2 = 2;
10542 dgst_pos3 = 3;
10543 break;
10544
10545 case 12800: hash_type = HASH_TYPE_PBKDF2_SHA256;
10546 salt_type = SALT_TYPE_EMBEDDED;
10547 attack_exec = ATTACK_EXEC_ON_CPU;
10548 opts_type = OPTS_TYPE_PT_GENERATE_LE;
10549 kern_type = KERN_TYPE_MS_DRSR;
10550 dgst_size = DGST_SIZE_4_8;
10551 parse_func = ms_drsr_parse_hash;
10552 sort_by_digest = sort_by_digest_4_8;
10553 opti_type = OPTI_TYPE_ZERO_BYTE;
10554 dgst_pos0 = 0;
10555 dgst_pos1 = 1;
10556 dgst_pos2 = 2;
10557 dgst_pos3 = 3;
10558 break;
10559
10560 default: usage_mini_print (PROGNAME); return (-1);
10561 }
10562
10563 /**
10564 * transpose
10565 */
10566
10567 data.parse_func = parse_func;
10568
10569 /**
10570 * misc stuff
10571 */
10572
10573 if (hex_salt)
10574 {
10575 if (salt_type == SALT_TYPE_INTERN)
10576 {
10577 opts_type |= OPTS_TYPE_ST_HEX;
10578 }
10579 else
10580 {
10581 log_error ("ERROR: Parameter hex-salt not valid for hash-type %u", hash_mode);
10582
10583 return (-1);
10584 }
10585 }
10586
10587 uint isSalted = ((salt_type == SALT_TYPE_INTERN)
10588 | (salt_type == SALT_TYPE_EXTERN)
10589 | (salt_type == SALT_TYPE_EMBEDDED)
10590 | (salt_type == SALT_TYPE_VIRTUAL));
10591
10592 sort_by_digest = sort_by_digest_p0p1; // overruled by 64 bit digest
10593
10594 data.hash_type = hash_type;
10595 data.attack_mode = attack_mode;
10596 data.attack_kern = attack_kern;
10597 data.attack_exec = attack_exec;
10598 data.kern_type = kern_type;
10599 data.opts_type = opts_type;
10600 data.dgst_size = dgst_size;
10601 data.salt_type = salt_type;
10602 data.isSalted = isSalted;
10603 data.sort_by_digest = sort_by_digest;
10604 data.dgst_pos0 = dgst_pos0;
10605 data.dgst_pos1 = dgst_pos1;
10606 data.dgst_pos2 = dgst_pos2;
10607 data.dgst_pos3 = dgst_pos3;
10608
10609 esalt_size = 0;
10610
10611 switch (hash_mode)
10612 {
10613 case 2500: esalt_size = sizeof (wpa_t); break;
10614 case 5300: esalt_size = sizeof (ikepsk_t); break;
10615 case 5400: esalt_size = sizeof (ikepsk_t); break;
10616 case 5500: esalt_size = sizeof (netntlm_t); break;
10617 case 5600: esalt_size = sizeof (netntlm_t); break;
10618 case 6211:
10619 case 6212:
10620 case 6213:
10621 case 6221:
10622 case 6222:
10623 case 6223:
10624 case 6231:
10625 case 6232:
10626 case 6233:
10627 case 6241:
10628 case 6242:
10629 case 6243: esalt_size = sizeof (tc_t); break;
10630 case 6600: esalt_size = sizeof (agilekey_t); break;
10631 case 7100: esalt_size = sizeof (pbkdf2_sha512_t); break;
10632 case 7200: esalt_size = sizeof (pbkdf2_sha512_t); break;
10633 case 7300: esalt_size = sizeof (rakp_t); break;
10634 case 7500: esalt_size = sizeof (krb5pa_t); break;
10635 case 8200: esalt_size = sizeof (cloudkey_t); break;
10636 case 8800: esalt_size = sizeof (androidfde_t); break;
10637 case 9200: esalt_size = sizeof (pbkdf2_sha256_t); break;
10638 case 9400: esalt_size = sizeof (office2007_t); break;
10639 case 9500: esalt_size = sizeof (office2010_t); break;
10640 case 9600: esalt_size = sizeof (office2013_t); break;
10641 case 9700: esalt_size = sizeof (oldoffice01_t); break;
10642 case 9710: esalt_size = sizeof (oldoffice01_t); break;
10643 case 9720: esalt_size = sizeof (oldoffice01_t); break;
10644 case 9800: esalt_size = sizeof (oldoffice34_t); break;
10645 case 9810: esalt_size = sizeof (oldoffice34_t); break;
10646 case 9820: esalt_size = sizeof (oldoffice34_t); break;
10647 case 10000: esalt_size = sizeof (pbkdf2_sha256_t); break;
10648 case 10200: esalt_size = sizeof (cram_md5_t); break;
10649 case 10400: esalt_size = sizeof (pdf_t); break;
10650 case 10410: esalt_size = sizeof (pdf_t); break;
10651 case 10420: esalt_size = sizeof (pdf_t); break;
10652 case 10500: esalt_size = sizeof (pdf_t); break;
10653 case 10600: esalt_size = sizeof (pdf_t); break;
10654 case 10700: esalt_size = sizeof (pdf_t); break;
10655 case 10900: esalt_size = sizeof (pbkdf2_sha256_t); break;
10656 case 11300: esalt_size = sizeof (bitcoin_wallet_t); break;
10657 case 11400: esalt_size = sizeof (sip_t); break;
10658 case 11600: esalt_size = sizeof (seven_zip_t); break;
10659 case 11900: esalt_size = sizeof (pbkdf2_md5_t); break;
10660 case 12000: esalt_size = sizeof (pbkdf2_sha1_t); break;
10661 case 12100: esalt_size = sizeof (pbkdf2_sha512_t); break;
10662 }
10663
10664 data.esalt_size = esalt_size;
10665
10666 /**
10667 * choose dictionary parser
10668 */
10669
10670 if (hash_type == HASH_TYPE_LM)
10671 {
10672 get_next_word_func = get_next_word_lm;
10673 }
10674 else if (opts_type & OPTS_TYPE_PT_UPPER)
10675 {
10676 get_next_word_func = get_next_word_uc;
10677 }
10678 else
10679 {
10680 get_next_word_func = get_next_word_std;
10681 }
10682
10683 /**
10684 * dictstat
10685 */
10686
10687 dictstat_t *dictstat_base = (dictstat_t *) mycalloc (MAX_DICTSTAT, sizeof (dictstat_t));
10688
10689 #ifdef _POSIX
10690 size_t dictstat_nmemb = 0;
10691 #endif
10692
10693 #ifdef _WIN
10694 uint dictstat_nmemb = 0;
10695 #endif
10696
10697 char dictstat[256];
10698
10699 FILE *dictstat_fp = NULL;
10700
10701 if (keyspace == 0)
10702 {
10703 memset (dictstat, 0, sizeof (dictstat));
10704
10705 snprintf (dictstat, sizeof (dictstat) - 1, "%s/%s.dictstat", install_dir, PROGNAME);
10706
10707 dictstat_fp = fopen (dictstat, "rb");
10708
10709 if (dictstat_fp)
10710 {
10711 #ifdef _POSIX
10712 struct stat tmpstat;
10713
10714 fstat (fileno (dictstat_fp), &tmpstat);
10715 #endif
10716
10717 #ifdef _WIN
10718 struct stat64 tmpstat;
10719
10720 _fstat64 (fileno (dictstat_fp), &tmpstat);
10721 #endif
10722
10723 if (tmpstat.st_mtime < COMPTIME)
10724 {
10725 /* with v0.15 the format changed so we have to ensure user is using a good version
10726 since there is no version-header in the dictstat file */
10727
10728 fclose (dictstat_fp);
10729
10730 unlink (dictstat);
10731 }
10732 else
10733 {
10734 while (!feof (dictstat_fp))
10735 {
10736 dictstat_t d;
10737
10738 if (fread (&d, sizeof (dictstat_t), 1, dictstat_fp) == 0) continue;
10739
10740 lsearch (&d, dictstat_base, &dictstat_nmemb, sizeof (dictstat_t), sort_by_dictstat);
10741
10742 if (dictstat_nmemb == (MAX_DICTSTAT - 1000))
10743 {
10744 log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat);
10745
10746 return -1;
10747 }
10748 }
10749
10750 fclose (dictstat_fp);
10751 }
10752 }
10753 }
10754
10755 /**
10756 * potfile
10757 */
10758
10759 char potfile[256];
10760
10761 memset (potfile, 0, sizeof (potfile));
10762
10763 snprintf (potfile, sizeof (potfile) - 1, "%s.pot", session);
10764
10765 data.pot_fp = NULL;
10766
10767 FILE *out_fp = NULL;
10768 FILE *pot_fp = NULL;
10769
10770 if (show == 1 || left == 1)
10771 {
10772 pot_fp = fopen (potfile, "rb");
10773
10774 if (pot_fp == NULL)
10775 {
10776 log_error ("ERROR: %s: %s", potfile, strerror (errno));
10777
10778 return (-1);
10779 }
10780
10781 if (outfile != NULL)
10782 {
10783 if ((out_fp = fopen (outfile, "ab")) == NULL)
10784 {
10785 log_error ("ERROR: %s: %s", outfile, strerror (errno));
10786
10787 fclose (pot_fp);
10788
10789 return (-1);
10790 }
10791 }
10792 else
10793 {
10794 out_fp = stdout;
10795 }
10796 }
10797 else
10798 {
10799 if (potfile_disable == 0)
10800 {
10801 pot_fp = fopen (potfile, "ab");
10802
10803 if (pot_fp == NULL)
10804 {
10805 log_error ("ERROR: %s: %s", potfile, strerror (errno));
10806
10807 return (-1);
10808 }
10809
10810 data.pot_fp = pot_fp;
10811 }
10812 }
10813
10814 pot_t *pot = NULL;
10815
10816 uint pot_cnt = 0;
10817 uint pot_avail = 0;
10818
10819 if (show == 1 || left == 1)
10820 {
10821 SUPPRESS_OUTPUT = 1;
10822
10823 pot_avail = count_lines (pot_fp);
10824
10825 rewind (pot_fp);
10826
10827 pot = (pot_t *) mycalloc (pot_avail, sizeof (pot_t));
10828
10829 uint pot_hashes_avail = 0;
10830
10831 uint line_num = 0;
10832
10833 while (!feof (pot_fp))
10834 {
10835 line_num++;
10836
10837 char line_buf[BUFSIZ];
10838
10839 int line_len = fgetl (pot_fp, line_buf);
10840
10841 if (line_len == 0) continue;
10842
10843 char *plain_buf = line_buf + line_len;
10844
10845 pot_t *pot_ptr = &pot[pot_cnt];
10846
10847 hash_t *hashes_buf = &pot_ptr->hash;
10848
10849 // we do not initialize all hashes_buf->digest etc at the beginning, since many lines may not be
10850 // valid lines of this specific hash type (otherwise it would be more waste of memory than gain)
10851
10852 if (pot_cnt == pot_hashes_avail)
10853 {
10854 uint pos = 0;
10855
10856 for (pos = 0; pos < INCR_POT; pos++)
10857 {
10858 if ((pot_cnt + pos) >= pot_avail) break;
10859
10860 pot_t *tmp_pot = &pot[pot_cnt + pos];
10861
10862 hash_t *tmp_hash = &tmp_pot->hash;
10863
10864 tmp_hash->digest = mymalloc (dgst_size);
10865
10866 if (isSalted)
10867 {
10868 tmp_hash->salt = (salt_t *) mymalloc (sizeof (salt_t));
10869 }
10870
10871 if (esalt_size)
10872 {
10873 tmp_hash->esalt = mymalloc (esalt_size);
10874 }
10875
10876 pot_hashes_avail++;
10877 }
10878 }
10879
10880 int plain_len = 0;
10881
10882 int parser_status;
10883
10884 int iter = MAX_CUT_TRIES;
10885
10886 do
10887 {
10888 for (int i = line_len - 1; i; i--, plain_len++, plain_buf--, line_len--)
10889 {
10890 if (line_buf[i] == ':')
10891 {
10892 line_len--;
10893
10894 break;
10895 }
10896 }
10897
10898 if (data.hash_mode != 2500)
10899 {
10900 parser_status = parse_func (line_buf, line_len, hashes_buf);
10901 }
10902 else
10903 {
10904 int max_salt_size = sizeof (hashes_buf->salt->salt_buf);
10905
10906 if (line_len > max_salt_size)
10907 {
10908 parser_status = PARSER_GLOBAL_LENGTH;
10909 }
10910 else
10911 {
10912 memset (&hashes_buf->salt->salt_buf, 0, max_salt_size);
10913
10914 memcpy (&hashes_buf->salt->salt_buf, line_buf, line_len);
10915
10916 hashes_buf->salt->salt_len = line_len;
10917
10918 parser_status = PARSER_OK;
10919 }
10920 }
10921
10922 // if NOT parsed without error, we add the ":" to the plain
10923
10924 if (parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH)
10925 {
10926 plain_len++;
10927 plain_buf--;
10928 }
10929
10930 } while ((parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH) && --iter);
10931
10932 if (parser_status < PARSER_GLOBAL_ZERO)
10933 {
10934 // log_info ("WARNING: Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status));
10935
10936 continue;
10937 }
10938
10939 memcpy (pot_ptr->plain_buf, plain_buf, plain_len);
10940
10941 pot_ptr->plain_len = plain_len;
10942
10943 pot_cnt++;
10944 }
10945
10946 fclose (pot_fp);
10947
10948 SUPPRESS_OUTPUT = 0;
10949
10950 qsort (pot, pot_cnt, sizeof (pot_t), sort_by_pot);
10951 }
10952
10953 /**
10954 * gpu accel and loops auto adjustment
10955 */
10956
10957 if (gpu_accel_chgd == 0) gpu_accel = set_gpu_accel (hash_mode);
10958 if (gpu_loops_chgd == 0) gpu_loops = set_gpu_loops (hash_mode);
10959
10960 if (workload_profile == 1)
10961 {
10962 gpu_loops /= 8;
10963 gpu_accel /= 4;
10964
10965 if (gpu_loops == 0) gpu_loops = 8;
10966 if (gpu_accel == 0) gpu_accel = 2;
10967 }
10968 else if (workload_profile == 3)
10969 {
10970 gpu_loops *= 8;
10971 gpu_accel *= 4;
10972
10973 if (gpu_loops > 1024) gpu_loops = 1024;
10974 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
10975 }
10976
10977 // those hashes *must* run at a specific gpu_loops count because of some optimization inside the kernel
10978
10979 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
10980 {
10981 gpu_loops = 1024;
10982 }
10983
10984 if (hash_mode == 12500)
10985 {
10986 gpu_loops = ROUNDS_RAR3 / 16;
10987 }
10988
10989 data.gpu_accel = gpu_accel;
10990 data.gpu_loops = gpu_loops;
10991
10992 /**
10993 * word len
10994 */
10995
10996 uint pw_min = PW_MIN;
10997 uint pw_max = PW_MAX;
10998
10999 switch (hash_mode)
11000 {
11001 case 400: if (pw_max > 40) pw_max = 40;
11002 break;
11003 case 500: if (pw_max > 16) pw_max = 16;
11004 break;
11005 case 1500: if (pw_max > 8) pw_max = 8;
11006 break;
11007 case 1600: if (pw_max > 16) pw_max = 16;
11008 break;
11009 case 1800: if (pw_max > 16) pw_max = 16;
11010 break;
11011 case 2100: if (pw_max > 16) pw_max = 16;
11012 break;
11013 case 2500: if (pw_min < 8) pw_min = 8;
11014 break;
11015 case 3000: if (pw_max > 7) pw_max = 7;
11016 break;
11017 case 5200: if (pw_max > 24) pw_max = 24;
11018 break;
11019 case 5800: if (pw_max > 16) pw_max = 16;
11020 break;
11021 case 6300: if (pw_max > 16) pw_max = 16;
11022 break;
11023 case 7400: if (pw_max > 16) pw_max = 16;
11024 break;
11025 case 7900: if (pw_max > 48) pw_max = 48;
11026 break;
11027 case 8500: if (pw_max > 8) pw_max = 8;
11028 break;
11029 case 8600: if (pw_max > 16) pw_max = 16;
11030 break;
11031 case 9710: pw_min = 5;
11032 pw_max = 5;
11033 break;
11034 case 9810: pw_min = 5;
11035 pw_max = 5;
11036 break;
11037 case 10410: pw_min = 5;
11038 pw_max = 5;
11039 break;
11040 case 10300: if (pw_max < 3) pw_min = 3;
11041 if (pw_max > 40) pw_max = 40;
11042 break;
11043 case 10500: if (pw_max < 3) pw_min = 3;
11044 if (pw_max > 40) pw_max = 40;
11045 break;
11046 case 10700: if (pw_max > 16) pw_max = 16;
11047 break;
11048 case 11300: if (pw_max > 40) pw_max = 40;
11049 break;
11050 case 12500: if (pw_max > 20) pw_max = 20;
11051 break;
11052 case 12800: if (pw_max > 24) pw_max = 24;
11053 break;
11054 }
11055
11056 if (attack_exec == ATTACK_EXEC_ON_GPU)
11057 {
11058 switch (attack_kern)
11059 {
11060 case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
11061 break;
11062 case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
11063 break;
11064 }
11065 }
11066
11067 /**
11068 * charsets : keep them together for more easy maintainnce
11069 */
11070
11071 cs_t mp_sys[6];
11072 cs_t mp_usr[4];
11073
11074 memset (mp_sys, 0, sizeof (mp_sys));
11075 memset (mp_usr, 0, sizeof (mp_usr));
11076
11077 mp_setup_sys (mp_sys);
11078
11079 if (custom_charset_1) mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
11080 if (custom_charset_2) mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
11081 if (custom_charset_3) mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
11082 if (custom_charset_4) mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
11083
11084 /**
11085 * load hashes, part I: find input mode, count hashes
11086 */
11087
11088 uint hashlist_mode = 0;
11089 uint hashlist_format = HLFMT_HASHCAT;
11090
11091 uint hashes_avail = 0;
11092
11093 if (benchmark == 0)
11094 {
11095 struct stat f;
11096
11097 hashlist_mode = (stat (myargv[optind], &f) == 0) ? HL_MODE_FILE : HL_MODE_ARG;
11098
11099 if ((hash_mode == 2500) ||
11100 (hash_mode == 5200) ||
11101 ((hash_mode >= 6200) && (hash_mode <= 6299)) ||
11102 (hash_mode == 9000))
11103 {
11104 hashlist_mode = HL_MODE_ARG;
11105
11106 char *hashfile = myargv[optind];
11107
11108 data.hashfile = hashfile;
11109
11110 logfile_top_var_string ("target", hashfile);
11111 }
11112
11113 if (hashlist_mode == HL_MODE_ARG)
11114 {
11115 if (hash_mode == 2500)
11116 {
11117 struct stat st;
11118
11119 if (stat (data.hashfile, &st) == -1)
11120 {
11121 log_error ("ERROR: %s: %s", data.hashfile, strerror (errno));
11122
11123 return (-1);
11124 }
11125
11126 hashes_avail = st.st_size / sizeof (hccap_t);
11127 }
11128 else
11129 {
11130 hashes_avail = 1;
11131 }
11132 }
11133 else if (hashlist_mode == HL_MODE_FILE)
11134 {
11135 char *hashfile = myargv[optind];
11136
11137 data.hashfile = hashfile;
11138
11139 logfile_top_var_string ("target", hashfile);
11140
11141 FILE *fp = NULL;
11142
11143 if ((fp = fopen (hashfile, "rb")) == NULL)
11144 {
11145 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
11146
11147 return (-1);
11148 }
11149
11150 if (data.quiet == 0) log_info_nn ("Counting lines in %s", hashfile);
11151
11152 hashes_avail = count_lines (fp);
11153
11154 rewind (fp);
11155
11156 if (hashes_avail == 0)
11157 {
11158 log_error ("ERROR: hashfile is empty or corrupt");
11159
11160 fclose (fp);
11161
11162 return (-1);
11163 }
11164
11165 hashlist_format = hlfmt_detect (fp, 100); // 100 = max numbers to "scan". could be hashes_avail, too
11166
11167 if ((remove == 1) && (hashlist_format != HLFMT_HASHCAT))
11168 {
11169 log_error ("ERROR: remove not supported in native hashfile-format mode");
11170
11171 fclose (fp);
11172
11173 return (-1);
11174 }
11175
11176 fclose (fp);
11177 }
11178 }
11179 else
11180 {
11181 hashlist_mode = HL_MODE_ARG;
11182
11183 hashes_avail = 1;
11184 }
11185
11186 if (hash_mode == 3000) hashes_avail *= 2;
11187
11188 data.hashlist_mode = hashlist_mode;
11189 data.hashlist_format = hashlist_format;
11190
11191 logfile_top_uint (hashlist_mode);
11192 logfile_top_uint (hashlist_format);
11193
11194 /**
11195 * load hashes, part II: allocate required memory, set pointers
11196 */
11197
11198 hash_t *hashes_buf = NULL;
11199 void *digests_buf = NULL;
11200 salt_t *salts_buf = NULL;
11201 void *esalts_buf = NULL;
11202
11203 hashes_buf = (hash_t *) mycalloc (hashes_avail, sizeof (hash_t));
11204
11205 digests_buf = (void *) mycalloc (hashes_avail, dgst_size);
11206
11207 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
11208 {
11209 uint32_t hash_pos;
11210
11211 for (hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
11212 {
11213 hashinfo_t *hash_info = (hashinfo_t *) mymalloc (sizeof (hashinfo_t));
11214
11215 hashes_buf[hash_pos].hash_info = hash_info;
11216
11217 if (username && (remove || show || left))
11218 {
11219 hash_info->user = (user_t*) mymalloc (sizeof (user_t));
11220 }
11221
11222 if (benchmark)
11223 {
11224 hash_info->orighash = (char *) mymalloc (256);
11225 }
11226 }
11227 }
11228
11229 if (isSalted)
11230 {
11231 salts_buf = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
11232
11233 if (esalt_size)
11234 {
11235 esalts_buf = (void *) mycalloc (hashes_avail, esalt_size);
11236 }
11237 }
11238 else
11239 {
11240 salts_buf = (salt_t *) mycalloc (1, sizeof (salt_t));
11241 }
11242
11243 for (uint hash_pos = 0; hash_pos < hashes_avail; hash_pos++)
11244 {
11245 hashes_buf[hash_pos].digest = ((char *) digests_buf) + (hash_pos * dgst_size);
11246
11247 if (isSalted)
11248 {
11249 hashes_buf[hash_pos].salt = &salts_buf[hash_pos];
11250
11251 if (esalt_size)
11252 {
11253 hashes_buf[hash_pos].esalt = ((char *) esalts_buf) + (hash_pos * esalt_size);
11254 }
11255 }
11256 else
11257 {
11258 hashes_buf[hash_pos].salt = &salts_buf[0];
11259 }
11260 }
11261
11262 /**
11263 * load hashes, part III: parse hashes or generate them if benchmark
11264 */
11265
11266 uint hashes_cnt = 0;
11267
11268 if (benchmark == 0)
11269 {
11270 if (keyspace == 1)
11271 {
11272 // useless to read hash file for keyspace, cheat a little bit w/ optind
11273 }
11274 else if (hashes_avail == 0)
11275 {
11276 }
11277 else if (hashlist_mode == HL_MODE_ARG)
11278 {
11279 char *input_buf = myargv[optind];
11280
11281 uint input_len = strlen (input_buf);
11282
11283 logfile_top_var_string ("target", input_buf);
11284
11285 char *hash_buf = NULL;
11286 int hash_len = 0;
11287
11288 hlfmt_hash (hashlist_format, input_buf, input_len, &hash_buf, &hash_len);
11289
11290 if (hash_len)
11291 {
11292 if (opts_type & OPTS_TYPE_HASH_COPY)
11293 {
11294 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
11295
11296 hash_info_tmp->orighash = mystrdup (hash_buf);
11297 }
11298
11299 if (isSalted)
11300 {
11301 memset (hashes_buf[0].salt, 0, sizeof (salt_t));
11302 }
11303
11304 int parser_status = PARSER_OK;
11305
11306 if (hash_mode == 2500)
11307 {
11308 if (hash_len == 0)
11309 {
11310 log_error ("ERROR: hccap file not specified");
11311
11312 return (-1);
11313 }
11314
11315 hashlist_mode = HL_MODE_FILE;
11316
11317 data.hashlist_mode = hashlist_mode;
11318
11319 FILE *fp = fopen (hash_buf, "rb");
11320
11321 if (fp == NULL)
11322 {
11323 log_error ("ERROR: %s: %s", hash_buf, strerror (errno));
11324
11325 return (-1);
11326 }
11327
11328 if (hashes_avail < 1)
11329 {
11330 log_error ("ERROR: hccap file is empty or corrupt");
11331
11332 fclose (fp);
11333
11334 return (-1);
11335 }
11336
11337 uint hccap_size = sizeof (hccap_t);
11338
11339 char in[hccap_size];
11340
11341 while (!feof (fp))
11342 {
11343 int n = fread (&in, hccap_size, 1, fp);
11344
11345 if (n != 1)
11346 {
11347 if (hashes_cnt < 1) parser_status = PARSER_HCCAP_FILE_SIZE;
11348
11349 break;
11350 }
11351
11352 parser_status = parse_func (in, hccap_size, &hashes_buf[hashes_cnt]);
11353
11354 if (parser_status != PARSER_OK)
11355 {
11356 log_info ("WARNING: Hash '%s': %s", hash_buf, strparser (parser_status));
11357
11358 continue;
11359 }
11360
11361 // hack: append MAC1 and MAC2 s.t. in --show and --left the line matches with the .pot file format (i.e. ESSID:MAC1:MAC2)
11362
11363 if ((show == 1) || (left == 1))
11364 {
11365 salt_t *tmp_salt = hashes_buf[hashes_cnt].salt;
11366
11367 char *salt_ptr = (char *) tmp_salt->salt_buf;
11368
11369 int cur_pos = tmp_salt->salt_len;
11370 int rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
11371
11372 wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt;
11373
11374 unsigned char *pke_ptr = (unsigned char *) wpa->pke;
11375
11376 // do the appending task
11377
11378 snprintf (salt_ptr + cur_pos,
11379 rem_len,
11380 ":%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
11381 pke_ptr[20], pke_ptr[27], pke_ptr[26], pke_ptr[25], pke_ptr[24], pke_ptr[31], // MAC1
11382 pke_ptr[30], pke_ptr[29], pke_ptr[28], pke_ptr[35], pke_ptr[34], pke_ptr[33]); // MAC2
11383
11384
11385 // memset () the remaining part of the salt
11386
11387 cur_pos = tmp_salt->salt_len + 1 + 12 + 1 + 12;
11388 rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
11389
11390 if (rem_len > 0) memset (salt_ptr + cur_pos, 0, rem_len);
11391
11392 tmp_salt->salt_len += 1 + 12 + 1 + 12;
11393 }
11394
11395 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);
11396 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);
11397
11398 hashes_cnt++;
11399 }
11400
11401 fclose (fp);
11402 }
11403 else if (hash_mode == 3000)
11404 {
11405 if (hash_len == 32)
11406 {
11407 parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
11408
11409 hash_t *lm_hash_left = NULL;
11410
11411 if (parser_status == PARSER_OK)
11412 {
11413 lm_hash_left = &hashes_buf[hashes_cnt];
11414
11415 hashes_cnt++;
11416 }
11417 else
11418 {
11419 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11420 }
11421
11422
11423 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
11424
11425 hash_t *lm_hash_right = NULL;
11426
11427 if (parser_status == PARSER_OK)
11428 {
11429 lm_hash_right = &hashes_buf[hashes_cnt];
11430
11431 hashes_cnt++;
11432 }
11433 else
11434 {
11435 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11436 }
11437
11438 // show / left
11439
11440 if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
11441 {
11442 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);
11443 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);
11444 }
11445 }
11446 else
11447 {
11448 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11449
11450 if (parser_status == PARSER_OK)
11451 {
11452 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11453 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11454 }
11455
11456 if (parser_status == PARSER_OK)
11457 {
11458 hashes_cnt++;
11459 }
11460 else
11461 {
11462 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11463 }
11464 }
11465 }
11466 else
11467 {
11468 parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11469
11470 if (parser_status == PARSER_OK)
11471 {
11472 if (show == 1) handle_show_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11473 if (left == 1) handle_left_request (pot, pot_cnt, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11474 }
11475
11476 if (parser_status == PARSER_OK)
11477 {
11478 hashes_cnt++;
11479 }
11480 else
11481 {
11482 log_info ("WARNING: Hash '%s': %s", input_buf, strparser (parser_status));
11483 }
11484 }
11485 }
11486 }
11487 else if (hashlist_mode == HL_MODE_FILE)
11488 {
11489 char *hashfile = data.hashfile;
11490
11491 FILE *fp;
11492
11493 if ((fp = fopen (hashfile, "rb")) == NULL)
11494 {
11495 log_error ("ERROR: %s: %s", hashfile, strerror (errno));
11496
11497 return (-1);
11498 }
11499
11500 uint line_num = 0;
11501
11502 while (!feof (fp))
11503 {
11504 line_num++;
11505
11506 char line_buf[BUFSIZ];
11507
11508 int line_len = fgetl (fp, line_buf);
11509
11510 if (line_len == 0) continue;
11511
11512 char *hash_buf = NULL;
11513 int hash_len = 0;
11514
11515 hlfmt_hash (hashlist_format, line_buf, line_len, &hash_buf, &hash_len);
11516
11517 if (username)
11518 {
11519 char *user_buf = NULL;
11520 int user_len = 0;
11521
11522 hlfmt_user (hashlist_format, line_buf, line_len, &user_buf, &user_len);
11523
11524 if (remove || show)
11525 {
11526 user_t **user = &hashes_buf[hashes_cnt].hash_info->user;
11527
11528 *user = (user_t *) malloc (sizeof (user_t));
11529
11530 user_t *user_ptr = *user;
11531
11532 if (user_buf != NULL)
11533 {
11534 user_ptr->user_name = mystrdup (user_buf);
11535 }
11536 else
11537 {
11538 user_ptr->user_name = mystrdup ("");
11539 }
11540
11541 user_ptr->user_len = user_len;
11542 }
11543 }
11544
11545 if (opts_type & OPTS_TYPE_HASH_COPY)
11546 {
11547 hashinfo_t *hash_info_tmp = hashes_buf[hashes_cnt].hash_info;
11548
11549 hash_info_tmp->orighash = mystrdup (hash_buf);
11550 }
11551
11552 if (isSalted)
11553 {
11554 memset (hashes_buf[hashes_cnt].salt, 0, sizeof (salt_t));
11555 }
11556
11557 if (hash_mode == 3000)
11558 {
11559 if (hash_len == 32)
11560 {
11561 int parser_status = parse_func (hash_buf, 16, &hashes_buf[hashes_cnt]);
11562
11563 if (parser_status < PARSER_GLOBAL_ZERO)
11564 {
11565 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11566
11567 continue;
11568 }
11569
11570 hash_t *lm_hash_left = &hashes_buf[hashes_cnt];
11571
11572 hashes_cnt++;
11573
11574 parser_status = parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt]);
11575
11576 if (parser_status < PARSER_GLOBAL_ZERO)
11577 {
11578 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11579
11580 continue;
11581 }
11582
11583 hash_t *lm_hash_right = &hashes_buf[hashes_cnt];
11584
11585 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);
11586
11587 hashes_cnt++;
11588
11589 // show / left
11590
11591 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);
11592 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);
11593 }
11594 else
11595 {
11596 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11597
11598 if (parser_status < PARSER_GLOBAL_ZERO)
11599 {
11600 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11601
11602 continue;
11603 }
11604
11605 if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((float) hashes_cnt / hashes_avail) * 100);
11606
11607 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11608 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11609
11610 hashes_cnt++;
11611 }
11612 }
11613 else
11614 {
11615 int parser_status = parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt]);
11616
11617 if (parser_status < PARSER_GLOBAL_ZERO)
11618 {
11619 log_info ("WARNING: Hashfile '%s' in line %u (%s): %s", data.hashfile, line_num, line_buf, strparser (parser_status));
11620
11621 continue;
11622 }
11623
11624 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);
11625
11626 if (show == 1) handle_show_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11627 if (left == 1) handle_left_request (pot, pot_cnt, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot, out_fp);
11628
11629 hashes_cnt++;
11630 }
11631 }
11632
11633 fclose (fp);
11634
11635 if (data.quiet == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
11636
11637 if ((out_fp != NULL) && (out_fp != stdout)) fclose (out_fp);
11638 }
11639 }
11640 else
11641 {
11642 if (isSalted)
11643 {
11644 hashes_buf[0].salt->salt_len = 8;
11645
11646 // special salt handling
11647
11648 switch (hash_mode)
11649 {
11650 case 1500: hashes_buf[0].salt->salt_len = 2;
11651 break;
11652 case 1731: hashes_buf[0].salt->salt_len = 4;
11653 break;
11654 case 2410: hashes_buf[0].salt->salt_len = 4;
11655 break;
11656 case 2500: memcpy (hashes_buf[0].salt->salt_buf, "hashcat.net", 11);
11657 break;
11658 case 3100: hashes_buf[0].salt->salt_len = 1;
11659 break;
11660 case 5000: hashes_buf[0].salt->keccak_mdlen = 32;
11661 break;
11662 case 5800: hashes_buf[0].salt->salt_len = 16;
11663 break;
11664 case 6800: hashes_buf[0].salt->salt_len = 32;
11665 break;
11666 case 8400: hashes_buf[0].salt->salt_len = 40;
11667 break;
11668 case 8800: hashes_buf[0].salt->salt_len = 16;
11669 break;
11670 case 8900: hashes_buf[0].salt->salt_len = 16;
11671 hashes_buf[0].salt->scrypt_N = 1024;
11672 hashes_buf[0].salt->scrypt_r = 1;
11673 hashes_buf[0].salt->scrypt_p = 1;
11674 break;
11675 case 9100: hashes_buf[0].salt->salt_len = 16;
11676 break;
11677 case 9300: hashes_buf[0].salt->salt_len = 14;
11678 hashes_buf[0].salt->scrypt_N = 16384;
11679 hashes_buf[0].salt->scrypt_r = 1;
11680 hashes_buf[0].salt->scrypt_p = 1;
11681 break;
11682 case 9400: hashes_buf[0].salt->salt_len = 16;
11683 break;
11684 case 9500: hashes_buf[0].salt->salt_len = 16;
11685 break;
11686 case 9600: hashes_buf[0].salt->salt_len = 16;
11687 break;
11688 case 9700: hashes_buf[0].salt->salt_len = 16;
11689 break;
11690 case 9710: hashes_buf[0].salt->salt_len = 16;
11691 break;
11692 case 9720: hashes_buf[0].salt->salt_len = 16;
11693 break;
11694 case 9800: hashes_buf[0].salt->salt_len = 16;
11695 break;
11696 case 9810: hashes_buf[0].salt->salt_len = 16;
11697 break;
11698 case 9820: hashes_buf[0].salt->salt_len = 16;
11699 break;
11700 case 10300: hashes_buf[0].salt->salt_len = 12;
11701 break;
11702 case 11500: hashes_buf[0].salt->salt_len = 4;
11703 break;
11704 case 11600: hashes_buf[0].salt->salt_len = 4;
11705 break;
11706 case 12400: hashes_buf[0].salt->salt_len = 4;
11707 break;
11708 case 12500: hashes_buf[0].salt->salt_len = 8;
11709 break;
11710 case 12600: hashes_buf[0].salt->salt_len = 64;
11711 break;
11712 }
11713
11714 // special esalt handling
11715
11716 switch (hash_mode)
11717 {
11718 case 2500: ((wpa_t *) hashes_buf[0].esalt)->eapol_size = 128;
11719 break;
11720 case 5300: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
11721 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
11722 break;
11723 case 5400: ((ikepsk_t *) hashes_buf[0].esalt)->nr_len = 1;
11724 ((ikepsk_t *) hashes_buf[0].esalt)->msg_len = 1;
11725 break;
11726 case 5500: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
11727 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
11728 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
11729 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
11730 break;
11731 case 5600: ((netntlm_t *) hashes_buf[0].esalt)->user_len = 1;
11732 ((netntlm_t *) hashes_buf[0].esalt)->domain_len = 1;
11733 ((netntlm_t *) hashes_buf[0].esalt)->srvchall_len = 1;
11734 ((netntlm_t *) hashes_buf[0].esalt)->clichall_len = 1;
11735 break;
11736 case 7300: ((rakp_t *) hashes_buf[0].esalt)->salt_len = 32;
11737 break;
11738 case 10400: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11739 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11740 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11741 break;
11742 case 10410: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11743 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11744 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11745 break;
11746 case 10420: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11747 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11748 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11749 break;
11750 case 10500: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11751 ((pdf_t *) hashes_buf[0].esalt)->o_len = 32;
11752 ((pdf_t *) hashes_buf[0].esalt)->u_len = 32;
11753 break;
11754 case 10600: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11755 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
11756 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
11757 break;
11758 case 10700: ((pdf_t *) hashes_buf[0].esalt)->id_len = 16;
11759 ((pdf_t *) hashes_buf[0].esalt)->o_len = 127;
11760 ((pdf_t *) hashes_buf[0].esalt)->u_len = 127;
11761 break;
11762 case 11600: ((seven_zip_t *) hashes_buf[0].esalt)->iv_len = 16;
11763 ((seven_zip_t *) hashes_buf[0].esalt)->data_len = 112;
11764 ((seven_zip_t *) hashes_buf[0].esalt)->unpack_size = 112;
11765 break;
11766 }
11767 }
11768
11769 // set hashfile
11770
11771 switch (hash_mode)
11772 {
11773 case 5200: data.hashfile = mystrdup ("hashcat.psafe3");
11774 break;
11775 case 5300: data.hashfile = mystrdup ("hashcat.ikemd5");
11776 break;
11777 case 5400: data.hashfile = mystrdup ("hashcat.ikesha1");
11778 break;
11779 case 6211:
11780 case 6212:
11781 case 6213:
11782 case 6221:
11783 case 6222:
11784 case 6223:
11785 case 6231:
11786 case 6232:
11787 case 6233:
11788 case 6241:
11789 case 6242:
11790 case 6243: data.hashfile = mystrdup ("hashcat.tc");
11791 break;
11792 case 6600: data.hashfile = mystrdup ("hashcat.agilekey");
11793 break;
11794 case 8200: data.hashfile = mystrdup ("hashcat.cloudkey");
11795 break;
11796 case 9000: data.hashfile = mystrdup ("hashcat.psafe2");
11797 break;
11798 }
11799
11800 // set default iterations
11801
11802 switch (hash_mode)
11803 {
11804 case 400: hashes_buf[0].salt->salt_iter = ROUNDS_PHPASS;
11805 break;
11806 case 500: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11807 break;
11808 case 501: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11809 break;
11810 case 1600: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11811 break;
11812 case 1800: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512CRYPT;
11813 break;
11814 case 2100: hashes_buf[0].salt->salt_iter = ROUNDS_DCC2;
11815 break;
11816 case 2500: hashes_buf[0].salt->salt_iter = ROUNDS_WPA2;
11817 break;
11818 case 3200: hashes_buf[0].salt->salt_iter = ROUNDS_BCRYPT;
11819 break;
11820 case 5200: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE3;
11821 break;
11822 case 5800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDPIN - 1;
11823 break;
11824 case 6211:
11825 case 6212:
11826 case 6213: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_2K;
11827 break;
11828 case 6221:
11829 case 6222:
11830 case 6223: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11831 break;
11832 case 6231:
11833 case 6232:
11834 case 6233: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11835 break;
11836 case 6241:
11837 case 6242:
11838 case 6243: hashes_buf[0].salt->salt_iter = ROUNDS_TRUECRYPT_1K;
11839 break;
11840 case 6300: hashes_buf[0].salt->salt_iter = ROUNDS_MD5CRYPT;
11841 break;
11842 case 6400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256AIX;
11843 break;
11844 case 6500: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512AIX;
11845 break;
11846 case 6700: hashes_buf[0].salt->salt_iter = ROUNDS_SHA1AIX;
11847 break;
11848 case 6600: hashes_buf[0].salt->salt_iter = ROUNDS_AGILEKEY;
11849 break;
11850 case 6800: hashes_buf[0].salt->salt_iter = ROUNDS_LASTPASS;
11851 break;
11852 case 7100: hashes_buf[0].salt->salt_iter = ROUNDS_SHA512OSX;
11853 break;
11854 case 7200: hashes_buf[0].salt->salt_iter = ROUNDS_GRUB;
11855 break;
11856 case 7400: hashes_buf[0].salt->salt_iter = ROUNDS_SHA256CRYPT;
11857 break;
11858 case 7900: hashes_buf[0].salt->salt_iter = ROUNDS_DRUPAL7;
11859 break;
11860 case 8200: hashes_buf[0].salt->salt_iter = ROUNDS_CLOUDKEY;
11861 break;
11862 case 8300: hashes_buf[0].salt->salt_iter = ROUNDS_NSEC3;
11863 break;
11864 case 8800: hashes_buf[0].salt->salt_iter = ROUNDS_ANDROIDFDE;
11865 break;
11866 case 8900: hashes_buf[0].salt->salt_iter = 1;
11867 break;
11868 case 9000: hashes_buf[0].salt->salt_iter = ROUNDS_PSAFE2;
11869 break;
11870 case 9100: hashes_buf[0].salt->salt_iter = ROUNDS_LOTUS8;
11871 break;
11872 case 9200: hashes_buf[0].salt->salt_iter = ROUNDS_CISCO8;
11873 break;
11874 case 9300: hashes_buf[0].salt->salt_iter = 1;
11875 break;
11876 case 9400: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2007;
11877 break;
11878 case 9500: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2010;
11879 break;
11880 case 9600: hashes_buf[0].salt->salt_iter = ROUNDS_OFFICE2013;
11881 break;
11882 case 10000: hashes_buf[0].salt->salt_iter = ROUNDS_DJANGOPBKDF2;
11883 break;
11884 case 10300: hashes_buf[0].salt->salt_iter = ROUNDS_SAPH_SHA1 - 1;
11885 break;
11886 case 10500: hashes_buf[0].salt->salt_iter = ROUNDS_PDF14;
11887 break;
11888 case 10700: hashes_buf[0].salt->salt_iter = ROUNDS_PDF17L8;
11889 break;
11890 case 10900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA256 - 1;
11891 break;
11892 case 11300: hashes_buf[0].salt->salt_iter = ROUNDS_BITCOIN_WALLET - 1;
11893 break;
11894 case 11600: hashes_buf[0].salt->salt_iter = ROUNDS_SEVEN_ZIP;
11895 break;
11896 case 11900: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_MD5 - 1;
11897 break;
11898 case 12000: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA1 - 1;
11899 break;
11900 case 12100: hashes_buf[0].salt->salt_iter = ROUNDS_PBKDF2_SHA512 - 1;
11901 break;
11902 case 12200: hashes_buf[0].salt->salt_iter = ROUNDS_ECRYPTFS - 1;
11903 break;
11904 case 12300: hashes_buf[0].salt->salt_iter = ROUNDS_ORACLET - 1;
11905 break;
11906 case 12400: hashes_buf[0].salt->salt_iter = ROUNDS_BSDICRYPT - 1;
11907 break;
11908 case 12500: hashes_buf[0].salt->salt_iter = ROUNDS_RAR3;
11909 break;
11910 case 12700: hashes_buf[0].salt->salt_iter = ROUNDS_MYWALLET;
11911 break;
11912 case 12800: hashes_buf[0].salt->salt_iter = ROUNDS_MS_DRSR - 1;
11913 break;
11914 }
11915
11916 // set special tuning for benchmark-mode 1
11917
11918 if (benchmark_mode == 1)
11919 {
11920 gpu_loops *= 8;
11921 gpu_accel *= 4;
11922
11923 switch (hash_mode)
11924 {
11925 case 400: gpu_loops = ROUNDS_PHPASS;
11926 gpu_accel = 32;
11927 break;
11928 case 500: gpu_loops = ROUNDS_MD5CRYPT;
11929 gpu_accel = 32;
11930 break;
11931 case 501: gpu_loops = ROUNDS_MD5CRYPT;
11932 gpu_accel = 32;
11933 break;
11934 case 1600: gpu_loops = ROUNDS_MD5CRYPT;
11935 gpu_accel = 32;
11936 break;
11937 case 1800: gpu_loops = ROUNDS_SHA512CRYPT;
11938 gpu_accel = 8;
11939 break;
11940 case 2100: gpu_loops = ROUNDS_DCC2;
11941 gpu_accel = 16;
11942 break;
11943 case 2500: gpu_loops = ROUNDS_WPA2;
11944 gpu_accel = 32;
11945 break;
11946 case 3200: gpu_loops = ROUNDS_BCRYPT;
11947 gpu_accel = 2;
11948 break;
11949 case 5200: gpu_loops = ROUNDS_PSAFE3;
11950 gpu_accel = 16;
11951 break;
11952 case 5800: gpu_loops = ROUNDS_ANDROIDPIN;
11953 gpu_accel = 16;
11954 break;
11955 case 6211: gpu_loops = ROUNDS_TRUECRYPT_2K;
11956 gpu_accel = 64;
11957 break;
11958 case 6212: gpu_loops = ROUNDS_TRUECRYPT_2K;
11959 gpu_accel = 32;
11960 break;
11961 case 6213: gpu_loops = ROUNDS_TRUECRYPT_2K;
11962 gpu_accel = 32;
11963 break;
11964 case 6221: gpu_loops = ROUNDS_TRUECRYPT_1K;
11965 gpu_accel = 8;
11966 break;
11967 case 6222: gpu_loops = ROUNDS_TRUECRYPT_1K;
11968 gpu_accel = 8;
11969 break;
11970 case 6223: gpu_loops = ROUNDS_TRUECRYPT_1K;
11971 gpu_accel = 8;
11972 break;
11973 case 6231: gpu_loops = ROUNDS_TRUECRYPT_1K;
11974 gpu_accel = 8;
11975 break;
11976 case 6232: gpu_loops = ROUNDS_TRUECRYPT_1K;
11977 gpu_accel = 8;
11978 break;
11979 case 6233: gpu_loops = ROUNDS_TRUECRYPT_1K;
11980 gpu_accel = 8;
11981 break;
11982 case 6241: gpu_loops = ROUNDS_TRUECRYPT_1K;
11983 gpu_accel = 128;
11984 break;
11985 case 6242: gpu_loops = ROUNDS_TRUECRYPT_1K;
11986 gpu_accel = 64;
11987 break;
11988 case 6243: gpu_loops = ROUNDS_TRUECRYPT_1K;
11989 gpu_accel = 64;
11990 break;
11991 case 6300: gpu_loops = ROUNDS_MD5CRYPT;
11992 gpu_accel = 32;
11993 break;
11994 case 6700: gpu_loops = ROUNDS_SHA1AIX;
11995 gpu_accel = 128;
11996 break;
11997 case 6400: gpu_loops = ROUNDS_SHA256AIX;
11998 gpu_accel = 128;
11999 break;
12000 case 6500: gpu_loops = ROUNDS_SHA512AIX;
12001 gpu_accel = 32;
12002 break;
12003 case 6600: gpu_loops = ROUNDS_AGILEKEY;
12004 gpu_accel = 64;
12005 break;
12006 case 6800: gpu_loops = ROUNDS_LASTPASS;
12007 gpu_accel = 64;
12008 break;
12009 case 7100: gpu_loops = ROUNDS_SHA512OSX;
12010 gpu_accel = 2;
12011 break;
12012 case 7200: gpu_loops = ROUNDS_GRUB;
12013 gpu_accel = 2;
12014 break;
12015 case 7400: gpu_loops = ROUNDS_SHA256CRYPT;
12016 gpu_accel = 4;
12017 break;
12018 case 7900: gpu_loops = ROUNDS_DRUPAL7;
12019 gpu_accel = 8;
12020 break;
12021 case 8200: gpu_loops = ROUNDS_CLOUDKEY;
12022 gpu_accel = 2;
12023 break;
12024 case 8800: gpu_loops = ROUNDS_ANDROIDFDE;
12025 gpu_accel = 32;
12026 break;
12027 case 8900: gpu_loops = 1;
12028 gpu_accel = 64;
12029 break;
12030 case 9000: gpu_loops = ROUNDS_PSAFE2;
12031 gpu_accel = 16;
12032 break;
12033 case 9100: gpu_loops = ROUNDS_LOTUS8;
12034 gpu_accel = 64;
12035 break;
12036 case 9200: gpu_loops = ROUNDS_CISCO8;
12037 gpu_accel = 8;
12038 break;
12039 case 9300: gpu_loops = 1;
12040 gpu_accel = 4;
12041 break;
12042 case 9400: gpu_loops = ROUNDS_OFFICE2007;
12043 gpu_accel = 32;
12044 break;
12045 case 9500: gpu_loops = ROUNDS_OFFICE2010;
12046 gpu_accel = 32;
12047 break;
12048 case 9600: gpu_loops = ROUNDS_OFFICE2013;
12049 gpu_accel = 4;
12050 break;
12051 case 10000: gpu_loops = ROUNDS_DJANGOPBKDF2;
12052 gpu_accel = 8;
12053 break;
12054 case 10300: gpu_loops = ROUNDS_SAPH_SHA1;
12055 gpu_accel = 16;
12056 break;
12057 case 10500: gpu_loops = ROUNDS_PDF14;
12058 gpu_accel = 256;
12059 break;
12060 case 10700: gpu_loops = ROUNDS_PDF17L8;
12061 gpu_accel = 8;
12062 break;
12063 case 10900: gpu_loops = ROUNDS_PBKDF2_SHA256;
12064 gpu_accel = 8;
12065 break;
12066 case 11300: gpu_loops = ROUNDS_BITCOIN_WALLET;
12067 gpu_accel = 2;
12068 break;
12069 case 11600: gpu_loops = ROUNDS_SEVEN_ZIP;
12070 gpu_accel = 4;
12071 break;
12072 case 11900: gpu_loops = ROUNDS_PBKDF2_MD5;
12073 gpu_accel = 8;
12074 break;
12075 case 12000: gpu_loops = ROUNDS_PBKDF2_SHA1;
12076 gpu_accel = 8;
12077 break;
12078 case 12100: gpu_loops = ROUNDS_PBKDF2_SHA512;
12079 gpu_accel = 8;
12080 break;
12081 case 12200: gpu_loops = ROUNDS_ECRYPTFS;
12082 gpu_accel = 8;
12083 break;
12084 case 12300: gpu_loops = ROUNDS_ORACLET;
12085 gpu_accel = 8;
12086 break;
12087 case 12500: gpu_loops = ROUNDS_RAR3;
12088 gpu_accel = 32;
12089 break;
12090 case 12700: gpu_loops = ROUNDS_MYWALLET;
12091 gpu_accel = 512;
12092 break;
12093 case 12800: gpu_loops = ROUNDS_MS_DRSR;
12094 gpu_accel = 512;
12095 break;
12096 }
12097
12098 // some algorithm collide too fast, make that impossible
12099
12100 switch (hash_mode)
12101 {
12102 case 11500: ((uint *) digests_buf)[1] = 1;
12103 break;
12104 }
12105
12106 if (gpu_loops > 1024) gpu_loops = 1024;
12107 if (gpu_accel > 256) gpu_accel = 256; // causes memory problems otherwise
12108 }
12109
12110 if ((opts_type & OPTS_TYPE_PT_BITSLICE) && (attack_mode == ATTACK_MODE_BF))
12111 {
12112 gpu_loops = 1024;
12113 }
12114
12115 if (hash_mode == 12500)
12116 {
12117 gpu_loops = ROUNDS_RAR3 / 16;
12118 }
12119
12120 data.gpu_accel = gpu_accel;
12121 data.gpu_loops = gpu_loops;
12122
12123 hashes_cnt = 1;
12124 }
12125
12126 if (show == 1 || left == 1)
12127 {
12128 for (uint i = 0; i < pot_cnt; i++)
12129 {
12130 pot_t *pot_ptr = &pot[i];
12131
12132 hash_t *hashes_buf = &pot_ptr->hash;
12133
12134 local_free (hashes_buf->digest);
12135
12136 if (isSalted)
12137 {
12138 local_free (hashes_buf->salt);
12139 }
12140 }
12141
12142 local_free (pot);
12143
12144 if (data.quiet == 0) log_info_nn ("");
12145
12146 return (0);
12147 }
12148
12149 if (keyspace == 0)
12150 {
12151 if (hashes_cnt == 0)
12152 {
12153 log_error ("ERROR: No hashes loaded");
12154
12155 return (-1);
12156 }
12157 }
12158
12159 /**
12160 * Sanity check for hashfile vs outfile (should not point to the same physical file)
12161 */
12162
12163 if (data.outfile != NULL)
12164 {
12165 if (data.hashfile != NULL)
12166 {
12167 #ifdef _POSIX
12168 struct stat tmpstat_outfile;
12169 struct stat tmpstat_hashfile;
12170 #endif
12171
12172 #ifdef _WIN
12173 struct stat64 tmpstat_outfile;
12174 struct stat64 tmpstat_hashfile;
12175 #endif
12176
12177 FILE *tmp_outfile_fp = fopen (data.outfile, "r");
12178
12179 if (tmp_outfile_fp)
12180 {
12181 #ifdef _POSIX
12182 fstat (fileno (tmp_outfile_fp), &tmpstat_outfile);
12183 #endif
12184
12185 #ifdef _WIN
12186 _fstat64 (fileno (tmp_outfile_fp), &tmpstat_outfile);
12187 #endif
12188
12189 fclose (tmp_outfile_fp);
12190 }
12191
12192 FILE *tmp_hashfile_fp = fopen (data.hashfile, "r");
12193
12194 if (tmp_hashfile_fp)
12195 {
12196 #ifdef _POSIX
12197 fstat (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
12198 #endif
12199
12200 #ifdef _WIN
12201 _fstat64 (fileno (tmp_hashfile_fp), &tmpstat_hashfile);
12202 #endif
12203
12204 fclose (tmp_hashfile_fp);
12205 }
12206
12207 if (tmp_outfile_fp && tmp_outfile_fp)
12208 {
12209 tmpstat_outfile.st_mode = 0;
12210 tmpstat_outfile.st_nlink = 0;
12211 tmpstat_outfile.st_uid = 0;
12212 tmpstat_outfile.st_gid = 0;
12213 tmpstat_outfile.st_rdev = 0;
12214 tmpstat_outfile.st_atime = 0;
12215
12216 tmpstat_hashfile.st_mode = 0;
12217 tmpstat_hashfile.st_nlink = 0;
12218 tmpstat_hashfile.st_uid = 0;
12219 tmpstat_hashfile.st_gid = 0;
12220 tmpstat_hashfile.st_rdev = 0;
12221 tmpstat_hashfile.st_atime = 0;
12222
12223 #ifdef _POSIX
12224 tmpstat_outfile.st_blksize = 0;
12225 tmpstat_outfile.st_blocks = 0;
12226
12227 tmpstat_hashfile.st_blksize = 0;
12228 tmpstat_hashfile.st_blocks = 0;
12229 #endif
12230
12231 #ifdef _POSIX
12232 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat)) == 0)
12233 {
12234 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
12235
12236 return (-1);
12237 }
12238 #endif
12239
12240 #ifdef _WIN
12241 if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (struct stat64)) == 0)
12242 {
12243 log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
12244
12245 return (-1);
12246 }
12247 #endif
12248 }
12249 }
12250 }
12251
12252 /**
12253 * Remove duplicates
12254 */
12255
12256 if (data.quiet == 0) log_info_nn ("Removing duplicate hashes...");
12257
12258 if (isSalted)
12259 {
12260 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
12261 }
12262 else
12263 {
12264 qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
12265 }
12266
12267 uint hashes_cnt_orig = hashes_cnt;
12268
12269 hashes_cnt = 1;
12270
12271 for (uint hashes_pos = 1; hashes_pos < hashes_cnt_orig; hashes_pos++)
12272 {
12273 if (isSalted)
12274 {
12275 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) == 0)
12276 {
12277 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
12278 }
12279 }
12280 else
12281 {
12282 if (sort_by_digest (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
12283 }
12284
12285 if (hashes_pos > hashes_cnt)
12286 {
12287 memcpy (&hashes_buf[hashes_cnt], &hashes_buf[hashes_pos], sizeof (hash_t));
12288 }
12289
12290 hashes_cnt++;
12291 }
12292
12293 /**
12294 * Potfile removes
12295 */
12296
12297 uint potfile_remove_cracks = 0;
12298
12299 if (potfile_disable == 0)
12300 {
12301 hash_t hash_buf;
12302
12303 hash_buf.digest = mymalloc (dgst_size);
12304 hash_buf.salt = NULL;
12305 hash_buf.esalt = NULL;
12306 hash_buf.hash_info = NULL;
12307 hash_buf.cracked = 0;
12308
12309 if (isSalted)
12310 {
12311 hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
12312 }
12313
12314 if (esalt_size)
12315 {
12316 hash_buf.esalt = mymalloc (esalt_size);
12317 }
12318
12319 if (quiet == 0) log_info_nn ("Comparing hashes with potfile entries...");
12320
12321 // no solution for these special hash types (for instane because they use hashfile in output etc)
12322 if ((hash_mode != 5200) &&
12323 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
12324 (hash_mode != 9000))
12325 {
12326 FILE *fp = fopen (potfile, "rb");
12327
12328 if (fp != NULL)
12329 {
12330 while (!feof (fp))
12331 {
12332 char line_buf[BUFSIZ];
12333
12334 memset (line_buf, 0, BUFSIZ);
12335
12336 char *ptr = fgets (line_buf, BUFSIZ - 1, fp);
12337
12338 if (ptr == NULL) break;
12339
12340 int line_len = strlen (line_buf);
12341
12342 if (line_len == 0) continue;
12343
12344 int iter = MAX_CUT_TRIES;
12345
12346 for (int i = line_len - 1; i && iter; i--, line_len--)
12347 {
12348 if (line_buf[i] != ':') continue;
12349
12350 if (isSalted)
12351 {
12352 memset (hash_buf.salt, 0, sizeof (salt_t));
12353 }
12354
12355 hash_t *found = NULL;
12356
12357 if (hash_mode == 6800)
12358 {
12359 if (i < 48) // 48 = 12 * uint in salt_buf[]
12360 {
12361 // manipulate salt_buf
12362 memcpy (hash_buf.salt->salt_buf, line_buf, i);
12363
12364 hash_buf.salt->salt_len = i;
12365
12366 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt);
12367 }
12368 }
12369 else if (hash_mode == 2500)
12370 {
12371 if (i < 48) // 48 = 12 * uint in salt_buf[]
12372 {
12373 // here we have in line_buf: ESSID:MAC1:MAC2 (without the plain)
12374 // manipulate salt_buf
12375
12376 // to be safe work with a copy (because of line_len loop, i etc)
12377
12378 char line_buf_cpy[BUFSIZ];
12379 memset (line_buf_cpy, 0, BUFSIZ);
12380
12381 memset (line_buf_cpy, 0, sizeof (line_buf_cpy));
12382
12383 memcpy (line_buf_cpy, line_buf, i);
12384
12385 char *mac2_pos = strrchr (line_buf_cpy, ':');
12386
12387 if (mac2_pos == NULL) continue;
12388
12389 mac2_pos[0] = 0;
12390 mac2_pos++;
12391
12392 if (strlen (mac2_pos) != 12) continue;
12393
12394 char *mac1_pos = strrchr (line_buf_cpy, ':');
12395
12396 if (mac1_pos == NULL) continue;
12397
12398 mac1_pos[0] = 0;
12399 mac1_pos++;
12400
12401 if (strlen (mac1_pos) != 12) continue;
12402
12403 uint essid_length = mac1_pos - line_buf_cpy - 1;
12404
12405 // here we need the ESSID
12406 memcpy (hash_buf.salt->salt_buf, line_buf_cpy, essid_length);
12407
12408 hash_buf.salt->salt_len = essid_length;
12409
12410 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_t_salt_hccap);
12411
12412 if (found)
12413 {
12414 wpa_t *wpa = (wpa_t *) found->esalt;
12415
12416 uint pke[25];
12417
12418 char *pke_ptr = (char *) pke;
12419
12420 for (uint i = 0; i < 25; i++)
12421 {
12422 pke[i] = byte_swap_32 (wpa->pke[i]);
12423 }
12424
12425 unsigned char mac1[6];
12426 unsigned char mac2[6];
12427
12428 memcpy (mac1, pke_ptr + 23, 6);
12429 memcpy (mac2, pke_ptr + 29, 6);
12430
12431 // compare hex string(s) vs binary MAC address(es)
12432
12433 for (uint i = 0, j = 0; i < 6; i++, j += 2)
12434 {
12435 if (mac1[i] != (unsigned char) hex_to_char (&mac1_pos[j]))
12436 {
12437 found = NULL;
12438 break;
12439 }
12440 }
12441
12442 // early skip ;)
12443 if (!found) continue;
12444
12445 for (uint i = 0, j = 0; i < 6; i++, j += 2)
12446 {
12447 if (mac2[i] != (unsigned char) hex_to_char (&mac2_pos[j]))
12448 {
12449 found = NULL;
12450 break;
12451 }
12452 }
12453 }
12454 }
12455 }
12456 else
12457 {
12458 int parser_status = parse_func (line_buf, line_len - 1, &hash_buf);
12459
12460 if (parser_status == PARSER_OK)
12461 {
12462 if (isSalted)
12463 {
12464 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
12465 }
12466 else
12467 {
12468 found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
12469 }
12470 }
12471 }
12472
12473 if (found == NULL) continue;
12474
12475 if (!found->cracked) potfile_remove_cracks++;
12476
12477 found->cracked = 1;
12478
12479 if (found) break;
12480
12481 iter--;
12482 }
12483 }
12484
12485 fclose (fp);
12486 }
12487 }
12488
12489 if (esalt_size)
12490 {
12491 local_free (hash_buf.esalt);
12492 }
12493
12494 if (isSalted)
12495 {
12496 local_free (hash_buf.salt);
12497 }
12498
12499 local_free (hash_buf.digest);
12500 }
12501
12502 /**
12503 * Now generate all the buffers required for later
12504 */
12505
12506 void *digests_buf_new = (void *) mycalloc (hashes_avail, dgst_size);
12507
12508 salt_t *salts_buf_new = NULL;
12509 void *esalts_buf_new = NULL;
12510
12511 if (isSalted)
12512 {
12513 salts_buf_new = (salt_t *) mycalloc (hashes_avail, sizeof (salt_t));
12514
12515 if (esalt_size)
12516 {
12517 esalts_buf_new = (void *) mycalloc (hashes_avail, esalt_size);
12518 }
12519 }
12520 else
12521 {
12522 salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t));
12523 }
12524
12525 if (data.quiet == 0) log_info_nn ("Structuring salts for cracking task...");
12526
12527 uint digests_cnt = hashes_cnt;
12528 uint digests_done = 0;
12529
12530 uint size_digests = digests_cnt * dgst_size;
12531 uint size_shown = digests_cnt * sizeof (uint);
12532
12533 uint *digests_shown = (uint *) mymalloc (size_shown);
12534 uint *digests_shown_tmp = (uint *) mymalloc (size_shown);
12535
12536 uint salts_cnt = 0;
12537 uint salts_done = 0;
12538
12539 hashinfo_t **hash_info = NULL;
12540
12541 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12542 {
12543 hash_info = (hashinfo_t**) mymalloc (hashes_cnt * sizeof (hashinfo_t *));
12544
12545 if (username && (remove || show))
12546 {
12547 uint user_pos;
12548
12549 for (user_pos = 0; user_pos < hashes_cnt; user_pos++)
12550 {
12551 hash_info[user_pos] = (hashinfo_t*) mycalloc (hashes_cnt, sizeof (hashinfo_t));
12552
12553 hash_info[user_pos]->user = (user_t*) mymalloc (sizeof (user_t));
12554 }
12555 }
12556 }
12557
12558 uint *salts_shown = (uint *) mymalloc (size_shown);
12559
12560 salt_t *salt_buf;
12561
12562 {
12563 // copied from inner loop
12564
12565 salt_buf = &salts_buf_new[salts_cnt];
12566
12567 memcpy (salt_buf, hashes_buf[0].salt, sizeof (salt_t));
12568
12569 if (esalt_size)
12570 {
12571 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[0].esalt, esalt_size);
12572 }
12573
12574 salt_buf->digests_cnt = 0;
12575 salt_buf->digests_done = 0;
12576 salt_buf->digests_offset = 0;
12577
12578 salts_cnt++;
12579 }
12580
12581 if (hashes_buf[0].cracked == 1)
12582 {
12583 digests_shown[0] = 1;
12584
12585 digests_done++;
12586
12587 salt_buf->digests_done++;
12588 }
12589
12590 salt_buf->digests_cnt++;
12591
12592 memcpy (((char *) digests_buf_new) + (0 * dgst_size), hashes_buf[0].digest, dgst_size);
12593
12594 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12595 {
12596 hash_info[0] = hashes_buf[0].hash_info;
12597 }
12598
12599 // copy from inner loop
12600
12601 for (uint hashes_pos = 1; hashes_pos < hashes_cnt; hashes_pos++)
12602 {
12603 if (isSalted)
12604 {
12605 if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) != 0)
12606 {
12607 salt_buf = &salts_buf_new[salts_cnt];
12608
12609 memcpy (salt_buf, hashes_buf[hashes_pos].salt, sizeof (salt_t));
12610
12611 if (esalt_size)
12612 {
12613 memcpy (((char *) esalts_buf_new) + (salts_cnt * esalt_size), hashes_buf[hashes_pos].esalt, esalt_size);
12614 }
12615
12616 salt_buf->digests_cnt = 0;
12617 salt_buf->digests_done = 0;
12618 salt_buf->digests_offset = hashes_pos;
12619
12620 salts_cnt++;
12621 }
12622 }
12623
12624 if (hashes_buf[hashes_pos].cracked == 1)
12625 {
12626 digests_shown[hashes_pos] = 1;
12627
12628 digests_done++;
12629
12630 salt_buf->digests_done++;
12631 }
12632
12633 salt_buf->digests_cnt++;
12634
12635 memcpy (((char *) digests_buf_new) + (hashes_pos * dgst_size), hashes_buf[hashes_pos].digest, dgst_size);
12636
12637 if ((username && (remove || show)) || (opts_type & OPTS_TYPE_HASH_COPY))
12638 {
12639 hash_info[hashes_pos] = hashes_buf[hashes_pos].hash_info;
12640 }
12641 }
12642
12643 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
12644 {
12645 salt_t *salt_buf = &salts_buf_new[salt_pos];
12646
12647 if (salt_buf->digests_done == salt_buf->digests_cnt)
12648 {
12649 salts_shown[salt_pos] = 1;
12650
12651 salts_done++;
12652 }
12653
12654 if (salts_done == salts_cnt) data.devices_status = STATUS_CRACKED;
12655 }
12656
12657 local_free (digests_buf);
12658 local_free (salts_buf);
12659 local_free (esalts_buf);
12660
12661 digests_buf = digests_buf_new;
12662 salts_buf = salts_buf_new;
12663 esalts_buf = esalts_buf_new;
12664
12665 local_free (hashes_buf);
12666
12667 /**
12668 * special modification not set from parser
12669 */
12670
12671 switch (hash_mode)
12672 {
12673 case 6211: salts_buf->truecrypt_mdlen = 1 * 512; break;
12674 case 6212: salts_buf->truecrypt_mdlen = 2 * 512; break;
12675 case 6213: salts_buf->truecrypt_mdlen = 3 * 512; break;
12676 case 6221: salts_buf->truecrypt_mdlen = 1 * 512; break;
12677 case 6222: salts_buf->truecrypt_mdlen = 2 * 512; break;
12678 case 6223: salts_buf->truecrypt_mdlen = 3 * 512; break;
12679 case 6231: salts_buf->truecrypt_mdlen = 1 * 512; break;
12680 case 6232: salts_buf->truecrypt_mdlen = 2 * 512; break;
12681 case 6233: salts_buf->truecrypt_mdlen = 3 * 512; break;
12682 case 6241: salts_buf->truecrypt_mdlen = 1 * 512; break;
12683 case 6242: salts_buf->truecrypt_mdlen = 2 * 512; break;
12684 case 6243: salts_buf->truecrypt_mdlen = 3 * 512; break;
12685 }
12686
12687 if (truecrypt_keyfiles)
12688 {
12689 uint *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf;
12690
12691 char *keyfiles = strdup (truecrypt_keyfiles);
12692
12693 char *keyfile = strtok (keyfiles, ",");
12694
12695 do
12696 {
12697 truecrypt_crc32 (keyfile, (unsigned char *) keyfile_buf);
12698
12699 } while ((keyfile = strtok (NULL, ",")) != NULL);
12700
12701 free (keyfiles);
12702 }
12703
12704 data.digests_cnt = digests_cnt;
12705 data.digests_done = digests_done;
12706 data.digests_buf = digests_buf;
12707 data.digests_shown = digests_shown;
12708 data.digests_shown_tmp = digests_shown_tmp;
12709
12710 data.salts_cnt = salts_cnt;
12711 data.salts_done = salts_done;
12712 data.salts_buf = salts_buf;
12713 data.salts_shown = salts_shown;
12714
12715 data.esalts_buf = esalts_buf;
12716 data.hash_info = hash_info;
12717
12718 /**
12719 * Automatic Optimizers
12720 */
12721
12722 if (salts_cnt == 1)
12723 opti_type |= OPTI_TYPE_SINGLE_SALT;
12724
12725 if (digests_cnt == 1)
12726 opti_type |= OPTI_TYPE_SINGLE_HASH;
12727
12728 if (attack_exec == ATTACK_EXEC_ON_GPU)
12729 opti_type |= OPTI_TYPE_NOT_ITERATED;
12730
12731 if (attack_mode == ATTACK_MODE_BF)
12732 opti_type |= OPTI_TYPE_BRUTE_FORCE;
12733
12734 data.opti_type = opti_type;
12735
12736 if (opti_type & OPTI_TYPE_BRUTE_FORCE)
12737 {
12738 if (opti_type & OPTI_TYPE_SINGLE_HASH)
12739 {
12740 if (opti_type & OPTI_TYPE_APPENDED_SALT)
12741 {
12742 if (opts_type & OPTS_TYPE_ST_ADD80)
12743 {
12744 opts_type &= ~OPTS_TYPE_ST_ADD80;
12745 opts_type |= OPTS_TYPE_PT_ADD80;
12746 }
12747
12748 if (opts_type & OPTS_TYPE_ST_ADDBITS14)
12749 {
12750 opts_type &= ~OPTS_TYPE_ST_ADDBITS14;
12751 opts_type |= OPTS_TYPE_PT_ADDBITS14;
12752 }
12753
12754 if (opts_type & OPTS_TYPE_ST_ADDBITS15)
12755 {
12756 opts_type &= ~OPTS_TYPE_ST_ADDBITS15;
12757 opts_type |= OPTS_TYPE_PT_ADDBITS15;
12758 }
12759 }
12760 }
12761 }
12762
12763 /**
12764 * generate bitmap tables
12765 */
12766
12767 const uint bitmap_shift1 = 5;
12768 const uint bitmap_shift2 = 13;
12769
12770 if (bitmap_max < bitmap_min) bitmap_max = bitmap_min;
12771
12772 uint *bitmap_s1_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12773 uint *bitmap_s1_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12774 uint *bitmap_s1_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12775 uint *bitmap_s1_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12776 uint *bitmap_s2_a = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12777 uint *bitmap_s2_b = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12778 uint *bitmap_s2_c = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12779 uint *bitmap_s2_d = (uint *) mymalloc ((1 << bitmap_max) * sizeof (uint));
12780
12781 uint bitmap_bits;
12782 uint bitmap_nums;
12783 uint bitmap_mask;
12784 uint bitmap_size;
12785
12786 for (bitmap_bits = bitmap_min; bitmap_bits < bitmap_max; bitmap_bits++)
12787 {
12788 if (data.quiet == 0) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits);
12789
12790 bitmap_nums = 1 << bitmap_bits;
12791
12792 bitmap_mask = bitmap_nums - 1;
12793
12794 bitmap_size = bitmap_nums * sizeof (uint);
12795
12796 if ((hashes_cnt & bitmap_mask) == hashes_cnt) break;
12797
12798 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;
12799 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;
12800
12801 break;
12802 }
12803
12804 bitmap_nums = 1 << bitmap_bits;
12805
12806 bitmap_mask = bitmap_nums - 1;
12807
12808 bitmap_size = bitmap_nums * sizeof (uint);
12809
12810 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);
12811 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);
12812
12813 /**
12814 * prepare quick rule
12815 */
12816
12817 data.rule_buf_l = rule_buf_l;
12818 data.rule_buf_r = rule_buf_r;
12819
12820 int rule_len_l = (int) strlen (rule_buf_l);
12821 int rule_len_r = (int) strlen (rule_buf_r);
12822
12823 data.rule_len_l = rule_len_l;
12824 data.rule_len_r = rule_len_r;
12825
12826 /**
12827 * load rules
12828 */
12829
12830 uint *all_gpu_rules_cnt = NULL;
12831
12832 gpu_rule_t **all_gpu_rules_buf = NULL;
12833
12834 if (rp_files_cnt)
12835 {
12836 all_gpu_rules_cnt = (uint *) mycalloc (rp_files_cnt, sizeof (uint));
12837
12838 all_gpu_rules_buf = (gpu_rule_t **) mycalloc (rp_files_cnt, sizeof (gpu_rule_t *));
12839 }
12840
12841 char rule_buf[BUFSIZ];
12842
12843 int rule_len = 0;
12844
12845 for (uint i = 0; i < rp_files_cnt; i++)
12846 {
12847 uint gpu_rules_avail = 0;
12848
12849 uint gpu_rules_cnt = 0;
12850
12851 gpu_rule_t *gpu_rules_buf = NULL;
12852
12853 char *rp_file = rp_files[i];
12854
12855 char in[BLOCK_SIZE];
12856 char out[BLOCK_SIZE];
12857
12858 FILE *fp = NULL;
12859
12860 uint rule_line = 0;
12861
12862 if ((fp = fopen (rp_file, "rb")) == NULL)
12863 {
12864 log_error ("ERROR: %s: %s", rp_file, strerror (errno));
12865
12866 return (-1);
12867 }
12868
12869 while (!feof (fp))
12870 {
12871 memset (rule_buf, 0, BUFSIZ);
12872
12873 rule_len = fgetl (fp, rule_buf);
12874
12875 rule_line++;
12876
12877 if (rule_len == 0) continue;
12878
12879 if (rule_buf[0] == '#') continue;
12880
12881 if (gpu_rules_avail == gpu_rules_cnt)
12882 {
12883 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12884
12885 gpu_rules_avail += INCR_RULES;
12886 }
12887
12888 memset (in, 0, BLOCK_SIZE);
12889 memset (out, 0, BLOCK_SIZE);
12890
12891 int result = _old_apply_rule (rule_buf, rule_len, in, 1, out);
12892
12893 if (result == -1)
12894 {
12895 log_info ("WARNING: Skipping invalid or unsupported rule in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12896
12897 continue;
12898 }
12899
12900 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1)
12901 {
12902 log_info ("WARNING: Cannot convert rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12903
12904 memset (&gpu_rules_buf[gpu_rules_cnt], 0, sizeof (gpu_rule_t)); // needs to be cleared otherwise we could have some remaining data
12905
12906 continue;
12907 }
12908
12909 /* its so slow
12910 if (rulefind (&gpu_rules_buf[gpu_rules_cnt], gpu_rules_buf, gpu_rules_cnt, sizeof (gpu_rule_t), sort_by_gpu_rule))
12911 {
12912 log_info ("Duplicate rule for use on GPU in file %s in line %u: %s", rp_file, rule_line, rule_buf);
12913
12914 continue;
12915 }
12916 */
12917
12918 gpu_rules_cnt++;
12919 }
12920
12921 fclose (fp);
12922
12923 all_gpu_rules_cnt[i] = gpu_rules_cnt;
12924
12925 all_gpu_rules_buf[i] = gpu_rules_buf;
12926 }
12927
12928 /**
12929 * merge rules or automatic rule generator
12930 */
12931
12932 uint gpu_rules_cnt = 0;
12933
12934 gpu_rule_t *gpu_rules_buf = NULL;
12935
12936 if (attack_mode == ATTACK_MODE_STRAIGHT)
12937 {
12938 if (rp_files_cnt)
12939 {
12940 gpu_rules_cnt = 1;
12941
12942 uint *repeats = (uint *) mycalloc (rp_files_cnt + 1, sizeof (uint));
12943
12944 repeats[0] = gpu_rules_cnt;
12945
12946 for (uint i = 0; i < rp_files_cnt; i++)
12947 {
12948 gpu_rules_cnt *= all_gpu_rules_cnt[i];
12949
12950 repeats[i + 1] = gpu_rules_cnt;
12951 }
12952
12953 gpu_rules_buf = (gpu_rule_t *) mycalloc (gpu_rules_cnt, sizeof (gpu_rule_t));
12954
12955 memset (gpu_rules_buf, 0, gpu_rules_cnt * sizeof (gpu_rule_t));
12956
12957 for (uint i = 0; i < gpu_rules_cnt; i++)
12958 {
12959 uint out_pos = 0;
12960
12961 gpu_rule_t *out = &gpu_rules_buf[i];
12962
12963 for (uint j = 0; j < rp_files_cnt; j++)
12964 {
12965 uint in_off = (i / repeats[j]) % all_gpu_rules_cnt[j];
12966 uint in_pos;
12967
12968 gpu_rule_t *in = &all_gpu_rules_buf[j][in_off];
12969
12970 for (in_pos = 0; in->cmds[in_pos]; in_pos++, out_pos++)
12971 {
12972 if (out_pos == RULES_MAX - 1)
12973 {
12974 // log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
12975
12976 break;
12977 }
12978
12979 out->cmds[out_pos] = in->cmds[in_pos];
12980 }
12981 }
12982 }
12983
12984 local_free (repeats);
12985 }
12986 else if (rp_gen)
12987 {
12988 uint gpu_rules_avail = 0;
12989
12990 while (gpu_rules_cnt < rp_gen)
12991 {
12992 if (gpu_rules_avail == gpu_rules_cnt)
12993 {
12994 gpu_rules_buf = (gpu_rule_t *) myrealloc (gpu_rules_buf, gpu_rules_avail * sizeof (gpu_rule_t), INCR_RULES * sizeof (gpu_rule_t));
12995
12996 gpu_rules_avail += INCR_RULES;
12997 }
12998
12999 memset (rule_buf, 0, BLOCK_SIZE);
13000
13001 rule_len = (int) generate_random_rule (rule_buf, rp_gen_func_min, rp_gen_func_max);
13002
13003 if (cpu_rule_to_gpu_rule (rule_buf, rule_len, &gpu_rules_buf[gpu_rules_cnt]) == -1) continue;
13004
13005 gpu_rules_cnt++;
13006 }
13007 }
13008 }
13009
13010 /**
13011 * generate NOP rules
13012 */
13013
13014 if (gpu_rules_cnt == 0)
13015 {
13016 gpu_rules_buf = (gpu_rule_t *) mymalloc (sizeof (gpu_rule_t));
13017
13018 gpu_rules_buf[gpu_rules_cnt].cmds[0] = RULE_OP_MANGLE_NOOP;
13019
13020 gpu_rules_cnt++;
13021 }
13022
13023 data.gpu_rules_cnt = gpu_rules_cnt;
13024 data.gpu_rules_buf = gpu_rules_buf;
13025
13026 /**
13027 * platform
13028 */
13029
13030 #ifdef _CUDA
13031 if (cuInit (0) != CUDA_SUCCESS)
13032 {
13033 log_error ("ERROR: No NVidia compatible platform found");
13034
13035 return (-1);
13036 }
13037 #endif
13038
13039 /**
13040 * devices get
13041 */
13042
13043 uint devices_all_cnt = 0;
13044
13045 #ifdef _CUDA
13046 CUdevice devices_all[DEVICES_MAX];
13047 CUdevice devices[DEVICES_MAX];
13048
13049 hc_cuDeviceGetCount ((int *) &devices_all_cnt);
13050
13051 for (uint i = 0; i < devices_all_cnt; i++)
13052 {
13053 hc_cuDeviceGet (&devices_all[i], i);
13054 }
13055
13056 #elif _OCL
13057 cl_platform_id CL_platform = NULL;
13058
13059 cl_platform_id CL_platforms[CL_PLATFORMS_MAX];
13060
13061 uint CL_platforms_cnt = 0;
13062
13063 hc_clGetPlatformIDs (CL_PLATFORMS_MAX, CL_platforms, &CL_platforms_cnt);
13064
13065 for (uint i = 0; i < CL_platforms_cnt; i++)
13066 {
13067 char CL_platform_vendor[INFOSZ];
13068
13069 memset (CL_platform_vendor, 0, sizeof (CL_platform_vendor));
13070
13071 hc_clGetPlatformInfo (CL_platforms[i], CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
13072
13073 if ((strcmp (CL_platform_vendor, CL_VENDOR_AMD) != 0)
13074 && (strcmp (CL_platform_vendor, CL_VENDOR_SDS) != 0)
13075 && (strcmp (CL_platform_vendor, CL_VENDOR_APPLE) != 0)) continue;
13076
13077 if (strcmp (CL_platform_vendor, CL_VENDOR_SDS) == 0) gpu_temp_disable = 1;
13078
13079 CL_platform = CL_platforms[i];
13080 }
13081
13082 if (CL_platform == NULL)
13083 {
13084 log_error ("ERROR: No AMD/SDS compatible platform found");
13085
13086 return (-1);
13087 }
13088
13089 cl_device_id devices_all[DEVICES_MAX];
13090 cl_device_id devices[DEVICES_MAX];
13091
13092 hc_clGetDeviceIDs (CL_platform, CL_DEVICE_TYPE_GPU, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
13093
13094 #endif
13095
13096 int hm_adapters_all = devices_all_cnt;
13097
13098 hm_attrs_t hm_adapter_all[DEVICES_MAX];
13099
13100 memset (hm_adapter_all, 0, sizeof (hm_adapter_all));
13101
13102 if (gpu_temp_disable == 0)
13103 {
13104 #ifdef _CUDA
13105 #ifdef LINUX
13106 if (hc_NVML_nvmlInit () == NVML_SUCCESS)
13107 {
13108 HM_ADAPTER nvGPUHandle[DEVICES_MAX];
13109
13110 int tmp_in = hm_get_adapter_index (nvGPUHandle);
13111
13112 int tmp_out = 0;
13113
13114 for (int i = 0; i < tmp_in; i++)
13115 {
13116 hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i];
13117 }
13118
13119 hm_adapters_all = tmp_out;
13120
13121 for (int i = 0; i < tmp_out; i++)
13122 {
13123 unsigned int speed;
13124
13125 if (nvmlDeviceGetFanSpeed (hm_adapter_all[i].adapter_index, &speed) != NVML_ERROR_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
13126 }
13127 }
13128 #endif
13129
13130 #ifdef WIN
13131 if (NvAPI_Initialize () == NVAPI_OK)
13132 {
13133 HM_ADAPTER nvGPUHandle[DEVICES_MAX];
13134
13135 int tmp_in = hm_get_adapter_index (nvGPUHandle);
13136
13137 int tmp_out = 0;
13138
13139 for (int i = 0; i < tmp_in; i++)
13140 {
13141 hm_adapter_all[tmp_out++].adapter_index = nvGPUHandle[i];
13142 }
13143
13144 hm_adapters_all = tmp_out;
13145
13146 for (int i = 0; i < tmp_out; i++)
13147 {
13148 NvU32 speed;
13149
13150 if (NvAPI_GPU_GetTachReading (hm_adapter_all[i].adapter_index, &speed) != NVAPI_NOT_SUPPORTED) hm_adapter_all[i].fan_supported = 1;
13151 }
13152 }
13153 #endif
13154 #endif
13155
13156 #ifdef _OCL
13157 #ifndef OSX
13158 HM_LIB hm_dll = hm_init ();
13159
13160 data.hm_dll = hm_dll;
13161
13162 if (hc_ADL_Main_Control_Create (hm_dll, ADL_Main_Memory_Alloc, 0) == ADL_OK)
13163 {
13164 // total number of adapters
13165
13166 int hm_adapters_num;
13167
13168 if (get_adapters_num (hm_dll, &hm_adapters_num) != 0) return (-1);
13169
13170 // adapter info
13171
13172 LPAdapterInfo lpAdapterInfo = hm_get_adapter_info (hm_dll, hm_adapters_num);
13173
13174 if (lpAdapterInfo == NULL) return (-1);
13175
13176 // get a list (of ids of) valid/usable adapters
13177
13178 int num_adl_adapters = 0;
13179
13180 uint32_t *valid_adl_device_list = hm_get_list_valid_adl_adapters (hm_adapters_num, &num_adl_adapters, lpAdapterInfo);
13181
13182 if (num_adl_adapters > 0)
13183 {
13184 hc_thread_mutex_lock (mux_adl);
13185
13186 // hm_get_opencl_busid_devid (hm_adapter_all, devices_all_cnt, devices_all);
13187
13188 hm_get_adapter_index (hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13189
13190 hm_get_overdrive_version (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13191 hm_check_fanspeed_control (hm_dll, hm_adapter_all, valid_adl_device_list, num_adl_adapters, lpAdapterInfo);
13192
13193 hc_thread_mutex_unlock (mux_adl);
13194 }
13195
13196 hm_adapters_all = num_adl_adapters;
13197
13198 myfree (valid_adl_device_list);
13199 myfree (lpAdapterInfo);
13200 }
13201 #endif
13202 #endif
13203 }
13204
13205 if (hm_adapters_all == 0)
13206 {
13207 gpu_temp_disable = 1;
13208 }
13209
13210 if (gpu_temp_disable == 1)
13211 {
13212 gpu_temp_abort = 0;
13213 gpu_temp_retain = 0;
13214 }
13215
13216 /**
13217 * enable custom signal handler(s)
13218 */
13219
13220 if (benchmark == 0)
13221 {
13222 hc_signal (sigHandler_default);
13223 }
13224 else
13225 {
13226 hc_signal (sigHandler_benchmark);
13227 }
13228
13229 /**
13230 * devices mask and properties
13231 */
13232
13233 uint devices_cnt = 0;
13234
13235 for (uint device_all_id = 0; device_all_id < devices_all_cnt; device_all_id++)
13236 {
13237 if (gpu_devicemask)
13238 {
13239 uint device_all_id_mask = 1 << device_all_id;
13240
13241 if ((device_all_id_mask & gpu_devicemask) != device_all_id_mask)
13242 {
13243 if (quiet == 0 && algorithm_pos == 0) log_info ("Device #%d: skipped by user", device_all_id_mask + 1);
13244
13245 continue;
13246 }
13247 }
13248
13249 const uint device_id = devices_cnt;
13250
13251 devices[device_id] = devices_all[device_all_id];
13252
13253 memcpy (&data.hm_device[device_id], &hm_adapter_all[device_all_id], sizeof (hm_attrs_t));
13254
13255 char device_name[INFOSZ];
13256
13257 memset (device_name, 0, sizeof (device_name));
13258
13259 #ifdef _CUDA
13260 size_t global_mem_size;
13261 int max_clock_frequency;
13262 int max_compute_units;
13263 int kernel_exec_timeout;
13264
13265 hc_cuDeviceGetName (device_name, sizeof (device_name), devices[device_id]);
13266 hc_cuDeviceTotalMem (&global_mem_size, devices[device_id]);
13267 hc_cuDeviceGetAttribute (&max_clock_frequency, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, devices[device_id]); max_clock_frequency /= 1000;
13268 hc_cuDeviceGetAttribute (&max_compute_units, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, devices[device_id]);
13269 hc_cuDeviceGetAttribute (&kernel_exec_timeout, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, devices[device_id]);
13270
13271 #elif _OCL
13272 cl_ulong global_mem_size;
13273 cl_uint max_clock_frequency;
13274 cl_uint max_compute_units;
13275
13276 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_NAME, sizeof (device_name), &device_name, NULL);
13277 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof (global_mem_size), &global_mem_size, NULL);
13278 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof (max_clock_frequency), &max_clock_frequency, NULL);
13279 hc_clGetDeviceInfo (devices[device_id], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
13280
13281 #endif
13282
13283 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
13284 {
13285 log_info ("Device #%u: %s, %luMB, %dMhz, %uMCU",
13286 device_all_id + 1,
13287 device_name,
13288 (unsigned int) (global_mem_size / 1024 / 1024),
13289 (unsigned int) (max_clock_frequency),
13290 (unsigned int) max_compute_units);
13291 }
13292
13293 #ifdef _CUDA
13294 if (quiet == 0 && kernel_exec_timeout != 0 && algorithm_pos == 0)
13295 {
13296 log_info ("Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1);
13297 #if _WIN
13298 log_info (" You can disable it with a regpatch, see here: http://hashcat.net/wiki/doku.php?id=timeout_patch");
13299 #endif
13300 }
13301 #endif
13302
13303 devices_cnt++;
13304 }
13305
13306 if (devices_cnt == 0)
13307 {
13308 log_error ("ERROR: No devices left that matches your specification.");
13309
13310 return (-1);
13311 }
13312
13313 if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
13314 {
13315 log_info ("");
13316 }
13317
13318 /**
13319 * inform the user
13320 */
13321
13322 // gpu temp sanity check
13323
13324 if ((gpu_temp_abort != 0) && (gpu_temp_retain != 0))
13325 {
13326 if (gpu_temp_abort < gpu_temp_retain)
13327 {
13328 log_error ("ERROR: invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain.");
13329
13330 return (-1);
13331 }
13332 }
13333
13334 if (data.quiet == 0)
13335 {
13336 log_info ("Hashes: %u hashes; %u unique digests, %u unique salts", hashes_cnt_orig, digests_cnt, salts_cnt);
13337
13338 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);
13339
13340 if (attack_mode == ATTACK_MODE_STRAIGHT)
13341 {
13342 log_info ("Rules: %u", gpu_rules_cnt);
13343 }
13344
13345 if (opti_type)
13346 {
13347 log_info ("Applicable Optimizers:");
13348
13349 for (uint i = 0; i < 32; i++)
13350 {
13351 const uint opti_bit = 1 << i;
13352
13353 if (opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit));
13354 }
13355 }
13356
13357 /**
13358 * Watchdog and Temperature balance
13359 */
13360
13361 if (gpu_temp_abort == 0)
13362 {
13363 log_info ("Watchdog: Temperature abort trigger disabled");
13364 }
13365 else
13366 {
13367 log_info ("Watchdog: Temperature abort trigger set to %uc", gpu_temp_abort);
13368 }
13369
13370 if (gpu_temp_retain == 0)
13371 {
13372 log_info ("Watchdog: Temperature retain trigger disabled");
13373 }
13374 else
13375 {
13376 log_info ("Watchdog: Temperature retain trigger set to %uc", gpu_temp_retain);
13377 }
13378 }
13379
13380 /**
13381 * store all the preparation, not hash_mode dependant
13382 */
13383
13384 data.gpu_temp_disable = gpu_temp_disable;
13385 data.gpu_temp_abort = gpu_temp_abort;
13386 data.gpu_temp_retain = gpu_temp_retain;
13387
13388 data.devices_cnt = devices_cnt;
13389
13390 #ifdef _OCL
13391 /**
13392 * catalyst driver check
13393 */
13394
13395 int catalyst_check = (force == 1) ? 0 : 1;
13396
13397 int catalyst_warn = 0;
13398
13399 int catalyst_broken = 0;
13400 #endif
13401
13402 /**
13403 * devices init
13404 */
13405
13406 #ifdef _OCL
13407 #ifndef OSX
13408 int gpu_temp_retain_set = 0;
13409
13410 int *temp_retain_fanspeed_value = (int *) mycalloc (devices_cnt, sizeof (int));
13411
13412 ADLOD6MemClockState *od_clock_mem_status = (ADLOD6MemClockState *) mycalloc (devices_cnt, sizeof (ADLOD6MemClockState));
13413
13414 int *od_power_control_status = (int *) mycalloc (devices_cnt, sizeof (int));
13415 #endif
13416 #endif
13417
13418 hc_device_param_t *devices_param = (hc_device_param_t *) mycalloc (devices_cnt, sizeof (hc_device_param_t));
13419
13420 data.devices_param = devices_param;
13421
13422 for (uint device_id = 0; device_id < devices_cnt; device_id++)
13423 {
13424 hc_device_param_t *device_param = &data.devices_param[device_id];
13425
13426 #ifdef _CUDA
13427 CUdevice device = devices[device_id];
13428
13429 device_param->device = device;
13430
13431 size_t bytes;
13432
13433 hc_cuDeviceTotalMem (&bytes, device);
13434
13435 device_param->gpu_maxmem_alloc = bytes;
13436
13437 int sm_major = 0;
13438 int sm_minor = 0;
13439 int max_compute_units = 0;
13440
13441 hc_cuDeviceComputeCapability (&sm_major, &sm_minor, device);
13442
13443 if (sm_major == 1)
13444 {
13445 log_error ("ERROR: Shader Model 1.0 - 1.3 based GPU detected. Support for CUDA was dropped by NVidia.");
13446 log_error (" Remove it from your system or use -d and select only supported cards.");
13447
13448 return (-1);
13449 }
13450
13451 device_param->sm_major = sm_major;
13452 device_param->sm_minor = sm_minor;
13453
13454 hc_cuDeviceGetAttribute (&max_compute_units, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, device);
13455
13456 if (sm_major >= 5)
13457 {
13458 // those maxwell and newer are so good compared to older chipsets we need to equalize
13459 // their power to older chipsets, otherwise workload distribution which is based on the compute_units
13460 // gets out of control
13461
13462 max_compute_units *= 3;
13463 }
13464
13465 device_param->gpu_processors = max_compute_units;
13466
13467 /**
13468 * calculate vector size
13469 */
13470
13471 uint vliw = get_vliw_by_compute_capability (sm_major, sm_minor);
13472
13473 device_param->gpu_vector_width = get_gpu_vector_width (hash_mode, attack_kern, attack_exec, opti_type, vliw);
13474
13475 #elif _OCL
13476 cl_device_id device = devices[device_id];
13477
13478 device_param->device = device;
13479
13480 cl_uint max_compute_units = 0;
13481
13482 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof (max_compute_units), &max_compute_units, NULL);
13483
13484 device_param->gpu_processors = max_compute_units;
13485
13486 cl_ulong max_mem_alloc_size = 0;
13487
13488 hc_clGetDeviceInfo (device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof (max_mem_alloc_size), &max_mem_alloc_size, NULL);
13489
13490 device_param->gpu_maxmem_alloc = max_mem_alloc_size;
13491
13492 char tmp[INFOSZ], t1[64];
13493
13494 memset (tmp, 0, sizeof (tmp));
13495
13496 hc_clGetDeviceInfo (device, CL_DEVICE_NAME, sizeof (tmp), &tmp, NULL);
13497
13498 device_param->device_name = mystrdup (tmp);
13499
13500 memset (tmp, 0, sizeof (tmp));
13501
13502 hc_clGetDeviceInfo (device, CL_DEVICE_VERSION, sizeof (tmp), &tmp, NULL);
13503
13504 memset (t1, 0, sizeof (t1));
13505
13506 sscanf (tmp, "%*16s %*16s %*16s (%[^)]16s)", t1);
13507
13508 device_param->device_version = mystrdup (t1);
13509
13510 memset (tmp, 0, sizeof (tmp));
13511
13512 hc_clGetDeviceInfo (device, CL_DRIVER_VERSION, sizeof (tmp), &tmp, NULL);
13513
13514 device_param->driver_version = mystrdup (tmp);
13515
13516 /**
13517 * calculate vector size
13518 */
13519
13520 uint vliw = get_vliw_by_device_name (device_param->device_name);
13521
13522 device_param->gpu_vector_width = get_gpu_vector_width (hash_mode, attack_kern, attack_exec, opti_type, vliw);
13523
13524 /**
13525 * catalyst driver check
13526 */
13527
13528 if (catalyst_check == 1)
13529 {
13530 catalyst_warn = 1;
13531
13532 // v14.9 and higher
13533 if ((atoi (device_param->device_version) >= 1573)
13534 && (atoi (device_param->driver_version) >= 1573))
13535 {
13536 catalyst_warn = 0;
13537 }
13538
13539 /*
13540 // v14.9
13541 if ((strstr (device_param->device_version, "1573.") != NULL)
13542 && (strstr (device_param->driver_version, "1573.") != NULL))
13543 {
13544 catalyst_warn = 0;
13545 }
13546
13547 // v14.12 -- version overlaps with v15.4 beta
13548 if ((strstr (device_param->device_version, "1642.") != NULL)
13549 && (strstr (device_param->driver_version, "1642.") != NULL))
13550 {
13551 catalyst_broken = 1;
13552 }
13553
13554 // v15.4 (Beta, Windows only release)
13555 if ((strstr (device_param->device_version, "1642.") != NULL)
13556 && (strstr (device_param->driver_version, "1642.") != NULL))
13557 {
13558 catalyst_warn = 0;
13559 }
13560
13561 // v15.5 (Release, Linux)
13562 if ((strstr (device_param->device_version, "1702.") != NULL)
13563 && (strstr (device_param->driver_version, "1702.") != NULL))
13564 {
13565 catalyst_warn = 0;
13566 }
13567
13568 // v15.3 (Beta, Ubuntu repository release)
13569 if ((strstr (device_param->device_version, "1729.") != NULL)
13570 && (strstr (device_param->driver_version, "1729.") != NULL))
13571 {
13572 catalyst_warn = 0;
13573 }
13574 */
13575
13576 catalyst_check = 0;
13577 }
13578 #endif
13579 }
13580
13581 #ifdef _OCL
13582 if (catalyst_broken == 1)
13583 {
13584 log_error ("");
13585 log_error ("ATTENTION! The installed GPU driver in your system is known to be broken!");
13586 log_error ("It will pass over cracked hashes and does not report them as cracked");
13587 log_error ("You are STRONGLY encouraged not to use it");
13588 log_error ("You can use --force to override this but do not post error reports if you do so");
13589
13590 return (-1);
13591 }
13592
13593 if (catalyst_warn == 1)
13594 {
13595 log_error ("");
13596 log_error ("ATTENTION! Unsupported or incorrect installed GPU driver detected!");
13597 log_error ("You are STRONGLY encouraged to use the official supported GPU driver for good reasons");
13598 log_error ("See oclHashcat's homepage for official supported GPU drivers");
13599 #ifdef _WIN
13600 log_error ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
13601 #endif
13602 log_error ("You can use --force to override this but do not post error reports if you do so");
13603
13604 return (-1);
13605 }
13606 #endif
13607
13608 uint gpu_blocks_all = 0;
13609
13610 #ifdef _CUDA
13611 for (uint device_id = 0; device_id < devices_cnt; device_id++)
13612 {
13613 /**
13614 * host buffer
13615 */
13616
13617 hc_device_param_t *device_param = &data.devices_param[device_id];
13618
13619 /**
13620 * device properties
13621 */
13622
13623 int sm_minor = device_param->sm_minor;
13624 int sm_major = device_param->sm_major;
13625
13626 uint gpu_processors = device_param->gpu_processors;
13627 uint gpu_vector_width = device_param->gpu_vector_width;
13628
13629 /**
13630 * create context for each device
13631 */
13632
13633 uint flags = 0;
13634
13635 if (gpu_async == 0) flags |= CU_CTX_SCHED_BLOCKING_SYNC;
13636 else flags |= CU_CTX_SCHED_SPIN;
13637
13638 hc_cuCtxCreate (&device_param->context, flags, device_param->device);
13639
13640 // does bad things hc_cuCtxSetCacheConfig (CU_FUNC_CACHE_PREFER_L1);
13641
13642 /**
13643 * create input buffers on device
13644 */
13645
13646 uint gpu_threads = GPU_THREADS_NV;
13647
13648 if (hash_mode == 1500) gpu_threads = 64;
13649 if (hash_mode == 3000) gpu_threads = 64;
13650 if (hash_mode == 3200) gpu_threads = 8;
13651 if (hash_mode == 7500) gpu_threads = 64;
13652 if (hash_mode == 8900) gpu_threads = 64;
13653 if (hash_mode == 9000) gpu_threads = 8;
13654 if (hash_mode == 9300) gpu_threads = 64;
13655 if (hash_mode == 9700) gpu_threads = 64;
13656 if (hash_mode == 9710) gpu_threads = 64;
13657 if (hash_mode == 9800) gpu_threads = 64;
13658 if (hash_mode == 9810) gpu_threads = 64;
13659 if (hash_mode == 10400) gpu_threads = 64;
13660 if (hash_mode == 10410) gpu_threads = 64;
13661 if (hash_mode == 10500) gpu_threads = 64;
13662
13663 uint gpu_power = gpu_processors * gpu_threads * gpu_accel;
13664 uint gpu_blocks = gpu_power * gpu_vector_width;
13665
13666 device_param->gpu_threads = gpu_threads;
13667 device_param->gpu_power_user = gpu_power;
13668 device_param->gpu_blocks_user = gpu_blocks;
13669
13670 gpu_blocks_all += gpu_blocks;
13671
13672 uint size_pws = gpu_power * sizeof (pw_t);
13673
13674 uint size_tmps = 4;
13675
13676 switch (hash_mode)
13677 {
13678 case 400: size_tmps = gpu_blocks * sizeof (phpass_tmp_t); break;
13679 case 500: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13680 case 501: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13681 case 1600: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13682 case 1800: size_tmps = gpu_blocks * sizeof (sha512crypt_tmp_t); break;
13683 case 2100: size_tmps = gpu_blocks * sizeof (dcc2_tmp_t); break;
13684 case 2500: size_tmps = gpu_blocks * sizeof (wpa_tmp_t); break;
13685 case 3200: size_tmps = gpu_blocks * sizeof (bcrypt_tmp_t); break;
13686 case 5200: size_tmps = gpu_blocks * sizeof (pwsafe3_tmp_t); break;
13687 case 5800: size_tmps = gpu_blocks * sizeof (androidpin_tmp_t); break;
13688 case 6211:
13689 case 6212:
13690 case 6213: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13691 case 6221:
13692 case 6222:
13693 case 6223: size_tmps = gpu_blocks * sizeof (tc64_tmp_t); break;
13694 case 6231:
13695 case 6232:
13696 case 6233: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13697 case 6241:
13698 case 6242:
13699 case 6243: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
13700 case 6300: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
13701 case 6400: size_tmps = gpu_blocks * sizeof (sha256aix_tmp_t); break;
13702 case 6500: size_tmps = gpu_blocks * sizeof (sha512aix_tmp_t); break;
13703 case 6600: size_tmps = gpu_blocks * sizeof (agilekey_tmp_t); break;
13704 case 6700: size_tmps = gpu_blocks * sizeof (sha1aix_tmp_t); break;
13705 case 6800: size_tmps = gpu_blocks * sizeof (lastpass_tmp_t); break;
13706 case 7100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13707 case 7200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13708 case 7400: size_tmps = gpu_blocks * sizeof (sha256crypt_tmp_t); break;
13709 case 7900: size_tmps = gpu_blocks * sizeof (drupal7_tmp_t); break;
13710 case 8200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13711 case 8800: size_tmps = gpu_blocks * sizeof (androidfde_tmp_t); break;
13712 case 8900: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
13713 case 9000: size_tmps = gpu_blocks * sizeof (pwsafe2_tmp_t); break;
13714 case 9100: size_tmps = gpu_blocks * sizeof (lotus8_tmp_t); break;
13715 case 9200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13716 case 9300: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
13717 case 9400: size_tmps = gpu_blocks * sizeof (office2007_tmp_t); break;
13718 case 9500: size_tmps = gpu_blocks * sizeof (office2010_tmp_t); break;
13719 case 9600: size_tmps = gpu_blocks * sizeof (office2013_tmp_t); break;
13720 case 10000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13721 case 10200: size_tmps = gpu_blocks * sizeof (cram_md5_t); break;
13722 case 10300: size_tmps = gpu_blocks * sizeof (saph_sha1_tmp_t); break;
13723 case 10500: size_tmps = gpu_blocks * sizeof (pdf14_tmp_t); break;
13724 case 10700: size_tmps = gpu_blocks * sizeof (pdf17l8_tmp_t); break;
13725 case 10900: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13726 case 11300: size_tmps = gpu_blocks * sizeof (bitcoin_wallet_tmp_t); break;
13727 case 11600: size_tmps = gpu_blocks * sizeof (seven_zip_tmp_t); break;
13728 case 11900: size_tmps = gpu_blocks * sizeof (pbkdf2_md5_tmp_t); break;
13729 case 12000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha1_tmp_t); break;
13730 case 12100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
13731 case 12200: size_tmps = gpu_blocks * sizeof (ecryptfs_tmp_t); break;
13732 case 12300: size_tmps = gpu_blocks * sizeof (oraclet_tmp_t); break;
13733 case 12400: size_tmps = gpu_blocks * sizeof (bsdicrypt_tmp_t); break;
13734 case 12500: size_tmps = gpu_blocks * sizeof (rar3_tmp_t); break;
13735 case 12700: size_tmps = gpu_blocks * sizeof (mywallet_tmp_t); break;
13736 case 12800: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
13737 };
13738
13739 uint size_hooks = 4;
13740
13741 if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23))
13742 {
13743 // fill size_hook with correct size
13744 }
13745
13746 // we can optimize some stuff here...
13747
13748 device_param->size_pws = size_pws;
13749 device_param->size_tmps = size_tmps;
13750 device_param->size_hooks = size_hooks;
13751
13752 uint size_root_css = SP_PW_MAX * sizeof (cs_t);
13753 uint size_markov_css = SP_PW_MAX * CHARSIZ * sizeof (cs_t);
13754
13755 device_param->size_root_css = size_root_css;
13756 device_param->size_markov_css = size_markov_css;
13757
13758 uint size_results = GPU_THREADS_NV * sizeof (uint);
13759
13760 device_param->size_results = size_results;
13761
13762 uint size_rules = gpu_rules_cnt * sizeof (gpu_rule_t);
13763 uint size_plains = digests_cnt * sizeof (plain_t);
13764 uint size_salts = salts_cnt * sizeof (salt_t);
13765 uint size_esalts = salts_cnt * esalt_size;
13766
13767 device_param->size_plains = size_plains;
13768 device_param->size_digests = size_digests;
13769 device_param->size_shown = size_shown;
13770 device_param->size_salts = size_salts;
13771
13772 uint size_combs = GPU_COMBS * sizeof (comb_t);
13773 uint size_bfs = GPU_BFS * sizeof (bf_t);
13774 uint size_tm = 32 * sizeof (bs_word_t);
13775
13776 uint64_t size_scryptV = 1;
13777
13778 if ((hash_mode == 8900) || (hash_mode == 9300))
13779 {
13780 #define SHADER_PER_MP 32
13781 #define WARPS 32
13782
13783 uint tmto_start = 2;
13784 uint tmto_stop = 1024;
13785
13786 if (scrypt_tmto)
13787 {
13788 tmto_start = 1 << scrypt_tmto;
13789 tmto_stop = tmto_start + 1;
13790 }
13791
13792 for (uint tmto = tmto_start; tmto < tmto_stop; tmto <<= 1)
13793 {
13794 // todo -- make sure all salts get the new tmto value
13795
13796 size_scryptV = (128 * data.salts_buf[0].scrypt_r) * data.salts_buf[0].scrypt_N;
13797
13798 size_scryptV /= tmto;
13799
13800 size_scryptV *= gpu_processors * WARPS * SHADER_PER_MP;
13801
13802 if (size_scryptV > (device_param->gpu_maxmem_alloc / 2)) continue;
13803
13804 for (uint salts_pos = 0; salts_pos < data.salts_cnt; salts_pos++)
13805 {
13806 data.salts_buf[salts_pos].scrypt_tmto = tmto;
13807 data.salts_buf[salts_pos].scrypt_phy = gpu_processors * WARPS * SHADER_PER_MP;
13808 }
13809
13810 break;
13811 }
13812
13813 if (data.salts_buf[0].scrypt_tmto == 0)
13814 {
13815 log_error ("ERROR: can't allocate enough GPU memory");
13816
13817 return -1;
13818 }
13819
13820 if (quiet == 0) log_info ("");
13821 if (quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u\n", data.salts_buf[0].scrypt_tmto);
13822 }
13823
13824 /**
13825 * stream
13826 */
13827
13828 hc_cuStreamCreate (&device_param->stream, 0);
13829
13830 /**
13831 * module find
13832 */
13833
13834 char module_file[256];
13835
13836 memset (module_file, 0, sizeof (module_file));
13837
13838 #ifdef __x86_64__
13839 if (attack_exec == ATTACK_EXEC_ON_GPU)
13840 {
13841 if (attack_kern == ATTACK_KERN_STRAIGHT)
13842 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a0.sm_%d%d.64.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13843 else if (attack_kern == ATTACK_KERN_COMBI)
13844 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a1.sm_%d%d.64.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13845 else if (attack_kern == ATTACK_KERN_BF)
13846 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a3.sm_%d%d.64.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13847 }
13848 else
13849 {
13850 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d.sm_%d%d.64.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13851
13852 if ((hash_mode == 8900) || (hash_mode == 9300))
13853 {
13854 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_%d_%d_%d_%d.sm_%d%d.64.cubin", install_dir, (int) kern_type, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto, sm_major, sm_minor);
13855 }
13856 }
13857
13858 #else
13859 if (attack_exec == ATTACK_EXEC_ON_GPU)
13860 {
13861 if (attack_kern == ATTACK_KERN_STRAIGHT)
13862 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a0.sm_%d%d.32.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13863 else if (attack_kern == ATTACK_KERN_COMBI)
13864 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a1.sm_%d%d.32.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13865 else if (attack_kern == ATTACK_KERN_BF)
13866 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_a3.sm_%d%d.32.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13867 }
13868 else
13869 {
13870 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d.sm_%d%d.32.cubin", install_dir, (int) kern_type, sm_major, sm_minor);
13871
13872 if ((hash_mode == 8900) || (hash_mode == 9300))
13873 {
13874 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4318/m%05d_%d_%d_%d_%d.sm_%d%d.32.cubin", install_dir, (int) kern_type, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto, sm_major, sm_minor);
13875 }
13876 }
13877
13878 #endif
13879
13880 char module_mp_file[256];
13881
13882 memset (module_mp_file, 0, sizeof (module_mp_file));
13883
13884 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
13885 {
13886 #ifdef __x86_64__
13887 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4318/markov_be_v%d.sm_%d%d.64.cubin", install_dir, gpu_vector_width, sm_major, sm_minor);
13888 #else
13889 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4318/markov_be_v%d.sm_%d%d.32.cubin", install_dir, gpu_vector_width, sm_major, sm_minor);
13890 #endif
13891 }
13892 else
13893 {
13894 #ifdef __x86_64__
13895 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4318/markov_le_v%d.sm_%d%d.64.cubin", install_dir, gpu_vector_width, sm_major, sm_minor);
13896 #else
13897 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4318/markov_le_v%d.sm_%d%d.32.cubin", install_dir, gpu_vector_width, sm_major, sm_minor);
13898 #endif
13899 }
13900
13901 char module_amp_file[256];
13902
13903 memset (module_amp_file, 0, sizeof (module_amp_file));
13904
13905 #ifdef __x86_64__
13906 snprintf (module_amp_file, sizeof (module_amp_file) - 1, "%s/kernels/4318/amp_a%d_v%d.sm_%d%d.64.cubin", install_dir, attack_kern, gpu_vector_width, sm_major, sm_minor);
13907 #else
13908 snprintf (module_amp_file, sizeof (module_amp_file) - 1, "%s/kernels/4318/amp_a%d_v%d.sm_%d%d.32.cubin", install_dir, attack_kern, gpu_vector_width, sm_major, sm_minor);
13909 #endif
13910
13911 /**
13912 * module load
13913 */
13914
13915 hc_cuModuleLoad (&device_param->module, module_file);
13916
13917 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_file);
13918
13919 if (attack_mode != ATTACK_MODE_STRAIGHT)
13920 {
13921 hc_cuModuleLoad (&device_param->module_mp, module_mp_file);
13922
13923 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_mp_file);
13924 }
13925
13926 if (attack_exec == ATTACK_EXEC_ON_GPU)
13927 {
13928 // nothing to do
13929 }
13930 else
13931 {
13932 hc_cuModuleLoad (&device_param->module_amp, module_amp_file);
13933
13934 if (quiet == 0) log_info ("Device #%u: Kernel %s", device_id + 1, module_amp_file);
13935 }
13936
13937 /**
13938 * module functions
13939 */
13940
13941 char module_name[64];
13942
13943 memset (module_name, 0, sizeof (module_name));
13944
13945 if (attack_exec == ATTACK_EXEC_ON_GPU)
13946 {
13947 if (opti_type & OPTI_TYPE_SINGLE_HASH)
13948 {
13949 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 4);
13950
13951 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
13952
13953 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 8);
13954
13955 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
13956
13957 snprintf (module_name, sizeof (module_name) - 1, "m%05d_s%02d", kern_type, 16);
13958
13959 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
13960 }
13961 else
13962 {
13963 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 4);
13964
13965 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
13966
13967 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 8);
13968
13969 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
13970
13971 snprintf (module_name, sizeof (module_name) - 1, "m%05d_m%02d", kern_type, 16);
13972
13973 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
13974 }
13975
13976 if (attack_mode == ATTACK_MODE_BF)
13977 {
13978 if (opts_type & OPTS_TYPE_PT_BITSLICE)
13979 {
13980 snprintf (module_name, sizeof (module_name) - 1, "m%05d_tb", kern_type);
13981
13982 hc_cuModuleGetFunction (&device_param->function_tb, device_param->module, module_name);
13983
13984 snprintf (module_name, sizeof (module_name) - 1, "m%05d_tm", kern_type);
13985
13986 hc_cuModuleGetFunction (&device_param->function_tm, device_param->module, module_name);
13987 }
13988 }
13989 }
13990 else
13991 {
13992 snprintf (module_name, sizeof (module_name) - 1, "m%05d_init", kern_type);
13993
13994 hc_cuModuleGetFunction (&device_param->function1, device_param->module, module_name);
13995
13996 snprintf (module_name, sizeof (module_name) - 1, "m%05d_loop", kern_type);
13997
13998 hc_cuModuleGetFunction (&device_param->function2, device_param->module, module_name);
13999
14000 snprintf (module_name, sizeof (module_name) - 1, "m%05d_comp", kern_type);
14001
14002 hc_cuModuleGetFunction (&device_param->function3, device_param->module, module_name);
14003
14004 if (opts_type & OPTS_TYPE_HOOK12)
14005 {
14006 snprintf (module_name, sizeof (module_name) - 1, "m%05d_hook12", kern_type);
14007
14008 hc_cuModuleGetFunction (&device_param->function12, device_param->module, module_name);
14009 }
14010
14011 if (opts_type & OPTS_TYPE_HOOK23)
14012 {
14013 snprintf (module_name, sizeof (module_name) - 1, "m%05d_hook23", kern_type);
14014
14015 hc_cuModuleGetFunction (&device_param->function23, device_param->module, module_name);
14016 }
14017 }
14018
14019 if (attack_mode == ATTACK_MODE_BF)
14020 {
14021 hc_cuModuleGetFunction (&device_param->function_mp_l, device_param->module_mp, "l_markov");
14022 hc_cuModuleGetFunction (&device_param->function_mp_r, device_param->module_mp, "r_markov");
14023 }
14024 else if (attack_mode == ATTACK_MODE_HYBRID1)
14025 {
14026 hc_cuModuleGetFunction (&device_param->function_mp, device_param->module_mp, "C_markov");
14027 }
14028 else if (attack_mode == ATTACK_MODE_HYBRID2)
14029 {
14030 hc_cuModuleGetFunction (&device_param->function_mp, device_param->module_mp, "C_markov");
14031 }
14032
14033 /**
14034 * amplifiers are not independant
14035 */
14036
14037 if (attack_exec == ATTACK_EXEC_ON_GPU)
14038 {
14039 // nothing to do
14040 }
14041 else
14042 {
14043 hc_cuModuleGetFunction (&device_param->function_amp, device_param->module_amp, "amp");
14044 }
14045
14046 /**
14047 * global buffers
14048 */
14049
14050 hc_cuMemAlloc (&device_param->d_pws_buf, size_pws);
14051 hc_cuMemAlloc (&device_param->d_pws_amp_buf, size_pws);
14052 hc_cuMemAlloc (&device_param->d_tmps, size_tmps);
14053 hc_cuMemAlloc (&device_param->d_hooks, size_hooks);
14054 hc_cuMemAlloc (&device_param->d_bitmap_s1_a, bitmap_size);
14055 hc_cuMemAlloc (&device_param->d_bitmap_s1_b, bitmap_size);
14056 hc_cuMemAlloc (&device_param->d_bitmap_s1_c, bitmap_size);
14057 hc_cuMemAlloc (&device_param->d_bitmap_s1_d, bitmap_size);
14058 hc_cuMemAlloc (&device_param->d_bitmap_s2_a, bitmap_size);
14059 hc_cuMemAlloc (&device_param->d_bitmap_s2_b, bitmap_size);
14060 hc_cuMemAlloc (&device_param->d_bitmap_s2_c, bitmap_size);
14061 hc_cuMemAlloc (&device_param->d_bitmap_s2_d, bitmap_size);
14062 hc_cuMemAlloc (&device_param->d_plain_bufs, size_plains);
14063 hc_cuMemAlloc (&device_param->d_digests_buf, size_digests);
14064 hc_cuMemAlloc (&device_param->d_digests_shown, size_shown);
14065 hc_cuMemAlloc (&device_param->d_salt_bufs, size_salts);
14066 hc_cuMemAlloc (&device_param->d_result, size_results);
14067 hc_cuMemAlloc (&device_param->d_scryptV_buf, size_scryptV);
14068
14069 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_a, bitmap_s1_a, bitmap_size);
14070 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_b, bitmap_s1_b, bitmap_size);
14071 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_c, bitmap_s1_c, bitmap_size);
14072 hc_cuMemcpyHtoD (device_param->d_bitmap_s1_d, bitmap_s1_d, bitmap_size);
14073 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_a, bitmap_s2_a, bitmap_size);
14074 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_b, bitmap_s2_b, bitmap_size);
14075 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_c, bitmap_s2_c, bitmap_size);
14076 hc_cuMemcpyHtoD (device_param->d_bitmap_s2_d, bitmap_s2_d, bitmap_size);
14077 hc_cuMemcpyHtoD (device_param->d_digests_buf, data.digests_buf, size_digests);
14078 hc_cuMemcpyHtoD (device_param->d_digests_shown, data.digests_shown, size_shown);
14079 hc_cuMemcpyHtoD (device_param->d_salt_bufs, data.salts_buf, size_salts);
14080
14081 run_kernel_bzero (device_param, device_param->d_pws_buf, size_pws);
14082 run_kernel_bzero (device_param, device_param->d_pws_amp_buf, size_pws);
14083 run_kernel_bzero (device_param, device_param->d_tmps, size_tmps);
14084 run_kernel_bzero (device_param, device_param->d_hooks, size_hooks);
14085 run_kernel_bzero (device_param, device_param->d_plain_bufs, size_plains);
14086 run_kernel_bzero (device_param, device_param->d_result, size_results);
14087
14088 /**
14089 * special buffers
14090 */
14091
14092 if (attack_kern == ATTACK_KERN_STRAIGHT)
14093 {
14094 hc_cuMemAlloc (&device_param->d_rules, size_rules);
14095
14096 hc_cuMemcpyHtoD (device_param->d_rules, gpu_rules_buf, size_rules);
14097 }
14098 else if (attack_kern == ATTACK_KERN_COMBI)
14099 {
14100 hc_cuMemAlloc (&device_param->d_combs, size_combs);
14101 hc_cuMemAlloc (&device_param->d_root_css_buf, size_root_css);
14102 hc_cuMemAlloc (&device_param->d_markov_css_buf, size_markov_css);
14103
14104 run_kernel_bzero (device_param, device_param->d_combs, size_combs);
14105 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
14106 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
14107 }
14108 else if (attack_kern == ATTACK_KERN_BF)
14109 {
14110 hc_cuMemAlloc (&device_param->d_bfs, size_bfs);
14111 hc_cuMemAlloc (&device_param->d_tm, size_tm);
14112 hc_cuMemAlloc (&device_param->d_root_css_buf, size_root_css);
14113 hc_cuMemAlloc (&device_param->d_markov_css_buf, size_markov_css);
14114
14115 run_kernel_bzero (device_param, device_param->d_bfs, size_bfs);
14116 run_kernel_bzero (device_param, device_param->d_tm, size_tm);
14117 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
14118 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
14119 }
14120
14121 if (size_esalts)
14122 {
14123 hc_cuMemAlloc (&device_param->d_esalt_bufs, size_esalts);
14124
14125 hc_cuMemcpyHtoD (device_param->d_esalt_bufs, data.esalts_buf, size_esalts);
14126 }
14127
14128 /**
14129 * main host data
14130 */
14131
14132 uint *result = (uint *) mymalloc (size_results);
14133
14134 memset (result, 0, size_results);
14135
14136 device_param->result = result;
14137
14138 pw_t *pws_buf = (pw_t *) mymalloc (size_pws);
14139
14140 memset (pws_buf, 0, size_pws);
14141
14142 device_param->pws_buf = pws_buf;
14143
14144 pw_cache_t *pw_caches = (pw_cache_t *) mycalloc (64, sizeof (pw_cache_t));
14145
14146 for (int i = 0; i < 64; i++)
14147 {
14148 pw_caches[i].pw_buf.pw_len = i;
14149 pw_caches[i].cnt = 0;
14150 }
14151
14152 device_param->pw_caches = pw_caches;
14153
14154 comb_t *combs_buf = (comb_t *) mycalloc (GPU_COMBS, sizeof (comb_t));
14155
14156 device_param->combs_buf = combs_buf;
14157
14158 void *hooks_buf = mymalloc (size_hooks);
14159
14160 device_param->hooks_buf = hooks_buf;
14161
14162 switch (device_param->gpu_vector_width)
14163 {
14164 case 1: device_param->pw_transpose = pw_transpose_to_hi1;
14165 device_param->pw_add = pw_add_to_hc1;
14166 break;
14167 case 2: device_param->pw_transpose = pw_transpose_to_hi2;
14168 device_param->pw_add = pw_add_to_hc2;
14169 break;
14170 case 4: device_param->pw_transpose = pw_transpose_to_hi4;
14171 device_param->pw_add = pw_add_to_hc4;
14172 break;
14173 }
14174
14175 /**
14176 * module args
14177 */
14178
14179 device_param->kernel_params_buf32[21] = bitmap_mask;
14180 device_param->kernel_params_buf32[22] = bitmap_shift1;
14181 device_param->kernel_params_buf32[23] = bitmap_shift2;
14182 device_param->kernel_params_buf32[24] = 0; // salt_pos
14183 device_param->kernel_params_buf32[25] = 0; // loop_pos
14184 device_param->kernel_params_buf32[26] = 0; // loop_cnt
14185 device_param->kernel_params_buf32[27] = 0; // gpu_rules_cnt
14186 device_param->kernel_params_buf32[28] = 0; // digests_cnt
14187 device_param->kernel_params_buf32[29] = 0; // digests_offset
14188 device_param->kernel_params_buf32[30] = 0; // combs_mode
14189 device_param->kernel_params_buf32[31] = 0; // gid_max
14190
14191 device_param->kernel_params[ 0] = (attack_exec == ATTACK_EXEC_ON_GPU)
14192 ? &device_param->d_pws_buf
14193 : &device_param->d_pws_amp_buf;
14194 device_param->kernel_params[ 1] = &device_param->d_rules;
14195 device_param->kernel_params[ 2] = &device_param->d_combs;
14196 device_param->kernel_params[ 3] = &device_param->d_bfs;
14197 device_param->kernel_params[ 4] = &device_param->d_tmps;
14198 device_param->kernel_params[ 5] = &device_param->d_hooks;
14199 device_param->kernel_params[ 6] = &device_param->d_bitmap_s1_a;
14200 device_param->kernel_params[ 7] = &device_param->d_bitmap_s1_b;
14201 device_param->kernel_params[ 8] = &device_param->d_bitmap_s1_c;
14202 device_param->kernel_params[ 9] = &device_param->d_bitmap_s1_d;
14203 device_param->kernel_params[10] = &device_param->d_bitmap_s2_a;
14204 device_param->kernel_params[11] = &device_param->d_bitmap_s2_b;
14205 device_param->kernel_params[12] = &device_param->d_bitmap_s2_c;
14206 device_param->kernel_params[13] = &device_param->d_bitmap_s2_d;
14207 device_param->kernel_params[14] = &device_param->d_plain_bufs;
14208 device_param->kernel_params[15] = &device_param->d_digests_buf;
14209 device_param->kernel_params[16] = &device_param->d_digests_shown;
14210 device_param->kernel_params[17] = &device_param->d_salt_bufs;
14211 device_param->kernel_params[18] = &device_param->d_esalt_bufs;
14212 device_param->kernel_params[19] = &device_param->d_result;
14213 device_param->kernel_params[20] = &device_param->d_scryptV_buf;
14214 device_param->kernel_params[21] = &device_param->kernel_params_buf32[21];
14215 device_param->kernel_params[22] = &device_param->kernel_params_buf32[22];
14216 device_param->kernel_params[23] = &device_param->kernel_params_buf32[23];
14217 device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
14218 device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
14219 device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
14220 device_param->kernel_params[27] = &device_param->kernel_params_buf32[27];
14221 device_param->kernel_params[28] = &device_param->kernel_params_buf32[28];
14222 device_param->kernel_params[29] = &device_param->kernel_params_buf32[29];
14223 device_param->kernel_params[30] = &device_param->kernel_params_buf32[30];
14224 device_param->kernel_params[31] = &device_param->kernel_params_buf32[31];
14225
14226 device_param->kernel_params_mp_buf64[3] = 0;
14227 device_param->kernel_params_mp_buf32[4] = 0;
14228 device_param->kernel_params_mp_buf32[5] = 0;
14229 device_param->kernel_params_mp_buf32[6] = 0;
14230 device_param->kernel_params_mp_buf32[7] = 0;
14231 device_param->kernel_params_mp_buf32[8] = 0;
14232
14233 device_param->kernel_params_mp[0] = NULL;
14234 device_param->kernel_params_mp[1] = NULL;
14235 device_param->kernel_params_mp[2] = NULL;
14236 device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];
14237 device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4];
14238 device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5];
14239 device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6];
14240 device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7];
14241 device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf32[8];
14242
14243 device_param->kernel_params_mp_l_buf64[3] = 0;
14244 device_param->kernel_params_mp_l_buf32[4] = 0;
14245 device_param->kernel_params_mp_l_buf32[5] = 0;
14246 device_param->kernel_params_mp_l_buf32[6] = 0;
14247 device_param->kernel_params_mp_l_buf32[7] = 0;
14248 device_param->kernel_params_mp_l_buf32[8] = 0;
14249 device_param->kernel_params_mp_l_buf32[9] = 0;
14250
14251 device_param->kernel_params_mp_l[0] = NULL;
14252 device_param->kernel_params_mp_l[1] = NULL;
14253 device_param->kernel_params_mp_l[2] = NULL;
14254 device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3];
14255 device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4];
14256 device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5];
14257 device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6];
14258 device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7];
14259 device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8];
14260 device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf32[9];
14261
14262 device_param->kernel_params_mp_r_buf64[3] = 0;
14263 device_param->kernel_params_mp_r_buf32[4] = 0;
14264 device_param->kernel_params_mp_r_buf32[5] = 0;
14265 device_param->kernel_params_mp_r_buf32[6] = 0;
14266 device_param->kernel_params_mp_r_buf32[7] = 0;
14267 device_param->kernel_params_mp_r_buf32[8] = 0;
14268
14269 device_param->kernel_params_mp_r[0] = NULL;
14270 device_param->kernel_params_mp_r[1] = NULL;
14271 device_param->kernel_params_mp_r[2] = NULL;
14272 device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3];
14273 device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4];
14274 device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5];
14275 device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6];
14276 device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7];
14277 device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf32[8];
14278
14279 device_param->kernel_params_amp_buf32[5] = 0; // combs_mode
14280 device_param->kernel_params_amp_buf32[6] = 0; // gid_max
14281
14282 device_param->kernel_params_amp[0] = &device_param->d_pws_buf;
14283 device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf;
14284 device_param->kernel_params_amp[2] = &device_param->d_rules;
14285 device_param->kernel_params_amp[3] = &device_param->d_combs;
14286 device_param->kernel_params_amp[4] = &device_param->d_bfs;
14287 device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5];
14288 device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf32[6];
14289
14290 device_param->kernel_params_tb[0] = &device_param->d_pws_buf;
14291
14292 device_param->kernel_params_tm[0] = &device_param->d_bfs;
14293 device_param->kernel_params_tm[1] = &device_param->d_tm;
14294
14295 /* constant memory init */
14296
14297 CUmodule c_module;
14298
14299 if (attack_exec == ATTACK_EXEC_ON_GPU)
14300 {
14301 c_module = device_param->module;
14302 }
14303 else
14304 {
14305 c_module = device_param->module_amp;
14306 }
14307
14308 size_t c_bytes;
14309
14310 if (attack_kern == ATTACK_KERN_STRAIGHT)
14311 {
14312 CUdeviceptr c_rules;
14313
14314 hc_cuModuleGetGlobal (&c_rules, &c_bytes, c_module, "c_rules");
14315
14316 device_param->c_rules = c_rules;
14317 device_param->c_bytes = c_bytes;
14318
14319 hc_cuMemsetD8 (c_rules, 0, c_bytes);
14320 }
14321 else if (attack_kern == ATTACK_KERN_COMBI)
14322 {
14323 CUdeviceptr c_combs;
14324
14325 hc_cuModuleGetGlobal (&c_combs, &c_bytes, c_module, "c_combs");
14326
14327 device_param->c_combs = c_combs;
14328 device_param->c_bytes = c_bytes;
14329
14330 hc_cuMemsetD8 (c_combs, 0, c_bytes);
14331 }
14332 else if (attack_kern == ATTACK_KERN_BF)
14333 {
14334 CUdeviceptr c_bfs;
14335
14336 hc_cuModuleGetGlobal (&c_bfs, &c_bytes, c_module, "c_bfs");
14337
14338 device_param->c_bfs = c_bfs;
14339 device_param->c_bytes = c_bytes;
14340
14341 hc_cuMemsetD8 (c_bfs, 0, c_bytes);
14342
14343 if (data.opts_type & OPTS_TYPE_PT_BITSLICE)
14344 {
14345 size_t bytes;
14346
14347 CUdeviceptr c_tm;
14348
14349 hc_cuModuleGetGlobal (&c_tm, &bytes, c_module, "c_tm");
14350
14351 device_param->c_tm = c_tm;
14352
14353 hc_cuMemsetD8 (c_tm, 0, bytes);
14354 }
14355 }
14356
14357 hc_cuCtxPopCurrent (NULL);
14358 }
14359
14360 #elif _OCL
14361 for (uint device_id = 0; device_id < devices_cnt; device_id++)
14362 {
14363 /**
14364 * host buffer
14365 */
14366
14367 hc_device_param_t *device_param = &data.devices_param[device_id];
14368
14369 /**
14370 * device properties
14371 */
14372
14373 char *device_name = device_param->device_name;
14374 char *device_version = device_param->device_version;
14375 char *driver_version = device_param->driver_version;
14376
14377 uint gpu_processors = device_param->gpu_processors;
14378 uint gpu_vector_width = device_param->gpu_vector_width;
14379
14380 /**
14381 * create context for each device
14382 */
14383
14384 device_param->context = hc_clCreateContext (NULL, 1, &device_param->device, NULL, NULL);
14385
14386 /**
14387 * create command-queue
14388 */
14389
14390 device_param->command_queue = hc_clCreateCommandQueueWithProperties (device_param->context, device_param->device, NULL);
14391
14392 /**
14393 * create input buffers on device
14394 */
14395
14396 uint gpu_threads = GPU_THREADS_AMD;
14397
14398 if (hash_mode == 3200) gpu_threads = 8;
14399 if (hash_mode == 9000) gpu_threads = 8;
14400
14401 uint gpu_power = gpu_processors * gpu_threads * gpu_accel;
14402
14403 uint gpu_blocks = gpu_power * gpu_vector_width;
14404
14405 device_param->gpu_threads = gpu_threads;
14406 device_param->gpu_power_user = gpu_power;
14407 device_param->gpu_blocks_user = gpu_blocks;
14408
14409 gpu_blocks_all += gpu_blocks;
14410
14411 uint size_pws = gpu_power * sizeof (pw_t);
14412
14413 uint size_tmps = 4;
14414
14415 switch (hash_mode)
14416 {
14417 case 400: size_tmps = gpu_blocks * sizeof (phpass_tmp_t); break;
14418 case 500: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14419 case 501: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14420 case 1600: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14421 case 1800: size_tmps = gpu_blocks * sizeof (sha512crypt_tmp_t); break;
14422 case 2100: size_tmps = gpu_blocks * sizeof (dcc2_tmp_t); break;
14423 case 2500: size_tmps = gpu_blocks * sizeof (wpa_tmp_t); break;
14424 case 3200: size_tmps = gpu_blocks * sizeof (bcrypt_tmp_t); break;
14425 case 5200: size_tmps = gpu_blocks * sizeof (pwsafe3_tmp_t); break;
14426 case 5800: size_tmps = gpu_blocks * sizeof (androidpin_tmp_t); break;
14427 case 6211:
14428 case 6212:
14429 case 6213: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14430 case 6221:
14431 case 6222:
14432 case 6223: size_tmps = gpu_blocks * sizeof (tc64_tmp_t); break;
14433 case 6231:
14434 case 6232:
14435 case 6233: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14436 case 6241:
14437 case 6242:
14438 case 6243: size_tmps = gpu_blocks * sizeof (tc_tmp_t); break;
14439 case 6300: size_tmps = gpu_blocks * sizeof (md5crypt_tmp_t); break;
14440 case 6400: size_tmps = gpu_blocks * sizeof (sha256aix_tmp_t); break;
14441 case 6500: size_tmps = gpu_blocks * sizeof (sha512aix_tmp_t); break;
14442 case 6600: size_tmps = gpu_blocks * sizeof (agilekey_tmp_t); break;
14443 case 6700: size_tmps = gpu_blocks * sizeof (sha1aix_tmp_t); break;
14444 case 6800: size_tmps = gpu_blocks * sizeof (lastpass_tmp_t); break;
14445 case 7100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14446 case 7200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14447 case 7400: size_tmps = gpu_blocks * sizeof (sha256crypt_tmp_t); break;
14448 case 7900: size_tmps = gpu_blocks * sizeof (drupal7_tmp_t); break;
14449 case 8200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14450 case 8800: size_tmps = gpu_blocks * sizeof (androidfde_tmp_t); break;
14451 case 8900: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
14452 case 9000: size_tmps = gpu_blocks * sizeof (pwsafe2_tmp_t); break;
14453 case 9100: size_tmps = gpu_blocks * sizeof (lotus8_tmp_t); break;
14454 case 9200: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14455 case 9300: size_tmps = gpu_blocks * sizeof (scrypt_tmp_t); break;
14456 case 9400: size_tmps = gpu_blocks * sizeof (office2007_tmp_t); break;
14457 case 9500: size_tmps = gpu_blocks * sizeof (office2010_tmp_t); break;
14458 case 9600: size_tmps = gpu_blocks * sizeof (office2013_tmp_t); break;
14459 case 10000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14460 case 10200: size_tmps = gpu_blocks * sizeof (cram_md5_t); break;
14461 case 10300: size_tmps = gpu_blocks * sizeof (saph_sha1_tmp_t); break;
14462 case 10500: size_tmps = gpu_blocks * sizeof (pdf14_tmp_t); break;
14463 case 10700: size_tmps = gpu_blocks * sizeof (pdf17l8_tmp_t); break;
14464 case 10900: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14465 case 11300: size_tmps = gpu_blocks * sizeof (bitcoin_wallet_tmp_t); break;
14466 case 11600: size_tmps = gpu_blocks * sizeof (seven_zip_tmp_t); break;
14467 case 11900: size_tmps = gpu_blocks * sizeof (pbkdf2_md5_tmp_t); break;
14468 case 12000: size_tmps = gpu_blocks * sizeof (pbkdf2_sha1_tmp_t); break;
14469 case 12100: size_tmps = gpu_blocks * sizeof (pbkdf2_sha512_tmp_t); break;
14470 case 12200: size_tmps = gpu_blocks * sizeof (ecryptfs_tmp_t); break;
14471 case 12300: size_tmps = gpu_blocks * sizeof (oraclet_tmp_t); break;
14472 case 12400: size_tmps = gpu_blocks * sizeof (bsdicrypt_tmp_t); break;
14473 case 12500: size_tmps = gpu_blocks * sizeof (rar3_tmp_t); break;
14474 case 12700: size_tmps = gpu_blocks * sizeof (mywallet_tmp_t); break;
14475 case 12800: size_tmps = gpu_blocks * sizeof (pbkdf2_sha256_tmp_t); break;
14476 };
14477
14478 uint size_hooks = 4;
14479
14480 if ((opts_type & OPTS_TYPE_HOOK12) || (opts_type & OPTS_TYPE_HOOK23))
14481 {
14482 // insert correct hook size
14483 }
14484
14485 // we can optimize some stuff here...
14486
14487 device_param->size_pws = size_pws;
14488 device_param->size_tmps = size_tmps;
14489 device_param->size_hooks = size_hooks;
14490
14491 uint size_root_css = SP_PW_MAX * sizeof (cs_t);
14492 uint size_markov_css = SP_PW_MAX * CHARSIZ * sizeof (cs_t);
14493
14494 device_param->size_root_css = size_root_css;
14495 device_param->size_markov_css = size_markov_css;
14496
14497 uint size_results = GPU_THREADS_AMD * sizeof (uint);
14498
14499 device_param->size_results = size_results;
14500
14501 uint size_rules = gpu_rules_cnt * sizeof (gpu_rule_t);
14502 uint size_rules_c = GPU_RULES * sizeof (gpu_rule_t);
14503 uint size_plains = digests_cnt * sizeof (plain_t);
14504 uint size_salts = salts_cnt * sizeof (salt_t);
14505 uint size_esalts = salts_cnt * esalt_size;
14506
14507 device_param->size_plains = size_plains;
14508 device_param->size_digests = size_digests;
14509 device_param->size_shown = size_shown;
14510 device_param->size_salts = size_salts;
14511
14512 uint size_combs = GPU_COMBS * sizeof (comb_t);
14513 uint size_bfs = GPU_BFS * sizeof (bf_t);
14514 uint size_tm = 32 * sizeof (bs_word_t);
14515
14516 uint64_t size_scryptV = 1;
14517
14518 if ((hash_mode == 8900) || (hash_mode == 9300))
14519 {
14520 #define SHADER_PER_MP 8
14521 #define WAVEFRONTS 64
14522
14523 uint tmto_start = 2;
14524 uint tmto_stop = 1024;
14525
14526 if (scrypt_tmto)
14527 {
14528 tmto_start = 1 << scrypt_tmto;
14529 tmto_stop = tmto_start + 1;
14530 }
14531
14532 for (uint tmto = tmto_start; tmto < tmto_stop; tmto <<= 1)
14533 {
14534 // todo -- make sure all salts get the new tmto value
14535
14536 size_scryptV = (128 * data.salts_buf[0].scrypt_r) * data.salts_buf[0].scrypt_N;
14537
14538 size_scryptV /= tmto;
14539
14540 size_scryptV *= gpu_processors * WAVEFRONTS * SHADER_PER_MP;
14541
14542 if (size_scryptV > (device_param->gpu_maxmem_alloc / 2)) continue;
14543
14544 for (uint salts_pos = 0; salts_pos < data.salts_cnt; salts_pos++)
14545 {
14546 data.salts_buf[salts_pos].scrypt_tmto = tmto;
14547 data.salts_buf[salts_pos].scrypt_phy = gpu_processors * WAVEFRONTS * SHADER_PER_MP;
14548 }
14549
14550 break;
14551 }
14552
14553 if (data.salts_buf[0].scrypt_tmto == 0)
14554 {
14555 log_error ("ERROR: can't allocate enough GPU memory");
14556
14557 return -1;
14558 }
14559
14560 if (quiet == 0) log_info ("");
14561 if (quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u\n", data.salts_buf[0].scrypt_tmto);
14562 }
14563
14564 /**
14565 * kernel find
14566 */
14567
14568 uint vliw = get_vliw_by_device_name (device_name);
14569
14570 struct stat st;
14571
14572 char kernel_file[256];
14573
14574 memset (kernel_file, 0, sizeof (kernel_file));
14575
14576 size_t *kernel_lengths = (size_t *) mymalloc (sizeof (size_t));
14577
14578 const unsigned char **kernel_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14579
14580 #ifdef BINARY_KERNEL
14581 if (attack_exec == ATTACK_EXEC_ON_GPU)
14582 {
14583 if (attack_kern == ATTACK_KERN_STRAIGHT)
14584 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d_a0.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
14585 else if (attack_kern == ATTACK_KERN_COMBI)
14586 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d_a1.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
14587 else if (attack_kern == ATTACK_KERN_BF)
14588 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d_a3.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
14589 }
14590 else
14591 {
14592 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, device_name, device_version, driver_version, COMPTIME);
14593
14594 if ((hash_mode == 8900) || (hash_mode == 9300))
14595 {
14596 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/kernels/4098/m%05d_%d_%d_%d_%d.%s_%s_%s_%d.kernel", install_dir, (int) kern_type, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto, device_name, device_version, driver_version, COMPTIME);
14597 }
14598 }
14599
14600 if (stat (kernel_file, &st) == -1)
14601 {
14602 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_file);
14603
14604 char module_file[256];
14605
14606 memset (module_file, 0, sizeof (module_file));
14607
14608 if (attack_exec == ATTACK_EXEC_ON_GPU)
14609 {
14610 if (attack_kern == ATTACK_KERN_STRAIGHT)
14611 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a0.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14612 else if (attack_kern == ATTACK_KERN_COMBI)
14613 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a1.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14614 else if (attack_kern == ATTACK_KERN_BF)
14615 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_a3.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14616 }
14617 else
14618 {
14619 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d.VLIW%d.llvmir", install_dir, (int) kern_type, vliw);
14620
14621 if ((hash_mode == 8900) || (hash_mode == 9300))
14622 {
14623 snprintf (module_file, sizeof (module_file) - 1, "%s/kernels/4098/m%05d_%d_%d_%d_%d.VLIW%d.llvmir", install_dir, (int) kern_type, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto, vliw);
14624 }
14625 }
14626
14627 load_kernel (module_file, 1, kernel_lengths, kernel_sources);
14628
14629 cl_program program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
14630
14631 local_free (kernel_sources[0]);
14632
14633 hc_clBuildProgram (program, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14634
14635 size_t binary_size;
14636
14637 clGetProgramInfo (program, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL);
14638
14639 unsigned char *binary = (unsigned char *) mymalloc (binary_size);
14640
14641 clGetProgramInfo (program, CL_PROGRAM_BINARIES, sizeof (binary), &binary, NULL);
14642
14643 writeProgramBin (kernel_file, binary, binary_size);
14644
14645 local_free (binary);
14646
14647 stat (kernel_file, &st); // to reload filesize
14648 }
14649
14650 #else
14651 if (attack_exec == ATTACK_EXEC_ON_GPU)
14652 {
14653 if (attack_kern == ATTACK_KERN_STRAIGHT)
14654 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a0.cl", install_dir, (int) kern_type);
14655 else if (attack_kern == ATTACK_KERN_COMBI)
14656 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a1.cl", install_dir, (int) kern_type);
14657 else if (attack_kern == ATTACK_KERN_BF)
14658 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d_a3.cl", install_dir, (int) kern_type);
14659 }
14660 else
14661 snprintf (kernel_file, sizeof (kernel_file) - 1, "%s/amd/m%05d.cl", install_dir, (int) kern_type);
14662
14663 if (stat (kernel_file, &st) == -1)
14664 {
14665 log_error ("ERROR: %s: %s", kernel_file, strerror (errno));
14666
14667 return -1;
14668 }
14669
14670 #endif
14671
14672 load_kernel (kernel_file, 1, kernel_lengths, kernel_sources);
14673
14674 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_file, st.st_size);
14675
14676 #ifdef BINARY_KERNEL
14677 device_param->program = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_lengths, (const unsigned char **) kernel_sources, NULL);
14678 #else
14679 device_param->program = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_sources, NULL);
14680 #endif
14681
14682 local_free (kernel_lengths);
14683
14684 local_free (kernel_sources[0]);
14685
14686 local_free (kernel_sources)
14687
14688 /**
14689 * kernel mp find
14690 */
14691
14692 if (attack_mode != ATTACK_MODE_STRAIGHT)
14693 {
14694 char kernel_mp_file[256];
14695
14696 memset (kernel_mp_file, 0, sizeof (kernel_mp_file));
14697
14698 size_t *kernel_mp_lengths = (size_t *) mymalloc (sizeof (size_t));
14699
14700 const unsigned char **kernel_mp_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14701
14702 #ifdef BINARY_KERNEL
14703 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14704 {
14705 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/kernels/4098/markov_be_v%d.%s_%s_%s_%d.kernel", install_dir, gpu_vector_width, device_name, device_version, driver_version, COMPTIME);
14706 }
14707 else
14708 {
14709 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/kernels/4098/markov_le_v%d.%s_%s_%s_%d.kernel", install_dir, gpu_vector_width, device_name, device_version, driver_version, COMPTIME);
14710 }
14711
14712 if (stat (kernel_mp_file, &st) == -1)
14713 {
14714 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_mp_file);
14715
14716 char module_mp_file[256];
14717
14718 memset (module_mp_file, 0, sizeof (module_mp_file));
14719
14720 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14721 {
14722 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4098/markov_be_v%d.llvmir", install_dir, gpu_vector_width);
14723 }
14724 else
14725 {
14726 snprintf (module_mp_file, sizeof (module_mp_file) - 1, "%s/kernels/4098/markov_le_v%d.llvmir", install_dir, gpu_vector_width);
14727 }
14728
14729 load_kernel (module_mp_file, 1, kernel_mp_lengths, kernel_mp_sources);
14730
14731 cl_program program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_mp_lengths, (const unsigned char **) kernel_mp_sources, NULL);
14732
14733 local_free (kernel_mp_sources[0]);
14734
14735 hc_clBuildProgram (program_mp, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14736
14737 size_t binary_mp_size;
14738
14739 clGetProgramInfo (program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_mp_size, NULL);
14740
14741 unsigned char *binary_mp = (unsigned char *) mymalloc (binary_mp_size);
14742
14743 clGetProgramInfo (program_mp, CL_PROGRAM_BINARIES, sizeof (binary_mp), &binary_mp, NULL);
14744
14745 writeProgramBin (kernel_mp_file, binary_mp, binary_mp_size);
14746
14747 local_free (binary_mp);
14748
14749 stat (kernel_mp_file, &st); // to reload filesize
14750 }
14751
14752 #else
14753 if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
14754 {
14755 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/amd/markov_be_v%d.cl", install_dir, gpu_vector_width);
14756 }
14757 else
14758 {
14759 snprintf (kernel_mp_file, sizeof (kernel_mp_file) - 1, "%s/amd/markov_le_v%d.cl", install_dir, gpu_vector_width);
14760 }
14761
14762 if (stat (kernel_mp_file, &st) == -1)
14763 {
14764 log_error ("ERROR: %s: %s", kernel_mp_file, strerror (errno));
14765
14766 return -1;
14767 }
14768
14769 #endif
14770
14771 load_kernel (kernel_mp_file, 1, kernel_mp_lengths, kernel_mp_sources);
14772
14773 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_mp_file, st.st_size);
14774
14775 #ifdef BINARY_KERNEL
14776 device_param->program_mp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_mp_lengths, (const unsigned char **) kernel_mp_sources, NULL);
14777 #else
14778 device_param->program_mp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_mp_sources, NULL);
14779 #endif
14780
14781 local_free (kernel_mp_lengths);
14782
14783 local_free (kernel_mp_sources[0]);
14784
14785 local_free (kernel_mp_sources);
14786 }
14787
14788 /**
14789 * kernel amp find
14790 */
14791
14792 if (attack_exec == ATTACK_EXEC_ON_GPU)
14793 {
14794 // nothing to do
14795 }
14796 else
14797 {
14798 char kernel_amp_file[256];
14799
14800 memset (kernel_amp_file, 0, sizeof (kernel_amp_file));
14801
14802 size_t *kernel_amp_lengths = (size_t *) mymalloc (sizeof (size_t));
14803
14804 const unsigned char **kernel_amp_sources = (const unsigned char **) mymalloc (sizeof (unsigned char *));
14805
14806 #ifdef BINARY_KERNEL
14807 snprintf (kernel_amp_file, sizeof (kernel_amp_file) - 1, "%s/kernels/4098/amp_a%d_v%d.%s_%s_%s_%d.kernel", install_dir, attack_kern, gpu_vector_width, device_name, device_version, driver_version, COMPTIME);
14808
14809 if (stat (kernel_amp_file, &st) == -1)
14810 {
14811 if (quiet == 0) log_info ("Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, kernel_amp_file);
14812
14813 char module_amp_file[256];
14814
14815 memset (module_amp_file, 0, sizeof (module_amp_file));
14816
14817 snprintf (module_amp_file, sizeof (module_amp_file) - 1, "%s/kernels/4098/amp_a%d_v%d.llvmir", install_dir, attack_kern, gpu_vector_width);
14818
14819 load_kernel (module_amp_file, 1, kernel_amp_lengths, kernel_amp_sources);
14820
14821 cl_program program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_amp_lengths, (const unsigned char **) kernel_amp_sources, NULL);
14822
14823 local_free (kernel_amp_sources[0]);
14824
14825 hc_clBuildProgram (program_amp, 1, &device_param->device, "-cl-std=CL1.2", NULL, NULL);
14826
14827 size_t binary_amp_size;
14828
14829 clGetProgramInfo (program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_amp_size, NULL);
14830
14831 unsigned char *binary_amp = (unsigned char *) mymalloc (binary_amp_size);
14832
14833 clGetProgramInfo (program_amp, CL_PROGRAM_BINARIES, sizeof (binary_amp), &binary_amp, NULL);
14834
14835 writeProgramBin (kernel_amp_file, binary_amp, binary_amp_size);
14836
14837 local_free (binary_amp);
14838
14839 stat (kernel_amp_file, &st); // to reload filesize
14840 }
14841 #else
14842 snprintf (kernel_amp_file, sizeof (kernel_amp_file) - 1, "%s/amd/amp_a%d_v%d.cl", install_dir, attack_kern, gpu_vector_width);
14843
14844 if (stat (kernel_amp_file, &st) == -1)
14845 {
14846 log_error ("ERROR: %s: %s", kernel_amp_file, strerror (errno));
14847
14848 return -1;
14849 }
14850 #endif
14851
14852 load_kernel (kernel_amp_file, 1, kernel_amp_lengths, kernel_amp_sources);
14853
14854 if (quiet == 0) log_info ("Device #%u: Kernel %s (%ld bytes)", device_id + 1, kernel_amp_file, st.st_size);
14855
14856 #ifdef BINARY_KERNEL
14857 device_param->program_amp = hc_clCreateProgramWithBinary (device_param->context, 1, &device_param->device, kernel_amp_lengths, (const unsigned char **) kernel_amp_sources, NULL);
14858 #else
14859 device_param->program_amp = hc_clCreateProgramWithSource (device_param->context, 1, (const char **) kernel_amp_sources, NULL);
14860 #endif
14861
14862 local_free (kernel_amp_lengths);
14863
14864 local_free (kernel_amp_sources[0]);
14865
14866 local_free (kernel_amp_sources);
14867 }
14868
14869 /**
14870 * kernel compile
14871 */
14872
14873 char *build_opts = NULL;
14874
14875 #ifndef BINARY_KERNEL
14876 build_opts = (char *) mymalloc (256);
14877
14878 sprintf (build_opts, "-I . -I amd/ -D VLIW%d -x clc++ -cl-std=CL1.2", vliw);
14879
14880 if ((hash_mode == 8900) || (hash_mode == 9300))
14881 {
14882 sprintf (build_opts, "-I . -I amd/ -D VLIW%d -x clc++ -cl-std=CL1.2 -DSCRYPT_N=%d -DSCRYPT_R=%d -DSCRYPT_P=%d -DSCRYPT_TMTO=%d", vliw, data.salts_buf[0].scrypt_N, data.salts_buf[0].scrypt_r, data.salts_buf[0].scrypt_p, data.salts_buf[0].scrypt_tmto);
14883 }
14884 #endif
14885
14886 clBuildProgram (device_param->program, 1, &device_param->device, build_opts, NULL, NULL);
14887
14888 size_t ret_val_size = 0;
14889
14890 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
14891
14892 if (ret_val_size > 1)
14893 {
14894 char *build_log = (char *) malloc (ret_val_size + 1);
14895
14896 memset (build_log, 0, ret_val_size + 1);
14897
14898 clGetProgramBuildInfo (device_param->program, device_param->device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
14899
14900 puts (build_log);
14901
14902 free (build_log);
14903 }
14904
14905 if (attack_mode != ATTACK_MODE_STRAIGHT)
14906 {
14907 hc_clBuildProgram (device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL);
14908 }
14909
14910 if (attack_exec == ATTACK_EXEC_ON_GPU)
14911 {
14912 // nothing to do
14913 }
14914 else
14915 {
14916 hc_clBuildProgram (device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL);
14917 }
14918
14919 /**
14920 * amp is not independent
14921 */
14922
14923 if (attack_exec == ATTACK_EXEC_ON_GPU)
14924 {
14925 // nothing to do
14926 }
14927 else
14928 {
14929 device_param->kernel_amp = hc_clCreateKernel (device_param->program_amp, "amp");
14930 }
14931
14932 /**
14933 * global buffers
14934 */
14935
14936 device_param->d_pws_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
14937 device_param->d_pws_amp_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_pws, NULL);
14938 device_param->d_tmps = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_tmps, NULL);
14939 device_param->d_hooks = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_hooks, NULL);
14940 device_param->d_bitmap_s1_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14941 device_param->d_bitmap_s1_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14942 device_param->d_bitmap_s1_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14943 device_param->d_bitmap_s1_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14944 device_param->d_bitmap_s2_a = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14945 device_param->d_bitmap_s2_b = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14946 device_param->d_bitmap_s2_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14947 device_param->d_bitmap_s2_d = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, bitmap_size, NULL);
14948 device_param->d_plain_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_plains, NULL);
14949 device_param->d_digests_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_digests, NULL);
14950 device_param->d_digests_shown = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_shown, NULL);
14951 device_param->d_salt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_salts, NULL);
14952 device_param->d_result = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_results, NULL);
14953 device_param->d_scryptV_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_WRITE, size_scryptV, NULL);
14954
14955 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_a, CL_TRUE, 0, bitmap_size, bitmap_s1_a, 0, NULL, NULL);
14956 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_b, CL_TRUE, 0, bitmap_size, bitmap_s1_b, 0, NULL, NULL);
14957 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_c, CL_TRUE, 0, bitmap_size, bitmap_s1_c, 0, NULL, NULL);
14958 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s1_d, CL_TRUE, 0, bitmap_size, bitmap_s1_d, 0, NULL, NULL);
14959 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_a, CL_TRUE, 0, bitmap_size, bitmap_s2_a, 0, NULL, NULL);
14960 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_b, CL_TRUE, 0, bitmap_size, bitmap_s2_b, 0, NULL, NULL);
14961 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_c, CL_TRUE, 0, bitmap_size, bitmap_s2_c, 0, NULL, NULL);
14962 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_bitmap_s2_d, CL_TRUE, 0, bitmap_size, bitmap_s2_d, 0, NULL, NULL);
14963 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_buf, CL_TRUE, 0, size_digests, data.digests_buf, 0, NULL, NULL);
14964 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_digests_shown, CL_TRUE, 0, size_shown, data.digests_shown, 0, NULL, NULL);
14965 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_salt_bufs, CL_TRUE, 0, size_salts, data.salts_buf, 0, NULL, NULL);
14966
14967 run_kernel_bzero (device_param, device_param->d_pws_buf, size_pws);
14968 run_kernel_bzero (device_param, device_param->d_pws_amp_buf, size_pws);
14969 run_kernel_bzero (device_param, device_param->d_tmps, size_tmps);
14970 run_kernel_bzero (device_param, device_param->d_hooks, size_hooks);
14971 run_kernel_bzero (device_param, device_param->d_plain_bufs, size_plains);
14972 run_kernel_bzero (device_param, device_param->d_result, size_results);
14973
14974 /**
14975 * special buffers
14976 */
14977
14978 if (attack_kern == ATTACK_KERN_STRAIGHT)
14979 {
14980 device_param->d_rules = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules, NULL);
14981 device_param->d_rules_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL);
14982
14983 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, gpu_rules_buf, 0, NULL, NULL);
14984
14985 run_kernel_bzero (device_param, device_param->d_rules_c, size_rules_c);
14986 }
14987 else if (attack_kern == ATTACK_KERN_COMBI)
14988 {
14989 device_param->d_combs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
14990 device_param->d_combs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_combs, NULL);
14991 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
14992 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
14993
14994 run_kernel_bzero (device_param, device_param->d_combs, size_combs);
14995 run_kernel_bzero (device_param, device_param->d_combs_c, size_combs);
14996 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
14997 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
14998 }
14999 else if (attack_kern == ATTACK_KERN_BF)
15000 {
15001 device_param->d_bfs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
15002 device_param->d_bfs_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL);
15003 device_param->d_tm_c = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_tm, NULL);
15004 device_param->d_root_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL);
15005 device_param->d_markov_css_buf = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL);
15006
15007 run_kernel_bzero (device_param, device_param->d_bfs, size_bfs);
15008 run_kernel_bzero (device_param, device_param->d_bfs_c, size_bfs);
15009 run_kernel_bzero (device_param, device_param->d_tm_c, size_tm);
15010 run_kernel_bzero (device_param, device_param->d_root_css_buf, size_root_css);
15011 run_kernel_bzero (device_param, device_param->d_markov_css_buf, size_markov_css);
15012 }
15013
15014 if (size_esalts)
15015 {
15016 device_param->d_esalt_bufs = hc_clCreateBuffer (device_param->context, CL_MEM_READ_ONLY, size_esalts, NULL);
15017
15018 hc_clEnqueueWriteBuffer (device_param->command_queue, device_param->d_esalt_bufs, CL_TRUE, 0, size_esalts, data.esalts_buf, 0, NULL, NULL);
15019 }
15020
15021 /**
15022 * main host data
15023 */
15024
15025 uint *result = (uint *) mymalloc (size_results);
15026
15027 memset (result, 0, size_results);
15028
15029 device_param->result = result;
15030
15031 pw_t *pws_buf = (pw_t *) mymalloc (size_pws);
15032
15033 memset (pws_buf, 0, size_pws);
15034
15035 device_param->pws_buf = pws_buf;
15036
15037 pw_cache_t *pw_caches = (pw_cache_t *) mycalloc (64, sizeof (pw_cache_t));
15038
15039 for (int i = 0; i < 64; i++)
15040 {
15041 pw_caches[i].pw_buf.pw_len = i;
15042 pw_caches[i].cnt = 0;
15043 }
15044
15045 device_param->pw_caches = pw_caches;
15046
15047 comb_t *combs_buf = (comb_t *) mycalloc (GPU_COMBS, sizeof (comb_t));
15048
15049 device_param->combs_buf = combs_buf;
15050
15051 void *hooks_buf = mymalloc (size_hooks);
15052
15053 device_param->hooks_buf = hooks_buf;
15054
15055 switch (device_param->gpu_vector_width)
15056 {
15057 case 1: device_param->pw_transpose = pw_transpose_to_hi1;
15058 device_param->pw_add = pw_add_to_hc1;
15059 break;
15060 case 2: device_param->pw_transpose = pw_transpose_to_hi2;
15061 device_param->pw_add = pw_add_to_hc2;
15062 break;
15063 case 4: device_param->pw_transpose = pw_transpose_to_hi4;
15064 device_param->pw_add = pw_add_to_hc4;
15065 break;
15066 }
15067
15068 /**
15069 * kernel args
15070 */
15071
15072 device_param->kernel_params_buf32[21] = bitmap_mask;
15073 device_param->kernel_params_buf32[22] = bitmap_shift1;
15074 device_param->kernel_params_buf32[23] = bitmap_shift2;
15075 device_param->kernel_params_buf32[24] = 0; // salt_pos
15076 device_param->kernel_params_buf32[25] = 0; // loop_pos
15077 device_param->kernel_params_buf32[26] = 0; // loop_cnt
15078 device_param->kernel_params_buf32[27] = 0; // gpu_rules_cnt
15079 device_param->kernel_params_buf32[28] = 0; // digests_cnt
15080 device_param->kernel_params_buf32[29] = 0; // digests_offset
15081 device_param->kernel_params_buf32[30] = 0; // combs_mode
15082 device_param->kernel_params_buf32[31] = 0; // gid_max
15083
15084 device_param->kernel_params[ 0] = (attack_exec == ATTACK_EXEC_ON_GPU)
15085 ? &device_param->d_pws_buf
15086 : &device_param->d_pws_amp_buf;
15087 device_param->kernel_params[ 1] = &device_param->d_rules_c;
15088 device_param->kernel_params[ 2] = &device_param->d_combs_c;
15089 device_param->kernel_params[ 3] = &device_param->d_bfs_c;
15090 device_param->kernel_params[ 4] = &device_param->d_tmps;
15091 device_param->kernel_params[ 5] = &device_param->d_hooks;
15092 device_param->kernel_params[ 6] = &device_param->d_bitmap_s1_a;
15093 device_param->kernel_params[ 7] = &device_param->d_bitmap_s1_b;
15094 device_param->kernel_params[ 8] = &device_param->d_bitmap_s1_c;
15095 device_param->kernel_params[ 9] = &device_param->d_bitmap_s1_d;
15096 device_param->kernel_params[10] = &device_param->d_bitmap_s2_a;
15097 device_param->kernel_params[11] = &device_param->d_bitmap_s2_b;
15098 device_param->kernel_params[12] = &device_param->d_bitmap_s2_c;
15099 device_param->kernel_params[13] = &device_param->d_bitmap_s2_d;
15100 device_param->kernel_params[14] = &device_param->d_plain_bufs;
15101 device_param->kernel_params[15] = &device_param->d_digests_buf;
15102 device_param->kernel_params[16] = &device_param->d_digests_shown;
15103 device_param->kernel_params[17] = &device_param->d_salt_bufs;
15104 device_param->kernel_params[18] = &device_param->d_esalt_bufs;
15105 device_param->kernel_params[19] = &device_param->d_result;
15106 device_param->kernel_params[20] = &device_param->d_scryptV_buf;
15107 device_param->kernel_params[21] = &device_param->kernel_params_buf32[21];
15108 device_param->kernel_params[22] = &device_param->kernel_params_buf32[22];
15109 device_param->kernel_params[23] = &device_param->kernel_params_buf32[23];
15110 device_param->kernel_params[24] = &device_param->kernel_params_buf32[24];
15111 device_param->kernel_params[25] = &device_param->kernel_params_buf32[25];
15112 device_param->kernel_params[26] = &device_param->kernel_params_buf32[26];
15113 device_param->kernel_params[27] = &device_param->kernel_params_buf32[27];
15114 device_param->kernel_params[28] = &device_param->kernel_params_buf32[28];
15115 device_param->kernel_params[29] = &device_param->kernel_params_buf32[29];
15116 device_param->kernel_params[30] = &device_param->kernel_params_buf32[30];
15117 device_param->kernel_params[31] = &device_param->kernel_params_buf32[31];
15118
15119 device_param->kernel_params_mp_buf64[3] = 0;
15120 device_param->kernel_params_mp_buf32[4] = 0;
15121 device_param->kernel_params_mp_buf32[5] = 0;
15122 device_param->kernel_params_mp_buf32[6] = 0;
15123 device_param->kernel_params_mp_buf32[7] = 0;
15124 device_param->kernel_params_mp_buf32[8] = 0;
15125
15126 device_param->kernel_params_mp[0] = NULL;
15127 device_param->kernel_params_mp[1] = NULL;
15128 device_param->kernel_params_mp[2] = NULL;
15129 device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];
15130 device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4];
15131 device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5];
15132 device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6];
15133 device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7];
15134 device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf32[8];
15135
15136 device_param->kernel_params_mp_l_buf64[3] = 0;
15137 device_param->kernel_params_mp_l_buf32[4] = 0;
15138 device_param->kernel_params_mp_l_buf32[5] = 0;
15139 device_param->kernel_params_mp_l_buf32[6] = 0;
15140 device_param->kernel_params_mp_l_buf32[7] = 0;
15141 device_param->kernel_params_mp_l_buf32[8] = 0;
15142 device_param->kernel_params_mp_l_buf32[9] = 0;
15143
15144 device_param->kernel_params_mp_l[0] = NULL;
15145 device_param->kernel_params_mp_l[1] = NULL;
15146 device_param->kernel_params_mp_l[2] = NULL;
15147 device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3];
15148 device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4];
15149 device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5];
15150 device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6];
15151 device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7];
15152 device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8];
15153 device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf32[9];
15154
15155 device_param->kernel_params_mp_r_buf64[3] = 0;
15156 device_param->kernel_params_mp_r_buf32[4] = 0;
15157 device_param->kernel_params_mp_r_buf32[5] = 0;
15158 device_param->kernel_params_mp_r_buf32[6] = 0;
15159 device_param->kernel_params_mp_r_buf32[7] = 0;
15160 device_param->kernel_params_mp_r_buf32[8] = 0;
15161
15162 device_param->kernel_params_mp_r[0] = NULL;
15163 device_param->kernel_params_mp_r[1] = NULL;
15164 device_param->kernel_params_mp_r[2] = NULL;
15165 device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3];
15166 device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4];
15167 device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5];
15168 device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6];
15169 device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7];
15170 device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf32[8];
15171
15172 device_param->kernel_params_amp_buf32[5] = 0; // combs_mode
15173 device_param->kernel_params_amp_buf32[6] = 0; // gid_max
15174
15175 device_param->kernel_params_amp[0] = &device_param->d_pws_buf;
15176 device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf;
15177 device_param->kernel_params_amp[2] = &device_param->d_rules_c;
15178 device_param->kernel_params_amp[3] = &device_param->d_combs_c;
15179 device_param->kernel_params_amp[4] = &device_param->d_bfs_c;
15180 device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5];
15181 device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf32[6];
15182
15183 device_param->kernel_params_tb[0] = &device_param->d_pws_buf;
15184
15185 device_param->kernel_params_tm[0] = &device_param->d_bfs_c;
15186 device_param->kernel_params_tm[1] = &device_param->d_tm_c;
15187
15188 /**
15189 * kernel name
15190 */
15191
15192 char kernel_name[64];
15193
15194 memset (kernel_name, 0, sizeof (kernel_name));
15195
15196 if (attack_exec == ATTACK_EXEC_ON_GPU)
15197 {
15198 if (opti_type & OPTI_TYPE_SINGLE_HASH)
15199 {
15200 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 4);
15201
15202 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15203
15204 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 8);
15205
15206 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15207
15208 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_s%02d", kern_type, 16);
15209
15210 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15211 }
15212 else
15213 {
15214 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 4);
15215
15216 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15217
15218 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 8);
15219
15220 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15221
15222 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_m%02d", kern_type, 16);
15223
15224 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15225 }
15226
15227 if (data.attack_mode == ATTACK_MODE_BF)
15228 {
15229 if (opts_type & OPTS_TYPE_PT_BITSLICE)
15230 {
15231 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tb", kern_type);
15232
15233 device_param->kernel_tb = hc_clCreateKernel (device_param->program, kernel_name);
15234
15235 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_tm", kern_type);
15236
15237 device_param->kernel_tm = hc_clCreateKernel (device_param->program, kernel_name);
15238 }
15239 }
15240 }
15241 else
15242 {
15243 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_init", kern_type);
15244
15245 device_param->kernel1 = hc_clCreateKernel (device_param->program, kernel_name);
15246
15247 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_loop", kern_type);
15248
15249 device_param->kernel2 = hc_clCreateKernel (device_param->program, kernel_name);
15250
15251 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_comp", kern_type);
15252
15253 device_param->kernel3 = hc_clCreateKernel (device_param->program, kernel_name);
15254
15255 if (opts_type & OPTS_TYPE_HOOK12)
15256 {
15257 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook12", kern_type);
15258
15259 device_param->kernel12 = hc_clCreateKernel (device_param->program, kernel_name);
15260 }
15261
15262 if (opts_type & OPTS_TYPE_HOOK23)
15263 {
15264 snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05d_hook23", kern_type);
15265
15266 device_param->kernel23 = hc_clCreateKernel (device_param->program, kernel_name);
15267 }
15268 }
15269
15270 for (uint i = 0; i <= 20; i++)
15271 {
15272 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_mem), device_param->kernel_params[i]);
15273 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_mem), device_param->kernel_params[i]);
15274 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_mem), device_param->kernel_params[i]);
15275
15276 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_mem), device_param->kernel_params[i]);
15277 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_mem), device_param->kernel_params[i]);
15278 }
15279
15280 for (uint i = 21; i <= 31; i++)
15281 {
15282 hc_clSetKernelArg (device_param->kernel1, i, sizeof (cl_uint), device_param->kernel_params[i]);
15283 hc_clSetKernelArg (device_param->kernel2, i, sizeof (cl_uint), device_param->kernel_params[i]);
15284 hc_clSetKernelArg (device_param->kernel3, i, sizeof (cl_uint), device_param->kernel_params[i]);
15285
15286 if (opts_type & OPTS_TYPE_HOOK12) hc_clSetKernelArg (device_param->kernel12, i, sizeof (cl_uint), device_param->kernel_params[i]);
15287 if (opts_type & OPTS_TYPE_HOOK23) hc_clSetKernelArg (device_param->kernel23, i, sizeof (cl_uint), device_param->kernel_params[i]);
15288 }
15289
15290 if (attack_mode == ATTACK_MODE_BF)
15291 {
15292 device_param->kernel_mp_l = hc_clCreateKernel (device_param->program_mp, "l_markov");
15293 device_param->kernel_mp_r = hc_clCreateKernel (device_param->program_mp, "r_markov");
15294
15295 if (opts_type & OPTS_TYPE_PT_BITSLICE)
15296 {
15297 hc_clSetKernelArg (device_param->kernel_tb, 0, sizeof (cl_mem), device_param->kernel_params_tb[0]);
15298
15299 hc_clSetKernelArg (device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]);
15300 hc_clSetKernelArg (device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]);
15301 }
15302 }
15303 else if (attack_mode == ATTACK_MODE_HYBRID1)
15304 {
15305 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
15306 }
15307 else if (attack_mode == ATTACK_MODE_HYBRID2)
15308 {
15309 device_param->kernel_mp = hc_clCreateKernel (device_param->program_mp, "C_markov");
15310 }
15311
15312 if (attack_exec == ATTACK_EXEC_ON_GPU)
15313 {
15314 // nothing to do
15315 }
15316 else
15317 {
15318 for (uint i = 0; i < 5; i++)
15319 {
15320 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]);
15321 }
15322
15323 for (uint i = 5; i < 7; i++)
15324 {
15325 hc_clSetKernelArg (device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]);
15326 }
15327 }
15328
15329 /**
15330 * Store initial fanspeed if gpu_temp_retain is enabled
15331 */
15332
15333 if (gpu_temp_disable == 0)
15334 {
15335 if (gpu_temp_retain != 0)
15336 {
15337 hc_thread_mutex_lock (mux_adl);
15338
15339 if (data.hm_device[device_id].fan_supported == 1)
15340 {
15341 if (gpu_temp_retain_chgd == 0)
15342 {
15343 uint cur_temp = 0;
15344 uint default_temp = 0;
15345
15346 int ADL_rc = hc_ADL_Overdrive6_TargetTemperatureData_Get (data.hm_dll, data.hm_device[device_id].adapter_index, (int *) &cur_temp, (int *) &default_temp);
15347
15348 if (ADL_rc == ADL_OK)
15349 {
15350 #define GPU_TEMP_RETAIN_ABORT_DIFF 15
15351
15352 const uint gpu_temp_retain_target = default_temp - GPU_TEMP_RETAIN_ABORT_DIFF;
15353
15354 // special case with multi gpu setups: always use minimum retain
15355
15356 if (gpu_temp_retain_set == 0)
15357 {
15358 gpu_temp_retain = gpu_temp_retain_target;
15359 gpu_temp_retain_set = 1;
15360 }
15361 else
15362 {
15363 gpu_temp_retain = MIN (gpu_temp_retain, gpu_temp_retain_target);
15364 }
15365
15366 if (gpu_temp_abort_chgd == 0) gpu_temp_abort = gpu_temp_retain + GPU_TEMP_RETAIN_ABORT_DIFF;
15367 }
15368 }
15369
15370 const int fan_speed = hm_get_fanspeed_with_device_id (device_id);
15371
15372 temp_retain_fanspeed_value[device_id] = fan_speed;
15373
15374 if (fan_speed == -1)
15375 {
15376 log_info ("WARNING: Failed to get current fan speed settings for gpu number: %i:", device_id + 1);
15377
15378 temp_retain_fanspeed_value[device_id] = 0;
15379 }
15380 }
15381
15382 hc_thread_mutex_unlock (mux_adl);
15383 }
15384 }
15385
15386 /**
15387 * Store original powercontrol/clocks settings, set overdrive 6 performance tuning settings
15388 */
15389
15390 if (powertune_enable == 1)
15391 {
15392 hc_thread_mutex_lock (mux_adl);
15393
15394 if (data.hm_device[device_id].od_version == 6)
15395 {
15396 int ADL_rc;
15397
15398 // check powertune capabilities first, if not available then skip device
15399
15400 int powertune_supported = 0;
15401
15402 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune_supported)) != ADL_OK)
15403 {
15404 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
15405
15406 return (-1);
15407 }
15408
15409 if (powertune_supported != 0)
15410 {
15411 // powercontrol settings
15412
15413 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
15414
15415 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &powertune)) == ADL_OK)
15416 {
15417 ADL_rc = hc_ADL_Overdrive_PowerControl_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &od_power_control_status[device_id]);
15418 }
15419
15420 if (ADL_rc != ADL_OK)
15421 {
15422 log_error ("ERROR: Failed to get current ADL PowerControl settings");
15423
15424 return (-1);
15425 }
15426
15427 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[device_id].adapter_index, powertune.iMaxValue)) != ADL_OK)
15428 {
15429 log_error ("ERROR: Failed to set new ADL PowerControl values");
15430
15431 return (-1);
15432 }
15433
15434 // clocks
15435
15436 memset (&od_clock_mem_status[device_id], 0, sizeof (ADLOD6MemClockState));
15437
15438 od_clock_mem_status[device_id].state.iNumberOfPerformanceLevels = 2;
15439
15440 if ((ADL_rc = hc_ADL_Overdrive_StateInfo_Get (data.hm_dll, data.hm_device[device_id].adapter_index, ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE, &od_clock_mem_status[device_id])) != ADL_OK)
15441 {
15442 log_error ("ERROR: Failed to get ADL memory and engine clock frequency");
15443
15444 return (-1);
15445 }
15446
15447 // Query capabilities only to see if profiles were not "damaged", if so output a warning but do accept the users profile settings
15448
15449 ADLOD6Capabilities caps = {0, 0, 0, {0, 0, 0}, {0, 0, 0}, 0, 0};
15450
15451 if ((ADL_rc = hc_ADL_Overdrive_Capabilities_Get (data.hm_dll, data.hm_device[device_id].adapter_index, &caps)) != ADL_OK)
15452 {
15453 log_error ("ERROR: Failed to get ADL device capabilities");
15454
15455 return (-1);
15456 }
15457
15458 int engine_clock_max = caps.sEngineClockRange.iMax * 0.6666;
15459 int memory_clock_max = caps.sMemoryClockRange.iMax * 0.6250;
15460
15461 int warning_trigger_engine = (int) (0.25 * (float) engine_clock_max);
15462 int warning_trigger_memory = (int) (0.25 * (float) memory_clock_max);
15463
15464 int engine_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iEngineClock;
15465 int memory_clock_profile_max = od_clock_mem_status[device_id].state.aLevels[1].iMemoryClock;
15466
15467 // warning if profile has to low max values
15468
15469 if ((engine_clock_max - engine_clock_profile_max) > warning_trigger_engine)
15470 {
15471 log_info ("WARN: the custom profile seems to have too low maximum engine clock values. You therefore may not reach full performance");
15472 }
15473
15474 if ((memory_clock_max - memory_clock_profile_max) > warning_trigger_memory)
15475 {
15476 log_info ("WARN: the custom profile seems to have too low maximum memory clock values. You therefore may not reach full performance");
15477 }
15478
15479 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
15480
15481 performance_state->iNumberOfPerformanceLevels = 2;
15482
15483 performance_state->aLevels[0].iEngineClock = engine_clock_profile_max;
15484 performance_state->aLevels[1].iEngineClock = engine_clock_profile_max;
15485 performance_state->aLevels[0].iMemoryClock = memory_clock_profile_max;
15486 performance_state->aLevels[1].iMemoryClock = memory_clock_profile_max;
15487
15488 if ((ADL_rc = hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[device_id].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
15489 {
15490 log_info ("ERROR: Failed to set ADL performance state");
15491
15492 return (-1);
15493 }
15494
15495 local_free (performance_state);
15496 }
15497 }
15498
15499 hc_thread_mutex_unlock (mux_adl);
15500 }
15501 }
15502
15503 /* Temporary fix:
15504 * with AMD r9 295x cards it seems that we need to set the powertune value just AFTER the ocl init stuff
15505 * otherwise after hc_clCreateContext () etc, powertune value was set back to "normal" and cards unfortunately
15506 * were not working @ full speed (setting hc_ADL_Overdrive_PowerControl_Set () here seems to fix the problem)
15507 * Driver / ADL bug?
15508 */
15509
15510 if (powertune_enable == 1)
15511 {
15512 hc_thread_mutex_lock (mux_adl);
15513
15514 for (uint i = 0; i < devices_cnt; i++)
15515 {
15516 if (data.hm_device[i].od_version == 6)
15517 {
15518 // set powertune value only
15519
15520 int powertune_supported = 0;
15521
15522 int ADL_rc = 0;
15523
15524 if ((ADL_rc = hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK)
15525 {
15526 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
15527
15528 return (-1);
15529 }
15530
15531 if (powertune_supported != 0)
15532 {
15533 // powertune set
15534 ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
15535
15536 if ((ADL_rc = hc_ADL_Overdrive_PowerControlInfo_Get (data.hm_dll, data.hm_device[i].adapter_index, &powertune)) != ADL_OK)
15537 {
15538 log_error ("ERROR: Failed to get current ADL PowerControl settings");
15539
15540 return (-1);
15541 }
15542
15543 if ((ADL_rc = hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, powertune.iMaxValue)) != ADL_OK)
15544 {
15545 log_error ("ERROR: Failed to set new ADL PowerControl values");
15546
15547 return (-1);
15548 }
15549 }
15550 }
15551 }
15552
15553 hc_thread_mutex_unlock (mux_adl);
15554 }
15555 #endif
15556
15557 data.gpu_blocks_all = gpu_blocks_all;
15558
15559 #ifdef _OCL
15560 if (gpu_async == 0) gpu_async = 1; // get rid of the warning
15561 #endif
15562
15563 if (data.quiet == 0) log_info ("");
15564
15565 /**
15566 * Inform user which algorithm is checked and at which workload setting
15567 */
15568
15569 if (benchmark == 1)
15570 {
15571 quiet = 0;
15572
15573 data.quiet = quiet;
15574
15575 char *hash_type = strhashtype (data.hash_mode); // not a bug
15576
15577 log_info ("Hashtype: %s", hash_type);
15578 log_info ("Workload: %u loops, %u accel", gpu_loops, gpu_accel);
15579 log_info ("");
15580 }
15581
15582 /**
15583 * keep track of the progress
15584 */
15585
15586 data.words_progress_done = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15587 data.words_progress_rejected = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15588 data.words_progress_restored = (uint64_t *) mycalloc (data.salts_cnt, sizeof (uint64_t));
15589
15590 /**
15591 * open filehandles
15592 */
15593
15594 #if _WIN
15595 if (_setmode (_fileno (stdin), _O_BINARY) == -1)
15596 {
15597 log_error ("ERROR: %s: %s", "stdin", strerror (errno));
15598
15599 return (-1);
15600 }
15601
15602 if (_setmode (_fileno (stdout), _O_BINARY) == -1)
15603 {
15604 log_error ("ERROR: %s: %s", "stdout", strerror (errno));
15605
15606 return (-1);
15607 }
15608
15609 if (_setmode (_fileno (stderr), _O_BINARY) == -1)
15610 {
15611 log_error ("ERROR: %s: %s", "stderr", strerror (errno));
15612
15613 return (-1);
15614 }
15615 #endif
15616
15617 /**
15618 * dictionary pad
15619 */
15620
15621 segment_size *= (1024 * 1024);
15622
15623 data.segment_size = segment_size;
15624
15625 wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
15626
15627 wl_data->buf = (char *) mymalloc (segment_size);
15628 wl_data->avail = segment_size;
15629 wl_data->incr = segment_size;
15630 wl_data->cnt = 0;
15631 wl_data->pos = 0;
15632
15633 uint wordlist_mode = ((optind + 1) < myargc) ? WL_MODE_FILE : WL_MODE_STDIN;
15634
15635 data.wordlist_mode = wordlist_mode;
15636
15637 cs_t *css_buf = NULL;
15638 uint css_cnt = 0;
15639 uint dictcnt = 0;
15640 uint maskcnt = 1;
15641 char **masks = NULL;
15642 char **dictfiles = NULL;
15643
15644 uint mask_from_file = 0;
15645
15646 if (attack_mode == ATTACK_MODE_STRAIGHT)
15647 {
15648 if (wordlist_mode == WL_MODE_FILE)
15649 {
15650 int wls_left = myargc - (optind + 1);
15651
15652 for (int i = 0; i < wls_left; i++)
15653 {
15654 char *l0_filename = myargv[optind + 1 + i];
15655
15656 struct stat l0_stat;
15657
15658 if (stat (l0_filename, &l0_stat) == -1)
15659 {
15660 log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
15661
15662 return (-1);
15663 }
15664
15665 uint is_dir = S_ISDIR (l0_stat.st_mode);
15666
15667 if (is_dir == 0)
15668 {
15669 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
15670
15671 dictcnt++;
15672
15673 dictfiles[dictcnt - 1] = l0_filename;
15674 }
15675 else
15676 {
15677 // do not allow --keyspace w/ a directory
15678
15679 if (keyspace == 1)
15680 {
15681 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
15682
15683 return (-1);
15684 }
15685
15686 char **dictionary_files = NULL;
15687
15688 dictionary_files = scan_directory (l0_filename);
15689
15690 if (dictionary_files != NULL)
15691 {
15692 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
15693
15694 for (int d = 0; dictionary_files[d] != NULL; d++)
15695 {
15696 char *l1_filename = dictionary_files[d];
15697
15698 struct stat l1_stat;
15699
15700 if (stat (l1_filename, &l1_stat) == -1)
15701 {
15702 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
15703
15704 return (-1);
15705 }
15706
15707 if (S_ISREG (l1_stat.st_mode))
15708 {
15709 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
15710
15711 dictcnt++;
15712
15713 dictfiles[dictcnt - 1] = strdup (l1_filename);
15714 }
15715 }
15716 }
15717
15718 local_free (dictionary_files);
15719 }
15720 }
15721
15722 if (dictcnt < 1)
15723 {
15724 log_error ("ERROR: No usable dictionary file found.");
15725
15726 return (-1);
15727 }
15728 }
15729 else if (wordlist_mode == WL_MODE_STDIN)
15730 {
15731 dictcnt = 1;
15732 }
15733 }
15734 else if (attack_mode == ATTACK_MODE_COMBI)
15735 {
15736 // display
15737
15738 char *dictfile1 = myargv[optind + 1 + 0];
15739 char *dictfile2 = myargv[optind + 1 + 1];
15740
15741 // find the bigger dictionary and use as base
15742
15743 FILE *fp1;
15744 FILE *fp2;
15745
15746 struct stat tmp_stat;
15747
15748 if ((fp1 = fopen (dictfile1, "rb")) == NULL)
15749 {
15750 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
15751
15752 return (-1);
15753 }
15754
15755 if (stat (dictfile1, &tmp_stat) == -1)
15756 {
15757 log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
15758
15759 fclose (fp1);
15760
15761 return (-1);
15762 }
15763
15764 if (S_ISDIR (tmp_stat.st_mode))
15765 {
15766 log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno));
15767
15768 fclose (fp1);
15769
15770 return (-1);
15771 }
15772
15773 if ((fp2 = fopen (dictfile2, "rb")) == NULL)
15774 {
15775 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
15776
15777 fclose (fp1);
15778
15779 return (-1);
15780 }
15781
15782 if (stat (dictfile2, &tmp_stat) == -1)
15783 {
15784 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
15785
15786 fclose (fp1);
15787 fclose (fp2);
15788
15789 return (-1);
15790 }
15791
15792 if (S_ISDIR (tmp_stat.st_mode))
15793 {
15794 log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno));
15795
15796 fclose (fp1);
15797 fclose (fp2);
15798
15799 return (-1);
15800 }
15801
15802 data.combs_cnt = 1;
15803
15804 data.quiet = 1;
15805
15806 const uint64_t words1_cnt = count_words (wl_data, fp1, dictfile1, dictstat_base, &dictstat_nmemb);
15807
15808 data.quiet = quiet;
15809
15810 if (words1_cnt == 0)
15811 {
15812 log_error ("ERROR: %s: empty file", dictfile1);
15813
15814 fclose (fp1);
15815 fclose (fp2);
15816
15817 return (-1);
15818 }
15819
15820 data.combs_cnt = 1;
15821
15822 data.quiet = 1;
15823
15824 const uint64_t words2_cnt = count_words (wl_data, fp2, dictfile2, dictstat_base, &dictstat_nmemb);
15825
15826 data.quiet = quiet;
15827
15828 if (words2_cnt == 0)
15829 {
15830 log_error ("ERROR: %s: empty file", dictfile2);
15831
15832 fclose (fp1);
15833 fclose (fp2);
15834
15835 return (-1);
15836 }
15837
15838 fclose (fp1);
15839 fclose (fp2);
15840
15841 data.dictfile = dictfile1;
15842 data.dictfile2 = dictfile2;
15843
15844 if (words1_cnt >= words2_cnt)
15845 {
15846 data.combs_cnt = words2_cnt;
15847 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
15848
15849 dictfiles = &data.dictfile;
15850
15851 dictcnt = 1;
15852 }
15853 else
15854 {
15855 data.combs_cnt = words1_cnt;
15856 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
15857
15858 dictfiles = &data.dictfile2;
15859
15860 dictcnt = 1;
15861
15862 // we also have to switch wordlist related rules!
15863
15864 char *tmpc = data.rule_buf_l;
15865
15866 data.rule_buf_l = data.rule_buf_r;
15867 data.rule_buf_r = tmpc;
15868
15869 int tmpi = data.rule_len_l;
15870
15871 data.rule_len_l = data.rule_len_r;
15872 data.rule_len_r = tmpi;
15873 }
15874 }
15875 else if (attack_mode == ATTACK_MODE_BF)
15876 {
15877 char *mask = NULL;
15878
15879 maskcnt = 0;
15880
15881 if (benchmark == 0)
15882 {
15883 mask = myargv[optind + 1];
15884
15885 masks = (char **) mymalloc (INCR_MASKS * sizeof (char *));
15886
15887 if ((optind + 2) <= myargc)
15888 {
15889 struct stat file_stat;
15890
15891 if (stat (mask, &file_stat) == -1)
15892 {
15893 maskcnt = 1;
15894
15895 masks[maskcnt - 1] = mystrdup (mask);
15896 }
15897 else
15898 {
15899 int wls_left = myargc - (optind + 1);
15900
15901 uint masks_avail = INCR_MASKS;
15902
15903 for (int i = 0; i < wls_left; i++)
15904 {
15905 if (i != 0)
15906 {
15907 mask = myargv[optind + 1 + i];
15908
15909 if (stat (mask, &file_stat) == -1)
15910 {
15911 log_error ("ERROR: %s: %s", mask, strerror (errno));
15912
15913 return (-1);
15914 }
15915 }
15916
15917 uint is_file = S_ISREG (file_stat.st_mode);
15918
15919 if (is_file == 1)
15920 {
15921 FILE *mask_fp;
15922
15923 if ((mask_fp = fopen (mask, "r")) == NULL)
15924 {
15925 log_error ("ERROR: %s: %s", mask, strerror (errno));
15926
15927 return (-1);
15928 }
15929
15930 char line_buf[BUFSIZ];
15931
15932 while (!feof (mask_fp))
15933 {
15934 memset (line_buf, 0, BUFSIZ);
15935
15936 int line_len = fgetl (mask_fp, line_buf);
15937
15938 if (line_len == 0) continue;
15939
15940 if (line_buf[0] == '#') continue;
15941
15942 if (masks_avail == maskcnt)
15943 {
15944 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
15945
15946 masks_avail += INCR_MASKS;
15947 }
15948
15949 masks[maskcnt] = mystrdup (line_buf);
15950
15951 maskcnt++;
15952 }
15953
15954 fclose (mask_fp);
15955 }
15956 else
15957 {
15958 log_error ("ERROR: %s: unsupported file-type", mask);
15959
15960 return (-1);
15961 }
15962 }
15963
15964 mask_from_file = 1;
15965 }
15966 }
15967 else
15968 {
15969 custom_charset_1 = (char *) "?l?d?u";
15970 custom_charset_2 = (char *) "?l?d";
15971 custom_charset_3 = (char *) "?l?d*!$@_";
15972
15973 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
15974 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
15975 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
15976
15977 masks[maskcnt] = mystrdup ("?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d");
15978
15979 wordlist_mode = WL_MODE_MASK;
15980
15981 data.wordlist_mode = wordlist_mode;
15982
15983 increment = 1;
15984
15985 maskcnt = 1;
15986 }
15987 }
15988 else
15989 {
15990 /**
15991 * generate full masks and charsets
15992 */
15993
15994 masks = (char **) mymalloc (sizeof (char *));
15995
15996 switch (hash_mode)
15997 {
15998 case 1731: pw_min = 5;
15999 pw_max = 5;
16000 mask = mystrdup ("?b?b?b?b?b");
16001 break;
16002 case 12500: pw_min = 5;
16003 pw_max = 5;
16004 mask = mystrdup ("?b?b?b?b?b");
16005 break;
16006 default: pw_min = 7;
16007 pw_max = 7;
16008 mask = mystrdup ("?b?b?b?b?b?b?b");
16009 break;
16010 }
16011
16012 maskcnt = 1;
16013
16014 masks[maskcnt - 1] = mystrdup (mask);
16015
16016 wordlist_mode = WL_MODE_MASK;
16017
16018 data.wordlist_mode = wordlist_mode;
16019
16020 increment = 1;
16021 }
16022
16023 dictfiles = (char **) mycalloc (pw_max, sizeof (char *));
16024
16025 if (increment)
16026 {
16027 if (increment_min > pw_min) pw_min = increment_min;
16028
16029 if (increment_max < pw_max) pw_max = increment_max;
16030 }
16031 }
16032 else if (attack_mode == ATTACK_MODE_HYBRID1)
16033 {
16034 data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
16035
16036 // display
16037
16038 char *mask = myargv[myargc - 1];
16039
16040 maskcnt = 0;
16041
16042 masks = (char **) mymalloc (1 * sizeof (char *));
16043
16044 // mod
16045
16046 struct stat file_stat;
16047
16048 if (stat (mask, &file_stat) == -1)
16049 {
16050 maskcnt = 1;
16051
16052 masks[maskcnt - 1] = mystrdup (mask);
16053 }
16054 else
16055 {
16056 uint is_file = S_ISREG (file_stat.st_mode);
16057
16058 if (is_file == 1)
16059 {
16060 FILE *mask_fp;
16061
16062 if ((mask_fp = fopen (mask, "r")) == NULL)
16063 {
16064 log_error ("ERROR: %s: %s", mask, strerror (errno));
16065
16066 return (-1);
16067 }
16068
16069 char line_buf[BUFSIZ];
16070
16071 uint masks_avail = 1;
16072
16073 while (!feof (mask_fp))
16074 {
16075 memset (line_buf, 0, BUFSIZ);
16076
16077 int line_len = fgetl (mask_fp, line_buf);
16078
16079 if (line_len == 0) continue;
16080
16081 if (line_buf[0] == '#') continue;
16082
16083 if (masks_avail == maskcnt)
16084 {
16085 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
16086
16087 masks_avail += INCR_MASKS;
16088 }
16089
16090 masks[maskcnt] = mystrdup (line_buf);
16091
16092 maskcnt++;
16093 }
16094
16095 fclose (mask_fp);
16096
16097 mask_from_file = 1;
16098 }
16099 else
16100 {
16101 maskcnt = 1;
16102
16103 masks[maskcnt - 1] = mystrdup (mask);
16104 }
16105 }
16106
16107 // base
16108
16109 int wls_left = myargc - (optind + 2);
16110
16111 for (int i = 0; i < wls_left; i++)
16112 {
16113 char *filename = myargv[optind + 1 + i];
16114
16115 struct stat file_stat;
16116
16117 if (stat (filename, &file_stat) == -1)
16118 {
16119 log_error ("ERROR: %s: %s", filename, strerror (errno));
16120
16121 return (-1);
16122 }
16123
16124 uint is_dir = S_ISDIR (file_stat.st_mode);
16125
16126 if (is_dir == 0)
16127 {
16128 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16129
16130 dictcnt++;
16131
16132 dictfiles[dictcnt - 1] = filename;
16133 }
16134 else
16135 {
16136 // do not allow --keyspace w/ a directory
16137
16138 if (keyspace == 1)
16139 {
16140 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
16141
16142 return (-1);
16143 }
16144
16145 char **dictionary_files = NULL;
16146
16147 dictionary_files = scan_directory (filename);
16148
16149 if (dictionary_files != NULL)
16150 {
16151 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
16152
16153 for (int d = 0; dictionary_files[d] != NULL; d++)
16154 {
16155 char *l1_filename = dictionary_files[d];
16156
16157 struct stat l1_stat;
16158
16159 if (stat (l1_filename, &l1_stat) == -1)
16160 {
16161 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
16162
16163 return (-1);
16164 }
16165
16166 if (S_ISREG (l1_stat.st_mode))
16167 {
16168 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16169
16170 dictcnt++;
16171
16172 dictfiles[dictcnt - 1] = strdup (l1_filename);
16173 }
16174 }
16175 }
16176
16177 local_free (dictionary_files);
16178 }
16179 }
16180
16181 if (dictcnt < 1)
16182 {
16183 log_error ("ERROR: No usable dictionary file found.");
16184
16185 return (-1);
16186 }
16187
16188 if (increment)
16189 {
16190 maskcnt = 0;
16191
16192 uint mask_min = increment_min; // we can't reject smaller masks here
16193 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
16194
16195 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
16196 {
16197 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
16198
16199 if (cur_mask == NULL) break;
16200
16201 masks[maskcnt] = cur_mask;
16202
16203 maskcnt++;
16204
16205 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
16206 }
16207 }
16208 }
16209 else if (attack_mode == ATTACK_MODE_HYBRID2)
16210 {
16211 data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
16212
16213 // display
16214
16215 char *mask = myargv[optind + 1 + 0];
16216
16217 maskcnt = 0;
16218
16219 masks = (char **) mymalloc (1 * sizeof (char *));
16220
16221 // mod
16222
16223 struct stat file_stat;
16224
16225 if (stat (mask, &file_stat) == -1)
16226 {
16227 maskcnt = 1;
16228
16229 masks[maskcnt - 1] = mystrdup (mask);
16230 }
16231 else
16232 {
16233 uint is_file = S_ISREG (file_stat.st_mode);
16234
16235 if (is_file == 1)
16236 {
16237 FILE *mask_fp;
16238
16239 if ((mask_fp = fopen (mask, "r")) == NULL)
16240 {
16241 log_error ("ERROR: %s: %s", mask, strerror (errno));
16242
16243 return (-1);
16244 }
16245
16246 char line_buf[BUFSIZ];
16247
16248 uint masks_avail = 1;
16249
16250 while (!feof (mask_fp))
16251 {
16252 memset (line_buf, 0, BUFSIZ);
16253
16254 int line_len = fgetl (mask_fp, line_buf);
16255
16256 if (line_len == 0) continue;
16257
16258 if (line_buf[0] == '#') continue;
16259
16260 if (masks_avail == maskcnt)
16261 {
16262 masks = (char **) myrealloc (masks, masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
16263
16264 masks_avail += INCR_MASKS;
16265 }
16266
16267 masks[maskcnt] = mystrdup (line_buf);
16268
16269 maskcnt++;
16270 }
16271
16272 fclose (mask_fp);
16273
16274 mask_from_file = 1;
16275 }
16276 else
16277 {
16278 maskcnt = 1;
16279
16280 masks[maskcnt - 1] = mystrdup (mask);
16281 }
16282 }
16283
16284 // base
16285
16286 int wls_left = myargc - (optind + 2);
16287
16288 for (int i = 0; i < wls_left; i++)
16289 {
16290 char *filename = myargv[optind + 2 + i];
16291
16292 struct stat file_stat;
16293
16294 if (stat (filename, &file_stat) == -1)
16295 {
16296 log_error ("ERROR: %s: %s", filename, strerror (errno));
16297
16298 return (-1);
16299 }
16300
16301 uint is_dir = S_ISDIR (file_stat.st_mode);
16302
16303 if (is_dir == 0)
16304 {
16305 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16306
16307 dictcnt++;
16308
16309 dictfiles[dictcnt - 1] = filename;
16310 }
16311 else
16312 {
16313 // do not allow --keyspace w/ a directory
16314
16315 if (keyspace == 1)
16316 {
16317 log_error ("ERROR: keyspace parameter is not allowed together with a directory");
16318
16319 return (-1);
16320 }
16321
16322 char **dictionary_files = NULL;
16323
16324 dictionary_files = scan_directory (filename);
16325
16326 if (dictionary_files != NULL)
16327 {
16328 qsort (dictionary_files, count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
16329
16330 for (int d = 0; dictionary_files[d] != NULL; d++)
16331 {
16332 char *l1_filename = dictionary_files[d];
16333
16334 struct stat l1_stat;
16335
16336 if (stat (l1_filename, &l1_stat) == -1)
16337 {
16338 log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
16339
16340 return (-1);
16341 }
16342
16343 if (S_ISREG (l1_stat.st_mode))
16344 {
16345 dictfiles = (char **) myrealloc (dictfiles, dictcnt * sizeof (char *), sizeof (char *));
16346
16347 dictcnt++;
16348
16349 dictfiles[dictcnt - 1] = strdup (l1_filename);
16350 }
16351 }
16352 }
16353
16354 local_free (dictionary_files);
16355 }
16356 }
16357
16358 if (dictcnt < 1)
16359 {
16360 log_error ("ERROR: No usable dictionary file found.");
16361
16362 return (-1);
16363 }
16364
16365 if (increment)
16366 {
16367 maskcnt = 0;
16368
16369 uint mask_min = increment_min; // we can't reject smaller masks here
16370 uint mask_max = (increment_max < pw_max) ? increment_max : pw_max;
16371
16372 for (uint mask_cur = mask_min; mask_cur <= mask_max; mask_cur++)
16373 {
16374 char *cur_mask = mp_get_truncated_mask (mask, strlen (mask), mask_cur);
16375
16376 if (cur_mask == NULL) break;
16377
16378 masks[maskcnt] = cur_mask;
16379
16380 maskcnt++;
16381
16382 masks = (char **) myrealloc (masks, maskcnt * sizeof (char *), sizeof (char *));
16383 }
16384 }
16385 }
16386
16387 data.pw_min = pw_min;
16388 data.pw_max = pw_max;
16389
16390 /**
16391 * weak hash check
16392 */
16393
16394 if (weak_hash_threshold >= salts_cnt)
16395 {
16396 if (data.quiet == 0) log_info_nn ("Checking for weak hashes...");
16397
16398 for (uint salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
16399 {
16400 weak_hash_check (&data.devices_param[0], salt_pos, gpu_loops);
16401 }
16402 }
16403
16404 // Display hack, guarantee that there is at least one \r before real start
16405
16406 if (data.quiet == 0) log_info_nn ("");
16407
16408 /**
16409 * status and monitor threads
16410 */
16411
16412 if (data.devices_status != STATUS_CRACKED) data.devices_status = STATUS_STARTING;
16413
16414 hc_thread_t i_thread = 0;
16415
16416 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
16417 {
16418 hc_thread_create (i_thread, thread_keypress, &benchmark);
16419 }
16420
16421 if (wordlist_mode == WL_MODE_STDIN) data.status = 1;
16422
16423 uint ni_threads_cnt = 0;
16424
16425 hc_thread_t *ni_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
16426
16427 hc_thread_create (ni_threads[ni_threads_cnt], thread_monitor, NULL);
16428
16429 ni_threads_cnt++;
16430
16431 /**
16432 * Outfile remove
16433 */
16434
16435 if (keyspace == 0)
16436 {
16437 if (outfile_check_timer != 0)
16438 {
16439 if (data.outfile_check_directory != NULL)
16440 {
16441 if ((hash_mode != 5200) &&
16442 !((hash_mode >= 6200) && (hash_mode <= 6299)) &&
16443 (hash_mode != 9000))
16444 {
16445 hc_thread_create (ni_threads[ni_threads_cnt], thread_outfile_remove, NULL);
16446
16447 ni_threads_cnt++;
16448 }
16449 else
16450 {
16451 outfile_check_timer = 0;
16452 }
16453 }
16454 else
16455 {
16456 outfile_check_timer = 0;
16457 }
16458 }
16459 }
16460
16461 /**
16462 * Inform the user if we got some hashes remove because of the pot file remove feature
16463 */
16464
16465 if (data.quiet == 0)
16466 {
16467 if (potfile_remove_cracks > 0)
16468 {
16469 if (potfile_remove_cracks == 1) log_info ("INFO: removed 1 hash found in pot file\n");
16470 else log_info ("INFO: removed %u hashes found in pot file\n", potfile_remove_cracks);
16471 }
16472 }
16473
16474 data.outfile_check_timer = outfile_check_timer;
16475
16476 /**
16477 * main loop
16478 */
16479
16480 char **induction_dictionaries = NULL;
16481
16482 int induction_dictionaries_cnt = 0;
16483
16484 hcstat_table_t *root_table_buf = NULL;
16485 hcstat_table_t *markov_table_buf = NULL;
16486
16487 uint initial_restore_done = 0;
16488
16489 data.maskcnt = maskcnt;
16490
16491 for (uint maskpos = rd->maskpos; maskpos < maskcnt; maskpos++)
16492 {
16493 if (data.devices_status == STATUS_CRACKED) break;
16494
16495 data.devices_status = STATUS_INIT;
16496
16497 if (maskpos > rd->maskpos)
16498 {
16499 rd->dictpos = 0;
16500 }
16501
16502 rd->maskpos = maskpos;
16503 data.maskpos = maskpos;
16504
16505 if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2 || attack_mode == ATTACK_MODE_BF)
16506 {
16507 char *mask = masks[maskpos];
16508
16509 if (mask_from_file == 1)
16510 {
16511 if (mask[0] == '\\' && mask[1] == '#') mask++; // escaped comment sign (sharp) "\#"
16512
16513 char *str_ptr;
16514 uint str_pos;
16515
16516 uint mask_offset = 0;
16517
16518 uint separator_cnt;
16519
16520 for (separator_cnt = 0; separator_cnt < 4; separator_cnt++)
16521 {
16522 str_ptr = strstr (mask + mask_offset, ",");
16523
16524 if (str_ptr == NULL) break;
16525
16526 str_pos = str_ptr - mask;
16527
16528 // escaped separator, i.e. "\,"
16529
16530 if (str_pos > 0)
16531 {
16532 if (mask[str_pos - 1] == '\\')
16533 {
16534 separator_cnt --;
16535
16536 mask_offset = str_pos + 1;
16537
16538 continue;
16539 }
16540 }
16541
16542 // reset the offset
16543
16544 mask_offset = 0;
16545
16546 mask[str_pos] = '\0';
16547
16548 switch (separator_cnt)
16549 {
16550 case 0:
16551 mp_reset_usr (mp_usr, 0);
16552
16553 custom_charset_1 = mask;
16554 mp_setup_usr (mp_sys, mp_usr, custom_charset_1, 0);
16555 break;
16556
16557 case 1:
16558 mp_reset_usr (mp_usr, 1);
16559
16560 custom_charset_2 = mask;
16561 mp_setup_usr (mp_sys, mp_usr, custom_charset_2, 1);
16562 break;
16563
16564 case 2:
16565 mp_reset_usr (mp_usr, 2);
16566
16567 custom_charset_3 = mask;
16568 mp_setup_usr (mp_sys, mp_usr, custom_charset_3, 2);
16569 break;
16570
16571 case 3:
16572 mp_reset_usr (mp_usr, 3);
16573
16574 custom_charset_4 = mask;
16575 mp_setup_usr (mp_sys, mp_usr, custom_charset_4, 3);
16576 break;
16577 }
16578
16579 mask = mask + str_pos + 1;
16580 }
16581 }
16582
16583 if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
16584 {
16585 if (maskpos > 0)
16586 {
16587 local_free (css_buf);
16588 local_free (data.root_css_buf);
16589 local_free (data.markov_css_buf);
16590
16591 local_free (masks[maskpos - 1]);
16592 }
16593
16594 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
16595
16596 data.mask = mask;
16597 data.css_cnt = css_cnt;
16598 data.css_buf = css_buf;
16599
16600 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
16601
16602 memset (uniq_tbls, 0, sizeof (uniq_tbls));
16603
16604 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
16605
16606 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
16607 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
16608
16609 sp_setup_tbl (install_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
16610
16611 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
16612
16613 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
16614 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
16615
16616 data.root_css_buf = root_css_buf;
16617 data.markov_css_buf = markov_css_buf;
16618
16619 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
16620
16621 data.combs_cnt = sp_get_sum (0, css_cnt, root_css_buf);
16622
16623 local_free (root_table_buf);
16624 local_free (markov_table_buf);
16625
16626 // args
16627
16628 for (uint device_id = 0; device_id < devices_cnt; device_id++)
16629 {
16630 hc_device_param_t *device_param = &data.devices_param[device_id];
16631
16632 device_param->kernel_params_mp[0] = &device_param->d_combs;
16633 device_param->kernel_params_mp[1] = &device_param->d_root_css_buf;
16634 device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf;
16635
16636 device_param->kernel_params_mp_buf64[3] = 0;
16637 device_param->kernel_params_mp_buf32[4] = css_cnt;
16638 device_param->kernel_params_mp_buf32[5] = 0;
16639 device_param->kernel_params_mp_buf32[6] = 0;
16640 device_param->kernel_params_mp_buf32[7] = 0;
16641
16642 if (attack_mode == ATTACK_MODE_HYBRID1)
16643 {
16644 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_buf32[5] = full01;
16645 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_buf32[5] = full80;
16646 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_buf32[6] = 1;
16647 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_buf32[7] = 1;
16648 }
16649 else if (attack_mode == ATTACK_MODE_HYBRID2)
16650 {
16651 device_param->kernel_params_mp_buf32[5] = 0;
16652 device_param->kernel_params_mp_buf32[6] = 0;
16653 device_param->kernel_params_mp_buf32[7] = 0;
16654 }
16655
16656 #ifdef _CUDA
16657 hc_cuCtxPushCurrent (device_param->context);
16658
16659 hc_cuMemcpyHtoD (device_param->d_root_css_buf, root_css_buf, device_param->size_root_css);
16660 hc_cuMemcpyHtoD (device_param->d_markov_css_buf, markov_css_buf, device_param->size_markov_css);
16661
16662 hc_cuCtxPopCurrent (&device_param->context);
16663 #elif _OCL
16664 for (uint i = 0; i < 3; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_mem), (void *) device_param->kernel_params_mp[i]);
16665 for (uint i = 3; i < 4; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_ulong), (void *) device_param->kernel_params_mp[i]);
16666 for (uint i = 4; i < 8; i++) hc_clSetKernelArg (device_param->kernel_mp, i, sizeof (cl_uint), (void *) device_param->kernel_params_mp[i]);
16667
16668 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);
16669 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);
16670 #endif
16671 }
16672 }
16673 else if (attack_mode == ATTACK_MODE_BF)
16674 {
16675 dictcnt = 0; // number of "sub-masks", i.e. when using incremental mode
16676
16677 if (increment)
16678 {
16679 for (uint i = 0; i < dictcnt; i++)
16680 {
16681 local_free (dictfiles[i]);
16682 }
16683
16684 for (uint pw_len = MAX (1, pw_min); pw_len <= pw_max; pw_len++)
16685 {
16686 char *l1_filename = mp_get_truncated_mask (mask, strlen (mask), pw_len);
16687
16688 if (l1_filename == NULL) break;
16689
16690 dictcnt++;
16691
16692 dictfiles[dictcnt - 1] = l1_filename;
16693 }
16694 }
16695 else
16696 {
16697 dictcnt++;
16698
16699 dictfiles[dictcnt - 1] = mask;
16700 }
16701
16702 if (dictcnt == 0)
16703 {
16704 log_error ("ERROR: Mask is too small");
16705
16706 return (-1);
16707 }
16708 }
16709 }
16710
16711 free (induction_dictionaries);
16712
16713 // induction_dictionaries_cnt = 0; // implied
16714
16715 if (attack_mode != ATTACK_MODE_BF)
16716 {
16717 if (keyspace == 0)
16718 {
16719 induction_dictionaries = scan_directory (induction_directory);
16720
16721 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
16722 }
16723 }
16724
16725 if (induction_dictionaries_cnt)
16726 {
16727 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
16728 }
16729
16730 /**
16731 * prevent the user from using --keyspace together w/ maskfile and or dictfile
16732 */
16733 if (keyspace == 1)
16734 {
16735 if ((maskcnt > 1) || (dictcnt > 1))
16736 {
16737 log_error ("ERROR: --keyspace is not supported with --increment or mask files");
16738
16739 return (-1);
16740 }
16741 }
16742
16743 for (uint dictpos = rd->dictpos; dictpos < dictcnt; )
16744 {
16745 char *subid = logfile_generate_subid ();
16746
16747 data.subid = subid;
16748
16749 logfile_sub_msg ("START");
16750
16751 data.devices_status = STATUS_INIT;
16752
16753 memset (data.words_progress_done, 0, data.salts_cnt * sizeof (uint64_t));
16754 memset (data.words_progress_rejected, 0, data.salts_cnt * sizeof (uint64_t));
16755 memset (data.words_progress_restored, 0, data.salts_cnt * sizeof (uint64_t));
16756
16757 memset (data.cpt_buf, 0, CPT_BUF * sizeof (cpt_t));
16758
16759 data.cpt_pos = 0;
16760
16761 data.cpt_start = time (NULL);
16762
16763 data.cpt_total = 0;
16764
16765 if (data.restore == 0)
16766 {
16767 rd->words_cur = skip;
16768
16769 skip = 0;
16770
16771 data.skip = 0;
16772 }
16773
16774 data.ms_paused = 0;
16775
16776 data.words_cur = rd->words_cur;
16777
16778 for (uint device_id = 0; device_id < data.devices_cnt; device_id++)
16779 {
16780 hc_device_param_t *device_param = &data.devices_param[device_id];
16781
16782 device_param->speed_pos = 0;
16783
16784 memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (uint64_t));
16785 memset (device_param->speed_ms, 0, SPEED_CACHE * sizeof (float));
16786 memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
16787
16788 device_param->gpu_power = device_param->gpu_power_user;
16789 device_param->gpu_blocks = device_param->gpu_blocks_user;
16790
16791 device_param->outerloop_pos = 0;
16792 device_param->outerloop_left = 0;
16793 device_param->innerloop_pos = 0;
16794 device_param->innerloop_left = 0;
16795
16796 // some more resets:
16797
16798 memset (device_param->pw_caches, 0, 64 * sizeof (pw_cache_t));
16799
16800 memset (device_param->pws_buf, 0, device_param->size_pws);
16801
16802 device_param->pw_cnt = 0;
16803 device_param->pws_cnt = 0;
16804
16805 device_param->words_off = 0;
16806 device_param->words_done = 0;
16807 }
16808
16809 data.gpu_blocks_div = 0;
16810
16811 // figure out some workload
16812
16813 if (attack_mode == ATTACK_MODE_STRAIGHT)
16814 {
16815 if (data.wordlist_mode == WL_MODE_FILE)
16816 {
16817 char *dictfile = NULL;
16818
16819 if (induction_dictionaries_cnt)
16820 {
16821 dictfile = induction_dictionaries[0];
16822 }
16823 else
16824 {
16825 dictfile = dictfiles[dictpos];
16826 }
16827
16828 data.dictfile = dictfile;
16829
16830 logfile_sub_string (dictfile);
16831
16832 for (uint i = 0; i < rp_files_cnt; i++)
16833 {
16834 logfile_sub_var_string ("rulefile", rp_files[i]);
16835 }
16836
16837 FILE *fd2 = fopen (dictfile, "rb");
16838
16839 if (fd2 == NULL)
16840 {
16841 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16842
16843 return (-1);
16844 }
16845
16846 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16847
16848 fclose (fd2);
16849
16850 if (data.words_cnt == 0)
16851 {
16852 if (data.devices_status == STATUS_CRACKED) break;
16853 if (data.devices_status == STATUS_ABORTED) break;
16854
16855 dictpos++;
16856
16857 continue;
16858 }
16859 }
16860 }
16861 else if (attack_mode == ATTACK_MODE_COMBI)
16862 {
16863 char *dictfile = data.dictfile;
16864 char *dictfile2 = data.dictfile2;
16865
16866 logfile_sub_string (dictfile);
16867 logfile_sub_string (dictfile2);
16868
16869 if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
16870 {
16871 FILE *fd2 = fopen (dictfile, "rb");
16872
16873 if (fd2 == NULL)
16874 {
16875 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16876
16877 return (-1);
16878 }
16879
16880 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16881
16882 fclose (fd2);
16883 }
16884 else if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
16885 {
16886 FILE *fd2 = fopen (dictfile2, "rb");
16887
16888 if (fd2 == NULL)
16889 {
16890 log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
16891
16892 return (-1);
16893 }
16894
16895 data.words_cnt = count_words (wl_data, fd2, dictfile2, dictstat_base, &dictstat_nmemb);
16896
16897 fclose (fd2);
16898 }
16899
16900 if (data.words_cnt == 0)
16901 {
16902 if (data.devices_status == STATUS_CRACKED) break;
16903 if (data.devices_status == STATUS_ABORTED) break;
16904
16905 dictpos++;
16906
16907 continue;
16908 }
16909 }
16910 else if ((attack_mode == ATTACK_MODE_HYBRID1) || (attack_mode == ATTACK_MODE_HYBRID2))
16911 {
16912 char *dictfile = NULL;
16913
16914 if (induction_dictionaries_cnt)
16915 {
16916 dictfile = induction_dictionaries[0];
16917 }
16918 else
16919 {
16920 dictfile = dictfiles[dictpos];
16921 }
16922
16923 data.dictfile = dictfile;
16924
16925 char *mask = data.mask;
16926
16927 logfile_sub_string (dictfile);
16928 logfile_sub_string (mask);
16929
16930 FILE *fd2 = fopen (dictfile, "rb");
16931
16932 if (fd2 == NULL)
16933 {
16934 log_error ("ERROR: %s: %s", dictfile, strerror (errno));
16935
16936 return (-1);
16937 }
16938
16939 data.words_cnt = count_words (wl_data, fd2, dictfile, dictstat_base, &dictstat_nmemb);
16940
16941 fclose (fd2);
16942
16943 if (data.words_cnt == 0)
16944 {
16945 if (data.devices_status == STATUS_CRACKED) break;
16946 if (data.devices_status == STATUS_ABORTED) break;
16947
16948 dictpos++;
16949
16950 continue;
16951 }
16952 }
16953 else if (attack_mode == ATTACK_MODE_BF)
16954 {
16955 local_free (css_buf);
16956 local_free (data.root_css_buf);
16957 local_free (data.markov_css_buf);
16958
16959 char *mask = dictfiles[dictpos];
16960
16961 logfile_sub_string (mask);
16962
16963 // base
16964
16965 css_buf = mp_gen_css (mask, strlen (mask), mp_sys, mp_usr, &css_cnt);
16966
16967 if (opts_type & OPTS_TYPE_PT_UNICODE)
16968 {
16969 uint css_cnt_unicode = css_cnt * 2;
16970
16971 cs_t *css_buf_unicode = (cs_t *) mycalloc (css_cnt_unicode, sizeof (cs_t));
16972
16973 for (uint i = 0, j = 0; i < css_cnt; i += 1, j += 2)
16974 {
16975 memcpy (&css_buf_unicode[j + 0], &css_buf[i], sizeof (cs_t));
16976
16977 css_buf_unicode[j + 1].cs_buf[0] = 0;
16978 css_buf_unicode[j + 1].cs_len = 1;
16979 }
16980
16981 free (css_buf);
16982
16983 css_buf = css_buf_unicode;
16984 css_cnt = css_cnt_unicode;
16985 }
16986
16987 // check if mask is not too large or too small for pw_min/pw_max (*2 if unicode)
16988
16989 uint mask_min = pw_min;
16990 uint mask_max = pw_max;
16991
16992 if (opts_type & OPTS_TYPE_PT_UNICODE)
16993 {
16994 mask_min *= 2;
16995 mask_max *= 2;
16996 }
16997
16998 if ((css_cnt < mask_min) || (css_cnt > mask_max))
16999 {
17000 if (css_cnt < mask_min)
17001 {
17002 log_info ("WARNING: skipping mask '%s' because it is smaller than the minimum password length", mask);
17003 }
17004
17005 if (css_cnt > mask_max)
17006 {
17007 log_info ("WARNING: skipping mask '%s' because it is larger than the maximum password length", mask);
17008 }
17009
17010 // skip to next mask
17011
17012 dictpos++;
17013
17014 rd->dictpos = dictpos;
17015
17016 logfile_sub_msg ("STOP");
17017
17018 continue;
17019 }
17020
17021 uint save_css_cnt = css_cnt;
17022
17023 if (opti_type & OPTI_TYPE_SINGLE_HASH)
17024 {
17025 if (opti_type & OPTI_TYPE_APPENDED_SALT)
17026 {
17027 uint salt_len = (uint) data.salts_buf[0].salt_len;
17028 char *salt_buf = (char *) data.salts_buf[0].salt_buf;
17029
17030 uint css_cnt_salt = css_cnt + salt_len;
17031
17032 cs_t *css_buf_salt = (cs_t *) mycalloc (css_cnt_salt, sizeof (cs_t));
17033
17034 memcpy (css_buf_salt, css_buf, css_cnt * sizeof (cs_t));
17035
17036 for (uint i = 0, j = css_cnt; i < salt_len; i++, j++)
17037 {
17038 css_buf_salt[j].cs_buf[0] = salt_buf[i];
17039 css_buf_salt[j].cs_len = 1;
17040 }
17041
17042 free (css_buf);
17043
17044 css_buf = css_buf_salt;
17045 css_cnt = css_cnt_salt;
17046 }
17047 }
17048
17049 data.mask = mask;
17050 data.css_cnt = css_cnt;
17051 data.css_buf = css_buf;
17052
17053 if (maskpos > 0 && dictpos == 0) free (masks[maskpos - 1]);
17054
17055 uint uniq_tbls[SP_PW_MAX][CHARSIZ];
17056
17057 memset (uniq_tbls, 0, sizeof (uniq_tbls));
17058
17059 mp_css_to_uniq_tbl (css_cnt, css_buf, uniq_tbls);
17060
17061 if (root_table_buf == NULL) root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
17062 if (markov_table_buf == NULL) markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
17063
17064 sp_setup_tbl (install_dir, markov_hcstat, markov_disable, markov_classic, root_table_buf, markov_table_buf);
17065
17066 markov_threshold = (markov_threshold != 0) ? markov_threshold : CHARSIZ;
17067
17068 cs_t *root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
17069 cs_t *markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
17070
17071 data.root_css_buf = root_css_buf;
17072 data.markov_css_buf = markov_css_buf;
17073
17074 sp_tbl_to_css (root_table_buf, markov_table_buf, root_css_buf, markov_css_buf, markov_threshold, uniq_tbls);
17075
17076 data.words_cnt = sp_get_sum (0, css_cnt, root_css_buf);
17077
17078 local_free (root_table_buf);
17079 local_free (markov_table_buf);
17080
17081 // copy + args
17082
17083 uint css_cnt_l = css_cnt;
17084 uint css_cnt_r;
17085
17086 if (attack_exec == ATTACK_EXEC_ON_GPU)
17087 {
17088 if (save_css_cnt < 6)
17089 {
17090 css_cnt_r = 1;
17091 }
17092 else if (save_css_cnt == 6)
17093 {
17094 css_cnt_r = 2;
17095 }
17096 else
17097 {
17098 if (opts_type & OPTS_TYPE_PT_UNICODE)
17099 {
17100 if (save_css_cnt == 8 || save_css_cnt == 10)
17101 {
17102 css_cnt_r = 2;
17103 }
17104 else
17105 {
17106 css_cnt_r = 4;
17107 }
17108 }
17109 else
17110 {
17111 if ((css_buf[0].cs_len * css_buf[1].cs_len * css_buf[2].cs_len) > 256)
17112 {
17113 css_cnt_r = 3;
17114 }
17115 else
17116 {
17117 css_cnt_r = 4;
17118 }
17119 }
17120 }
17121 }
17122 else
17123 {
17124 css_cnt_r = 1;
17125
17126 /* unfinished code?
17127 int sum = css_buf[css_cnt_r - 1].cs_len;
17128
17129 for (uint i = 1; i < 4 && i < css_cnt; i++)
17130 {
17131 if (sum > 1) break; // we really don't need alot of amplifier them for slow hashes
17132
17133 css_cnt_r++;
17134
17135 sum *= css_buf[css_cnt_r - 1].cs_len;
17136 }
17137 */
17138 }
17139
17140 css_cnt_l -= css_cnt_r;
17141
17142 data.bfs_cnt = sp_get_sum (0, css_cnt_r, root_css_buf);
17143
17144 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17145 {
17146 hc_device_param_t *device_param = &data.devices_param[device_id];
17147
17148 device_param->kernel_params_mp_l[0] = &device_param->d_pws_buf;
17149 device_param->kernel_params_mp_l[1] = &device_param->d_root_css_buf;
17150 device_param->kernel_params_mp_l[2] = &device_param->d_markov_css_buf;
17151
17152 device_param->kernel_params_mp_l_buf64[3] = 0;
17153 device_param->kernel_params_mp_l_buf32[4] = css_cnt_l;
17154 device_param->kernel_params_mp_l_buf32[5] = css_cnt_r;
17155 device_param->kernel_params_mp_l_buf32[6] = 0;
17156 device_param->kernel_params_mp_l_buf32[7] = 0;
17157 device_param->kernel_params_mp_l_buf32[8] = 0;
17158
17159 if (opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_l_buf32[6] = full01;
17160 if (opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_l_buf32[6] = full80;
17161 if (opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1;
17162 if (opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1;
17163
17164 device_param->kernel_params_mp_r[0] = &device_param->d_bfs;
17165 device_param->kernel_params_mp_r[1] = &device_param->d_root_css_buf;
17166 device_param->kernel_params_mp_r[2] = &device_param->d_markov_css_buf;
17167
17168 device_param->kernel_params_mp_r_buf64[3] = 0;
17169 device_param->kernel_params_mp_r_buf32[4] = css_cnt_r;
17170 device_param->kernel_params_mp_r_buf32[5] = 0;
17171 device_param->kernel_params_mp_r_buf32[6] = 0;
17172 device_param->kernel_params_mp_r_buf32[7] = 0;
17173
17174 #ifdef _CUDA
17175 hc_cuCtxPushCurrent (device_param->context);
17176
17177 hc_cuMemcpyHtoD (device_param->d_root_css_buf, root_css_buf, device_param->size_root_css);
17178 hc_cuMemcpyHtoD (device_param->d_markov_css_buf, markov_css_buf, device_param->size_markov_css);
17179
17180 hc_cuCtxPopCurrent (&device_param->context);
17181 #elif _OCL
17182 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]);
17183 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]);
17184 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]);
17185
17186 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]);
17187 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]);
17188 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]);
17189
17190 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);
17191 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);
17192 #endif
17193 }
17194 }
17195
17196 uint64_t words_base = data.words_cnt;
17197
17198 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
17199 {
17200 if (data.gpu_rules_cnt)
17201 {
17202 words_base /= data.gpu_rules_cnt;
17203 }
17204 }
17205 else if (data.attack_kern == ATTACK_KERN_COMBI)
17206 {
17207 if (data.combs_cnt)
17208 {
17209 words_base /= data.combs_cnt;
17210 }
17211 }
17212 else if (data.attack_kern == ATTACK_KERN_BF)
17213 {
17214 if (data.bfs_cnt)
17215 {
17216 words_base /= data.bfs_cnt;
17217 }
17218 }
17219
17220 data.words_base = words_base;
17221
17222 if (keyspace == 1)
17223 {
17224 log_info ("%llu", (unsigned long long int) words_base);
17225
17226 return (0);
17227 }
17228
17229 if (data.words_cur > data.words_base)
17230 {
17231 log_error ("ERROR: restore value greater keyspace");
17232
17233 return (-1);
17234 }
17235
17236 if (data.words_cur)
17237 {
17238 if (data.attack_kern == ATTACK_KERN_STRAIGHT)
17239 {
17240 for (uint i = 0; i < data.salts_cnt; i++)
17241 {
17242 data.words_progress_restored[i] = data.words_cur * data.gpu_rules_cnt;
17243 }
17244 }
17245 else if (data.attack_kern == ATTACK_KERN_COMBI)
17246 {
17247 for (uint i = 0; i < data.salts_cnt; i++)
17248 {
17249 data.words_progress_restored[i] = data.words_cur * data.combs_cnt;
17250 }
17251 }
17252 else if (data.attack_kern == ATTACK_KERN_BF)
17253 {
17254 for (uint i = 0; i < data.salts_cnt; i++)
17255 {
17256 data.words_progress_restored[i] = data.words_cur * data.bfs_cnt;
17257 }
17258 }
17259 }
17260
17261 /*
17262 * Inform user about possible slow speeds
17263 */
17264
17265 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
17266 {
17267 if (data.words_base < gpu_blocks_all)
17268 {
17269 if (quiet == 0)
17270 {
17271 log_info ("");
17272 log_info ("ATTENTION!");
17273 log_info (" The wordlist or mask you are using is too small.");
17274 log_info (" Therefore, oclHashcat is unable to utilize the full parallelization power of your GPU(s).");
17275 log_info (" The cracking speed will drop.");
17276 log_info (" Workaround: https://hashcat.net/wiki/doku.php?id=frequently_asked_questions#how_to_create_more_work_for_full_speed");
17277 log_info ("");
17278 }
17279 }
17280 }
17281
17282 /*
17283 * Update loopback file
17284 */
17285
17286 if (loopback == 1)
17287 {
17288 time_t now;
17289
17290 time (&now);
17291
17292 uint random_num = get_random_num (0, 9999);
17293
17294 snprintf (loopback_file, loopback_size - 1, "%s/%s.%d_%i", induction_directory, LOOPBACK_FILE, (int) now, random_num);
17295
17296 data.loopback_file = loopback_file;
17297 }
17298
17299 /*
17300 * Update dictionary statistic
17301 */
17302
17303 if (keyspace == 0)
17304 {
17305 dictstat_fp = fopen (dictstat, "wb");
17306
17307 if (dictstat_fp)
17308 {
17309 fwrite (dictstat_base, sizeof (dictstat_t), dictstat_nmemb, dictstat_fp);
17310
17311 fclose (dictstat_fp);
17312 }
17313 }
17314
17315 data.devices_status = STATUS_RUNNING;
17316
17317 if (initial_restore_done == 0)
17318 {
17319 if (data.restore_disable == 0) cycle_restore ();
17320
17321 initial_restore_done = 1;
17322 }
17323
17324 hc_timer_set (&data.timer_running);
17325
17326 if ((wordlist_mode == WL_MODE_FILE) || (wordlist_mode == WL_MODE_MASK))
17327 {
17328 if ((quiet == 0) && (status == 0) && (benchmark == 0))
17329 {
17330 if (quiet == 0) fprintf (stdout, "%s", PROMPT);
17331 if (quiet == 0) fflush (stdout);
17332 }
17333 }
17334 else if (wordlist_mode == WL_MODE_STDIN)
17335 {
17336 if (data.quiet == 0) log_info ("Starting attack in stdin mode...");
17337 if (data.quiet == 0) log_info ("");
17338 }
17339
17340 time_t runtime_start;
17341
17342 time (&runtime_start);
17343
17344 data.runtime_start = runtime_start;
17345
17346 /**
17347 * create cracker threads
17348 */
17349
17350 hc_thread_t *c_threads = (hc_thread_t *) mycalloc (devices_cnt, sizeof (hc_thread_t));
17351
17352 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17353 {
17354 hc_device_param_t *device_param = &devices_param[device_id];
17355
17356 device_param->device_id = device_id;
17357
17358 if (wordlist_mode == WL_MODE_STDIN)
17359 {
17360 hc_thread_create (c_threads[device_id], thread_calc_stdin, device_param);
17361 }
17362 else
17363 {
17364 hc_thread_create (c_threads[device_id], thread_calc, device_param);
17365 }
17366 }
17367
17368 // wait for crack threads to exit
17369
17370 hc_thread_wait (devices_cnt, c_threads);
17371
17372 local_free (c_threads);
17373
17374 data.restore = 0;
17375
17376 // finalize task
17377
17378 logfile_sub_var_uint ("status-after-work", data.devices_status);
17379
17380 if (data.devices_status == STATUS_CRACKED) break;
17381 if (data.devices_status == STATUS_ABORTED) break;
17382
17383 if (data.devices_status == STATUS_BYPASS)
17384 {
17385 data.devices_status = STATUS_RUNNING;
17386 }
17387
17388 if (induction_dictionaries_cnt)
17389 {
17390 unlink (induction_dictionaries[0]);
17391 }
17392
17393 free (induction_dictionaries);
17394
17395 if (attack_mode != ATTACK_MODE_BF)
17396 {
17397 induction_dictionaries = scan_directory (induction_directory);
17398
17399 induction_dictionaries_cnt = count_dictionaries (induction_dictionaries);
17400 }
17401
17402 if (benchmark == 0)
17403 {
17404 if (((dictpos + 1) < dictcnt) || ((maskpos + 1) < maskcnt) || induction_dictionaries_cnt)
17405 {
17406 if (quiet == 0) clear_prompt ();
17407
17408 if (quiet == 0) log_info ("");
17409
17410 if (status == 1)
17411 {
17412 status_display ();
17413 }
17414 else
17415 {
17416 if (quiet == 0) status_display ();
17417 }
17418
17419 if (quiet == 0) log_info ("");
17420 }
17421 }
17422
17423 if (attack_mode == ATTACK_MODE_BF)
17424 {
17425 dictpos++;
17426
17427 rd->dictpos = dictpos;
17428 }
17429 else
17430 {
17431 if (induction_dictionaries_cnt)
17432 {
17433 qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
17434 }
17435 else
17436 {
17437 dictpos++;
17438
17439 rd->dictpos = dictpos;
17440 }
17441 }
17442
17443 time_t runtime_stop;
17444
17445 time (&runtime_stop);
17446
17447 data.runtime_stop = runtime_stop;
17448
17449 logfile_sub_uint (runtime_start);
17450 logfile_sub_uint (runtime_stop);
17451
17452 logfile_sub_msg ("STOP");
17453
17454 global_free (subid);
17455 }
17456
17457 if (data.devices_status == STATUS_CRACKED) break;
17458 if (data.devices_status == STATUS_ABORTED) break;
17459 if (data.devices_status == STATUS_QUIT) break;
17460
17461 if (data.devices_status == STATUS_BYPASS)
17462 {
17463 data.devices_status = STATUS_RUNNING;
17464 }
17465 }
17466
17467 // 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
17468
17469 if (attack_mode == ATTACK_MODE_STRAIGHT)
17470 {
17471 if (data.wordlist_mode == WL_MODE_FILE)
17472 {
17473 if (data.dictfile == NULL)
17474 {
17475 if (dictfiles != NULL)
17476 {
17477 data.dictfile = dictfiles[0];
17478
17479 hc_timer_set (&data.timer_running);
17480 }
17481 }
17482 }
17483 }
17484 // NOTE: combi is okay because it is already set beforehand
17485 else if (attack_mode == ATTACK_MODE_HYBRID1 || attack_mode == ATTACK_MODE_HYBRID2)
17486 {
17487 if (data.dictfile == NULL)
17488 {
17489 if (dictfiles != NULL)
17490 {
17491 hc_timer_set (&data.timer_running);
17492
17493 data.dictfile = dictfiles[0];
17494 }
17495 }
17496 }
17497 else if (attack_mode == ATTACK_MODE_BF)
17498 {
17499 if (data.mask == NULL)
17500 {
17501 hc_timer_set (&data.timer_running);
17502
17503 data.mask = masks[0];
17504 }
17505 }
17506
17507 if ((data.devices_status != STATUS_CRACKED) && (data.devices_status != STATUS_ABORTED) && (data.devices_status != STATUS_QUIT))
17508 {
17509 data.devices_status = STATUS_EXHAUSTED;
17510 }
17511
17512 // if cracked / aborted remove last induction dictionary
17513
17514 for (int file_pos = 0; file_pos < induction_dictionaries_cnt; file_pos++)
17515 {
17516 struct stat induct_stat;
17517
17518 if (stat (induction_dictionaries[file_pos], &induct_stat) == 0)
17519 {
17520 unlink (induction_dictionaries[file_pos]);
17521 }
17522 }
17523
17524 // wait for non-interactive threads
17525
17526 for (uint thread_idx = 0; thread_idx < ni_threads_cnt; thread_idx++)
17527 {
17528 hc_thread_wait (1, &ni_threads[thread_idx]);
17529 }
17530
17531 local_free (ni_threads);
17532
17533 // wait for interactive threads
17534
17535 if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
17536 {
17537 hc_thread_wait (1, &i_thread);
17538 }
17539
17540 // we dont need restore file anymore
17541 if (data.restore_disable == 0)
17542 {
17543 if ((data.devices_status == STATUS_EXHAUSTED) || (data.devices_status == STATUS_CRACKED))
17544 {
17545 unlink (eff_restore_file);
17546 unlink (new_restore_file);
17547 }
17548 else
17549 {
17550 cycle_restore ();
17551 }
17552 }
17553
17554 // finally save left hashes
17555
17556 if ((hashlist_mode == HL_MODE_FILE) && (remove == 1) && (data.digests_saved != data.digests_done))
17557 {
17558 save_hash ();
17559 }
17560
17561 /**
17562 * Clean up
17563 */
17564
17565 if (benchmark == 1)
17566 {
17567 status_benchmark ();
17568
17569 log_info ("");
17570 }
17571 else
17572 {
17573 if (quiet == 0) clear_prompt ();
17574
17575 if (quiet == 0) log_info ("");
17576
17577 if (status == 1)
17578 {
17579 status_display ();
17580 }
17581 else
17582 {
17583 if (quiet == 0) status_display ();
17584 }
17585
17586 if (quiet == 0) log_info ("");
17587 }
17588
17589 for (uint device_id = 0; device_id < devices_cnt; device_id++)
17590 {
17591 hc_device_param_t *device_param = &data.devices_param[device_id];
17592
17593 local_free (device_param->result);
17594
17595 local_free (device_param->pw_caches);
17596
17597 local_free (device_param->combs_buf);
17598
17599 local_free (device_param->hooks_buf);
17600
17601 #ifdef _CUDA
17602 hc_cuCtxPushCurrent (device_param->context);
17603
17604 if (device_param->pws_buf) myfree (device_param->pws_buf);
17605 if (device_param->d_pws_buf) hc_cuMemFree (device_param->d_pws_buf);
17606 if (device_param->d_pws_amp_buf) hc_cuMemFree (device_param->d_pws_amp_buf);
17607 if (device_param->d_rules) hc_cuMemFree (device_param->d_rules);
17608 if (device_param->d_combs) hc_cuMemFree (device_param->d_combs);
17609 if (device_param->d_bfs) hc_cuMemFree (device_param->d_bfs);
17610 if (device_param->d_bitmap_s1_a) hc_cuMemFree (device_param->d_bitmap_s1_a);
17611 if (device_param->d_bitmap_s1_b) hc_cuMemFree (device_param->d_bitmap_s1_b);
17612 if (device_param->d_bitmap_s1_c) hc_cuMemFree (device_param->d_bitmap_s1_c);
17613 if (device_param->d_bitmap_s1_d) hc_cuMemFree (device_param->d_bitmap_s1_d);
17614 if (device_param->d_bitmap_s2_a) hc_cuMemFree (device_param->d_bitmap_s2_a);
17615 if (device_param->d_bitmap_s2_b) hc_cuMemFree (device_param->d_bitmap_s2_b);
17616 if (device_param->d_bitmap_s2_c) hc_cuMemFree (device_param->d_bitmap_s2_c);
17617 if (device_param->d_bitmap_s2_d) hc_cuMemFree (device_param->d_bitmap_s2_d);
17618 if (device_param->d_plain_bufs) hc_cuMemFree (device_param->d_plain_bufs);
17619 if (device_param->d_digests_buf) hc_cuMemFree (device_param->d_digests_buf);
17620 if (device_param->d_digests_shown) hc_cuMemFree (device_param->d_digests_shown);
17621 if (device_param->d_salt_bufs) hc_cuMemFree (device_param->d_salt_bufs);
17622 if (device_param->d_esalt_bufs) hc_cuMemFree (device_param->d_esalt_bufs);
17623 if (device_param->d_tmps) hc_cuMemFree (device_param->d_tmps);
17624 if (device_param->d_hooks) hc_cuMemFree (device_param->d_hooks);
17625 if (device_param->d_result) hc_cuMemFree (device_param->d_result);
17626 if (device_param->d_scryptV_buf) hc_cuMemFree (device_param->d_scryptV_buf);
17627 if (device_param->d_root_css_buf) hc_cuMemFree (device_param->d_root_css_buf);
17628 if (device_param->d_markov_css_buf) hc_cuMemFree (device_param->d_markov_css_buf);
17629
17630 if (device_param->stream) hc_cuStreamDestroy (device_param->stream);
17631 if (device_param->module) hc_cuModuleUnload (device_param->module);
17632
17633 hc_cuCtxPopCurrent (&device_param->context);
17634
17635 if (device_param->context) hc_cuCtxDestroy (device_param->context);
17636
17637 #elif _OCL
17638 local_free (device_param->device_name);
17639
17640 local_free (device_param->device_version);
17641
17642 local_free (device_param->driver_version);
17643
17644 if (device_param->pws_buf) myfree (device_param->pws_buf);
17645 if (device_param->d_pws_buf) hc_clReleaseMemObject (device_param->d_pws_buf);
17646 if (device_param->d_pws_amp_buf) hc_clReleaseMemObject (device_param->d_pws_amp_buf);
17647 if (device_param->d_rules) hc_clReleaseMemObject (device_param->d_rules);
17648 if (device_param->d_rules_c) hc_clReleaseMemObject (device_param->d_rules_c);
17649 if (device_param->d_combs) hc_clReleaseMemObject (device_param->d_combs);
17650 if (device_param->d_combs_c) hc_clReleaseMemObject (device_param->d_combs_c);
17651 if (device_param->d_bfs) hc_clReleaseMemObject (device_param->d_bfs);
17652 if (device_param->d_bfs_c) hc_clReleaseMemObject (device_param->d_bfs_c);
17653 if (device_param->d_bitmap_s1_a) hc_clReleaseMemObject (device_param->d_bitmap_s1_a);
17654 if (device_param->d_bitmap_s1_b) hc_clReleaseMemObject (device_param->d_bitmap_s1_b);
17655 if (device_param->d_bitmap_s1_c) hc_clReleaseMemObject (device_param->d_bitmap_s1_c);
17656 if (device_param->d_bitmap_s1_d) hc_clReleaseMemObject (device_param->d_bitmap_s1_d);
17657 if (device_param->d_bitmap_s2_a) hc_clReleaseMemObject (device_param->d_bitmap_s2_a);
17658 if (device_param->d_bitmap_s2_b) hc_clReleaseMemObject (device_param->d_bitmap_s2_b);
17659 if (device_param->d_bitmap_s2_c) hc_clReleaseMemObject (device_param->d_bitmap_s2_c);
17660 if (device_param->d_bitmap_s2_d) hc_clReleaseMemObject (device_param->d_bitmap_s2_d);
17661 if (device_param->d_plain_bufs) hc_clReleaseMemObject (device_param->d_plain_bufs);
17662 if (device_param->d_digests_buf) hc_clReleaseMemObject (device_param->d_digests_buf);
17663 if (device_param->d_digests_shown) hc_clReleaseMemObject (device_param->d_digests_shown);
17664 if (device_param->d_salt_bufs) hc_clReleaseMemObject (device_param->d_salt_bufs);
17665 if (device_param->d_esalt_bufs) hc_clReleaseMemObject (device_param->d_esalt_bufs);
17666 if (device_param->d_tmps) hc_clReleaseMemObject (device_param->d_tmps);
17667 if (device_param->d_hooks) hc_clReleaseMemObject (device_param->d_hooks);
17668 if (device_param->d_result) hc_clReleaseMemObject (device_param->d_result);
17669 if (device_param->d_scryptV_buf) hc_clReleaseMemObject (device_param->d_scryptV_buf);
17670 if (device_param->d_root_css_buf) hc_clReleaseMemObject (device_param->d_root_css_buf);
17671 if (device_param->d_markov_css_buf) hc_clReleaseMemObject (device_param->d_markov_css_buf);
17672
17673 if (device_param->kernel1) hc_clReleaseKernel (device_param->kernel1);
17674 if (device_param->kernel12) hc_clReleaseKernel (device_param->kernel12);
17675 if (device_param->kernel2) hc_clReleaseKernel (device_param->kernel2);
17676 if (device_param->kernel23) hc_clReleaseKernel (device_param->kernel23);
17677 if (device_param->kernel3) hc_clReleaseKernel (device_param->kernel3);
17678 if (device_param->kernel_mp) hc_clReleaseKernel (device_param->kernel_mp);
17679 if (device_param->kernel_mp_l) hc_clReleaseKernel (device_param->kernel_mp_l);
17680 if (device_param->kernel_mp_r) hc_clReleaseKernel (device_param->kernel_mp_r);
17681
17682 if (device_param->program) hc_clReleaseProgram (device_param->program);
17683 if (device_param->program_mp) hc_clReleaseProgram (device_param->program_mp);
17684 if (device_param->command_queue) hc_clReleaseCommandQueue (device_param->command_queue);
17685 if (device_param->context) hc_clReleaseContext (device_param->context);
17686 #endif
17687 }
17688
17689 #ifdef _OCL
17690 #ifndef OSX
17691
17692 // reset default fan speed
17693
17694 if (gpu_temp_disable == 0)
17695 {
17696 if (gpu_temp_retain != 0)
17697 {
17698 hc_thread_mutex_lock (mux_adl);
17699
17700 for (uint i = 0; i < data.devices_cnt; i++)
17701 {
17702 if (data.hm_device[i].fan_supported == 1)
17703 {
17704 int fanspeed = temp_retain_fanspeed_value[i];
17705
17706 if (fanspeed == -1) continue;
17707
17708 int rc = hm_set_fanspeed_with_device_id (i, fanspeed);
17709
17710 if (rc == -1) log_info ("WARNING: Failed to restore default fan speed for gpu number: %i:", i);
17711 }
17712 }
17713
17714 hc_thread_mutex_unlock (mux_adl);
17715 }
17716 }
17717
17718 // reset power tuning
17719
17720 if (powertune_enable == 1)
17721 {
17722 hc_thread_mutex_lock (mux_adl);
17723
17724 for (uint i = 0; i < data.devices_cnt; i++)
17725 {
17726 if (data.hm_device[i].od_version == 6)
17727 {
17728 // check powertune capabilities first, if not available then skip device
17729
17730 int powertune_supported = 0;
17731
17732 if ((hc_ADL_Overdrive6_PowerControl_Caps (data.hm_dll, data.hm_device[i].adapter_index, &powertune_supported)) != ADL_OK)
17733 {
17734 log_error ("ERROR: Failed to get ADL PowerControl Capabilities");
17735
17736 return (-1);
17737 }
17738
17739 if (powertune_supported != 0)
17740 {
17741 // powercontrol settings
17742
17743 if ((hc_ADL_Overdrive_PowerControl_Set (data.hm_dll, data.hm_device[i].adapter_index, od_power_control_status[i])) != ADL_OK)
17744 {
17745 log_info ("ERROR: Failed to restore the ADL PowerControl values");
17746
17747 return (-1);
17748 }
17749
17750 // clocks
17751
17752 ADLOD6StateInfo *performance_state = (ADLOD6StateInfo*) mycalloc (1, sizeof (ADLOD6StateInfo) + sizeof (ADLOD6PerformanceLevel));
17753
17754 performance_state->iNumberOfPerformanceLevels = 2;
17755
17756 performance_state->aLevels[0].iEngineClock = od_clock_mem_status[i].state.aLevels[0].iEngineClock;
17757 performance_state->aLevels[1].iEngineClock = od_clock_mem_status[i].state.aLevels[1].iEngineClock;
17758 performance_state->aLevels[0].iMemoryClock = od_clock_mem_status[i].state.aLevels[0].iMemoryClock;
17759 performance_state->aLevels[1].iMemoryClock = od_clock_mem_status[i].state.aLevels[1].iMemoryClock;
17760
17761 if ((hc_ADL_Overdrive_State_Set (data.hm_dll, data.hm_device[i].adapter_index, ADL_OD6_SETSTATE_PERFORMANCE, performance_state)) != ADL_OK)
17762 {
17763 log_info ("ERROR: Failed to restore ADL performance state");
17764
17765 return (-1);
17766 }
17767
17768 local_free (performance_state);
17769 }
17770 }
17771 }
17772
17773 hc_thread_mutex_unlock (mux_adl);
17774 }
17775
17776 #endif
17777 #endif
17778
17779 if (gpu_temp_disable == 0)
17780 {
17781 #ifdef _CUDA
17782 #ifdef LINUX
17783 hc_NVML_nvmlShutdown ();
17784 #endif
17785
17786 #ifdef WIN
17787 NvAPI_Unload ();
17788 #endif
17789 #endif
17790
17791 #ifdef _OCL
17792 #ifndef OSX
17793 hc_ADL_Main_Control_Destroy (data.hm_dll);
17794
17795 hm_close (data.hm_dll);
17796 #endif
17797 #endif
17798 }
17799
17800 // free memory
17801
17802 local_free (masks);
17803
17804 local_free (dictstat_base);
17805
17806 for (uint pot_pos = 0; pot_pos < pot_cnt; pot_pos++)
17807 {
17808 pot_t *pot_ptr = &pot[pot_pos];
17809
17810 hash_t *hash = &pot_ptr->hash;
17811
17812 local_free (hash->digest);
17813
17814 if (isSalted)
17815 {
17816 local_free (hash->salt);
17817 }
17818 }
17819
17820 local_free (pot);
17821
17822 local_free (all_gpu_rules_cnt);
17823 local_free (all_gpu_rules_buf);
17824
17825 local_free (wl_data->buf);
17826 local_free (wl_data);
17827
17828 local_free (bitmap_s1_a);
17829 local_free (bitmap_s1_b);
17830 local_free (bitmap_s1_c);
17831 local_free (bitmap_s1_d);
17832 local_free (bitmap_s2_a);
17833 local_free (bitmap_s2_b);
17834 local_free (bitmap_s2_c);
17835 local_free (bitmap_s2_d);
17836
17837 #ifdef _OCL
17838 #ifndef OSX
17839 local_free (temp_retain_fanspeed_value);
17840 local_free (od_clock_mem_status);
17841 local_free (od_power_control_status);
17842 #endif
17843 #endif
17844
17845 global_free (devices_param);
17846
17847 global_free (gpu_rules_buf);
17848
17849 global_free (root_css_buf);
17850 global_free (markov_css_buf);
17851
17852 global_free (digests_buf);
17853 global_free (digests_shown);
17854 global_free (digests_shown_tmp);
17855
17856 global_free (salts_buf);
17857 global_free (salts_shown);
17858
17859 global_free (esalts_buf);
17860
17861 global_free (words_progress_done);
17862 global_free (words_progress_rejected);
17863 global_free (words_progress_restored);
17864
17865 if (pot_fp) fclose (pot_fp);
17866
17867 if (data.devices_status == STATUS_QUIT) break;
17868 }
17869
17870 // destroy others mutex
17871
17872 hc_thread_mutex_delete (mux_dispatcher);
17873 hc_thread_mutex_delete (mux_counter);
17874 hc_thread_mutex_delete (mux_display);
17875 hc_thread_mutex_delete (mux_adl);
17876
17877 // free memory
17878
17879 local_free (eff_restore_file);
17880 local_free (new_restore_file);
17881
17882 local_free (rd);
17883
17884 // loopback
17885
17886 local_free (loopback_file);
17887
17888 if (loopback == 1) unlink (loopback_file);
17889
17890 // induction directory
17891
17892 if (induction_dir == NULL)
17893 {
17894 if (attack_mode != ATTACK_MODE_BF)
17895 {
17896 if (rmdir (induction_directory) == -1)
17897 {
17898 if (errno == ENOENT)
17899 {
17900 // good, we can ignore
17901 }
17902 else if (errno == ENOTEMPTY)
17903 {
17904 // good, we can ignore
17905 }
17906 else
17907 {
17908 log_error ("ERROR: %s: %s", induction_directory, strerror (errno));
17909
17910 return (-1);
17911 }
17912 }
17913
17914 local_free (induction_directory);
17915 }
17916 }
17917
17918 // outfile-check directory
17919
17920 if (outfile_check_dir == NULL)
17921 {
17922 if (rmdir (outfile_check_directory) == -1)
17923 {
17924 if (errno == ENOENT)
17925 {
17926 // good, we can ignore
17927 }
17928 else if (errno == ENOTEMPTY)
17929 {
17930 // good, we can ignore
17931 }
17932 else
17933 {
17934 log_error ("ERROR: %s: %s", outfile_check_directory, strerror (errno));
17935
17936 return (-1);
17937 }
17938 }
17939
17940 local_free (outfile_check_directory);
17941 }
17942
17943 time_t proc_stop;
17944
17945 time (&proc_stop);
17946
17947 logfile_top_uint (proc_start);
17948 logfile_top_uint (proc_stop);
17949
17950 logfile_top_msg ("STOP");
17951
17952 if (quiet == 0) log_info_nn ("Started: %s", ctime (&proc_start));
17953 if (quiet == 0) log_info_nn ("Stopped: %s", ctime (&proc_stop));
17954
17955 if (data.devices_status == STATUS_ABORTED) return 2;
17956 if (data.devices_status == STATUS_QUIT) return 2;
17957 if (data.devices_status == STATUS_EXHAUSTED) return 1;
17958 if (data.devices_status == STATUS_CRACKED) return 0;
17959
17960 return -1;
17961 }