From c5635de295c509096210ca87b9fcc421a8f3235e Mon Sep 17 00:00:00 2001 From: Gravit Date: Wed, 22 May 2019 05:32:40 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=D0=9F=D0=BE=D0=BB=D0=BD=D0=BE=D1=86?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B5=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B1=D0=BB=D0=BE=D0=BA=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=B8=20launcher=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=81=D0=BE=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launchserver/binary/JAConfigurator.java | 6 ++++++ .../ru/gravit/launchserver/binary/tasks/MainBuildTask.java | 2 ++ .../launchserver/config/LaunchServerRuntimeConfig.java | 1 + .../java/ru/gravit/launcher/managers/ConsoleManager.java | 6 +++++- .../src/main/java/ru/gravit/launcher/AutogenConfig.java | 1 + .../src/main/java/ru/gravit/launcher/LauncherConfig.java | 2 ++ 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java index a720d371..f3980d97 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JAConfigurator.java @@ -83,6 +83,12 @@ public void setSecretKey(String key) { body.append("\";"); } + public void setOemUnlockKey(String key) { + body.append("this.oemUnlockKey = \""); + body.append(key); + body.append("\";"); + } + public void setGuardType(String key) { body.append("this.guardType = \""); body.append(key); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java index 06d60a01..255dfd59 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -137,6 +137,8 @@ public Path process(Path inputJar) throws IOException { jaConfigurator.setGuardType(server.config.launcher.guardType); jaConfigurator.setWarningMissArchJava(server.config.isWarningMissArchJava); jaConfigurator.setEnv(server.config.env); + if(server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken(); + jaConfigurator.setOemUnlockKey(server.runtime.oemUnlockKey); server.buildHookManager.registerAllClientModuleClass(jaConfigurator); reader.getCp().add(new JarFile(inputJar.toFile())); server.launcherBinary.coreLibs.forEach(e -> { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/config/LaunchServerRuntimeConfig.java b/LaunchServer/src/main/java/ru/gravit/launchserver/config/LaunchServerRuntimeConfig.java index c46ffadf..31e55878 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/config/LaunchServerRuntimeConfig.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/config/LaunchServerRuntimeConfig.java @@ -5,6 +5,7 @@ public class LaunchServerRuntimeConfig { public String clientToken; + public String oemUnlockKey; public void verify() { if (clientToken == null) LogHelper.error("[RuntimeConfig] clientToken must not be null"); diff --git a/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java b/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java index 5ef6838a..209157f0 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java +++ b/Launcher/src/main/java/ru/gravit/launcher/managers/ConsoleManager.java @@ -1,5 +1,6 @@ package ru.gravit.launcher.managers; +import ru.gravit.launcher.Launcher; import ru.gravit.launcher.console.FeatureCommand; import ru.gravit.launcher.console.UnlockCommand; import ru.gravit.launcher.console.admin.ExecCommand; @@ -19,6 +20,9 @@ import ru.gravit.utils.helper.LogHelper; import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; public class ConsoleManager { public static CommandHandler handler; @@ -50,7 +54,7 @@ public static void registerCommands() { } public static boolean checkUnlockKey(String key) { - return true; + return key.equals(Launcher.getConfig().oemUnlockKey); } public static void unlock() { diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/AutogenConfig.java b/LauncherAPI/src/main/java/ru/gravit/launcher/AutogenConfig.java index dd00f048..355ba7be 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/AutogenConfig.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/AutogenConfig.java @@ -8,6 +8,7 @@ public class AutogenConfig { private boolean isInitModules; public String guardType; public String secretKeyClient; + public String oemUnlockKey; public String guardLicenseName; public String guardLicenseKey; public String guardLicenseEncryptKey; diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/LauncherConfig.java b/LauncherAPI/src/main/java/ru/gravit/launcher/LauncherConfig.java index 2f7a3b4a..6ce013de 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/LauncherConfig.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/LauncherConfig.java @@ -25,6 +25,7 @@ public static AutogenConfig getAutogenConfig() { public final String projectname; public final int clientPort; public String secretKeyClient; + public String oemUnlockKey; @LauncherAPI public final RSAPublicKey publicKey; @@ -45,6 +46,7 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException projectname = config.projectname; clientPort = config.clientPort; secretKeyClient = config.secretKeyClient; + oemUnlockKey = config.oemUnlockKey; isWarningMissArchJava = config.isWarningMissArchJava; guardLicenseEncryptKey = config.guardLicenseEncryptKey;