| name | performing-web-application-scanning-with-nikto |
| description | Nikto 是一款开源 Web 服务器和 Web 应用程序扫描器,可针对超过 7,000 个潜在危险文件/程序进行测试,检查超过 1,250 个服务器的过期版本,并识别超过 270 个服务器的版本特定问题。 |
| domain | cybersecurity |
| subdomain | vulnerability-management |
| tags | ["vulnerability-management","cve","nikto","web-scanning","owasp","risk"] |
| version | 1.0 |
| author | mahipal |
| license | Apache-2.0 |
使用 Nikto 执行 Web 应用程序扫描
概述
Nikto 是一款开源 Web 服务器和 Web 应用程序扫描器,可针对超过 7,000 个潜在危险文件/程序进行测试,检查超过 1,250 个服务器的过期版本,并识别超过 270 个服务器的版本特定问题。它执行全面测试,包括 XSS、SQL 注入、服务器错误配置、默认凭据和已知漏洞 CGI 脚本。
前置条件
- 已安装 Nikto(基于 Perl,Kali Linux 中已包含)
- 扫描目标 Web 服务器的书面授权
- 目标 Web 应用程序的网络访问权限
- 了解 HTTP/HTTPS 协议
核心概念
Nikto 可检测的内容
- 服务器错误配置和危险的默认文件
- 具有已知 CVE 的过期服务器软件版本
- 常见 CGI 漏洞和危险脚本
- 默认凭据和管理页面
- 应禁用的 HTTP 方法(PUT、DELETE、TRACE)
- SSL/TLS 错误配置和弱密码套件
- 缺失的安全标头(X-Frame-Options、CSP、HSTS)
- 通过响应头和错误页面的信息泄露
Nikto 与其他 Web 扫描器对比
| 功能 | Nikto | OWASP ZAP | Burp Suite | Nuclei |
|---|
| 许可证 | 开源 | 开源 | 商业 | 开源 |
| 重点 | 服务器/配置 | 应用逻辑 | 完整渗透测试 | 模板驱动 |
| 速度 | 快 | 中 | 慢 | 非常快 |
| 误报率 | 中等 | 低 | 低 | 低 |
| 认证支持 | 基本 | 完整 | 完整 | 模板 |
| 活跃社区 | 是 | 是 | 是 | 是 |
工作流程
步骤 1:基本扫描
nikto -h https://target.example.com
nikto -h target.example.com -p 8443
nikto -h target.example.com -p 80,443,8080,8443
nikto -h target.example.com -ssl
nikto -h targets.txt
步骤 2:高级扫描选项
nikto -h https://target.example.com \
-Tuning 123456789abcde \
-timeout 10 \
-Pause 2 \
-Display V \
-output report.html \
-Format htm
nikto -h https://target.example.com -Tuning 49a
nikto -h https://target.example.com -id admin:password
nikto -h https://target.example.com -useproxy http://proxy:8080
nikto -h https://target.example.com -useragent "Mozilla/5.0 (Security Scan)"
nikto -h https://target.example.com -Cgidirs /cgi-bin/,/scripts/
nikto -h https://target.example.com -evasion 1234
步骤 3:输出与报告
nikto -h https://target.example.com -output scan.csv -Format csv
nikto -h https://target.example.com -output scan.xml -Format xml
nikto -h https://target.example.com -output scan.html -Format htm
nikto -h https://target.example.com -output scan.txt -Format txt
nikto -h https://target.example.com -output scan.json -Format json
nikto -h https://target.example.com \
-output scan_report \
-Format htm
步骤 4:扫描多个目标
cat > targets.txt << 'EOF'
https://app1.example.com
https://app2.example.com:8443
http://internal-app.corp.local
192.168.1.100:8080
EOF
nikto -h targets.txt -output multi_scan.html -Format htm
cat targets.txt | parallel -j 5 "nikto -h {} -output {/}_report.html -Format htm"
步骤 5:SSL/TLS 评估
nikto -h https://target.example.com -ssl \
-Tuning b \
-Display V
步骤 6:与其他工具集成
nmap -p 80,443,8080 --open -oG - 192.168.1.0/24 | \
awk '/open/{print $2}' | \
while read host; do nikto -h "$host" -output "${host}_nikto.html" -Format htm; done
nikto -h target.example.com -output msf_import.xml -Format xml
python3 -c "
import xml.etree.ElementTree as ET
tree = ET.parse('scan.xml')
for item in tree.findall('.//item'):
print(f\"[{item.get('id')}] {item.findtext('description', '')[:100]}\")
"
解读结果
严重性分类
- OSVDB/CVE 引用:与 NVD 交叉对比以获取 CVSS 评分
- 服务器信息泄露:版本横幅、技术栈
- 危险 HTTP 方法:启用了 PUT、DELETE、TRACE
- 默认/备份文件:.bak、.old、.swp、web.config.bak
- 管理界面:暴露的 /admin、/manager、/console
- 缺失安全标头:CSP、X-Frame-Options、HSTS
常见误报
- 自定义 404 页面触发的通用检查
- 防 CSRF 令牌被标记为表单漏洞
- CDN/WAF 响应被错误识别为漏洞
- 负载均衡器健康检查页面
最佳实践
- 扫描前务必获取书面授权
- 将 Nikto 与应用层扫描器(ZAP、Burp)结合使用
- 使用 -Pause 标志降低对生产服务器的负载
- 报告前手动验证发现
- 结合 SSL 测试工具(testssl.sh、sslyze)进行全面覆盖
- 将定期扫描纳入持续漏洞管理流程
- 保持 Nikto 数据库更新以检查最新漏洞
- 仅在授权的 IDS 测试中使用适当的规避设置
常见陷阱
- 未经授权运行 Nikto(法律责任)
- 将 Nikto 视为完整的 Web 应用程序扫描器(它专注于服务器/配置问题)
- 不验证结果导致误报报告
- 对生产系统进行过于激进的扫描
- 将 SSL/TLS 发现忽视为"信息性"
相关技能
- scanning-infrastructure-with-nessus
- scanning-apis-for-security-vulnerabilities
- performing-network-vulnerability-assessment