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;