From 554ca54c4a6d3215faade5bc6f45c6c12ea8108b Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Fri, 31 Jan 2020 19:07:33 +0100 Subject: [PATCH 1/5] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=B5=D1=80=D0=B5=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=20=D0=BD=D0=B0=20=D0=BD=D0=BE=D0=B2=D1=83=D1=8E=20?= =?UTF-8?q?=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=83=20props=20=D1=87?= =?UTF-8?q?=D0=B0=D1=81=D1=82=D1=8C=201=20(=D0=B1=D1=83=D0=B4=D0=B5=D1=82?= =?UTF-8?q?=20=D0=B5=D1=89=D1=91=20=D1=87=D0=B0=D1=81=D1=82=D1=8C=202).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/asm/ConfigGenerator.java | 84 ------------------- .../launchserver/asm/InjectClassAcceptor.java | 5 ++ .../launchserver/binary/BuildContext.java | 4 +- .../binary/LauncherConfigurator.java | 56 ------------- .../binary/tasks/MainBuildTask.java | 40 ++++----- .../launcher/ClientLauncherWrapper.java | 2 +- .../pro/gravit/launcher/LauncherEngine.java | 2 +- .../launcher/client/ClientLauncher.java | 2 +- .../pro/gravit/launcher/AutogenConfig.java | 26 ------ .../pro/gravit/launcher/LauncherConfig.java | 77 ++++++++++------- .../gravit/launcher/SecureAutogenConfig.java | 48 ----------- .../gravit/launcher/server/ServerWrapper.java | 1 - 12 files changed, 69 insertions(+), 278 deletions(-) delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/asm/ConfigGenerator.java delete mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/AutogenConfig.java delete mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ConfigGenerator.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ConfigGenerator.java deleted file mode 100644 index ab66442c..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ConfigGenerator.java +++ /dev/null @@ -1,84 +0,0 @@ -package pro.gravit.launchserver.asm; - -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.*; - -import java.util.Base64; -import java.util.List; - -public class ConfigGenerator { - protected static final String stringDesc = Type.getDescriptor(String.class); - protected static final String byteArrDesc = Type.getDescriptor(byte[].class); - protected static final String base64DecDesc = "(" + stringDesc + ")" + byteArrDesc; - protected final ClassNode configclass; - protected final MethodNode constructor; - - public ConfigGenerator(ClassNode configclass) { - this.configclass = configclass; - constructor = this.configclass.methods.stream().filter(e -> "".equals(e.name)).findFirst().get(); - constructor.instructions = new InsnList(); - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "", "()V")); - } - - public byte[] getBytecode(ClassMetadataReader reader) { - constructor.instructions.add(new InsnNode(Opcodes.RETURN)); - ClassWriter cw = new SafeClassWriter(reader, ClassWriter.COMPUTE_FRAMES); - configclass.accept(cw); - return cw.toByteArray(); - } - - public String getZipEntryPath() { - return configclass.name.concat(".class"); - } - - public void setStringField(String name, String value) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(NodeUtils.getSafeStringInsnList(value)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, configclass.name, name, stringDesc)); - } - - public void setByteArrayField(String name, byte[] value) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/util/Base64", "getDecoder", "()Ljava/util/Base64$Decoder;", false)); - constructor.instructions.add(NodeUtils.getSafeStringInsnList(Base64.getEncoder().encodeToString(value))); - constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/util/Base64$Decoder", "decode", base64DecDesc, false)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, configclass.name, name, stringDesc)); - } - - public void setByteArrayListField(String name, List b) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new TypeInsnNode(Opcodes.NEW, "java/util/ArrayList")); - constructor.instructions.add(new InsnNode(Opcodes.DUP)); // +1 - constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "java/util/ArrayList", "", "()V")); - for (byte[] value : b) { - constructor.instructions.add(new InsnNode(Opcodes.DUP)); // +1-1 - constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/util/Base64", "getDecoder", "()Ljava/util/Base64$Decoder;", false)); - constructor.instructions.add(NodeUtils.getSafeStringInsnList(Base64.getEncoder().encodeToString(value))); - constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/util/Base64$Decoder", "decode", base64DecDesc, false)); - constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true)); - constructor.instructions.add(new InsnNode(Opcodes.POP)); - } - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, configclass.name, name, "Ljava/util/List;")); - } - - public void setIntegerField(String name, int value) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(NodeUtils.push(value)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, configclass.name, name, Type.INT_TYPE.getInternalName())); - } - - public void setLongField(String name, long value) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new LdcInsnNode(value)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, configclass.name, name, Type.INT_TYPE.getInternalName())); - } - - public void setBooleanField(String name, boolean b) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new InsnNode(b ? Opcodes.ICONST_1 : Opcodes.ICONST_0)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, configclass.name, name, Type.BOOLEAN_TYPE.getInternalName())); - } -} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java index fcba7a13..fc384a91 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/InjectClassAcceptor.java @@ -123,6 +123,11 @@ public void visit(final String name, final Object value) { serializers.put(byte[].class, new ByteArraySerializer()); serializers.put(Short.class, serializerClass(Opcodes.I2S)); serializers.put(Byte.class, serializerClass(Opcodes.I2B)); + serializers.put(Type.class, (Serializer) e -> { // ow.Type == java.lang.Class in LDC + InsnList ret = new InsnList(); + ret.add(new LdcInsnNode(e)); + return ret; + }); serializers.put(Boolean.class, (Serializer) e -> { InsnList ret = new InsnList(); ret.add(new InsnNode(e ? Opcodes.ICONST_1 : Opcodes.ICONST_0)); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BuildContext.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BuildContext.java index 24692d17..e4d43c2f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BuildContext.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/BuildContext.java @@ -32,7 +32,6 @@ public class BuildContext { public final ZipOutputStream output; - public final LauncherConfigurator config; public final List readerClassPath; public final MainBuildTask task; public final HashSet fileList; @@ -78,9 +77,8 @@ private ZipEntry newEntry(String fileName) { } - public BuildContext(ZipOutputStream output, LauncherConfigurator config, List readerClassPath, MainBuildTask task) { + public BuildContext(ZipOutputStream output, List readerClassPath, MainBuildTask task) { this.output = output; - this.config = config; this.readerClassPath = readerClassPath; this.task = task; fileList = new HashSet<>(1024); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java deleted file mode 100644 index c09684a2..00000000 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java +++ /dev/null @@ -1,56 +0,0 @@ -package pro.gravit.launchserver.binary; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.*; -import pro.gravit.launcher.LauncherConfig; -import pro.gravit.launcher.modules.LauncherModule; -import pro.gravit.launchserver.asm.ClassMetadataReader; -import pro.gravit.launchserver.asm.ConfigGenerator; - -public class LauncherConfigurator extends ConfigGenerator { - private static final String modulesManagerName = "pro/gravit/launcher/modules/LauncherModulesManager"; - private static final String launcherName = "pro/gravit/launcher/LauncherEngine"; - private static final String modulesManagerDesc = "Lpro/gravit/launcher/client/ClientModuleManager;"; - private static final String registerModDesc = Type.getMethodDescriptor(Type.getType(LauncherModule.class), Type.getType(LauncherModule.class)); - private final MethodNode initModuleMethod; - - public LauncherConfigurator(ClassNode configclass) { - super(configclass); - initModuleMethod = configclass.methods.stream().filter(e -> "initModules".equals(e.name)).findFirst().get(); - initModuleMethod.instructions = new InsnList(); - } - - public void addModuleClass(String fullName) { - initModuleMethod.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, launcherName, "modulesManager", modulesManagerDesc)); - initModuleMethod.instructions.add(new TypeInsnNode(Opcodes.NEW, fullName.replace('.', '/'))); - initModuleMethod.instructions.add(new InsnNode(Opcodes.DUP)); - initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, fullName.replace('.', '/'), "", "()V")); - initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, modulesManagerName, "loadModule", registerModDesc)); - } - - @Override - public byte[] getBytecode(ClassMetadataReader reader) { - initModuleMethod.instructions.add(new InsnNode(Opcodes.RETURN)); - return super.getBytecode(reader); - } - - public void setEnv(LauncherConfig.LauncherEnvironment env) { - int i = 2; - switch (env) { - case DEV: - i = 0; - break; - case DEBUG: - i = 1; - break; - case STD: - i = 2; - break; - case PROD: - i = 3; - break; - } - setIntegerField("env", i); - } -} 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 41c66644..81bba9cd 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 @@ -5,17 +5,13 @@ import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.FieldNode; -import pro.gravit.launcher.AutogenConfig; import pro.gravit.launcher.Launcher; import pro.gravit.launcher.LauncherConfig; -import pro.gravit.launcher.SecureAutogenConfig; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.asm.ClassMetadataReader; -import pro.gravit.launchserver.asm.ConfigGenerator; import pro.gravit.launchserver.asm.InjectClassAcceptor; import pro.gravit.launchserver.asm.SafeClassWriter; import pro.gravit.launchserver.binary.BuildContext; -import pro.gravit.launchserver.binary.LauncherConfigurator; import pro.gravit.utils.HookException; import pro.gravit.utils.helper.IOHelper; import pro.gravit.utils.helper.JarHelper; @@ -137,22 +133,17 @@ public String getName() { public Path process(Path inputJar) throws IOException { Path outputJar = server.launcherBinary.nextPath("main"); try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(outputJar))) { - ClassNode cn = new ClassNode(); - new ClassReader(JarHelper.getClassBytes(AutogenConfig.class)).accept(cn, 0); - LauncherConfigurator launcherConfigurator = new LauncherConfigurator(cn); - ClassNode cn1 = new ClassNode(); - new ClassReader(JarHelper.getClassBytes(SecureAutogenConfig.class)).accept(cn1, 0); - ConfigGenerator secureConfigurator = new ConfigGenerator(cn1); - BuildContext context = new BuildContext(output, launcherConfigurator, reader.getCp(), this); + BuildContext context = new BuildContext(output, reader.getCp(), this); preBuildHook.hook(context); - launcherConfigurator.setStringField("address", server.config.netty.address); - launcherConfigurator.setStringField("projectname", server.config.projectName); - launcherConfigurator.setStringField("secretKeyClient", SecurityHelper.randomStringAESKey()); - launcherConfigurator.setIntegerField("clientPort", 32148 + SecurityHelper.newRandom().nextInt(512)); - launcherConfigurator.setStringField("guardType", server.config.launcher.guardType); - launcherConfigurator.setBooleanField("isWarningMissArchJava", server.config.launcher.warningMissArchJava); - launcherConfigurator.setEnv(server.config.env); - launcherConfigurator.setStringField("passwordEncryptKey", server.runtime.passwordEncryptKey); + properties.clear(); + properties.put("launcher.address", server.config.netty.address); + 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("launcher.isWarningMissArchJava", server.config.launcher.warningMissArchJava); + properties.put("launchercore.env" ,server.config.env); + properties.put("runtimeconfig.passwordEncryptKey", server.runtime.passwordEncryptKey); List certificates = Arrays.stream(server.certificateManager.trustManager.getTrusted()).map(e -> { try { return e.getEncoded(); @@ -170,15 +161,15 @@ public Path process(Path inputJar) throws IOException { throw new InternalError(e); } } - secureConfigurator.setByteArrayListField("certificates", certificates); + properties.put("launchercore.certificates", certificates); String launcherSalt = SecurityHelper.randomStringToken(); byte[] launcherSecureHash = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA256, server.runtime.clientCheckSecret.concat(".").concat(launcherSalt)); - launcherConfigurator.setStringField("secureCheckHash", Base64.getEncoder().encodeToString(launcherSecureHash)); - launcherConfigurator.setStringField("secureCheckSalt", launcherSalt); + properties.put("runtimeconfig.secureCheckHash", Base64.getEncoder().encodeToString(launcherSecureHash)); + properties.put("runtimeconfig.secureCheckSalt", launcherSalt); //LogHelper.debug("[checkSecure] %s: %s", launcherSalt, Arrays.toString(launcherSecureHash)); if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken(); - launcherConfigurator.setStringField("oemUnlockKey", server.runtime.oemUnlockKey); + properties.put("runtimeconfig.oemUnlockKey", server.runtime.oemUnlockKey); context.clientModules.forEach(launcherConfigurator::addModuleClass); reader.getCp().add(new JarFile(inputJar.toFile())); server.launcherBinary.coreLibs.forEach(e -> { @@ -188,9 +179,6 @@ public Path process(Path inputJar) throws IOException { LogHelper.error(e1); } }); - context.pushBytes(launcherConfigurator.getZipEntryPath(), launcherConfigurator.getBytecode(reader)); - context.pushBytes(secureConfigurator.getZipEntryPath(), secureConfigurator.getBytecode(reader)); - context.pushJarFile(inputJar, (e) -> blacklist.contains(e.getName()), (e) -> true); // map for guard diff --git a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java index 36781176..dbe125ce 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java @@ -31,7 +31,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep EnvHelper.checkDangerousParams(); LauncherConfig config = Launcher.getConfig(); LauncherEngine.modulesManager = new ClientModuleManager(); - LauncherConfig.getAutogenConfig().initModules(); + LauncherConfig.initModules(); LogHelper.info("Launcher for project %s", config.projectName); if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java index e9c9a0e8..e468542f 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java @@ -80,7 +80,7 @@ public static void main(String... args) throws Throwable { LauncherEngine.checkClass(LauncherAgent.class); LauncherEngine.checkClass(ClientLauncher.class); LauncherEngine.modulesManager = new ClientModuleManager(); - LauncherConfig.getAutogenConfig().initModules(); + LauncherConfig.initModules(); LauncherEngine.modulesManager.initModules(null); // Start Launcher initGson(LauncherEngine.modulesManager); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java index cd2f642e..ecb96566 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java @@ -443,7 +443,7 @@ public static void main(String... args) throws Throwable { LauncherEngine.checkClass(LauncherAgent.class); LauncherEngine.checkClass(ClientLauncher.class); LauncherEngine.modulesManager = new ClientModuleManager(); - LauncherConfig.getAutogenConfig().initModules(); //INIT + LauncherConfig.initModules(); //INIT LauncherEngine.modulesManager.initModules(null); initGson(LauncherEngine.modulesManager); LauncherEngine.verifyNoAgent(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/AutogenConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/AutogenConfig.java deleted file mode 100644 index da1d710c..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/AutogenConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package pro.gravit.launcher; - -public class AutogenConfig { - public String projectname; - public String address; - public int clientPort; - public String guardType; - public String secretKeyClient; - public String oemUnlockKey; - public String secureCheckHash; - public String secureCheckSalt; - public String passwordEncryptKey; - public int env; - public boolean isWarningMissArchJava; - // 0 - Dev (дебаг включен по умолчанию, все сообщения) - // 1 - Debug (дебаг включен по умолчанию, основные сообщения) - // 2 - Std (дебаг выключен по умолчанию, основные сообщения) - // 3 - Production (дебаг выключен, минимальный объем сообщений, stacktrace не выводится) - - AutogenConfig() { - } - - public void initModules() { - - } -} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java index a755e529..33219b4c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java @@ -13,20 +13,19 @@ import java.util.*; public final class LauncherConfig extends StreamObject { - private static final AutogenConfig config = new AutogenConfig(); - private static final SecureAutogenConfig secureConfig = new SecureAutogenConfig(); - - - public static AutogenConfig getAutogenConfig() { - return config; - } - - // Instance - public String address; - + @LauncherInject("launchercore.env") + private static final int cenv = -1; + @LauncherInject("launchercore.certificates") + private static final List secureConfigCertificates = null; + @LauncherInject("launcher.address") + public String address; + @LauncherInject("launcher.projectName") public final String projectName; + @LauncherInject("launcher.port") public final int clientPort; + @LauncherInject("runtimeconfig.secretKeyClient") public String secretKeyClient; + @LauncherInject("runtimeconfig.oemUnlockKey") public String oemUnlockKey; public final LauncherTrustManager trustManager; @@ -34,40 +33,43 @@ public static AutogenConfig getAutogenConfig() { public final Map runtime; + @LauncherInject("launcher.isWarningMissArchJava") public final boolean isWarningMissArchJava; - public boolean isNettyEnabled; public LauncherEnvironment environment; - + @LauncherInject("launcher.guardType") public final String guardType; - + @LauncherInject("runtimeconfig.secureCheckHash") public final String secureCheckHash; + @LauncherInject("runtimeconfig.secureCheckSalt") public final String secureCheckSalt; + @LauncherInject("runtimeconfig.passwordEncryptKey") public final String passwordEncryptKey; - + @SuppressWarnings("unused") + @LauncherInjectionConstructor public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException { publicKey = SecurityHelper.toPublicECKey(input.readByteArray(SecurityHelper.CRYPTO_MAX_LENGTH)); - secureCheckHash = config.secureCheckHash; - secureCheckSalt = config.secureCheckSalt; - passwordEncryptKey = config.passwordEncryptKey; - projectName = config.projectname; - clientPort = config.clientPort; - secretKeyClient = config.secretKeyClient; - oemUnlockKey = config.oemUnlockKey; + secureCheckHash = null; + secureCheckSalt = null; + passwordEncryptKey = null; + projectName = null; + clientPort = -1; + secretKeyClient = null; + oemUnlockKey = null; try { - trustManager = new LauncherTrustManager(secureConfig.certificates); + trustManager = new LauncherTrustManager(secureConfigCertificates); } catch (CertificateException e) { throw new IOException(e); } - isWarningMissArchJava = config.isWarningMissArchJava; - guardType = config.guardType; - address = config.address; + isWarningMissArchJava = false; + guardType = null; + address = null; LauncherEnvironment env; - if (config.env == 0) env = LauncherEnvironment.DEV; - else if (config.env == 1) env = LauncherEnvironment.DEBUG; - else if (config.env == 2) env = LauncherEnvironment.STD; - else if (config.env == 3) env = LauncherEnvironment.PROD; + if (cenv == 0) env = LauncherEnvironment.DEV; + else if (cenv == 1) env = LauncherEnvironment.DEBUG; + else if (cenv == 2) env = LauncherEnvironment.STD; + else if (cenv == 3) env = LauncherEnvironment.PROD; else env = LauncherEnvironment.STD; Launcher.applyLauncherEnv(env); environment = env; @@ -92,7 +94,6 @@ public LauncherConfig(String address, ECPublicKey publicKey, Map this.clientPort = 32148; guardType = "no"; isWarningMissArchJava = true; - isNettyEnabled = false; environment = LauncherEnvironment.STD; secureCheckSalt = null; secureCheckHash = null; @@ -116,4 +117,18 @@ public void write(HOutput output) throws IOException { public enum LauncherEnvironment { DEV, DEBUG, STD, PROD } + + public static void initModules() { + // TODO Fill + /* + * Old filler + public void addModuleClass(String fullName) { + initModuleMethod.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, launcherName, "modulesManager", modulesManagerDesc)); + initModuleMethod.instructions.add(new TypeInsnNode(Opcodes.NEW, fullName.replace('.', '/'))); + initModuleMethod.instructions.add(new InsnNode(Opcodes.DUP)); + initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, fullName.replace('.', '/'), "", "()V")); + initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, modulesManagerName, "loadModule", registerModDesc)); + } + */ + } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java deleted file mode 100644 index fc34057b..00000000 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -package pro.gravit.launcher; - -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.List; - -public class SecureAutogenConfig { - public static final Charset KEY_CHARSET = StandardCharsets.US_ASCII; // ? Какая из них, но выбрать надо однозачно проверить методом тыка!!! - public final List certificates; - - public SecureAutogenConfig() { - //Пока не реализован SecureLauncherConfigurator - certificates = null;/*Arrays.asList( - ("-----BEGIN CERTIFICATE-----\n" + - "MIIFyjCCA7KgAwIBAgIRALnsjNjfvOTXfla3fX1fNEUwDQYJKoZIhvcNAQELBQAw\n" + - "WTELMAkGA1UEBhMCUlUxFzAVBgNVBAoTDkdyYXZpdFRydXN0IENBMRAwDgYDVQQL\n" + - "EwdSb290IENBMR8wHQYDVQQDExZHcmF2aXQgQ2VudHJhbCBSb290IENBMCAXDTE5\n" + - "MDYwOTAyNDIwMFoYDzIwNTEwNjA5MDI0MjAwWjBZMQswCQYDVQQGEwJSVTEXMBUG\n" + - "A1UEChMOR3Jhdml0VHJ1c3QgQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHzAdBgNVBAMT\n" + - "FkdyYXZpdCBDZW50cmFsIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n" + - "ggIKAoICAQDA3Qm9OH8Xz3YM3bKkZuQI7T/aL3ulMOdY5GFADYgHrOVZXVSJi/4P\n" + - "PruBsut4WXN6TGQdpJtNZ2kyWTYzENGTm/TMzBcIchor1M3JW5Uv/C0r5gSEU1uP\n" + - "DPe7oEpeKtb3FXML/pGoGpLv/sonTKky4AKZnK7B15bZ+oVZNwh7UKANpNrVA8k5\n" + - "0gb4BisFcegLidYL9Y00H1x5WzUxldQAA1IQuwdkL3NP0NPQrSVJ2Ka2EtebE2HP\n" + - "fXHtbftvvnvSWyh4CXAxTfEmJgut0gSPQPm9wVt6pIWWd4O0hHwVmxkKQidgnP6A\n" + - "+d05FnJGsBw0ztMCifIteqNiHF0D8E0GuSz6NtcuV47J3p43qkvKr2vPc8o6WMN8\n" + - "PAb0eVHc/AX8qqOwYQyHlj4M0SDhCltHeeYRWmuZmRFIIelv6VAocaQLlPQrhJNp\n" + - "feIzmXLy60a+84vpe/eQKQx+D8a1elarQkoHMxI7x/9AJvxcnJ4KuXc2rkiu3Zv9\n" + - "KMhixtkLc+pA6jY023U211v+c20RjTqwKIZoMFc7BZipoinAOn1bdsTzXlhOMv1O\n" + - "zj5WoW6DsQQONMZNyLQAkaX6SYZE/kQVJ9YMPhNdaXjxxzfrY05IrWAaWhtPbW8z\n" + - "5nb4/JyO+bJq3v2rav9p03s8P/lQ4k/0af5vOkGkEO0+YKx97ZP8FQIDAQABo4GK\n" + - "MIGHMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFjMGCvHXAE/vGJih+Lfdo2s\n" + - "YnzsMAsGA1UdDwQEAwIBBjA1BgNVHR8ELjAsMCqgKKAmhiRodHRwOi8vY2EuZ3Jh\n" + - "dml0LnByby9jZW50cmFscm9vdC5jcmwwEQYJYIZIAYb4QgEBBAQDAgAHMA0GCSqG\n" + - "SIb3DQEBCwUAA4ICAQAexCGpThx85skEllva1UskmdlRh3rud9u59AUiwNZF0b0I\n" + - "+7eeyLNaLHarg2Zm30TSCF53ksyPTE5QNdmozs1fl3MddFqunkbUm4G6hwedZMSi\n" + - "4IXIb2QK3z3gZG5ZNdHaDG2u00Jdkc39h3jQFp1rpn4+0DcnYJAe+lw5G+XHURY2\n" + - "j15wcmUFp/Ywgw3pfCWmH5+rxq21e/LG8JiQrxekkFI2GUD+Qw7+Hq3o1Fgg3kfh\n" + - "Lg4B5WEbEICQ1FC+dHYHasEI3q3c96Qpqu2k3pO0l1fr6Cys+AGjoI2WrgXkGlmA\n" + - "F+Wi2ndoZbvspGAwxmrNMtLE3OYNuMXFF410QSPf4o9QqpGDC3a2mccTXb231a18\n" + - "5vDJixeZpuzEm5ECXg8j6aj53X3rtm7C8yfOsg5UTKJJj+pSNz4YTp91IDHm0nTP\n" + - "2KhrgS7jujgKdJn9xv07e/API3kLWkVmMwHBiaSCIaHOfAN0RJMQVV+YgnSp2sIa\n" + - "OATWgSKH0qTkleE/v7k+USs0a+KV8wmC5wwliqH+uLO++yIP/9bjDctyLulQX5Ee\n" + - "+EhD7tb1R/yyWY4uhkzlsr3N2Kl34aQAEBMn8Z1mHsyyu1FcbEaNLU8jcS3pHPVM\n" + - "gQRn3m1iDnQlFciAMxW0pW6mW/4xKYzhXk5BTSolnqMVylxHgWXuBwdDDQQVnQ==\n" + - "-----END CERTIFICATE-----").getBytes(KEY_CHARSET));*/ - } -} diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index a003ef25..6093920d 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -196,7 +196,6 @@ public void updateLauncherConfig() { if(IOHelper.isFile(publicKeyFile)) publicKey = SecurityHelper.toPublicECKey(IOHelper.read(publicKeyFile)); cfg = new LauncherConfig(config.address, publicKey, new HashMap<>(), config.projectname); - cfg.isNettyEnabled = true; cfg.address = config.address; } catch (InvalidKeySpecException | IOException e) { LogHelper.error(e); From 6b7468e36634dc2fd67a0b1eba735cf6472b6a6f Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Fri, 31 Jan 2020 19:21:24 +0100 Subject: [PATCH 2/5] =?UTF-8?q?[FEATURE]=20=D0=9E=D0=BA=D0=BE=D0=BD=D1=87?= =?UTF-8?q?=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20=D0=BD=D0=B0=20=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D1=83=D1=8E=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=83?= =?UTF-8?q?=20props=20(=D1=87=D0=B0=D1=81=D1=82=D1=8C=202).=20=D0=A1=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=BE=D0=BA=20props(=D1=82=D0=B5=D0=BA=D1=83=D1=89?= =?UTF-8?q?=D0=B8=D0=B9=20=D1=82=D0=B8=D0=BF=20=D0=B8=20=D0=B7=D0=BD=D0=B0?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B5):=20String=20launcher.projectNam?= =?UTF-8?q?e;=20//=20=D0=9D=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=B0=20String=20launcher.?= =?UTF-8?q?address;=20//=20=D0=90=D0=B4=D1=80=D0=B5=D1=81=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B5=D1=80=D0=B0=20int=20launcher.port;=20//=20?= =?UTF-8?q?=D0=9F=D0=BE=D1=80=D1=82=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=20(=D1=80=D0=B0=D0=BD=D0=B4=D0=BE=D0=BC)=20=D0=B8=D1=81?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D0=B5=D1=82=D1=81=D1=8F=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4=D0=B0=D1=87?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B0=20String=20?= =?UTF-8?q?launcher.guardType;=20//=20=D0=A2=D0=B8=D0=BF=20=D0=B7=D0=B0?= =?UTF-8?q?=D1=89=D0=B8=D1=82=D1=8B=20(java,=20wrapper,=20no=20=D0=B8=20?= =?UTF-8?q?=D1=82.=20=D0=B4.)=20String=20runtimeconfig.secretKeyClient;=20?= =?UTF-8?q?//=20=D0=A1=D0=B5=D0=BA=D1=80=D0=B5=D1=82=D0=BD=D1=8B=D0=B9=20?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87=20String=20runtimeconfig.oemUnlockKey;?= =?UTF-8?q?=20//=20=D0=9A=D0=BB=D1=8E=D1=87=20=D1=80=D0=B0=D0=B7=D0=B1?= =?UTF-8?q?=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=81=D0=BE=D0=BB=D0=B8=20=D0=B2=D0=B2=D0=BE=D0=B4?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=20=D0=B2=20=D0=BB?= =?UTF-8?q?=D0=B0=D1=83=D0=BD=D1=87=D0=B5=D1=80=D0=B5...=20String=20runtim?= =?UTF-8?q?econfig.secureCheckHash;=20//=20=D0=9F=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BA=D0=B8=20=D0=B1=D0=B5=D0=B7=D0=BE=D0=BF=D0=B0=D1=81?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=BB=D0=B0=D1=83=D0=BD=D1=87?= =?UTF-8?q?=D0=B5=D1=80=D0=B0=20(=D1=85=D0=B5=D1=88)=20String=20runtimecon?= =?UTF-8?q?fig.secureCheckSalt;=20//=20=D0=AD=D1=82=D0=BE=20=D0=B6=D0=B5?= =?UTF-8?q?=20=D0=BD=D0=BE=20=D1=81=D0=BE=D0=BB=D1=8C...=20String=20runtim?= =?UTF-8?q?econfig.passwordEncryptKey;=20//=20=D0=9A=D0=BB=D1=8E=D1=87=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=88=D0=B8=D1=84=D1=80=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8F...=20int=20launch?= =?UTF-8?q?ercore.env;=20//=20=D0=A1=D1=80=D0=B5=D0=B4=D0=B0=20=D0=BB?= =?UTF-8?q?=D0=B0=D1=83=D0=BD=D1=87=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=20(0=3DDEV,1=3DDEBUG,2=3DSTD,3=3DPROD,=20=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B5=20=3D=20=D1=82=D0=B0?= =?UTF-8?q?=D0=BA=20=D0=B6=D0=B5=20STD)=20boolean=20launcher.isWarningMiss?= =?UTF-8?q?ArchJava;=20//=20=D0=92=D1=8B=D0=B2=D0=BE=D0=B4=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BB=D0=B8=20=D0=BF=D1=80=D0=B5=D0=B4=D1=83=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=20os.?= =?UTF-8?q?bits!=3D=20java.bits=20List=20launchercore.certificates?= =?UTF-8?q?;=20//=20EC-=D1=81=D0=B5=D1=80=D1=82=D0=B8=D1=84=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D1=82=D1=8B=20=D0=B2=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=20byte[]=20List>=20launcher.modules;=20?= =?UTF-8?q?//=20=D0=A1=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D0=BE=D0=B2=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B5?= =?UTF-8?q?=D0=B9=20=D0=BB=D0=B0=D1=83=D0=BD=D1=87=D0=B5=D1=80=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/tasks/MainBuildTask.java | 4 +-- .../launcher/ClientLauncherWrapper.java | 2 +- .../pro/gravit/launcher/LauncherEngine.java | 2 +- .../launcher/client/ClientLauncher.java | 2 +- .../pro/gravit/launcher/LauncherConfig.java | 30 +++++++++++-------- 5 files changed, 23 insertions(+), 17 deletions(-) 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 81bba9cd..14c71088 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 @@ -2,6 +2,7 @@ import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Type; import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.FieldNode; @@ -14,7 +15,6 @@ import pro.gravit.launchserver.binary.BuildContext; import pro.gravit.utils.HookException; import pro.gravit.utils.helper.IOHelper; -import pro.gravit.utils.helper.JarHelper; import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.SecurityHelper; @@ -170,7 +170,7 @@ public Path process(Path inputJar) throws IOException { //LogHelper.debug("[checkSecure] %s: %s", launcherSalt, Arrays.toString(launcherSecureHash)); if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken(); properties.put("runtimeconfig.oemUnlockKey", server.runtime.oemUnlockKey); - context.clientModules.forEach(launcherConfigurator::addModuleClass); + properties.put("launcher.modules", context.clientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList())); reader.getCp().add(new JarFile(inputJar.toFile())); server.launcherBinary.coreLibs.forEach(e -> { try { diff --git a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java index dbe125ce..1ea56772 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java @@ -31,7 +31,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep EnvHelper.checkDangerousParams(); LauncherConfig config = Launcher.getConfig(); LauncherEngine.modulesManager = new ClientModuleManager(); - LauncherConfig.initModules(); + LauncherConfig.initModules(LauncherEngine.modulesManager); LogHelper.info("Launcher for project %s", config.projectName); if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java index e468542f..301cd7b1 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java @@ -80,7 +80,7 @@ public static void main(String... args) throws Throwable { LauncherEngine.checkClass(LauncherAgent.class); LauncherEngine.checkClass(ClientLauncher.class); LauncherEngine.modulesManager = new ClientModuleManager(); - LauncherConfig.initModules(); + LauncherConfig.initModules(LauncherEngine.modulesManager); LauncherEngine.modulesManager.initModules(null); // Start Launcher initGson(LauncherEngine.modulesManager); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java index ecb96566..db685b77 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java @@ -443,7 +443,7 @@ public static void main(String... args) throws Throwable { LauncherEngine.checkClass(LauncherAgent.class); LauncherEngine.checkClass(ClientLauncher.class); LauncherEngine.modulesManager = new ClientModuleManager(); - LauncherConfig.initModules(); //INIT + LauncherConfig.initModules(LauncherEngine.modulesManager); //INIT LauncherEngine.modulesManager.initModules(null); initGson(LauncherEngine.modulesManager); LauncherEngine.verifyNoAgent(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java index 33219b4c..906fccb8 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java @@ -1,12 +1,17 @@ package pro.gravit.launcher; +import pro.gravit.launcher.modules.LauncherModule; +import pro.gravit.launcher.modules.LauncherModulesManager; import pro.gravit.launcher.serialize.HInput; import pro.gravit.launcher.serialize.HOutput; import pro.gravit.launcher.serialize.stream.StreamObject; +import pro.gravit.utils.helper.LogHelper; import pro.gravit.utils.helper.SecurityHelper; import pro.gravit.utils.helper.VerifyHelper; import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.security.cert.CertificateException; import java.security.interfaces.ECPublicKey; import java.security.spec.InvalidKeySpecException; @@ -17,6 +22,8 @@ public final class LauncherConfig extends StreamObject { private static final int cenv = -1; @LauncherInject("launchercore.certificates") private static final List secureConfigCertificates = null; + @LauncherInject("launcher.modules") + private static final List> modulesClasses = null; @LauncherInject("launcher.address") public String address; @LauncherInject("launcher.projectName") @@ -118,17 +125,16 @@ public enum LauncherEnvironment { DEV, DEBUG, STD, PROD } - public static void initModules() { - // TODO Fill - /* - * Old filler - public void addModuleClass(String fullName) { - initModuleMethod.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, launcherName, "modulesManager", modulesManagerDesc)); - initModuleMethod.instructions.add(new TypeInsnNode(Opcodes.NEW, fullName.replace('.', '/'))); - initModuleMethod.instructions.add(new InsnNode(Opcodes.DUP)); - initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, fullName.replace('.', '/'), "", "()V")); - initModuleMethod.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, modulesManagerName, "loadModule", registerModDesc)); - } - */ + private static final MethodType VOID_TYPE = MethodType.methodType(void.class); + + public static void initModules(LauncherModulesManager modulesManager) { + for (Class clazz : modulesClasses) + try { + modulesManager.loadModule((LauncherModule) MethodHandles.publicLookup().findConstructor(clazz, VOID_TYPE).invokeWithArguments(Collections.emptyList())); + } catch (Throwable e) { + LogHelper.error(e); + } + // This method should be called once at exec time. + modulesClasses.clear(); } } From 2a7570b9b6f6bb247c13498ca24a96b746d99044 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Fri, 31 Jan 2020 19:27:06 +0100 Subject: [PATCH 3/5] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5?= =?UTF-8?q?=D1=80=D0=B6=D0=BA=D0=B0=201.15.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/defaults/profile1.15.2.cfg | 38 +++++++++++++++++++ .../launcher/profiles/ClientProfile.java | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/profile1.15.2.cfg diff --git a/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/profile1.15.2.cfg b/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/profile1.15.2.cfg new file mode 100644 index 00000000..d59a68be --- /dev/null +++ b/LaunchServer/src/main/resources/pro/gravit/launchserver/defaults/profile1.15.2.cfg @@ -0,0 +1,38 @@ +{ + "version": "1.15.2", + "assetIndex": "1.15.2", + "assetDir": "asset1.15.2", + "dir": "HiTech", + "info": "Информация о сервере", + "sortIndex": 0, + "title": "xxxxxxxx", + "serverAddress": "localhost", + "serverPort": 25565, + "update": [ + "servers.dat" + ], + "updateExclusions": [], + "updateShared": [], + "updateVerify": [ + "libraries", + "natives", + "minecraft.jar" + ], + "updateOptional": [], + "updateFastCheck": true, + "useWhitelist": false, + "mainClass": "net.minecraft.client.main.Main", + "jvmArgs": [ + "-XX:+UseConcMarkSweepGC", + "-XX:+CMSIncrementalMode", + "-XX:-UseAdaptiveSizePolicy", + "-Xmn128M", + "-XX:+DisableAttachMechanism" + ], + "classPath": [ + "minecraft.jar", + "libraries" + ], + "clientArgs": [], + "whitelist": [] +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java index 10a25fa2..9f78774f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/profiles/ClientProfile.java @@ -41,7 +41,8 @@ public enum Version { MC1143("1.14.3", 490), MC1144("1.14.4", 498), MC115("1.15", 573), - MC1151("1.15.1", 575); + MC1151("1.15.1", 575), + MC1152("1.15.2", 578); private static final Map VERSIONS; static { From ff5ed0eb27d0f6394ec8e6946f8e6b4bd9a83064 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Sat, 1 Feb 2020 06:30:04 +0100 Subject: [PATCH 4/5] =?UTF-8?q?[ANY]=20=D0=9D=D0=B5=D0=BC=D0=BD=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D0=BD=D0=B3=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/tasks/MainBuildTask.java | 81 ++++++++++--------- 1 file changed, 45 insertions(+), 36 deletions(-) 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 14c71088..f54d5f57 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 @@ -134,43 +134,10 @@ public Path process(Path inputJar) throws IOException { Path outputJar = server.launcherBinary.nextPath("main"); try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(outputJar))) { BuildContext context = new BuildContext(output, reader.getCp(), this); + initProps(); preBuildHook.hook(context); - properties.clear(); - properties.put("launcher.address", server.config.netty.address); - 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("launcher.isWarningMissArchJava", server.config.launcher.warningMissArchJava); - properties.put("launchercore.env" ,server.config.env); - properties.put("runtimeconfig.passwordEncryptKey", server.runtime.passwordEncryptKey); - List certificates = Arrays.stream(server.certificateManager.trustManager.getTrusted()).map(e -> { - try { - return e.getEncoded(); - } catch (CertificateEncodingException e2) { - LogHelper.error(e2); - return new byte[0]; - } - }).collect(Collectors.toList()); - if(!server.config.sign.enabled) - { - CertificateAutogenTask task = server.launcherBinary.getTaskByClass(CertificateAutogenTask.class).get(); - try { - certificates.add(task.certificate.getEncoded()); - } catch (CertificateEncodingException e) { - throw new InternalError(e); - } - } - properties.put("launchercore.certificates", certificates); - String launcherSalt = SecurityHelper.randomStringToken(); - byte[] launcherSecureHash = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA256, - server.runtime.clientCheckSecret.concat(".").concat(launcherSalt)); - properties.put("runtimeconfig.secureCheckHash", Base64.getEncoder().encodeToString(launcherSecureHash)); - properties.put("runtimeconfig.secureCheckSalt", launcherSalt); - //LogHelper.debug("[checkSecure] %s: %s", launcherSalt, Arrays.toString(launcherSecureHash)); - if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken(); - properties.put("runtimeconfig.oemUnlockKey", server.runtime.oemUnlockKey); properties.put("launcher.modules", context.clientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList())); + postInitProps(); reader.getCp().add(new JarFile(inputJar.toFile())); server.launcherBinary.coreLibs.forEach(e -> { try { @@ -195,7 +162,49 @@ public Path process(Path inputJar) throws IOException { return outputJar; } - public byte[] transformClass(byte[] bytes, String classname, BuildContext context) + protected void postInitProps() { + List certificates = Arrays.stream(server.certificateManager.trustManager.getTrusted()).map(e -> { + try { + return e.getEncoded(); + } catch (CertificateEncodingException e2) { + LogHelper.error(e2); + return new byte[0]; + } + }).collect(Collectors.toList()); + if(!server.config.sign.enabled) + { + CertificateAutogenTask task = server.launcherBinary.getTaskByClass(CertificateAutogenTask.class).get(); + try { + certificates.add(task.certificate.getEncoded()); + } catch (CertificateEncodingException e) { + throw new InternalError(e); + } + } + properties.put("launchercore.certificates", certificates); + } + + protected void initProps() { + properties.clear(); + properties.put("launcher.address", server.config.netty.address); + 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("launcher.isWarningMissArchJava", server.config.launcher.warningMissArchJava); + properties.put("launchercore.env" ,server.config.env); + properties.put("runtimeconfig.passwordEncryptKey", server.runtime.passwordEncryptKey); + String launcherSalt = SecurityHelper.randomStringToken(); + byte[] launcherSecureHash = SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA256, + server.runtime.clientCheckSecret.concat(".").concat(launcherSalt)); + properties.put("runtimeconfig.secureCheckHash", Base64.getEncoder().encodeToString(launcherSecureHash)); + properties.put("runtimeconfig.secureCheckSalt", launcherSalt); + //LogHelper.debug("[checkSecure] %s: %s", launcherSalt, Arrays.toString(launcherSecureHash)); + if (server.runtime.oemUnlockKey == null) server.runtime.oemUnlockKey = SecurityHelper.randomStringToken(); + properties.put("runtimeconfig.oemUnlockKey", server.runtime.oemUnlockKey); + + } + + public byte[] transformClass(byte[] bytes, String classname, BuildContext context) { byte[] result = bytes; ClassReader cr = null; From 01b25aa6d8891982e0574023f8ccaba69928aa72 Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Sat, 1 Feb 2020 06:42:41 +0100 Subject: [PATCH 5/5] =?UTF-8?q?[AMY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B8?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/binary/tasks/exe/Launch4JTask.java | 4 ---- modules | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/exe/Launch4JTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/exe/Launch4JTask.java index fbbb3c43..e636439a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/exe/Launch4JTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/exe/Launch4JTask.java @@ -27,13 +27,9 @@ public void clear() { } } - // URL constants public static final String DOWNLOAD_URL = "http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html"; // Oracle - // JRE 8 - // File constants private final Path faviconFile; - // File constants private final LaunchServer server; public Launch4JTask(LaunchServer launchServer) { diff --git a/modules b/modules index 5464417b..0fbc3fb2 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 5464417b18e27d7ae8ce91861e42f167e11b8215 +Subproject commit 0fbc3fb26c505800a61976cdf1310cad6ab7808d