有一个客户服务器root密码设置很简单,被***挂马了。top能看到名称大概为10个字母的进程,字母是随机的。一看就不是正常进程(而且杀掉问题进程会自动生成新的、删除问题服务也会自动生成、很占用服务器带宽总是连接外网一个主机)。这种情况下,一般建议断开外网,然后处理。
问题现象:
1、查看定时任务(注意这三个地方都看下)
[root@localhost ~]# crontab -l
[root@localhost ~]# vi /etc/crontab
[root@localhost ~]# ll /etc/cron.*
#这个里面有异常定时任务。
[root@localhost ~]# 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@localhost ~]# 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@localhost ~]# cat /proc/net/dev|grep :|awk -F: {'print $1'}
lo
eth0
#脚本里面的文件
[root@localhost ~]# 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
2、查看启动服务,有异常服务。
/etc/rc.d/{init.d,rc{1,2,3,4,5}.d}/
[root@localhost ~]# cat /etc/rc.d/init.d/eregsdfdzk
#!/bin/sh
# chkconfig: 12345 90 90
# description: eregsdfdzk
### BEGIN INIT INFO
# Provides: eregsdfdzk
# Required-Start:
# Required-Stop:
# Default-Start: 1 2 3 4 5
# Default-Stop:
# Short-Description: eregsdfdzk
### END INIT INFO
case $1 in
start)
/usr/bin/eregsdfdzk
;;
stop)
;;
*)
/usr/bin/eregsdfdzk
;;
esac
可以确定如下特点:
(1)这几个地方有我呢提/lib/libudev.so /etc/cron.hourly/gcc.sh /etc/crontab /etc/rc.d/init.d/ /etc/rc.d/rc3.d/
(2)会连接外网的一个地址,防火墙屏蔽也没有用,它会把output是state 为new的drop掉。
(3)/lib/libudev.so应该是主程序。其他是协助运行和自我保护自我复制的实现。
解决办法:
#注意,一定连着执行,要不你的速度超过不了它重新生成的速度。
[root@localhost ~]# chmod 0000 /lib/libudev.so && rm -rf /lib/libudev.so && chattr +i /lib/
#验证libudev.so已经删除了。
[root@localhost ~]# ls /lib/
cpp firmware kbd modules security terminfo udev
[root@localhost ~]# ls /lib/
cpp firmware kbd modules security terminfo udev
#删除问题服务并锁定服务目录。
[root@localhost ~]#到/etc/rc.d/rc3.d/和/etc/rc.d/init.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
#删除定时任务并锁定配置文件。
[root@localhost ~]# sed '/gcc.sh/d' /etc/crontab && chmod 0000 /etc/crontab && chattr +i /etc/crontab
#重启服务器top观察、查看定时任务、服务。
#如果正常了,就再恢复权限和解锁,然后再观察。
历史资源提醒--必看
该页面资源/教程来自原魔趣吧历史资源转移,因发布历史久远,部分资源/教程可能已失效或无法在最新版程序中安装使用!DZ资源建议在Discuz3.4及以下版本使用,PHP版本建议5.6。资源仅提供做代码研究学习使用!
因改版,部分贴内链接将无法正常跳转,如链接失效或未正常跳转,请利用站内搜索功能搜索资源名称获取对应资源!