Natas Level 28
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Username: natas28
URL: http://natas28.natas.labs.overthewire.org
Study guide¶
Level map: sign in as natas28 and find the password for natas29.
What this level teaches¶
An encryption oracle attack against ECB mode.
Key ideas¶
- ECB mode. Each block of 16 bytes is encrypted independently, so identical plaintext blocks give identical ciphertext blocks and blocks can be rearranged.
- Oracle. The application encrypts text you submit, which you can study.
- Finding the block boundaries. Submitting repeated input and watching where the ciphertext starts to repeat reveals how the application's own text is laid out.
- Cut and paste. You can build a ciphertext containing the plaintext you want by assembling blocks from different requests.
How to approach it¶
- Submit inputs of increasing length and watch the output length and repeating patterns.
- Work out the unknown prefix and suffix the server adds.
- Craft input so that a block you control contains the SQL you want, then reuse it.
How developers prevent it¶
Use authenticated encryption such as AES-GCM, and do not construct SQL from decrypted data.