From 930a5caf746c7599e7b50672b7c8636605c5bfe2 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Sun, 26 Feb 2023 19:01:43 +0700 Subject: [PATCH] [ANY] Remove old guard/antiinject support --- .../binary/JARLauncherBinary.java | 2 - .../binary/tasks/MainBuildTask.java | 2 - .../binary/tasks/PrepareBuildTask.java | 1 - .../config/LaunchServerConfig.java | 2 - .../pro/gravit/launcher/LauncherEngine.java | 15 ------- .../client/ClientLauncherProcess.java | 1 - .../gravit/launcher/guard/LauncherGuard.java | 9 ----- .../launcher/guard/LauncherNoGuard.java | 15 ------- .../launcher/guard/LauncherWrapperGuard.java | 40 ------------------- .../java/pro/gravit/launcher/Launcher.java | 1 - .../pro/gravit/launcher/LauncherConfig.java | 5 --- 11 files changed, 93 deletions(-) delete mode 100644 Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGuard.java delete mode 100644 Launcher/src/main/java/pro/gravit/launcher/guard/LauncherNoGuard.java delete mode 100644 Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java index 77685633..72f60338 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/JARLauncherBinary.java @@ -16,7 +16,6 @@ public final class JARLauncherBinary extends LauncherBinary { public final AtomicLong count; public final Path runtimeDir; - public final Path guardDir; public final Path buildDir; public final List coreLibs; public final List addonLibs; @@ -27,7 +26,6 @@ public JARLauncherBinary(LaunchServer server) throws IOException { super(server, resolve(server, ".jar"), "Launcher-%s-%d.jar"); count = new AtomicLong(0); runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); - guardDir = server.dir.resolve(Launcher.GUARD_DIR); buildDir = server.dir.resolve("build"); coreLibs = new ArrayList<>(); addonLibs = new ArrayList<>(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java index 27e06a7b..0b3a87bf 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -72,7 +72,6 @@ public Path process(Path inputJar) throws IOException { } else { context.pushDir(server.launcherBinary.runtimeDir, Launcher.RUNTIME_DIR, runtime, false); } - context.pushDir(server.launcherBinary.guardDir, Launcher.GUARD_DIR, runtime, false); LauncherConfig launcherConfig = new LauncherConfig(server.config.netty.address, server.keyAgreementManager.ecdsaPublicKey, server.keyAgreementManager.rsaPublicKey, runtime, server.config.projectName); context.pushFile(Launcher.CONFIG_FILE, launcherConfig); @@ -108,7 +107,6 @@ protected void initProps() { properties.put("launcher.projectName", server.config.projectName); properties.put("runtimeconfig.secretKeyClient", SecurityHelper.randomStringAESKey()); properties.put("launcher.port", 32148 + SecurityHelper.newRandom().nextInt(512)); - properties.put("launcher.guardType", server.config.launcher.guardType); properties.put("launchercore.env", server.config.env); properties.put("launcher.memory", server.config.launcher.memoryLimit); properties.put("launcher.customJvmOptions", server.config.launcher.customJvmOptions); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/PrepareBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/PrepareBuildTask.java index 0ab1675c..4772615b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/PrepareBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/PrepareBuildTask.java @@ -60,7 +60,6 @@ public boolean allowDelete() { public void tryUnpack() throws IOException { logger.info("Unpacking launcher native guard list and runtime"); - UnpackHelper.unpackZipNoCheck("guard.zip", server.launcherBinary.guardDir); UnpackHelper.unpackZipNoCheck("runtime.zip", server.launcherBinary.runtimeDir); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java index 583bf33b..af766e3c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -84,7 +84,6 @@ public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) { newConfig.netty.performance.schedulerThread = 2; newConfig.launcher = new LauncherConf(); - newConfig.launcher.guardType = "no"; newConfig.launcher.compress = true; newConfig.launcher.deleteTempFiles = true; newConfig.launcher.stripLineNumbers = true; @@ -269,7 +268,6 @@ public static class NettyUpdatesBind { } public static class LauncherConf { - public String guardType; public boolean compress; public boolean stripLineNumbers; public boolean deleteTempFiles; diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java index 793f151c..6f22d4f9 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java @@ -8,9 +8,6 @@ import pro.gravit.launcher.console.ModulesCommand; import pro.gravit.launcher.console.SignDataCommand; import pro.gravit.launcher.events.request.*; -import pro.gravit.launcher.guard.LauncherGuard; -import pro.gravit.launcher.guard.LauncherNoGuard; -import pro.gravit.launcher.guard.LauncherWrapperGuard; import pro.gravit.launcher.gui.NoRuntimeProvider; import pro.gravit.launcher.gui.RuntimeProvider; import pro.gravit.launcher.managers.ClientGsonManager; @@ -49,7 +46,6 @@ public class LauncherEngine { public static ClientLauncherProcess.ClientParams clientParams; - public static LauncherGuard guard; public static ClientModuleManager modulesManager; public final boolean clientInstance; // Instance @@ -153,16 +149,6 @@ public static void verifyNoAgent() { throw new SecurityException("JavaAgent found"); } - public static LauncherGuard tryGetStdGuard() { - switch (Launcher.getConfig().guardType) { - case "no": - return new LauncherNoGuard(); - case "wrapper": - return new LauncherWrapperGuard(); - } - return null; - } - public static RequestService initOffline() { OfflineRequestService service = new OfflineRequestService(); applyBasicOfflineProcessors(service); @@ -232,7 +218,6 @@ public void readKeys() throws IOException, InvalidKeySpecException { public void start(String... args) throws Throwable { //Launcher.modulesManager = new ClientModuleManager(this); - LauncherEngine.guard = tryGetStdGuard(); ClientPreGuiPhase event = new ClientPreGuiPhase(null); LauncherEngine.modulesManager.invokeEvent(event); runtimeProvider = event.runtimeProvider; diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java index 66bcc917..8a9343f6 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java @@ -133,7 +133,6 @@ private void applyClientProfile() { public void start(boolean pipeOutput) throws IOException, InterruptedException { if (isStarted) throw new IllegalStateException("Process already started"); - if (LauncherEngine.guard != null) LauncherEngine.guard.applyGuardParams(this); LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderPreLaunchEvent(this)); List processArgs = new LinkedList<>(); processArgs.add(executeFile.toString()); diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGuard.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGuard.java deleted file mode 100644 index 899cf1af..00000000 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGuard.java +++ /dev/null @@ -1,9 +0,0 @@ -package pro.gravit.launcher.guard; - -import pro.gravit.launcher.client.ClientLauncherProcess; - -public interface LauncherGuard { - String getName(); - - void applyGuardParams(ClientLauncherProcess process); -} diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherNoGuard.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherNoGuard.java deleted file mode 100644 index d43bff54..00000000 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherNoGuard.java +++ /dev/null @@ -1,15 +0,0 @@ -package pro.gravit.launcher.guard; - -import pro.gravit.launcher.client.ClientLauncherProcess; - -public class LauncherNoGuard implements LauncherGuard { - @Override - public String getName() { - return "noGuard"; - } - - @Override - public void applyGuardParams(ClientLauncherProcess process) { - //IGNORED - } -} diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java deleted file mode 100644 index 0991673a..00000000 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java +++ /dev/null @@ -1,40 +0,0 @@ -package pro.gravit.launcher.guard; - -import pro.gravit.launcher.Launcher; -import pro.gravit.launcher.client.ClientLauncherProcess; -import pro.gravit.launcher.client.DirBridge; -import pro.gravit.utils.helper.JVMHelper; -import pro.gravit.utils.helper.UnpackHelper; - -import java.io.IOException; - -public class LauncherWrapperGuard implements LauncherGuard { - - public LauncherWrapperGuard() { - try { - String wrapperName = JVMHelper.JVM_BITS == 64 ? "wrapper64.exe" : "wrapper32.exe"; - String projectName = Launcher.getConfig().projectName; - String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); - String antiInjectName = JVMHelper.JVM_BITS == 64 ? "AntiInject64.dll" : "AntiInject32.dll"; - UnpackHelper.unpack(Launcher.getResourceURL(wrapperName, "guard"), DirBridge.getGuardDir().resolve(wrapperUnpackName)); - UnpackHelper.unpack(Launcher.getResourceURL(antiInjectName, "guard"), DirBridge.getGuardDir().resolve(antiInjectName)); - } catch (IOException e) { - throw new SecurityException(e); - } - } - - @Override - public String getName() { - return "wrapper"; - } - - @Override - public void applyGuardParams(ClientLauncherProcess process) { - if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) { - String projectName = Launcher.getConfig().projectName; - String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); - process.executeFile = DirBridge.getGuardDir().resolve(wrapperUnpackName); - process.useLegacyJavaClassPathProperty = true; - } - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/Launcher.java b/LauncherAPI/src/main/java/pro/gravit/launcher/Launcher.java index 384623cb..e9471df0 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/Launcher.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/Launcher.java @@ -41,7 +41,6 @@ public final class Launcher { public static final String RUNTIME_DIR = "runtime"; // Constants - public static final String GUARD_DIR = "guard"; public static final String CONFIG_FILE = "config.bin"; private static final AtomicReference CONFIG = new AtomicReference<>(); private static final Pattern UUID_PATTERN = Pattern.compile("-", Pattern.LITERAL); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java index 290d64e3..0d90c99d 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java @@ -32,8 +32,6 @@ public final class LauncherConfig extends StreamObject { public final ECPublicKey ecdsaPublicKey; public final RSAPublicKey rsaPublicKey; public final Map runtime; - @LauncherInject("launcher.guardType") - public final String guardType; @LauncherInject("runtimeconfig.secureCheckHash") public final String secureCheckHash; @LauncherInject("runtimeconfig.secureCheckSalt") @@ -68,7 +66,6 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException } catch (CertificateException e) { throw new IOException(e); } - guardType = null; address = null; environment = LauncherEnvironment.STD; Launcher.applyLauncherEnv(environment); @@ -91,7 +88,6 @@ public LauncherConfig(String address, ECPublicKey ecdsaPublicKey, RSAPublicKey r this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime)); this.projectName = projectName; this.clientPort = 32148; - guardType = "no"; environment = LauncherEnvironment.STD; secureCheckSalt = null; secureCheckHash = null; @@ -109,7 +105,6 @@ public LauncherConfig(String address, Map runtime, String projec this.rsaPublicKey = null; this.ecdsaPublicKey = null; environment = env; - guardType = "no"; secureCheckSalt = null; secureCheckHash = null; passwordEncryptKey = null;