SQLmap tamper script for bypassing WAF
Tamper injection data
Option: –tamper
sqlmap itself does no obfuscation of the payload sent, except for strings between single quotes replaced by their CHAR()
-alike representation. More information about programming you can find on Thoughtsoncloud.
This option can be very useful and powerful in situations where there is a weak input validation mechanism between you and the back-end database management system. This mechanism usually is a self-developed input validation routine called by the application source code, an expensive enterprise-grade IPS appliance or a web application firewall (WAF). All buzzwords to define the same concept, implemented in a different way and costing lots of money, usually.
To take advantage of this option, provide sqlmap with a comma-separated list of tamper scripts and this will process the payload and return it transformed. You can define your own tamper scripts, use sqlmap ones from the tamper/
folder or edit them as long as you concatenate them comma-separated as a value of the option --tamper
(e.g. --tamper="between,randomcase"
).
Here are the list tamper injection data
- apostrophemask.py replace single quote character in UTF-8-byte characters
- apostrophenullencode.py replace single-quote character with an illegal double-byte Unicode characters
- appendnullbyte.py, add a null character at the end of payload encoding
- base64encode.py use Base64 encoding for a given payload all characters
- between.py, “the BETWEEN the AND # #” is replaced with “NOT BETWEEN 0 AND #” replace greater-than sign “>” equal sign “=”
- bluecoat.py After the SQL statements replace spaces with valid random whitespace, followed by “the LIKE” Alternatively equal sign “=”
- chardoubleencode.py use double URL encoding for a given payload all characters (not handle characters already encoded)
- charencode.py use URL encoding for a given payload all characters (not handle characters already encoded)
- charunicodeencode.py use Unicode URL encoding for a given payload of non-coded character (the character does not handle already encoded)
- concat2concatws.py with Examples “CONCAT_WS (MID (CHAR (0 ), 0, 0), A, B)” replacement image “CONCAT (A, B)” is
- equaltolike.py with “the LIKE” operator replace all equal sign “=”
- greatest.py Alternatively greater than “>” use “GREATEST” function
- halfversionedmorekeywords.py add MySQL comments before each keyword
- ifnull2ifisnull.py with “IF (ISNULL (A), B, A)” replacement image “IFNULL (A, B)” Examples
- lowercase.py replace the value of each keyword character lowercase
- modsecurityversioned.py surrounded by complete query with a comment
- modsecurityzeroversioned.py comments with zero digits of which is surrounded by a full inquiry
- multiplespaces.py add more spaces around SQL keywords
- nonrecursivereplacement.py replace the predefined keywords using SQL representations, a filter suitable for
- overlongutf8.py conversion to all characters in a given payload among
- percentage.py add a percent sign before each character
- randomcase.py random character case conversion for each keyword
- randomcomments.py insert random comments to SQL keywords
- securesphere.py add the string through a special configuration
- sp_password.py Appends ‘sp_password’ to the end of the payload for automatic obfuscation from DBMS logs
- space2comment.py replace spaces with “/ ** /”
- space2dash.py dash comment character “-” followed by a linefeed a random string of characters and replace the space character
- space2hash.py pounds comment character “#” followed by a linefeed a random string of characters and replace the space character
- space2morehash.py pounds comment character “#” followed by a linefeed a random string of characters and replace the space character
- space2mssqlblank.py replace spaces with a set of valid candidate among the set of random character whitespace
- space2mssqlhash.py pounds comment symbol “#” followed by a space character to replace newline
- space2mysqlblank.py replace spaces with a set of valid candidate among the set of random character whitespace
- space2mysqldash.py dash comment character “-” followed by a linefeed character replace spaces
- space2plus.py a plus “+” with spaces
- space2randomblank.py replace spaces with a set of valid candidate among the set of random character whitespace
- unionalltounion.py Replaces UNION ALL SELECT with UNION SELECT
- unmagicquotes.py use a combination of multi-byte% bf% 27 and the end of general note replaced with spaces
- varnish.py add an HTTP header “X-originating-IP” to bypass WAF
- versionedkeywords.py surrounding each non-comment function key with MySQL
- versionedmorekeywords.py surrounded by each keyword with a MySQL Notes
Usage
MSSQL:
MySQL:
General Tamper testing:
Example:
Reference:
- https://github.com/sqlmapproject/sqlmap/tree/master/tamper
- https://forum.bugcrowd.com/t/sqlmap-tamper-scripts-sql-injection-and-waf-bypass/423