Skip to content

Instantly share code, notes, and snippets.

@drahamim
Forked from chancez/supermicro_ipmi.py
Created December 28, 2021 18:59
Show Gist options
  • Save drahamim/1f29d93b883651073d791d18c2481c0e to your computer and use it in GitHub Desktop.
Save drahamim/1f29d93b883651073d791d18c2481c0e to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import string
import sys
import hmac
import hashlib
def split_hex(value):
value = value[4:] if len(value) % 4 == 0 else "0" + value[4:]
return " ".join(value[i:i+4] for i in range(0, len(value), 4))
SECRET = bytearray.fromhex('85 44 E3 B4 7E CA 58 F9 58 30 43 F8')
D = hmac.new(SECRET, digestmod=hashlib.sha1)
mac = bytearray.fromhex(sys.argv[1].replace(":", " "))
D.update(mac)
y = D.hexdigest()[:24]
x = int(D.hexdigest()[:24], 16)
print(' '.join(y[i:i+4] for i in range(0, len(y), 4)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment