mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
feat: support servletNameFilter for JettyFilterProbe
This commit is contained in:
+51
-27
@@ -14,38 +14,46 @@ public class JettyFilterProbe {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String msg = "";
|
||||
StringBuilder msg = new StringBuilder();
|
||||
Map<String, List<Map<String, String>>> allFiltersData = new LinkedHashMap<String, List<Map<String, String>>>();
|
||||
Set<Object> contexts = null;
|
||||
try {
|
||||
contexts = getContext();
|
||||
} catch (Throwable throwable) {
|
||||
msg += "context error: " + getErrorMessage(throwable);
|
||||
msg.append("context error: ").append(getErrorMessage(throwable));
|
||||
}
|
||||
if (contexts == null || contexts.isEmpty()) {
|
||||
msg += "context not found\n";
|
||||
msg.append("context not found\n");
|
||||
} else {
|
||||
for (Object context : contexts) {
|
||||
String contextRoot = getContextRoot(context);
|
||||
List<Map<String, String>> filters = collectFiltersData(context);
|
||||
allFiltersData.put(contextRoot, filters);
|
||||
try {
|
||||
List<Map<String, String>> filters = collectFiltersData(context);
|
||||
allFiltersData.put(contextRoot, filters);
|
||||
} catch (Throwable e) {
|
||||
msg.append(contextRoot).append(" failed ").append(getErrorMessage(e)).append("\n");
|
||||
}
|
||||
}
|
||||
msg += formatFiltersData(allFiltersData);
|
||||
msg.append(formatFiltersData(allFiltersData));
|
||||
}
|
||||
return msg;
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
private List<Map<String, String>> collectFiltersData(Object context) {
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
try {
|
||||
Object servletHandler = getFieldValue(context, "_servletHandler");
|
||||
if (servletHandler == null) return Collections.emptyList();
|
||||
Object[] filterMappings = (Object[]) invokeMethod(servletHandler, "getFilterMappings");
|
||||
Object[] filterHolders = (Object[]) invokeMethod(servletHandler, "getFilters");
|
||||
if (filterMappings == null || filterMappings.length == 0) return Collections.emptyList();
|
||||
for (Object mapping : filterMappings) {
|
||||
String name = (String) invokeMethod(mapping, "getFilterName");
|
||||
if (name == null) continue;
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Map<String, String>> collectFiltersData(Object context) throws Exception {
|
||||
Map<String, Map<String, Object>> aggregatedData = new LinkedHashMap<>();
|
||||
|
||||
Object servletHandler = getFieldValue(context, "_servletHandler");
|
||||
Object[] filterMappings = (Object[]) invokeMethod(servletHandler, "getFilterMappings");
|
||||
if (filterMappings == null || filterMappings.length == 0) return Collections.emptyList();
|
||||
|
||||
Object[] filterHolders = (Object[]) invokeMethod(servletHandler, "getFilters");
|
||||
|
||||
for (Object mapping : filterMappings) {
|
||||
String name = (String) invokeMethod(mapping, "getFilterName");
|
||||
if (name == null) continue;
|
||||
|
||||
if (!aggregatedData.containsKey(name)) {
|
||||
String filterClass = "N/A";
|
||||
if (filterHolders != null) {
|
||||
for (Object holder : filterHolders) {
|
||||
@@ -58,22 +66,37 @@ public class JettyFilterProbe {
|
||||
cls = filterInstance.getClass().getName();
|
||||
}
|
||||
}
|
||||
|
||||
if (cls != null) filterClass = cls;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Map<String, String> info = new HashMap<>();
|
||||
Map<String, Object> info = new HashMap<>();
|
||||
info.put("filterName", name);
|
||||
info.put("filterClass", filterClass);
|
||||
try {
|
||||
String[] pathSpecs = (String[]) invokeMethod(mapping, "getPathSpecs");
|
||||
info.put("urlPatterns", pathSpecs.length == 0 ? "" : Arrays.toString(pathSpecs));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
result.add(info);
|
||||
info.put("urlPatterns", new LinkedHashSet<String>());
|
||||
info.put("servletNames", new LinkedHashSet<String>());
|
||||
aggregatedData.put(name, info);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
Map<String, Object> info = aggregatedData.get(name);
|
||||
|
||||
String[] pathSpecs = (String[]) invokeMethod(mapping, "getPathSpecs");
|
||||
if (pathSpecs != null) ((Set<String>) info.get("urlPatterns")).addAll(Arrays.asList(pathSpecs));
|
||||
|
||||
String[] servletNames = (String[]) invokeMethod(mapping, "getServletNames");
|
||||
if (servletNames != null) ((Set<String>) info.get("servletNames")).addAll(Arrays.asList(servletNames));
|
||||
}
|
||||
|
||||
List<Map<String, String>> result = new ArrayList<>();
|
||||
for (Map<String, Object> entry : aggregatedData.values()) {
|
||||
Map<String, String> finalInfo = new HashMap<>();
|
||||
finalInfo.put("filterName", (String) entry.get("filterName"));
|
||||
finalInfo.put("filterClass", (String) entry.get("filterClass"));
|
||||
Set<?> urls = (Set<?>) entry.get("urlPatterns");
|
||||
finalInfo.put("urlPatterns", urls.isEmpty() ? "" : urls.toString());
|
||||
Set<?> servletNames = (Set<?>) entry.get("servletNames");
|
||||
finalInfo.put("servletNames", servletNames.isEmpty() ? "" : servletNames.toString());
|
||||
result.add(finalInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -94,6 +117,7 @@ public class JettyFilterProbe {
|
||||
appendIfPresent(output, "", info.get("filterName"), "");
|
||||
appendIfPresent(output, " -> ", info.get("filterClass"), "");
|
||||
appendIfPresent(output, " -> URL:", info.get("urlPatterns"), "");
|
||||
appendIfPresent(output, " -> Servlet:", info.get("servletNames"), "");
|
||||
output.append("\n");
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -73,20 +73,16 @@ public class TomcatFilterProbe {
|
||||
try {
|
||||
urls = (String[]) invokeMethod(fm, "getURLPatterns");
|
||||
} catch (Exception e) {
|
||||
Object urlPattern = invokeMethod(fm, "getURLPattern");
|
||||
if (urlPattern instanceof String) {
|
||||
urls = new String[]{(String) urlPattern};
|
||||
}
|
||||
// Tomcat 5
|
||||
urls = new String[]{(String) invokeMethod(fm, "getURLPattern")};
|
||||
}
|
||||
if (urls != null) ((Set<String>) info.get("urlPatterns")).addAll(Arrays.asList(urls));
|
||||
String[] servletNames = null;
|
||||
try {
|
||||
servletNames = (String[]) invokeMethod(fm, "getServletNames");
|
||||
} catch (Exception e) {
|
||||
Object servletName = invokeMethod(fm, "getServletName");
|
||||
if (servletName instanceof String) {
|
||||
servletNames = new String[]{(String) servletName};
|
||||
}
|
||||
// Tomcat 5
|
||||
servletNames = new String[]{(String) invokeMethod(fm, "getServletName")};
|
||||
}
|
||||
if (servletNames != null) ((Set<String>) info.get("servletNames")).addAll(Arrays.asList(servletNames));
|
||||
}
|
||||
|
||||
+7
-7
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -86,20 +89,17 @@ public class Jetty10ContainerTest {
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V11, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V11, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+9
-8
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -24,7 +27,8 @@ import java.util.List;
|
||||
import static com.reajason.javaweb.integration.ContainerTool.getUrl;
|
||||
import static com.reajason.javaweb.integration.ContainerTool.warJakartaFile;
|
||||
import static com.reajason.javaweb.integration.ShellAssertion.shellInjectIsOk;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.CoreMatchers.anyOf;
|
||||
import static org.hamcrest.CoreMatchers.startsWith;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@@ -86,20 +90,17 @@ public class Jetty11ContainerTest {
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.JAKARTA_FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V17, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.JAKARTA_FILTER, ShellTool.Command, Opcodes.V17, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+4
-5
@@ -2,11 +2,13 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -73,11 +75,8 @@ public class Jetty12ee10ContainerTest {
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+4
-5
@@ -2,11 +2,13 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -73,11 +75,8 @@ public class Jetty12ee11ContainerTest {
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+7
-7
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -79,20 +82,17 @@ public class Jetty12ee8ContainerTest {
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, Opcodes.V21, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, Opcodes.V21, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+4
-5
@@ -2,11 +2,13 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -73,11 +75,8 @@ public class Jetty12ee9ContainerTest {
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+7
-9
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -24,8 +27,6 @@ import java.util.List;
|
||||
import static com.reajason.javaweb.integration.ContainerTool.getUrl;
|
||||
import static com.reajason.javaweb.integration.ContainerTool.warFile;
|
||||
import static com.reajason.javaweb.integration.ShellAssertion.shellInjectIsOk;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
@@ -86,20 +87,17 @@ public class Jetty61ContainerTest {
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, Opcodes.V1_6, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+7
-9
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -23,8 +26,6 @@ import java.util.List;
|
||||
import static com.reajason.javaweb.integration.ContainerTool.getUrl;
|
||||
import static com.reajason.javaweb.integration.ContainerTool.warFile;
|
||||
import static com.reajason.javaweb.integration.ShellAssertion.shellInjectIsOk;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
@@ -80,20 +81,17 @@ public class Jetty75ContainerTest {
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, Opcodes.V1_6, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -77,23 +80,20 @@ public class Jetty76ContainerTest {
|
||||
ProbeAssertion.responseBytecodeIsOk(url, Server.Jetty, Opcodes.V1_6);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -77,23 +80,20 @@ public class Jetty81ContainerTest {
|
||||
ProbeAssertion.responseBytecodeIsOk(url, Server.Jetty, Opcodes.V1_7);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -78,23 +81,20 @@ public class Jetty92ContainerTest {
|
||||
ProbeAssertion.responseBytecodeIsOk(url, Server.Jetty, Opcodes.V1_7);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -77,23 +80,20 @@ public class Jetty93ContainerTest {
|
||||
ProbeAssertion.responseBytecodeIsOk(url, Server.Jetty, Opcodes.V1_8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -2,11 +2,14 @@ package com.reajason.javaweb.integration.probe.jetty;
|
||||
|
||||
import com.reajason.javaweb.Server;
|
||||
import com.reajason.javaweb.integration.ProbeAssertion;
|
||||
import com.reajason.javaweb.integration.ShellAssertion;
|
||||
import com.reajason.javaweb.integration.VulTool;
|
||||
import com.reajason.javaweb.integration.probe.DetectionTool;
|
||||
import com.reajason.javaweb.memshell.MemShellResult;
|
||||
import com.reajason.javaweb.memshell.ShellTool;
|
||||
import com.reajason.javaweb.memshell.ShellType;
|
||||
import com.reajason.javaweb.packer.Packers;
|
||||
import com.reajason.javaweb.probe.payload.FilterProbeFactory;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
@@ -77,23 +80,20 @@ public class Jetty94ContainerTest {
|
||||
ProbeAssertion.responseBytecodeIsOk(url, Server.Jetty, Opcodes.V1_8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
void testFilterProbe() {
|
||||
String url = getUrl(container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
System.out.println(data);
|
||||
assertThat(data, anyOf(
|
||||
containsString("Context: ")
|
||||
));
|
||||
String data = VulTool.post(url + "/b64", FilterProbeFactory.getBase64ByServer(Server.Jetty));
|
||||
ShellAssertion.assertFilterProbeIsRight(data);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterFirstInject() {
|
||||
String url = getUrl(container);
|
||||
shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
MemShellResult memShellResult = shellInjectIsOk(url, Server.Jetty, ShellType.FILTER, ShellTool.Command, org.objectweb.asm.Opcodes.V1_6, Packers.BigInteger, container);
|
||||
String data = VulTool.post(url + "/b64", DetectionTool.getJettyFilterProbe());
|
||||
List<String> filter = ProbeAssertion.getFiltersForContext(data, "/app");
|
||||
String filterName = ProbeAssertion.extractFilterName(filter.get(0));
|
||||
assertThat(filterName, anyOf(startsWith("org.eclipse.jetty.servlet.handlers")));
|
||||
assertEquals(filterName, memShellResult.getShellClassName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user