开源快速漏洞扫描器Nuclei:使用详解

admin 2024年9月9日10:43:57评论330 views字数 4872阅读16分14秒阅读模式
开源快速漏洞扫描器Nuclei:使用详解
开源快速漏洞扫描器Nuclei系列历史文章超链接:
(一)开源快速漏洞扫描器Nuclei:简介与安装

一、扫描输入

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 burpnuclei -l openapi.yaml -im openapi

二、扫描策略模板

核心模板库 nuclei-template repository中的大多数社区模板放在标准安全路径下,扫描时会默认执行这些策略模板。典型命令如下:

nuclei -u https://example.comnuclei -list http_urls.txt

但是,默认运行的模板有一些例外:

1、默认文件中包含nuclei-ignore的标记和模板不包括在内
2、代码模板需要-Code标志才能执行
3、除非增加-headless 标记,否则Headless Templates 不会运行
4、除非增加-fuzze标志,否则Fuzzing Templates 将不会运行
5、位于不同存储库中的单独的Fuzzing Templates 集合必须单独下载和配置才能使用

可使用以下命令运行一个自定义模板目录或者多个目录

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')"

支持的字段包括:

-id string-name string-description string-tags slice of strings-authors slice of strings-severity string-protocol string-http_method slice of strings-body string (containing all request bodies if any)-matcher_type slice of string-extractor_type slice of string-description 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

开源快速漏洞扫描器Nuclei:使用详解

七、配置文件

自从v2.3.2版本发布以来,Nuclei使用goflags来获得干净的CLI体验和长/短格式的标志。goflags附带了自动生成的配置文件支持,可以将所有可用的CLI标志转换为配置文件,基本上你可以在配置文件中定义所有CLI标志,以避免重复的CLI标志,这些标志在每次扫描核时都会作为默认值加载。

配置文件默认路径:$HOME/.config/nuclei/config.yaml

开源快速漏洞扫描器Nuclei:使用详解

# Headers to include with all HTTP requestheader:  - 'X-BugBounty-Hacker: h1/geekboy'# Directory based template executiontemplates:  - cves/  - vulnerabilities/  - misconfiguration/# Tags based template executiontags: exposures,cve# Template Filterstags: exposures,cveauthor: geeknik,pikpikcu,dhiyaneshdkseverity: 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 inclusioninclude-templates: # Template based inclusion  - vulnerabilities/xxx  - misconfiguration/xxxx# Template Denylistexclude-tags: info # Tag based exclusionexclude-templates: # Template based exclusion  - vulnerabilities/xxx  - misconfiguration/xxxx# Rate Limit configurationrate-limit: 500bulk-size: 50concurrency: 50

八、扫描报告

Nuclei在v2.3.0版本中支持报告模块,支持GitHub、GitLab和Jira集成,这允许Nuclei引擎根据发现的结果在支持的平台上自动创建扫描报告。

开源快速漏洞扫描器Nuclei:使用详解

-rc,-report-config标志可用于提供一个配置文件,以读取要集成的平台的配置详细信息。以下是所有支持平台的示例配置文件:

# GitHub contains configuration options for GitHub issue trackergithub:  username: '$user'  owner: '$user'  token: '$token'  project-name: 'testing-project'  issue-label: 'Nuclei'  duplicate-issue-check: true
# elasticsearch contains configuration options for elasticsearch exporterelasticsearch:  # 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  index-name: nuclei
# splunkhec contains configuration options for splunkhec exportersplunkhec:  # Hostname for splunkhec instance  host: '$hec_host'  # Port is the port of splunkhec instance  port: 8088  # IndexName is the name of the splunkhec index  index-name: nuclei  # SSL enables ssl for splunkhec connection  ssl: true  # SSLVerification disables SSL verification for splunkhec  ssl-verification: true  # HEC Token for the splunkhec instance  token: '$hec_token'

制定输出扫描报告的命令样例:

nuclei -l urls.txt -t cves/ -rc issue-tracker.yaml

原文始发于微信公众号(安全有术):开源快速漏洞扫描器Nuclei:使用详解

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年9月9日10:43:57
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   开源快速漏洞扫描器Nuclei:使用详解https://cn-sec.com/archives/3145596.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息