ApoorvCTF
We played ApoorvCTF
Crypto
kowareta cipher
THe question is about AES-ECB Plaintext Recovery. It is a cryptographic attack that exploits the weaknesses of the ECB mode. In ECB mode, identical plaintext blocks are encrypted into identical ciphertext blocks, making it vulnerable to pattern recognition and chosen-plaintext attacks.
Chall.py1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37import sys
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
from random import randbytes
def main():
key = randbytes(16)
cipher = AES.new(key, AES.MODE_ECB)
flag = b'apoorvctf{fake_flag_123}'
print("Welcome to the ECB Oracle challenge!")
print("Enter your input in hex format.")
try:
while True:
print("Enter your input: ", end="", flush=True)
userinput = sys.stdin.readline().strip()
if not userinput:
break
try:
userinput = bytes.fromhex(userinput)
ciphertext = cipher.encrypt(pad(userinput + flag + userinput, 16))
print(ciphertext)
print("Ciphertext:", ciphertext.hex())
except Exception as e:
print(f"Error: {str(e)}")
except KeyboardInterrupt:
print("Server shutting down.")
if __name__ == "__main__":
main()
main()
I’m using a script from John Hammond’s YT video here
solve.py
1 |
|




