引言
Nikto 是一个流行的开源 Web 服务器扫描器,它针对 Web 服务器进行全面的测试,检查超过 6700 个潜在危险文件/程序,检查超过 1250 个服务器的过时版本,以及超过 270 个服务器的版本特定问题。然而,有时完全扫描可能会产生过多的“噪音”或误报。在本实验中,你将学习如何通过排除特定插件来优化你的 Nikto 扫描,使你的结果更加聚焦和可操作。
Nikto 是一个流行的开源 Web 服务器扫描器,它针对 Web 服务器进行全面的测试,检查超过 6700 个潜在危险文件/程序,检查超过 1250 个服务器的过时版本,以及超过 270 个服务器的版本特定问题。然而,有时完全扫描可能会产生过多的“噪音”或误报。在本实验中,你将学习如何通过排除特定插件来优化你的 Nikto 扫描,使你的结果更加聚焦和可操作。
在此步骤中,我们将针对测试 Web 服务器执行一次基础的 Nikto 扫描。这次初步扫描将作为基线,使我们能够看到由默认插件集生成的所有发现。通过这份完整报告,我们可以识别出在未来扫描中可能想要排除的插件。
首先,请确保你位于 ~/project 目录。我们的设置脚本已经启动了一个简单的 Web 服务器在后台运行。让我们针对它运行一次标准的 Nikto 扫描。-h 选项用于指定目标主机。
在你的终端中执行以下命令:
nikto -h http://127.0.0.1:8000
扫描完成后,你将看到一份报告。你的输出将与此类似,尽管服务器版本和其他细节可能会有所不同。
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: 127.0.0.1
+ Target Hostname: 127.0.0.1
+ Target Port: 8000
+ Start Time: ...
---------------------------------------------------------------------------
+ Server: SimpleHTTP/0.6 Python/3.10.12
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type.
+ No CGI directories found (use '-C all' to force check all possible dirs)
+ OSVDB-3233: /cgi-bin/: This might be interesting...
+ 7558 requests: 0 error(s) and 4 item(s) reported on remote host
+ End Time: ...
---------------------------------------------------------------------------
+ 1 host(s) tested
在上面的输出中,请注意这一行:+ OSVDB-3233: /cgi-bin/: This might be interesting...。这个发现是由 cgi 插件生成的。对于本次实验,我们将假定这是一个预期的目录,而这个发现只是我们想要抑制的“噪音”。
-plugins 选项在此步骤中,你将学习用于控制 Nikto 运行哪些插件的语法。Nikto 为此提供了 -plugins 选项。要排除一个插件,你需要提供其名称并加上一个前导连字符 (-)。
要了解哪些插件可供包含或排除,你可以使用 -list-plugins 选项。这将打印出所有可用插件的列表,并附有每个插件的简要描述。
让我们列出所有插件:
nikto -list-plugins
输出将是一个长列表。以下是你将看到的输出的简要示例:
- Nikto v2.5.0
---------------------------------------------------------------------------
Loaded Main Plugins:
- apache_expect_header
Apache Expect header XSS (CVE-2006-3918)
- apache_users
Checks for sensitive files in ~user directories
- auth
Checks for authentication problems
- cgi
Checks for CGI directories
- clientaccesspolicy
Checks for permissive Client Access Policy (Silverlight)
... (列表继续) ...
从这个列表中,你可以找到你希望排除的插件的准确名称,例如我们在上一步中识别出的 cgi。
在此步骤中,我们将结合所学知识,构建一个排除单个插件的新扫描命令。我们将以在步骤 1 中识别出的 cgi 插件为目标。
语法很简单:你将 -plugins 选项附加到你的常规扫描命令后面,然后是带有前导连字符的插件名称。
命令结构是:nikto -h [目标] -plugins -[要排除的插件]
基于此结构,在排除 cgi 插件的同时扫描本地服务器的命令是:
nikto -h http://127.0.0.1:8000 -plugins -cgi
此命令告诉 Nikto 在 http://127.0.0.1:8000 上执行其标准扫描,但要跳过与 cgi 插件相关的任何检查。在下一步中,我们将执行此命令并观察输出的差异。
在此步骤中,你将执行我们在上一步中构建的命令。通过运行排除 cgi 插件的扫描,我们期望报告不再包含与 /cgi-bin/ 目录相关的发现。
现在,在你的终端中运行命令:
nikto -h http://127.0.0.1:8000 -plugins -cgi
扫描将再次运行,但这次会稍微快一些,因为它执行的检查更少。输出应该如下所示:
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: 127.0.0.1
+ Target Hostname: 127.0.0.1
+ Target Port: 8000
+ Start Time: ...
---------------------------------------------------------------------------
+ Server: SimpleHTTP/0.6 Python/3.10.12
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type.
+ 7557 requests: 0 error(s) and 3 item(s) reported on remote host
+ End Time: ...
---------------------------------------------------------------------------
+ 1 host(s) tested
将此输出与步骤 1 的输出进行比较。你将注意到 + OSVDB-3233: /cgi-bin/: This might be interesting... 这行现在不见了。这证实我们已成功地从扫描中排除了 cgi 插件。
在此步骤中,你将学习如何在单个扫描中排除多个插件。当你想要一次性抑制多个产生大量告警或不相关的插件时,这将非常有用。
要排除多个插件,你需要在 -plugins 选项后提供一个逗号分隔的插件名称列表。列表中的每个插件名称都必须以连字符开头。
语法是:nikto -h [目标] -plugins -[插件1],-[插件2],-[插件3]
让我们扩展之前的命令,也排除 apache_expect_header 插件,这是另一个常见的发现,在某些情况下可能被认为是低优先级的。
构建并运行以下命令:
nikto -h http://127.0.0.1:8000 -plugins -cgi,-apache_expect_header
现在输出将更加简洁,因为 cgi 和 apache_expect_header 这两个插件的检查都已被跳过。
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: 127.0.0.1
+ Target Hostname: 127.0.0.1
+ Target Port: 8000
+ Start Time: ...
---------------------------------------------------------------------------
+ Server: SimpleHTTP/0.6 Python/3.10.12
+ The anti-clickjacking X-Frame-Options header is not present.
+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type.
+ ... requests: 0 error(s) and 2 item(s) reported on remote host
+ End Time: ...
---------------------------------------------------------------------------
+ 1 host(s) tested
如你所见,通过选择性地排除插件,你可以根据你的特定需求定制 Nikto 的扫描行为,从而获得更简洁、更相关的报告。
在此实验中,你学习了如何通过排除特定插件来定制 Nikto 扫描。你首先运行了一个完整的基线扫描来识别需要排除的插件。然后,你了解了 -plugins 选项和 -list-plugins 命令。最后,你练习了构建和执行命令来排除单个插件和多个插件,并通过观察扫描输出的变化来验证结果。这项技术对于使用 Nikto 运行更高效、更有针对性且噪音更少的漏洞扫描至关重要。