Added padding oracle attack vector

This commit is contained in:
Emile Clark-Boman 2025-06-26 00:20:13 +10:00
parent 09d4c52043
commit 6365e737df
8 changed files with 412 additions and 0 deletions

26
test.py Normal file
View file

@ -0,0 +1,26 @@
import string
from imp.attacks import paddingoracle
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
CHARSET = [c.encode() for c in string.printable]
KEY = b'you wont get me!'
FLAG = b'imbaud{omg_you_catched_me}'
CIPHER = AES.new(KEY, AES.MODE_ECB)
def encrypt(b: bytes) -> bytes:
padded = pad(b + FLAG, 16)
# print(padded)
return CIPHER.encrypt(padded)
def main() -> None:
paddingoracle.crack(encrypt, pad, CHARSET, 16, batch_size=1, debug=True)
if __name__ == '__main__':
try:
main()
except (KeyboardInterrupt, EOFError):
print('\n[!] Interrupt')