Created
October 18, 2017 07:48
-
-
Save yousefamar/4749db578716ee22df4786a390678d9c to your computer and use it in GitHub Desktop.
Splits PCAP files into several by MAC address
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
#!/bin/sh | |
# | |
# Splits up a PCAP file by MAC addresses | |
# | |
# Authors: | |
# Yousef Amar <[email protected]> | |
# | |
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