mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Экспериментальная защита на основе StackTrace
This commit is contained in:
parent
4e75894438
commit
761ddc3087
4 changed files with 12 additions and 0 deletions
|
@ -263,6 +263,7 @@ private SignConf(BlockConfigEntry block, Path coredir) {
|
|||
}
|
||||
|
||||
public static void main(String... args) throws Throwable {
|
||||
JVMHelper.checkStackTrace(LaunchServer.class);
|
||||
JVMHelper.verifySystemProperties(LaunchServer.class, true);
|
||||
LogHelper.addOutput(IOHelper.WORKING_DIR.resolve("LaunchServer.log"));
|
||||
LogHelper.printVersion("LaunchServer");
|
||||
|
|
|
@ -148,6 +148,7 @@ public static void addLauncherClassBindings(Map<String, Object> bindings) {
|
|||
}
|
||||
|
||||
public static void main(String... args) throws Throwable {
|
||||
JVMHelper.checkStackTrace(LauncherEngine.class);
|
||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||
EnvHelper.checkDangerousParametrs();
|
||||
LogHelper.printVersion("Launcher");
|
||||
|
|
|
@ -416,6 +416,7 @@ public static void main(String... args) throws Throwable {
|
|||
checkJVMBitsAndVersion();
|
||||
JVMHelper.verifySystemProperties(ClientLauncher.class, true);
|
||||
EnvHelper.checkDangerousParametrs();
|
||||
JVMHelper.checkStackTrace(ClientLauncher.class);
|
||||
LogHelper.printVersion("Client Launcher");
|
||||
// Read and delete params file
|
||||
LogHelper.debug("Reading ClientLauncher params");
|
||||
|
|
|
@ -134,6 +134,15 @@ public static URL[] getClassPathURL() {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
public static void checkStackTrace(Class mainClass)
|
||||
{
|
||||
Exception e = new Exception("Testing stacktrace");
|
||||
StackTraceElement[] list = e.getStackTrace();
|
||||
if(!list[list.length - 1].getClassName().equals(mainClass.getName()))
|
||||
{
|
||||
throw new SecurityException(String.format("Invalid StackTraceElement: %s",list[0].getClassName()));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("CallToSystemGetenv")
|
||||
private static int getCorrectOSArch() {
|
||||
|
|
Loading…
Reference in a new issue