您的需求已经提交,我们将在48小时内联系您
全国服务热线:400-1000-221
确定
免费享受企业级云安全服务
获取手机验证码
{{message}}
免费试用

linux服务器被植入木马怎么解决

作者:
发布时间:2020-08-18

  linux系统因为可扩展性和稳定性较强,因此许多服务器都搭载着linux系统,但是linux系统同样也会被挂木马病毒,如果linux服务器被植入木马怎么解决?们linux系统中木马病毒,大概几十台主机挨,一直大量向外发流量,黑客主要是去攻击阿里云,这里给大家介绍下我们的解决过程。

linux服务器被植入木马怎么解决

  

linux服务器被植入木马怎么解决

 

  linux服务器被植入木马怎么解决?我因为时间远,而且没有专门记录当时排查过程,以下是解决的一些history记录,大部分人应该可以看得懂,对今后你碰到类似的,也有帮助。

  先看看sshd就否有异常,异常一般是名称不一样,如.ssh进程在运行

  ps -ef|grep sshd

  或看看运行的sshd是否被替换过了,比如 ls -art /usr/local/bin/sshd

  如看不出来, 看ps是否被替换过,可以如下看

  which ps

  ls -alrt /bin/ps

  如文件生成日期很新或大小与其它正常服务器不一样,那可能被替换了,从其它服务器拷过来。

  rm -f /usr/bin/.sshd

  删除发现异常的的命令

  ps -ef|grep .sshd|grep -v grep|grep -v slviss|grep -v sbin|cut -c 9-15|xargs kill -9

  批量把异常进程杀掉,其中grep -v slviss 是过淲自己登录的目录

  /usr/bin/sshd -v

  看看sshd版本,是否对

  which sshd

  rm /usr/bin/sshd

  不对则删掉

  ls -alrt /usr/bin/dpkgd

  rm -rf /usr/bin/dpkgd

  删除异常进程

  ls -alrt /usr/bin/bsd-port

  rm -rf /usr/bin/bsd-port

  删掉他们的扫描软件

  42 find / -name zabbix_AgentD

  查找名为 zabbix_AgentD 异常程序

  ls -alrt /root/cmd.n

  rm /root/cmd.n

  rm /root/conf.n

  rm /root/IP

  删除root下的异常程序

  rm -f /tmp/gates.lod

  ls -alrt /tmp/moni.lod

  rm /tmp/moni.lod

  ls -alrt /tmp/notify.file

  ls -alrt /tmp/*

  删除/tmp下的异常文件

  rm -f /etc/rc.d/init.d/DbSecuritySpt

  rm -f /etc/rc.d/init.d/DbSecuritySpt

  rm -f /etc/rc.d/rc1.d/S97DbSecuritySpt

  find / -name S97DbSecuritySpt

  rm -f /etc/rc.d/rc2.d/S97DbSecuritySpt

  rm -f /etc/rc.d/rc3.d/S97DbSecuritySpt

  rm -f /etc/rc.d/rc4.d/S97DbSecuritySpt

  rm -f /etc/rc.d/rc5.d/S97DbSecuritySpt

  删除 /etc/rc.d/r 下的异常启动脚本

  find / -name S99selinux

  rm -f /etc/rc.d/init.d/selinux

  m -f /etc/rc.d/rc1.d/S99selinux

  rm -f /etc/rc.d/rc2.d/S99selinux

  rm -f /etc/rc.d/rc3.d/S99selinux

  rm -f /etc/rc.d/rc4.d/S99selinux

  rm -f /etc/rc.d/rc5.d/S99selinux

  删除 /etc/rc.d/r 下的异常启动脚本

  find / -size 1223123c

  按文件 大小查全系统里被替换的命令

  主要被替换的命令有 ps ,lsof,netstat,top (top.1,top.2,top.3,top.4)

  cd tool1

  tar -xvf tool1.tar

  ./ps -ef

  用替换回正确的ps再查询异常进程

  cp ps /bin/ps

  把完好的ps 放回正确目录

  which lsof

  cp lsof /usr/sbin/lsof

  cp netstat /bin/netstat

  which ss

  cp ss /usr/sbin/ss

  which top

  rm /top

  rm /top.1

  rm /top.2

  rm /l

  rm /top.3

  rm /top.4

  rm /pelr

  再检 查,

  ps -ef

  发现下面的异常进程 getty, 杀之

  ps -ef|grep getty|grep port |grep -v grep |cut -c 9-15|xargs kill -9

  把相关的top进程杀之

  ps -ef|grep top |grep -v grep |cut -c 9-15|xargs kill -9

  把相关的netstat 进程杀之

  ps -ef

  ps -ef|grep netstat |grep -v grep |cut -c 9-15|xargs kill -9

  后面在 /usr/bin/看到一些异常进程

  -rwxrwxrwx. 1 root root 69 7鏈 14 17:26 /usr/bin/32.sh

  -rw-r--r--. 1 root root 481 7鏈 14 17:26 /usr/bin/32.local

  -rw-r--r--. 1 root root 523 7鏈 14 17:26 /usr/bin/32crontab

  -rwxr-xr-x. 1 root root 1223123 7鏈 16 16:45 /usr/bin/netstat

  -rwxr-xr-x. 1 root root 1223123 7鏈 16 16:45 /usr/bin/ps

  内容如下,感兴趣的人可以研究一下

  [root@gg-cs-1 opt]# more /usr/bin/32.sh

  killall -9 32

  cd /tmp

  chmod 777 32

  nohup /tmp/32 >/dev/null 2>&1 &

  [root@gg-cs-1 opt]# more /usr/bin/32crontab

  SHELL=/bin/bash

  PATH=/sbin:/bin:/usr/sbin:/usr/bin

  MAILTO=root

  # For details see man 4 crontabs

  # Example of job definition:

  # .---------------- minute (0 - 59)

  # | .------------- hour (0 - 23)

  # | | .---------- day of month (1 - 31)

  # | | | .------- month (1 - 12) OR jan,feb,mar,apr ...

  # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

  # | | | | |

  # * * * * * user-name command to be executed

  */3 * * * * root /etc/cron.hourly/udev.sh

  */55 * * * * root /bin/32.sh

  [root@gg-cs-1 opt]#

  [root@gg-cs-1 opt]# more /etc/cron.hourly/udev.sh

  #!/bin/sh

  PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R6/bin

  cp /lib/libgcc4.so /lib/libgcc4.4.so

  /lib/libgcc4.4.so

  可以对应查看端口所在进程,看看哪个进程有异常流量

  [root@gg-cs-1 etc]# lsof -Pnl +M -i4

  COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

  13 615 0 4u IPv4 7938104 0t0 TCP 222.218.24.131:49450->183.60.202.12:13 (ESTABLISHED)

  getty 642 0 5u IPv4 7949677 0t0 TCP 222.218.24.131:44335->144.48.172.147:6001 (SYN_SENT)

  被替换后的ps文件,大家可以研究

  [root@YN-KT-LJ init.d]# more /bin/ps

  #!/bin/sh

  for arg in "$*";do

  ips $arg|grep -v "589a2ec0c1"|grep -v "4b74cd2dba"|grep -v "ips"|grep -v "grep"

  done;exit

  [root@YN-KT-LJ init.d]#

  

linux服务器被植入木马怎么解决

 

  关于linux服务器被植入木马怎么解决就为大家介绍到这里,上面记录的是解决木马病毒的详细过程,linux系统相比windows系统会更加安全稳定一些,主要中的木马病毒,也以shell脚本居多,因此大家在排查的时候一定要仔细耐心,只要肯花时间都能解决。如果实在解决不了,也可以向安全狗咨询,我们会安排专业的技术人员为您提供技术支持。

标签: