Plugin Code Cleanup
This commit is contained in:
parent
6031154319
commit
a12f1aa503
2 changed files with 49 additions and 48 deletions
|
@ -1,10 +1,12 @@
|
||||||
import the.bytecode.club.bytecodeviewer.api.*;
|
import the.bytecode.club.bytecodeviewer.api.*
|
||||||
|
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import org.objectweb.asm.tree.FieldNode;
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
|
import org.objectweb.asm.tree.FieldNode
|
||||||
|
|
||||||
|
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an example of a string decrypter plugin
|
* This is an example of a string decrypter plugin
|
||||||
|
@ -15,27 +17,25 @@ public class ExampleStringDecrypter extends Plugin {
|
||||||
public void execute(ArrayList<ClassNode> classNodesList) {
|
public void execute(ArrayList<ClassNode> classNodesList) {
|
||||||
PluginConsole gui = new PluginConsole("Example String Decrypter");
|
PluginConsole gui = new PluginConsole("Example String Decrypter");
|
||||||
|
|
||||||
JOptionPane pane = new JOptionPane("WARNING: This method of decryption loads the classes into a classloader and executes the init function, this could lead to malicious code executing.\n\r\n\rAre you sure you want to run this plugin?");
|
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING",
|
||||||
String[] options = ["Yes", "No"];
|
"WARNING: This will load the classes into the JVM and execute the initialize function"
|
||||||
pane.setOptions(options);
|
+ nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
|
||||||
JDialog dialog = pane.createDialog(the.bytecode.club.bytecodeviewer.BytecodeViewer.viewer, "WARNING");
|
new String[]{"Continue", "Cancel"});
|
||||||
dialog.show();
|
|
||||||
Object obj = pane.getValue();
|
|
||||||
int result = -1;
|
|
||||||
for (int k = 0; k < options.length; k++)
|
|
||||||
if (options[k].equals(obj))
|
|
||||||
result = k;
|
|
||||||
|
|
||||||
|
if(dialogue.promptChoice() == 0)
|
||||||
if(result == 0) {
|
{
|
||||||
for(ClassNode cn : classNodesList) {
|
for(ClassNode cn : classNodesList)
|
||||||
|
{
|
||||||
the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().addClass(cn);
|
the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().addClass(cn);
|
||||||
|
|
||||||
for(Object o : cn.fields.toArray()) {
|
for(Object o : cn.fields.toArray())
|
||||||
|
{
|
||||||
FieldNode f = (FieldNode) o;
|
FieldNode f = (FieldNode) o;
|
||||||
if(f.name.equals("z")) {// && f.desc.equals("([Ljava/lang/String;)V")) {
|
if(f.name.equals("z")) {// && f.desc.equals("([Ljava/lang/String;)V")) {
|
||||||
try {
|
try
|
||||||
for(Field f2 : the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().nodeToClass(cn).getFields()) {
|
{
|
||||||
|
for(Field f2 : the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().nodeToClass(cn).getFields())
|
||||||
|
{
|
||||||
String s = f2.get(null);
|
String s = f2.get(null);
|
||||||
if(s != null && !s.empty())
|
if(s != null && !s.empty())
|
||||||
gui.appendText(cn+":"+s);
|
gui.appendText(cn+":"+s);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
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;
|
||||||
|
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.*;
|
import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
|
|
||||||
|
@ -38,54 +39,54 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
* @author Righteous
|
* @author Righteous
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ZStringArrayDecrypter extends Plugin {
|
public class ZStringArrayDecrypter extends Plugin
|
||||||
|
{
|
||||||
PluginConsole gui = new PluginConsole("ZStringArray Decrypter");
|
PluginConsole gui = new PluginConsole("ZStringArray Decrypter");
|
||||||
StringBuilder out = new StringBuilder();
|
StringBuilder out = new StringBuilder();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ArrayList<ClassNode> classNodeList) {
|
public void execute(ArrayList<ClassNode> classNodeList)
|
||||||
JOptionPane pane = new JOptionPane(
|
{
|
||||||
|
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING",
|
||||||
"WARNING: This will load the classes into the JVM and execute the initialize function"
|
"WARNING: This will load the classes into the JVM and execute the initialize function"
|
||||||
+ nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE."
|
+ nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
|
||||||
);
|
new String[]{"Continue", "Cancel"});
|
||||||
Object[] options = new String[]{"Continue", "Cancel"};
|
|
||||||
pane.setOptions(options);
|
|
||||||
JDialog dialog = pane.createDialog(BytecodeViewer.viewer,
|
|
||||||
"Bytecode Viewer - WARNING");
|
|
||||||
dialog.setVisible(true);
|
|
||||||
Object obj = pane.getValue();
|
|
||||||
int result = -1;
|
|
||||||
for (int k = 0; k < options.length; k++)
|
|
||||||
if (options[k].equals(obj))
|
|
||||||
result = k;
|
|
||||||
|
|
||||||
if (result == 0) {
|
if (dialogue.promptChoice() == 0)
|
||||||
|
{
|
||||||
boolean needsWarning = false;
|
boolean needsWarning = false;
|
||||||
for (Class<?> debug :
|
for (Class<?> debug :
|
||||||
Objects.requireNonNull(the.bytecode.club.bytecodeviewer.api.BytecodeViewer.loadClassesIntoClassLoader())) {
|
Objects.requireNonNull(the.bytecode.club.bytecodeviewer.api.BytecodeViewer.loadClassesIntoClassLoader()))
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
Field[] fields = debug.getDeclaredFields();
|
Field[] fields = debug.getDeclaredFields();
|
||||||
for (Field field : fields) {
|
for (Field field : fields)
|
||||||
if (field.getName().equals("z")) {
|
{
|
||||||
|
if (field.getName().equals("z"))
|
||||||
|
{
|
||||||
out.append(debug.getName()).append(":").append(nl);
|
out.append(debug.getName()).append(":").append(nl);
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
if (field.get(null) != null && field.get(null) instanceof String[] && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) {
|
if (field.get(null) != null && field.get(null) instanceof String[]
|
||||||
|
&& Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()))
|
||||||
|
{
|
||||||
String[] fieldVal = (String[]) field.get(null);
|
String[] fieldVal = (String[]) field.get(null);
|
||||||
for (int i = 0; i < fieldVal.length; i++) {
|
for (int i = 0; i < fieldVal.length; i++)
|
||||||
out.append(" z[").append(i).append("] = ").append(fieldVal[i]).append(nl);
|
out.append(" z[").append(i).append("] = ").append(fieldVal[i]).append(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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsWarning) {
|
if (needsWarning)
|
||||||
|
{
|
||||||
BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them"
|
BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them"
|
||||||
+ nl + "makes sure you include ALL the libraries it requires.");
|
+ nl + "makes sure you include ALL the libraries it requires.");
|
||||||
}
|
}
|
||||||
|
@ -94,4 +95,4 @@ public class ZStringArrayDecrypter extends Plugin {
|
||||||
gui.setVisible(true);
|
gui.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue