0
点赞
收藏
分享

微信扫一扫

shell 抓包脚本

慕犹清 2022-05-06 阅读 72

#!/bin/bash

. /etc/profile     #解决which tcpdump ifconfig找不到的问题

savapath=XXXXX #保存路径

dayout=XXX #保存多少天的值

maxfilesize= XXX #文件的大小

netnames=$* #传入网口的名称,如果不传入,则默认监视所以网卡,传入模式eth0 eth1

G_captool=`which tcpdump`

G_ifconfig=`which ifconfig`

if [ ! -d $savapath ]; then

mkdir $savapath

fi

if [ -z "$netnames ]; then

#列出所有网卡,屏蔽lo

netlist= `$G_ifconfig | grep -o ^[a-z0-9]* | grep -v lo`

else

netlist=$netnames

fi

dt_str=`date + "F"`

#遍历网卡

for net in $netlist

do

      #查找非今天的抓包进程,全部杀死

       procid=`ps aux | grep $G_captool | grep $ savapath | grep -v $dt_str | grep $net | grep -v grep | awk '{print $2}' | xargs`

         if [ !  -z "$procid"]: then

               

举报

相关推荐

0 条评论