-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdumbdecode
executable file
·28 lines (24 loc) · 1022 Bytes
/
dumbdecode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /bin/sh
# Emulate dumbdecode.py from python netarch
# What this script does:
# * pmerge takes multiple pcap files and outputs a single pcap stream,
# with everything in time order
# * pcat outputs a line with six fields for each input packet:
# * timestamp (in seconds, with millisecond precison)
# * protocol (like `UDP` or `TCP`)
# * source address
# * destination address
# * protocol options (like SYN or PSH)
# * payload, hex-encoded
# * For each pcat output line:
# * Convert timestamp to RFC3339 format, so humans can read it
# * Print a bit of header with the protocol, using python netarch formatting
# * Print the source, destination, and formatted time
# * Write out a hex dump of the paylaod
pmerge "$@" | pcat | while read ts proto src dst opts payload; do
when=$(TZ=Z date -d @${ts%.*} "+%Y-%m-%d %H:%M:%S") # Format time as human-readable
printf "Packet %s None: None\n" $proto
printf " %s -> %s (%s)\n" ${src%,*} ${dst%,*} "$when"
echo $payload | unhex | hd
echo
done