Subversion Repositories ALCASAR

Rev

Rev 2888 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2770 rexy 1
#!/bin/bash
2
 
3
# alcasar-iot_capture.sh
4
# by Guillaume Gellusseau, Dorian Lemoine & REXY
5
# This script is distributed under the Gnu General Public License (GPL)
6
 
7
# Ce script lance une capture de flux réseau en fonction d'une adresse IP source ($1) 
8
# This script performs a network flow capture based on source ip address ($1) 
9
 
10
CONF_FILE="/usr/local/etc/alcasar.conf"
2888 rexy 11
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`
12
PRIVATE_IP=$(grep ^PRIVATE_IP= $CONF_FILE | cut -d'=' -f2 | cut -d'/' -f1)
2770 rexy 13
 
14
function info
15
{
16
	_PID=$(ps -ef | grep tcpdump | grep $1 | awk {'print $2'})
17
	if [[ -n $_PID ]]
18
	then
19
		echo "CaptureON"
20
	else
21
		echo "CaptureOFF"
22
	fi 
23
}
24
 
25
function kill
26
{
27
	_PID=$(ps -ef | grep tcpdump | grep $1 | awk {'print $2'})
28
	sudo kill -2 $_PID
29
}
30
 
31
function launch
32
{
2888 rexy 33
# capture only one @MAC, on $INTIF, max filesize=10M, without flows to PRIVATE_IP except DNS
2919 rexy 34
	sudo tcpdump "ether host $1 and (host not $PRIVATE_IP or port 53)" -i $INTIF -n -C 10 -W 1 -w /var/Save/iot_captures/$1.pcap
2770 rexy 35
}
36
 
37
function flush
38
{
2887 rexy 39
	sudo rm /var/Save/iot_captures/$1.pcap -f
2770 rexy 40
}
41
 
42
 
43
while getopts "l k i f" option; do
44
 
45
	case "${option}" in
46
 
47
		l)
48
			launch $2
49
			;;
50
		k)
51
			kill $2
52
			;;
53
		i)
54
			info $2
55
			;;
56
		f)
57
			flush $2
58
			;;
59
	esac
60
done
61
 
62
#End