Automating Infrastructure Security: A Hands-On Guide to Nuclei

Security tutorial - IT technology blog
Security tutorial - IT technology blog

Why Manual Audits Don’t Scale

Spinning up a fresh Linux server feels great, but the honeymoon ends the moment you face your first security audit. After watching my logs fill up with over 5,000 failed SSH login attempts in a single midnight window, I stopped relying on luck. Manual audits are grueling. If you manage more than two or three machines, human error isn’t just a possibility—it is a mathematical certainty. That is why I integrated Nuclei into my daily stack.

Nuclei is a fast, template-based scanner that sends requests across protocols like HTTP, DNS, and TCP. Unlike heavy enterprise tools that bury you in complex UIs, Nuclei treats security as code. It is backed by a community that often releases vulnerability templates within hours of a new CVE announcement. Currently, the project boasts over 7,000 verified templates, ranging from simple version checks to complex multi-step exploits.

Quick start: Your first scan in under 5 minutes

Deploying Nuclei on a Linux box is painless. Since it is written in Go, it runs as a single portable binary.

Step 1: Installation

For systems with the Go toolchain already configured, use:

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

If you prefer a direct approach, the official script handles the heavy lifting:

curl -sL https://raw.githubusercontent.com/projectdiscovery/nuclei/master/install.sh | bash

Step 2: Syncing the Template Library

Nuclei is only as smart as its templates. Download the latest community-verified checks by running:

nuclei -update-templates

Step 3: Launching the Scan

Point the tool at your domain or IP to hunt for obvious vulnerabilities:

nuclei -u http://your-server-ip.com

The output is color-coded by severity. You will immediately see if your server is leaking sensitive info or running outdated software marked as Medium, High, or Critical.

Under the Hood: Templates and Logic

The real strength of Nuclei is its transparency. Traditional scanners are often “black boxes,” but you can open any Nuclei YAML file to see exactly how a test works. Each template defines a specific request and a “matcher” that identifies the vulnerability in the response.

Breaking down a check

Navigate to ~/nuclei-templates/ to explore categories like cves and exposed-panels. A typical check looks like this:

id: exposed-git-directory
info:
  name: Exposed Git Directory
  severity: medium
requests:
  - method: GET
    path:
      - "{{BaseURL}}/.git/config"
    matchers:
      - type: word
        words:
          - "[core]"

This simple logic allows you to write custom rules for your company’s specific policies in minutes. You aren’t just scanning for public bugs; you are enforcing your own architectural standards.

Smart Filtering

Running 7,000+ tests every time is overkill. If you only care about critical Remote Code Execution (RCE) flaws, use severity tags:

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

To audit server hardening specifically, target the misconfiguration directory:

nuclei -u https://example.com -t misconfiguration/

Advanced Workflow: Automating Like a Pro

Manual commands are for testing. Professional environments require automation. I use a simple cron job to run scans weekly and pipe the results to my team.

Handling Multiple Targets

If you manage a fleet of internal IPs or staging subdomains, list them in targets.txt:

nuclei -l targets.txt -o results.txt

JSON Output for Data Pipelines

For serious reporting, export your findings to JSON. This allows you to use jq to filter results or feed them into a centralized dashboard.

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

CI/CD Integration

Integrating Nuclei into GitHub Actions ensures that every deployment is scanned before it goes live. This catches vulnerabilities in your staging environment before they reach production. A basic step looks like this:

- name: Run Nuclei Scan
  uses: projectdiscovery/nuclei-action@main
  with:
    target: https://example.com

Practical Tips for Real-World Usage

Data is great, but noise is the enemy. After running Nuclei across dozens of production environments, I recommend these adjustments to avoid “security fatigue”:

  • Respect the Hardware: Nuclei is incredibly fast. Default settings can easily overwhelm a small 1vCPU VPS. Use -rate-limit 10 to keep your CPU usage in check.
  • Silencing False Positives: If a specific template triggers a false alarm on your stack, add it to a .nuclei-ignore file to keep your reports clean.
  • Out-of-Band Detection: Some bugs, like Log4j, don’t show up in a standard response. Nuclei uses interactsh to catch these “blind” vulnerabilities automatically.
  • Daily Updates: Set a cron job to run nuclei -update-templates every morning. This ensures you are protected against exploits discovered just hours ago.

Infrastructure security is a moving target. By automating your scans, you stop playing catch-up and start building with confidence. It is much better to have a robot checking your back door than to wait for a 3 AM notification that your data is gone.

Share: