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 (20 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
This construction assumes /encrypt accepts hex-encoded
plaintext and encrypts caller-provided bytes under the same ECB key
across both requests. If it also applies PKCS#7, its extra padding block
is discarded. The local check covers block layout and unpadding only;
the service and endpoint parsing have not been rerun.
Solution
1 | import binascii |
The returned flag belongs to the launched service instance; no cross-instance invariance is established. Record the generation/retrieval method and use the current instance response instead of a fixed-answer spoiler.