keine, don't use openssl, use python instead with crypto plus:
https://github.com/doegox/python-cryptoplus
https://github.com/doegox/python-cryptoplus
Code:
import sys, os, hashlib
from Crypto.Cipher import AES
from CryptoPlus.Util import util
def sha1(data):
return hashlib.sha1(data).digest()
def aes_ctr(key, iv, input):
ctr = util.Counter(iv)
aes = AES.new(key, AES.MODE_CTR, counter=ctr)
output = aes.encrypt(input)
return output
def aes_decrypt_cbc(key, iv, input):
aes = AES.new(key, AES.MODE_CBC, iv)
output = aes.decrypt(input)
return output
key = 'keyhere'.decode('hex')
iv = 'ivhere'.decode('hex')
# put kernel.img from offset 0x100, not from 0x0
with open(sys.argv[1], 'rb') as f:
data = f.read()
data = aes_decrypt_cbc(key, iv, data)
with open(sys.argv[1] + '.out', 'wb') as f:
f.write(data)