Created
September 1, 2017 19:39
-
-
Save grigorescu/682d7efc7282912a7b3c74c7aa4abfd3 to your computer and use it in GitHub Desktop.
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/python | |
import argparse, sys | |
def hexdump(text, space=False): | |
result = "" | |
for t in text: | |
s = str(hex(ord(t))).replace('0x', '') | |
if len(s) == 1: | |
s = '0' + s | |
result = result + s | |
if space: | |
result = result + ' ' | |
return result | |
def fix_parity(key): | |
byte_string = bin(int(key, 16))[2:] | |
result = "" | |
for offset in range(0, 56, 7): | |
byte = byte_string[offset:offset+7] | |
if byte.count('1') % 2 == 1: | |
result = result + chr(int(byte + '0', 2)) | |
else: | |
result = result + chr(int(byte + '1', 2)) | |
return result | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('key', help='kerberos key in hex format') | |
args = parser.parse_args() | |
result = fix_parity(args.key) | |
print hexdump(result) | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment