Web Application Firewall (WAF)可以是一個(gè)硬件也可以是一個(gè)軟件,用以檢查過(guò)濾發(fā)往 Web 應(yīng)用的數(shù)據(jù)包弹砚,常見(jiàn)的過(guò)濾機(jī)制是基于認(rèn)證簽名或正則表達(dá)式双仍。
如果靶機(jī)應(yīng)用的 WAF 屏蔽了我們的請(qǐng)求或封了我們的 IP 地址,那么我們的很多操作就顯得多此一舉了桌吃。在滲透測(cè)試的勘察階段朱沃,探測(cè)并識(shí)別 WAF ,比如 Intrusion Detection System (IDS) 或者 Intrusion Prevention System (IPS)茅诱。進(jìn)行 WAF 探測(cè)識(shí)別的目的是為了防止被靶機(jī)封殺訪問(wèn)逗物。
這篇文章,我們討論如何使用不同的方法让簿,借助 Kali 提供的工具掃描并探測(cè)靶機(jī)和我們之間的 WAF敬察。
實(shí)施步驟
Nmap 包含一堆腳本用來(lái)檢測(cè) WAF 是否存在:
root@kali:~# nmap -p 80,443 --script=http-waf-detect 192.168.150.143
Starting Nmap 7.01 ( https://nmap.org ) at 2016-07-18 23:09 CST
Nmap scan report for bogon (192.168.150.143)
Host is up (0.00034s latency).
PORT STATE SERVICE
80/tcp open http
443/tcp open https
MAC Address: 00:0C:29:8F:CA:00 (VMware)
Nmap done: 1 IP address (1 host up) scanned in 0.58 seconds
上面這個(gè)掃描結(jié)果顯示,該站點(diǎn)沒(méi)有使用 WAF
下面掃描一個(gè)使用 WAF 的 Web 應(yīng)用:
root@kali:~# nmap -p 80,443 --script=http-waf-detect www.reibang.com
Starting Nmap 7.01 ( https://nmap.org ) at 2016-07-18 CST
Nmap scan report for www.reibang.com (120.132.92.21)
Host is up (0.0049s latency).
PORT STATE SERVICE
80/tcp open http
| http-waf-detect: IDS/IPS/WAF detected:
|_www.reibang.com:80/?p4yl04d3=<script>alert(document.cookie)</script>
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 1.31 seconds
root@kali:~# nmap -p 80,443 --script=http-waf-detect idea.lanyus.com
Starting Nmap 7.01 ( https://nmap.org ) at 2016-07-18 23:19 CST
Nmap scan report for idea.lanyus.com (120.52.29.180)
Host is up (0.0081s latency).
PORT STATE SERVICE
80/tcp open http
| http-waf-detect: IDS/IPS/WAF detected:
|_idea.lanyus.com:80/?p4yl04d3=<script>alert(document.cookie)</script>
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 1.32 seconds
下面我們使用 Nmap 的另一個(gè)腳本來(lái)更加精確的定位 所使用的 WAF 產(chǎn)品:
root@kali:~# nmap -p 80,443 --script=http-waf-fingerprint idea.lanyus.com
Starting Nmap 7.01 ( https://nmap.org ) at 2016-07-18 23:34 CST
Nmap scan report for idea.lanyus.com (120.52.29.180)
Host is up (0.0083s latency).
PORT STATE SERVICE
80/tcp open http
| http-waf-fingerprint:
| Detected WAF
|_ Cloudflare
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 1.28 seconds
另一個(gè)檢測(cè) WAF 的工具 wafw00f:
root@kali:~# wafw00f www.example.com
^ ^
_ __ _ ____ _ __ _ _ ____
///7/ /.' \ / __////7/ /,' \ ,' \ / __/
| V V // o // _/ | V V // 0 // 0 // _/
|_n_,'/_n_//_/ |_n_,' \_,' \_,'/_/
<
...'
WAFW00F - Web Application Firewall Detection Tool
By Sandro Gauci && Wendel G. Henrique
Checking http://www.example.com
Generic Detection results:
The site http://www.example.com seems to be behind a WAF or some sort of security solution
Reason: The server header is different when an attack is detected.
The server header for a normal response is "ECS (rhv/818F)", while the server header a response to an attack is "ECS (rhv/8192).",
Number of requests: 12
檢測(cè)原理
WAF 檢測(cè)原理是給服務(wù)發(fā)送特定請(qǐng)求尔当,然后分析響應(yīng)莲祸。比如 http-waf-detect ,它發(fā)送很多惡意請(qǐng)求椭迎,看有沒(méi)有被服務(wù)端封殺锐帜、過(guò)濾或檢測(cè)到的請(qǐng)求。 http-waf-fingerprint 也是這個(gè)工作流程畜号,但是這個(gè)腳本還會(huì)進(jìn)一步解析響應(yīng)缴阎,根據(jù)不同 IDSs 和 WAFs 的模式來(lái)對(duì) WAF 進(jìn)行分類。wafw00f 的檢測(cè)原理也是如此简软。