记一次给 XCRH 的杀毒经历

Rei SuzunamiAnti-virusVPS maintainenceVirusMining大约 5 分钟

记一次给 XCRH 的杀毒经历

一封来自遥远西方的邮件

某天早上一起床,就收到 XCRH 的信息,说是主机提供商 RackNerd 给他发了一封奇怪的邮件。

我点开截图一看,这不是典型的 SSH Abuse 嘛。还好之前为了维护方便,挂了探针到他的机器上。点开一看,好家伙,CPU 占用 100% ,看得我头皮发麻。

XCRH 的机器只用来搭博客,Hexo 的静态页面怎么说都不可能占用如此高的 CPU 负载。一个念头划过我的脑海:莫不是中了挖矿病毒?

邮件内容

Hello,

RackNerd has received an abuse complaint concerning your service racknerd-5dd6e4.

For more on our Terms of Service and Acceptable Use Policy, please visit:

https://www.racknerd.com/terms-of-serviceopen in new window

We await your response to the below abuse complaint. =-=-=-=-=-=-=-= An attempt to brute-force account passwords over SSH/FTP by a machine in your domain > or in your network has been detected. Attached are the host who attacks and time / > date of activity. Please take the necessary action(s) to stop this activity > immediately. If you have any questions please reply to this email.

Host of attacker: 23.94.. => 23.94.. => 23.94.. Responsible email contacts: [email protected] Attacked hosts in our Network: 77.75.., 91.151.., 178.250.., 37.228..

Logfile entries (time is CE(S)T): Sun Mar 26 20:17:54 2023: user: root service: ssh target: 178.250*.* source: 23.94*.* Sun Mar 26 20:16:54 2023: user: root service: ssh target: 77.75*.source: 23.94..* Sun Mar 26 20:16:00 2023: user: root service: ssh target: 37.228*.* source: 23.94.. Sun Mar 26 20:15:01 2023: user: root service: ssh target: 91.151*.* source: 23.94.. Sun Mar 26 20:14:24 2023: user: root service: ssh target: 178.250*.* source: 23.94.. ...

Regards, Profihost AG Team

The recipient address of this report was provided by the Abuse Contact DB by abusix.> com. Abusix provides a free proxy DB service which provides the abuse@ address for all > global RIRs. Abusix does not maintain the core DB content but provides a service built on top of > the RIR databases. If you wish to change or report a non-working abuse contact address. please contact the appropriate RIR responsible for managing the underlying data. If you have any further questions about using the Abusix Abuse Contact DB, please > either contact abusix.comopen in new window directly via email ([email protected]) or visit the URL > here: https://abusix.com/contactdbopen in new window

Abusix is neither responsible nor liable for the content or accuracy of this message. =-=-=-=-=-=-=-= Thank You,

RackNerd Abuse Department [email protected] 888-881-NERD (6373)

(为保护隐私,已隐去 IP 地址的后两位。)

排查原因

top 定位具体进程

  • 我惊奇地发现,占用了高达 90+% CPU 负载的竟然是一个素未谋面的 kswapd 进程,还是由 XCRH 的博客调试用户 blog 所启动的。

使用 ps aux | grep 进程名 获取详细信息

  • 发现它在 /tmp 目录下隐藏了数个本体文件,类似下面的样例:
 ps aux | grep tsm
root      96052  0.0  0.0  11552    88 ?        S    11:14   0:00 timeout 3h ./tsm -t 515 -f 1 -s 12 -S 10 -p 0 -d 1 p ip
root      96053  0.0  0.0  12512   196 ?        S    11:14   0:00 /bin/bash ./tsm -t 515 -f 1 -s 12 -S 10 -p 0 -d 1 p ip
root      96058 43.7  1.7 5263372 60524 ?       Sl   11:14  66:54 /tmp/.X25-unix/.rsync/c/lib/64/tsm --library-path /tmp/.X25-unix/.rsync/c/lib/64/ /usr/sbin/httpd rsync/c/tsm64 -t 515 -f 1 -s 12 -S 10 -p 0 -d 1 p ip
ubuntu   118586  0.0  0.0  11552    84 ?        S    13:22   0:00 timeout 3h ./tsm -t 515 -f 1 -s 12 -S 10 -p 0 -d 1 p ip
ubuntu   118587  0.0  0.0  12512   652 ?        S    13:22   0:00 /bin/bash ./tsm -t 515 -f 1 -s 12 -S 10 -p 0 -d 1 p ip
ubuntu   118592 13.3  1.0 5263336 37160 ?       Sl   13:22   3:15 /tmp/.X25-unix/.rsync/c/lib/64/tsm --library-path /tmp/.X25-unix/.rsync/c/lib/64/ /usr/sbin/httpd rsync/c/tsm64 -t 515 -f 1 -s 12 -S 10 -p 0 -d 1 p ip

使用 ps -ef | grep bash 获取命令历史信息

  • 发现仅有 blog 用户使用了此病毒,关键的 root 权限并未丢失。
  • 情况大致如下所示,由一个 tsm 与一个 go 文件组成。(GoLang 首先在病毒界证明了自己的价值)
 ps -ef | grep bash
ubuntu      564    563  0 14:19 ?        00:00:00 /bin/bash ./tsm -t 515 -f 1 -s 12 -S 10 -p 0 -d 1 p ip
root       1196   1195  0 14:19 ?        00:00:00 /bin/bash ./tsm -t 515 -f 1 -s 12 -S 10 -p 0 -d 1 p ip
root       5988   5987  0 May18 pts/2    00:00:01 /bin/bash
ubuntu    55500  55499  0 Apr23 pts/2    00:00:00 -bash
ubuntu    75581      1  0 May13 ?        00:00:03 /bin/bash ./go
root     103117      1  0 May03 ?        00:00:04 /bin/bash ./go

做好清理

清理 /tmp 目录

  • 看了一圈发现似乎并没有什么重要文件存储在此目录下,干脆 rm -rf * 一删了之。
  • 然而目标进程依然没有终止,kill 命令也没有作用。于是继续追查。

清理 crontab/home/blog

crontab

  • 切到受感染用户之后查看 crontab -e ,发现它的 crontab 被写满了保活脚本。遂删除之。

/home/blog 目录下的隐藏文件

  • 使用 ls -a 发现了名为 .bashrc5 的奇怪目录,内含了名为 dota3.tar.gz 的神秘文件。由于这是建站目的的 VPS ,故不可能存在游戏压缩包,遂删除之。

清理 /home/blog/.ssh 目录

  • 此类病毒渗透的一个特点就是会注入自己的 SSH 密钥方便远控。
  • 由于该用户没有远程登陆需求,故直接删除 .ssh 目录。

清理 /home/blog/.configrc

  • 同样是定时任务保活脚本。清理之。

检查清理情况

  • reboot 之后 CPU 占用恢复正常。观察一段时间后无变化。暂时视为杀毒完成。

后续处理

  • 后来给 RackNerd 回信,表示很抱歉,有人渗透进了我们的系统,我们已经第一时间处理完毕。
  • RackNerd 的限制总体而言还是很宽松的,既没有直接停机也没有因为 CPU 爆满开罚单,可能是因为荷兰的母机性能溢出太厉害了吧。
  • 之后 XCRH 迁移了博客部署系统到 root 用户上,blog 用户就给删掉了。这样也好,毕竟 root 用户使用的是密钥验证,攻击者没办法通过密码偷渡进来。
  • 其实 fail2ban 也是一种解决方案,但是之前目睹了 NaiveTomcat 被自家机器 ban 了之后,莫名对其产生了恐惧。

参考资料

One More Thing

另外小小推荐下这家 RackNerd 主机商,现在正是复活节促销季,只要 10.88$ 就能抱回一只 840MB RAM 的小 VPS ,性能尚可网络还行,实乃居家旅行、代理建站之必备。

上次编辑于:
贡献者: Rei Suzunami / 鈴波 靈
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.14.9