08 - SQL injection UNION attack, finding a column containing text
The lab will provide a random value that you need to make appear within the query results. To solve the lab, perform a SQL injection UNION attack that returns an additional row containing the value provided. This technique helps you determine which columns are compatible with string data.
Given : Injectin point (Product category)
Find : Number of coumns , Column compatible with string
End Goal : Print the given string (ppLAen) in addition row using sqli
As we know that injection point it product category filter , so click on any category and intercept the request in burp. Now we have to get the number of columns,If we use 2 null values then it gives 500 Internal Server Error :
After using 3 null values it gives 200 OK :
That means there are 3 columns in the table.
Now we have to determine the position of the columns that compatible with strings. To find the columns we can replace each null value one by one with any string untill we got 200OK. Possible query would be - s'+UNION+SELECT+NULL,NULL,'ppLAen'--
It gives 500 Internal Server Error , that means the position of the column that is compatible with is different.
Now change the position of the string. Possible injectable query would be - s'+UNION+SELECT+NULL,'ppLAen',NULL--
It gives 200 Ok , that means 2nd column is compatible with string data type , the above query would give the string which is used on the position as output.
Lab solved :