sqlmap tamper脚本备忘录与tamper脚本编写

查看sqlmap全部脚本

$ python sqlmap.py --list-tampers
[*] starting @ 12:30:47 /2019-10-14/

[12:30:47] [INFO] listing available tamper scripts

* apostrophemask.py - Replaces apostrophe character (') with its UTF-8 full width counterpart (e.g. ' -> %EF%BC%87)
* apostrophenullencode.py - Replaces apostrophe character (') with its illegal double unicode counterpart (e.g. ' -> %00%27)
* appendnullbyte.py - Appends (Access) NULL byte character (%00) at the end of payload
* base64encode.py - Base64-encodes all characters in a given payload
* between.py - Replaces greater than operator ('>') with 'NOT BETWEEN 0 AND #' and equals operator ('=') with 'BETWEEN # AND #'
* bluecoat.py - Replaces space character after SQL statement with a valid random blank character. Afterwards replace character '=' with operator LIKE
* chardoubleencode.py - Double URL-encodes all characters in a given payload (not processing already encoded) (e.g. SELECT -> %2553%2545%254C%2545%2543%2554)
* charencode.py - URL-encodes all characters in a given payload (not processing already encoded) (e.g. SELECT -> %53%45%4C%45%43%54)
* charunicodeencode.py - Unicode-URL-encodes all characters in a given payload (not processing already encoded) (e.g. SELECT -> %u0053%u0045%u004C%u0045%u0043%u0054)
* charunicodeescape.py - Unicode-escapes non-encoded characters in a given payload (not processing already encoded) (e.g. SELECT -> \u0053\u0045\u004C\u0045\u0043\u0054)
* commalesslimit.py - Replaces (MySQL) instances like 'LIMIT M, N' with 'LIMIT N OFFSET M' counterpart
* commalessmid.py - Replaces (MySQL) instances like 'MID(A, B, C)' with 'MID(A FROM B FOR C)' counterpart
* commentbeforeparentheses.py - Prepends (inline) comment before parentheses (e.g. ( -> /**/()
* concat2concatws.py - Replaces (MySQL) instances like 'CONCAT(A, B)' with 'CONCAT_WS(MID(CHAR(0), 0, 0), A, B)' counterpart
* equaltolike.py - Replaces all occurrences of operator equal ('=') with 'LIKE' counterpart
* escapequotes.py - Slash escape single and double quotes (e.g. ' -> \')
* greatest.py - Replaces greater than operator ('>') with 'GREATEST' counterpart
* halfversionedmorekeywords.py - Adds (MySQL) versioned comment before each keyword
* hex2char.py - Replaces each (MySQL) 0x<hex> encoded string with equivalent CONCAT(CHAR(),...) counterpart
* htmlencode.py - HTML encode (using code points) all non-alphanumeric characters (e.g. ' -> &#39;)
* ifnull2casewhenisnull.py - Replaces instances like 'IFNULL(A, B)' with 'CASE WHEN ISNULL(A) THEN (B) ELSE (A) END' counterpart
* ifnull2ifisnull.py - Replaces instances like 'IFNULL(A, B)' with 'IF(ISNULL(A), B, A)' counterpart
* informationschemacomment.py - Add an inline comment (/**/) to the end of all occurrences of (MySQL) "information_schema" identifier
* least.py - Replaces greater than operator ('>') with 'LEAST' counterpart
* lowercase.py - Replaces each keyword character with lower case value (e.g. SELECT -> select)
* luanginx.py - LUA-Nginx WAFs Bypass (e.g. Cloudflare)
* modsecurityversioned.py - Embraces complete query with (MySQL) versioned comment
* modsecurityzeroversioned.py - Embraces complete query with (MySQL) zero-versioned comment
* multiplespaces.py - Adds multiple spaces (' ') around SQL keywords
* overlongutf8.py - Converts all (non-alphanum) characters in a given payload to overlong UTF8 (not processing already encoded) (e.g. ' -> %C0%A7)
* overlongutf8more.py - Converts all characters in a given payload to overlong UTF8 (not processing already encoded) (e.g. SELECT -> %C1%93%C1%85%C1%8C%C1%85%C1%83%C1%94)
* percentage.py - Adds a percentage sign ('%') infront of each character (e.g. SELECT -> %S%E%L%E%C%T)
* plus2concat.py - Replaces plus operator ('+') with (MsSQL) function CONCAT() counterpart
* plus2fnconcat.py - Replaces plus operator ('+') with (MsSQL) ODBC function {fn CONCAT()} counterpart
* randomcase.py - Replaces each keyword character with random case value (e.g. SELECT -> SEleCt)
* randomcomments.py - Add random inline comments inside SQL keywords (e.g. SELECT -> S/**/E/**/LECT)
* sp_password.py - Appends (MsSQL) function 'sp_password' to the end of the payload for automatic obfuscation from DBMS logs
* space2comment.py - Replaces space character (' ') with comments '/**/'
* space2dash.py - Replaces space character (' ') with a dash comment ('--') followed by a random string and a new line ('\n')
* space2hash.py - Replaces (MySQL) instances of space character (' ') with a pound character ('#') followed by a random string and a new line ('\n')
* space2morecomment.py - Replaces (MySQL) instances of space character (' ') with comments '/**_**/'
* space2morehash.py - Replaces (MySQL) instances of space character (' ') with a pound character ('#') followed by a random string and a new line ('\n')
* space2mssqlblank.py - Replaces (MsSQL) instances of space character (' ') with a random blank character from a valid set of alternate characters
* space2mssqlhash.py - Replaces space character (' ') with a pound character ('#') followed by a new line ('\n')
* space2mysqlblank.py - Replaces (MySQL) instances of space character (' ') with a random blank character from a valid set of alternate characters
* space2mysqldash.py - Replaces space character (' ') with a dash comment ('--') followed by a new line ('\n')
* space2plus.py - Replaces space character (' ') with plus ('+')
* space2randomblank.py - Replaces space character (' ') with a random blank character from a valid set of alternate characters
* substring2leftright.py - Replaces PostgreSQL SUBSTRING with LEFT and RIGHT
* symboliclogical.py - Replaces AND and OR logical operators with their symbolic counterparts (&& and ||)
* unionalltounion.py - Replaces instances of UNION ALL SELECT with UNION SELECT counterpart
* unmagicquotes.py - Replaces quote character (') with a multi-byte combo %BF%27 together with generic comment at the end (to make it work)
* uppercase.py - Replaces each keyword character with upper case value (e.g. select -> SELECT)
* varnish.py - Appends a HTTP header 'X-originating-IP' to bypass Varnish Firewall
* versionedkeywords.py - Encloses each non-function keyword with (MySQL) versioned comment
* versionedmorekeywords.py - Encloses each keyword with (MySQL) versioned comment
* xforwardedfor.py - Append a fake HTTP header 'X-Forwarded-For' (and alike)

[*] ending @ 12:30:48 /2019-10-14/

使用方法

--tamper=TAMPER

2019.9更新后翻译

* apostrophemask.py-用其UTF-8全角字符替换撇号(')(例如'->%EF%BC%87)
* apostrophenullencode.py-用非法的双unicode替换撇号(')(例如'->%00%27)
* appendnullbyte.py-在有效载荷的末尾附加(访问)NULL字节字符(%00)
* base64encode.py-Base64对给定有效载荷中的所有字符进行编码
* between.py- 替换较大比运算符('>')带有'NOT BETWEEN 0 AND#',等于运算符('=')与'BETWEEN#AND#'
* bluecoat.py-用有效的随机空白字符替换SQL语句后的空格字符。然后用运算符LIKE替换字符'='
* chardoubleencode.py-双重URL编码给定有效负载中的所有字符(未处理已编码)(例如SELECT->%2553%2545%254C%2545%2543%2554)
* charencode.py-URL编码中的所有字符给定的有效载荷(不处理已经编码的)(例如SELECT->%53%45%4C%45%43%54)
* charunicodeencode.py-Unicode-URL编码给定的有效载荷中的所有字符(不处理已经编码的)(例如SELECT->%u0053%u0045%u004C%u0045%u0043%u0054)
* charunicodeescape.py-Unicode转义给定有效负载中的未编码字符(未处理已编码的字符)(例如SELECT-> \ u0053 \ u0045 \ u004C \ u0045 \ u0043 \ u0054)
* commalesslimit.py-'LIMIT N OFFSET M'替换(MySQL)实例,例如'LIMIT M,N'
* commalessmid.py-'MID(A FROM B FOR C)'替换(MySQL)实例,例如'MID(A,B,C)'
* commentbeforeparentheses.py-在括号前加(内联)注释(例如((-> / ** /()
* concat2concatws.py-'CONCAT_WS(MID(CHAR(0),0,0),A,B)' 等价物(相当于)替换(MySQL)实例,例如'CONCAT(A,B)'* equaltolike.py- 将所有出现的等于('=')运算符替换为'LIKE'
* escapequotes.py-斜杠转义单引号和双引号(例如'-> \'* great.py- 替换大于运算符('>' )和'GREATEST'对应
* Halfversionedmorekeywords.py-在每个关键字
* hex2char.py-替换每个(MySQL)0x等效的CONCAT(CHAR(),...)编码字符串
* htmlencode.py-HTML编码(使用代码点)所有非字母数字字符(例如'->'* ifnull2casewhenisnull.py-替换'IFNULL( A,B)''CASE WHEN ISNULL(A)THEN(B)ELSE(A)END'对应
* ifnull2ifisnull.py-'IF(ISNULL(A),B)替换'IFNULL(A,B)'之类的实例,A)'对应
* informationschemacomment.py-在所有出现的(MySQL)“ information_schema”标识符的末尾添加一个内联注释(/ ** /* least.py 用'LEAST'对应替换大于运算符('>'* lowercase.py-用小写值替换每个关键字字符(例如SELECT->选择)
* luanginx.py-LUA-Nginx WAF绕过(例如Cloudflare)
* modsecurityversioned.py-包含带有(MySQL)版本注释的完整查询
* modsecurityzeroversioned.py-包含带有(MySQL)零版本注释的完整查询
* multiplespaces.py-在SQL关键字周围添加多个空格(''* overlongutf8.py-将给定有效载荷中的所有(非字母数字)字符转换为超长UTF8(未处理已编码)(例如'->%C0%A7)
* overlongutf8more.py-将给定有效载荷中的所有字符转换为超长UTF8(尚未处理编码)(例如SELECT->%C1%93%C1%85%C1%8C%C1%85%C1%83%C1%94)
* percent.py-在每个字符前面添加一个百分号('') (例如SELECT->%S%E%L%E%C%T)
* plus2concat.py-替换加号运算符('+')与(MsSQL)函数CONCAT()对应
* plus2fnconcat.py-用(MsSQL)ODBC函数{fn CONCAT()}替换加号('+')对应项
* randomcase.py-用随机大小写值替换每个关键字字符(例如SELECT-> SEleCt)
* randomcomments.py -在SQL关键字内添加随机内联注释(例如SELECT-> S / ** / E / ** / LECT)
* sp_password.py-将(MsSQL)函数'sp_password'附加到有效负载的末尾,以便从DBMS日志中自动进行混淆
* space2comment.py-用注释'/ ** /' 替换空格字符('')
* space2dash.py-用短划线注释('-')替换空格字符(''),后跟一个随机字符串和一个新的行('\ n')
* space2hash.py-用井字符('')替换(MySQL)空格字符('')实例,后跟随机字符串和换行('\ n')
* space2morecomment.py-替换(MySQL)带注释'/ ** _ ** /' 的空格字符('')实例
* space2morehash.py-用井号('')后面跟一个随机字符串替换(MySQL)空格字符('')实例和新行('\ n')
* space2mssqlblank.py-用有效的替代字符集中的随机空白字符替换空间字符('')的(MsSQL)实例
* space2mssqlhash.py-替换空间字符('' )和井号(''),后接换行('\ n')
* space2mysqlblank.py-用有效替代字符集中的随机空白字符替换(MySQL)空格字符('')实例
* space2mysqldash.py-用破折号('-')替换空格字符('') )后跟换行('\ n')
* space2plus.py-用加号('+')替换空格字符('')
* space2randomblank.py-用空格中的随机空白字符替换空格字符('')有效的替代字符集
* substring2leftright.py-用LEFT和RIGHT替换PostgreSQL SUBSTRING
* symbolicologic.py-用其符号对应物(&&和||)替换AND和OR逻辑运算符
* unionalltounion.py-用UNION SELECT对应项替换UNION ALL SELECT的实例
* unmagicquotes.py-用多字节组合%BF%27替换引号字符('),并在末尾添加通用注释(以使其起作用)
* uppercase.py-用大写值替换每个关键字字符(例如select -> SELECT* varnish.py-附加HTTP标头'X-originating-IP'以绕过Varnish防火墙
* versionedkeywords.py-用(MySQL)版本注释将每个非功能性关键字括起来
* versionedmorekeywords.py-将每个关键字包含(MySQL)版本注释
* xforwardedfor.py-附加伪造的HTTP标头'X-Forwarded-For'

tamper脚本编写

拿第一个脚本apostrophemask来说

from lib.core.enums import PRIORITY 
 
__priority__ = PRIORITY.LOWEST  # 优先级设置
 
def dependencies():  # 当前脚本适用和不适用的情况,一般pass
    pass
 
def tamper(payload, **kwargs):  # tamper函数为自定义你的payload
    """
    Replaces apostrophe character (') with its UTF-8 full width counterpart (e.g. ' -> %EF%BC%87)
 
    References:
        * http://www.utf8-chartable.de/unicode-utf8-table.pl?start=65280&number=128
        * http://lukasz.pilorz.net/testy/unicode_conversion/
        * http://sla.ckers.org/forum/read.php?13,11562,11850
        * http://lukasz.pilorz.net/testy/full_width_utf/index.phps
 
    >>> tamper("1 AND '1'='1")
    '1 AND %EF%BC%871%EF%BC%87=%EF%BC%871'
    """
 
    return payload.replace('\'', "%EF%BC%87") if payload else payload

该脚本将 ’ 全部替换为%EF%BC%87最后返回payload

return payload.replace('\'', "%EF%BC%87") if payload else payload

具体测试情况可以添加你自己的payload,比如绕过waf,参数测试修改

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

USG_f4d

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值