Lab: SQL injection vulnerability in WHERE clause allowing retrieval of hidden data
This lab contains a SQL injection vulnerability in the product category filter. When the user selects a category, the application carries out a SQL query like the following
SELECT * FROM products WHERE category = 'Gifts' AND released = 1
To solve the lab, perform a SQL injection attack that causes the application to display details of all products in any category, both released and unreleased.
This is a picture of a shopping mall.
Let's click on the Pets category.
If category=Pets, 3 pictures are displayed.
But if category=Pets'--, 4 pictures are displayed.
--(주석)으로 인해 released = 1 부분이 수행되지 않으므로 출시되지 않은 Pets의 카테고리도 출력된다.
하지만 우리는 모든 제품을 다 출력해야하기 때문에 아래와 같이 입력하면 문제를 해결할 수 있다.
category=Pets' or 1=1--
카테고리가 Pets이거나 1=1인 참인경우를 출력하니깐 모든 경우를 출력한다.
해당 페이로드를 입력해보자!!
문제를 해결하였다.