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 79959151..dee3cd85 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncher.java @@ -442,6 +442,7 @@ public static void main(String... args) throws Throwable { EnvHelper.checkDangerousParams(); JVMHelper.checkStackTrace(ClientLauncher.class); LogHelper.printVersion("Client Launcher"); + System.setSecurityManager(new ClientSecurityManager()); engine.readKeys(); HWIDProvider.registerHWIDs(); LauncherGuardManager.initGuard(true); diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientSecurityManager.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientSecurityManager.java new file mode 100644 index 00000000..28b4ab01 --- /dev/null +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientSecurityManager.java @@ -0,0 +1,29 @@ +package pro.gravit.launcher.client; + +import java.security.Permission; + +public class ClientSecurityManager extends SecurityManager { + @Override + public void checkPermission(Permission perm) + { + String permName = perm.getName(); + if(permName == null) return; + if (permName.startsWith("exitVM")) + { + Class[] classContexts = getClassContext(); + String callingClass = classContexts.length > 3 ? classContexts[4].getName() : "none"; + if (!(callingClass.startsWith("pro.gravit."))) + { + throw new ExitTrappedException(); + } + } + } + + @Override + public void checkPermission(Permission perm, Object context) { + } + + public static class ExitTrappedException extends SecurityException { + + } +}