执行扫描并将输出保存到 XML 文件
在此步骤中,你将针对本地测试 Web 服务器执行基本的 Nikto 扫描。关键在于将输出以结构化格式(如 XML)保存到文件中,Nikto 稍后可以解析该文件。我们将使用 -o 选项指定输出文件,并使用 -Format 定义文件类型。
首先,请确保你位于 ~/project 目录。我们的设置脚本已经启动了一个简单的 Web 服务器,运行在 localhost 的 8000 端口。
现在,在你的终端中运行以下命令,扫描本地 Web 服务器并将结果保存到名为 scan_results.xml 的文件中:
nikto -h http://localhost:8000 -o scan_results.xml -Format xml
让我们分解一下这个命令:
nikto: 运行 Nikto 扫描器的命令。
-h http://localhost:8000: 指定要扫描的主机(目标)。
-o scan_results.xml: 指定输出文件名。
-Format xml: 指示 Nikto 以 XML 格式保存输出。
扫描需要一些时间才能完成。你将在终端中看到类似以下的输出(详细信息可能有所不同):
- Nikto v2.5.0
---------------------------------------------------------------------------
+ Target IP: 127.0.0.1
+ Target Hostname: localhost
+ Target Port: 8000
+ Start Time: ...
---------------------------------------------------------------------------
+ Server: SimpleHTTP/0.6 Python/3.10.6
+ 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)
+ Allowed HTTP Methods: GET, HEAD, OPTIONS
+ Public HTTP Methods: GET, HEAD, OPTIONS
...
+ 1 host(s) tested
命令完成后,将在你当前目录(~/project)中创建一个名为 scan_results.xml 的文件。