Nuclei 漏洞掃描工具完整指南

使用 ProjectDiscovery Nuclei 進行自動化漏洞掃描,支援數千種漏洞模板,適合 Bug Bounty 和滲透測試

專案簡介

Nuclei 是 ProjectDiscovery 開發的快速漏洞掃描工具,使用 YAML 模板定義掃描規則。擁有社群維護的數千種模板,涵蓋 CVE、錯誤設定、敏感資訊洩露等。

GitHub Stars: 27K+

主要功能

  • 模板驅動 - 使用 YAML 定義掃描規則
  • 高效能 - Go 語言開發,支援大規模掃描
  • 社群模板 - 數千種現成的漏洞檢測模板
  • 自訂模板 - 可撰寫自己的檢測規則
  • 多協定支援 - HTTP、DNS、TCP、SSL 等

安裝

Go Install

1
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest

Homebrew

1
brew install nuclei

Docker

1
docker pull projectdiscovery/nuclei:latest

更新模板

1
nuclei -update-templates

基本使用

掃描單一目標

1
nuclei -u https://example.com

掃描多個目標

1
nuclei -l targets.txt

指定模板

1
2
3
4
5
6
7
8
# 使用特定模板
nuclei -u https://example.com -t cves/

# 使用多個模板目錄
nuclei -u https://example.com -t cves/ -t vulnerabilities/

# 排除模板
nuclei -u https://example.com -exclude-templates dos/

依嚴重度過濾

1
2
3
4
5
# 只掃描 critical 和 high
nuclei -u https://example.com -severity critical,high

# 排除 info 等級
nuclei -u https://example.com -exclude-severity info

進階選項

效能調整

1
2
3
4
5
# 調整並行數
nuclei -l targets.txt -c 50 -rl 150

# -c: 並行模板數
# -rl: 每秒請求限制

輸出格式

1
2
3
4
5
6
7
8
# JSON 輸出
nuclei -u https://example.com -json -o results.json

# Markdown 輸出
nuclei -u https://example.com -me output/

# SARIF 格式(整合 CI/CD)
nuclei -u https://example.com -sarif-export results.sarif

代理設定

1
2
3
4
5
# HTTP 代理
nuclei -u https://example.com -proxy http://127.0.0.1:8080

# 搭配 Burp Suite
nuclei -u https://example.com -proxy http://127.0.0.1:8080 -H "Cookie: session=xxx"

模板語法

基本結構

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
id: example-detection

info:
  name: Example Vulnerability Detection
  author: your-name
  severity: high
  description: 描述這個漏洞
  tags: cve,example

http:
  - method: GET
    path:
      - "{{BaseURL}}/vulnerable-endpoint"
    matchers:
      - type: word
        words:
          - "vulnerable response"

HTTP 請求模板

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
id: sql-injection-check

info:
  name: SQL Injection Check
  severity: critical

http:
  - method: GET
    path:
      - "{{BaseURL}}/search?q=test'"
    matchers-condition: and
    matchers:
      - type: word
        words:
          - "SQL syntax"
          - "mysql_fetch"
        condition: or
      - type: status
        status:
          - 500

使用變數

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
http:
  - raw:
      - |
        POST /login HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/json

        {"username":"{{username}}","password":"{{password}}"}        
    payloads:
      username:
        - admin
        - administrator
      password:
        - admin123
        - password
    attack: clusterbomb

Workflow 模板

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
id: wordpress-workflow

info:
  name: WordPress Security Check
  author: your-name

workflows:
  - template: technologies/wordpress-detect.yaml
    subtemplates:
      - template: vulnerabilities/wordpress/*.yaml

實戰範例

Bug Bounty 流程

1
2
3
4
5
6
7
8
# 1. 子域名收集
subfinder -d target.com -o subdomains.txt

# 2. 存活檢測
httpx -l subdomains.txt -o alive.txt

# 3. 漏洞掃描
nuclei -l alive.txt -t cves/ -t vulnerabilities/ -severity critical,high -o findings.txt

CI/CD 整合

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# .github/workflows/security-scan.yml
name: Security Scan
on: [push]
jobs:
  nuclei:
    runs-on: ubuntu-latest
    steps:
      - uses: projectdiscovery/nuclei-action@main
        with:
          target: https://example.com
          templates: cves/
          sarif-export: nuclei.sarif
      - uses: github/codeql-action/upload-sarif@v3
        with:
          sarif_file: nuclei.sarif

自動化監控

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#!/bin/bash
# daily-scan.sh
nuclei -l targets.txt \
  -t cves/ \
  -severity critical,high \
  -new-templates \
  -json -o "scans/$(date +%Y%m%d).json"

# 比對新發現
diff scans/$(date +%Y%m%d).json scans/$(date -d "yesterday" +%Y%m%d).json

常用模板分類

分類說明
cves/CVE 漏洞檢測
vulnerabilities/已知漏洞
exposures/敏感資訊洩露
misconfiguration/錯誤設定
default-logins/預設憑證
takeovers/子域名接管
technologies/技術偵測

相關連結

延伸閱讀

comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy