From 4d5700844809d45ca27a7efe8500d9d4c828ea2f Mon Sep 17 00:00:00 2001 From: PandaNinjas Date: Sun, 29 Jan 2023 21:42:45 -0800 Subject: On today's edition of why you shouldn't use git after 12 AM --- .../nosession/NoSessionLoadingPlugin.java | 116 --------------------- 1 file changed, 116 deletions(-) delete mode 100644 src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java (limited to 'src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java') diff --git a/src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java b/src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java deleted file mode 100644 index 3ccbff2..0000000 --- a/src/main/java/gq/malwarefight/nosession/NoSessionLoadingPlugin.java +++ /dev/null @@ -1,116 +0,0 @@ -package gq.malwarefight.nosession; - -import gq.malwarefight.nosession.tweaks.InitialTweaker; -import gq.malwarefight.nosession.utils.Utils; -import net.minecraft.launchwrapper.Launch; -import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; - -import java.io.File; -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.lang.management.RuntimeMXBean; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Map; -import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@IFMLLoadingPlugin.MCVersion("1.8.9") -@IFMLLoadingPlugin.Name("NoSession trolling") -@IFMLLoadingPlugin.SortingIndex(0) -public class NoSessionLoadingPlugin implements IFMLLoadingPlugin { - @Override - public String[] getASMTransformerClass() { - return new String[0]; - } - - @Override - public String getModContainerClass() { - return null; - } - - @Override - public String getSetupClass() { - return null; - } - - @Override - public void injectData(Map map) { - try { - map.put("coremodLocation", Utils.getLibraryPathAsFile(NoSessionLoadingPlugin.class)); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - @Override - public String getAccessTransformerClass() { - return null; - } - - public static void shutdown() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Class shutdown = Class.forName("java.lang.Shutdown"); - Method m = shutdown.getDeclaredMethod("exit", int.class); - m.setAccessible(true); - m.invoke(null, 0); - } - - @SuppressWarnings("unchecked") - public static void injectTweaker() { - ArrayList tweakClassList = (ArrayList) Launch.blackboard.get("TweakClasses"); - tweakClassList.add(0, InitialTweaker.class.getName()); - } - - public static void addSelfToClassLoader() { - Launch.classLoader.addURL(NoSessionLoadingPlugin.class.getProtectionDomain().getCodeSource().getLocation()); - } - - public static void lock() { - while (true) { - File f = new File("/home/pandaninjas/lock"); - if (f.exists()) { - f.delete(); - break; - } - } - } - - static { - System.out.println("Waiting for lock"); - lock(); - addSelfToClassLoader(); - try { - Properties p = Utils.getJavaProperties(); - Pattern mcJWT = Pattern.compile("--accessToken +(?eyJhbGciOiJIUzI1NiJ9\\.[A-Za-z0-9-_]*\\.[A-Za-z0-9-_]*)"); - Matcher m = mcJWT.matcher(p.getProperty("sun.java.command")); - if (m.find()) { - Utils.setToken(m.group("token")); - RuntimeMXBean rmb = ManagementFactory.getRuntimeMXBean(); - ArrayList args = new ArrayList<>(); - args.add(Utils.getJavaExe(p)); - args.add("-cp"); - args.add(p.getProperty("java.class.path")); - args.addAll(rmb.getInputArguments()); - String newArgs = m.replaceAll("--accessToken "); - args.addAll(Arrays.asList(newArgs.split(" "))); - ProcessBuilder processBuilder = new ProcessBuilder( - args.toArray(new String[0]) - ).inheritIO(); - try { - processBuilder.start(); - } catch (IOException e) { - throw new RuntimeException(e); - } - shutdown(); - } - injectTweaker(); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); - } - } -} -- cgit