I found a hash of an encrypted PIN code (in this case 9999) which I know to be encrypted using AES CTR.
Problem is, I can't figure how to write this in python. I know the key and the IV are the same however I understand CTR mode does not require an IV but instead uses a counter. I just can't figure out how to use the IV/Counter part of CTR.
from Crypto.Cipher import AES
from Crypto.Util import Counter
import base64
import binascii
hashed = "aEotxA=="
encrypted = base64.b64decode(hashed)
key = b'4170ac2a2782a1516fe9e13d7322ae48'
iv = b'4170ac2a2782a1516fe9e13d7322ae48'
aes = AES.new(key, AES.MODE_CTR)
print (binascii.hexlify(aes.decrypt(encrypted)))
I've also tried using Counter:
ctr = Counter.new(128, initial_value=int_of_string(iv[:16]))
aes = AES.new(key, AES.MODE_CTR, ctr)
Any help would be great thank you.