一、扫描输入
Nuclei支持各种输入格式来运行模板,包括urls, hosts, ips, cidrs, asn, openapi, swagger, proxify, burpsuite导出数据等。可以使用-list/-l和-input-mode/-im标志。
-l, -list string 包含要扫描的目标URL/主机列表的文件路径(每行一个)
-im, -input-mode string 输入文件模式(list、burp、jsonl、yaml、openapi、swagger)(默认“list”)
可以直接通过以下命令对输入列表(url、host、ips、cidrs、asn)执行Nuclei扫描:
nuclei -l targets.txt
对于运行其他输入格式(burp、jsonl、yaml、openapi、swagger),需要使用-im标志指定输入模式。
nuclei -l targets.burp -im burp
nuclei -l openapi.yaml -im openapi
二、扫描策略模板
核心模板库 nuclei-template repository中的大多数社区模板放在标准安全路径下,扫描时会默认执行这些策略模板。典型命令如下:
nuclei -u https://example.com
nuclei -list http_urls.txt
但是,默认运行的模板有一些例外:
可使用以下命令运行一个自定义模板目录或者多个目录
nuclei -u https://example.com -t cves/ -t exposures/
可以使用以下命令执行存储在GitHub目录下的自定义GitHub存储库中的模板:
nuclei -u https://example.com -t github/private-repo
三、执行模板工作流
可以使用以下命令执行工作流:
nuclei -u https://example.com -w workflows/
nuclei -list http_urls.txt -w workflows/wordpress-workflow.yaml
四、模板过滤
Nuclei支持三个基本过滤器来定制模板执行。使用-tags标签根据模板中可用的标签字段进行筛选;使用-severity标签根据模板中可用的严重性字段进行筛选;使用-author标签根据模板中可用的作者字段进行筛选。
通过-tags标签过滤执行cve扫描模板:
nuclei -u https://example.com -tags cve
运行~/nucleus templates/exposes/目录下所有可用的、包含config标签的扫描模板:
nuclei -u https://example.com -tags config -t exposures/
多个过滤器条件可以一起使用,以下示例,运行所有带有cve标签的模板,AND具有严重性或高严重性,并且模板的作者是geeknik:
nuclei -u https://example.com -tags cve -severity critical,high -author geeknik
五、高级模板过滤
可以使用模板条件标志(-tc)组合多个过滤器,该标志允许使用以下复杂表达式:
nuclei -tc "contains(id,'xss') || contains(tags,'xss')"
nuclei -tc "contains(tags,'cve') && contains(tags,'ssrf')"
nuclei -tc "contains(name, 'Local File Inclusion')"
支持的字段包括:
string
string
string
slice of strings
slice of strings
string
string
slice of strings
string (containing all request bodies if any)
slice of string
slice of string
string
六、常见命令参数
1、Nuclei对多个因素有多个速率限制控制,包括并行执行的多个模板、每个模板并行扫描的多个主机,以及每秒发出/限制的请求数,以下是每个标记的示例及其描述。
-rate-limit 控制每秒发送的请求总数
-bulk-size 控制每个模板并行处理的主机数量
-c 控制并行处理的模板数量
2、使用-H / header 自定义请求头:
# 每个请求中应包含的请求头
header:
- 'X-BugBounty-Hacker: h1/geekboy'
- 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) / nuclei'
nuclei -header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) / nuclei' -list urls.txt -tags cves
3、使用-excluded templates标志排除单个或多个模板和目录,-multiple-exclude templates标志可用于提供多个值。-exclude tags(-etags)标志用于排除基于已定义标签的模板,可以使用单个或多个标签来排除模板。
# 排除单个扫描模板
nuclei -list urls.txt -t cves/ -exclude-templates cves/2020/CVE-2020-XXXX.yaml
# 排除多个扫描模板
nuclei -list urls.txt -exclude-templates exposed-panels/ -exclude-templates technologies/
# 排除带有单个标记的模板
nuclei -l urls.txt -t cves/ -etags xss
# 排除带有多个标记的模板
nuclei -l urls.txt -t cves/ -etags sqli,rce
4、-tl 参数列出所有可用的扫描模板
# Command to list templates (-tl)
nuclei -tags cve -severity critical,high -author geeknik -tl
七、配置文件
自从v2.3.2版本发布以来,Nuclei使用goflags来获得干净的CLI体验和长/短格式的标志。goflags附带了自动生成的配置文件支持,可以将所有可用的CLI标志转换为配置文件,基本上你可以在配置文件中定义所有CLI标志,以避免重复的CLI标志,这些标志在每次扫描核时都会作为默认值加载。
配置文件默认路径:$HOME/.config/nuclei/config.yaml
# Headers to include with all HTTP request
header:
- 'X-BugBounty-Hacker: h1/geekboy'
# Directory based template execution
templates:
- cves/
- vulnerabilities/
- misconfiguration/
# Tags based template execution
tags: exposures,cve
# Template Filters
tags: exposures,cve
author: geeknik,pikpikcu,dhiyaneshdk
severity: critical,high,medium
# Template Allowlist
#
# Note: This will take precedence over the .nuclei-ignore file and denylist
# entries (exclude-tags or exclude-templates list).
include-tags: dos,fuzz # Tag based inclusion
include-templates: # Template based inclusion
- vulnerabilities/xxx
- misconfiguration/xxxx
# Template Denylist
exclude-tags: info # Tag based exclusion
exclude-templates: # Template based exclusion
- vulnerabilities/xxx
- misconfiguration/xxxx
# Rate Limit configuration
rate-limit: 500
bulk-size: 50
concurrency: 50
八、扫描报告
Nuclei在v2.3.0版本中支持报告模块,支持GitHub、GitLab和Jira集成,这允许Nuclei引擎根据发现的结果在支持的平台上自动创建扫描报告。
-rc,-report-config标志可用于提供一个配置文件,以读取要集成的平台的配置详细信息。以下是所有支持平台的示例配置文件:
# GitHub contains configuration options for GitHub issue tracker
github:
username: '$user'
owner: '$user'
token: '$token'
project-name: 'testing-project'
issue-label: 'Nuclei'
duplicate-issue-check: true
# elasticsearch contains configuration options for elasticsearch exporter
elasticsearch:
# IP for elasticsearch instance
ip: 127.0.0.1
# Port is the port of elasticsearch instance
port: 9200
# IndexName is the name of the elasticsearch index
nuclei :
# splunkhec contains configuration options for splunkhec exporter
splunkhec:
# Hostname for splunkhec instance
host: '$hec_host'
# Port is the port of splunkhec instance
port: 8088
# IndexName is the name of the splunkhec index
nuclei :
# SSL enables ssl for splunkhec connection
ssl: true
# SSLVerification disables SSL verification for splunkhec
true :
# HEC Token for the splunkhec instance
'$hec_token' :
制定输出扫描报告的命令样例:
nuclei -l urls.txt -t cves/ -rc issue-tracker.yaml
原文始发于微信公众号(安全有术):开源快速漏洞扫描器Nuclei:使用详解
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论