Sqlmap Tricks for Advanced SQL Injection


SUBMITTED BY: jorge110

DATE: Jan. 6, 2017, 1:42 a.m.

FORMAT: Text only

SIZE: 1.7 kB

HITS: 38071

  1. qlmap is an awesome tool that automates SQL Injection discovery and exploitation processes. I normally use it for exploitation only because I prefer manual detection in order to avoid stressing the web server or being blocked by IPS/WAF devices.
  2. Below I provide a basic overview of sqlmap and some configuration tweaks for finding trickier injection points.
  3. Basics
  4. Using sqlmap for classic SQLi is very straightforward:
  5. ./sqlmap.py -u 'http://mywebsite.com/page.php?vulnparam=hello'
  6. The target URL after the -u option includes a parameter vulnerable to SQLi (vulnparam). Sqlmap will run a series of tests and detect it very quickly. You can also explicitly tell sqlmap to only test specific parameters with the -p option. This is useful when the query contains various parameters, and you don't want sqlmap to test everyting. You can use the --data option to pass any POST parameters.
  7. To maximize successful detection and exploitation, I usually use the --headers option to pass a valid User-Agent header (from my browser for example). Finally, the --cookie option is used to specify any useful Cookie along with the queries (e.g. Session Cookie).
  8. Advanced Attack
  9. Sometimes sqlmap cannot find tricky injection points and some configuration tweaks are needed. In this example, I will use the Damn Vulnerable Web App (http://www.dvwa.co.uk/), a deliberately insecure web application used for educational purposes. It uses PHP and a MySQL database. I also customized the source code to simulate a complex injection point. Here is the source of the php file responsible for the Blind SQL Injection exercise located at /[install_dir]/dvwa/vulnerabilities/sqli_blind/source/low.php:

comments powered by Disqus