bcv-vf/plugins/javascript/ExampleStringDecrypter.js

67 lines
2.7 KiB
JavaScript
Raw Normal View History

2021-06-27 23:27:16 +00:00
/**
* This is an example of a string decrypter plugin
*/
var PluginConsole = Java.type("the.bytecode.club.bytecodeviewer.api.PluginConsole");
var MultipleChoiceDialog = Java.type("the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog")
var BytecodeViewer = Java.type("the.bytecode.club.bytecodeviewer.api.BCV")
2021-06-27 23:27:16 +00:00
var dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING",
2022-01-08 10:48:25 +00:00
"WARNING: This will load the classes into the JVM and execute the initialize function"
+ "\nfor each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
["Continue", "Cancel"]);
var gui;
2021-06-27 23:27:16 +00:00
2022-01-08 10:48:25 +00:00
function execute(classNodeList) {
2022-01-18 01:35:18 +00:00
gui = new PluginConsole("Example String Decrypter Javascript Edition");
2022-01-08 10:48:25 +00:00
if (dialog.promptChoice() == 0) {
2021-06-27 23:27:16 +00:00
var needsWarning = false;
2022-01-08 10:48:25 +00:00
for (cnIndex = 0; cnIndex < classNodeList.length; cnIndex++) {
try {
2021-06-27 23:27:16 +00:00
var cn = classNodeList[cnIndex];
//load the class node into the classloader
2022-01-08 10:48:25 +00:00
BytecodeViewer.getClassNodeLoader().addClass(cn);
2021-06-27 23:27:16 +00:00
2022-01-08 10:48:25 +00:00
var fields = cn.fields.toArray();
for (fieldIndex = 0; fieldIndex < fields.length; fieldIndex++) {
2021-06-27 23:27:16 +00:00
var field = fields[fieldIndex];
//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
2022-01-22 18:59:22 +00:00
if (field.name.equals("z")) {
2022-01-08 10:48:25 +00:00
try {
2021-06-27 23:27:16 +00:00
var loadedClass = BytecodeViewer.getClassNodeLoader().nodeToClass(cn);
var reflectedFields = loadedClass.getFields();
2022-01-08 10:48:25 +00:00
for (reflectedFieldIndex = 0; reflectedFieldIndex < reflectedFields.length; reflectedFieldIndex++) {
2021-06-27 23:27:16 +00:00
var reflectedField = reflectedFields[fieldIndex];
var s = reflectedField.get(null);
2022-01-08 10:48:25 +00:00
if (s != null && !s.empty())
2021-06-27 23:27:16 +00:00
gui.appendText(cn + "->" + s);
}
2022-01-22 19:06:25 +00:00
} catch (ignored) {
2022-01-08 10:48:25 +00:00
}
2021-06-27 23:27:16 +00:00
}
}
2022-01-08 10:48:25 +00:00
} catch (e) {
gui.appendText("Failed loading class " + cn.name);
2021-06-27 23:27:16 +00:00
e.printStackTrace();
needsWarning = true;
}
}
2022-01-08 10:48:25 +00:00
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.");
2021-06-27 23:27:16 +00:00
}
gui.setVisible(true);
}
2022-01-08 10:48:25 +00:00
}