Created
August 29, 2012 23:33
-
-
Save kuzuha/3520393 to your computer and use it in GitHub Desktop.
tcpdump filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
$buf = ''; | |
while(<STDIN>) { | |
$flag = $_ =~ m/^\s+0x[\da-f]{4}: /; | |
if (!$flag) { | |
$buf =~ s/\s//g; | |
$buf =~ s/[0-9A-Fa-f][0-9A-Fa-f]/pack("C", hex $&)/eg; | |
$buf = substr($buf, 52); | |
$buf =~ s/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f-\xff]/ /g; | |
print "$buf\n\n"; | |
$buf = ''; | |
print $_; | |
} else { | |
$_ =~ s/^[^:]+: //gm; | |
$buf .= $_; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment