Created
April 17, 2024 04:31
-
-
Save zengxinhui/5c1b153d986fc6270843f9b19a0f18b4 to your computer and use it in GitHub Desktop.
group by tcp stream and output the last 10 packets captured to see how a connection ended.
This file contains hidden or 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
tshark -r xyz.pcapng -Y "tcp.port != 445" -T fields -e tcp.stream -e frame.time_relative -e ip.src -e ip.dst -e _ws.col.info | sort -V | awk 'BEGIN { | |
prev = 0; | |
count = 0; | |
} { | |
buffer[NR % 11] = $0; | |
if ($1 != prev) { | |
for (i = NR-count; i<NR; i++) | |
print buffer[i % 11]; | |
print ""; | |
prev = $1; | |
count = 1 | |
} else { | |
if (count<10) | |
count++; | |
} | |
} | |
END { | |
for (i = NR-count; i<NR; i++) | |
print buffer[i % 11]; | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment