From 01fd6d2689f13b539216cbcaedbad0a3211ad6b3 Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 22 Oct 2018 00:09:32 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BE=D0=B1=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=20=D0=BD=D0=B0=20=D0=BE=D1=81=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=20=D0=B3=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launcher/LauncherEngine.java | 1 + .../ru/gravit/launcher/client/ClientLauncher.java | 1 + .../main/java/ru/gravit/utils/helper/EnvHelper.java | 12 ++++++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java index 7b882b73..40a033bd 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/ru/gravit/launcher/LauncherEngine.java @@ -149,6 +149,7 @@ public static void addLauncherClassBindings(Map bindings) { public static void main(String... args) throws Throwable { JVMHelper.verifySystemProperties(Launcher.class, true); + EnvHelper.checkDangerousParametrs(); LogHelper.printVersion("Launcher"); // Start Launcher Instant start = Instant.now(); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index 044653ab..d00431ac 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -415,6 +415,7 @@ public static void main(String... args) throws Throwable { } checkJVMBitsAndVersion(); JVMHelper.verifySystemProperties(ClientLauncher.class, true); + EnvHelper.checkDangerousParametrs(); LogHelper.printVersion("Client Launcher"); // Read and delete params file LogHelper.debug("Reading ClientLauncher params"); diff --git a/libLauncher/src/main/java/ru/gravit/utils/helper/EnvHelper.java b/libLauncher/src/main/java/ru/gravit/utils/helper/EnvHelper.java index 7e0406fe..057d799a 100644 --- a/libLauncher/src/main/java/ru/gravit/utils/helper/EnvHelper.java +++ b/libLauncher/src/main/java/ru/gravit/utils/helper/EnvHelper.java @@ -8,13 +8,10 @@ import ru.gravit.launcher.LauncherAPI; -@LauncherAPI public class EnvHelper { private static final boolean TST; private static final boolean HASXM; - @LauncherAPI public static final String[] toTest; - @LauncherAPI public static final Pattern[] test; static { @@ -24,7 +21,6 @@ public class EnvHelper { HASXM = check1(); } - @LauncherAPI public static void addEnv(ProcessBuilder builder) { if (hasOptsVar()) { Map repl = new HashMap<>(); @@ -35,6 +31,14 @@ public static void addEnv(ProcessBuilder builder) { JVMHelper.appendVars(builder, repl); } } + public static void checkDangerousParametrs() + { + for(String t : toTest) + { + String env = System.getenv(t); + if(env.contains("-javaagent") || env.contains("-agentpath") || env.contains("-agentlib")) throw new SecurityException("JavaAgent in global optings not allow"); + } + } private static boolean check0() { for (String test : toTest) if (System.getProperty(test) != null) return true;