「Wireshark」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(→‎Filter packets by port: add === Headless capturing with dumpcap ===)
52行目: 52行目:
 
This will filter traffic within any of the private network spaces.
 
This will filter traffic within any of the private network spaces.
   
  +
=== ポート毎にパケットをフィルタ ===
=== Filter packets by port ===
 
   
  +
2 つ以上のポートのすべてのトラフィックを表示:
See all traffic on two ports or more:
 
   
 
tcp.port==80||tcp.port==3306
 
tcp.port==80||tcp.port==3306

2022年10月5日 (水) 10:01時点における版

Wireshark はフリーでオープンソースのパケットアナライザです。ネットワークのトラブルシューティングや解析、ソフトウェアと通信プロトコルの開発、または教育などに使われています。

インストール

Wireshark GUI の場合は wireshark-qt パッケージをインストールし、tshark CLIの場合は wireshark-cliインストールします。

特権の取得

Wireshark を root で実行しないでください。Wireshark は特権分離を実装しています。つまり、Wireshark GUI(または tshark CLI)は通常のユーザとして動作し、dumpcap キャプチャユーティリティは root[1] として動作します。

wireshark-cli インストールスクリプト は、/usr/bin/dumpcap 実行ファイルにパケットキャプチャケイパビリティを設定します。

/usr/bin/dumpcap は root と wireshark グループのメンバーしか実行できないので、通常のユーザーとして Wireshark を使用するには、自分のユーザーを wireshark ユーザーグループに追加する必要があります(ユーザーとグループ#グループ管理 を参照)。

キャプチャのテクニック

フィルターを適用することで Wireshark で見たいパケットだけをキャプチャすることが可能です。

ノート: フィルターの構文については、pcap-filter(7)wireshark-filter(4) の man ページを見て下さい。

TCP パケットを抽出

TCP パケットを全て閲覧したい場合、"Filter" バーに tcp と入力してください。もしくは CLI 版の場合:

$ tshark -f "tcp"

UDP パケットを抽出

UDP パケットを全て閲覧したい場合、"Filter" バーに udp と入力してください。もしくは CLI 版の場合:

$ tshark -f "udp"

特定の IP アドレスのパケットを抽出

  • 特定のアドレスに送信されるトラフィックを全て閲覧したい場合、ip.dst == 1.2.3.4 と入力してください。1.2.3.4 はトラフィックの送信先の IP アドレスに置き換えて下さい。
  • 特定のアドレスから送られたトラフィックを全て閲覧したい場合、ip.src == 1.2.3.4 と入力してください。1.2.3.4 はトラフィックの送信元の IP アドレスに置き換えて下さい。
  • 特定のアドレスから送受信されるトラフィックを全て閲覧したい場合、ip.addr == 1.2.3.4 と入力してください。1.2.3.4 は適当な IP アドレスに置き換えて下さい。

Exclude packets from a specific IP address

ip.addr != 1.2.3.4

Filter packets to LAN

To only see LAN traffic, no internet traffic run

(ip.src==10.0.0/8 AND ip.dst==10.0.0/8) OR (ip.src==172.16.0.0/12 AND ip.dst==172.16.0.0/12) OR (ip.src==192.168.0.0/16 and ip.dst==192.168.0.0/16)

This will filter traffic within any of the private network spaces.

ポート毎にパケットをフィルタ

2 つ以上のポートのすべてのトラフィックを表示:

tcp.port==80||tcp.port==3306
tcp.port==80||tcp.port==3306||tcp.port==443

Headless capturing with dumpcap

dumpcap is part of Wireshark and can be used for capturing packets without the GUI. Used in combination with tmux will allow the capture of packets in a detached session.

To see all dumpcap options, use the -h flag.

The following example will provide a ringbuffer capture. It captures twenty .pcap files of 100MB each, replacing the oldest file with the twenty-first file and so on… This allows a continuous capture without exhausting disk space.

# dumpcap -i 1 -b filesize:100000 -b files:20 -w mycapture.pcapng
  • -i − interface number (listed from dumpcap -D)
  • -b filesize: − file size in kB before starting a new .pcap file
  • -b files: − the number of files to capture before overwriting the oldest
  • -w − write the output to the file mycaptureidentifier.pcapng