247CTF - The Impossible User
An encryption service encrypts plaintext, but blocks encryption of
the impossible_flag_user string. Exploit the ECB mode
implementation to forge an encrypted token that decrypts to this
forbidden value.
Vulnerability
The service uses AES in ECB mode, which has critical weakness: identical plaintext blocks produce identical ciphertext blocks. By crafting specific payloads, we can:
- Encrypt the first 16 bytes of the target string
- Encrypt padding-aligned subsequent bytes
- Concatenate the cipher blocks to forge a valid token
Exploit Strategy
The target user is: impossible_flag_user (23 bytes)
- Block 1: Encrypt
impossible_flag_(16 bytes) → get first cipher block - Block 2: Encrypt
user+ PKCS#7 padding → get second cipher block - Combine: Concatenate blocks to form forged token → decrypt equals target
Solution
1 | import binascii |