Created
October 18, 2024 14:33
-
-
Save RealEnder/32c7eea7de7be899c18f16e4b9847e22 to your computer and use it in GitHub Desktop.
Calculate potfile from -o output for hashcat m22000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# Calculate potfile from -o output for hashcat m22000 | |
# Useful for -a9 mode, where the cracker, as of v6.2.6 cracker disables potfile output | |
import os | |
import sys | |
from hashlib import pbkdf2_hmac | |
if len(sys.argv) != 2 or not os.path.exists(sys.argv[1]): | |
print(f'Usage: {sys.argv[0]} [hashcat.mac]') | |
sys.exit(1) | |
with open(sys.argv[1], 'r', encoding='utf-8') as f: | |
for line in f: | |
line = line.rstrip('\r\n') | |
arr = line.split(':', 4) | |
if len(arr) != 5: | |
continue | |
if arr[4].startswith('$HEX[') and arr[4].endswith(']'): | |
try: | |
key = bytes.fromhex(arr[4][5:-1]) | |
except ValueError: | |
continue | |
else: | |
key = arr[4].encode() | |
print(f'{pbkdf2_hmac("sha1", key, arr[3].encode(), 4096, 32).hex()}*{arr[3].encode().hex()}:{arr[4]}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment