Simple use of nuclei (1)

![[Pasted image 20230703232213.png]]

It is a customized fast vulnerability scanner based on YAML syntax templates

official page: https://nuclei.projectdiscovery.io/
item site: https:/ /github.com/projectdiscovery/nuclei
Item script: https://github.com/projectdiscovery/nuclei-templates
Screenplay text: https://nuclei.projectdiscovery.io/templating-guide/

1. Installation process

# kali/ubuntu go语言 安装

sudo apt update
sudo apt install golang-go

go version

![[Pasted image 20230703233353.png]]

# 快速安装(需要先安装go环境)
go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest  
# 编译安装(需要先安装go环境)
git clone https://github.com/projectdiscovery/nuclei.git; \
cd nuclei/v2/cmd/nuclei; \
go build; \
mv nuclei /usr/local/bin/; \
nuclei -version;
# docker 环境安装 不需要安装Go语言
docker pull projectdiscovery/nuclei:latest
# 直接下载releases,下载即用
https://github.com/projectdiscovery/nuclei/releases

After the installation is complete

nuclei -version

![[Pasted image 20230703233427.png]]

renew

nuclei -up  # 更新 nuclei
nuclei -ut  # 更新脚本

2. Common operations

nuclei -up  # 更新 nuclei
nuclei -ut  # 更新脚本

![[Pasted image 20230703233945.png]]

nuclei -h
用法:
  nuclei [命令]
 
命令:
目标:
   -u, -target string[]                 指定扫描的URL/主机
   -l, -list string                     指定需要扫描的URL/主机文件(一行一个)
 
模板:
   -t, -templates string[]              指定需要扫描的模板或者模板的路径
   -nt, -new-templates                  只扫描最新版本中添加的模板
   -w, -workflows string[]              指定扫描中的工作流或者工作流目录
   -validate                            验证通过的模板
   -tl                                  列出所有可用的模板
 
过滤:
   -tags string[]                       执行有标记的模板子集
   -etags, -exclude-tags string[]       执行标记为排除的模板
   -itags, -include-tags string[]       不执行具有攻击性的模板
   -et, -exclude-templates string[]     要排除的模板或者模板目录
   -it, -include-templates string[]     执行默认或配置中排除的模板
   -s, -severity value[]                根据严重性运行模板,允许的值有:info,low,medium,high,critical   
   -es, -exclude-severity value[]       根据严重性排除模板,允许的值有:info,low,medium,high,critical   
   -a, -author string[]                 执行指定作者的模板
 
输出:
   -o, -output string                   输出发现的问题到文件
   -silent                              只显示结果
   -nc, -no-color                       禁用输出内容着色(ANSI转义码)
   -json                                输出为jsonL(ines)
   -irr, -include-rr                    在JSONL中输出对应的请求和相应(仅结果)
   -nm, -no-meta                        不显示匹配的元数据
   -nts, -no-timestamp                  不在输出中显示时间戳
   -rdb, -report-db string              本地的Nuclei结果数据库(始终使用该数据库保存结果)       
   -me, -markdown-export string         以markdown导出结果
   -se, -sarif-export string            以SARIF导出结果
 
配置:
   -config string                       指定Nuclei的配置文件
   -rc, -report-config string           指定Nuclei报告模板文件
   -H, -header string[]                 指定报告中的标题:value格式
   -V, -var value                       通过var=value指定var值
   -r, -resolvers string                指定Nuclei的解析文件
   -sr, -system-resolvers               当DNS错误时使用系统DNS
   -passive                             启用被动扫描处理HTTP响应
   -ev, env-vars                        在模板中使用环境变量
 
交互:
   -inserver, -ineractsh-server string  使用interactsh反连检测平台(默认为"https://interact.sh")
   -itoken, -interactsh-token string    指定反连检测平台的身份凭证
   -interactions-cache-size int         指定保存在交互缓存中的请求数(默认:5000)
   -interactions-eviction int           聪缓存中删除请求前等待的时间(默认为60秒)
   -interactions-poll-duration int      每个轮询前等待时间(默认为5秒)
   -interactions-cooldown-period int    退出轮询前的等待时间(默认为5秒)
   -ni, -no-interactsh                  禁用反连检测平台,同时排除基于反连检测的模板
 
限速:
   -r1, -rate-limit int                 每秒最大请求量(默认:150)
   -rlm, -rate-limit-minute int         每分钟最大请求量
   -bs, -bulk-size int                  每个模板最大并行检测数(默认:25)
   -c, -concurrency int                 并行执行的最大模板数量(默认:25)
 
 
优化:
   -timeout int                         超时时间(默认为5秒)
   -retries int                         重试次数(默认:1)
   -mhe, -max-host-error int            某主机扫描失败次数,跳过该主机(默认:30)
   -project                             使用项目文件夹避免多次发送同一请求
   -project-path string                 设置特定的项目文件夹
   -spm, -stop-at-first-path            得到一个结果后停止(或许会中断模板和工作流的逻辑)
   -stream                              流模式 - 在不整理输入的情况下详细描述
 
无界面浏览器:
    -headless                           启用需要无界面浏览器的模板
    -page-timeout int                   在无界面下超时秒数(默认:20)
    -sb, -show-brower                   在无界面浏览器运行模板时,显示浏览器
    -sc, -system-chrome                 不使用Nuclei自带的浏览器,使用本地浏览器
 
调试:
    -debug                              显示所有请求和响应
    -debug-req                          显示所有请求
    -debug-resp                         显示所有响应
    -proxy, -proxy-url string           使用HTTP代理
    -proxy-socks-url string             使用SOCK5代理
    -tlog, -trace-log string            写入请求日志到文件
    -version                            显示版本信息
    -v, -verbose                        显示详细信息
    -vv                                 显示额外的详细信息
    -tv, -templates-version             显示已安装的模板版本
 
升级:
    -update                             更新Nuclei到最新版本
    -ut, -update-templates              更新Nuclei模板到最新版
    -ud, -update-directory string       覆盖安装模板
    -duc, -disable-update-check         禁用更新
 
统计:
    -stats                              显示正在扫描的统计信息
    -sj, -stats-json                    将统计信息以JSONL格式输出到文件
    -si, -stats-inerval int             显示统计信息更新的间隔秒数(默认:5)
    -m, -metrics                        显示Nuclei端口信息
    -mp, -metrics-port int              更改Nuclei默认端口(默认:9092)

Scan a single target

nuclei -u https://example.com

Scan multiple targets

nuclei -list urls.txt

Example of urls.txt:

http://example.com
http://app.example.com
http://test.example.com
http://uat.example.com

Needetags cve Map title

nuclei -u https://example.com -tags cve

Scan the target using a script with all tags in the exposures directory being config

nuclei -u https://example.com -tags config -t exposures/

You can set the security level and author of the selected script

nuclei -u https://example.com  -severity critical,high -author geeknik

You can also run templates based on dsl expressions

nuclei -tc "contains(id,'xss') || contains(tags,'xss')"
nuclei -tc "contains(tags,'cve') && contains(tags,'ssrf')"
nuclei -tc "contains(name, 'Local File Inclusion')"

Save results to res.txt

nuclei -l urls.txt -o results.txt

nuclei can pass a list of URLs via piped standard input (STDIN)

cat urls.txt | nuclei -o results.txt

docker call

cat urls.txt | docker run -v /path/to/nuclei-templates:/app/nuclei-templates -v /path/to/nuclei/config:/app/.nuclei-config.json -i projectdiscovery/nuclei -t /app/nuclei-templates/files/git-config.yaml > results.txt

3. Use optimization

rate limit

Nuclei has a variety of ways to control the rate, including executing multiple templates in parallel, checking multiple hosts in parallel, and enabling nuclei to limit the global request rate. Here are examples.

  • -cParameters - Limit the number of templates in parallel
  • -bulk-sizeParameters - Limit the number of parallel hosts
  • -rate-limitParameters - Global Rate Limit

If you want to scan quickly or control the scan, use these flags and enter a limit number, 速率限制 only guarantees control of outgoing requests, regardless of other parameters.
Exclude template

Nuclei template contains a variety of checks, many of which are useful for attacks, but not all of them are useful. If you only want to scan a few specific templates or directories, you can use the parameters below to filter the templates or exclude certain templates.

  • Exclude template runs

    We do not recommend running all nuclei templates at the same time. If you want to exclude templates, you can use the exclude parameter to exclude specific directories or templates.

    nuclei -l urls.txt -t nuclei-templates -exclude panels/ -exclude technologies -exclude files/wp-xmlrpc.yaml
    

    Note: As shown in the example above, neither directories nor specific templates will be scanned

Hang proxy

nuclei -l xxx.txt -t xxx.yaml -proxy-url http://192.168.1.1:8080

debug

nuclei -l xxx.txt -t xxx.yaml -v -duc
nuclei -l xxx.txt -t xxx.yaml -debug -duc
nuclei -l xxx.txt -t xxx.yaml -debug-req -duc

other

# 断网环境
# -ni -stats -si 20 -rate-limit 500 -timeout 3

# 报错跳过(2.5.0 开始支持)
# -max-host-error 10

# 速率
# -rate-limit 500

# 超时时间
# -timeout 3

# 不更新
# -duc

# 无网络环境下
# -ni

# 监控
# -stats -si 60

# 无颜色
# -nc

Reference connection:

nuclei

nuclei-doc

Study notes-nuclei

Guess you like

Origin blog.csdn.net/qq_35607078/article/details/131648824