*[TCP]TCPダンプの方法

  • ダンプを取る

tcpdump host "ホスト名" -x > tcpdump.log

  • ダンプの出力は16進数でわけわからないので、perlにて加工する。perlのプログラムはこれ


#!/usr/bin/perl
while(<>){
if(m/^[ \t]/){
$store .= $_
} else {
s/^[^ ]* //;
s/:[^:]*$//;
print "$_\n";
$_ = $store;
s/\s//g;
s/^.{120}//;
s/[0-9A-Fa-f][0-9A-Fa-f]/pack("C",hex $&)/eg;
s/[\x00-\x08\x0a-\x1f\x7f-\xff]/ /g;
print "$_\n";
$store = "";
}
}
あとは

./tcpdump.pl < tcpdump.log

を実行すればOK