From 35a94ae59f45bdd8bc530b8c6b787706cbd59cb9 Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 16 Oct 2019 17:08:48 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=92=D1=8B=D1=80=D0=B5=D0=B7=D0=B0?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BB=D0=B8=D1=86=D0=B5=D0=BD=D0=B7=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=B7=D0=B0=D1=89=D0=B8=D1=82=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/LauncherConfigurator.java | 28 ------------------- .../binary/tasks/MainBuildTask.java | 4 --- .../config/LaunchServerConfig.java | 7 ----- .../launcher/bridge/GravitGuardBridge.java | 22 --------------- .../launcher/guard/LauncherGuardManager.java | 2 +- ...GravitGuard.java => LauncherStdGuard.java} | 10 ++----- .../launcher/guard/LauncherWrapperGuard.java | 1 - 7 files changed, 4 insertions(+), 70 deletions(-) delete mode 100644 Launcher/src/main/java/pro/gravit/launcher/bridge/GravitGuardBridge.java rename Launcher/src/main/java/pro/gravit/launcher/guard/{LauncherGravitGuard.java => LauncherStdGuard.java} (87%) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java index e1aac82e..9494a143 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java @@ -150,32 +150,4 @@ private void setBooleanField(String name, boolean b) constructor.instructions.add(new InsnNode(b ? Opcodes.ICONST_1 : Opcodes.ICONST_0)); constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, name, Type.BOOLEAN_TYPE.getInternalName())); } - - public void setGuardLicense(String name, String key, String encryptKey) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new LdcInsnNode(name)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "guardLicenseName", stringDesc)); - - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new LdcInsnNode(key)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "guardLicenseKey", stringDesc)); - - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new LdcInsnNode(encryptKey)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "guardLicenseEncryptKey", stringDesc)); - } - - public void nullGuardLicense() { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new InsnNode(Opcodes.ACONST_NULL)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "guardLicenseName", stringDesc)); - - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new InsnNode(Opcodes.ACONST_NULL)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "guardLicenseKey", stringDesc)); - - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new InsnNode(Opcodes.ACONST_NULL)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "guardLicenseEncryptKey", stringDesc)); - } } 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 df570184..b111755d 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 @@ -124,10 +124,6 @@ public Path process(Path inputJar) throws IOException { BuildContext context = new BuildContext(output, launcherConfigurator, this); server.buildHookManager.hook(context); launcherConfigurator.setAddress(server.config.netty.address); - if (server.config.guardLicense != null) - launcherConfigurator.setGuardLicense(server.config.guardLicense.name, server.config.guardLicense.key, server.config.guardLicense.encryptKey); - else - launcherConfigurator.nullGuardLicense(); launcherConfigurator.setProjectName(server.config.projectName); launcherConfigurator.setSecretKey(SecurityHelper.randomStringAESKey()); launcherConfigurator.setClientPort(32148 + SecurityHelper.newRandom().nextInt(512)); 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 a3e5aa04..7f7e01f5 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 AuthProviderPair getAuthProviderPair() { public ExeConf launch4j; public NettyConfig netty; - public GuardLicenseConf guardLicense; public String whitelistRejectString; public LauncherConf launcher; @@ -280,12 +279,6 @@ public NettyBindAddress(String address, int port) { this.port = port; } } - - public static class GuardLicenseConf { - public String name; - public String key; - public String encryptKey; - } public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) { LaunchServerConfig newConfig = new LaunchServerConfig(); diff --git a/Launcher/src/main/java/pro/gravit/launcher/bridge/GravitGuardBridge.java b/Launcher/src/main/java/pro/gravit/launcher/bridge/GravitGuardBridge.java deleted file mode 100644 index ec8e9fa5..00000000 --- a/Launcher/src/main/java/pro/gravit/launcher/bridge/GravitGuardBridge.java +++ /dev/null @@ -1,22 +0,0 @@ -package pro.gravit.launcher.bridge; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; - -import pro.gravit.launcher.LauncherAPI; - -@LauncherAPI -public class GravitGuardBridge { - @LauncherAPI - public static native void callGuard(); - - @LauncherAPI - public static int sendHTTPRequest(String strurl) throws IOException { - URL url = new URL(strurl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("GET"); - connection.setRequestProperty("Content-Language", "en-US"); - return connection.getResponseCode(); - } -} diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGuardManager.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGuardManager.java index 92718c25..6f0ce1d9 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGuardManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGuardManager.java @@ -12,7 +12,7 @@ public static void initGuard(boolean clientInstance) { LauncherConfig config = Launcher.getConfig(); switch (config.guardType) { case "gravitguard": { - guard = new LauncherGravitGuard(); + guard = new LauncherStdGuard(); break; } case "wrapper": { diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGravitGuard.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherStdGuard.java similarity index 87% rename from Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGravitGuard.java rename to Launcher/src/main/java/pro/gravit/launcher/guard/LauncherStdGuard.java index 10735c83..d93d9baa 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherGravitGuard.java +++ b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherStdGuard.java @@ -8,7 +8,6 @@ import pro.gravit.launcher.Launcher; import pro.gravit.launcher.LauncherConfig; -import pro.gravit.launcher.bridge.GravitGuardBridge; import pro.gravit.launcher.client.ClientLauncher; import pro.gravit.launcher.client.ClientLauncherContext; import pro.gravit.launcher.client.DirBridge; @@ -16,14 +15,14 @@ import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.UnpackHelper; -//Используется для всех типов защит, совместимых с новым GravitGuard API -public class LauncherGravitGuard implements LauncherGuardInterface { +//Стандартный интерфейс для всех AntiInject +public class LauncherStdGuard implements LauncherGuardInterface { public String protectToken; public Path javaBinPath; @Override public String getName() { - return "gravitguard"; + return "stdguard"; } @Override @@ -58,7 +57,6 @@ public void init(boolean clientInstance) { } catch (IOException e) { throw new SecurityException(e); } - if (clientInstance && JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) GravitGuardBridge.callGuard(); } @Override @@ -74,9 +72,7 @@ public void addCustomEnv(ClientLauncherContext context) { else env.put("JAVA_HOME", javaBinPath.toAbsolutePath().toString()); LauncherConfig config = Launcher.getConfig(); - env.put("GUARD_BRIDGE", GravitGuardBridge.class.getName()); env.put("GUARD_USERNAME", context.playerProfile.username); - //env.put("GUARD_PUBLICKEY", config.publicKey.getModulus().toString(16)); env.put("GUARD_PROJECTNAME", config.projectname); if (protectToken != null) env.put("GUARD_TOKEN", protectToken); diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java index e6922146..550a1925 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java @@ -63,7 +63,6 @@ public void addCustomEnv(ClientLauncherContext context) { env.put("JAVA_HOME", System.getProperty("java.home")); LauncherConfig config = Launcher.getConfig(); env.put("GUARD_USERNAME", context.playerProfile.username); - //env.put("GUARD_PUBLICKEY", config.publicKey.getModulus().toString(16)); env.put("GUARD_PROJECTNAME", config.projectname); if (protectToken != null) env.put("GUARD_TOKEN", protectToken);