imp/examples/local-ecboracle.py

29 lines
667 B
Python
Raw Normal View History

2025-06-26 00:20:13 +10:00
import string
2025-07-06 19:20:20 +10:00
from celeste.attacks import paddingoracle
2025-06-26 00:20:13 +10:00
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)
2025-06-26 01:26:27 +10:00
def encrypt(b: bytes, debug=False) -> bytes:
2025-06-26 00:20:13 +10:00
padded = pad(b + FLAG, 16)
2025-06-26 01:26:27 +10:00
if debug:
print(padded)
2025-06-26 00:20:13 +10:00
# print(padded)
return CIPHER.encrypt(padded)
def main() -> None:
2025-06-26 01:26:27 +10:00
paddingoracle.crack(encrypt, pad, CHARSET, 16, batch_size=50, debug=True)
2025-06-26 00:20:13 +10:00
if __name__ == '__main__':
try:
main()
except (KeyboardInterrupt, EOFError):
print('\n[!] Interrupt')