TDCTF Academy Logo TDCTF ACADEMY

Nuclei: Template-Based Vulnerability Scanner

Pengertian Nuclei

Nuclei adalah fast vulnerability scanner berbasis template yang dikembangkan oleh ProjectDiscovery. Tidak seperti scanner tradisional yang menggunakan signatures hardcoded, Nuclei menggunakan file YAML sebagai template untuk mendefinisikan deteksi kerentanan. Setiap template berisi request, matchers, dan extractors yang dapat dijalankan terhadap target secara massal.

Nuclei dirancang untuk kecepatan dan fleksibilitas - mampu memindai ribuan host dengan ribuan template secara paralel dalam hitungan menit. Dengan komunitas yang aktif, template ecosystem Nuclei terus bertambah ribuan deteksi setiap bulannya, mencakup CVE, misconfiguration, exposed panels, dan teknik-teknik keamanan lainnya.

Arsitektur dan Cara Kerja

Nuclei bekerja dalam alur sebagai berikut:

  1. Input Target - menerima daftar host (URL, IP, domain) dari file, stdin, atau hasil tools lain (httpx, subfinder)
  2. Template Loading - memuat template YAML dari direktori lokal atau GitHub (nuclei-templates)
  3. Protocol Engine - mengeksekusi template sesuai protokol (HTTP, DNS, TCP, dll)
  4. Matching and Extraction - mencocokkan response dengan matchers dan mengekstrak data dengan extractors
  5. Output - hasil ditampilkan di terminal dan/atau diekspor ke berbagai format
Input Target -> Template Loading -> Protocol Engine -> Matchers/Extractors -> Output
| | | | |
host:443 CVE-2024-xxx.yaml HTTP Request status: 200 terminal
domain.com tech-detect.yaml DNS Query regex match JSON

Struktur Template YAML

Setiap template Nuclei memiliki struktur dasar yang terdiri dari beberapa bagian utama:

ID dan Info

id: apache-log4j-rce

info:
name: Apache Log4j Remote Code Execution
author: pd-team
severity: critical
description: Deteksi kerentanan Log4Shell pada Apache Log4j
reference:
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-44228
tags: cve,cve2021,rce,log4j,apache

Requests

Bagian ini mendefinisikan HTTP request yang akan dikirim:

requests:
- method: GET
path:
- "{{BaseURL}}/{{payload}}"
headers:
User-Agent: "Mozilla/5.0"
payloads:
payload:
- "${jndi:ldap://{{interactsh-url}}/a}"

Matchers

Matchers digunakan untuk menentukan apakah suatu kerentanan terdeteksi:

matchers-condition: and
matchers:
- type: word
words:
- "ClassLoader"
- "java"
condition: or

- type: status
status:
- 200
- 500

- type: dsl
dsl:
- "len(body) > 100"

Extractors

Extractors digunakan untuk mengambil data tertentu dari response:

extractors:
- type: regex
group: 1
regex:
- "Server: (.+)"
- "X-Powered-By: (.+)"

- type: kval
kval:
- content_type
- server_header

Jenis-Jenis Template

Nuclei mendukung berbagai protokol melalui tipe template yang berbeda:

HTTP Template (paling umum)

http:
- method: GET
path:
- "{{BaseURL}}/?author=1"
- "{{BaseURL}}/wp-json/wp/v2/users"

matchers:
- type: word
words:
- "author-post"
- "rest_user"

DNS Template

dns:
- name: "{{FQDN}}"
type: A
class: inet

matchers:
- type: word
words:
- "127.0.0.1"
- "0.0.0.0"

TCP Template

tcp:
- host: "{{Hostname}}"
port: 22
inputs:
- data: "SSH-2.0-\r\n"
- read: 1024

matchers:
- type: word
words:
- "OpenSSH"
- "Dropbear"

Network Template (raw bytes)

network:
- inputs:
- data: "GET / HTTP/1.1\r\nHost: {{Hostname}}\r\n\r\n"

matchers:
- type: word
words:
- "Apache/2.4"

Headless Template (browser-based)

headless:
- steps:
- action: navigate
args:
url: "{{BaseURL}}/login"

- action: waitload
- action: screenshot

SSL Template

ssl:
- address: "{{Host}}:{{Port}}"

matchers:
- type: word
words:
- "TLSv1.0"
- "TLSv1.1"

Websocket Template

websocket:
- address: "ws://{{Host}}/ws"
inputs:
- data: '{"action":"ping"}'

matchers:
- type: word
words:
- "pong"

Workflow dan Fuzzing

Workflow

Menjalankan template secara berurutan dan bersyarat:

id: wordpress-full-audit

workflows:
- template: technologies/wordpress-detect.yaml
subtemplates:
- template: vulnerabilities/wp-user-enum.yaml
- template: vulnerabilities/wp-xmlrpc.yaml
- template: exploits/wp-brute-force.yaml

Jalankan:

nuclei -w wordpress-full-audit.yaml -u https://target.com

Fuzzing dengan Payload

http:
- method: GET
path:
- "{{BaseURL}}/api/user/{{user_id}}"
payloads:
user_id:
- 1
- 2
- 3
- admin
- ../../../etc/passwd
fuzzing:
- part: path
type: replace
mode: single

Tags, Filters, dan Rate Limiting

Tags

nuclei -u https://target.com -tags cve,rce,critical
nuclei -u https://target.com -tags wordpress,plugin

Severity Filters

nuclei -u https://target.com -severity critical,high
nuclei -u https://target.com -severity medium,high,critical

Rate Limiting

# Rate limit: 150 request/detik
nuclei -u https://target.com -rate-limit 150 -rate-limit-duration 1s

# Jeda antar request (milidetik)
nuclei -u https://target.com -delay 500

# Concurrency: jumlah template paralel
nuclei -u https://target.com -concurrency 30

# Bulk size: host dipindai paralel
nuclei -u https://target.com -bulk-size 25

Format Output

Terminal Output

nuclei -u https://target.com -o results.txt

JSON Output (Machine-Readable)

nuclei -u https://target.com -json -o results.json

CSV / JSONL

nuclei -u https://target.com -jsonl -o results.jsonl

Markdown Report

nuclei -u https://target.com -me ./report/

SARIF Output

nuclei -u https://target.com -sarif -o report.sarif

Contoh Penggunaan Nyata

1. Scanning CVE Terbaru

nuclei -update-templates
nuclei -u https://target.com -tags cve -severity critical,high
nuclei -u https://target.com -id CVE-2024-xxx,CVE-2023-yyy

2. Custom Template Creation

Buat file mongodb-exposed.yaml:

id: custom-mongodb-exposed

info:
name: MongoDB Exposed Without Auth
author: security-team
severity: high
description: Mendeteksi MongoDB tanpa autentikasi

network:
- host: "{{Hostname}}"
port: 27017
inputs:
- data: "Hello MongoDB"
- read: 1024

matchers:
- type: word
words:
- "buildInfo"
- "ok"

extractors:
- type: regex
part: data
regex:
- "version\\\":\\\"([0-9.]+)\\\""

Jalankan:

nuclei -t mongodb-exposed.yaml -l targets.txt

3. Nuclei + CI/CD Integration (GitHub Actions)

name: Security Scan with Nuclei

on:
schedule:
- cron: '0 6 * * 1'
push:
branches: [main]

jobs:
nuclei-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Nuclei
run: |
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest

- name: Update Templates
run: nuclei -update-templates

- name: Run Scan
run: |
nuclei -u https://staging.example.com -severity critical,high -json -o scan.json

- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: nuclei-scan-results
path: scan.json

4. Pipeline Multi-Target

cat domains.txt | httpx -silent | nuclei -t ~/nuclei-templates/ -severity critical,high -json

5. Integrasi Alert

nuclei -u https://target.com -json | jq -r '"\(.info.severity) - \(.info.name) on \(.host)"' | while read line; do curl -X POST -H "Content-Type: application/json" -d "{\"content\":\"$line\"}" \$WEBHOOK_URL; done

Template Playground

Nuclei menyediakan playground online: https://playground.nuclei.sh

Fitur:

  • Editor YAML dengan syntax highlighting
  • Preview matchers dan extractors
  • Simulasi eksekusi template
  • Export template ke file

Validasi template lokal:

nuclei -validate -t custom-template.yaml
nuclei -validate -t ~/nuclei-templates/

Tips dan Best Practices

  1. Gunakan Rate Limiting - Mulai dengan -rate-limit 50 lalu naikkan perlahan untuk target produksi
  2. Filter Template - Gunakan -tags untuk mempersempit cakupan daripada menjalankan ribuan template
  3. Autentikasi - Gunakan -header untuk Authorization token pada aplikasi internal
  4. Interactsh - Terintegrasi untuk blind vulnerabilities (SSRF, Blind RCE)
  5. Update Templates Rutin - Jalankan nuclei -update-templates secara berkala
  6. Pipeline - Nuclei dirancang untuk dipipakan dengan httpx, subfinder, naabu
subfinder -d example.com | httpx -silent | nuclei -t ~/nuclei-templates/ -severity critical,high -json -o scan.json

Kesimpulan

Nuclei adalah vulnerability scanner yang mengubah pendekatan security testing dengan template YAML. Keunggulan utamanya: kecepatan eksekusi paralel, komunitas template yang masif, fleksibilitas output, dan kemudahan integrasi CI/CD. Dengan memahami struktur template, filtering, dan workflow, Nuclei menjadi toolkit wajib bagi setiap security professional.

PADA HALAMAN INI