Skip to content

Instantly share code, notes, and snippets.

@skelsec
Created June 1, 2022 21:00
Show Gist options
  • Save skelsec/0f4430ffcd5f963a073d9a5ce02890e1 to your computer and use it in GitHub Desktop.
Save skelsec/0f4430ffcd5f963a073d9a5ce02890e1 to your computer and use it in GitHub Desktop.
More incorrect decryption
from Cryptodome.Cipher import AES
from Cryptodome.Random import get_random_bytes
from pypykatz.commons.common import hexdump
data = b"secret"*10
key = b'\xAA'*16
iv = b'\xAA'*16
cipher = AES.new(key, AES.MODE_CFB, iv=iv)
ct_bytes = cipher.encrypt(data)
print('============ ENCRYPTION ============')
print('DATA:')
print(hexdump(data))
print('IV:')
print(hexdump(iv))
print('KEY')
print(hexdump(key))
print('ENC DATA')
print(hexdump(ct_bytes))
#################################################
dec_iv = b'\xFF'*16
dec_key = b'\xAA'*16
print('============ DECRYPTION ============')
print('ENC DATA')
print(hexdump(ct_bytes))
print('IV:')
print(hexdump(dec_iv))
print('KEY')
print(hexdump(dec_key))
cipher = AES.new(dec_key, AES.MODE_CFB, iv=dec_iv)
data_dec = cipher.decrypt(ct_bytes)
print('DEC DATA')
print(hexdump(data_dec))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment