An interactive command-line tool for performing Padding Oracle Attacks against AES-CBC encrypted ciphertext. This tool generates attack vectors and guides you through the byte-by-byte decryption process.
A Padding Oracle Attack is a side-channel attack that exploits the padding validation of block ciphers operating in CBC (Cipher Block Chaining) mode. By observing whether decrypted ciphertext has valid padding, an attacker can iteratively reveal the plaintext without knowing the encryption key.
This tool assists in the attack by:
- Generating 256 attack vectors for each byte position
- Writing the vectors to files for testing against the target oracle
- Interactively collecting feedback on which vector produced valid padding
- Progressively revealing intermediate values and plaintext bytes
- 🔐 AES-128-CBC Support — Works with 16-byte block size
- 📦 Multi-block Decryption — Handles ciphertexts of arbitrary length
- 🧮 Automatic Vector Generation — Creates all 256 test cases per byte
- 📄 File-based Output — Writes
ciphertexts.txtandIVs.txtfor easy integration - 🖥️ Interactive CLI — Step-by-step guided attack process
- 📊 Real-time Progress — Displays revealed bytes as ASCII and hex
- Python 3.6+
- No external dependencies (uses only standard library)
git clone https://github.com/yourusername/AES-CBC-Padding-Oracle-Attack-Interactive-Tool.git
cd AES-CBC-Padding-Oracle-Attack-Interactive-Toolpython padding_oracle.pyWhen prompted, provide:
- Ciphertext: Hexadecimal string (no spaces), must be a multiple of 16 bytes
- IV (Initialization Vector): Hexadecimal string, exactly 16 bytes (32 hex characters)
- Enter the ciphertext and IV in hexadecimal format
- For each byte position (right to left, 256 guesses per byte):
- The tool generates 256 attack vectors
- Vectors are saved to
ciphertexts.txtandIVs.txt - Test each vector against the padding oracle
- Enter the ordinal number (1-256) of the vector that produced valid padding
- The tool reveals the intermediate value and plaintext byte
- Repeat until all bytes in all blocks are decrypted
============================================================
AES-CBC Padding Oracle Attack Helper
============================================================
Enter the ciphertext (hex, no spaces): a1b2c3d4e5f6...
Enter the IV (hex, no spaces): 00112233445566778899aabbccddeeff
Ciphertext has 2 block(s) (32 bytes)
============================================================
Attacking Block 1 of 2
============================================================
--- Attacking byte 1/16 (position 15) ---
Generated 256 attack vectors.
Enter the ordinal number [1, 256] with valid padding: 142
Intermediate byte revealed: 0x8d
Plaintext byte revealed: 0x48 ('H')
Block 1 plaintext so far (hex): 48
Block 1 plaintext so far (ASCII): H
In AES-CBC mode:
Plaintext[i] = Decrypt(Ciphertext[i]) XOR Ciphertext[i-1]
The attack exploits PKCS#7 padding validation:
- Modify the previous ciphertext block to manipulate the decrypted padding
- If the oracle indicates valid padding, we can deduce the intermediate value
- XOR the intermediate value with the original previous block to get plaintext
For each byte position, the tool:
- Creates a modified previous block with a guess value at the target position
- Sets subsequent bytes to produce the expected padding value
- Generates all 256 possible guesses (0x00 to 0xFF)
| File | Description |
|---|---|
ciphertexts.txt |
256 lines, each containing the target ciphertext block (hex) |
IVs.txt |
256 lines, each containing a modified previous block (hex) |
Use these files to batch-test against your padding oracle.
- Only use this tool on systems you own or have explicit permission to test
- Padding oracle vulnerabilities can exist in production systems — responsible disclosure is essential
- Understanding this attack helps developers build more secure systems
| Parameter | Value |
|---|---|
| Block Size | 16 bytes (AES-128) |
| Padding Scheme | PKCS#7 |
| Attack Direction | Right-to-left (byte 15 → byte 0) |
| Vectors per Byte | 256 |
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License — see the LICENSE file for details.
Built for learning cryptographic attacks and improving security awareness.