def aes_encryption(incoming_shellcode, encryption_pad=4):
# Generate a random key, create the cipher object
# pad the shellcode, and encrypt the padded shellcode
# return encrypted -> encoded shellcode and key
random_aes_key = helpers.randomKey()
iv = helpers.randomString(16)
aes_cipher_object = AES.new(random_aes_key, AES.MODE_CBC, iv)
padded_shellcode = encryption_padding(incoming_shellcode, encryption_pad)
encrypted_shellcode = aes_cipher_object.encrypt(padded_shellcode)
encoded_ciphertext = base64.b64encode(encrypted_shellcode)
return encoded_ciphertext, random_aes_key, iv
评论列表
文章目录