ActiveMQ FileServer漏洞(详细)

时间:2023-03-09 19:32:44
ActiveMQ FileServer漏洞(详细)

半个月前,巡检时发现服务器出现不明进程,对其进行了处理,由于当时没有做详细记录,在这里把大致过程描述一下.

症状:

ps命令发现出现几个不明进程,

  1.于/tmp下运行的,名称随机的进程.占用CPU高达100%,确认为挖矿机

  2.于activemq下运行的不明进程,占用CPU很低,kill -9 杀死进程后会自动重启(当时以为是activemq的正常进程,后核对后发现该进程不属于activemq)

crontab -l,发现5分钟一次的计划任务,于某IP下载shell脚本

处理过程:

1.直接杀死/tmp下运行的程序

2.该服务器运行了redis和activemq,因为redis曾报过一次漏洞,所以第一怀疑是redis.

3.google后发现redis的可能性比较,于是查了一下activemq的漏洞

4.确认为activemq管理存在弱口令,而activemq的fileserver存在远程执行命令漏洞,导致出现该问题,官方:http://activemq.apache.org/security-advisories.data/CVE-2016-3088-announcement.txt

见http://www.2cto.com/article/201607/522259.html

处理方法:

依照官方处理意见,关闭fileserver功能,重启activemq

更详细的安全策略,请参见阿里云帮助文档https://help.aliyun.com/knowledge_detail/50436.html


time:2017年7月6日10:26:33

今天巡检服务器时,发现activemq被入侵,与上述情况完全相同,现提供完整现场.(怪我当时没把其他服务器的漏洞也堵上)

# ps axuf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 3700 0.1 7.1 4716220 573796 ? Sl Apr27 192:18 /root/jdk1.8.0_121/bin/java -Xms1G -Xmx1G -Djava.util.logging.....省略后面
root 21062 299 0.5 492564 48000 ? Sl 00:15 1826:58 \_ ./avx2 -a lyra2z -o stratum+tcp://

可以看出,该挖矿程序是利用activemq运行的,并置于activemq目录下

# ll
总用量 1280
-rwxr-xr-x 1 mysql games 22287 10月 15 2013 activemq
-rwxr-xr-x 1 mysql games 5748 10月 15 2013 activemq-admin
-rw-r--r-- 1 mysql games 16110 10月 15 2013 activemq.jar
-rwxrwxrwx 1 root root 1152776 7月 4 12:50 avx2
-rwxr-xr-x 1 mysql games 6189 10月 15 2013 diag
drwxr-xr-x 2 root root 4096 4月 27 17:16 linux-x86-32
drwxr-xr-x 2 root root 4096 4月 27 17:16 linux-x86-64
drwxr-xr-x 2 root root 4096 4月 27 17:16 macosx
-rwxr-xr-x 1 mysql games 83820 10月 15 2013 wrapper.jar
# file avx2
avx2: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, stripped
# stat avx2
File: "avx2"
Size: 1152776 Blocks: 2256 IO Block: 4096 普通文件
Device: fc01h/64513d Inode: 665319 Links: 1
Access: (0777/-rwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-07-06 00:15:59.578818060 +0800
Modify: 2017-07-04 12:50:18.000000000 +0800
Change: 2017-07-06 00:15:55.004817830 +0800

# uptime
10:33:58 up 69 days, 17:42, 1 user, load average: 3.00, 3.00, 2.98

负载已经成功彪上了3

线杀死该挖矿机

# kill -9 21062
# ps axuf | grep avx2
root 21638 0.0 0.0 103332 832 pts/0 S+ 10:35 0:00 \_ grep avx2
# uptime
10:35:30 up 69 days, 17:43, 1 user, load average: 1.41, 2.58, 2.84

负载已经在回落.

进入activemq的配置目录,备份原文件

# cd /opt/apache-activemq-5.9.0/conf/
# cp jetty.xml jetty.xml.bak

删除fileserver配置项

# vim jetty.xml
              <bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/admin" />
<property name="resourceBase" value="${activemq.home}/webapps/admin" />
<property name="logUrlOnStart" value="true" />
</bean>
<!--删除下面选项

<bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/fileserver" />
<property name="resourceBase" value="${activemq.home}/webapps/fileserver" />
<property name="logUrlOnStart" value="true" />
<property name="parentLoaderPriority" value="true" />
</bean>
-->

<bean class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/api" />
<property name="resourceBase" value="${activemq.home}/webapps/api" />
<property name="logUrlOnStart" value="true" />
</bean>

修改控制台密码

# vim jetty-realm.properties

admin: NEW_PASSWORD, admin
user: NEW_PASSWORD, user

重启activemq,将端口加入防火墙.

后期将使用单独的用户启动activemq.