Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

170 sources

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

Repository files39

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

workspace/decomp/HeyRomUpdate/sources/org/apache/commons/compress/harmony/pack200/PackingUtils.java

Java · 9,435 bytes
package org.apache.commons.compress.harmony.pack200;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import org.apache.commons.compress.harmony.pack200.Archive;

/* loaded from: classes.dex */
public class PackingUtils {
    private static FileHandler fileHandler;
    private static PackingLogger packingLogger = new PackingLogger("org.harmony.apache.pack200", null);

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes.dex */
    public static final class PackingLogger extends Logger {
        private boolean verbose;

        protected PackingLogger(String name, String resourceBundleName) {
            super(name, resourceBundleName);
        }

        @Override // java.util.logging.Logger
        public void log(LogRecord logRecord) {
            if (this.verbose) {
                super.log(logRecord);
            }
        }

        public void setVerbose(boolean isVerbose) {
            this.verbose = isVerbose;
        }
    }

    static {
        LogManager.getLogManager().addLogger(packingLogger);
    }

    public static void config(PackingOptions options) throws IOException {
        String logFileName = options != null ? options.getLogFile() : null;
        FileHandler fileHandler2 = fileHandler;
        if (fileHandler2 != null) {
            fileHandler2.close();
        }
        if (logFileName != null) {
            FileHandler fileHandler3 = new FileHandler(logFileName, false);
            fileHandler = fileHandler3;
            fileHandler3.setFormatter(new SimpleFormatter());
            packingLogger.addHandler(fileHandler);
            packingLogger.setUseParentHandlers(false);
        }
        if (options != null) {
            packingLogger.setVerbose(options.isVerbose());
        }
    }

    public static void copyThroughJar(JarFile jarFile, OutputStream outputStream) throws IOException {
        JarOutputStream jarOutputStream = new JarOutputStream(outputStream);
        try {
            jarOutputStream.setComment("PACK200");
            byte[] bytes = new byte[16384];
            Enumeration<JarEntry> entries = jarFile.entries();
            while (entries.hasMoreElements()) {
                JarEntry jarEntry = entries.nextElement();
                jarOutputStream.putNextEntry(jarEntry);
                InputStream inputStream = jarFile.getInputStream(jarEntry);
                while (true) {
                    try {
                        int bytesRead = inputStream.read(bytes);
                        if (bytesRead == -1) {
                            break;
                        } else {
                            jarOutputStream.write(bytes, 0, bytesRead);
                        }
                    } finally {
                    }
                }
                jarOutputStream.closeEntry();
                log("Packed " + jarEntry.getName());
                if (inputStream != null) {
                    inputStream.close();
                }
            }
            jarFile.close();
            jarOutputStream.close();
        } catch (Throwable th) {
            try {
                jarOutputStream.close();
            } catch (Throwable th2) {
                th.addSuppressed(th2);
            }
            throw th;
        }
    }

    public static void copyThroughJar(JarInputStream jarInputStream, OutputStream outputStream) throws IOException {
        Manifest manifest = jarInputStream.getManifest();
        JarOutputStream jarOutputStream = new JarOutputStream(outputStream, manifest);
        try {
            jarOutputStream.setComment("PACK200");
            log("Packed META-INF/MANIFEST.MF");
            byte[] bytes = new byte[16384];
            while (true) {
                JarEntry jarEntry = jarInputStream.getNextJarEntry();
                if (jarEntry != null) {
                    jarOutputStream.putNextEntry(jarEntry);
                    while (true) {
                        int bytesRead = jarInputStream.read(bytes);
                        if (bytesRead != -1) {
                            jarOutputStream.write(bytes, 0, bytesRead);
                        }
                    }
                    log("Packed " + jarEntry.getName());
                } else {
                    jarInputStream.close();
                    jarOutputStream.close();
                    return;
                }
            }
        } catch (Throwable th) {
            try {
                jarOutputStream.close();
            } catch (Throwable th2) {
                th.addSuppressed(th2);
            }
            throw th;
        }
    }

    public static List<Archive.PackingFile> getPackingFileListFromJar(JarFile jarFile, boolean keepFileOrder) throws IOException {
        List<Archive.PackingFile> packingFileList = new ArrayList<>();
        Enumeration<JarEntry> jarEntries = jarFile.entries();
        while (jarEntries.hasMoreElements()) {
            JarEntry jarEntry = jarEntries.nextElement();
            InputStream inputStream = jarFile.getInputStream(jarEntry);
            try {
                byte[] bytes = readJarEntry(jarEntry, new BufferedInputStream(inputStream));
                packingFileList.add(new Archive.PackingFile(bytes, jarEntry));
                if (inputStream != null) {
                    inputStream.close();
                }
            } catch (Throwable th) {
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (Throwable th2) {
                        th.addSuppressed(th2);
                    }
                }
                throw th;
            }
        }
        if (!keepFileOrder) {
            reorderPackingFiles(packingFileList);
        }
        return packingFileList;
    }

    public static List<Archive.PackingFile> getPackingFileListFromJar(JarInputStream jarInputStream, boolean keepFileOrder) throws IOException {
        List<Archive.PackingFile> packingFileList = new ArrayList<>();
        Manifest manifest = jarInputStream.getManifest();
        if (manifest != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            manifest.write(baos);
            packingFileList.add(new Archive.PackingFile("META-INF/MANIFEST.MF", baos.toByteArray(), 0L));
        }
        while (true) {
            JarEntry jarEntry = jarInputStream.getNextJarEntry();
            if (jarEntry == null) {
                break;
            }
            byte[] bytes = readJarEntry(jarEntry, new BufferedInputStream(jarInputStream));
            packingFileList.add(new Archive.PackingFile(bytes, jarEntry));
        }
        if (!keepFileOrder) {
            reorderPackingFiles(packingFileList);
        }
        return packingFileList;
    }

    public static void log(String message) {
        packingLogger.log(Level.INFO, message);
    }

    private static byte[] readJarEntry(JarEntry jarEntry, InputStream inputStream) throws IOException {
        long size = jarEntry.getSize();
        if (size > 2147483647L) {
            throw new IllegalArgumentException("Large Class!");
        }
        if (size < 0) {
            size = 0;
        }
        byte[] bytes = new byte[(int) size];
        if (inputStream.read(bytes) != size) {
            throw new IllegalArgumentException("Error reading from stream");
        }
        return bytes;
    }

    private static void reorderPackingFiles(List<Archive.PackingFile> packingFileList) {
        Iterator<Archive.PackingFile> iterator = packingFileList.iterator();
        while (iterator.hasNext()) {
            Archive.PackingFile packingFile = iterator.next();
            if (packingFile.isDirectory()) {
                iterator.remove();
            }
        }
        packingFileList.sort(new Comparator() { // from class: org.apache.commons.compress.harmony.pack200.-$$Lambda$PackingUtils$2DuZutAjfGVFM7vcJutHiphxOtU
            @Override // java.util.Comparator
            public final int compare(Object obj, Object obj2) {
                return PackingUtils.lambda$reorderPackingFiles$0((Archive.PackingFile) obj, (Archive.PackingFile) obj2);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static /* synthetic */ int lambda$reorderPackingFiles$0(Archive.PackingFile arg0, Archive.PackingFile arg1) {
        String fileName0 = arg0.getName();
        String fileName1 = arg1.getName();
        if (fileName0.equals(fileName1)) {
            return 0;
        }
        if ("META-INF/MANIFEST.MF".equals(fileName0)) {
            return -1;
        }
        if ("META-INF/MANIFEST.MF".equals(fileName1)) {
            return 1;
        }
        return fileName0.compareTo(fileName1);
    }
}