最近才關注到的一款雲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
先熟悉一下檢測流程,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
%特性
防護規則還有待增強,繞過的方式確定還有很多,這邊只測試了一下IIS+ASP/ASPX+MSSQL的環境,Apache+php+mysql有待測試,有空再來試試吧。
x-waf 官網的介紹仍是感受很不錯的,使用指南也很清晰,總體部署體驗還不錯,X-admin的web界面很簡潔,配置起來仍是挺方便的。
關於我:一個網絡安全愛好者,致力於分享原創高質量乾貨,歡迎關注個人我的微信公衆號:Bypass--,瀏覽更多精彩文章。