Created
December 24, 2021 14:07
-
-
Save michelep/c2681714f7266c80de973089d3ad1cc1 to your computer and use it in GitHub Desktop.
Convert OpenLDAP hashes to a format Hashcat can understand
This file contains 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/env python3 | |
# Convert OpenLDAP hashes to a format Hashcat can understand | |
import sys | |
import base64 | |
with open(sys.argv[1], 'r') as f: | |
lines = f.readlines() | |
for line in lines: | |
line = line.rstrip("\n") | |
if '{PBKDF2-SHA512}' in line: | |
username = line.split(':')[0] | |
hashvals = line.split('}')[1] | |
iterations, b64salt, b64hash = hashvals.split('$') | |
b64salt = b64salt.replace('.', '+') | |
b64hash = b64hash.replace('.', '+') | |
print(username + ':' + 'sha512:' + iterations + ':' + b64salt + ':' + b64hash) | |
elif '{SHA256}' in line: | |
user = line.split(':')[0] | |
hhash = base64.b64decode(line.split('}')[1]).hex() | |
print(user + ":" + hhash) | |
elif '{MD5}' in line: | |
user = line.split(':')[0] | |
hhash = base64.b64decode(line.split('}')[1]).hex() | |
print(hhash) | |
elif '{SHA512}' in line: | |
user = line.split(':')[0] | |
hhash = base64.b64decode(line.split('}')[1]).hex() | |
print(user + ":" + hhash) | |
elif '{CRYPT}' in line: | |
print(line.replace('{CRYPT}', '')) | |
else: | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment