-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdump_packets.sh
36 lines (29 loc) · 884 Bytes
/
dump_packets.sh
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
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# hosts filtered out to not catch unwanted traffic
sshhost=""
officeip1=""
officeip2=""
captureport="eth0"
tempfile="/tmp/netsniff"
# only works for ipv4 at this time, will change it later if needed
localip=$(ip -o -4 addr show dev eth1 | sed 's/.* inet \([^/]*\).*/\1/')
startup() {
touch $tempfile
}
cleanup() {
rm -rf $tempfile
pkill netsniff-ng
}
capture(){
startup
/usr/sbin/netsniff-ng -i $captureport -s -o ~/pcaps/ -H --ring-size 1GiB --interval 1GiB -f "not host "${sshhost}" and not host "${localip}" and not host "${officeip1}" and not host "${officeip2}"" &
#/usr/bin/tshark -i ${captureport} -b duration:86400 -w ~/pcaps/capture -q -f "not src "${badhost}" and port not "${mport}" or port not "${sshport}"" &
}
main() {
if [[ ! -e "$tempfile" ]]; then
capture
else
echo "Capture is already in progress"
fi
}
main