Фикс обхода на основе глобальных переменных

This commit is contained in:
Gravit 2018-10-22 00:09:32 +07:00
parent d84193d5a4
commit 01fd6d2689
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 10 additions and 4 deletions

View file

@ -149,6 +149,7 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
public static void main(String... args) throws Throwable { public static void main(String... args) throws Throwable {
JVMHelper.verifySystemProperties(Launcher.class, true); JVMHelper.verifySystemProperties(Launcher.class, true);
EnvHelper.checkDangerousParametrs();
LogHelper.printVersion("Launcher"); LogHelper.printVersion("Launcher");
// Start Launcher // Start Launcher
Instant start = Instant.now(); Instant start = Instant.now();

View file

@ -415,6 +415,7 @@ public static void main(String... args) throws Throwable {
} }
checkJVMBitsAndVersion(); checkJVMBitsAndVersion();
JVMHelper.verifySystemProperties(ClientLauncher.class, true); JVMHelper.verifySystemProperties(ClientLauncher.class, true);
EnvHelper.checkDangerousParametrs();
LogHelper.printVersion("Client Launcher"); LogHelper.printVersion("Client Launcher");
// Read and delete params file // Read and delete params file
LogHelper.debug("Reading ClientLauncher params"); LogHelper.debug("Reading ClientLauncher params");

View file

@ -8,13 +8,10 @@
import ru.gravit.launcher.LauncherAPI; import ru.gravit.launcher.LauncherAPI;
@LauncherAPI
public class EnvHelper { public class EnvHelper {
private static final boolean TST; private static final boolean TST;
private static final boolean HASXM; private static final boolean HASXM;
@LauncherAPI
public static final String[] toTest; public static final String[] toTest;
@LauncherAPI
public static final Pattern[] test; public static final Pattern[] test;
static { static {
@ -24,7 +21,6 @@ public class EnvHelper {
HASXM = check1(); HASXM = check1();
} }
@LauncherAPI
public static void addEnv(ProcessBuilder builder) { public static void addEnv(ProcessBuilder builder) {
if (hasOptsVar()) { if (hasOptsVar()) {
Map<String, String> repl = new HashMap<>(); Map<String, String> repl = new HashMap<>();
@ -35,6 +31,14 @@ public static void addEnv(ProcessBuilder builder) {
JVMHelper.appendVars(builder, repl); 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() { private static boolean check0() {
for (String test : toTest) if (System.getProperty(test) != null) return true; for (String test : toTest) if (System.getProperty(test) != null) return true;