━━━ 機能 ━━━
━━━ クイックスタート ━━━
# 1. リポジトリをクローン
git clone https://github.com/Usman0220/port-scanner.git && cd port-scanner
# 2. ビルド
go build -o port-scanner main.go
# 3. 実行 — ポート5678を500ワーカー、1万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
━━━ アーキテクチャ ━━━
╔═══════════════════════════════════╗
║ ポートスキャナーエンジン ║
╚═══════════════════════════════════╝
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ IP生成器 │ │ ゴルーチン │ │ 結果 │
│ │ │ プール │ │ 収集器 │
│ ランダムIP │ │ │ │ │
│ プライベート│ │ Nワーカー │ │ チャネル │
│ 除外 │ │ 同時実行 │ │ バッファ付き │
│ 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 | ターゲット: $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
# FULL AUDIT — すべてのテンプレート
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 scanned | 847 open | 847 verified │
│ │
│ [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 │
│ │
│ [+] Done. Scanned: 30000 | Open: 847 | Verified: 847 │
└──────────────────────────────────────────────────────────────────────┘
━━━ フラグ ━━━
━━━ 対応サービス ━━━
━━━ パフォーマンス ━━━
━━━ 要件 ━━━
# Go
go version # >= 1.20
# Nuclei(オプション — 脆弱性スキャン用)
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
# Nucleiテンプレートを更新
nuclei -update-templates
━━━ 免責事項 ━━━
┌──────────────────────────────────────────────────────────────────────┐
│ │
│ ⚠️ 警告 │
│ │
│ このツールは許可されたセキュリティテストおよび研究専用です。 │
│ │
│ 明示的な許可なくネットワークをスキャンすることは違法です。 │
│ このツールは、自分が所有するシステム、またはテストのための │
│ 書面による許可を得たシステムにのみ、責任を持って使用してください。 │
│ │
│ 作者は、このツールの誤用やそれによって生じたいかなる損害に │
│ 対しても責任を負いません。 │
│ │
└──────────────────────────────────────────────────────────────────────┘
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Goで構築 · Nuclei搭載 · バグバウンティ向け
╔═╗╔═╗╔╦╗╔═╗ ╔═╗╔═╗╦═╗╦ ╦╔═╗╦═╗
╚═╗╠═╣║║║║╣ ╚═╗║╣ ╠╦╝╚╗╔╝║╣ ╠╦╝
╚═╝╩ ╩╩ ╩╚═╝ ╚═╝╚═╝╩╚═ ╚╝ ╚═╝╩╚═
