Communitygithub.com

Wiresharkによるネットワークトラフィック分析

Wiresharkとtsharkを使用してネットワークパケットデータをキャプチャし分析します。

Wiresharkによるネットワークトラフィック分析 とは?

このスキルは、Wiresharkおよびそのコマンドライン版である tshark を活用したネットワークパケット分析の包括的な手法を提供します。ネットワーク侵入の調査、パフォーマンス問題の診断、マルウェア通信パターンの解析、ファイアウォールやIDSルールの検証、そして侵入痕跡や認証情報の抽出など、多岐にわたるユースケースに対応します。 ワークフローは、キャプチャ環境の設定から始まり、表示フィルタによる対象分析、プロトコル別の詳細調査、アーティファクトやIoCの抽出、統計分析と異常検知、そしてレポート生成と証拠保全まで、段階的に構成されています。各ステップには具体的な tshark コマンド例が豊富に含まれており、コマンドラインでの操作に慣れた開発者やセキュリティアナリストがすぐに実践できます。 本書では、BPFキャプチャフィルタとWireshark表示フィルタの違いや、PCAPNG形式、TCPストリーム、プロトコルディセクタなどの主要概念も解説。さらに、DNSトンネリングによるデータ流出の調査シナリオを通じて、実際のインシデント対応で活用できる手順と落とし穴を学べます。 対応プラットフォームはWireshark 4.0以上、tshark、tcpdump、mergecap、editcapで、Linux、macOS、Windows環境で動作します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-network-traffic-with-wireshark

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Wiresharkによるネットワークトラフィック分析 は何をしますか?

使用するタイミング

  • ネットワーク侵入の疑いがある場合、コマンド&コントロールトラフィック、データ流出、ラテラルムーブメントのパケットレベル証拠を調査する
  • 再送信、フラグメンテーション、DNS解決失敗などのネットワークパフォーマンス問題を診断する
  • サンドボックス化または隔離されたホストからトラフィックをキャプチャし、マルウェアの通信パターンを分析する
  • ネットワークセグメントを実際に通過しているトラフィックを確認して、ファイアウォールやIDSルールを検証する
  • キャプチャしたネットワークセッションからファイル、認証情報、侵害指標(IoC)を抽出する

使用すべきでないケース: 許可なくネットワーク上のトラフィックをキャプチャすること、法的権限なしにプライベート通信を傍受すること、本番監視においてフル機能のSIEMプラットフォームの代わりとして使用すること。

前提条件

  • Wireshark 4.0以上とtsharkコマンドラインユーティリティがインストールされていること
  • ライブパケットキャプチャのためのroot/sudo権限、またはwiresharkグループへの所属
  • 監視対象セグメントへのネットワークインターフェースアクセス(物理NIC、SPANポート、またはネットワークタップ)
  • パケットキャプチャファイル用の十分なディスク容量(ビジーなギガビットリンクでは毎分約1 GBを見積もる)
  • TCP/IPプロトコル、HTTP、DNS、TLS、SMBに対するパケットレベルの知識

ワークフロー

ステップ1: キャプチャ環境の設定

関連するトラフィックを対象とするために、キャプチャインターフェースとフィルタを設定します:

# 利用可能なインターフェースを一覧表示
tshark -D

# eth0でキャプチャを開始し、キャプチャフィルタで範囲を制限
tshark -i eth0 -f "host 10.10.5.23 and (port 80 or port 443 or port 445)" -w /tmp/capture.pcapng

# リングバッファを使用してディスク使用量を管理(10ファイル、各100MB)
tshark -i eth0 -b filesize:102400 -b files:10 -w /tmp/rolling_capture.pcapng

# 複数のインターフェースで同時にキャプチャ
tshark -i eth0 -i eth1 -w /tmp/multi_interface.pcapng

Wireshark GUIの場合は、起動前にキャプチャオプションダイアログでキャプチャフィルタを設定します。

ステップ2: 対象分析のための表示フィルタの適用

# 不審なユーザーエージェントを含むHTTPトラフィックをフィルタ
tshark -r capture.pcapng -Y "http.user_agent contains \"curl\" or http.user_agent contains \"Wget\""

# 不審なTLDへのDNSクエリを検索
tshark -r capture.pcapng -Y "dns.qry.name contains \".xyz\" or dns.qry.name contains \".top\" or dns.qry.name contains \".tk\""

# ネットワーク問題を示すTCP再送信を特定
tshark -r capture.pcapng -Y "tcp.analysis.retransmission"

# ラテラルムーブメント検出のためのSMBトラフィックをフィルタ
tshark -r capture.pcapng -Y "smb2.cmd == 5 or smb2.cmd == 3" -T fields -e ip.src -e ip.dst -e smb2.filename

# 平文の認証情報送信を検出
tshark -r capture.pcapng -Y "ftp.request.command == \"PASS\" or http.authbasic"

# ビーコン動作の検出(一定間隔の接続)
tshark -r capture.pcapng -Y "ip.dst == 203.0.113.50" -T fields -e frame.time_relative -e ip.src -e tcp.dstport

ステップ3: プロトコル別の詳細分析

# TCPストリームを追跡して会話を再構成
tshark -r capture.pcapng -q -z follow,tcp,ascii,0

# HTTPリクエスト/レスポンスペアを分析
tshark -r capture.pcapng -Y "http" -T fields -e frame.time -e ip.src -e ip.dst -e http.request.method -e http.request.uri -e http.response.code

# DNSクエリ/レスポンス統計を抽出
tshark -r capture.pcapng -q -z dns,tree

# 弱い暗号スイートのためのTLSハンドシェイクを分析
tshark -r capture.pcapng -Y "tls.handshake.type == 2" -T fields -e ip.src -e ip.dst -e tls.handshake.ciphersuite

# SMBファイルアクセス列挙
tshark -r capture.pcapng -Y "smb2" -T fields -e frame.time -e ip.src -e ip.dst -e smb2.filename -e smb2.cmd

ステップ4: アーティファクトとIoCの抽出

# HTTPオブジェクトをエクスポート(HTTP経由で転送されたファイル)
tshark -r capture.pcapng --export-objects http,/tmp/http_objects/

# SMBオブジェクトをエクスポート(SMB経由で転送されたファイル)
tshark -r capture.pcapng --export-objects smb,/tmp/smb_objects/

# 脅威インテリジェンス検索用にすべての一意な宛先IPを抽出
tshark -r capture.pcapng -T fields -e ip.dst | sort -u > unique_dest_ips.txt

# SSL/TLS証明書情報を抽出
tshark -r capture.pcapng -Y "tls.handshake.type == 11" -T fields -e x509sat.uTF8String -e x509ce.dNSName

# アクセスされたすべてのURLを抽出
tshark -r capture.pcapng -Y "http.request" -T fields -e http.host -e http.request.uri | sort -u > urls.txt

# 抽出したファイルのハッシュを計算してIoC照合
tshark -r capture.pcapng --export-objects http,/tmp/http_objects/ && find /tmp/http_objects/ -type f -exec sha256sum {} \; > extracted_file_hashes.txt

ステップ5: 統計分析と異常検知

# プロトコル階層統計
tshark -r capture.pcapng -q -z io,phs

# バイト数でソートされた会話統計
tshark -r capture.pcapng -q -z conv,tcp -z conv,udp

# 主要な通信元を特定
tshark -r capture.pcapng -q -z endpoints,ip

# IOグラフデータ(1秒あたりのパケット数)
tshark -r capture.pcapng -q -z io,stat,1,"COUNT(frame) frame"

# ポートスキャンパターンを検出
tshark -r capture.pcapng -Y "tcp.flags.syn == 1 and tcp.flags.ack == 0" -T fields -e ip.src -e tcp.dstport | sort | uniq -c | sort -rn | head -20

ステップ6: レポート生成と証拠のエクスポート

# フィルタリングされたパケットを新しいPCAPファイルにエクスポートして証拠保存
tshark -r capture.pcapng -Y "ip.addr == 10.10.5.23 and tcp.port == 4444" -w evidence_c2_traffic.pcapng

# パケットサマリーをCSV形式で生成
tshark -r capture.pcapng -T fields -E header=y -E separator=, -e frame.number -e frame.time -e ip.src -e ip.dst -e ip.proto -e tcp.srcport -e tcp.dstport -e frame.len > traffic_summary.csv

# プログラムによる分析のためのPDML(XML)出力を作成
tshark -r capture.pcapng -T pdml > capture_analysis.xml

# 証拠保管連鎖のためにキャプチャファイルのハッシュを計算
tshark -r capture.pcapng -w /dev/null && sha256sum capture.pcapng > capture_hash.txt

主要概念

用語定義
キャプチャフィルタ(BPF)キャプチャ時に適用されるBerkeley Packet Filter構文。記録するパケットを制限し、ファイルサイズを削減してパフォーマンスを向上させる
表示フィルタ既にキャプチャされたパケットに適用するWireshark独自のフィルタ構文。キャプチャファイルを変更せずに分析を絞り込む
PCAPNG次世代パケットキャプチャ形式。複数インターフェース、名前解決、注釈、メタデータを1つのファイルでサポート
TCPストリーム2つのエンドポイント間の完全な双方向通信を表す、TCPセグメントの再構成されたシーケンス
プロトコルディセクタ特定プロトコルのフィールドと構造をデコードするWiresharkモジュール。パケット内容の詳細な検査を可能にする
IOグラフキャプチャ期間中のパケット数やバイト数の時系列グラフ。トラフィックスパイクやビーコン動作の特定に有用

ツールとシステム

  • Wireshark 4.0+: 3,000以上のプロトコルに対応するプロトコルディセクタ、ストリーム再構成、エクスポート機能を備えたGUIベースのパケットアナライザ
  • tshark: Wiresharkのコマンドライン版。ヘッドレスキャプチャ、バッチ処理、スクリプト化された分析パイプラインに使用
  • tcpdump: GUI依存のないリモートシステムでのクイックキャプチャのための軽量パケットキャプチャツール
  • mergecap: 複数のキャプチャファイルを1つのPCAPに結合して統合分析するWiresharkユーティリティ
  • editcap: キャプチャファイルの分割、フィルタリング、形式変換を行うWiresharkユーティリティ

よくあるシナリオ

シナリオ: DNSトンネリングによるデータ流出の調査

背景: SOCチームが、ワークステーション(10.10.3.45)から外部ドメインへの異常に高いDNSクエリ量を検出。SIEMアラートにより、DNSクエリがベースラインの15件/分に対して平均200件/分であることが通知された。当該ワークステーションのVLANのネットワークタップからパケットキャプチャを開始。

アプローチ:

  1. ワークステーションのサブネットからのトラフィックをキャプチャ:tshark -i eth2 -f "host 10.10.3.45 and port 53" -w dns_exfil_investigation.pcapng
  2. DNSクエリパターンを分析:tshark -r dns_exfil_investigation.pcapng -Y "dns.qry.name contains \"suspect-domain.xyz\"" -T fields -e frame.time -e dns.qry.name
  3. エンコードされたデータを示すサブドメインラベル(長いbase64風サブドメインはトンネリングを示す)を検査:tshark -r dns_exfil_investigation.pcapng -Y "dns.qry.type == 16" -T fields -e dns.qry.name -e dns.txt
  4. クエリ名の長さを合計してデータ量を計算し、流出帯域幅を推定
  5. 一意なクエリ名を抽出し、base64サブドメインをデコードして流出コンテンツを復元
  6. 証拠パケットを別のPCAPにエクスポートし、SHA-256ハッシュを生成して証拠保管連鎖を確保

落とし穴:

  • ビジーネットワーク上でフィルタなしのトラフィックをキャプチャし、関連データを収集する前にディスク容量を使い果たす
  • キャプチャフィルタではなく表示フィルタを使用し、処理が遅い巨大なファイルを生成してしまう
  • 従来のポート53でのDNSキャプチャを回避する暗号化DNS(DoH/DoT)トラフィックを見落とす
  • パケットキャプチャのハッシュとフォレンジック証拠のための証拠保管連鎖の文書化を怠る

出力形式

## トラフィック分析レポート

**ケースID**: IR-2024-0847
**キャプチャファイル**: dns_exfil_investigation.pcapng
**SHA-256**: a3f2b8c1d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1
**期間**: 2024-03-15 14:00:00 ~ 14:45:00 UTC
**ソースインターフェース**: eth2(VLAN 30 SPANポート)

### 発見事項

**1. DNSトンネリング確認**
- 送信元: 10.10.3.45
- 宛先DNS: 8.8.8.8(ns1.suspect-domain.xyz に転送)
- クエリ数: 45分間で9,247クエリ(205件/分、ベースライン15件/分)
- 平均サブドメインラベル長: 63文字(base64エンコードデータ)
- 推定流出データ量: TXTレコード応答により約2.3 MB

**2. 侵害指標(IoC)**
- ドメイン: suspect-domain.xyz(3日前に登録)
- ネームサーバー: ns1.suspect-domain.xyz(203.0.113.50)
- クエリパターン: base64エンコードされたサブドメインを含むTXTレコード要求
- 応答パターン: base64エンコードされたペイロードを含むTXTレコード

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

関連スキル