一介闲人
一介闲人
sudo apt update && sudo apt install nikto
sudo yum install epel-release && sudo yum install nikto
git clone https://github.com/sullo/nikto.git
cd nikto/program
perl nikto.pl
nikto [选项] -h <目标主机/IP>
| 参数 | 作用 | 示例 |
|---|---|---|
-h |
指定目标主机(IP 地址或域名) | nikto -h 10.100.2.136 |
-p |
指定扫描端口(支持单端口、逗号分隔多端口、范围格式) | nikto -h example.com -p 80,443,8080-8090 |
-ssl |
强制使用 SSL/TLS 连接扫描 HTTPS 站点 | nikto -h example.com -p 443 -ssl |
-Tuning |
指定扫描类别(通过数字或字母过滤扫描项) | nikto -h example.com -Tuning 1,2,3 |
-output |
指定扫描结果输出文件(自动识别格式:txt/html/xml/csv) | nikto -h example.com -output scan_report.html |
-id |
提供 HTTP 基本认证凭证 | nikto -h example.com -id admin:password123 |
-Cgidirs |
扫描指定的 CGI 目录(默认扫描 /cgi-bin/) |
nikto -h example.com -Cgidirs /cgi-bin,/test-cgi |
-v |
启用详细输出模式,显示扫描过程中的每一个请求 | nikto -h example.com -v |
-update |
更新 Nikto 的漏洞数据库 | nikto -update |
-maxtime |
设置每个目标的最大扫描时间(单位:秒) | nikto -h example.com -maxtime 600 |
-timeout |
设置每个请求的超时时间(单位:秒) | nikto -h example.com -timeout 10 |
| 数字编码 | 类别说明 |
|---|---|
| 1 | 有趣的条目(信息泄露、默认页面等) |
| 2 | 不常用的选项(可能存在风险的配置) |
| 3 | 信息泄漏(服务器版本、路径等) |
| 4 | 注入漏洞(SQL/XSS/命令注入等) |
| 5 | 远程文件包含(RFI/LFI) |
| 6 | 身份认证绕过 |
| 7 | 命令执行 |
| 8 | 代码执行 |
| 9 | SQL 注入 |
| 10 | 跨站脚本(XSS) |
| 11 | 信息泄露(敏感文件/目录) |
| 12 | 拒绝服务(DoS) |
| 13 | 目录遍历 |
| 14 | 远程文件上传 |
| 15 | 常见的Web服务器漏洞 |
| 16 | 软件版本检测 |
| 17 | 弱密码/默认凭证 |
| 18 | 配置错误 |
| 19 | 缓存控制问题 |
| 20 | 安全头部缺失 |
nikto -h 10.100.2.136 -p 80
nikto -h 10.100.2.136 -p 80,443,8080
nikto -h example.com -p 443 -ssl
nikto -h 10.100.2.136 -Cgidirs /cgi-bin -output scan_result.html
nikto -h example.com -id "testuser:testpass123"
nikto -h 10.100.2.136 -Tuning 4,7,8
nikto -update
# 创建目标列表文件 targets.txt
echo "10.100.2.136:80" > targets.txt
echo "example.com:443" >> targets.txt
# 批量扫描
nikto -h targets.txt -list
nikto -h 10.100.2.136 -v -maxtime 300
支持通过HTTP/SOCKS代理进行扫描,避免真实IP被目标防火墙封禁:
# HTTP代理扫描
nikto -h example.com -useproxy http://127.0.0.1:8080
# SOCKS5代理扫描
nikto -h example.com -useproxy socks5://127.0.0.1:1080
模拟真实浏览器请求特征,绕过简单的Web应用防火墙拦截:
# 自定义User-Agent和Referer头
nikto -h example.com -useragent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" -referer "https://www.baidu.com"
# 添加自定义HTTP头
nikto -h example.com -header "X-Forwarded-For: 192.168.1.100" -header "Accept-Language: zh-CN,zh;q=0.9"
跳过不需要的扫描项,大幅加快扫描速度:
# 排除扫描类别(排除XSS和SQL注入检测,只扫其他项)
nikto -h example.com -Tuning x10,x9
# 排除指定路径不扫描
nikto -h example.com -exclude "/admin,/test,/upload"
# 跳过404检测,减少误报和无效请求
nikto -h example.com -no404
生产环境扫描时限制请求速率,避免影响目标服务正常运行:
# 每秒最多发送2个请求
nikto -h example.com -rate 2
# 每个请求之间延迟1秒
nikto -h example.com -delay 1
处理自签名证书、过期证书等特殊HTTPS站点:
# 忽略SSL证书错误(自签名证书、过期证书站点
nikto -h example.com -p 443 -ssl -nosslcheck
# 客户端证书认证站点扫描
nikto -h example.com -p 443 -ssl -cert /path/to/client.crt -key /path/to/client.key
# 导出为Nessus兼容格式报告,导入漏洞管理平台
nikto -h example.com -output scan_report.nessus -Format nessus
# 导出为Metasploit兼容格式,用于漏洞利用验证
nikto -h example.com -output scan_report.msf -Format msf
# 全量扫描站点,生成HTML报告,限制扫描时间1小时
nikto -h new-site.example.com -p 80,443 -ssl -maxtime 3600 -output new_site_security_report.html
扫描重点:默认页面、测试文件、备份文件、目录遍历、弱口令、安全头缺失等配置问题。
修复已知漏洞后,只扫描对应类别验证修复效果:
# 仅扫描SQL注入和XSS漏洞,验证修复结果
nikto -h example.com -Tuning 9,10 -output fix_verify_report.html
Web站点被入侵后,扫描是否存在后门文件、恶意路径:
# 扫描所有已知的敏感文件/路径,详细输出请求内容
nikto -h example.com -Tuning 11,15 -v -output incident_response_report.html
重点检查异常路径:webshell路径、恶意上传的文件、后门账户等。
对业务域名进行每周一次的安全扫描,自动生成报告:
# 编写定时任务脚本
#!/bin/bash
DATE=$(date +%Y%m%d)
TARGET="example.com"
nikto -h $TARGET -output /home/scan/report_${TARGET_$DATE.html
# 配置cron任务每周一凌晨2点执行
0 2 * * 1 /path/to/scan_script.sh
| 结果前缀 | 严重级别 | 说明 | 处理优先级 |
|---|---|---|---|
+ OSVDB-XXXX |
高危/中危 | 匹配到公开漏洞库的已知漏洞 | 最高,必须立即验证 |
+ Default account found |
高危 | 发现默认凭证/弱口令 | 最高,立即修改密码 |
+ XSS vulnerability found |
高危 | 存在跨站脚本漏洞 | 最高,立即修复 |
+ SQL Injection found |
高危 | 存在SQL注入漏洞 | 最高,立即修复 |
+ Remote Code Execution |
高危 | 存在远程命令/代码执行漏洞 | 最高,立即修复 |
+ Unrestricted File Upload |
高危 | 存在任意文件上传漏洞 | 最高,立即修复 |
+ Server leaks |
中危/低危 | 服务器信息泄露(版本号、路径等) | 中,评估是否需要隐藏 |
+ Missing security header |
中危 | 缺失安全响应头 | 中,按需修复 |
+ Outdated software |
中危/高危 | 软件版本过时存在已知漏洞 | 中高,评估升级必要性 |
+ Uncommon header found |
低危/信息 | 非标准HTTP头 | 低,参考即可 |
A:可以通过以下方式优化扫描速度:
-Tuning指定只扫描需要的漏洞类别,减少不必要的检测项-exclude排除不需要扫描的路径-timeout超时时间,默认10秒改为3秒-nosslcheck跳过证书验证-no404跳过404页面检测,减少无效请求A:尝试以下解决方法:
-p 443 -ssl参数-nosslcheck忽略证书错误-sslprotocol TLSv1.2A:两种常用方法:
域名:端口格式写入文件,每行一个,使用nikto -h targets.txt -listA:可以配合grep过滤输出:
# 只显示高危漏洞结果
grep -E "(OSVDB|SQL Injection|XSS|Default account|Code Execution|File Upload)" scan_result.txt
-rate参数控制扫描速率。nikto -update以获取最新的漏洞检测规则。
评论