Skip to content

Commit 9860c9d

Browse files
authored
Merge branch 'Konloch:master' into go-to-enhancement
2 parents f560fa5 + 3f1fd5a commit 9860c9d

87 files changed

Lines changed: 1547 additions & 1156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,82 @@
11
import java.lang.reflect.Field;
22
import java.util.List;
3+
34
import org.objectweb.asm.tree.ClassNode;
45
import org.objectweb.asm.tree.FieldNode;
6+
import the.bytecode.club.bytecodeviewer.*;
57
import the.bytecode.club.bytecodeviewer.api.*;
68
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog;
79

8-
import static the.bytecode.club.bytecodeviewer.Constants.nl;
10+
import static the.bytecode.club.bytecodeviewer.Constants.NL;
911

1012
/**
11-
** This is an example of a String Decrypter Java Plugin for BCV.
12-
**
13-
** @author [Your-Name-Goes-Here]
13+
* * This is an example of a String Decrypter Java Plugin for BCV.
14+
* *
15+
* * @author [Your-Name-Goes-Here]
1416
**/
1517

16-
public class ExampleStringDecrypter extends Plugin {
18+
public class ExampleStringDecrypter extends Plugin
19+
{
1720

1821
@Override
19-
public void execute(List<ClassNode> classNodesList) {
22+
public void execute(List<ClassNode> classNodesList)
23+
{
2024
PluginConsole gui = new PluginConsole("Example String Decrypter Java Edition");
2125

22-
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING",
23-
"WARNING: This will load the classes into the JVM and execute the initialize function"
24-
+ nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
25-
new String[]{"Continue", "Cancel"});
26+
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the initialize function" + NL +
27+
"for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"});
2628

27-
if (dialog.promptChoice() == 0) {
29+
if (dialog.promptChoice() == 0)
30+
{
2831
boolean needsWarning = false;
29-
30-
for (ClassNode cn : classNodesList) {
31-
try {
32+
33+
for (ClassNode cn : classNodesList)
34+
{
35+
try
36+
{
3237
//load the class node into the classloader
3338
BCV.getClassNodeLoader().addClass(cn);
34-
35-
for (Object o : cn.fields.toArray()) {
39+
40+
for (Object o : cn.fields.toArray())
41+
{
3642
FieldNode f = (FieldNode) o;
37-
43+
3844
//if the class contains the field z, get the class object from the class node
3945
//then print out the value of the fields inside the class
4046
//if the strings get decrypted on init, this allows you to dump the current values
41-
42-
if (f.name.equals("z")) {
43-
try {
44-
for (Field f2 : BCV.getClassNodeLoader().nodeToClass(cn).getFields()) {
47+
if (f.name.equals("z"))
48+
{
49+
try
50+
{
51+
for (Field f2 : BCV.getClassNodeLoader().nodeToClass(cn).getFields())
52+
{
4553
String s = (String) f2.get(null);
4654
if (s != null && !s.isEmpty())
4755
gui.appendText(cn + ":" + s);
4856
}
49-
} catch (Exception ignored) {
57+
}
58+
catch (Exception ignored)
59+
{
5060
}
5161
}
5262
}
53-
} catch (Exception e) {
63+
}
64+
catch (Exception e)
65+
{
5466
gui.appendText("Failed loading class " + cn.name);
5567
e.printStackTrace();
5668
needsWarning = true;
5769
}
5870
}
59-
60-
if (needsWarning) {
61-
BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them\n"
62-
+ "makes sure you include ALL the libraries it requires.");
71+
72+
if (needsWarning)
73+
{
74+
BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them" + NL +
75+
"makes sure you include ALL the libraries it requires.");
6376
}
6477

6578
gui.setVisible(true);
6679
}
6780
}
81+
6882
}

plugins/java/Skeleton.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
** @author [Your Name Goes Here]
99
**/
1010

11-
public class Skeleton extends Plugin {
11+
public class Skeleton extends Plugin
12+
{
1213

1314
@Override
14-
public void execute(List<ClassNode> classNodesList) {
15+
public void execute(List<ClassNode> classNodesList)
16+
{
1517
PluginConsole gui = new PluginConsole("Skeleton Title");
1618
gui.setVisible(true);
1719
gui.appendText("executed skeleton example");
1820
}
19-
}
21+
22+
}

plugins/java/XposedGenerator.java

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,17 @@ public void execute(List<ClassNode> classNodeList)
4646
String className = viewer.getName();
4747
ClassNode classnode = BytecodeViewer.getCurrentlyOpenedClassNode();
4848

49+
if (classnode == null)
50+
{
51+
BytecodeViewer.showMessage("Open A Classfile First");
52+
return;
53+
}
54+
4955
//Call XposedGenerator class
50-
ParseChosenFileContent(className, classnode);
56+
parseChosenFileContent(className, classnode);
5157
}
5258

53-
public static void ParseChosenFileContent(String classname, ClassNode classNode)
59+
public static void parseChosenFileContent(String classname, ClassNode classNode)
5460
{
5561
try
5662
{
@@ -64,7 +70,9 @@ public static void ParseChosenFileContent(String classname, ClassNode classNode)
6470
//Decompile using Fern
6571
String decomp = decompilefern.decompileClassNode(classNode, cont);
6672
String[] xposedTemplateTypes = {"Empty", "Parameters", "Helper"};
67-
@SuppressWarnings({"unchecked", "rawtypes"}) JComboBox xposedTemplateList = new JComboBox(xposedTemplateTypes);
73+
@SuppressWarnings({"unchecked", "rawtypes"})
74+
JComboBox xposedTemplateList = new JComboBox(xposedTemplateTypes);
75+
6876
//Set results of parsed methods into a list
6977
List<String> methodsExtracted = ProcessContentExtractedClass(decomp);
7078
String packgExtracted = ProcessContentExtractedPackage(decomp);
@@ -86,6 +94,7 @@ public static void ParseChosenFileContent(String classname, ClassNode classNode)
8694

8795
//output methods to pane box
8896
int result = JOptionPane.showConfirmDialog(null, myPanel, "Choose Template and Method for Xposed Module", JOptionPane.OK_CANCEL_OPTION);
97+
myPanel.remove();
8998

9099
if (result == JOptionPane.OK_OPTION)
91100
{
@@ -129,13 +138,6 @@ public static void WriteXposedModule(String functionToHook, String packageName,
129138
{
130139
try
131140
{
132-
//TODO: Prompt save dialog
133-
File file = new File("./XposedClassTest.java");
134-
135-
// if file doesn't exist, then create it
136-
if (!file.exists())
137-
file.createNewFile();
138-
139141
//Extract the package name only
140142
String packageNameOnly = packageName.substring(8, packageName.length() - 2).trim();
141143
String classToHookNameOnly = classToHook;
@@ -151,18 +153,35 @@ public static void WriteXposedModule(String functionToHook, String packageName,
151153
String onlyFunction = CleanUpFunction(functionSplitValues);
152154

153155
//Write Xposed Class
154-
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";
155-
FileWriter fw = new FileWriter(file.getAbsoluteFile());
156-
BufferedWriter bw = new BufferedWriter(fw);
157-
bw.write(XposedClassText);
158-
bw.write("\r\n");
159-
bw.close();
160-
161-
JOptionPane.showMessageDialog(null, "Xposed Module Generated");
156+
String XposedClassText = "package androidpentesting.com.xposedmodule;" + "\r\n"
157+
+ "import de.robv.android.xposed.IXposedHookLoadPackage;" + "\r\n" + "\r\n"
158+
+ "import de.robv.android.xposed.XC_MethodHook;" + "\r\n"
159+
+ "import de.robv.android.xposed.XposedBridge;" + "\r\n"
160+
+ "import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;" + "\r\n"
161+
+ "import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;" + "\r\n" + "\r\n"
162+
+ "public class XposedClassTest implements IXposedHookLoadPackage {" + "\r\n" + "\r\n"
163+
+ " public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {" + "\r\n" + "\r\n"
164+
+ " String classToHook = " + "\"" + packageNameOnly + "." + onlyClass + "\";" + "\r\n"
165+
+ " String functionToHook = " + "\"" + onlyFunction + "\";" + "\r\n" + "\r\n"
166+
+ " if (lpparam.packageName.equals(" + "\"" + packageNameOnly + "\"" + ")){" + "\r\n"
167+
+ " XposedBridge.log(" + "\" Loaded app: \" " + " + lpparam.packageName);" + "\r\n" + "\r\n"
168+
+ " findAndHookMethod(" + "\"" + onlyClass + "\"" + ", lpparam.classLoader, " + " \"" + onlyFunction + "\"" + ", int.class," + "\r\n"
169+
+ " new XC_MethodHook() {" + "\r\n"
170+
+ " @Override" + "\r\n"
171+
+ " protected void beforeHookedMethod(MethodHookParam param) throws Throwable {" + "\r\n"
172+
+ " //TO BE FILLED BY ANALYST" + "\r\n"
173+
+ " }" + "\r\n"
174+
+ " });" + "\r\n"
175+
+ " }" + "\r\n"
176+
+ " }" + "\r\n"
177+
+ "}" + "\r\n";
178+
179+
PluginConsole gui = new PluginConsole("Xposed Code Generation");
180+
gui.appendText(XposedClassText);
181+
gui.setVisible(true);
162182
}
163-
catch (IOException e)
183+
catch (Exception e)
164184
{
165-
JOptionPane.showMessageDialog(null, "Error" + e);
166185
e.printStackTrace();
167186
}
168187
}
@@ -308,4 +327,5 @@ private static String quote(String aText)
308327
String QUOTE = "'";
309328
return QUOTE + aText + QUOTE;
310329
}
330+
311331
}

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<java-parser.version>3.26.2</java-parser.version>
5555
<taskmanager.version>1.0.1</taskmanager.version>
5656
<google-java-format.version>1.7</google-java-format.version> <!-- Newer versions require Java 11+ -->
57+
<disk-lib.version>1.2.0</disk-lib.version>
5758
</properties>
5859

5960
<repositories>
@@ -395,6 +396,11 @@
395396
<artifactId>google-java-format</artifactId>
396397
<version>${google-java-format.version}</version>
397398
</dependency>
399+
<dependency>
400+
<groupId>com.konloch</groupId>
401+
<artifactId>DiskLib</artifactId>
402+
<version>${disk-lib.version}</version>
403+
</dependency>
398404

399405
<!-- TODO Re-add for Graal.JS support -->
400406
<!--<dependency>

src/main/java/me/konloch/kontainer/io/DiskReader.java

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)