Step by step basic SQL Injection
We saw in Chapter 4, Finding Vulnerabilities, how to detect an SQL Injection. In this recipe, we will exploit an injection and use it to extract information from the database.
How to do it...
We already know that DVWA is vulnerable to SQL Injection, so let's login using OWASP-Mantra and go to
http://192.168.56.102/dvwa/vulnerabilities/sqli/
.After detecting that an SQLi exists, the next step is to get to know the query, more precisely, the number of columns its result has. Enter any number in the ID box and click Submit.
Now, open the HackBar (hit F9) and click Load URL. The URL in the address bar should now appear in the HackBar.
In the HackBar, we replace the value of the
id
parameter with 1' order by 1 -- ' and click on Execute.We keep increasing the number after
order by
and executing the requests until we get an error. In this example, it happens when ordering by 3.Now, we know that the query has two columns. Let's try if we can use the UNION statement to...