摘要

这次被挂马机器是朋友的一台要上线的生产机器,昨晚装的系统今天2点就挂马了。不说了都是泪,直接说说查杀过程吧。

今天朋友说他一台要准备上线的生产服务器被挂马,特征ps命令找不到进程,top能看到负载最高的一个程序是一个随机的10位字母的东西,kill掉之后自动再次出现一个随机10位字母的进程。

我让他关闭这个机器的外网,内网放开,在局域网中给我一个跳板。等我拿到权限之后进入机器,先按照朋友说的验证了一遍,果然是那样,木马有自我保护自我恢复。

这时候我想到一个问题居然是能自我开机启动,要么/etc/rc.d/{init.d,rc{1,2,3,4,5}.d}/下有启动脚本,要么有cron计划任务。

于是我发现crontab -l是正常,来到/etc/rc.d/init.d下发现了异常有10位字母的启动脚本,脚本内容如下

[root@Xd9BdoAkG ~]# cat /etc/rc.d/init.d/fregonnzkq

#!/bin/sh

# chkconfig: 12345 90 90

# description: fregonnzkq

### BEGIN INIT INFO

# Provides:        fregonnzkq

# Required-Start:   

# Required-Stop:   

# Default-Start:    1 2 3 4 5

# Default-Stop:       

# Short-Description:    fregonnzkq

### END INIT INFO

case $1 in

start)

    /usr/bin/fregonnzkq

    ;;

stop)

    ;;

*)

    /usr/bin/fregonnzkq

    ;;

esac

看到这我真是佩服这帮人单用户启动模式都不放过啊
到了这里我天真的删除了几个这样的启动脚本,然后重启服务器,问题依旧

到了这时候我多想了下,是不是还有启动脚本?仔细核查发现/etc/rc.d/rc3.d/下还有问题

[root@Xd9BdoAkG rc3.d]# ls -lt

total 0

lrwxrwxrwx  1 root root 20 Sep  8 13:21 S90eviykluziy -> ../init.d/eviykluziy

lrwxrwxrwx  1 root root 20 Sep  8 12:49 S90yuurxgembh -> ../init.d/yuurxgembh

lrwxrwxrwx  1 root root 20 Sep  8 10:37 S90fregonnzkq -> ../init.d/fregonnzkq

lrwxrwxrwx. 1 root root 15 Sep  7 14:08 S85nginx -> ../init.d/nginx

lrwxrwxrwx. 1 root root 24 Sep  7 13:55 S99libvirt-guests -> ../init.d/libvirt-guests

lrwxrwxrwx. 1 root root 19 Sep  7 13:55 S26haldaemon -> ../init.d/haldaemon

lrwxrwxrwx. 1 root root 19 Sep  7 13:54 K10saslauthd -> ../init.d/saslauthd

lrwxrwxrwx. 1 root root 20 Sep  7 13:54 S22messagebus -> ../init.d/messagebus

lrwxrwxrwx. 1 root root 14 Sep  7 13:51 S55sshd -> ../init.d/sshd

lrwxrwxrwx. 1 root root 18 Sep  7 13:51 K15svnserve -> ../init.d/svnserve

lrwxrwxrwx. 1 root root 17 Sep  7 13:44 S10network -> ../init.d/network

lrwxrwxrwx. 1 root root 17 Sep  7 13:44 S12rsyslog -> ../init.d/rsyslog

lrwxrwxrwx. 1 root root 15 Sep  7 13:44 S90crond -> ../init.d/crond

lrwxrwxrwx. 1 root root 19 Sep  7 13:44 K75udev-post -> ../init.d/udev-post

lrwxrwxrwx. 1 root root 17 Sep  7 13:44 K30postfix -> ../init.d/postfix

lrwxrwxrwx. 1 root root 15 Sep  7 13:44 K75netfs -> ../init.d/netfs

lrwxrwxrwx. 1 root root 19 Sep  7 13:44 K85mdmonitor -> ../init.d/mdmonitor

lrwxrwxrwx. 1 root root 22 Sep  7 13:44 K99lvm2-monitor -> ../init.d/lvm2-monitor

lrwxrwxrwx. 1 root root 15 Sep  7 13:44 K80kdump -> ../init.d/kdump

lrwxrwxrwx. 1 root root 18 Sep  7 13:44 K92iptables -> ../init.d/iptables

lrwxrwxrwx. 1 root root 19 Sep  7 13:44 K92ip6tables -> ../init.d/ip6tables

lrwxrwxrwx. 1 root root 20 Sep  7 13:44 K90eyshcjdmzg -> ../init.d/eyshcjdmzg

lrwxrwxrwx. 1 root root 26 Sep  7 13:44 K75blk-availability -> ../init.d/blk-availability

lrwxrwxrwx. 1 root root 16 Sep  7 13:44 K88auditd -> ../init.d/auditd

lrwxrwxrwx. 1 root root 17 Sep  7 13:37 K75ntpdate -> ../init.d/ntpdate

lrwxrwxrwx. 1 root root 20 Sep  7 12:15 K50netconsole -> ../init.d/netconsole

lrwxrwxrwx. 1 root root 11 Sep  7 12:15 S99local -> ../rc.local

lrwxrwxrwx. 1 root root 15 Sep  7 12:15 K89rdisc -> ../init.d/rdisc

lrwxrwxrwx. 1 root root 21 Sep  7 12:15 K87restorecond -> ../init.d/restorecond

看到后我只想把这个木马的作者找到然后说收我做徒弟吧。。。。。。。。
于是我又很傻很天真的删除了这些启动脚本,并且kill了相关进程,希望的太阳没有升起,沉重的打击再次来临,木马再次自我复制自我运行了。。。。启动脚本再次出现了。。
我知道我进入了误区,重新想思路。。。

不知道为什么我瞬间想到了我遗漏了一个地方,cron,对。。。我是crontab -l 来查看的,还有个地方的cron任务不会在这个命令下出现/etc/cron.*

[root@Xd9BdoAkG ~]# cat /etc/crontab

SHELL=/bin/bash

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

MAILTO=root

HOME=/

# 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/gcc.sh

[root@Xd9BdoAkG ~]# cat /etc/cron.hourly/gcc.sh

#!/bin/sh

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

for i in `cat /proc/net/dev|grep :|awk -F: {'print $1'}`; do ifconfig $i up& done

cp /lib/libudev.so /lib/libudev.so.6

/lib/libudev.so.6

[root@Xd9BdoAkG ~]# cat /proc/net/dev|grep :|awk -F: {'print $1'}

     lo

    em1

    em2

    em3

    em4

你还知道主动启动网络和外面联系啊。。。。

[root@Xd9BdoAkG ~]# file /lib/libudev.so

/lib/libudev.so: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, for GNU/Linux 2.6.9, not stripped

居然不是脚本什么的,想看文件具体内容暂时是没时间了。。。。。。。

到了这里我们可以确认有几个地方有问题/lib/libudev.so /etc/cron.hourly/gcc.sh /etc/crontab /etc/rc.d/init.d/ /etc/rc.d/rc3.d/

由于对方发送大量数据包,所以开始采取iptables来封禁,发现这玩意直接把output是 state 为new的drop掉。。。。。。。。不想说了,已经被他玩够了,不在乎多一次。。

通过排查可以肯定/lib/libudev.so是主体。其他是协助运行和自我保护自我复制的实现。既然你是个程序还在系统上,我有root,还搞不定么。为了不再多拖时间,直接查杀了。。

[root@Xd9BdoAkG ~]# chmod 0000 /lib/libudev.so && rm -rf /lib/libudev.so && chattr +i /lib/

#在一步一点要这样运行,不然赶不上木马的自我恢复速度。。。。。我在这里坑了很长时间。

[root@Xd9BdoAkG ~]# ls /lib/

cpp  firmware  kbd  modules  security  terminfo  udev

[root@Xd9BdoAkG ~]# ls /lib/

cpp  firmware  kbd  modules  security  terminfo  udev

[root@Xd9BdoAkG ~]# ls /lib/

cpp  firmware  kbd  modules  security  terminfo  udev

[root@Xd9BdoAkG ~]# ls /lib/

cpp  firmware  kbd  modules  security  terminfo  udev

[root@Xd9BdoAkG ~]# ls /lib/

cpp  firmware  kbd  modules  security  terminfo  udev

[root@Xd9BdoAkG ~]# ls /lib/

cpp  firmware  kbd  modules  security  terminfo  udev

##貌似主体被控制住了,不能再次自我恢复了。。。

[root@Xd9BdoAkG ~]# ls /etc/rc.d/rc3.d/ | awk '$7>=8 && $NF~/^K90/{print $NF}' | egrep '^.{10}$'| xargs -i rm -rf /etc/rc.d/rc3.d/{}

chmod 0000 /etc/rc.d/rc3.d/ && chmod 0000 /etc/rc.d/init.d && chattr +i /etc/rc.d/rc3.d/ && chattr +i /etc/rc.d/init.d

#删除启动脚本 awk '$7>=8 && $NF~/^K90/{print $NF}' 这里的8是当天的日期8号的意思,写的不严紧,勿喷~~~

#且控制目录不能写东西了

[root@Xd9BdoAkG ~]# sed '/gcc.sh/d' /etc/crontab && chmod 0000 /etc/crontab && chattr +i /etc/crontab

#删除计划任务且控制计划任务不能写东西

到了这里基本就差不多了。。。。。现在去重启服务器,

尝试查找最近3天内更新的文件

find /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin -mtime -3

/bin

/bin/wfukohsuk

/bin/wfukohsuk.sh

/bin/kushokufw

/usr/bin

/usr/bin/fknnknlajk

/usr/sbin

#停止病毒进程,确认病毒PID

kill -STOP 16452

#查找启动脚本,删除文件(发现病毒的启动文件为S90/K90)

find /etc -name '*90*' | xargs rm -f

#删除病毒文件

rm -rf /etc/cron.hourly/itfitufnyqsvg.sh

#删除病毒文件

find /bin -mtime -1 | xargs rm -f

#杀掉进程

pkill 16452

[root@Xd9BdoAkG ~]# top -b -n1 | head

top - 18:13:47 up 0 min,  1 user,  load average: 0.11, 0.03, 0.01

Tasks: 178 total,   2 running, 176 sleeping,   0 stopped,   0 zombie

Cpu(s):  1.4%us,  1.6%sy,  0.0%ni, 95.7%id,  1.3%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:  32827160k total,   486308k used, 32340852k free,     6864k buffers

Swap: 16482300k total,        0k used, 16482300k free,    28312k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                    

    1 root      20   0 19232 1512 1224 S  0.0  0.0   0:01.26 init                                                                       

    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd                                                                   

    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0

[root@Xd9BdoAkG ~]# top -b -n1 | head

top - 18:13:51 up 0 min,  1 user,  load average: 0.10, 0.03, 0.01

Tasks: 178 total,   1 running, 177 sleeping,   0 stopped,   0 zombie

Cpu(s):  1.3%us,  1.5%sy,  0.0%ni, 96.0%id,  1.2%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:  32827160k total,   486136k used, 32341024k free,     6872k buffers

Swap: 16482300k total,        0k used, 16482300k free,    28344k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                    

 1414 root      20   0 15020 1232  872 R  2.0  0.0   0:00.01 top

    1 root      20   0 19232 1512 1224 S  0.0  0.0   0:01.26 init                                                                       

    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd                                                                   

[root@Xd9BdoAkG ~]# top -b -n1 | head

top - 18:14:15 up 1 min,  1 user,  load average: 0.06, 0.03, 0.01

Tasks: 178 total,   1 running, 177 sleeping,   0 stopped,   0 zombie

Cpu(s):  0.8%us,  0.9%sy,  0.0%ni, 97.6%id,  0.7%wa,  0.0%hi,  0.0%si,  0.0%st

Mem:  32827160k total,   483360k used, 32343800k free,     6900k buffers

Swap: 16482300k total,        0k used, 16482300k free,    28360k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                    

    1 root      20   0 19232 1512 1224 S  0.0  0.0   0:01.26 init                                                                       

    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd                                                                   

    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0

[root@Xd9BdoAkG ~]# ls /etc/cron.hourly/

0anacron

[root@Xd9BdoAkG ~]# ls -lt /etc/rc.d/rc3.d/

total 0

lrwxrwxrwx. 1 root root 15 Sep  7 14:08 S85nginx -> ../init.d/nginx

lrwxrwxrwx. 1 root root 24 Sep  7 13:55 S99libvirt-guests -> ../init.d/libvirt-guests

lrwxrwxrwx. 1 root root 19 Sep  7 13:55 S26haldaemon -> ../init.d/haldaemon

lrwxrwxrwx. 1 root root 19 Sep  7 13:54 K10saslauthd -> ../init.d/saslauthd

lrwxrwxrwx. 1 root root 20 Sep  7 13:54 S22messagebus -> ../init.d/messagebus

lrwxrwxrwx. 1 root root 14 Sep  7 13:51 S55sshd -> ../init.d/sshd

lrwxrwxrwx. 1 root root 18 Sep  7 13:51 K15svnserve -> ../init.d/svnserve

lrwxrwxrwx. 1 root root 17 Sep  7 13:44 S10network -> ../init.d/network

lrwxrwxrwx. 1 root root 17 Sep  7 13:44 S12rsyslog -> ../init.d/rsyslog

lrwxrwxrwx. 1 root root 15 Sep  7 13:44 S90crond -> ../init.d/crond

lrwxrwxrwx. 1 root root 19 Sep  7 13:44 K75udev-post -> ../init.d/udev-post

lrwxrwxrwx. 1 root root 17 Sep  7 13:44 K30postfix -> ../init.d/postfix

lrwxrwxrwx. 1 root root 15 Sep  7 13:44 K75netfs -> ../init.d/netfs

lrwxrwxrwx. 1 root root 19 Sep  7 13:44 K85mdmonitor -> ../init.d/mdmonitor

lrwxrwxrwx. 1 root root 22 Sep  7 13:44 K99lvm2-monitor -> ../init.d/lvm2-monitor

lrwxrwxrwx. 1 root root 15 Sep  7 13:44 K80kdump -> ../init.d/kdump

lrwxrwxrwx. 1 root root 18 Sep  7 13:44 K92iptables -> ../init.d/iptables

lrwxrwxrwx. 1 root root 19 Sep  7 13:44 K92ip6tables -> ../init.d/ip6tables

lrwxrwxrwx. 1 root root 26 Sep  7 13:44 K75blk-availability -> ../init.d/blk-availability

lrwxrwxrwx. 1 root root 16 Sep  7 13:44 K88auditd -> ../init.d/auditd

lrwxrwxrwx. 1 root root 17 Sep  7 13:37 K75ntpdate -> ../init.d/ntpdate

lrwxrwxrwx. 1 root root 20 Sep  7 12:15 K50netconsole -> ../init.d/netconsole

lrwxrwxrwx. 1 root root 11 Sep  7 12:15 S99local -> ../rc.local

lrwxrwxrwx. 1 root root 15 Sep  7 12:15 K89rdisc -> ../init.d/rdisc

lrwxrwxrwx. 1 root root 21 Sep  7 12:15 K87restorecond -> ../init.d/restorecond

开机后发现进程没异常了,世界貌似平静了。。。。

然后再次恢复/etc/crontab /etc/rc.d/init.d/ /etc/rc.d/rc3.d/ /lib文件夹的权限。然后再次重启。。。。。世界真的清静。。。。

Linux之上一次艰难的木马查杀过程相关推荐

  1. Linux之在CentOS上一次艰难的木马查杀过程

    原文地址:https://blog.csdn.net/xpb1980/article/details/76647355 今天朋友说他一台要准备上线的生产服务器被挂马,特征ps命令找不到进程,top能看 ...

  2. centos中bash占用cpu_Linux CentOS 进程CPU占用100%木马查杀过程

    在安装CentOS-6.9-x86_64-minimal.iso之后因为设置用户密码比较简单,并且没有修改默认的22远程端口,导致短时间被扫描入侵,然后服务器疯狂向外发包,因此被自己搞死过好几次别人的 ...

  3. linux服务器杀毒软件命令,悬镜Linux服务器卫士-木马查杀详解

    原标题:悬镜Linux服务器卫士-木马查杀详解 今天悬镜小编详细给大家讲解下悬镜管家中-木马查杀功能的使用情况. 对于WebShell的理解,"Web"显然需要服务器开放Web服务 ...

  4. Linux安全之PHP木马查杀与防范

    1.服务器自身系统安全: 使用最新的操作系统,或者最新的稳定版(比如Ubuntu的LTS),定期打好更新,系统权限合理划分,重要文件做权限安全保护. 比如: # chattr +i /etc/pass ...

  5. Linux下 XordDos(BillGates)木马查杀记录

    最近朋友的一台服务器突然网络异常,cpu占用率暴表,登录上去一查,cpu占用300% 左右,流量异常,经过看查进程,获取信息最终确认为中了dos木马,经过几天的研究,基本上已经清除,以下是清理记录. ...

  6. svcagent32.exe,javaM.exe木马查杀解决方案 (转Ad0.cn)

    svcagent32.exe,javaM.exe木马查杀解决方案(Ad0.cn原创) svcagent32.exe, svcupdate.exe木马查杀方案(病毒清除)! svcagent32木马特征 ...

  7. 病毒木马查杀实战第009篇:QQ盗号木马之手动查杀

    前言 之前在<病毒木马查杀第002篇:熊猫烧香之手动查杀>中,我在不借助任何工具的情况下,基本实现了对于"熊猫烧香"病毒的查杀.但是毕竟"熊猫烧香" ...

  8. 病毒木马查杀实战第026篇:“白加黑”恶意程序研究(上)

    前言 众所周知,传统的恶意程序都是由单一文件构成的.从而实现某一种或者几种恶意功能. 而这类的恶意程序为了避免被发现以及被查杀,往往会採用五花八门的自我隐藏技术以及免杀技术,病毒程序的作者非常多时候也 ...

  9. 病毒木马查杀实战第010篇:QQ盗号木马之十六进制代码分析

    前言 按照我的个人习惯,在运用诸如IDA Pro与OllyDBG对病毒进行逆向分析之前,我都会利用一些自动化的工具,通过静态或动态的分析方法(参见<病毒木马查杀第008篇:熊猫烧香之病毒查杀总结 ...

最新文章

  1. Codeforces Round #535 (Div. 3)题解
  2. 夺命雷公狗---linux NO:22 linux下的yum安装的高级配置
  3. js深入研究之牛逼的类封装设计
  4. 初等数论--整除--带余除法
  5. linux c之解决array subscript is not integer和AF_NET not undeclared
  6. python函数:函数参数,常用函数工具
  7. Python面向对象编程三大特性之继承
  8. 苹果因不附赠充电头被罚200万美元,网友:该,大快人心!
  9. STM32L5特性简介 Cortex-M33内核TEE-TrustZone信息安全
  10. 浅谈分布式计算的开发与实现(二)
  11. [转载] Python学习之Numpy
  12. default value of template parameter c++
  13. html字体颜色代码表,字体颜色代码
  14. 无线网络何连不到服务器,关于电脑宾馆连接不上无线网络的解决方法
  15. 拉卡拉服务器响应超时,拉卡拉传统POS机11个常见问题及解决方法
  16. php手册3.1,thinkphp3.1手册下载|
  17. JDBC编程(Java操作数据库 MySQL)
  18. 反射(三) 笔记
  19. MySQL 所推荐的左右值法(毗邻目录法、预排序历遍法)
  20. 统计学(一): Z 分数 正态分布 (附 Python 实现代码) --Z 检验先修; Z 分数与正态分布两者关系; Z 分数与百分位数的异同;面试要点(以心理学实验为舟)

热门文章

  1. css旋转动画定义中心,CSS实现弹簧效果的旋转加载动画
  2. Rapidjson的简单使用
  3. jsp中的EL表达式用法
  4. 7-2 求集合数据的均方差
  5. Python3.7总结字符串的print和拼接
  6. python-alipay-sdk
  7. 详细的GStreamer开发教程
  8. 什么牌子的蓝牙耳机耐用?2023年最值得入手的蓝牙耳机推荐
  9. 科学养猪,5G工业网关赋能养殖业走上“快车道”
  10. 数据是怎么传输的?什么是数据通信?