Recover the Hidden Suffix
medium · 100 XP · machine with a lab · free · solves: 0
A test service encrypts your input with AES in ECB mode. Before it encrypts, it adds a hidden suffix after your input and pads the result with PKCS#7. The key is fixed and secret. There is no hidden prefix. The suffix contains the flag.
Start the lab. The service runs on host oracle, TCP port 9000.
Protocol. The service sends two banner lines when you connect. Send one command per line:
encrypt <hex>: the service replies with one line, the hex ciphertext of<your bytes> || suffix. Sendencryptwith no hex for empty input.- Input is at most 4096 bytes.
- Each connection allows 20000 encrypt queries. Then the service closes the connection. A new connection starts a new count with the same key and suffix.
- A line that starts with
error:reports a problem with your command.
client.py opens one connection and gives you Oracle.encrypt(data) for your scripts. Run it alone to send one input: python3 client.py 41414141.
Your task.
- Find the block size from the changes in ciphertext length.
- Confirm ECB mode with repeated input blocks.
- Recover the suffix one byte at a time. Use the suffix length to stop before the padding bytes.
Submit the flag that you find in the suffix.
Tags: learn
Try next
- Read the Vault's Timing (medium)
- Recover Plaintext with a Padding Oracle (medium)
- Intercept a Diffie-Hellman Exchange (medium)