如何查找哪個 WAF 正在保護網站?

已發表: 2021-10-11

對於攻擊者來說,在開始指紋識別之前知道 WAF 通常在網絡上的哪些位置使用總是一個好主意。

滲透測試人員在開始參與 Web 應用程序之前必須了解 WAF,因為他們的攻擊結果可能會受到影響。

但在那之前……

什麼是WAF?

WAF(Web Application Firewall)在網站安全中扮演著重要的角色。 他們過濾和監控流量。 Web 應用程序防火牆提供針對主要缺陷的保護。 許多組織正在對其基礎架構進行現代化改造,以包括 Web 應用程序防火牆。 根據道德黑客專家的說法,Web 應用程序防火牆無法自行解決安全問題; 需要足夠的配置來識別和阻止外部威脅。

WAF 與傳統防火牆的不同之處在於它可以過濾特定在線應用程序的內容,而傳統防火牆則充當服務器之間的安全屏障。

HTTP 交互受一組規則的約束。 這些規則通常解決跨站點腳本和 SQL 注入等典型漏洞。

互聯網上有許多免費和開源工具可以發現 Web 應用程序背後的防火牆。

在本文中,我們將介紹可用於發現 WAF 的方法和工具。

請注意:在本教程中,我使用了我自己的網站來列舉細節。 未經所有者事先許可,請勿在任何網站上執行掃描或其他黑客活動。

手動發現

使用 TELNET 檢測

Telnet 主要供網絡管理員和滲透測試人員使用。 Telnet 使您能夠通過任何端口連接到遠程主機,如前所述。

  • Web 應用程序防火牆通常將 HTTP 參數留在(或插入)響應標頭中。
  • Telnet 可用於獲取基本的收集信息,例如用於指紋識別的服務器和 cookie。
  • 鍵入Telnet Targetwebsite.com 80
 [email protected]: # telnet Targetwebsite.com 80 Trying 18.166.248.208... Connected to Targetwebsite.com. Escape character is '^]'.

運行上述命令後,寫入HEAD / HTTP / 1.1並按回車鍵。

 [email protected]: # telnet 18.166.248.208 80 Trying 18.166.248.208... Connected to 18.166.248.208. Escape character is '^]'. HEAD / HTTP/1.1 Host: 18.166.248.208 HTTP/1.1 200 OK Date: SUN, 10 Oct 2021 05:08:03 IST Server: Apache X-Powered-By: PHP/5.3.5 ZendServer/5.0 Set-Cookie: SESSIONID VULN SITE=t25put8gliicvqf62u3ctgjm21; path=/ Expires: Thu, 19 Nov 1981 08:52:00 IST Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache X-Varnish: 4723782781 Age: 0 Via: 1.1 varnish Connection: close Content-Type: text/html Connection closed by foreign host.

它指示在目標端口 80 上使用 telnet 後託管網站的服務器和創建網站的後端語言。

一些 WAF 系統允許修改標頭,它們也可能導致 Web 服務器發送與標準響應不同的 HTTP 響應。

如上面的結果所示,網絡服務器響應了我們的請求並顯示防火牆/邊緣網關是 Varnish。

自動發現

#1. 使用 NMAP 檢測

Nmap 具有可識別 Web 應用程序防火牆的腳本,也可用於此目的。

  • Nmap 是許多滲透測試人員和網絡管理員常用的安全評估工具。
  • Nmap 用於獲取有關目標的信息。
  • 該腳本是針對與以前相同的網頁運行的
  • 輸入命令nmap –script=http-waf-fingerprint targetweb.com
 [email protected]:# nmap --script=http-waf-fingerprint targetwebsite.com Starting Nmap 7.90 ( https://nmap.org ) at 2021-10-10 07:58 IST Nmap scan report for targetsite.com (18.166.248.208) Host is up (0.24s latency). Not shown: 982filtered ports PORT STATE SERVICE 53/tcp open domain 80/tcp open http | http-waf-fingerprint: | Detected WAF | Citrix Netscaler 443/tcp open https 5432/tcp closed postgresql 8080/tcp closed http-proxy Nmap done: 1 IP address (1 host up) scanned in 25.46 seconds

使用上述Nmap命令後,檢測到Citrix Netscaler防火牆。

#2. 使用 Whatwaf 進行檢測

Whatwaf 是一種安全工具,用於對 Web 應用程序進行指紋識別並檢測任何 WAF 的存在。 此工具可用於在安全評估期間確定 Web 應用程序是否受 WAF 保護。

如果是這種情況,繞過和避免策略可能有助於進一步測試或利用在線應用程序。

防火牆繞過、應用檢測、應用指紋識別和軟件識別都是 WhatWaf 的常用用途。 網絡
滲透測試人員和安全專家是該程序的預期用戶。

如何安裝 WhatWaf?

在 Kali-Linux 上安裝

sudo apt install python3-pip git clone https://github.com/ekultek/whatwaf cd whatwaf sudo pip3 install -r requirements.txt

在啟動時,沒有 Python 版本,我們可以輕鬆指定一個可執行文件:

 ./whatwaf --help

不過由於我們沒有安裝Python 2的依賴,建議您專門提供Python版本。

 python3 ./whatwaf --help

工具使用

Whatwaf 防火牆檢測工具簡單易用! 我們只需要執行以下命令:

 ./whatwaf -u https://www.targetsite.com

如下所示,此工具檢測到提供的網站 URL 的防火牆。

提醒! – 我使用我自己的網站進行掃描

┌──(rootkali)-[/home/writer/WhatWaf] └─# ./whatwaf -u https://www.renjith.org ,------. ' .--. ' ,--. .--. ,--. .--.| | | | | | | | | | | |'--' | | | | | | | | | | __. | | |.'.| | | |.'.| | | .' | | | | |___| | ,'. |hat| ,'. |af .---. '--' '--' '--' '--' '---' /><script>alert("WhatWaf?<|>v2.0.3($dev)");</script>%00 [11:12:34][ERROR] you must install psutil first `pip install psutil` to start mining XMR [11:12:34][INFO] checking for updates [11:12:34][WARN] it is highly advised to use a proxy when using WhatWaf. do so by passing the proxy flag (IE `--proxy http://127.0.0.1:9050`) or by passing the Tor flag (IE `--tor`) [11:12:34][INFO] using User-Agent 'whatwaf/2.0.3 (Language=2.7.18; Platform=Linux)' [11:12:34][INFO] using default payloads [11:12:34][INFO] testing connection to target URL before starting attack [11:12:35][SUCCESS] connection succeeded, continuing [11:12:35][INFO] running single web application 'https://www.renjith.org' [11:12:35][WARN] URL does not appear to have a query (parameter), this may interfere with the detection results [11:12:35][INFO] request type: GET [11:12:35][INFO] gathering HTTP responses [11:12:42][INFO] gathering normal response to compare against [11:12:42][INFO] loading firewall detection scripts [11:12:42][INFO] running firewall detection checks [11:12:44][FIREWALL] detected website protection identified as 'Apache Generic' [11:12:44][INFO] starting bypass analysis [11:12:44][INFO] loading payload tampering scripts [11:12:45][INFO] running tampering bypass checks [11:19:09][SUCCESS] apparent working tampers for target: ------------------------------ (#1) description: tamper payload by changing characters into a wildcard example: '/bin/cat /et?/?asswd' load path: content.tampers.randomwildcard ------------------------------

如上面的結果所示,網絡服務器響應了我們的請求並顯示防火牆是 Apache。 我們也可以使用 tor 服務來掃描 WAF,但它可能會增加延遲。

 ./whatwaf -u https://www.targetsite.com --tor

Whatwaf 工具的主要優點是,它會自動嘗試提供有效載荷以繞過暴露的防火牆。

#3. 使用 Wafw00f 進行檢測

最著名的檢測Web應用防火牆的工具是Wafw00f。 Wafw00f 向 Web 應用程序防火牆發送 HTTP 請求以對其進行識別。 當發送 HTTP 請求失敗時,wafw00f 會發出惡意的 HTTP 請求。 如果發出惡意 HTTP 請求失敗,wafw00f 會檢查之前的 HTTP 請求並使用簡單的算法來確定 Web 應用程序防火牆是否對我們的攻擊做出反應。

Kali Linux 發行版中未預裝 Wafw00f。

如何安裝 Wafw00f?

zip 包可從官方 GitHub 源下載。

下載 Wafwoof 工具。 您還可以使用 git 客戶端來克隆存儲庫。 要獲取包,請運行以下命令:

 $ git clone https://github.com/EnableSecurity/wafw00f.git

下載系統中的wafw00f工具,導航到wafw00f文件夾或目錄,執行以下命令。

 $ python setup.py install

將處理安裝文件,並在系統中安裝 wafw00f。

工具使用

要使用此工具,請運行此命令。

 $ wafw00f <url>

提醒 – 只掃描您被允許測試的網站

┌──(rootkali)-[/home/writer/wafw00f] └─# wafw00f https://webhashes.com ______ / \ ( Woof! ) \ ____/ ) ,, ) (_ .-. - _______ ( |__| ()``; |==|_______) .)|__| / (' /|\ ( |__| ( / ) / | \ . |__| \(_)_)) / | \ |__| ~ WAFW00F : v2.1.0 ~ The Web Application Firewall Fingerprinting Toolkit [*] Checking https://whatismyip.com [+] The site https://whatismyip.com is behind Cloudflare (Cloudflare Inc.) WAF. [~] Number of requests : 2

太糟糕了,檢測到防火牆!

我們將嘗試不同的目標網站進行討論。

 ┌──(rootkali)-[/home/writer/wafw00f] └─# wafw00f https://renjith.org ______ / \ ( Woof! ) \ ____/ ) ,, ) (_ .-. - _______ ( |__| ()``; |==|_______) .)|__| / (' /|\ ( |__| ( / ) / | \ . |__| \(_)_)) / | \ |__| ~ WAFW00F : v2.1.0 ~ The Web Application Firewall Fingerprinting Toolkit [*] Checking https://renjith.org [+] Generic Detection results: [-] No WAF detected by the generic detection [~] Number of requests: 7

這次沒有檢測到防火牆。

要在詳細模式下使用它,請運行以下命令。

 wafw00f <url> -v

通過執行此命令,您可以查看此實用程序的一些附加功能。

 wafw00f <url> --help

包起來

在本文中,我們研究了用於檢測 Web 應用程序防火牆的不同策略和工具。 這是每個 Web 應用程序滲透測試的信息收集階段必須執行的一項重要活動。

此外,知道 WAF 已到位,滲透測試人員可以嘗試各種方法來繞過防禦並利用在線應用程序中的任何漏洞。

根據道德黑客研究人員的說法,擁有 Web 應用程序防火牆 (WAF) 變得越來越必要。 分析您的 Web 應用程序日誌以檢測後端 Web 應用程序服務器上發生的新攻擊始終很重要。 這允許您自定義 Web 應用程序防火牆中的規則以提供最高級別的保護。

您可能也有興趣閱讀:使用 Nikto Scanner 的漏洞。