如何查找哪个 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 的漏洞。