X-WAF简单测试体验

 X-WAF

最近才关注到的一款云WAF,花了一些时间搭建了一个环境,并做了一些测试,感觉比较适合新手来练习WAF Bypass。

X-WAF是一款适用中、小企业的云WAF系统,让中、小企业也可以非常方便地拥有自己的免费云WAF。

官网:https://waf.xsec.io/

源码:https://github.com/xsec-lab

安装部署

系统版本:Centos6.5 x86_64

1、openresty的配置

yum -y install pcre pcre-devel
wget https://openresty.org/download/openresty-1.9.15.1.tar.gz
tar -zxvf openresty-1.9.15.1.tar.gz 
cd openresty-1.9.15.1
./configure 
gmake && gmake install

2、X-WAF

将x-waf的代码目录放置到openresty的/usr/local/openresty/nginx/conf目录下,然后在openresty的conf的目录下新建vhosts目录

cd /usr/local/openresty/nginx/conf/
git clone https://github.com/xsec-lab/x-waf
mkdir -p /usr/local/openresty/nginx/conf/vhosts

3、配置nginx

将x-waf/nginx_conf/nginx.conf 复制到nginx/conf目录下进行覆盖。

cp /usr/local/openresty/nginx/conf/x-waf/nginx_conf/nginx.conf  /usr/local/openresty/nginx/conf/nginx.conf
/usr/local/openresty/nginx/sbin/nginx  -t
nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
/usr/local/openresty/nginx/sbin/nginx 

设置反向代理: 

location /test/{

  proxy_pass http://192.168.8.158/;

}

4、x-waf-admin安装

直接从github中下载对应操作系统的二进制版本 https://github.com/xsec-lab/x-waf-admin/releases,上传到tmp目录

tar -zxvf x-waf-admin0.1-linux-amd64.tar.gz
cd x-waf-admin
cd conf
vi app.ini  //配置mysql账号密码
cd ..
./server

5、登录x-admin

管理地址为:http://ip:5000/login/

管理后台的默认的账户及口令分别为:admin,x@xsec.io

 WAF Bypass

先熟悉一下检测流程,x-waf目录的waf.lua,程序入口:

从中我们可以看到,通过if语句进行检测,单一的程序入口,一旦满足条件就不再进行检测。

1、利用白名单

在x-waf/rules中,默认存在着白名单和黑名单,默认都有ip:8.8.8.8

从上面的检测流程可以看出,一旦满足白名单就不再进行检测,从而绕过。我们可以伪造X-Real-IP:8.8.8.8

2、绕过正则

  rule中比较关键的两个正则如下:

(?:(union(.*?)select))
select.+(from|limit)

,.*? 是一个固定的搭配,.和*代表可以匹配任意无限多个字符,加上?表示使用非贪婪模式进行匹配,也就是会尽可能短地做匹配

点号(.)  匹配任意除换行符" "外的字符,可以尝试通过%0a来绕过正则。

 3、大小写可绕过 

4、其他绕过方式

如:宽字节、%特性、%u特性(asp/aspx+IIS)等

宽字节绕过:

POST:id=1 uю%69яю select  1,null,system_user цRяэ admin

 %特性

 END

   防御规则还有待加强,绕过的方式肯定还有不少,这边只测试了一下IIS+ASP/ASPX+MSSQL的环境,Apache+php+mysql有待测试,有空再来试试吧。

  x-waf 官网的介绍还是感觉很不错的,使用指南也很清晰,整体部署体验还不错,X-admin的web界面很简洁,配置起来还是挺方便的。

 

关于我:一个网络安全爱好者,致力于分享原创高质量干货,欢迎关注我的个人微信公众号:Bypass--,浏览更多精彩文章。

 

 

原文地址:https://www.cnblogs.com/xiaozi/p/7426681.html