WAF自動(dòng)化暴破(繞過(guò))腳本xwaf
xwaf
xwaf是一個(gè)python寫(xiě)的waf自動(dòng)繞過(guò)工具,上一個(gè)版本是bypass_waf,xwaf相比bypass_waf更智能,可無(wú)人干預(yù),自動(dòng)暴破waf
Disclaimer
- [!] legal disclaimer: Usage of 3xp10it.py and web.py for attacking targets without prior mutual consent is
- illegal.It is the end user's responsibility to obey all applicable local, state and federal laws.Developers
- assume no liability and are not responsible for any misuse or damage caused by this program.
Requirement
- python3
- pip3
- works on linux(test on ubuntu and kali2.0,others not test)
- python3安裝可參考如下步驟:
- apt-get install python3
- 或:
- wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
- tar xJf Python-3.5.2.tar.xz
- cd Python-3.5.2
- ./configure --prefix=/opt/python3
- make && make install
- ln -s /opt/python3/bin/python3.5 /usr/local/bin/python3
- pip3安裝:
- apt-get install -y python3-pip
- kali linux2安裝pip3可參考如下步驟:
- echo "deb-src http://http.kali.org/kali kali main non-free contrib" >> /etc/apt/sources.list
- echo "deb-src http://security.kali.org/kali-security kali/updates main contrib non-free" >> /etc/apt/sources.list
- apt-get update
- apt-get install python3-pip
Usage
- eg:
- python3 xwaf.py -u "http://www.baidu.com/1.php?id=1"
- python3 xwaf.py -u "http://www.baidu.com/1.php" --data="postdata" -p xxx
- python3 xwaf.py -r /tmp/headerfile -p xxx --level 5
Attention
1.xwaf支持除-m/-l外的所有sqlmap參數(shù),用法和sqlmap一樣即可,-m/-l為批量功能,暫不支持,如果需要批量,請(qǐng)自行code實(shí)現(xiàn)
2.由于xwaf已經(jīng)有比較好的參數(shù)方案,一般情況下盡量少用參數(shù),如果有必須要用的參數(shù)除外[如--data/-p/-r等參數(shù)]
3.普通get類(lèi)型注入點(diǎn),這樣用即可:
python3 xwaf.py -u "http://www.baidu.com/1.php?id=1&page=2" -p id
4.人工輸入的參數(shù)的優(yōu)先級(jí)大于xwaf自帶的參數(shù)方案
5.關(guān)于--tamper參數(shù)的使用:
xwaf的主要功能是排列組合使用所有可能的tamper組合來(lái)爆破waf,如果人為使用了--tamper參數(shù),xwaf將在人為設(shè)置的已有
tamper基礎(chǔ)上再排列組合,eg.人為使用的命令為:
python3 xwaf.py -u "http://www.baidu.com/1.php?id=1" --tamper=space2comment
那么xwaf使用的tamper方案中的每個(gè)都會(huì)有space2comment
6.關(guān)于代理的使用:
a)xwaf默認(rèn)不用代理,如果使用代理需要在xwaf運(yùn)行后選擇y|Y
b)使用的代理來(lái)源于程序自動(dòng)收集的網(wǎng)上的代理
c)使用代理有防封的優(yōu)點(diǎn),但網(wǎng)絡(luò)連接速度不一定能保證
7.need python3
代碼流程圖
以[127.0.0.1/1.php?id=1為例]
1.start
2.檢測(cè)系統(tǒng)/root/.sqlmap/output/127.0.0.1/log文件是否存在
3.獲取log文件:
如果不存在log文件則調(diào)用get_log_file_need_tamper函數(shù),執(zhí)行完這個(gè)函數(shù)后獲得log文件,也即成功檢測(cè)出目標(biāo)
url有sqli注入漏洞,如果執(zhí)行完get_log_file_need_tamper函數(shù)沒(méi)有獲得log文件則認(rèn)為該url沒(méi)有sqli漏洞
4.獲取db_type[數(shù)據(jù)庫(kù)類(lèi)型]
調(diào)用get_db_type_need_tamper函數(shù),用于后面的tamper排列組合時(shí),只將目標(biāo)url對(duì)應(yīng)的數(shù)據(jù)庫(kù)類(lèi)型的tamper用于
該目標(biāo)在sql注入時(shí)tamper的選擇后的組合
5.獲取sqli_type[注入方法]
調(diào)用get_good_sqli_type_need_tamper函數(shù),sql注入方法中一共有U|S|E+B|Q|T 6種注入方法,后3種查詢(xún)效率低,
首先在log文件中查找是否有U|S|E這3種高效方法中的任意一種,如果有略過(guò)這一步,否則執(zhí)行
get_good_sqli_type_need_tamper函數(shù),執(zhí)行該函數(shù)將嘗試獲得一種以上的高效注入方法
6.獲取current-db[當(dāng)前數(shù)據(jù)庫(kù)名]
如果上面獲得了高效注入方法,則先用高效注入方法獲得current-db,如果沒(méi)有則用B|Q|T方法嘗試獲得
current-db,用來(lái)嘗試獲得current-db的函數(shù)是get_db_name_need_tamper
7.獲取table[當(dāng)前數(shù)據(jù)庫(kù)的表名]
如果上面獲得了高效注入方法,則先用高效注入方法獲得table,如果沒(méi)有則用B|Q|T方法嘗試獲得table,嘗試獲得
table的函數(shù)是get_table_name_need_tamper
8.獲取column[當(dāng)前數(shù)據(jù)庫(kù)的***個(gè)表的所有列名]
如果上面獲得了高效注入方法,則先用高效注入方法獲得column,如果沒(méi)有則用B|Q|T方法獲得column,嘗試獲得
column的函數(shù)是get_column_name_need_tamper
9.獲取entries[column對(duì)應(yīng)的真實(shí)數(shù)據(jù)]
調(diào)用get_entries_need_tamper函數(shù),執(zhí)行完get_entries_need_tamper函數(shù)后,waf成功繞過(guò),從上面的步驟一直到
這個(gè)步驟,逐步獲得***繞過(guò)waf的腳本組合
About
1.xwaf支持記憶,運(yùn)行中斷后下次繼續(xù)運(yùn)行時(shí)會(huì)在中斷時(shí)的***一個(gè)命令附近繼續(xù)跑,不會(huì)重新經(jīng)歷上面的所有函數(shù)的處理
2.xwaf支持sqlmap除-m/-l外的所有參數(shù)用法
3.各個(gè)get_xxx_need_tamper函數(shù)的處理采用針對(duì)當(dāng)前url的數(shù)據(jù)庫(kù)類(lèi)型(eg.MySQL)的所有過(guò)waf的腳本
(在sqlmap的tamper目錄中)的排列組合的結(jié)果與--hex或--no-cast選項(xiàng)進(jìn)行暴力破解如果--hex起作用了則不再使用
--no-cast嘗試,--no-cast起作用了也不再用--hex嘗試
4.xwaf運(yùn)行完后將在/root/.sqlmap/output/127.0.0.1目錄下的ini文件中看到相關(guān)信息,bypassed_command是成功暴破
waf的sqlmap語(yǔ)句
5.在tamper組合中,先用到的tamper會(huì)加入到上面的ini文件中,在以后的每個(gè)tamper組合中,綜合已經(jīng)得到的有用的
tamper再組合,在上面的ini文件中的tamper_list即為不斷完善的tamper組合
6.支持自動(dòng)更新升級(jí),當(dāng)前版本為1.1
Changelog
[2017-02-13]
更新支持代替sqlmap跑普通沒(méi)有waf的注入點(diǎn),之前版本要求只能跑有waf的注入點(diǎn)
[2017-02-13]
更新支持自動(dòng)進(jìn)行版本升級(jí)
[2017-02-12]
更新支持所有sqlmap參數(shù)
[2017-01-18]
fix line128處的slef改成self
fix line128處的db_name未定義錯(cuò)誤
[2016-11-15]
修復(fù)一處ACCESS數(shù)據(jù)庫(kù)考慮不周全判斷和幾處good_print函數(shù)調(diào)用錯(cuò)誤
增加支持代理自動(dòng)切換功能,自選,默認(rèn)不用代理[用代理速度較慢]
[2016-11-02]
增加access數(shù)據(jù)庫(kù)特殊性的處理gg
[2016-11-01]
get_db_type_need_tamper之后的數(shù)據(jù)庫(kù)類(lèi)型獲取由之前的get_db_type_from_log_file改成
eval(get_key_value_from_config_file(self.log_config_file,'default','db_type'))