-
Notifications
You must be signed in to change notification settings - Fork 0
/
pacp_capture
61 lines (55 loc) · 1.04 KB
/
pacp_capture
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
#
#########################################################################
# File Name : pacp_capture
# Author : Li Yunpeng
# E-mail : [email protected]
# use : This script is used for capturing data packet.
# correlation:charon.sh
# Time : Wed 27 Aug 2014
#########################################################################
FILE_SIZE=20
usage(){
echo "usage:$0 {start | stop | restart}"
#非法参数输入时提示
}
start()
{
#每天一个文件夹,每次启动将启动时间设为文件名,以此防止重启后覆盖原文件
TIME=$(date +%Y%m%d)
if [ -d $TIME ];then
log=$(date +%H%M%S)
else
mkdir $TIME
fi
pkill -2 tcpdump
tcpdump -i $HOME_NET -s 0 -C $FILE_SIZE -w ${TIME}/$log #进行抓包
}
stop()
{
pkill -2 tcpdump
}
if
echo $2 | grep "^eth"
then
HOME_NET=$2
#若传入网口信息,则使用指定网口
else
HOME_NET="eth0"
#否则使用默认网口
fi
case $1 in
start)
start &
;;
stop)
stop
;;
restart)
start
;;
*)
usage
;;
esac
exit 0