1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5 
6 #ifndef ENGINE_H
7 #define ENGINE_H
8 
9 #define INCR_RULES_PTR            100000
10 #define INCR_WORDS_PTR            1000000
11 #define INCR_SALT_PTR             10000
12 #define INCR_POT                  100000
13 #define INCR_INDEX_PTR            1
14 #define INCR_DIGEST_PTR           1
15 #define INCR_MASK_PTR             1000
16 
17 #define INDEX_BITS                8
18 
19 #define DIGEST_SIZE_MD5            4 * 4
20 #define DIGEST_SIZE_SHA1           5 * 4
21 #define DIGEST_SIZE_MYSQL          2 * 4
22 #define DIGEST_SIZE_MD4            4 * 4
23 #define DIGEST_SIZE_SHA256         8 * 4
24 #define DIGEST_SIZE_SHA512         8 * 8
25 #define DIGEST_SIZE_DESCRYPT       2 * 4
26 #define DIGEST_SIZE_KECCAK        25 * 8
27 #define DIGEST_SIZE_NETNTLMv1      6 * 4
28 #define DIGEST_SIZE_GOST           8 * 4
29 #define DIGEST_SIZE_BCRYPT         6 * 4
30 #define DIGEST_SIZE_PLAIN          55
31 
32 #define HASH_SIZE_MD5             32
33 #define HASH_SIZE_SHA1            40
34 #define HASH_SIZE_MYSQL           16
35 #define HASH_SIZE_PHPASS          22
36 #define HASH_SIZE_MD5UNIX         22
37 #define HASH_SIZE_SHA1B64         28
38 #define HASH_SIZE_MD4             32
39 #define HASH_SIZE_MD5CHAP         32
40 #define HASH_SIZE_MSSQL2000       80
41 #define HASH_SIZE_MSSQL2005       40
42 #define HASH_SIZE_SHA256          64
43 #define HASH_SIZE_MD5APR          22
44 #define HASH_SIZE_SHA512          128
45 #define HASH_SIZE_SHA512UNIX      86
46 #define HASH_SIZE_MD5SUN          22
47 #define HASH_SIZE_OSX1            40
48 #define HASH_SIZE_OSX512          128
49 #define HASH_SIZE_MSSQL2012       128
50 #define HASH_SIZE_DESCRYPT        11
51 #define HASH_SIZE_KECCAK_MIN      1
52 #define HASH_SIZE_KECCAK_MAX      200
53 #define HASH_SIZE_EPIV6_MIN       27
54 #define HASH_SIZE_EPIV6_MAX       27
55 #define HASH_SIZE_VS2012_MIN      44
56 #define HASH_SIZE_VS2012_MAX      44
57 #define HASH_SIZE_IKEPSK_MD5_MIN  48
58 #define HASH_SIZE_IKEPSK_MD5_MAX  1024
59 #define HASH_SIZE_IKEPSK_SHA1_MIN 56
60 #define HASH_SIZE_IKEPSK_SHA1_MAX 1024
61 #define HASH_SIZE_NETNTLMv1       48
62 #define HASH_SIZE_NETNTLMv2       32
63 #define HASH_SIZE_CISCO_SECRET4   43
64 #define HASH_SIZE_MD5AIX          22
65 #define HASH_SIZE_SHA1AIX         27
66 #define HASH_SIZE_SHA256AIX       43
67 #define HASH_SIZE_SHA512AIX       86
68 #define HASH_SIZE_GOST            64
69 #define HASH_SIZE_SHA1FORTIGATE   40
70 #define HASH_SIZE_PBKDF2OSX       128
71 #define HASH_SIZE_PBKDF2GRUB      128
72 #define HASH_SIZE_MD5CISCO        16
73 #define HASH_SIZE_SHA1ORACLE      40
74 #define HASH_SIZE_BCRYPT          31
75 #define HASH_SIZE_HMACRAKP        40
76 #define HASH_SIZE_SHA256UNIX      43
77 #define HASH_SIZE_EPIV6_4_MIN     43
78 #define HASH_SIZE_EPIV6_4_MAX     43
79 #define HASH_SIZE_SHA512B64       86
80 #define HASH_SIZE_EPIV4_MIN       40
81 #define HASH_SIZE_EPIV4_MAX       40
82 #define HASH_SIZE_SCRYPT_MIN      44
83 #define HASH_SIZE_SCRYPT_MAX      44
84 #define HASH_SIZE_CISCO_SECRET9   43
85 #define HASH_SIZE_DJANGOSHA1_MIN  40
86 #define HASH_SIZE_DJANGOSHA1_MAX  40
87 #define HASH_SIZE_HMAIL           64
88 #define HASH_SIZE_MEDIAWIKI_B_MIN 32
89 #define HASH_SIZE_MEDIAWIKI_B_MAX 32
90 #define HASH_SIZE_CISCO_SECRET8   43
91 #define HASH_SIZE_DJANGO_SHA256   44
92 #define HASH_SIZE_PEOPLESOFT      28
93 #define HASH_SIZE_CRAM_MD5_MIN    44
94 #define HASH_SIZE_CRAM_MD5_MAX    132
95 #define HASH_SIZE_DRUPAL7         43
96 #define HASH_SIZE_SAP_H_MIN       33
97 #define HASH_SIZE_SAP_H_MAX       49
98 #define HASH_SIZE_SHA256B64       44
99 #define HASH_SIZE_PLAIN           55
100 
101 #define HASH_TYPE_MD5             1
102 #define HASH_TYPE_SHA1            2
103 #define HASH_TYPE_MYSQL           3
104 #define HASH_TYPE_PHPASS          4
105 #define HASH_TYPE_MD5UNIX         5
106 #define HASH_TYPE_SHA1B64         6
107 #define HASH_TYPE_SHA1B64S        7
108 #define HASH_TYPE_MD4             9
109 #define HASH_TYPE_DCC             10
110 #define HASH_TYPE_MD5CHAP         11
111 #define HASH_TYPE_MSSQL2000       12
112 #define HASH_TYPE_SHA256          13
113 #define HASH_TYPE_MD5APR          14
114 #define HASH_TYPE_SHA512          15
115 #define HASH_TYPE_SHA512UNIX      16
116 #define HASH_TYPE_MD5SUN          17
117 #define HASH_TYPE_OSX1            18
118 #define HASH_TYPE_OSX512          19
119 #define HASH_TYPE_MSSQL2012       20
120 #define HASH_TYPE_DESCRYPT        21
121 #define HASH_TYPE_KECCAK          22
122 #define HASH_TYPE_EPIV6           23
123 #define HASH_TYPE_VS2012          24
124 #define HASH_TYPE_PSAFE3          25
125 #define HASH_TYPE_IKEPSK_MD5      26
126 #define HASH_TYPE_IKEPSK_SHA1     27
127 #define HASH_TYPE_NETNTLMv1       28
128 #define HASH_TYPE_NETNTLMv2       29
129 #define HASH_TYPE_WPA             30
130 #define HASH_TYPE_CISCO_SECRET4   31
131 #define HASH_TYPE_MD5AIX          32
132 #define HASH_TYPE_SHA1AIX         33
133 #define HASH_TYPE_SHA256AIX       34
134 #define HASH_TYPE_SHA512AIX       35
135 #define HASH_TYPE_GOST            36
136 #define HASH_TYPE_SHA1FORTIGATE   37
137 #define HASH_TYPE_PBKDF2OSX       38
138 #define HASH_TYPE_PBKDF2GRUB      39
139 #define HASH_TYPE_MSSQL2005       40
140 #define HASH_TYPE_MD5CISCO_PIX    41
141 #define HASH_TYPE_SHA1ORACLE      42
142 #define HASH_TYPE_HMACRAKP        43
143 #define HASH_TYPE_BCRYPT          44
144 #define HASH_TYPE_SHA256UNIX      45
145 #define HASH_TYPE_EPIV6_4         46
146 #define HASH_TYPE_SHA512B64S      47
147 #define HASH_TYPE_EPIV4           48
148 #define HASH_TYPE_SCRYPT          49
149 #define HASH_TYPE_CISCO_SECRET9   50
150 #define HASH_TYPE_PHPS            51
151 #define HASH_TYPE_DJANGOSHA1      52
152 #define HASH_TYPE_HMAIL           53
153 #define HASH_TYPE_MEDIAWIKI_B     54
154 #define HASH_TYPE_CISCO_SECRET8   55
155 #define HASH_TYPE_DJANGO_SHA256   56
156 #define HASH_TYPE_PEOPLESOFT      57
157 #define HASH_TYPE_CRAM_MD5        58
158 #define HASH_TYPE_DRUPAL7         59
159 #define HASH_TYPE_MD5CISCO_ASA    60
160 #define HASH_TYPE_SAP_H_SHA1      61
161 #define HASH_TYPE_PRESTASHOP      62
162 #define HASH_TYPE_POSTGRESQL_AUTH 63
163 #define HASH_TYPE_MYSQL_AUTH      64
164 #define HASH_TYPE_SIP_AUTH        65
165 #define HASH_TYPE_SHA256B64       66
166 #define HASH_TYPE_PLAIN           99
167 
168 #define PLAIN_SIZE_MD5            55
169 #define PLAIN_SIZE_SHA1           55
170 #define PLAIN_SIZE_MYSQL          55
171 #define PLAIN_SIZE_PHPASS         55
172 #define PLAIN_SIZE_MD5UNIX        16
173 #define PLAIN_SIZE_SHA1B64        55
174 #define PLAIN_SIZE_SHA1B64S       55
175 #define PLAIN_SIZE_MD4            55
176 #define PLAIN_SIZE_NTLM           27
177 #define PLAIN_SIZE_DCC            27
178 #define PLAIN_SIZE_MD5CHAP        55
179 #define PLAIN_SIZE_MSSQL2000      27
180 #define PLAIN_SIZE_MSSQL2005      27
181 #define PLAIN_SIZE_SHA256         55
182 #define PLAIN_SIZE_MD5APR         16
183 #define PLAIN_SIZE_SHA512         55
184 #define PLAIN_SIZE_SHA512UNIX     64
185 #define PLAIN_SIZE_MD5SUN         55
186 #define PLAIN_SIZE_OSX1           55
187 #define PLAIN_SIZE_OSX512         55
188 #define PLAIN_SIZE_MSSQL2012      27
189 #define PLAIN_SIZE_DESCRYPT       8
190 #define PLAIN_SIZE_KECCAK         55
191 #define PLAIN_SIZE_EPIV6          27
192 #define PLAIN_SIZE_VS2012         55
193 #define PLAIN_SIZE_WPA            64
194 #define PLAIN_SIZE_MD5AIX         16
195 #define PLAIN_SIZE_SHA1AIX        55
196 #define PLAIN_SIZE_SHA256AIX      55
197 #define PLAIN_SIZE_SHA512AIX      55
198 #define PLAIN_SIZE_GOST           55
199 #define PLAIN_SIZE_FORTIGATE      47
200 #define PLAIN_SIZE_PBKDF2OSX      55
201 #define PLAIN_SIZE_PBKDF2GRUB     55
202 #define PLAIN_SIZE_NETNTLMv1      27
203 #define PLAIN_SIZE_NETNTLMv2      27
204 #define PLAIN_SIZE_MD5CISCO       16
205 #define PLAIN_SIZE_SHA1ORACLE     55
206 #define PLAIN_SIZE_HMACRAKP       55
207 #define PLAIN_SIZE_BCRYPT         55
208 #define PLAIN_SIZE_SHA256UNIX     16
209 #define PLAIN_SIZE_EPIV6_4        55
210 #define PLAIN_SIZE_SHA512B64S     55
211 #define PLAIN_SIZE_EPIV4          55
212 #define PLAIN_SIZE_SCRYPT         55
213 #define PLAIN_SIZE_CISCO_SECRET8  55
214 #define PLAIN_SIZE_DJANGO_SHA256  55
215 #define PLAIN_SIZE_PLAIN          55
216 
217 #define SALT_TYPE_NONE            1 << 1
218 #define SALT_TYPE_INCLUDED        1 << 2
219 #define SALT_TYPE_EXTERNAL        1 << 3
220 #define SALT_TYPE_EMBEDDED        1 << 4
221 
222 #define SALT_SIZE_MIN_MD5           0
223 #define SALT_SIZE_MAX_MD5           54
224 #define SALT_SIZE_MIN_SHA1          0
225 #define SALT_SIZE_MAX_SHA1          54
226 #define SALT_SIZE_MIN_PHPASS        8
227 #define SALT_SIZE_MAX_PHPASS        8
228 #define SALT_SIZE_MIN_MD5UNIX       0
229 #define SALT_SIZE_MAX_MD5UNIX       8
230 #define SALT_SIZE_MIN_SHA1B64S      0
231 #define SALT_SIZE_MAX_SHA1B64S      32
232 #define SALT_SIZE_MIN_DCC           1
233 #define SALT_SIZE_MAX_DCC           54
234 #define SALT_SIZE_MIN_MD5CHAP       32
235 #define SALT_SIZE_MAX_MD5CHAP       32
236 #define SALT_SIZE_MIN_MSSQL2000     8
237 #define SALT_SIZE_MIN_MSSQL2005     8
238 #define SALT_SIZE_MAX_MSSQL2000     8
239 #define SALT_SIZE_MAX_MSSQL2005     8
240 #define SALT_SIZE_MIN_SHA256        0
241 #define SALT_SIZE_MAX_SHA256        54
242 #define SALT_SIZE_MIN_MD5APR        0
243 #define SALT_SIZE_MAX_MD5APR        8
244 #define SALT_SIZE_MIN_SHA512        0
245 #define SALT_SIZE_MAX_SHA512        54
246 #define SALT_SIZE_MIN_SHA512UNIX    0
247 #define SALT_SIZE_MAX_SHA512UNIX    54
248 #define SALT_SIZE_MIN_MD5SUN        1
249 #define SALT_SIZE_MAX_MD5SUN        17
250 #define SALT_SIZE_MIN_OSX1          8
251 #define SALT_SIZE_MAX_OSX1          8
252 #define SALT_SIZE_MIN_OSX512        8
253 #define SALT_SIZE_MAX_OSX512        8
254 #define SALT_SIZE_MIN_MSSQL2012     8
255 #define SALT_SIZE_MAX_MSSQL2012     8
256 #define SALT_SIZE_MIN_DESCRYPT      2
257 #define SALT_SIZE_MAX_DESCRYPT      2
258 #define SALT_SIZE_MIN_KECCAK        1
259 #define SALT_SIZE_MAX_KECCAK        54
260 #define SALT_SIZE_MIN_EPIV6         1
261 #define SALT_SIZE_MAX_EPIV6         44
262 #define SALT_SIZE_MIN_VS2012        1
263 #define SALT_SIZE_MAX_VS2012        44
264 #define SALT_SIZE_MIN_NETNTLMv1     16
265 #define SALT_SIZE_MAX_NETNTLMv1     16
266 #define SALT_SIZE_MIN_NETNTLMv2     ( 1 +  1 + 1 + 16 + 1 +    1)
267 #define SALT_SIZE_MAX_NETNTLMv2     (60 + 45 + 1 + 16 + 1 + 1024)
268 #define SALT_SIZE_MIN_MD5AIX        8
269 #define SALT_SIZE_MAX_MD5AIX        8
270 #define SALT_SIZE_MIN_SHA1AIX       16
271 #define SALT_SIZE_MAX_SHA1AIX       128
272 #define SALT_SIZE_MIN_SHA256AIX     16
273 #define SALT_SIZE_MAX_SHA256AIX     128
274 #define SALT_SIZE_MIN_SHA512AIX     16
275 #define SALT_SIZE_MAX_SHA512AIX     128
276 #define SALT_SIZE_SHA1FORTIGATE     12
277 #define SALT_SIZE_MIN_PBKDF2OSX     64
278 #define SALT_SIZE_MAX_PBKDF2OSX     64
279 #define SALT_SIZE_MIN_PBKDF2GRUB    1
280 #define SALT_SIZE_MAX_PBKDF2GRUB    1024
281 #define SALT_SIZE_MIN_SHA1ORACLE    20
282 #define SALT_SIZE_MAX_SHA1ORACLE    20
283 #define SALT_SIZE_MIN_HMACRAKP      64
284 #define SALT_SIZE_MAX_HMACRAKP      512
285 #define SALT_SIZE_MIN_BCRYPT        22
286 #define SALT_SIZE_MAX_BCRYPT        22
287 #define SALT_SIZE_MIN_SHA256UNIX    0
288 #define SALT_SIZE_MAX_SHA256UNIX    16
289 #define SALT_SIZE_MIN_EPIV6_4       24
290 #define SALT_SIZE_MAX_EPIV6_4       24
291 #define SALT_SIZE_MIN_SHA512B64S    0
292 #define SALT_SIZE_MAX_SHA512B64S    68
293 #define SALT_SIZE_MIN_EPIV4         60
294 #define SALT_SIZE_MAX_EPIV4         60
295 #define SALT_SIZE_MIN_SCRYPT        1
296 #define SALT_SIZE_MAX_SCRYPT        44
297 #define SALT_SIZE_CISCO_SECRET9     14
298 #define SALT_SIZE_MIN_DJANGOSHA1    0
299 #define SALT_SIZE_MAX_DJANGOSHA1    54
300 #define SALT_SIZE_HMAIL             6
301 #define SALT_SIZE_MIN_MEDIAWIKI_B   0
302 #define SALT_SIZE_MAX_MEDIAWIKI_B   54
303 #define SALT_SIZE_MIN_CISCO_SECRET8 14
304 #define SALT_SIZE_MAX_CISCO_SECRET8 14
305 #define SALT_SIZE_MIN_DJANGO_SHA256 0
306 #define SALT_SIZE_MAX_DJANGO_SHA256 128
307 #define SALT_SIZE_MIN_CRAM_MD5      12
308 #define SALT_SIZE_MAX_CRAM_MD5      76
309 #define SALT_SIZE_DRUPAL7           8
310 #define SALT_SIZE_MIN_MD5CISCO_ASA  0
311 #define SALT_SIZE_MAX_MD5CISCO_ASA  16
312 #define SALT_SIZE_MIN_SAP_H_SHA1    4
313 #define SALT_SIZE_MAX_SAP_H_SHA1    16
314 #define SALT_SIZE_MIN_PRESTASHOP    56
315 #define SALT_SIZE_MAX_PRESTASHOP    56
316 #define SALT_SIZE_POSTGRESQL_AUTH   8
317 #define SALT_SIZE_MYSQL_AUTH        40
318 
319 #define PSAFE3_SIGN               4
320 #define PSAFE3_MAGIC              "PWS3"
321 #define PSAFE3_ROUNDS             2048
322 
323 #define PHPASS_SIGN               3
324 #define PHPASS_ITER               1
325 #define PHPASS_MAGIC_P            "$P$"
326 #define PHPASS_MAGIC_H            "$H$"
327 #define PHPASS_ROUNDS             (1 << 11)
328 
329 #define MD5UNIX_SIGN              3
330 #define MD5UNIX_MAGIC             "$1$"
331 #define MD5UNIX_ROUNDS            1000
332 
333 #define MD5SUN_SIGN               4
334 #define MD5SUN_MAGIC              "$md5"
335 #define MD5SUN_ROUNDS_MIN         4096
336 
337 #define MD5APR_SIGN               6
338 #define MD5APR_MAGIC              "$apr1$"
339 #define MD5APR_ROUNDS             1000
340 
341 #define SHA512UNIX_SIGN           3
342 #define SHA512UNIX_MAGIC          "$6$"
343 #define SHA512UNIX_ROUNDS         5000
344 
345 #define SHA1B64_SIGN              5
346 #define SHA1B64_MAGIC             "{SHA}"
347 
348 #define SHA1B64S_SIGN             6
349 #define SHA1B64S_MAGIC            "{SSHA}"
350 
351 #define MD5CHAP_IDBYTE            2
352 
353 #define MSSQL_SIGN                6
354 #define MSSQL_MAGIC               "0x0100"
355 
356 #define MSSQL2012_SIGN            6
357 #define MSSQL2012_MAGIC           "0x0200"
358 
359 #define EPISERVERV6_SIGN          14
360 #define EPISERVERV6_MAGIC         "$episerver$*0*"
361 
362 #define NETNTLMv1_SIGN            9
363 #define NETNTLMv1_MAGIC           "$NETNTLM$"
364 
365 #define NETNTLMv2_SIGN            11
366 #define NETNTLMv2_MAGIC           "$NETNTLMv2$"
367 
368 #define MD5AIX_SIGN               6
369 #define MD5AIX_MAGIC              "{smd5}"
370 #define MD5AIX_ROUNDS             1000
371 
372 #define SHA1AIX_SIGN              7
373 #define SHA1AIX_MAGIC             "{ssha1}"
374 #define SHA1AIX_ROUNDS            (1 << 6)
375 
376 #define SHA256AIX_SIGN            9
377 #define SHA256AIX_MAGIC           "{ssha256}"
378 #define SHA256AIX_ROUNDS          (1 << 6)
379 
380 #define SHA512AIX_SIGN            9
381 #define SHA512AIX_MAGIC           "{ssha512}"
382 #define SHA512AIX_ROUNDS          (1 << 6)
383 
384 #define FORTIGATE_SIGN            3
385 #define FORTIGATE_MAGIC           "AK1"
386 #define FORTIGATE_MAGIC_A         "\xa3\x88\xba\x2e\x42\x4c\xb0\x4a\x53\x79\x30\xc1\x31\x07\xcc\x3f\xa1\x32\x90\x29\xa9\x81\x5b\x70"
387 
388 #define PBKDF2OSX_SIGN            4
389 #define PBKDF2OSX_MAGIC           "$ml$"
390 #define PBKDF2OSX_ROUNDS          35000
391 
392 #define PBKDF2GRUB_SIGN           19
393 #define PBKDF2GRUB_MAGIC          "grub.pbkdf2.sha512."
394 #define PBKDF2GRUB_ROUNDS         10000
395 
396 #define BCRYPT_SIGN               4
397 #define BCRYPT_MAGIC              "$2a$"
398 #define BCRYPT_ROUNDS             (1 << 5)
399 
400 #define SHA256UNIX_SIGN           3
401 #define SHA256UNIX_MAGIC          "$5$"
402 #define SHA256UNIX_ROUNDS         5000
403 
404 #define EPISERVERV6_4_SIGN        14
405 #define EPISERVERV6_4_MAGIC       "$episerver$*1*"
406 
407 #define SHA512B64S_SIGN           9
408 #define SHA512B64S_MAGIC          "{SSHA512}"
409 
410 #define EPISERVERV4_SIGN          2
411 #define EPISERVERV4_MAGIC         "0x"
412 
413 #define SCRYPT_SIGN               6
414 #define SCRYPT_MAGIC              "SCRYPT"
415 
416 #define CISCO_SECRET9_SIGN        3
417 #define CISCO_SECRET9_MAGIC       "$9$"
418 
419 #define WPA2_ROUNDS               4096
420 
421 #define ANDROID_PIN_ROUNDS        1024
422 
423 #define PHPS_SIGN                 6
424 #define PHPS_MAGIC                "$PHPS$"
425 
426 #define DJANGOSHA1_SIGN           5
427 #define DJANGOSHA1_MAGIC          "sha1$"
428 
429 #define MEDIAWIKI_B_SIGN          3
430 #define MEDIAWIKI_B_MAGIC         "$B$"
431 
432 #define CISCO_SECRET8_SIGN        3
433 #define CISCO_SECRET8_MAGIC       "$8$"
434 #define CISCO_SECRET8_ROUNDS      20000
435 
436 #define DJANGO_SHA256_SIGN        14
437 #define DJANGO_SHA256_MAGIC       "pbkdf2_sha256$"
438 #define DJANGO_SHA256_ROUNDS      20000
439 
440 #define CRAM_MD5_SIGN             10
441 #define CRAM_MD5_MAGIC            "$cram_md5$"
442 
443 #define DRUPAL7_SIGN              3
444 #define DRUPAL7_MAGIC             "$S$"
445 #define DRUPAL7_ROUNDS            16384
446 
447 #define SAP_H_SHA1_SIGN           10
448 #define SAP_H_SHA1_MAGIC          "{x-issha, "
449 #define SAP_H_SHA1_ROUNDS         1024
450 
451 #define POSTGRESQL_AUTH_SIGN      10
452 #define POSTGRESQL_AUTH_MAGIC     "$postgres$"
453 
454 #define MYSQL_AUTH_SIGN           9
455 #define MYSQL_AUTH_MAGIC          "$mysqlna$"
456 
457 #define SIP_AUTH_SIGN             6
458 #define SIP_AUTH_MAGIC            "$sip$*"
459 
460 /**
461  * Strings
462  */
463 
464 #define HT_00000  "MD5"
465 #define HT_00010  "md5($pass.$salt)"
466 #define HT_00020  "md5($salt.$pass)"
467 #define HT_00030  "md5(unicode($pass).$salt)"
468 #define HT_00040  "md5($salt.unicode($pass))"
469 #define HT_00050  "HMAC-MD5 (key = $pass)"
470 #define HT_00060  "HMAC-MD5 (key = $salt)"
471 #define HT_00100  "SHA1"
472 #define HT_00110  "sha1($pass.$salt)"
473 #define HT_00120  "sha1($salt.$pass)"
474 #define HT_00130  "sha1(unicode($pass).$salt)"
475 #define HT_00140  "sha1($salt.unicode($pass))"
476 #define HT_00150  "HMAC-SHA1 (key = $pass)"
477 #define HT_00160  "HMAC-SHA1 (key = $salt)"
478 #define HT_00190  "sha1(LinkedIn)"
479 #define HT_00200  "MySQL323"
480 #define HT_00300  "MySQL4.1/MySQL5"
481 #define HT_00400  "phpass, MD5(Wordpress), MD5(phpBB3), MD5(Joomla)"
482 #define HT_00500  "md5crypt, MD5(Unix), FreeBSD MD5, Cisco-IOS MD5"
483 #define HT_00501  "Juniper IVE"
484 #define HT_00666  "Plaintext"
485 #define HT_00900  "MD4"
486 #define HT_01000  "NTLM"
487 #define HT_01100  "Domain Cached Credentials (DCC), MS Cache"
488 #define HT_01400  "SHA256"
489 #define HT_01410  "sha256($pass.$salt)"
490 #define HT_01420  "sha256($salt.$pass)"
491 #define HT_01430  "sha256(unicode($pass).$salt)"
492 #define HT_01431  "base64(sha256(unicode($pass)))"
493 #define HT_01440  "sha256($salt.$pass)"
494 #define HT_01450  "HMAC-SHA256 (key = $pass)"
495 #define HT_01460  "HMAC-SHA256 (key = $salt)"
496 #define HT_01500  "descrypt, DES(Unix), Traditional DES"
497 #define HT_01600  "md5apr1, MD5(APR), Apache MD5"
498 #define HT_01700  "SHA512"
499 #define HT_01710  "sha512($pass.$salt)"
500 #define HT_01720  "sha512($salt.$pass)"
501 #define HT_01730  "sha512(unicode($pass).$salt)"
502 #define HT_01740  "sha512($salt.unicode($pass))"
503 #define HT_01750  "HMAC-SHA512 (key = $pass)"
504 #define HT_01760  "HMAC-SHA512 (key = $salt)"
505 #define HT_01800  "sha512crypt, SHA512(Unix)"
506 #define HT_02400  "Cisco-PIX MD5"
507 #define HT_02410  "Cisco-ASA MD5"
508 #define HT_02500  "WPA/WPA2"
509 #define HT_02600  "Double MD5"
510 #define HT_03200  "bcrypt, Blowfish(OpenBSD)"
511 #define HT_03300  "MD5(Sun)"
512 #define HT_03500  "md5(md5(md5($pass)))"
513 #define HT_03610  "md5(md5($salt).$pass)"
514 #define HT_03710  "md5($salt.md5($pass))"
515 #define HT_03720  "md5($pass.md5($salt))"
516 #define HT_03800  "md5($salt.$pass.$salt)"
517 #define HT_03910  "md5(md5($pass).md5($salt))"
518 #define HT_04010  "md5($salt.md5($salt.$pass))"
519 #define HT_04110  "md5($salt.md5($pass.$salt))"
520 #define HT_04210  "md5($username.0.$pass)"
521 #define HT_04300  "md5(strtoupper(md5($pass)))"
522 #define HT_04400  "md5(sha1($pass))"
523 #define HT_04500  "Double SHA1"
524 #define HT_04600  "sha1(sha1(sha1($pass)))"
525 #define HT_04700  "sha1(md5($pass))"
526 #define HT_04800  "MD5(Chap), iSCSI CHAP authentication"
527 #define HT_04900  "sha1($salt.$pass.$salt)"
528 #define HT_05000  "SHA-3(Keccak)"
529 #define HT_05100  "Half MD5"
530 #define HT_05200  "Password Safe v3"
531 #define HT_05300  "IKE-PSK MD5"
532 #define HT_05400  "IKE-PSK SHA1"
533 #define HT_05500  "NetNTLMv1-VANILLA / NetNTLMv1+ESS"
534 #define HT_05600  "NetNTLMv2"
535 #define HT_05700  "Cisco-IOS SHA256"
536 #define HT_05800  "Android PIN"
537 #define HT_06300  "AIX {smd5}"
538 #define HT_06400  "AIX {ssha256}"
539 #define HT_06500  "AIX {ssha512}"
540 #define HT_06700  "AIX {ssha1}"
541 #define HT_06900  "GOST R 34.11-94"
542 #define HT_07000  "Fortigate (FortiOS)"
543 #define HT_07100  "OSX v10.8+"
544 #define HT_07200  "GRUB 2"
545 #define HT_07300  "IPMI2 RAKP HMAC-SHA1"
546 #define HT_07400  "sha256crypt, SHA256(Unix)"
547 #define HT_07900  "Drupal7"
548 #define HT_08400  "WBB3, Woltlab Burning Board 3"
549 #define HT_08900  "scrypt"
550 #define HT_09200  "Cisco $8$"
551 #define HT_09300  "Cisco $9$"
552 #define HT_09900  "Radmin2"
553 #define HT_10000  "Django (PBKDF2-SHA256)"
554 #define HT_10200  "Cram MD5"
555 #define HT_10300  "SAP CODVN H (PWDSALTEDHASH) iSSHA-1"
556 #define HT_11000  "PrestaShop"
557 #define HT_11100  "PostgreSQL Challenge-Response Authentication (MD5)"
558 #define HT_11200  "MySQL Challenge-Response Authentication (SHA1)"
559 #define HT_11400  "SIP digest authentication (MD5)"
560 #define HT_99999  "Plaintext"
561 
562 #define HT_00011  "Joomla < 2.5.18"
563 #define HT_00012  "PostgreSQL"
564 #define HT_00021  "osCommerce, xt:Commerce"
565 #define HT_00023  "Skype"
566 #define HT_00101  "SHA-1(Base64), nsldap, Netscape LDAP SHA"
567 #define HT_00111  "SSHA-1(Base64), nsldaps, Netscape LDAP SSHA"
568 #define HT_00112  "Oracle S: Type (Oracle 11+)"
569 #define HT_00121  "SMF > v1.1"
570 #define HT_00122  "OSX v10.4, v10.5, v10.6"
571 #define HT_00123  "EPi"
572 #define HT_00124  "Django (SHA-1)"
573 #define HT_00131  "MSSQL(2000)"
574 #define HT_00132  "MSSQL(2005)"
575 #define HT_00133  "PeopleSoft"
576 #define HT_00141  "EPiServer 6.x < v4"
577 #define HT_01421  "hMailServer"
578 #define HT_01441  "EPiServer 6.x > v4"
579 #define HT_01711  "SSHA-512(Base64), LDAP {SSHA512}"
580 #define HT_01722  "OSX v10.7"
581 #define HT_01731  "MSSQL(2012)"
582 #define HT_02611  "vBulletin < v3.8.5"
583 #define HT_02612  "PHPS"
584 #define HT_02711  "vBulletin > v3.8.5"
585 #define HT_02811  "IPB2+, MyBB1.2+"
586 #define HT_03711  "Mediawiki B type"
587 #define HT_03721  "WebEdition CMS"
588 #define HT_07600  "Redmine Project Management Web App"
589 
590 static const char constant_phrase[] =
591   "To be, or not to be,--that is the question:--\n"
592   "Whether 'tis nobler in the mind to suffer\n"
593   "The slings and arrows of outrageous fortune\n"
594   "Or to take arms against a sea of troubles,\n"
595   "And by opposing end them?--To die,--to sleep,--\n"
596   "No more; and by a sleep to say we end\n"
597   "The heartache, and the thousand natural shocks\n"
598   "That flesh is heir to,--'tis a consummation\n"
599   "Devoutly to be wish'd. To die,--to sleep;--\n"
600   "To sleep! perchance to dream:--ay, there's the rub;\n"
601   "For in that sleep of death what dreams may come,\n"
602   "When we have shuffled off this mortal coil,\n"
603   "Must give us pause: there's the respect\n"
604   "That makes calamity of so long life;\n"
605   "For who would bear the whips and scorns of time,\n"
606   "The oppressor's wrong, the proud man's contumely,\n"
607   "The pangs of despis'd love, the law's delay,\n"
608   "The insolence of office, and the spurns\n"
609   "That patient merit of the unworthy takes,\n"
610   "When he himself might his quietus make\n"
611   "With a bare bodkin? who would these fardels bear,\n"
612   "To grunt and sweat under a weary life,\n"
613   "But that the dread of something after death,--\n"
614   "The undiscover'd country, from whose bourn\n"
615   "No traveller returns,--puzzles the will,\n"
616   "And makes us rather bear those ills we have\n"
617   "Than fly to others that we know not of?\n"
618   "Thus conscience does make cowards of us all;\n"
619   "And thus the native hue of resolution\n"
620   "Is sicklied o'er with the pale cast of thought;\n"
621   "And enterprises of great pith and moment,\n"
622   "With this regard, their currents turn awry,\n"
623   "And lose the name of action.--Soft you now!\n"
624   "The fair Ophelia!--Nymph, in thy orisons\n"
625   "Be all my sins remember'd.\n";
626 
627 #define STATUS_STARTING 0
628 #define STATUS_INIT     1
629 #define STATUS_RUNNING  2
630 #define STATUS_PAUSED   3
631 #define STATUS_ABORTED  6
632 #define STATUS_QUIT     7
633 #define STATUS_BYPASS   8
634 
635 uint64_t get_thread_words_total  (uint32_t num_threads);
636 uint64_t get_thread_plains_total (uint32_t num_threads);
637 
638 void descrypt_decode (unsigned char digest[DIGEST_SIZE_DESCRYPT], unsigned char buf[HASH_SIZE_DESCRYPT]);
639 void descrypt_encode (unsigned char digest[DIGEST_SIZE_DESCRYPT], unsigned char buf[HASH_SIZE_DESCRYPT]);
640 
641 void phpass_decode (unsigned char digest[DIGEST_SIZE_MD5], unsigned char buf[HASH_SIZE_PHPASS]);
642 void phpass_encode (unsigned char digest[DIGEST_SIZE_MD5], unsigned char buf[HASH_SIZE_PHPASS]);
643 
644 void md5unix_decode (unsigned char digest[DIGEST_SIZE_MD5], unsigned char buf[HASH_SIZE_MD5UNIX]);
645 void md5unix_encode (unsigned char digest[DIGEST_SIZE_MD5], unsigned char buf[HASH_SIZE_MD5UNIX]);
646 
647 void md5sun_decode (unsigned char digest[DIGEST_SIZE_MD5], unsigned char buf[HASH_SIZE_MD5SUN]);
648 void md5sun_encode (unsigned char digest[DIGEST_SIZE_MD5], unsigned char buf[HASH_SIZE_MD5SUN]);
649 
650 void md5apr_decode (unsigned char digest[DIGEST_SIZE_MD5], unsigned char buf[HASH_SIZE_MD5APR]);
651 void md5apr_encode (unsigned char digest[DIGEST_SIZE_MD5], unsigned char buf[HASH_SIZE_MD5APR]);
652 
653 void sha512unix_decode (unsigned char digest[DIGEST_SIZE_SHA512], unsigned char buf[HASH_SIZE_SHA512UNIX]);
654 void sha512unix_encode (unsigned char digest[DIGEST_SIZE_SHA512], unsigned char buf[HASH_SIZE_SHA512UNIX]);
655 
656 void sha1b64_decode (unsigned char digest[DIGEST_SIZE_SHA1], unsigned char buf[HASH_SIZE_SHA1B64]);
657 void sha1b64_encode (unsigned char digest[DIGEST_SIZE_SHA1], unsigned char buf[HASH_SIZE_SHA1B64]);
658 
659 void sha1b64s_decode (unsigned char digest[DIGEST_SIZE_SHA1], unsigned char salt[BLOCK_SIZE], uint32_t in_len, uint32_t *out_len, char *buf);
660 void sha1b64s_encode (unsigned char digest[DIGEST_SIZE_SHA1], unsigned char salt[BLOCK_SIZE], uint32_t salt_len, char *buf);
661 
662 void sha256b64_decode (unsigned char digest[DIGEST_SIZE_SHA256], unsigned char buf[HASH_SIZE_SHA256B64]);
663 void sha256b64_encode (unsigned char digest[DIGEST_SIZE_SHA256], unsigned char buf[HASH_SIZE_SHA256B64]);
664 
665 void sha1aix_decode (unsigned char digest[DIGEST_SIZE_SHA1], unsigned char buf[HASH_SIZE_SHA1AIX]);
666 void sha1aix_encode (unsigned char digest[DIGEST_SIZE_SHA1], unsigned char buf[HASH_SIZE_SHA1AIX]);
667 
668 void sha256aix_decode (unsigned char digest[DIGEST_SIZE_SHA256], unsigned char buf[HASH_SIZE_SHA256AIX]);
669 void sha256aix_encode (unsigned char digest[DIGEST_SIZE_SHA256], unsigned char buf[HASH_SIZE_SHA256AIX]);
670 
671 void sha512aix_decode (unsigned char digest[DIGEST_SIZE_SHA512], unsigned char buf[HASH_SIZE_SHA512AIX]);
672 void sha512aix_encode (unsigned char digest[DIGEST_SIZE_SHA512], unsigned char buf[HASH_SIZE_SHA512AIX]);
673 
674 void sha1fortigate_decode (unsigned char digest[DIGEST_SIZE_SHA1], unsigned char salt[BLOCK_SIZE], char *buf);
675 void sha1fortigate_encode (unsigned char digest[DIGEST_SIZE_SHA1], unsigned char salt[BLOCK_SIZE], char *buf);
676 
677 void sha256unix_decode (unsigned char digest[DIGEST_SIZE_SHA256], unsigned char buf[HASH_SIZE_SHA256UNIX]);
678 void sha256unix_encode (unsigned char digest[DIGEST_SIZE_SHA256], unsigned char buf[HASH_SIZE_SHA256UNIX]);
679 
680 void md5cisco_decode (char in_buf[HASH_SIZE_MD5CISCO], uint32_t out_buf[4]);
681 void md5cisco_encode (uint32_t in_buf[4], unsigned char *out_buf);
682 
683 void bcrypt_encode (char digest[DIGEST_SIZE_BCRYPT], char salt[16], char *bcrypt_str);
684 void bcrypt_decode (char digest[HASH_SIZE_BCRYPT], char salt[SALT_SIZE_MIN_BCRYPT], char *hash_buf, char *salt_buf);
685 
686 void sha512b64s_encode (unsigned char digest[DIGEST_SIZE_SHA512], unsigned char salt[BLOCK_SIZE], uint32_t salt_len, char *buf);
687 void sha512b64s_decode (unsigned char digest[DIGEST_SIZE_SHA512], unsigned char salt[BLOCK_SIZE], uint32_t in_len, uint32_t *out_len, char *buf);
688 
689 void drupal7_encode (unsigned char digest[DIGEST_SIZE_SHA512], unsigned char buf[HASH_SIZE_DRUPAL7]);
690 void drupal7_decode (unsigned char digest[DIGEST_SIZE_SHA512], unsigned char buf[HASH_SIZE_DRUPAL7]);
691 
692 void format_plain  (FILE *fp, char *plain_ptr, uint plain_len, uint32_t output_authex);
693 void format_output (FILE *fp, engine_parameter_t *engine_parameter, char *out_buf, char *plain_ptr, uint plain_len, uint64_t pos);
694 
695 int sort_by_pot (const void *v1, const void *v2);
696 
697 void handle_show_request (FILE *out_fp, engine_parameter_t *engine_parameter, pot_t *pot, char *input_buf, int input_len, char *hash_buf, char *salt_buf, uint32_t salt_len, uint user_len);
698 void handle_left_request (FILE *out_fp, engine_parameter_t *engine_parameter, pot_t *pot, char *input_buf, int input_len, char *hash_buf, char *salt_buf, uint32_t salt_len);
699 
700 char *strhashtype (const uint hash_mode);
701 
702 uint is_valid_hex_char (const char c);
703 
704 char hex_convert (char c);
705 
706 char hex_to_char (char hex[2]);
707 
708 char int_to_itoa64 (const char c);
709 char itoa64_to_int (const char c);
710 
711 int base64_decode (char (*f) (const char), char *in_buf, int in_len, char *out_buf);
712 int base64_encode (char (*f) (const char), char *in_buf, int in_len, char *out_buf);
713 
714 uint32_t hex_to_uint   (char hex[ 8]);
715 uint64_t hex_to_uint64 (char hex[16]);
716 
717 void uint_to_hex_lower (uint32_t uint, char hex[8]);
718 void uint_to_hex_upper (uint32_t uint, char hex[8]);
719 
720 void transform_netntlmv1_key (const uint8_t *nthash, uint8_t *key);
721 
722 int compare_digest_plain      (const void *p1, const void *p2);
723 int compare_digest_md5        (const void *p1, const void *p2);
724 int compare_digest_sha1       (const void *p1, const void *p2);
725 int compare_digest_mysql      (const void *p1, const void *p2);
726 int compare_digest_md4        (const void *p1, const void *p2);
727 int compare_digest_sha256     (const void *p1, const void *p2);
728 int compare_digest_sha512     (const void *p1, const void *p2);
729 int compare_digest_descrypt   (const void *p1, const void *p2);
730 int compare_digest_keccak     (const void *p1, const void *p2);
731 int compare_digest_netntlmv1  (const void *p1, const void *p2);
732 int compare_digest_gost       (const void *p1, const void *p2);
733 int compare_digest_bcrypt     (const void *p1, const void *p2);
734 
735 void descrypt_64    (plain_t *plains, digest_t *digests);
736 void keccak_64      (plain_t *plains, digest_t *digests);
737 void gost_64        (plain_t *plains, digest_t *digests);
738 
739 void _des_keysetup (uint32_t data[2], uint32_t Kc[16], uint32_t Kd[16], const uint s_skb[8][64]);
740 void _des_encrypt  (uint32_t data[2], uint32_t Kc[16], uint32_t Kd[16], const uint s_SPtrans[8][64]);
741 
742 void hashcat_md4_64    (__m128i digests[4], __m128i W[16]);
743 void hashcat_md5_64    (__m128i digests[4], __m128i W[16]);
744 void hashcat_sha1_64   (__m128i digests[5], __m128i W[16]);
745 void hashcat_sha256_64 (__m128i digests[8], __m128i W[16]);
746 void hashcat_sha512_64 (__m128i digests[8], __m128i W[16]);
747 
748 void init_sse2 ();
749 
750 void run_threads (engine_parameter_t *engine_parameter, db_t *db, void (*store_out) (plain_t *, digest_t *, salt_t *), void (*store_debug) (char *, int), void (*done) (), digest_t *quick_digest);
751 
752 extern plain_t **plains_iteration;
753 
754 #endif /* ENGINE_H */
755