From 8ba00d106e334224aa6604e8f6837295978c205a Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Sat, 19 Oct 2019 06:53:13 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B6=D0=BA=D0=B0=20=D0=B2=20ConfigGenerator=20List?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/asm/ConfigGenerator.java | 19 +++++++++++++++++++ .../gravit/launcher/SecureAutogenConfig.java | 5 ++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ConfigGenerator.java b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ConfigGenerator.java index fbd3f77e..809f536e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ConfigGenerator.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/asm/ConfigGenerator.java @@ -1,6 +1,7 @@ package pro.gravit.launchserver.asm; import java.util.Base64; +import java.util.List; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; @@ -12,6 +13,7 @@ import org.objectweb.asm.tree.LdcInsnNode; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; +import org.objectweb.asm.tree.TypeInsnNode; import org.objectweb.asm.tree.VarInsnNode; public class ConfigGenerator { @@ -55,6 +57,23 @@ public void setByteArrayField(String name, byte[] value) constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "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)); + constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "java/util/ArrayList", "", "()V")); + for (byte[] value : b) { + constructor.instructions.add(new InsnNode(Opcodes.DUP)); + 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.INVOKESTATIC, "java/util/Base64$Decoder", "decode", base64DecDesc, false)); + constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", false)); + 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) { diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java index 2d971a4e..b72e5cb9 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/SecureAutogenConfig.java @@ -1,5 +1,7 @@ package pro.gravit.launcher; +import java.nio.charset.StandardCharsets; + public class SecureAutogenConfig { public byte[][] certificates; @@ -38,7 +40,8 @@ public SecureAutogenConfig() { "OATWgSKH0qTkleE/v7k+USs0a+KV8wmC5wwliqH+uLO++yIP/9bjDctyLulQX5Ee\n" + "+EhD7tb1R/yyWY4uhkzlsr3N2Kl34aQAEBMn8Z1mHsyyu1FcbEaNLU8jcS3pHPVM\n" + "gQRn3m1iDnQlFciAMxW0pW6mW/4xKYzhXk5BTSolnqMVylxHgWXuBwdDDQQVnQ==\n" + - "-----END CERTIFICATE-----").getBytes() + "-----END CERTIFICATE-----").getBytes(StandardCharsets.US_ASCII) + // ? Какая из них, но выбрать надо однозачно }; } }