Skip to content

Instantly share code, notes, and snippets.

@malware-kitten
Created May 13, 2019 18:45
Show Gist options
  • Save malware-kitten/2eec2e2531e32a9a5575fc6c0c063b9e to your computer and use it in GitHub Desktop.
Save malware-kitten/2eec2e2531e32a9a5575fc6c0c063b9e to your computer and use it in GitHub Desktop.
Convert CLSID to Hex
#!/usr/bin/env python
import binascii
import sys
'''
Usage:
python3 clsid.py 85131631-480C-11D2-B1F9-00C04F86C324
311613850c48d211B1F900C04F86C324
'''
def parse(clsid):
parts = [binascii.unhexlify(chunk) for chunk in clsid.split('-')]
repacked = [int.from_bytes(parts[0], byteorder='little'),
int.from_bytes(parts[1], byteorder='little'),
int.from_bytes(parts[2], byteorder='little'),
int.from_bytes(parts[3], byteorder='big'),
int.from_bytes(parts[4], byteorder='big')]
return '{:08x}{:04x}{:04x}{:04X}{:012X}'.format(*repacked)
if __name__ == '__main__':
print(parse(sys.argv[1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment