X-WAF简单测试体验

 X-WAF

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

X-WAF是一款适用中、小企业的云WAF系统,让中、小企业也能够很是方便地拥有本身的免费云WAF。mysql

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

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

安装部署

系统版本:Centos6.5 x86_64git

一、openresty的配置github

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

二、X-WAFweb

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

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

三、配置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/;

}

四、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

五、登陆x-admin

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

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

 WAF Bypass

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

从中咱们能够看到,经过if语句进行检测,单一的程序入口,一旦知足条件就再也不进行检测。

一、利用白名单

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

从上面的检测流程能够看出,一旦知足白名单就再也不进行检测,从而绕过。咱们能够伪造X-Real-IP:8.8.8.8

二、绕过正则

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

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

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

点号(.)  匹配任意除换行符"\n"外的字符,能够尝试经过%0a来绕过正则。

 三、大小写可绕过 

 

四、其余绕过方式

如:宽字节、%特性、%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--,浏览更多精彩文章。

 

相关文章
相关标签/搜索