This repository contains a Python implementation of a CBC (Cipher Block Chaining) Padding Oracle Attack. The attack demonstrates how padding oracle vulnerabilities can be exploited in CBC mode encryption. This project was part of the Systems Security Course Assignment at Aarhus University.
The script performs a padding oracle attack against a web server that exposes an endpoint vulnerable to this type of attack. It can decrypt encrypted content and forge new encrypted messages that will be accepted by the server.
- Python 3.x
- Required Python packages:
pip install requests pycryptodome
Run the script from the command line with the target server's URL as an argument:
python paddingattack.py <server_url>
Example:
python paddingattack.py http://localhost:5000
- The script retrieves an authentication token from the target server
- It performs the padding oracle attack to decrypt the token
- Extracts the secret message from the decrypted content
- Creates a new encrypted message by appending " plain CBC is not secure!" to the secret
- Sends the forged encrypted message back to the server
- Automatic token retrieval and parsing
- Block-by-block decryption using padding oracle
- Custom message encryption using CBC mode
- Progress visualization during decryption
- Colored output for better readability
- Block size: 16 bytes (128 bits)
- Padding scheme: PKCS#7
- Uses XOR operations for CBC mode implementation
- Handles both encryption and decryption operations
This implementation is for educational purposes only. It demonstrates the insecurity of CBC mode when implemented with a padding oracle vulnerability. Do not use this against systems without explicit permission.
👨💻 Author: Md. Mehedi Faruk
This project is intended for educational purposes only. Use responsibly and only on systems you have permission to test.