Linux CentOS 進(jìn)程CPU占用100%木馬查殺過程
技術(shù)支持服務(wù)電話:15308000360 【7x24提供運(yùn)維服務(wù),解決各類系統(tǒng)/軟硬件疑難技術(shù)問題】
在安裝CentOS-6.9-x86_64-minimal.iso之后因為設(shè)置用戶密碼比較簡單,并且沒有修改默認(rèn)的22遠(yuǎn)程端口,導(dǎo)致短時間被掃描入侵,然后服務(wù)器瘋狂向外發(fā)包,因此被自己搞死過好幾次別人的機(jī)房部分網(wǎng)絡(luò),當(dāng)時我并未注意,還認(rèn)為是獲取的鏡像源有問題,所以封鎖向外發(fā)包就沒事了,不過過了很久之后我發(fā)現(xiàn)服務(wù)器CPU一直100%但是并無異常,不過TOP查看進(jìn)程后看到一個進(jìn)程非常奇怪,是一個隨機(jī)的10位字母進(jìn)程,這就引起了我的注意,于是開始漫長折騰之路...
首先我kill掉該進(jìn)程之后它會自動再次出現(xiàn)一個新的隨機(jī)10位字母的進(jìn)程,我確定是中毒了,而且這個木馬有自我恢復(fù)能力。
TOP執(zhí)行后查看到一個異常進(jìn)程
[root@cloud cron.hourly]# top top - 00:35:21 up 10 min, 1 user, load average: 2.68, 2.18, 1.19 Tasks: 484 total, 1 running, 483 sleeping, 0 stopped, 0 zombie Cpu(s): 5.6%us, 3.1%sy, 0.0%ni, 90.8%id, 0.4%wa, 0.0%hi, 0.1%si, 0.0%st Mem: 8026932k total, 1084296k used, 6942636k free, 80368k buffers Swap: 8388604k total, 0k used, 8388604k free, 282692k cached PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 2918 root 20 0 32664 580 200 S 136.3 0.0 10:37.95 LWnS6b6qrw 1743 root 20 0 66236 1200 484 S 5.5 0.0 0:40.08 sshd 74026 root 20 0 15288 1520 892 R 5.5 0.0 0:00.06 top 1644 root 16 -4 93132 872 608 S 3.7 0.0 0:18.06 auditd 1666 root 20 0 246m 8632 1116 S 1.8 0.1 0:16.20 rsyslogd ...
這時候我想到一個問題我都沒執(zhí)行過這個進(jìn)程他怎么會一直存在呢?這玩意肯定是開機(jī)啟動,要么/etc/rc.d/{init.d,rc{1,2,3,4,5}.d}/下有啟動腳本,要么有cron計劃任務(wù)。 于是我發(fā)現(xiàn)crontab -l是正常的,來到/etc/rc.d/init.d下發(fā)現(xiàn)了異常有10位字母的啟動腳本,腳本內(nèi)容如下:
[root@cloud ~]# cat /etc/rc.d/init.d/LWnS6b6qrw #!/bin/sh # chkconfig: 12345 90 90 # description: LWnS6b6qrw ### BEGIN INIT INFO # Provides: LWnS6b6qrw # Required-Start: # Required-Stop: # Default-Start: 1 2 3 4 5 # Default-Stop: # Short-Description: LWnS6b6qrw ### END INIT INFO case $1 in start) /usr/bin/LWnS6b6qrw ;; stop) ;; *) /usr/bin/LWnS6b6qrw ;; esac
經(jīng)過查找
/etc/rc.d/rc1.d/
/etc/rc.d/rc2.d/
/etc/rc.d/rc3.d/
/etc/rc.d/rc4.d/
/etc/rc.d/rc5.d/
/etc/rc.d/rc6.d/
這些目錄下均存在木馬軟鏈接
[root@cloud init.d]# cd /etc/rc.d/rc1.d/
[root@cloud rc3.d]# ll
total 0
lrwxrwxrwx. 1 root root 19 Nov 20 2016 K10saslauthd -> ../init.d/saslauthd
lrwxrwxrwx. 1 root root 18 Nov 23 2016 K15svnserve -> ../init.d/svnserve
lrwxrwxrwx. 1 root root 20 Nov 20 2016 K87multipathd -> ../init.d/multipathd
lrwxrwxrwx. 1 root root 21 Nov 20 2016 K87restorecond -> ../init.d/restorecond
lrwxrwxrwx. 1 root root 20 Nov 20 2016 K89netconsole -> ../init.d/netconsole
lrwxrwxrwx. 1 root root 15 Nov 20 2016 K89rdisc -> ../init.d/rdisc
lrwxrwxrwx. 1 root root 22 Nov 20 2016 S02lvm2-monitor -> ../init.d/lvm2-monitor
lrwxrwxrwx. 1 root root 16 Nov 20 2016 S07iscsid -> ../init.d/iscsid
lrwxrwxrwx. 1 root root 19 Nov 20 2016 S08ip6tables -> ../init.d/ip6tables
lrwxrwxrwx. 1 root root 18 Nov 20 2016 S08iptables -> ../init.d/iptables
lrwxrwxrwx. 1 root root 17 Nov 20 2016 S10network -> ../init.d/network
lrwxrwxrwx. 1 root root 16 Nov 20 2016 S11auditd -> ../init.d/auditd
lrwxrwxrwx. 1 root root 17 Nov 20 2016 S12rsyslog -> ../init.d/rsyslog
lrwxrwxrwx. 1 root root 15 Nov 20 2016 S13iscsi -> ../init.d/iscsi
lrwxrwxrwx. 1 root root 19 Nov 20 2016 S15mdmonitor -> ../init.d/mdmonitor
lrwxrwxrwx. 1 root root 26 Nov 20 2016 S25blk-availability -> ../init.d/blk-availability
lrwxrwxrwx. 1 root root 15 Nov 20 2016 S25netfs -> ../init.d/netfs
lrwxrwxrwx. 1 root root 19 Nov 20 2016 S26udev-post -> ../init.d/udev-post
lrwxrwxrwx. 1 root root 19 Nov 23 2016 S50php56-fpm -> ../init.d/php56-fpm
lrwxrwxrwx. 1 root root 14 Nov 20 2016 S55sshd -> ../init.d/sshd
lrwxrwxrwx. 1 root root 17 Nov 22 2016 S64mariadb -> ../init.d/mariadb
lrwxrwxrwx. 1 root root 17 Nov 20 2016 S80postfix -> ../init.d/postfix
lrwxrwxrwx. 1 root root 15 Nov 23 2016 S85httpd -> ../init.d/httpd
lrwxrwxrwx. 1 root root 15 Nov 20 2016 S90crond -> ../init.d/crond
lrwxrwxrwx. 1 root root 22 Jun 12 00:25 S90LWnS6b6qrw -> /etc/init.d/LWnS6b6qrw
lrwxrwxrwx. 1 root root 11 Nov 20 2016 S99local -> ../rc.local
同時想到計劃任務(wù)是否會被串改,于是查看:
[root@cloud ~]# 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
果然被串改,最后一句是被增加上去的
再跟蹤/etc/cron.hourly/gcc.sh后發(fā)現(xiàn)
[root@cloud ~]# 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
到了這里我們可以確認(rèn)有幾個地方有問題
/lib/libudev.so
/etc/cron.hourly/gcc.sh
/etc/crontab
/etc/rc.d/init.d/
/etc/rc.d/{init.d,rc{1,2,3,4,5}.d}/
/etc/cron.hourly/gcc.sh
/etc/crontab
/etc/rc.d/init.d/
/etc/rc.d/{init.d,rc{1,2,3,4,5}.d}/
最后處理方法:
搜索并刪除所有病毒 LWnS6b6qrw (你的系統(tǒng)中可能名稱不一樣請仔細(xì)核對)
刪掉所有啟動目錄下的 S90LWnS6b6qrw 病毒軟鏈接(注意:如果你的服務(wù)器是其他病毒名稱,請仔細(xì)核對)。
搜索并刪除 libudev.so 和 libudev.so.6
刪除計劃任務(wù)多余的病毒代碼 */3 * * * * root /etc/cron.hourly/gcc.sh
刪除病毒配置文件 root /etc/cron.hourly/gcc.sh
重啟后發(fā)現(xiàn)進(jìn)程沒異常了
如果你依然無法解決,請聯(lián)系QQ:38585404 電話:15308000360 有償幫助你解決
如果你依然無法解決,請聯(lián)系QQ:38585404 電話:15308000360 有償幫助你解決