zoukankan      html  css  js  c++  java
  • shell每隔一秒钟就记录下netstat状态

    说明

    木马可能类似随机发送心跳包的操作,随机sleep。对这类情况写好了一个监听shell脚本,每隔一秒钟就记录下netstat状态。

    代码

    #!/bin/bash
    #功能:用于定时执行lsof 和 netstat 的执行状态并记录到文件
    
    slptime=1	#默认一秒执行一次
    filedir=/tmp		#默认存储在/tmp下
    lsoffile=lsof.log	#存储lsof的执行结果
    netstatfile=netstatfile.log	#存储netstat执行结果
    
    
    
    while true
    
    do
    	sleep $slptime
    	date=$(date '+%Y-%m-%d %H:%M:%S')
    	
    	echo $date":" >> $filedir/$lsoffile
    	echo $date":" >> $filedir/$netstatfile
    	lsof -i	  >> $filedir/$lsoffile
    	netstat -antlp >> $filedir/$netstatfile
    
    done
    
    
  • 相关阅读:
    JUC并发工具包之Semaphore
    Linux命令
    uWSGI
    数据库 MySQL 练习
    c++
    c++ 初阶
    Git
    MySQl 和 Redis
    MySQL 查询
    MySQL 命令
  • 原文地址:https://www.cnblogs.com/17bdw/p/11495108.html
Copyright © 2011-2022 走看看