Repository navigation
sqlmap SQL Injection Assessment and Defensive Validation
Upstream manual reviewed: 2026-11-21. No live target was tested.
Caution
Authorized use only. sqlmap can send many requests, alter application state or expose database contents. This guide limits exercises to a synthetic local training application and detection-focused use. Do not retrieve third-party data or attempt OS-level access. See Legal Notice.
sqlmap is an automated SQL injection (SQLi) testing framework. Its input is an HTTP request or URL containing candidate parameters, and it probes whether database-related input handling is unsafe. Automated hits require manual verification and context. A scanner result does not automatically prove data compromise, privileges or exploitability.
Use a deliberately vulnerable local training environment with synthetic records, a disposable database, no real users, no outbound access and reversible VM/container state. Turn on HTTP access logs, application exception logs and database statement/audit logs where available. Confirm a signed testing scope, even within organizational networks.
The diagram shows the intended test boundary and the evidence sources to compare:
flowchart LR
subgraph lab["Disposable isolated lab โ no outbound route"]
tester["Tester / sqlmap<br/>bounded local probe"]
app["Intentionally vulnerable<br/>training app"]
db["Disposable database<br/>synthetic records"]
httpLogs["HTTP and application logs"]
dbLogs["Database audit logs"]
evidence["Evidence review"]
tester -->|"loopback only"| app
app <--> db
app --> httpLogs
db --> dbLogs
httpLogs --> evidence
dbLogs --> evidence
end
Install via the official GitHub repository or trusted platform package. If using the upstream checkout, inspect dependencies and run:
python3 sqlmap.py --version
python3 sqlmap.py -hThe executable may be called sqlmap on a packaged installation; adjust examples accordingly.
| Step | Action | Expected Evidence |
|---|---|---|
| Baseline | Inspect an application request through a proxy | Method, path, parameter, normal response |
| Isolate | Choose a single lab query parameter | Clear test scope and synthetic record |
| Probe | Use the lowest reasonable test settings | Request trace, affected parameter, tool uncertainty |
| Confirm | Compare request/response against application & DB logs | Reproducible variation without sensitive extraction |
| Repair | Use parameterized queries and least privilege | Changed query construction and test coverage |
| Retest | Repeat a bounded equivalent request | Prior behavior no longer reproducible |
# Local training service only; /items?id=1 is an illustrative fixture.
# It must be provided by your own intentionally vulnerable lab.
sqlmap -u "http://127.0.0.1:8000/items?id=1" -p id \
--batch --level=1 --risk=1 --threads=1 --delay=0.5The example remains an active SQLi probe. Review request logs and stop if the app resets, errors unexpectedly or changes data. Low risk/level settings reduce the test set; they do not guarantee harmlessness.
For an application that uses POST, headers or cookies, save a sanitized HTTP request captured from a local lab into lab-request.txt, removing production tokens and personally identifiable information. Then consult sqlmap -hh and the official -r option documentation. Never commit actual cookies, session tokens or query dumps.
Do not enable database dumping, schema exfiltration, filesystem access, shell functionality or large concurrency as part of routine discovery. Consider dynamic pages, CSRF tokens, WAF interference, caching, redirects and timing-based probes when interpreting a result.
Use bound parameters/prepared statements for data values, allow-list identifiers that cannot be parameterized, restrict database privileges, avoid dynamic SQL concatenation and validate authorization separately. A WAF can reduce exposure but does not repair unsafe query construction.
# The parameter is bound as data, not appended to SQL source.
cursor.execute("SELECT name FROM items WHERE id = ?", (item_id,))For each finding, capture the vulnerable endpoint, parameter, request/response evidence (sanitized), environment, database error class, impact hypothesis, fix and reproducible retest result.
HTTP anomaly bursts, atypical SQL error patterns, DB audit exceptions and unexpected spikes in query latency may justify investigation. SQLmap can use custom headers and randomization, so a single User-Agent signature is unreliable. Prefer request+identity+DB correlation and alert testing against benign fixtures.
- Web App Security Methodology โ manual-first assessment workflow
- OWASP ASVS/WSTG & Nuclei โ verification & evidence requirements
- OWASP SQL Injection Prevention Cheat Sheet
- Official sqlmap Manual & Project
Web Application Security Index | Start Here | Legal Notice
๐ Source: WebAppSecurity/sqlmap-guide.md | โ๏ธ Suggest an edit | โฌ
๏ธ Back to Web App Security
- ๐บ๏ธ Browse by Topic
- ๐ All Repository Files
- ๐งญ Learning Paths
- ๐ Master Guide
- ๐ค Glossary
- โ๏ธ Legal & Disclaimer
๐ Foundations & Learning
๐ก๏ธ Defense & Investigations
- Incident Response
- Open Source Intelligence (OSINT)
- Reverse Engineering
- Operations Security (OPSEC)
- Compliance
โ๏ธ Platforms & Infrastructure
๐ก Hardware, Wireless & Field Projects
- PNWC Cyberdeck
- Hardware Testing
- Hardware Hacking
- Software-Defined Radio
- Wardriving
- uConsole
- Space Security
๐งฐ Assessment & Field Reference
๐ฆ Downloads & Project Resources
๐๏ธ Additional Topics