diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/ShellAssertionTool.java b/integration-test/src/test/java/com/reajason/javaweb/integration/ShellAssertionTool.java index b5d4602e..f220b8a6 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/ShellAssertionTool.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/ShellAssertionTool.java @@ -16,12 +16,14 @@ import okhttp3.Response; import org.junit.jupiter.api.Assumptions; import org.testcontainers.containers.GenericContainer; import org.testcontainers.shaded.org.apache.commons.io.FileUtils; +import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils; import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils; import org.testcontainers.utility.MountableFile; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Objects; import static org.hamcrest.CoreMatchers.anyOf; @@ -64,6 +66,7 @@ public class ShellAssertionTool { Files.write(tempJar, bytes); String jarPath = "/" + shellTool + shellType + packer.name() + ".jar"; container.copyFileToContainer(MountableFile.forHostPath(tempJar, 0100666), jarPath); +// Files.copy(tempJar, Paths.get("target.jar")); FileUtils.deleteQuietly(tempJar.toFile()); String pidInContainer = container.execInContainer("bash", "/fetch_pid.sh").getStdout(); assertDoesNotThrow(() -> Long.parseLong(pidInContainer)); @@ -164,7 +167,7 @@ public class ShellAssertionTool { .build(); ShellToolConfig shellToolConfig = null; - String uniqueName = shellTool + shellType + packer.name(); + String uniqueName = shellTool + RandomStringUtils.randomAlphabetic(5)+ shellType + RandomStringUtils.randomAlphabetic(5)+ packer.name(); switch (shellTool) { case Godzilla: String godzillaPass = "pass"; diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish3ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish3ContainerTest.java index e19a157d..0297aff5 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish3ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish3ContainerTest.java @@ -51,14 +51,9 @@ public class GlassFish3ContainerTest { static Stream casesProvider() { Server server = Server.GlassFish; - Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize); - Set> unSupportedCases = Set.of( - Triple.of(ShellType.CATALINA_AGENT_CONTEXT_VALVE, ShellTool.Godzilla, Packers.AgentJar), // ClassFormatError - Triple.of(ShellType.AGENT_FILTER_CHAIN, ShellTool.Godzilla, Packers.AgentJar) // ClassFormatError - ); - return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers, unSupportedCases); + return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } @AfterAll diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish4ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish4ContainerTest.java index 809bca69..a02d0f86 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish4ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish4ContainerTest.java @@ -53,8 +53,7 @@ public class GlassFish4ContainerTest { static Stream casesProvider() { Server server = Server.GlassFish; - Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish501ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish501ContainerTest.java index 50ca588b..fdd41c93 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish501ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish501ContainerTest.java @@ -1,10 +1,10 @@ package com.reajason.javaweb.integration.glassfish; import com.reajason.javaweb.integration.TestCasesProvider; -import com.reajason.javaweb.memshell.ShellType; +import com.reajason.javaweb.memshell.Packers; import com.reajason.javaweb.memshell.Server; import com.reajason.javaweb.memshell.ShellTool; -import com.reajason.javaweb.memshell.Packers; +import com.reajason.javaweb.memshell.ShellType; import lombok.extern.slf4j.Slf4j; import net.bytebuddy.jar.asm.Opcodes; import org.junit.jupiter.api.AfterAll; @@ -23,7 +23,6 @@ import static com.reajason.javaweb.integration.ContainerTool.*; import static com.reajason.javaweb.integration.DoesNotContainExceptionMatcher.doesNotContainException; import static com.reajason.javaweb.integration.ShellAssertionTool.testShellInjectAssertOk; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.params.provider.Arguments.arguments; /** * @author ReaJason @@ -44,8 +43,7 @@ public class GlassFish501ContainerTest { static Stream casesProvider() { Server server = Server.GlassFish; - Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish510ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish510ContainerTest.java index e91e8283..b87f44af 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish510ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish510ContainerTest.java @@ -44,8 +44,7 @@ public class GlassFish510ContainerTest { static Stream casesProvider() { Server server = Server.GlassFish; - Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish6ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish6ContainerTest.java index e3ba58a8..aed587fc 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish6ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish6ContainerTest.java @@ -43,12 +43,9 @@ public class GlassFish6ContainerTest { static Stream casesProvider() { Server server = Server.GlassFish; - Set supportedShellTypes = Set.of(ShellType.JAKARTA_FILTER, ShellType.JAKARTA_LISTENER, ShellType.JAKARTA_VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.JAKARTA_FILTER, ShellType.JAKARTA_LISTENER, ShellType.JAKARTA_VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize); - return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers, - null, Set.of(ShellTool.AntSword) // AntSword not support jakarta - ); + return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } @AfterAll diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish7ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish7ContainerTest.java index f03365bf..e8fa27e3 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish7ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish7ContainerTest.java @@ -43,12 +43,9 @@ public class GlassFish7ContainerTest { static Stream casesProvider() { Server server = Server.GlassFish; - Set supportedShellTypes = Set.of(ShellType.JAKARTA_FILTER, ShellType.JAKARTA_LISTENER, ShellType.JAKARTA_VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.JAKARTA_FILTER, ShellType.JAKARTA_LISTENER, ShellType.JAKARTA_VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX); - return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers, - null, Set.of(ShellTool.AntSword) // AntSword not support jakarta - ); + return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } @AfterAll diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/jbossas/Jboss423ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/jbossas/Jboss423ContainerTest.java index 6aea587e..4df7b341 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/jbossas/Jboss423ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/jbossas/Jboss423ContainerTest.java @@ -45,7 +45,7 @@ public class Jboss423ContainerTest { Server server = Server.JBossAS; Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE, ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); - Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize, Packers.ScriptEngine); + Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara5201ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara5201ContainerTest.java index 4ffdce6c..ce3921a4 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara5201ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara5201ContainerTest.java @@ -43,8 +43,7 @@ public class Payara5201ContainerTest { static Stream casesProvider() { Server server = Server.Payara; - Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize, Packers.ScriptEngine); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara520225ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara520225ContainerTest.java index 7bc0fa82..34e55d1a 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara520225ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara520225ContainerTest.java @@ -45,8 +45,7 @@ public class Payara520225ContainerTest { static Stream casesProvider() { Server server = Server.Payara; - Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.FILTER, ShellType.LISTENER, ShellType.VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize, Packers.ScriptEngine); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara620222ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara620222ContainerTest.java index 5d7a2449..f28225f3 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara620222ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara620222ContainerTest.java @@ -43,12 +43,9 @@ public class Payara620222ContainerTest { static Stream casesProvider() { Server server = Server.Payara; - Set supportedShellTypes = Set.of(ShellType.JAKARTA_FILTER, ShellType.JAKARTA_LISTENER, ShellType.JAKARTA_VALVE, - ShellType.AGENT_FILTER_CHAIN, ShellType.CATALINA_AGENT_CONTEXT_VALVE); + Set supportedShellTypes = Set.of(ShellType.JAKARTA_FILTER, ShellType.JAKARTA_LISTENER, ShellType.JAKARTA_VALVE); Set testPackers = Set.of(Packers.JSP, Packers.JSPX, Packers.JavaDeserialize); - return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers, - null, Set.of(ShellTool.AntSword) // AntSword not supported Jakarta - ); + return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } @AfterAll diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/springmvc/SpringBoot2WarContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/springmvc/SpringBoot2WarContainerTest.java index 9d25ae0d..f66af7e9 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/springmvc/SpringBoot2WarContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/springmvc/SpringBoot2WarContainerTest.java @@ -43,7 +43,8 @@ public class SpringBoot2WarContainerTest { static Stream casesProvider() { Server server = Server.SpringWebMvc; - Set supportedShellTypes = Set.of(ShellType.SPRING_WEBMVC_INTERCEPTOR, ShellType.SPRING_WEBMVC_CONTROLLER_HANDLER, ShellType.SPRING_WEBMVC_AGENT_FRAMEWORK_SERVLET); + Set supportedShellTypes = Set.of(ShellType.SPRING_WEBMVC_INTERCEPTOR, + ShellType.SPRING_WEBMVC_CONTROLLER_HANDLER); Set testPackers = Set.of(Packers.ScriptEngine, Packers.SpEL, Packers.Base64); return TestCasesProvider.getTestCases(imageName, server, supportedShellTypes, testPackers); } diff --git a/vul/vul-webapp-jakarta/src/main/java/jakarta/EmptyFilter.java b/vul/vul-webapp-jakarta/src/main/java/jakarta/EmptyFilter.java new file mode 100644 index 00000000..b8532598 --- /dev/null +++ b/vul/vul-webapp-jakarta/src/main/java/jakarta/EmptyFilter.java @@ -0,0 +1,18 @@ +package jakarta; + +import jakarta.servlet.*; +import jakarta.servlet.annotation.WebFilter; + +import java.io.IOException; + +/** + * @author ReaJason + * @since 2025/2/23 + */ +@WebFilter("/*") +public class EmptyFilter implements Filter { + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + chain.doFilter(request, response); + } +} diff --git a/vul/vul-webapp/src/main/webapp/WEB-INF/web.xml b/vul/vul-webapp/src/main/webapp/WEB-INF/web.xml index a01b0cc5..7d347c0b 100644 --- a/vul/vul-webapp/src/main/webapp/WEB-INF/web.xml +++ b/vul/vul-webapp/src/main/webapp/WEB-INF/web.xml @@ -54,4 +54,13 @@ b64 /b64 + + + godzilla + EmptyFilter + + + godzilla + /* + \ No newline at end of file