Plugin Code Cleanup

This commit is contained in:
Konloch 2021-06-27 14:41:58 -07:00
parent 6031154319
commit a12f1aa503
2 changed files with 49 additions and 48 deletions

View file

@ -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 org.objectweb.asm.tree.ClassNode;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
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
@ -15,27 +17,25 @@ public class ExampleStringDecrypter extends Plugin {
public void execute(ArrayList<ClassNode> classNodesList) {
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?");
String[] options = ["Yes", "No"];
pane.setOptions(options);
JDialog dialog = pane.createDialog(the.bytecode.club.bytecodeviewer.BytecodeViewer.viewer, "WARNING");
dialog.show();
Object obj = pane.getValue();
int result = -1;
for (int k = 0; k < options.length; k++)
if (options[k].equals(obj))
result = k;
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING",
"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.",
new String[]{"Continue", "Cancel"});
if(result == 0) {
for(ClassNode cn : classNodesList) {
if(dialogue.promptChoice() == 0)
{
for(ClassNode cn : classNodesList)
{
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;
if(f.name.equals("z")) {// && f.desc.equals("([Ljava/lang/String;)V")) {
try {
for(Field f2 : the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().nodeToClass(cn).getFields()) {
try
{
for(Field f2 : the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().nodeToClass(cn).getFields())
{
String s = f2.get(null);
if(s != null && !s.empty())
gui.appendText(cn+":"+s);

View file

@ -10,6 +10,7 @@ import org.objectweb.asm.tree.ClassNode;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.api.Plugin;
import the.bytecode.club.bytecodeviewer.api.PluginConsole;
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
import static the.bytecode.club.bytecodeviewer.Constants.*;
@ -38,54 +39,54 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
* @author Righteous
*/
public class ZStringArrayDecrypter extends Plugin {
public class ZStringArrayDecrypter extends Plugin
{
PluginConsole gui = new PluginConsole("ZStringArray Decrypter");
StringBuilder out = new StringBuilder();
@Override
public void execute(ArrayList<ClassNode> classNodeList) {
JOptionPane pane = new JOptionPane(
public void execute(ArrayList<ClassNode> classNodeList)
{
MultipleChoiceDialogue dialogue = new MultipleChoiceDialogue("Bytecode Viewer - WARNING",
"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."
);
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;
+ nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
new String[]{"Continue", "Cancel"});
if (result == 0) {
if (dialogue.promptChoice() == 0)
{
boolean needsWarning = false;
for (Class<?> debug :
Objects.requireNonNull(the.bytecode.club.bytecodeviewer.api.BytecodeViewer.loadClassesIntoClassLoader())) {
try {
Objects.requireNonNull(the.bytecode.club.bytecodeviewer.api.BytecodeViewer.loadClassesIntoClassLoader()))
{
try
{
Field[] fields = debug.getDeclaredFields();
for (Field field : fields) {
if (field.getName().equals("z")) {
for (Field field : fields)
{
if (field.getName().equals("z"))
{
out.append(debug.getName()).append(":").append(nl);
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);
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);
}
}
}
}
} catch (NoClassDefFoundError | Exception e) {
}
catch (NoClassDefFoundError | Exception e)
{
System.err.println("Failed loading class " + debug.getName());
e.printStackTrace();
needsWarning = true;
}
}
if (needsWarning) {
if (needsWarning)
{
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.");
}