Skip to content

Instantly share code, notes, and snippets.

@baioc
Created November 6, 2023 14:12
Show Gist options
  • Save baioc/96fd4e893b56d78dfce6817374c71f9d to your computer and use it in GitHub Desktop.
Save baioc/96fd4e893b56d78dfce6817374c71f9d to your computer and use it in GitHub Desktop.
Extract payload data from captured TCP stream
#!/bin/sh
#
# Example usage:
# cat tcpdump.pcap | ./readtcpcap.sh 1 > stream1
#
if [ -z "$1" ]; then
echo 'You have to specify a TCP stream!'
exit 1
else
stream=$1
fi
tshark -r '-' -Q -z "follow,tcp,raw,$stream" | \
head -n -1 | tail -n +7 | \
sed 's/^\s\+//g' | \
xxd -r -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment