━━━ 功能特性 ━━━
━━━ 快速开始 ━━━
# 1. 克隆巨兽
git clone https://github.com/Usman0220/port-scanner.git && cd port-scanner
# 2. 构建
go build -o port-scanner main.go
# 3. 释放 — 扫描端口5678,500个worker,10000个IP
./port-scanner -port 5678 -w 500 -n 10000
# 4. 完整流水线 — 扫描 → 过滤 → nuclei
./port-scanner -port 80 -w 1000 -n 50000 -o http-open.txt
awk -F'[|]' '{print $1}' http-open.txt | sed 's/\[OPEN\] //' | cut -d: -f1 | sort -u > http-targets.txt
nuclei -l http-targets.txt -tags http -severity critical,high -o findings.txt
━━━ 架构 ━━━
╔═══════════════════════════════════╗
║ PORT SCANNER ENGINE ║
╚═══════════════════════════════════╝
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ IP 生成器 │ │ Goroutine │ │ 结果收集器 │
│ │ │ 池 │ │ │
│ 随机 IP │ │ │ │ 通道 │
│ 跳过私有 │ │ N 个 worker │ │ 缓冲 │
│ 1-223.x.x.x│ │ 并发 │ │ │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ TCP 连接 │ │ 发送探测包 │ │ 读取横幅 │
│ │ │ │ │ │
│ Dial 超时 │ │ 协议感知 │ │ 服务指纹 │
│ 默认 2s │ │ │ │ │
└──────────────┘ └──────────────┘ └──────────────┘
│
╔═══════════════╧═══════════════╗
║ 输出: results.txt ║
╚═══════════════╤═══════════════╝
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ awk / grep │ │ sort -u │ │ nuclei -l │
│ 提取 IP │ │ 去重 │ │ 漏洞扫描 │
└──────────────┘ └──────────────┘ └──────────────┘
│
╔═══════════════╧═══════════════╗
║ 发现结果: nuclei-*.txt ║
╚═══════════════════════════════╝
━━━ Nuclei 集成 ━━━
基础流水线
# ┌─────────────────────────────────────────────────────────────┐
# │ 步骤 1: 扫描 — 发现活跃服务 │
# │ 步骤 2: 提取 — 从结果中提取 IP │
# │ 步骤 3: 审计 — Nuclei 漏洞扫描 │
# └─────────────────────────────────────────────────────────────┘
# 扫描
./port-scanner -port 21 -w 1000 -n 50000 -o ftp-open.txt
# 提取
awk -F'[|]' '{print $1}' ftp-open.txt | sed 's/\[OPEN\] //' | cut -d: -f1 | sort -u > ftp-targets.txt
# 审计
nuclei -l ftp-targets.txt -tags ftp -severity critical,high -o ftp-findings.txt
多端口自动化流水线
#!/bin/bash
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 完整侦察流水线 — 扫描 → 提取 → Nuclei → 报告
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PORTS=(21 22 23 25 80 110 143 443 3306 5432 6379 8080 8443 9090 27017 5678)
WORKERS=1000
IPS=30000
SEVERITY="critical,high,medium"
TEMPLATES="$HOME/.local/nuclei-templates"
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ 完整侦察流水线已启动 ║"
echo "╚══════════════════════════════════════════════════════════╝"
for port in "${PORTS[@]}"; do
echo ""
echo "┌──────────────────────────────────────────────────────┐"
echo "│ [*] 正在扫描端口 $port"
echo "│ Workers: $WORKERS | 目标数: $IPS"
echo "└──────────────────────────────────────────────────────┘"
# 扫描
./port-scanner -port $port -w $WORKERS -n $IPS -o "scan-port${port}.txt"
# 提取目标
awk -F'[|]' '{print $1}' "scan-port${port}.txt" | \
sed 's/\[OPEN\] //' | cut -d: -f1 | sort -u > "targets-port${port}.txt"
count=$(wc -l < "targets-port${port}.txt")
echo "[+] 在端口 $port 上发现 $count 个活跃主机"
# Nuclei 审计
if [ "$count" -gt 0 ]; then
echo "[*] 正在对端口 $port 运行 Nuclei 模板..."
nuclei -l "targets-port${port}.txt" \
-p-port $port \
-t "$TEMPLATES" \
-severity $SEVERITY \
-o "nuclei-port${port}.txt" \
-silent -stats
vulns=$(wc -l < "nuclei-port${port}.txt" 2>/dev/null || echo "0")
echo "[!] 在端口 $port 上发现 $vulns 个漏洞"
fi
done
# 合并所有发现结果
echo ""
echo "┌──────────────────────────────────────────────────────┐"
echo "│ [*] 正在合并所有发现结果 │"
echo "└──────────────────────────────────────────────────────┘"
cat nuclei-port*.txt 2>/dev/null | sort -u > all-findings.txt
total=$(wc -l < "all-findings.txt" 2>/dev/null || echo "0")
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ 流水线完成 ║"
echo "║ 漏洞总数: $total"
echo "║ 报告: all-findings.txt"
echo "╚══════════════════════════════════════════════════════════╝"
按服务的 Nuclei 命令
# ┌─────────────────────────────────────────────────────────────┐
# │ 服务特定的 Nuclei 扫描 │
# └─────────────────────────────────────────────────────────────┘
# FTP — 匿名登录、暴力破解、已知 CVE
nuclei -l targets.txt -tags ftp -severity critical,high
# SSH — 弱加密算法、用户枚举、CVE
nuclei -l targets.txt -tags ssh -severity critical,high,medium
# HTTP — 完整 Web 审计 (XSS, SQLi, LFI, RCE, 配置错误)
nuclei -l targets.txt -tags http -severity critical,high,medium,low
# MySQL — 弱认证、CVE、配置错误
nuclei -l targets.txt -tags mysql -severity critical,high
# Redis — 未授权访问、模块加载
nuclei -l targets.txt -tags redis -severity critical,high
# MongoDB — 无认证、CVE
nuclei -l targets.txt -tags mongodb -severity critical,high
# PostgreSQL — 弱认证、CVE
nuclei -l targets.txt -tags postgresql -severity critical,high
# n8n — God Mode 利用, CVE-2025-68613
nuclei -l targets.txt -tags n8n -severity critical
# Jenkins — 脚本控制台、CVE
nuclei -l targets.txt -tags jenkins -severity critical,high
# Grafana — 路径遍历、CVE
nuclei -l targets.txt -tags grafana -severity critical,high
# 完整审计 — 所有内容
nuclei -l targets.txt -t ~/.local/nuclei-templates/ -severity critical,high,medium,low
━━━ 扫描模式 ━━━
单端口扫描
./port-scanner -port 443 -w 500 -n 10000 -o results.txt
高速扫描
./port-scanner -port 80 -w 2000 -n 100000 -o results.txt
快速侦察
./port-scanner -port 5678 -w 100 -n 5000 -timeout 1s
深度扫描(较慢但彻底)
./port-scanner -port 22 -w 200 -n 50000 -timeout 5s -o deep-scan.txt
━━━ 实际输出示例 ━━━
┌──────────────────────────────────────────────────────────────────────┐
│ [*] 15234/30000 已扫描 | 847 个开放 | 847 已验证 │
│ │
│ [OPEN] 103.21.244.12:80 | HTTP/Apache | HTTP/1.1 200 OK │
│ [OPEN] 198.51.100.45:22 | SSH | SSH-2.0-OpenSSH_8.9p1 │
│ [OPEN] 203.0.113.88:3306 | MySQL | 5.7.42-0ubuntu0.18.04.1 │
│ [OPEN] 192.0.2.15:6379 | Redis | Redis server version 7.0.11 │
│ [OPEN] 198.51.100.200:5678 | n8n | n8n v1.19.0 │
│ [OPEN] 203.0.113.55:27017 | MongoDB | MongoDB 6.0.4 │
│ [OPEN] 103.21.244.90:8080 | HTTP/Nginx | HTTP/1.1 200 OK │
│ [OPEN] 198.51.100.120:5432 | PostgreSQL | PostgreSQL 15.3 │
│ │
│ [+] 完成。已扫描: 30000 | 开放: 847 | 已验证: 847 │
└──────────────────────────────────────────────────────────────────────┘
━━━ 参数标志 ━━━
━━━ 支持的服务 ━━━
━━━ 性能 ━━━
━━━ 要求 ━━━
# Go
go version # >= 1.20
# Nuclei(可选 — 用于漏洞扫描)
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
# 更新 Nuclei 模板
nuclei -update-templates
━━━ 免责声明 ━━━
┌──────────────────────────────────────────────────────────────────────┐
│ │
│ ⚠️ 警告 │
│ │
│ 本工具仅供授权的安全测试和研究使用。 │
│ │
│ 未经明确许可扫描网络属于违法行为。 │
│ 请负责任地使用本工具,仅对您拥有或已获得书面授权的系统进行测试。 │
│ │
│ 作者不对因滥用本工具造成的任何损害或损失承担责任。 │
│ │
└──────────────────────────────────────────────────────────────────────┘
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
使用 Go 构建 · 由 Nuclei 驱动 · 专为漏洞赏金而生
╔═╗╔═╗╔╦╗╔═╗ ╔═╗╔═╗╦═╗╦ ╦╔═╗╦═╗
╚═╗╠═╣║║║║╣ ╚═╗║╣ ╠╦╝╚╗╔╝║╣ ╠╦╝
╚═╝╩ ╩╩ ╩╚═╝ ╚═╝╚═╝╩╚═ ╚╝ ╚═╝╩╚═
