Until now, we've just considered injections in the GET requests and parameters, if you have not yet completed them then click the below links:
SQLMap Brief Introductory-
Detect & Exploit SQL Injection
Dumping The Data
Let us now look at an injection in a POST parameter and exploit the same with the SQL Map.
It will redirect to a login Portal, as below screenshot:
In the Username field, we try to insert a stray character to break the query as we did before.
Let's see what happens, when we click on Submit button.
Upon submitting the work, we get a typical MySQL error. Now, we need to check exactly which POST parameter is affected.
To view the request we will use a Firefox add-on known as Live HTTP Headers which can be easily installed from the Firefox add-on gallery.
Now, Launch the HTTP Header Live extension, and refresh the page to load the entries.
So, based on the output of Live HTTP Headers, the affected parameter is "uname".
Let's use SQLMap's --data switch to exploit this POST-based scenario.
Now, we'll enforce the parameter to check to uname and pass the POST parameters inside --data. Let's try this out in SQLMap.
Here's what you'll see:
Look at that, SQLMap exploited the same level of easiness as it did in the GET-based injections.
Another way of exploiting this is by capturing the POST request and manually specifying the parameter.
Now we've saved the request. We'll utilize the -r switch to read the HTTP request from the aforementioned file and then specify the vulnerable parameter, which in our case is uname through the -p switch.
And again! Through this technique, we achieved the same result but in a different manner.
I demonstrated this through a file because this can be used when exploiting SQL injections that are not straightforward; when the payload is SOAP (XML-based) or JSON then we can use the same -r switch and feed the request to SQL Map through a file and exploit the injection.
.png)
.png)
.png)
.png)
.png)
.png)
.png)