Network Security & Traffic Analysis について
Network Security & Traffic Analysisは、トラフィック分析、検知ルール作成、ネットワーク設定のレビューを行う担当者向けのClaudeスキルです。PCAP、Suricata、Snort、Zeekに加え、ファイアウォールやネットワーク構成の評価を扱います。
主な機能
- 01PCAPトラフィックと不審な通信の分析
- 02SuricataとSnortのルール作成
- 03Zeekのネットワーク分析スクリプト作成
- 04ファイアウォールルールと設定のレビュー
- 05ネットワーク分割と構成セキュリティの評価
活用シーン
- 01PCAPからDNSトンネリングやデータ流出を調査
- 02IDS検知ルールの作成とテスト
- 03ファイアウォールルールの公開リスクを確認
- 04ネットワーク分割と東西トラフィック制御を評価
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ masriyan/ claude-code-cybersecurity-skill --skill network-security-&-traffic-analysisインストール後、Claude Code で/network-security-&-traffic-analysisを入力して読み込まれたか確認します。
同梱ファイルexamples/example_usage.mdscripts/pcap_analyzer.py
詳細
ネットワークセキュリティとトラフィック分析
目的
PCAP ファイルからのトラフィック分析、Snort および Suricata 向け IDS/IPS ルールの作成、ファイアウォールルールの監査、ネットワークの異常検知、ネットワークアーキテクチャのセキュリティレビューなど、ネットワークセキュリティ運用を Claude が支援できるようにします。
有効化の条件
次のような依頼があった場合に、このスキルが有効になります。
- 不審なアクティビティを調べるために、PCAP または PCAPNG ファイルを分析する
- Snort または Suricata の検知ルールを作成する
- ネットワーク分析用の Zeek(Bro)スクリプトを作成する
- ファイアウォールルール(iptables、nftables、pf、クラウドセキュリティグループ)をレビューする
- ネットワークトラフィックから C2 ビーコニング、DNS トンネリング、データ流出を検知する
- ネットワークアーキテクチャのセキュリティレビューを行う
- IDS/IPS シグネチャを開発する
- ネットワークセグメンテーションと東西トラフィックを分析する
- TLS インスペクションと証明書を分析する
前提条件
pip install scapy dpkt requests
推奨ツール:
Wireshark / tshark— パケットキャプチャと GUI 分析Suricata— 最新の IDS/IPS エンジンSnort 3— 従来型の IDS/IPS エンジンZeek (Bro)— ネットワーク分析およびスクリプト作成フレームワークtcpdump— コマンドラインでのパケットキャプチャNetworkMiner— PCAP アーティファクトの抽出nmap— ネットワークのスキャンと検出
主な機能
1. PCAP トラフィック分析
ユーザーが PCAP ファイルを提供した場合、またはネットワークトラフィックの分析を依頼した場合:
# Quick summary with tshark
tshark -r capture.pcap -q -z io,phs # Protocol hierarchy
tshark -r capture.pcap -q -z conv,tcp # TCP conversations
tshark -r capture.pcap -q -z endpoints,ip # IP endpoints
# Extract HTTP requests
tshark -r capture.pcap -Y http.request -T fields -e ip.src -e http.host -e http.request.uri
# Extract DNS queries
tshark -r capture.pcap -Y dns.flags.response==0 -T fields -e ip.src -e dns.qry.name
# Extract files
tshark -r capture.pcap --export-objects http,./extracted_files/
tshark -r capture.pcap --export-objects smb,./smb_files/
# Run automated analysis
python scripts/pcap_analyzer.py --file capture.pcap --output analysis.json
python scripts/pcap_analyzer.py --file traffic.pcapng --dns --http --top-talkers 20
トラフィック分析チェックリスト:
[ ] Protocol distribution — any unexpected protocols?
[ ] Top talkers — unusual source/destination combinations
[ ] DNS analysis — DGA domains, unusually long queries, high volume
[ ] HTTP analysis — suspicious user agents, unusual methods, encoded data
[ ] TLS analysis — invalid certificates, unusual SNI, cert fingerprints
[ ] ICMP analysis — large payloads (tunneling), ping sweeps
[ ] SMB analysis — authentication attempts, file access patterns
[ ] Data volume — large uploads (exfiltration?), irregular transfer sizes
[ ] Timing analysis — regular interval beaconing patterns
ビーコニングの検知: ビーコニングは、外向き接続の間隔が一定であることで確認できます。
# tshark: extract connection timestamps to check for regularity
tshark -r capture.pcap -Y "ip.dst == 203.0.113.10 and tcp.flags.syn==1" \
-T fields -e frame.time_epoch | \
awk 'NR>1{printf "%.0f\n", ($1-prev)} {prev=$1}' | sort | uniq -c | sort -rn
# Consistent counts at specific intervals = beaconing
DNS トンネリングの検知:
# Long DNS query names (>50 chars for subdomain) = likely tunneling
tshark -r capture.pcap -Y "dns.qry.name.len > 50" \
-T fields -e ip.src -e dns.qry.name | head -50
# High-volume DNS to single domain = tunneling
tshark -r capture.pcap -Y "dns" -T fields -e dns.qry.name | \
awk -F. '{print $(NF-1)"."$NF}' | sort | uniq -c | sort -rn | head -20
2. Suricata ルールの作成
ユーザーが Suricata IDS ルールの作成を依頼した場合:
Suricata ルール構文リファレンス:
action protocol src_ip src_port -> dst_ip dst_port (options)
ルールテンプレート:
# Template: C2 Beaconing over HTTP
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"MALWARE Suspicious C2 Beacon - Regular Interval HTTP POST";
flow:established,to_server;
http.method; content:"POST";
http.uri; content:"/api/check" endswith;
http.header; content:"User-Agent: Mozilla/4.0 (compatible)";
threshold:type both, track by_src, count 5, seconds 300;
classtype:trojan-activity;
sid:9000001;
rev:1;
metadata:affected_product Windows_XP_Vista_7_8_10_Server, attack_target Client_Endpoint,
created_at 2025_05_28, deployment Perimeter;
)
# Template: DNS Tunneling Detection
alert dns $HOME_NET any -> any any (
msg:"POLICY Possible DNS Tunneling - Long Subdomain Query";
dns.query;
content:".";
byte_test:1,>,50,0,relative; # Query length > 50 chars
threshold:type both, track by_src, count 20, seconds 60;
classtype:policy-violation;
sid:9000002;
rev:1;
)
# Template: Lateral Movement via SMB
alert smb $HOME_NET any -> $HOME_NET 445 (
msg:"LATERAL-MOVEMENT PsExec Lateral Movement Detected";
flow:established,to_server;
content:"PSEXESVC";
nocase;
classtype:trojan-activity;
sid:9000003;
rev:1;
)
# Template: Data Exfiltration - Large Upload
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"EXFILTRATION Possible Data Exfiltration - Large HTTP POST";
flow:established,to_server;
http.method; content:"POST";
http.request_body; content:!"";
dsize:>1000000; # > 1MB body
threshold:type both, track by_src, count 3, seconds 300;
classtype:policy-violation;
sid:9000004;
rev:1;
)
# Template: Malicious TLS Certificate (self-signed with suspicious CN)
alert tls $EXTERNAL_NET any -> $HOME_NET any (
msg:"MALWARE Suspicious TLS Certificate - Self-Signed C2";
tls.cert_subject; content:"CN=localhost";
tls.cert_issuer; content:"CN=localhost";
classtype:trojan-activity;
sid:9000005;
rev:1;
)
# Template: Web Shell Access
alert http $EXTERNAL_NET any -> $HOME_NET 80 (
msg:"WEBSHELL Possible Web Shell Access";
flow:established,to_server;
http.uri; content:".php";
http.request_body; content:"cmd="; nocase;
content:"exec"; nocase; distance:0;
classtype:web-application-attack;
sid:9000006;
rev:1;
)
Suricata のテスト:
# Test rules against PCAP (offline)
suricata -r capture.pcap -S custom.rules -l ./logs/
# Test rule syntax
suricata --dump-config
# Check for rule performance issues
suricata -r test.pcap -S rules.rules --runmode single 2>&1 | grep "perf"
3. Snort 3 ルールの作成
# Snort 3 format — note different syntax from Snort 2
alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS 80 (
msg:"WEB-ATTACK SQL Injection Attempt";
flow:established,to_server;
http_uri;
content:"' OR '1'='1";
nocase;
sid:9001001;
rev:1;
classtype:web-application-attack;
)
4. Zeek スクリプトのテンプレート
# Detect connections with unusually regular intervals (beaconing)
module BeaconDetect;
export {
redef enum Log::ID += { LOG };
type Info: record {
ts: time &log;
src: addr &log;
dst: addr &log;
interval: interval &log;
};
}
global connection_times: table[addr, addr] of vector of time;
event connection_established(c: connection) {
local key = [c$id$orig_h, c$id$resp_h];
if (key !in connection_times)
connection_times[key] = vector();
connection_times[key] += network_time();
}
event connection_state_remove(c: connection) {
local key = [c$id$orig_h, c$id$resp_h];
if (key in connection_times && |connection_times[key]| > 5) {
# Calculate intervals and check for regularity
# Flag if standard deviation < 5% of mean
}
}
5. ファイアウォール設定の監査
ユーザーがファイアウォールルールを提供した場合、または監査を依頼した場合:
iptables レビューチェックリスト:
# View current rules
iptables -L -n -v --line-numbers
iptables -L INPUT -n -v --line-numbers
iptables -L OUTPUT -n -v --line-numbers
# Check for dangerous rules:
iptables -L | grep "ACCEPT" # List all ACCEPT rules
iptables -L | grep "0.0.0.0" # Any-source rules
iptables セキュリティチェックリスト:
[ ] Default policy is DROP (not ACCEPT) for all chains
[ ] INPUT chain: only established/related + specific allowed services
[ ] OUTPUT chain: restrict to necessary outbound (optional but best practice)
[ ] FORWARD chain: DROP by default unless this is a router
[ ] Management access (SSH/22) restricted to specific source IPs
[ ] No rules accepting from 0.0.0.0/0 to ALL ports
[ ] Logging enabled for DROPPED packets
[ ] Anti-spoofing rules for RFC 1918 addresses on external interfaces
[ ] ICMP restricted (allow echo-reply/time-exceeded, block ping from internet)
[ ] Port 0 blocked (often used in scans)
AWS セキュリティグループの監査:
Rules that should NEVER exist in production:
✗ Inbound: 0.0.0.0/0 → Port 22 (SSH open to internet)
✗ Inbound: 0.0.0.0/0 → Port 3389 (RDP open to internet)
✗ Inbound: 0.0.0.0/0 → Port 0-65535 (any port from internet)
✗ Outbound: 0.0.0.0/0 → Port 0-65535 (unrestricted outbound)
Rules that are acceptable:
✓ Inbound: 0.0.0.0/0 → Port 443 (HTTPS for public web service)
✓ Inbound: 10.0.0.0/8 → Port 22 (SSH from internal VPC only)
✓ Inbound: [known IP] → Port 22 (SSH from jump box)
ファイアウォール監査レポートのテンプレート:
## Firewall Audit Report — [Device/Platform]
**Risk Summary:**
| Severity | Count |
|----------|-------|
| Critical | 2 |
| High | 5 |
| Medium | 8 |
**CRITICAL: SSH exposed to internet**
- Rule: `iptables -A INPUT -p tcp --dport 22 -j ACCEPT`
- Risk: Exposed to brute-force and CVE exploitation
- Fix: `iptables -A INPUT -p tcp --dport 22 -s [admin_ip] -j ACCEPT`
**HIGH: No default deny policy**
- Current: `-P INPUT ACCEPT`
- Fix: `-P INPUT DROP` + explicit allow rules
6. ネットワークアーキテクチャのセキュリティレビュー
ユーザーがネットワークアーキテクチャを説明または提供した場合:
レビューフレームワーク:
Zone Model (most to least trusted):
Internal (Core) → DMZ → Internet
Checkpoints:
[ ] Clear network zones with enforced boundaries
[ ] DMZ properly isolated from internal network
[ ] No direct internet-to-internal traffic allowed
[ ] East-west traffic controls between internal zones (microsegmentation)
[ ] Management network isolated from production
[ ] Out-of-band management for network devices
[ ] VPN gateway in DMZ, not directly on internal segment
[ ] DNS resolvers not exposed to internet
[ ] Log aggregation on separate isolated segment
スクリプトリファレンス
pcap_analyzer.py
python scripts/pcap_analyzer.py --file capture.pcap --output analysis.json
python scripts/pcap_analyzer.py --file traffic.pcapng --dns --http --top-talkers 20
python scripts/pcap_analyzer.py --file capture.pcap --detect-beaconing --output beacons.json
スキル連携
| 条件 | 関連スキル |
|---|---|
| 偵察でサービスを発見 | ← スキル 01(偵察と OSINT) |
| 脅威の相関分析に使うネットワーク IOC | → スキル 06(脅威ハンティング) |
| インシデント対応のタイムラインに使うネットワーク証拠 | → スキル 07(インシデント対応) |
| アラートへの対応を自動化 | → スキル 11(CSOC 自動化) |
参考資料
v3.0 の強化(2026年アップデート)
暗号化トラフィック時代の分析:
- JA4+ フィンガープリント — JA3 の後継となる JA4/JA4S/JA4H/JA4X スイートを採用し、復号せずに TLS 上のクライアント、サーバー、マルウェアをフィンガープリントします。Zeek/Suricata でこれらをピボットとして使用します。
- QUIC / HTTP3 — QUIC(UDP/443)を解析します。従来の TCP 中心のルールでは検出できないことに注意してください。可視範囲で Initial パケットと SNI を検査します。
- 暗号化 DNS — DoH/DoT/DoQ の利用とトンネリングを検出します。リゾルバーのベースラインを作成し、不審なエンドポイントを検知します。
- ビーコン検出の精度向上 — ジッターを考慮した間隔分析、バイト数の規則性、長時間接続のスコアリング(RITA 方式)により、HTTPS/QUIC 上の C2 を検出します。
- Zeek 優先のパイプライン —
conn、ssl、http、dns、x509、JA4 の各ログを分析の基盤として生成し、Zeek の notice を対象に検出ルールを作成します。
精度ルール: 5 タプル、JA4 フィンガープリント、バイト数/継続時間、信頼度スコア付き判定を含めてフローを報告します。該当する場合は、Suricata ルールと Zeek 検出の両方を提示します。