1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacOSX El Capitan でパケットキャプチャし、自動的にファイルに保存する:tcpdump編

1
Last updated at Posted at 2016-01-30

実現したいこと

MacOSX El Capitan でパケットキャプチャしながら、自動的にファイルに保存する。
後ほどWiresharkでパケットファイルを閲覧したい。

実現方法および解決方法

tcpdump起動時にパケットキャプチャしたものをファイルに保存するコマンドオプションを利用する。

実行コマンド

mkdir -p ~/tmp/pkt
cd ~/tmp/pkt
pcap_date=$(date +%Y-%m-%d_%H-%M-%S) ; sudo tcpdump -i en0 -w testcap_$pcap_date.pcap
sudo chown $(whoami):staff testcap_$pcap_date.pcap

停止する際は、Ctrl + C を押す。

~/tmp/pkt に日付フォーマット付きのファイルが保存されているので、そのファイルwiresharkで開くとパケットが閲覧できます。

補足

$ tcpdump -h
tcpdump version 4.7.3 -- Apple version 66
libpcap version 1.5.3 - Apple version 54
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqRStuUvxX#] [ -B size ] [ -c count ]
		[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
		[ -i interface ] [ -j tstamptype ] [ -M secret ]
		[ -Q metadata-filter-expression ]
		[ -r file ] [ -s snaplen ] [ -T type ] [ --version ] [ -V file ]
		[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z command ]
		[ -Z user ] [ expression ]
$

情報源

man tcpdump

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?