唐僧还在拜佛求经路。  

1、查看流量图发现问题

查看的时候网页非常卡,有的时候甚至没有响应

2、top动态查看进程

我马上远程登录出问题的服务器,远程操作很卡,网卡出去的流量非常大,通过top发现了一个异常的进程占用资源比较高,名字不仔细看还真以为是一个Web服务进程。

4、结束异常进程并继续追踪

  1. killall -9 nginx1  
  2. rm -f /etc/nginx1 

干掉进程之后,流量立刻下来了,远程也不卡顿了,难道删掉程序文件,干掉异常进程我们就认为处理完成了么?想想也肯定没那么简单的,这个是木马啊,肯定还会自己生成程序文件(果然不出我所料,在我没有搞清楚之前,后面确实又生成了)我们得继续追查。

5、查看登录记录及日志文件secure

通过命令last查看账户登录记录,一切正常。查看系统文件message并没有发现什么,但是当我查看secure文件的时候发现有些异常,反正是和认证有关的,应该是尝试连进来控制发包?

7、更多异常文件的发现

查看定时任务文件crontab并没有发现什么一次,然后查看系统启动文件rc.local,也没有什么异常,然后进入/etc/init.d目录查看,发现比较奇怪的脚本文件DbSecuritySpt、selinux。

三、木马手动清除

现在综合总结了大概步骤如下:

1、简单判断有无木马

  1. #有无下列文件 
  2. cat /etc/rc.d/init.d/selinux 
  3. cat /etc/rc.d/init.d/DbSecuritySpt 
  4. ls /usr/bin/bsd-port 
  5. ls /usr/bin/dpkgd 
  6. #查看大小是否正常 
  7. ls -lh /bin/netstat 
  8. ls -lh /bin/ps 
  9. ls -lh /usr/sbin/lsof 
  10. ls -lh /usr/sbin/ss 

2、上传如下命令到/root下

  1. ps netstat ss lsof 

3、删除如下目录及文件

  1. rm -rf /usr/bin/dpkgd (ps netstat lsof ss) 
  2. rm -rf /usr/bin/bsd-port #木马程序 
  3. rm -f /usr/bin/.sshd #木马后门 
  4. rm -f /tmp/gates.lod 
  5. rm -f /tmp/moni.lod 
  6. rm -f /etc/rc.d/init.d/DbSecuritySpt(启动上述描述的那些木马变种程序) 
  7. rm -f /etc/rc.d/rc1.d/S97DbSecuritySpt 
  8. rm -f /etc/rc.d/rc2.d/S97DbSecuritySpt 
  9. rm -f /etc/rc.d/rc3.d/S97DbSecuritySpt 
  10. rm -f /etc/rc.d/rc4.d/S97DbSecuritySpt 
  11. rm -f /etc/rc.d/rc5.d/S97DbSecuritySpt 
  12. rm -f /etc/rc.d/init.d/selinux(默认是启动/usr/bin/bsd-port/getty) 
  13. rm -f /etc/rc.d/rc1.d/S99selinux 
  14. rm -f /etc/rc.d/rc2.d/S99selinux 
  15. rm -f /etc/rc.d/rc3.d/S99selinux 
  16. rm -f /etc/rc.d/rc4.d/S99selinux 
  17. rm -f /etc/rc.d/rc5.d/S99selinux 

4、找出异常程序并杀死

5、删除含木马命令并重新安装(或者把上传的正常程序复制过去也行)

我自己重新安装好像不行,我是找的正常的机器复制的命令。

  1. #ps 
  2. /root/chattr -i -a /bin/ps && rm /bin/ps -f 
  3. yum reinstall procps -y 或 cp /root/ps /bin 
  4. #netstat 
  5. /root/chattr -i -a /bin/netstat && rm /bin/netstat -f 
  6. yum reinstall net-tools -y 或 cp /root/netstat /bin 
  7. #lsof 
  8. /root/chattr -i -a /bin/lsof && rm /usr/sbin/lsof -f 
  9. yum reinstall lsof -y 或 cp /root/lsof /usr/sbin 
  10. #ss 
  11. /root/chattr -i -a /usr/sbin/ss && rm /usr/sbin/ss -f 
  12. yum -y reinstall iproute 或 cp /root/ss /usr/sbin
posted on 2017-11-21 09:59  唐僧还在拜佛求经路。  阅读(4733)  评论(0编辑  收藏  举报