sqlmap on Kali Linux: SQL injection testing in a lab
sqlmap on Kali Linux is an open-source tool that automates the detection and exploitation of SQL injection flaws in web applications. It sends crafted payloads, reads the responses, fingerprints the back-end database, and can enumerate databases, tables and columns. Defenders use it to prove, on a lab copy of their own app, that a suspicious parameter really is injectable before it ships. Testers use it to give a client a repeatable, documented demonstration of impact.
This post covers what sqlmap is, how to install it on Kali Linux, the legal limits that apply, a worked example against a lab VM you own, and the defences that blunt it. The install steps follow the official Kali Linux tools page for sqlmap, and the project documentation is the reference for every switch.
What sqlmap on Kali Linux is and when to use it
sqlmap is an automatic SQL injection and database takeover tool. It ships with a detection engine that supports the five classic injection techniques: boolean-based blind, time-based blind, error-based, UNION query and stacked queries. It supports over 40 database backends, from MySQL and PostgreSQL to Oracle and SQL Server.
Use it when a manual review or a scanner has flagged a parameter and you need to confirm whether the flaw is real and what it exposes. It is not a substitute for code review: it confirms exploitability, it does not find every logic flaw.
Before you reach for sqlmap, you usually map the target with Nmap and gather context with SpiderFoot. After you confirm an injection, you may inspect the same session traffic in Wireshark.
Installing it on Kali Linux
Kali Linux ships sqlmap in its default metapackage. Check first:
sqlmap --version
If it is missing, install it from Kali’s repositories:
sudo apt update
sudo apt install sqlmap
The Kali tools page lists the sqlmap and sqlmapapi binaries, with dependencies on python3 and python3-magic. Keep the system current with sudo apt upgrade so you stay on the latest stable line.
Ethical and lawful use
Only test applications you own or have written permission to test. In the UK, unauthorised access to a system or data can engage the Computer Misuse Act 1990. sqlmap prints its own legal disclaimer at the start of every run: use for attacking targets without prior mutual consent is illegal.
The practical rules: agree scope in writing, name the target, the time window and the techniques allowed, and never run data-extraction switches against production. sqlmap is a detection and impact tool; treat every finding as sensitive until it is fixed.
Worked example on a lab target
Lab target: DVWA (a deliberately vulnerable web application, the practice web app) running on a VM you own, on an isolated host-only network, security level set to Low. Nothing below touches a real system. If you still need a lab, see our guide to creating a pentesting environment with Parrot OS and Kali Linux on VirtualBox.
Confirm the app is up, then ask sqlmap to test the id parameter on the vulnerable page:
sqlmap -u "https://192.168.56.101/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit#" --cookie="PHPSESSID=YOUR_SESSION" --batch --level=1 --risk=1
What this does: -u names the target URL, --cookie passes the session you logged in with on your own lab, --batch accepts defaults, and --level=1 --risk=1 keeps the test to the least intrusive settings. Read the output to confirm whether the parameter is injectable and which DBMS sqlmap fingerprinted. Stop there for a detection check. Enumeration and dumping switches stay off unless your written scope explicitly allows them.
For a repeatable session, save the exact request to a file and replay it:
sqlmap -r request.txt -p id --batch --level=1 --risk=1
Defences and detections
sqlmap succeeds when the app concatenates user input into SQL. Fix that and the tool has nothing to find.
- Parameterised queries. Bind values, never concatenate them. OWASP’s SQL Injection Prevention Cheat Sheet makes prepared statements the primary defence.
- Least privilege. The app’s database account should hold only the rights it needs. No DBA rights, no direct access to system tables.
- Allow-list structural input. Map table names, column names and sort directions to fixed application-owned values; reject anything else.
- WAF and rate rules. Block or alert on the classic sqlmap signatures:
sqlmapin the User-Agent, stacked queries, and repeated boolean or time-based payloads on one parameter. - Log and alert. A burst of 500 errors or unusual query latency on one endpoint is a detection signal. Review query construction in code and stored procedures.
sqlmap on Kali Linux is a confirmation tool: it turns a suspicion into evidence on a lab you own, so the fix lands before a real attacker finds the same hole.







