modified loadClassesIntoClassLoader
loadClassesIntoClassLoader is now using specified list of ClassNode
This commit is contained in:
parent
198d0f2ddd
commit
91f42e91d0
2 changed files with 75 additions and 60 deletions
|
@ -1,6 +1,7 @@
|
||||||
package the.bytecode.club.bytecodeviewer.api;
|
package the.bytecode.club.bytecodeviewer.api;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -62,50 +63,60 @@ public class BytecodeViewer {
|
||||||
return cl;
|
return cl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-instances the URLClassLoader and loads a jar to it.
|
* Re-instances the URLClassLoader and loads a jar to it.
|
||||||
* @param path
|
*
|
||||||
|
* @param nodeList
|
||||||
|
* The list of ClassNodes to be loaded
|
||||||
* @return The loaded classes into the new URLClassLoader instance
|
* @return The loaded classes into the new URLClassLoader instance
|
||||||
* @author Cafebabe
|
* @author Cafebabe
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
*/
|
*/
|
||||||
public static List<Class<?>> loadClassesIntoClassLoader() {
|
@SuppressWarnings("deprecation")
|
||||||
try {
|
public static List<Class<?>> loadClassesIntoClassLoader(
|
||||||
File f = new File(
|
ArrayList<ClassNode> nodeList) throws IOException,
|
||||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.tempDirectory +
|
ClassNotFoundException {
|
||||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.fs +
|
|
||||||
"loaded_temp.jar");
|
File f = new File(
|
||||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), f.getAbsolutePath());
|
the.bytecode.club.bytecodeviewer.BytecodeViewer.tempDirectory
|
||||||
JarFile jarFile = new JarFile(""+f.getAbsolutePath());
|
+ the.bytecode.club.bytecodeviewer.BytecodeViewer.fs
|
||||||
Enumeration<JarEntry> e = jarFile.entries();
|
+ "loaded_temp.jar");
|
||||||
URL[] urls = { new URL("jar:file:" + ""+f.getAbsolutePath()+"!/") };
|
JarUtils.saveAsJarClassesOnly(nodeList, f.getAbsolutePath());
|
||||||
cl = URLClassLoader.newInstance(urls);
|
|
||||||
List<Class<?>> ret = new ArrayList<Class<?>>();
|
JarFile jarFile = new JarFile("" + f.getAbsolutePath());
|
||||||
|
Enumeration<JarEntry> e = jarFile.entries();
|
||||||
while (e.hasMoreElements())
|
cl = URLClassLoader.newInstance(new URL[]{ f.toURL() });
|
||||||
{
|
List<Class<?>> ret = new ArrayList<Class<?>>();
|
||||||
JarEntry je = (JarEntry) e.nextElement();
|
|
||||||
if(je.isDirectory() || !je.getName().endsWith(".class"))
|
while (e.hasMoreElements()) {
|
||||||
continue;
|
JarEntry je = (JarEntry) e.nextElement();
|
||||||
String className = je.getName().replace("/", ".").replace(".class", "");
|
if (je.isDirectory() || !je.getName().endsWith(".class"))
|
||||||
className = className.replace('/', '.');
|
continue;
|
||||||
try{
|
String className = je.getName().replace("/", ".").replace(".class", "");
|
||||||
ret.add(cl.loadClass(className));
|
className = className.replace('/', '.');
|
||||||
}
|
ret.add(cl.loadClass(className));
|
||||||
catch(Exception e2)
|
|
||||||
{
|
}
|
||||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e2);
|
jarFile.close();
|
||||||
}
|
|
||||||
}
|
return ret;
|
||||||
jarFile.close();
|
|
||||||
|
}
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
/**
|
||||||
{
|
* Re-instances the URLClassLoader and loads a jar to it.
|
||||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
* @return The loaded classes into the new URLClassLoader instance
|
||||||
}
|
* @author Cafebabe
|
||||||
return null;
|
* @throws IOException
|
||||||
}
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
|
public static List<Class<?>> loadAllClassesIntoClassLoader() throws ClassNotFoundException, IOException {
|
||||||
|
return loadClassesIntoClassLoader(getLoadedClasses());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the ClassNode loader.
|
* Creates a new instance of the ClassNode loader.
|
||||||
|
|
|
@ -3,6 +3,7 @@ package the.bytecode.club.bytecodeviewer.plugin.preinstalled;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
|
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
|
||||||
import the.bytecode.club.bytecodeviewer.api.Plugin;
|
import the.bytecode.club.bytecodeviewer.api.Plugin;
|
||||||
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
||||||
|
|
||||||
|
@ -63,28 +64,31 @@ public class ZStringArrayDecrypter extends Plugin {
|
||||||
|
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
boolean needsWarning = false;
|
boolean needsWarning = false;
|
||||||
for (Class<?> debug : the.bytecode.club.bytecodeviewer.api.BytecodeViewer.loadClassesIntoClassLoader()) {
|
try {
|
||||||
try {
|
for (Class<?> debug : the.bytecode.club.bytecodeviewer.api.BytecodeViewer.loadAllClassesIntoClassLoader()) {
|
||||||
Field[] fields = debug.getDeclaredFields();
|
try {
|
||||||
for ( Field field : fields ) {
|
Field[] fields = debug.getDeclaredFields();
|
||||||
if ( field.getName().equals("z") ) {
|
for ( Field field : fields ) {
|
||||||
out.append(debug.getName() + ":" + BytecodeViewer.nl);
|
if ( field.getName().equals("z") ) {
|
||||||
field.setAccessible(true);
|
out.append(debug.getName() + ":" + BytecodeViewer.nl);
|
||||||
if(field.get(null) != null && field.get(null) instanceof String[] && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) {
|
field.setAccessible(true);
|
||||||
String[] fieldVal = (String[]) field.get(null);
|
if(field.get(null) != null && field.get(null) instanceof String[] && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) {
|
||||||
for ( int i = 0; i < fieldVal.length; i++ ) {
|
String[] fieldVal = (String[]) field.get(null);
|
||||||
out.append(" z[" + i + "] = " + fieldVal[i] + BytecodeViewer.nl);
|
for ( int i = 0; i < fieldVal.length; i++ ) {
|
||||||
|
out.append(" z[" + i + "] = " + fieldVal[i] + BytecodeViewer.nl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch(NoClassDefFoundError | Exception e) {
|
||||||
} catch(NoClassDefFoundError | Exception e) {
|
System.err.println("Failed loading class " + debug.getName());
|
||||||
System.err.println("Failed loading class " + debug.getName());
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
needsWarning = true;
|
||||||
needsWarning = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e){
|
||||||
|
new ExceptionUI(e);
|
||||||
|
}
|
||||||
if(needsWarning) {
|
if(needsWarning) {
|
||||||
BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them"+BytecodeViewer.nl+"makes sure you include ALL the libraries it requires.");
|
BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them"+BytecodeViewer.nl+"makes sure you include ALL the libraries it requires.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue