More Guides will be available soon, Stay tuned!
Imagine this: you run a nuclei scan, and seconds later, your terminal returns a clean, AI-analyzed summary of vulnerabilities, ranked by severity and risk, with remediation steps included.
That’s exactly what you’ll get this week.
We’re going to build ai-nuclei—a script that:
• Runs Nuclei on a target or list
• Parses the output
• Pipes results into your local AI for risk analysis
Let’s go.
Create a new script file:
$ nano ~/.local/bin/ai-nuclei
Make sure it's in your $PATH
#!/bin/bash
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
CYAN="\033[1;36m"
BLUE="\033[1;34m"
RESET="\033[0m"
TMP_OUTPUT=$(mktemp)
TMP_RESULTS=$(mktemp)
WARNINGS_FILE=$(mktemp)
cleanup() {
rm -f "$TMP_OUTPUT" "$TMP_RESULTS" "$WARNINGS_FILE"
}
trap cleanup EXIT
validate_input() {
if [[ ! "$*" =~ (-u|-l) ]]; then
echo -e "${RED}Error: Must specify either -u (URL) or -l (file list)${RESET}"
exit 1
fi
}
parse_findings() {
awk '
/\[(http|ssl|dns|info|low|medium|high|critical)\]/ {
template = $0
sub(/.*\[/, "", template)
sub(/\].*/, "", template)
host = ""
if (match($0, /https?:\/\/[^ ]+/)) {
host = substr($0, RSTART, RLENGTH)
} else if (match($0, /([a-z0-9.-]+\.)+[a-z]{2,}(:[0-9]+)?/)) {
host = substr($0, RSTART, RLENGTH)
}
severity = "info"
if (match($0, /\[(critical|high|medium|low)\]/)) {
severity = substr($0, RSTART+1, RLENGTH-2)
}
printf "{\"template\":\"%s\",\"host\":\"%s\",\"severity\":\"%s\"}\n", template, host, severity
}' "$TMP_OUTPUT" > "$TMP_RESULTS"
}
analyze_with_ai() {
local input="$1"
timeout 20 ollama run deepseek-coder "Analyze this security finding:
${input}
Provide:
1. Risk level (1-10)
2. Business impact
3. Verification steps" 2>/dev/null || echo "AI analysis timed out"
}
validate_input "$@"
echo -e "${CYAN}[+] Running nuclei scan...${RESET}"
nuclei "$@" -silent 2>"$WARNINGS_FILE" | tee "$TMP_OUTPUT"
parse_findings
echo -e "\n${CYAN}=== Scan Results ===${RESET}"
if [[ ! -s "$TMP_RESULTS" ]]; then
echo -e "${YELLOW}[!] No findings parsed from output${RESET}"
echo -e "${BLUE}[?] Debug options:${RESET}"
echo -e "1. View raw output: ${GREEN}cat $TMP_OUTPUT${RESET}"
echo -e "2. Check warnings: ${YELLOW}cat $WARNINGS_FILE${RESET}"
exit 0
fi
while IFS= read -r line; do
template=$(echo "$line" | jq -r '.template')
host=$(echo "$line" | jq -r '.host')
severity=$(echo "$line" | jq -r '.severity')
echo -e "\n${BLUE}=== $template ===${RESET}"
echo -e "Target: ${GREEN}$host${RESET}"
echo -e "Severity: $(case "$severity" in
"critical") echo -ne "${RED}CRITICAL${RESET}" ;;
"high") echo -ne "${YELLOW}HIGH${RESET}" ;;
*) echo -ne "$severity" ;;
esac)"
analysis=$(analyze_with_ai "$template")
echo -e "${YELLOW}[AI Analysis]${RESET}\n$analysis"
done < <(jq -c '.' "$TMP_RESULTS" 2>/dev/null)
Save and make it executable:
chmod +x ~/bin/ai-nuclei
## ⚡ Usage Examples:
1. Basic Scan
$ ai-nuclei -u https://example.com -t ~/nuclei-templates
2. Filter by Severity
$ ai-nuclei -u https://example.com -severity critical,high
3. Debug Mode
$ ai-nuclei -u https://example.com -retries 3 -timeout 5
Anything that Nuclei can run, you can run with this script now.
🎯 What You Now Have
A smart, AI-enhanced vulnerability scanner that:
• Runs silently and efficiently
• Filters output into structured JSON
• Automatically provides risk analysis and mitigation help
Coming up in Week 5: You’ll learn how to automate daily CVE fetches with cron and organize your intel in Obsidian.
All the guides, tips, and tricks on this web site are for education purpose only, the website owner is not accountable for any use of this information