Nuclei Scanner
Nuclei Scanner Security Hardening ป้องกันแฮก Vulnerability Scanning Template YAML CVE Bug Bounty Penetration Testing Security Audit ProjectDiscovery Infrastructure
| Scanner | Type | Templates | Speed | เหมาะกับ |
|---|---|---|---|---|
| Nuclei | Template-based | 8,000+ | เร็วมาก | ทั่วไป |
| Nmap + NSE | Network | 600+ | ปานกลาง | Network Scan |
| OWASP ZAP | Web DAST | Built-in | ช้า | Web App |
| Burp Suite | Web Proxy | Extensions | ปานกลาง | Manual Testing |
| Trivy | Container/IaC | CVE DB | เร็ว | Docker K8s |
Nuclei Usage
# === Nuclei Scanner Commands ===
# Installation
# go install github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
# # or
# brew install nuclei
# # or
# docker pull projectdiscovery/nuclei:latest
# Basic Scanning
# nuclei -u https://target.com # Scan single URL
# nuclei -l urls.txt # Scan URL list
# nuclei -u https://target.com -t cves/ # CVE templates only
# nuclei -u https://target.com -severity critical, high # High severity
# nuclei -u https://target.com -as # Auto template selection
# nuclei -u https://target.com -t exposures/ # Exposed files/configs
# nuclei -u https://target.com -t misconfiguration/ # Misconfigs
# Advanced Options
# nuclei -l urls.txt -t cves/ -severity critical \
# -rate-limit 100 \ # 100 requests/sec
# -bulk-size 25 \ # 25 hosts parallel
# -concurrency 10 \ # 10 templates parallel
# -timeout 10 \ # 10 sec timeout
# -retries 2 \ # 2 retries
# -o results.txt \ # Output file
# -json \ # JSON output
# -silent # Minimal output
# Subdomain + Nuclei Pipeline
# subfinder -d target.com -silent | httpx -silent | nuclei -severity critical, high
# Custom Headers
# nuclei -u https://target.com \
# -H "Authorization: Bearer TOKEN" \
# -H "X-Custom: value"
from dataclasses import dataclass
@dataclass
class ScanResult:
vulnerability: str
severity: str
url: str
template: str
status: str
results = [
ScanResult("CVE-2024-1234 RCE", "critical", "/api/upload", "cves/2024/CVE-2024-1234", "Fixed"),
ScanResult("SQL Injection", "high", "/search?q=", "vulnerabilities/sqli", "Fixed"),
ScanResult("Open Redirect", "medium", "/redirect?url=", "vulnerabilities/redirect", "Fixed"),
ScanResult("Directory Listing", "low", "/backup/", "exposures/directory-listing", "Fixed"),
ScanResult("Missing HSTS", "info", "/", "misconfiguration/hsts", "Fixed"),
ScanResult("WordPress xmlrpc.php", "medium", "/xmlrpc.php", "technologies/wordpress", "Blocked"),
]
print("=== Nuclei Scan Results ===")
for r in results:
print(f" [{r.severity.upper()}] {r.vulnerability}")
print(f" URL: {r.url} | Template: {r.template}")
print(f" Status: {r.status}")
Custom Templates
# === Nuclei Custom Template ===
# Custom Template — Check for exposed .env file
# id: exposed-env-file
#
# info:
# name: Exposed .env File
# author: security-team
# severity: high
# description: .env file is publicly accessible
# tags: exposure, config, env
#
# http:
# - method: GET
# path:
# - "{{BaseURL}}/.env"
# - "{{BaseURL}}/../.env"
# matchers-condition: and
# matchers:
# - type: status
# status:
# - 200
# - type: word
# words:
# - "DB_PASSWORD"
# - "API_KEY"
# - "SECRET"
# condition: or
# - type: word
# words:
# - "
Security Hardening
# === Security Hardening Checklist ===
@dataclass
class HardeningItem:
category: str
item: str
command_or_config: str
priority: str
status: str
checklist = [
HardeningItem("Network", "ปิด Port ที่ไม่จำเป็น", "ufw default deny incoming && ufw allow 22,80,443", "Critical", "Done"),
HardeningItem("Network", "ตั้ง Fail2ban", "apt install fail2ban && systemctl enable fail2ban", "High", "Done"),
HardeningItem("Web", "HTTPS ทุก Endpoint", "certbot --nginx -d example.com", "Critical", "Done"),
HardeningItem("Web", "Security Headers", "add_header X-Frame-Options DENY; add_header CSP ...", "High", "Done"),
HardeningItem("Web", "WAF (ModSecurity)", "apt install libapache2-mod-security2", "High", "In Progress"),
HardeningItem("Auth", "Disable Root SSH", "PermitRootLogin no ใน /etc/ssh/sshd_config", "Critical", "Done"),
HardeningItem("Auth", "SSH Key Only", "PasswordAuthentication no ใน sshd_config", "High", "Done"),
HardeningItem("Auth", "Enable MFA", "google-authenticator สำหรับ SSH", "Medium", "Planned"),
HardeningItem("Update", "Patch ทุก CVE", "apt update && apt upgrade -y", "Critical", "Done"),
HardeningItem("Update", "Auto Security Updates", "apt install unattended-upgrades", "High", "Done"),
HardeningItem("Monitoring", "Log Monitoring", "rsyslog + logwatch ส่ง Email ทุกวัน", "High", "Done"),
HardeningItem("Backup", "Daily Backup", "cron job rsync/rclone to S3", "Critical", "Done"),
]
print("Security Hardening Checklist:")
done = sum(1 for c in checklist if c.status == "Done")
total = len(checklist)
for c in checklist:
icon = "OK" if c.status == "Done" else c.status
print(f" [{icon}] [{c.priority}] [{c.category}] {c.item}")
print(f" Command: {c.command_or_config}")
print(f"\n Progress: {done}/{total} ({done/total*100:.0f}%)")
# Nginx Security Config
nginx_security = """
# /etc/nginx/conf.d/security.conf
# add_header X-Frame-Options "DENY" always;
# add_header X-Content-Type-Options "nosniff" always;
# add_header X-XSS-Protection "1; mode=block" always;
# add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# add_header Content-Security-Policy "default-src 'self'; script-src 'self'" always;
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
#
# server_tokens off;
# client_max_body_size 10m;
# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_ciphers HIGH:!aNULL:!MD5;
"""
print(nginx_security)
เคล็ดลับ
- Scan: สแกนด้วย Nuclei ทุกสัปดาห์ หรือหลัง Deploy
- Patch: แก้ไข Critical และ High ทันที ไม่รอ
- Headers: ตั้ง Security Headers ทุก Endpoint
- Firewall: ปิด Port ที่ไม่จำเป็น เปิดเฉพาะ 80 443
- Monitor: ตรวจสอบ Log ทุกวัน ตั้ง Alert ผิดปกติ
แนวทางป้องกันภัยไซเบอร์สำหรับองค์กรไทย
ภัยคุกคามทางไซเบอร์ในปี 2026 มีความซับซ้อนมากขึ้น Ransomware ยังคงเป็นภัยอันดับหนึ่ง โดยผู้โจมตีใช้ AI ช่วยสร้าง Phishing Email ที่แนบเนียนขึ้น องค์กรควรมี Multi-Layered Security ตั้งแต่ Perimeter Defense ด้วย Next-Gen Firewall Endpoint Protection ด้วย EDR Solution และ Network Detection and Response
การฝึกอบรมพนักงานเป็นสิ่งสำคัญที่สุด เพราะ Human Error เป็นสาเหตุหลักของการรั่วไหลข้อมูล ควรจัด Security Awareness Training อย่างน้อยไตรมาสละครั้ง ทำ Phishing Simulation ทดสอบพนักงาน และมี Incident Response Plan ที่ชัดเจน ฝึกซ้อมเป็นประจำ
สำหรับกฎหมาย PDPA ของไทย องค์กรต้องมี Data Protection Officer แจ้งวัตถุประสงค์การเก็บข้อมูลอย่างชัดเจน ขอ Consent ก่อนใช้ข้อมูลส่วนบุคคล มีมาตรการรักษาความปลอดภัยที่เหมาะสม และแจ้งเหตุ Data Breach ภายใน 72 ชั่วโมง
Nuclei Scanner คืออะไร
Open Source Vulnerability Scanner ProjectDiscovery Template YAML 8,000+ HTTP DNS SSL Network Bug Bounty Penetration Testing Security Audit
ใช้ Nuclei สแกนอย่างไร
nuclei -u URL -l list -t templates -severity critical high -as Auto Selection -rate-limit -o output -json subfinder httpx Pipeline
เขียน Nuclei Template อย่างไร
YAML id info name severity requests method path matchers status word regex extractors Community Templates Custom Template
Security Hardening ทำอย่างไร
สแกน Nuclei แก้ Critical High Patch CVE ปิด Port Firewall WAF HTTPS Security Headers SSH Key MFA Log Monitor Backup
สรุป
Nuclei Scanner Security Hardening ป้องกันแฮก Vulnerability Scanning Template YAML CVE Patch Firewall WAF HTTPS Headers SSH MFA Monitoring Backup Production
