Skip to content

Commit

Permalink
Create py3_AES.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Nero22k authored May 2, 2021
1 parent b8509f6 commit e79ee5a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions py3_AES.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import sys
from base64 import b64encode
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from Crypto.Random import get_random_bytes
import hashlib

KEY = get_random_bytes(16)
iv = 16 * b'\x00'
cipher = AES.new(hashlib.sha256(KEY).digest(), AES.MODE_CBC, iv)

try:
plaintext = open(sys.argv[1], "rb").read()
except:
print("Argument needed! %s <raw payload file>" % sys.argv[0])
sys.exit()

ciphertext = cipher.encrypt(pad(plaintext, AES.block_size))

# spits out an encrypted payload with the key to be used for decryption
print('AESkey = { 0x' + ', 0x'.join(hex(x)[2:] for x in KEY) + ' };')
print('payload = { 0x' + ', 0x'.join(hex(x)[2:] for x in ciphertext) + ' };')

0 comments on commit e79ee5a

Please sign in to comment.