diff --git a/plugins/java/ExampleStringDecrypter.java b/plugins/java/ExampleStringDecrypter.java index cc7d3dab..8e71a3b4 100644 --- a/plugins/java/ExampleStringDecrypter.java +++ b/plugins/java/ExampleStringDecrypter.java @@ -1,68 +1,82 @@ import java.lang.reflect.Field; import java.util.List; + import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.FieldNode; +import the.bytecode.club.bytecodeviewer.*; import the.bytecode.club.bytecodeviewer.api.*; import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog; -import static the.bytecode.club.bytecodeviewer.Constants.nl; +import static the.bytecode.club.bytecodeviewer.Constants.NL; /** - ** This is an example of a String Decrypter Java Plugin for BCV. - ** - ** @author [Your-Name-Goes-Here] + * * This is an example of a String Decrypter Java Plugin for BCV. + * * + * * @author [Your-Name-Goes-Here] **/ -public class ExampleStringDecrypter extends Plugin { +public class ExampleStringDecrypter extends Plugin +{ @Override - public void execute(List classNodesList) { + public void execute(List classNodesList) + { PluginConsole gui = new PluginConsole("Example String Decrypter Java Edition"); - MultipleChoiceDialog dialog = new MultipleChoiceDialog("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"}); + MultipleChoiceDialog dialog = new MultipleChoiceDialog("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 (dialog.promptChoice() == 0) { + if (dialog.promptChoice() == 0) + { boolean needsWarning = false; - - for (ClassNode cn : classNodesList) { - try { + + for (ClassNode cn : classNodesList) + { + try + { //load the class node into the classloader BCV.getClassNodeLoader().addClass(cn); - - for (Object o : cn.fields.toArray()) { + + for (Object o : cn.fields.toArray()) + { FieldNode f = (FieldNode) o; - + //if the class contains the field z, get the class object from the class node //then print out the value of the fields inside the class //if the strings get decrypted on init, this allows you to dump the current values - - if (f.name.equals("z")) { - try { - for (Field f2 : BCV.getClassNodeLoader().nodeToClass(cn).getFields()) { + if (f.name.equals("z")) + { + try + { + for (Field f2 : BCV.getClassNodeLoader().nodeToClass(cn).getFields()) + { String s = (String) f2.get(null); if (s != null && !s.isEmpty()) gui.appendText(cn + ":" + s); } - } catch (Exception ignored) { + } + catch (Exception ignored) + { } } } - } catch (Exception e) { + } + catch (Exception e) + { gui.appendText("Failed loading class " + cn.name); e.printStackTrace(); needsWarning = true; } } - - if (needsWarning) { - BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them\n" - + "makes sure you include ALL the libraries it requires."); + + 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."); } gui.setVisible(true); } } + } diff --git a/plugins/java/Skeleton.java b/plugins/java/Skeleton.java index 4177905b..32444410 100644 --- a/plugins/java/Skeleton.java +++ b/plugins/java/Skeleton.java @@ -8,12 +8,15 @@ import the.bytecode.club.bytecodeviewer.api.*; ** @author [Your Name Goes Here] **/ -public class Skeleton extends Plugin { +public class Skeleton extends Plugin +{ @Override - public void execute(List classNodesList) { + public void execute(List classNodesList) + { PluginConsole gui = new PluginConsole("Skeleton Title"); gui.setVisible(true); gui.appendText("executed skeleton example"); } -} \ No newline at end of file + +} diff --git a/plugins/java/XposedGenerator.java b/plugins/java/XposedGenerator.java index 5d869cf7..70c44eed 100644 --- a/plugins/java/XposedGenerator.java +++ b/plugins/java/XposedGenerator.java @@ -46,11 +46,17 @@ public class XposedGenerator extends Plugin String className = viewer.getName(); ClassNode classnode = BytecodeViewer.getCurrentlyOpenedClassNode(); + if (classnode == null) + { + BytecodeViewer.showMessage("Open A Classfile First"); + return; + } + //Call XposedGenerator class - ParseChosenFileContent(className, classnode); + parseChosenFileContent(className, classnode); } - public static void ParseChosenFileContent(String classname, ClassNode classNode) + public static void parseChosenFileContent(String classname, ClassNode classNode) { try { @@ -64,7 +70,9 @@ public class XposedGenerator extends Plugin //Decompile using Fern String decomp = decompilefern.decompileClassNode(classNode, cont); String[] xposedTemplateTypes = {"Empty", "Parameters", "Helper"}; - @SuppressWarnings({"unchecked", "rawtypes"}) JComboBox xposedTemplateList = new JComboBox(xposedTemplateTypes); + @SuppressWarnings({"unchecked", "rawtypes"}) + JComboBox xposedTemplateList = new JComboBox(xposedTemplateTypes); + //Set results of parsed methods into a list List methodsExtracted = ProcessContentExtractedClass(decomp); String packgExtracted = ProcessContentExtractedPackage(decomp); @@ -86,6 +94,7 @@ public class XposedGenerator extends Plugin //output methods to pane box int result = JOptionPane.showConfirmDialog(null, myPanel, "Choose Template and Method for Xposed Module", JOptionPane.OK_CANCEL_OPTION); + myPanel.remove(); if (result == JOptionPane.OK_OPTION) { @@ -129,13 +138,6 @@ public class XposedGenerator extends Plugin { try { - //TODO: Prompt save dialog - File file = new File("./XposedClassTest.java"); - - // if file doesn't exist, then create it - if (!file.exists()) - file.createNewFile(); - //Extract the package name only String packageNameOnly = packageName.substring(8, packageName.length() - 2).trim(); String classToHookNameOnly = classToHook; @@ -151,18 +153,35 @@ public class XposedGenerator extends Plugin String onlyFunction = CleanUpFunction(functionSplitValues); //Write Xposed Class - String XposedClassText = "package androidpentesting.com.xposedmodule;" + "\r\n" + "import de.robv.android.xposed.IXposedHookLoadPackage;" + "\r\n" + "\r\n" + "import de.robv.android.xposed.XC_MethodHook;" + "\r\n" + "import de.robv.android.xposed.XposedBridge;" + "\r\n" + "import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;" + "\r\n" + "import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;" + "\r\n" + "\r\n" + "public class XposedClassTest implements IXposedHookLoadPackage {" + "\r\n" + "\r\n" + " public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {" + "\r\n" + "\r\n" + " String classToHook = " + "\"" + packageNameOnly + "." + onlyClass + "\";" + "\r\n" + " String functionToHook = " + "\"" + onlyFunction + "\";" + "\r\n" + " if (lpparam.packageName.equals(" + "\"" + packageNameOnly + "\"" + ")){" + "\r" + "\n" + " XposedBridge.log(" + "\" Loaded app: \" " + " + lpparam.packageName);" + "\r\n" + "\r\n" + " findAndHookMethod(" + "\"" + onlyClass + "\"" + ", lpparam.classLoader, " + " \"" + onlyFunction + "\"" + ", int.class," + "\r\n" + " new XC_MethodHook() {" + "\r\n" + " @Override" + "\r\n" + " protected void beforeHookedMethod(MethodHookParam param) throws " + "Throwable {" + "\r\n" + " //TO BE FILLED BY ANALYST" + "\r\n" + " }" + "\r\n" + " });" + "\r\n" + " }" + "\r\n" + " }" + "\r\n" + "}" + "\r\n"; - FileWriter fw = new FileWriter(file.getAbsoluteFile()); - BufferedWriter bw = new BufferedWriter(fw); - bw.write(XposedClassText); - bw.write("\r\n"); - bw.close(); + String XposedClassText = "package androidpentesting.com.xposedmodule;" + "\r\n" + + "import de.robv.android.xposed.IXposedHookLoadPackage;" + "\r\n" + "\r\n" + + "import de.robv.android.xposed.XC_MethodHook;" + "\r\n" + + "import de.robv.android.xposed.XposedBridge;" + "\r\n" + + "import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;" + "\r\n" + + "import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;" + "\r\n" + "\r\n" + + "public class XposedClassTest implements IXposedHookLoadPackage {" + "\r\n" + "\r\n" + + " public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {" + "\r\n" + "\r\n" + + " String classToHook = " + "\"" + packageNameOnly + "." + onlyClass + "\";" + "\r\n" + + " String functionToHook = " + "\"" + onlyFunction + "\";" + "\r\n" + "\r\n" + + " if (lpparam.packageName.equals(" + "\"" + packageNameOnly + "\"" + ")){" + "\r\n" + + " XposedBridge.log(" + "\" Loaded app: \" " + " + lpparam.packageName);" + "\r\n" + "\r\n" + + " findAndHookMethod(" + "\"" + onlyClass + "\"" + ", lpparam.classLoader, " + " \"" + onlyFunction + "\"" + ", int.class," + "\r\n" + + " new XC_MethodHook() {" + "\r\n" + + " @Override" + "\r\n" + + " protected void beforeHookedMethod(MethodHookParam param) throws Throwable {" + "\r\n" + + " //TO BE FILLED BY ANALYST" + "\r\n" + + " }" + "\r\n" + + " });" + "\r\n" + + " }" + "\r\n" + + " }" + "\r\n" + + "}" + "\r\n"; - JOptionPane.showMessageDialog(null, "Xposed Module Generated"); + PluginConsole gui = new PluginConsole("Xposed Code Generation"); + gui.appendText(XposedClassText); + gui.setVisible(true); } - catch (IOException e) + catch (Exception e) { - JOptionPane.showMessageDialog(null, "Error" + e); e.printStackTrace(); } } @@ -308,4 +327,5 @@ public class XposedGenerator extends Plugin String QUOTE = "'"; return QUOTE + aText + QUOTE; } + } diff --git a/pom.xml b/pom.xml index 26e5d548..f69cb364 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,7 @@ 3.26.2 1.0.1 1.7 + 1.2.0 @@ -395,6 +396,11 @@ google-java-format ${google-java-format.version} + + com.konloch + DiskLib + ${disk-lib.version} +