Advertisement
9r3nXPaRTa

Tools IPMIView-Decryptor By GrenXPaRTa

Oct 5th, 2021
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.55 KB | None | 0 0
  1. import sys
  2. from Crypto.Cipher import AES
  3. from Crypto.Util.Padding import unpad, pad
  4. import binascii
  5.  
  6. # example hashes password is ADMIN
  7. # 192.168.4.245=ADMIN,9fffcc32ee4ff7a419a1394121259f4e
  8. # 16bytesaaaaaaaaa=ADMIN,403c38617187a228142c0745b2c48c56
  9.  
  10.  
  11. def encrypt(device_name, encrypted_text):
  12.  
  13.     iv = b'\x00' * 16
  14.     if len(device_name) < 16:
  15.         key = pad(device_name, 16, style='iso7816')
  16.     elif len(device_name) == 16:
  17.         key = device_name
  18.  
  19.     padding_len = 16 - len(encrypted_text)
  20.     padding = b'\x00' * padding_len
  21.     data = encrypted_text + padding
  22.     # data = pad(encrypted_text, 16, style='iso7816')
  23.  
  24.     print('Using key: {}'.format(key))
  25.     print('Using iv: {}'.format(iv))
  26.  
  27.     print('Using data: {}'.format(data))
  28.  
  29.     cipher1 = AES.new(key, AES.MODE_CBC, iv)
  30.     ct = cipher1.encrypt(data)
  31.  
  32.     print(ct.hex())
  33.  
  34.  
  35. def decrypt(device_name, encrypted_text):
  36.  
  37.     # I know, i'll get fancy later to catch the other cases.
  38.     # RN only works if less than 16
  39.     padding_len = 16 - len(device_name)
  40.     padding = b'\x00' * padding_len
  41.     key = device_name + padding
  42.  
  43.     print('Device Name (key): {}'.format(key))
  44.  
  45.     iv = b'\x00' * 16
  46.     data = binascii.unhexlify(encrypted_text)
  47.  
  48.     print('Encrypted Text: {}'.format(data))
  49.  
  50.     cipher2 = AES.new(key, AES.MODE_CBC, iv)
  51.     pt = cipher2.decrypt(data)
  52.  
  53.     print('Password: {}'.format(pt.decode()))
  54.  
  55.  
  56. if __name__ == '__main__':
  57.     # encrypt(sys.argv[1].encode('utf-8'), sys.argv[2].encode('utf-8'))
  58.     decrypt(sys.argv[1].encode('utf-8'), sys.argv[2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement