I'm doing reverse-engineering a product and identified a critical issue with it. The work is done and the developer was notified, but for my own personal curiosity, I'd like to learn how to exploit it so I can make a small write-up.
The short of it is, the developer is using a fixed key and IV for encrypting multiple similar messages using AES-128-CFB. Since I know the IV for all messages, and I know parts of the plaintext (the messages have a standard format, JSON), can I recover the plaintext or key? I'm not looking for someone to do this for me, I'm just looking for how I would tackle this.
Below is a small replication of what is happening, and I noticed that the output is very similar which leads me to believe that is can be cracked.
import base64
from Crypto.Cipher import AES
key = b'\x00'*16
iv = b'\xFF'*16
p1 = b'Hello, world'
p2 = b'Hello, world!'
cipher = AES.new(key, AES.MODE_CFB, iv=iv)
c1 = cipher.encrypt(p1)
e1 = base64.b64encode(c1)
cipher = AES.new(key, AES.MODE_CFB, iv=iv)
c2 = cipher.encrypt(p2)
e2 = base64.b64encode(c2)
print(' '.join('{:02X}'.format(c) for c in c1))
print(' '.join('{:02X}'.format(c) for c in c2))
print(e1.decode())
print(e2.decode())
$ python3 test.py
77 6D 0C 86 D8 6B C9 9F 72 FD F4 3B
77 6D 0C 86 D8 6B C9 9F 72 FD F4 3B 04
d20MhthryZ9y/fQ7
d20MhthryZ9y/fQ7BA==