JS Plugin Support
This commit is contained in:
parent
2573aaa937
commit
5290692c3e
2 changed files with 39 additions and 9 deletions
7
plugins/Skeleton.js
Normal file
7
plugins/Skeleton.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
function execute(classNodeList)
|
||||||
|
{
|
||||||
|
var GuiRef = Java.type("the.bytecode.club.bytecodeviewer.api.PluginConsole");
|
||||||
|
var gui = new GuiRef("Skeleton");
|
||||||
|
gui.setVisible(true);
|
||||||
|
gui.appendText("exceuted skeleton");
|
||||||
|
}
|
|
@ -1,13 +1,14 @@
|
||||||
package the.bytecode.club.bytecodeviewer.plugin.strategies;
|
package the.bytecode.club.bytecodeviewer.plugin.strategies;
|
||||||
|
|
||||||
|
import org.objectweb.asm.tree.ClassNode;
|
||||||
import the.bytecode.club.bytecodeviewer.api.Plugin;
|
import the.bytecode.club.bytecodeviewer.api.Plugin;
|
||||||
import the.bytecode.club.bytecodeviewer.plugin.PluginLaunchStrategy;
|
import the.bytecode.club.bytecodeviewer.plugin.PluginLaunchStrategy;
|
||||||
|
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.*;
|
||||||
import javax.script.ScriptEngineManager;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
|
||||||
|
@ -32,19 +33,41 @@ import java.io.Reader;
|
||||||
* @author Bibl (don't ban me pls)
|
* @author Bibl (don't ban me pls)
|
||||||
* @since 06/25/2021
|
* @since 06/25/2021
|
||||||
*/
|
*/
|
||||||
public class JavascriptPluginLaunchStrategy implements PluginLaunchStrategy {
|
public class JavascriptPluginLaunchStrategy implements PluginLaunchStrategy
|
||||||
|
{
|
||||||
|
public static final String firstPickEngine = "rhino";
|
||||||
|
public static final String fallBackEngine = "nashorn";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Plugin run(File file) throws Throwable {
|
public Plugin run(File file) throws Throwable
|
||||||
|
{
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
ScriptEngine engine = manager.getEngineByName("rhino");
|
ScriptEngine engine = manager.getEngineByName(firstPickEngine);
|
||||||
|
|
||||||
if (engine == null)
|
if (engine == null)
|
||||||
throw new Exception("Cannot find Rhino script engine! Please contact Konloch.");
|
engine = manager.getEngineByName(fallBackEngine);
|
||||||
|
|
||||||
|
if (engine == null)
|
||||||
|
throw new Exception("Cannot find Javascript script engine! Please contact Konloch.");
|
||||||
|
|
||||||
Reader reader = new FileReader(file);
|
Reader reader = new FileReader(file);
|
||||||
engine.eval(reader);
|
engine.eval(reader);
|
||||||
|
|
||||||
return (Plugin) engine.eval(file.getName().replace(".js", "") + ".new");
|
ScriptEngine finalEngine = engine;
|
||||||
|
return new Plugin()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void execute(ArrayList<ClassNode> classNodeList)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
((Invocable) finalEngine).invokeFunction("execute", classNodeList);
|
||||||
|
}
|
||||||
|
catch (NoSuchMethodException | ScriptException e)
|
||||||
|
{
|
||||||
|
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue