非专业人事第一次处理挖矿木马,脱壳啥的也不会,一点一点找到并删除相关文件,最后整理为清理脚本
事由
发现我的esxi内的Gitlab虚机连不上了,登录显示ERROR:ld.so:object '/usr/local/lib/libprocessshider.so' from /etc/ld.so.preload cannot be preloaded: ignored.,机子卡的基本属于断连状态。
console和SSH登录显示异常:


后发现相同网段其他设备也有这个问题,但是可以正常登录,就先上另一台设备处理(代号:33)
检查
表征问题
- CPU 占用 100%
- 空闲内存低
- 输命令经常会出
ERROR:ld.so:...ignored. - 会有异常定时任务
会有一个update.sh或者root.sh的文件,进程会看到curl请求并运行一个脚本,相关进程已经隐藏,不在进程列表显示
系统资源占用,但是没有相关进程显示:

检查主要看几个常见的地儿,有没有最近同一时间创建或者修改的内容,像/sbin/,/bin/,/etc/init.d,/etc/corn*/,可疑用户等
有关木马的分析可以看:精准投放Tsunami僵尸网络和“魔铲”挖矿木马的行动分析
清理
参考其他人清理挖矿木马的过程
先清空
/etc/ld.so.preload1
2echo "" > /etc/ld.so.preload
rm -rf /usr/local/lib/libprocesshider.so删除可疑服务
pwnrigl.service和ntpdate.service1
2
3chattr -ia /usr/lib/systemd/system/pwnrigl.service /usr/lib/systemd/system/ntpdate.service > /dev/null 2>&1
systemctl stop pwnrigl.service ntpdate.service && systemctl disable pwnrigl.service ntpdate.service
rm -rf /usr/lib/systemd/system/pwnrigl.service /usr/lib/systemd/system/ntpdate.service清空定时任务,删除建的用户
x1
2
3crontab -r && crontab -u x -r > /dev/null 2>&1
chattr -ia /etc/cron*/ntpdate /etc/cron*/pwnrig > /dev/null 2>&1 && rm -rf /etc/cron*/ntpdate /etc/cron*/pwnrig
userdel -r x > /dev/null 2>&1 && rm -rf /home/x删除所有释放的程序
1
2
3
4
5
6
7rm -rf /var/tmp /tmp/*
pkill -f '\-bash'
chattr -ia /bin/sysdr /bin/initdr /bin/crondr /bin/bprofr /bin/-bash > /dev/null 2>&1
rm -rf /bin/sysdr /bin/initdr /bin/crondr /bin/bprofr /bin/-bash
chattr -ia /sbin/lntpdate /sbin/entpdate /sbin/bsysd /sbin/binitd /sbin/bcrond /sbin/msysd /sbin/minitd /sbin/mcrond /sbin/-bash > /dev/null 2>&1
rm -rf /sbin/lntpdate /sbin/entpdate /sbin/bsysd /sbin/binitd /sbin/bcrond /sbin/msysd /sbin/minitd /sbin/mcrond /sbin/-bash
chattr -ia /etc/init.d/ntpdate /etc/init.d/pwnrig > /dev/null 2>&1 && rm -rf /etc/init.d/ntpdate /etc/init.d/pwnrig删除.bash_profile中的异常命令
1
chattr -ia /$USER/.bash_profile > /dev/null 2>&1 && sed -i '/bprofr/d' /$USER/.bash_profile
清理脚本
Gist 地址:clean.sh
1 |
|
