|
35 | 35 | from hashlib import md5 |
36 | 36 | from hashlib import sha1 |
37 | 37 | from hashlib import sha224 |
| 38 | +from hashlib import sha256 |
38 | 39 | from hashlib import sha384 |
39 | 40 | from hashlib import sha512 |
40 | 41 | from Queue import Queue |
@@ -272,6 +273,16 @@ def sha224_generic_passwd(password, uppercase=False): |
272 | 273 |
|
273 | 274 | return retVal.upper() if uppercase else retVal.lower() |
274 | 275 |
|
| 276 | +def sha256_generic_passwd(password, uppercase=False): |
| 277 | + """ |
| 278 | + >>> sha256_generic_passwd(password='testpass', uppercase=False) |
| 279 | + '13d249f2cb4127b40cfa757866850278793f814ded3c587fe5889e889a7a9f6c' |
| 280 | + """ |
| 281 | + |
| 282 | + retVal = sha256(password).hexdigest() |
| 283 | + |
| 284 | + return retVal.upper() if uppercase else retVal.lower() |
| 285 | + |
275 | 286 | def sha384_generic_passwd(password, uppercase=False): |
276 | 287 | """ |
277 | 288 | >>> sha384_generic_passwd(password='testpass', uppercase=False) |
@@ -455,6 +466,7 @@ def _encode64(input_, count): |
455 | 466 | HASH.MD5_GENERIC: md5_generic_passwd, |
456 | 467 | HASH.SHA1_GENERIC: sha1_generic_passwd, |
457 | 468 | HASH.SHA224_GENERIC: sha224_generic_passwd, |
| 469 | + HASH.SHA256_GENERIC: sha256_generic_passwd, |
458 | 470 | HASH.SHA384_GENERIC: sha384_generic_passwd, |
459 | 471 | HASH.SHA512_GENERIC: sha512_generic_passwd, |
460 | 472 | HASH.CRYPT_GENERIC: crypt_generic_passwd, |
@@ -911,7 +923,8 @@ def dictionaryAttack(attack_dict): |
911 | 923 | if user and not user.startswith(DUMMY_USER_PREFIX): |
912 | 924 | custom_wordlist.append(normalizeUnicode(user)) |
913 | 925 |
|
914 | | - if hash_regex in (HASH.MYSQL, HASH.MYSQL_OLD, HASH.MD5_GENERIC, HASH.SHA1_GENERIC, HASH.APACHE_SHA1): |
| 926 | + # Algorithms without extra arguments (e.g. salt and/or username) |
| 927 | + if hash_regex in (HASH.MYSQL, HASH.MYSQL_OLD, HASH.MD5_GENERIC, HASH.SHA1_GENERIC, HASH.SHA224_GENERIC, HASH.SHA256_GENERIC, HASH.SHA384_GENERIC, HASH.SHA512_GENERIC, HASH.APACHE_SHA1): |
915 | 928 | for suffix in suffix_list: |
916 | 929 | if not attack_info or processException: |
917 | 930 | break |
|
0 commit comments