Skip to content

Instantly share code, notes, and snippets.

@yousefamar
Created October 18, 2017 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yousefamar/4749db578716ee22df4786a390678d9c to your computer and use it in GitHub Desktop.
Save yousefamar/4749db578716ee22df4786a390678d9c to your computer and use it in GitHub Desktop.
Splits PCAP files into several by MAC address
#!/bin/sh
#
# Splits up a PCAP file by MAC addresses
#
# Authors:
# Yousef Amar <yousef@amar.io>
#
if [ $# -lt 1 ]; then
echo "usage: $0 PCAP_FILE"
exit
fi
DIR=$(dirname "$1")
if [ ! -f "$DIR/dhcp.log" ]; then
echo "Please run bro on $1 in the directory $DIR."
exit 1
fi
if ! [ -x "$(command -v bro-cut)" ]; then
echo "Please install Bro Auxilliary Tools."
exit 1
fi
mkdir -p "$DIR/by-mac"
for MAC in $(cat "$DIR/dhcp.log" | bro-cut mac | sort | uniq)
do
echo "Filtering to $DIR/by-mac/$MAC.pcap"
tcpdump -r $1 -w "$DIR/by-mac/$MAC.pcap" ether host "$MAC"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment