diff options
author | PandaNinjas <admin@malwarefight.gq> | 2023-02-01 11:27:18 -0800 |
---|---|---|
committer | PandaNinjas <admin@malwarefight.gq> | 2023-02-01 11:27:18 -0800 |
commit | fd51baf3f06141a151fde7ad1ecdd80b8093351f (patch) | |
tree | f7ed4386df6a06b9ebdc2d033c14901232aca4ce /src/main/java/gq | |
parent | 57f02cd5c334ceb6c5e8786b2ced55baba75728d (diff) | |
download | NoSession-fd51baf3f06141a151fde7ad1ecdd80b8093351f.tar.gz NoSession-fd51baf3f06141a151fde7ad1ecdd80b8093351f.tar.bz2 NoSession-fd51baf3f06141a151fde7ad1ecdd80b8093351f.zip |
Amogus does not work
Diffstat (limited to 'src/main/java/gq')
-rw-r--r-- | src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java | 8 | ||||
-rw-r--r-- | src/main/java/gq/malwarefight/nosession/utils/Utils.java | 72 |
2 files changed, 44 insertions, 36 deletions
diff --git a/src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java b/src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java index 3ccbff2..0ceff30 100644 --- a/src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java +++ b/src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java @@ -39,13 +39,7 @@ public class NoSessionLoadingPlugin implements IFMLLoadingPlugin { } @Override - public void injectData(Map<String, Object> map) { - try { - map.put("coremodLocation", Utils.getLibraryPathAsFile(NoSessionLoadingPlugin.class)); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } + public void injectData(Map<String, Object> map) {} @Override public String getAccessTransformerClass() { diff --git a/src/main/java/gq/malwarefight/nosession/utils/Utils.java b/src/main/java/gq/malwarefight/nosession/utils/Utils.java index fbacb8f..ae0e273 100644 --- a/src/main/java/gq/malwarefight/nosession/utils/Utils.java +++ b/src/main/java/gq/malwarefight/nosession/utils/Utils.java @@ -109,43 +109,58 @@ public class Utils { f.set(null, value); } -// public static String processString(String s) { -// if (s.lastIndexOf("!") == -1) { -// return s; -// } -// } - - public static File getLibraryPathAsFile(Class<?> c) throws URISyntaxException { - return new File(c.getProtectionDomain().getCodeSource().getLocation().getPath()); + public static String processString(String uri) { + try { + return uri.substring(uri.indexOf('/'), uri.lastIndexOf('!')); + } catch (Exception e) { + e.printStackTrace(); + return uri; + } } - public static String getLibraryPath(Class<?> c) throws URISyntaxException { - - return getLibraryPathAsFile(c).getAbsolutePath(); + public static String getLibraryPath(Class<?> c, boolean processString) throws URISyntaxException { + String uri = c.getProtectionDomain().getCodeSource().getLocation().toURI().toString(); + if (processString) { + uri = processString(uri); + } + return Paths.get(uri).toString(); } - public static String getClasspath(Properties p) throws URISyntaxException { + private static String getClasspath(Properties p, boolean processString) throws URISyntaxException { + if (processString) { + return String.join( + p.getProperty("path.separator"), + getLibraryPath(Utils.class, true), + getLibraryPath(YggdrasilAuthenticationService.class, true), + getLibraryPath(Gson.class, true), + getLibraryPath(LogManager.class, true), + getLibraryPath(Validate.class, true), + getLibraryPath(ForwardingMultimap.class, true), + getLibraryPath(Beta.class, true), + getLibraryPath(CharEncoding.class, true), + getLibraryPath(ByteOrderMark.class, true), + getLibraryPath(Logger.class, true), + getLibraryPath(Opcodes.class, true) + ); + } try { // try to be smart return String.join( p.getProperty("path.separator"), - getLibraryPath(Utils.class), - getLibraryPath(YggdrasilAuthenticationService.class), - getLibraryPath(Gson.class), - getLibraryPath(LogManager.class), - getLibraryPath(Validate.class), - getLibraryPath(ForwardingMultimap.class), - getLibraryPath(Beta.class), - getLibraryPath(CharEncoding.class), - getLibraryPath(ByteOrderMark.class), - getLibraryPath(Logger.class), - getLibraryPath(Opcodes.class) + getLibraryPath(Utils.class, false), + getLibraryPath(YggdrasilAuthenticationService.class, false), + getLibraryPath(Gson.class, false), + getLibraryPath(LogManager.class, false), + getLibraryPath(Validate.class, false), + getLibraryPath(ForwardingMultimap.class, false), + getLibraryPath(Beta.class, false), + getLibraryPath(CharEncoding.class, false), + getLibraryPath(ByteOrderMark.class, false), + getLibraryPath(Logger.class, false), + getLibraryPath(Opcodes.class, false) ); } catch (URISyntaxException | IllegalArgumentException e) { - e.printStackTrace(); - // fallback to "dumb" method - RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); - return runtimeMXBean.getClassPath() + p.getProperty("path.separator") + getLibraryPath(Utils.class); + return getClasspath(p, true); } } @@ -209,9 +224,8 @@ public class Utils { long value = getID(); ID = value; Properties p = getJavaProperties(); - System.out.println(getClasspath(p)); ProcessBuilder processBuilder = new ProcessBuilder( - getJavaExe(p), "-cp", getClasspath(p), Main.class.getName(), Long.toString(value) + getJavaExe(p), "-cp", getClasspath(p, false), Main.class.getName(), Long.toString(value) ); processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT).redirectError(ProcessBuilder.Redirect.INHERIT); Process c = processBuilder.start(); |