-
-
Save MalikDz/944cae9c168fa05fbd0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package zRsbotDumper; | |
import java.io.ByteArrayOutputStream; | |
import java.io.InputStream; | |
import java.util.HashMap; | |
import java.util.jar.JarFile; | |
public class CustomURLClassLoader extends ClassLoader { | |
/** | |
* | |
* Author : MalikDz | |
* | |
*/ | |
private JarFile jar; | |
public static final HashMap<String, byte[]> MAP = new HashMap<String, byte[]>(); | |
/** | |
* | |
* Creates our custom class loader | |
* | |
*/ | |
public CustomURLClassLoader(JarFile jar) { | |
this.jar = jar; | |
} | |
/** | |
* | |
* Override the load method in the class loader class | |
* | |
*/ | |
@Override | |
@SuppressWarnings("unused") | |
public Class<?> loadClass(String name) { | |
Class<?> clazz = null; | |
try { | |
int bit; | |
final String n = name.replace(".", "/") + ".class"; | |
final InputStream stream = jar.getInputStream(jar.getJarEntry(n)); | |
final ByteArrayOutputStream bytesObj = new ByteArrayOutputStream(); | |
while ((bit = stream.read()) != -1) { | |
bytesObj.write(bit); | |
System.out.println(bit); | |
} | |
byte[] bytes = bytesObj.toByteArray(); | |
clazz = super.defineClass(bytes, 0, bytes.length); | |
MAP.put(n, bytes); | |
} catch (Exception e) { | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment