1、抓包脚本
# cat capturepackages.sh
#!/usr/bin/sh
#
while [ 1 ]
do
STIME=`date +%F"@"%H%M%S`
DATE_DIR=`date +%F`
if [ ! -d /tnm/capture/$DATE_DIR ];then
mkdir -p /tnm/capture/$DATE_DIR
fi
/usr/local/sbin/tcpdump -w /tnm/capture/$DATE_DIR/$STIME.log -s 5000 -i lan0
done
2、停抓包的脚本
# cat stopscript.sh
#!/usr/bin/sh
STIME=`date +%F"@"%H%M%S`
zhuabao=`ps -ef|grep tcpdump|awk '/lan0/ { print $2 }'`
jiaoben=`ps -ef|grep capturepackages|awk '/bin/ { print $2 }'`
if [ -n "$zhuabao" ] && [ -n "$jiaoben" ];
then
kill -9 $jiaoben
kill -9 $zhuabao
echo " This $STIME the script is execute success! " >> /tnm/capture/messages
else
echo " The script has problem! "
fi
3、把这两个脚本加入crontab定时任务
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。