This repository contains a simple example of a padding oracle attack on a vulnerable API.
vulnerable_api.py: this code simulates a vulnerable API susceptible to the padding oracle attack.padding_oracle.pythis script performs a Padding Oracle Attack in the vulnerable API.
- The attacker has access to a valid payload (IV + encrypted blocks).
- The attacker can use a
requestfunction that simulates interaction with a vulnerable API. Specifically, the function returnsTrueif a given payload can be decrypted andFalseotherwise. - The encryption algorithm used by the API is vulnerable to a padding oracle attack. In this case, the API uses AES in CBC mode with PKCS7 padding.
To run the example just cd into the cloned repository and execute
python3 padding_oracle.pyI wrote this code to better understand the algorithm behind padding oracle attacks. It is not optimized, but it is useful for learning. If you want to test a padding oracle attack against an application (with permission, of course), consider using other tools like padre.