From ca694601dfbf4c4c8af90f5555b6c1acd9316b85 Mon Sep 17 00:00:00 2001 From: Alexey <24605601+typicalcoder@users.noreply.github.com> Date: Sun, 5 Apr 2020 17:47:21 +0300 Subject: [PATCH 1/6] [FIX] Permissions --- .../src/main/java/pro/gravit/launcher/ClientPermissions.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java index 5bb005d1..43a08176 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/ClientPermissions.java @@ -8,7 +8,9 @@ public class ClientPermissions { public static final ClientPermissions DEFAULT = new ClientPermissions(); + @LauncherNetworkAPI public long permissions; + @LauncherNetworkAPI public long flags; public enum PermissionConsts { From 5c5240a2f3866d788a46a328d366da07b8a0e68a Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 7 Apr 2020 18:10:34 +0700 Subject: [PATCH 2/6] =?UTF-8?q?[FEATURE]=20HWID=20=D0=B2=D0=BE=D0=B7=D0=B2?= =?UTF-8?q?=D1=80=D0=B0=D1=89=D0=B0=D0=B5=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/socket/WebSocketService.java | 2 + .../secure/HardwareReportResponse.java | 20 +++++ .../gravit/launcher/utils/HWIDProvider.java | 81 +++++++++++++++++++ .../request/HardwareReportRequestEvent.java | 10 +++ .../request/secure/HardwareReportRequest.java | 22 +++++ .../websockets/ClientWebSocketService.java | 1 + 6 files changed, 136 insertions(+) create mode 100644 LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java create mode 100644 Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java create mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/events/request/HardwareReportRequestEvent.java create mode 100644 LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java index 00b1b1b7..6f0908f1 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/WebSocketService.java @@ -22,6 +22,7 @@ import pro.gravit.launchserver.socket.response.profile.ProfileByUUIDResponse; import pro.gravit.launchserver.socket.response.profile.ProfileByUsername; import pro.gravit.launchserver.socket.response.secure.GetSecureLevelInfoResponse; +import pro.gravit.launchserver.socket.response.secure.HardwareReportResponse; import pro.gravit.launchserver.socket.response.secure.SecurityReportResponse; import pro.gravit.launchserver.socket.response.secure.VerifySecureLevelKeyResponse; import pro.gravit.launchserver.socket.response.update.LauncherResponse; @@ -131,6 +132,7 @@ public static void registerResponses() { providers.register("getSecureLevelInfo", GetSecureLevelInfoResponse.class); providers.register("verifySecureLevelKey", VerifySecureLevelKeyResponse.class); providers.register("securityReport", SecurityReportResponse.class); + providers.register("hardwareReport", HardwareReportResponse.class); } public void sendObject(ChannelHandlerContext ctx, Object obj) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java new file mode 100644 index 00000000..83b87337 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java @@ -0,0 +1,20 @@ +package pro.gravit.launchserver.socket.response.secure; + +import io.netty.channel.ChannelHandlerContext; +import pro.gravit.launchserver.socket.Client; +import pro.gravit.launchserver.socket.response.SimpleResponse; + +public class HardwareReportResponse extends SimpleResponse { + public String pathToJava; + public String javaVersion; + + @Override + public String getType() { + return "hardwareReport"; + } + + @Override + public void execute(ChannelHandlerContext ctx, Client client) throws Exception { + + } +} diff --git a/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java new file mode 100644 index 00000000..3f8aa00d --- /dev/null +++ b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java @@ -0,0 +1,81 @@ +package pro.gravit.launcher.utils; + +import oshi.SystemInfo; +import oshi.hardware.HWDiskStore; +import oshi.hardware.HardwareAbstractionLayer; +import oshi.hardware.PowerSource; +import oshi.software.os.OperatingSystem; +import pro.gravit.launcher.request.secure.HardwareReportRequest; + +public class HWIDProvider { + public SystemInfo systemInfo; + public OperatingSystem system; + public HardwareAbstractionLayer hardware; + public HWIDProvider() + { + systemInfo = new SystemInfo(); + system = systemInfo.getOperatingSystem(); + hardware = systemInfo.getHardware(); + } + //Statistic information + public int getBitness() + { + return system.getBitness(); + } + public long getTotalMemory() + { + return hardware.getMemory().getTotal(); + } + public long getProcessorMaxFreq() + { + return hardware.getProcessor().getMaxFreq(); + } + public int getProcessorPhysicalCount() + { + return hardware.getProcessor().getPhysicalProcessorCount(); + } + public int getProcessorLogicalCount() + { + return hardware.getProcessor().getLogicalProcessorCount(); + } + public boolean isBattery() + { + PowerSource[] powerSources = hardware.getPowerSources(); + return powerSources != null && powerSources.length != 0; + } + //Hardware Information + public String getHWDiskID() + { + HWDiskStore[] hwDiskStore = hardware.getDiskStores(); + long size = 0; + HWDiskStore maxStore = null; + for(HWDiskStore store : hwDiskStore) + { + if(store.getSize() > size) + { + maxStore = store; + size = store.getSize(); + } + } + if(maxStore != null) + { + return maxStore.getSerial(); + } + return null; + } + public HardwareReportRequest.HardwareInfo getHardwareInfo(boolean needSerial) + { + HardwareReportRequest.HardwareInfo info = new HardwareReportRequest.HardwareInfo(); + info.bitness = getBitness(); + info.logicalProcessors = getProcessorLogicalCount(); + info.physicalProcessors = getProcessorPhysicalCount(); + info.processorMaxFreq = getProcessorMaxFreq(); + info.totalMemory = getTotalMemory(); + info.battery = isBattery(); + if(needSerial) + { + info.hwDiskId = getHWDiskID(); + } + return info; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/HardwareReportRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/HardwareReportRequestEvent.java new file mode 100644 index 00000000..7305eca8 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/HardwareReportRequestEvent.java @@ -0,0 +1,10 @@ +package pro.gravit.launcher.events.request; + +import pro.gravit.launcher.events.RequestEvent; + +public class HardwareReportRequestEvent extends RequestEvent { + @Override + public String getType() { + return "hardwareReport"; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java new file mode 100644 index 00000000..857d6c97 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java @@ -0,0 +1,22 @@ +package pro.gravit.launcher.request.secure; + +import pro.gravit.launcher.events.request.HardwareReportRequestEvent; +import pro.gravit.launcher.request.Request; + +public class HardwareReportRequest extends Request { + public HardwareInfo hardware; + @Override + public String getType() { + return "hardwareReport"; + } + + public static class HardwareInfo { + public int bitness; + public long totalMemory; + public int logicalProcessors; + public int physicalProcessors; + public long processorMaxFreq; + public boolean battery; + public String hwDiskId; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java index 4e74f253..0e50045c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/ClientWebSocketService.java @@ -110,6 +110,7 @@ public void registerResults() { results.register("getSecureLevelInfo", GetSecureLevelInfoRequestEvent.class); results.register("verifySecureLevelKey", VerifySecureLevelKeyRequestEvent.class); results.register("securityReport", SecurityReportRequestEvent.class); + results.register("hardwareReport", HardwareReportRequestEvent.class); } public void waitIfNotConnected() { From 925c1170a3f6b5418bf25f02f523777749a45c05 Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 7 Apr 2020 18:17:00 +0700 Subject: [PATCH 3/6] =?UTF-8?q?[ANY]=20=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules b/modules index 07e4380a..afda996e 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit 07e4380ad52c4ef08378b8eb2202d8a1bd3639a2 +Subproject commit afda996e39ac3ab5d20ec304d011da2a517e6000 From c438f08d7aa9fa64874769a0c4c3913dbbe733f7 Mon Sep 17 00:00:00 2001 From: Gravit Date: Tue, 7 Apr 2020 19:05:58 +0700 Subject: [PATCH 4/6] =?UTF-8?q?[FEATURE]=20=D0=9F=D1=80=D0=BE=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=BA=D0=B0=20HWID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../secure/HardwareReportResponse.java | 4 +- .../test/PrintHardwareInfoCommand.java | 48 +++++++++++++++++++ .../launcher/managers/ConsoleManager.java | 2 + .../gravit/launcher/utils/HWIDProvider.java | 17 +++++++ .../request/secure/HardwareReportRequest.java | 2 + 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 Launcher/src/main/java/pro/gravit/launcher/console/test/PrintHardwareInfoCommand.java diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java index 83b87337..c9aa8db2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/secure/HardwareReportResponse.java @@ -1,12 +1,12 @@ package pro.gravit.launchserver.socket.response.secure; import io.netty.channel.ChannelHandlerContext; +import pro.gravit.launcher.request.secure.HardwareReportRequest; import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.SimpleResponse; public class HardwareReportResponse extends SimpleResponse { - public String pathToJava; - public String javaVersion; + public HardwareReportRequest.HardwareInfo hardware; @Override public String getType() { diff --git a/Launcher/src/main/java/pro/gravit/launcher/console/test/PrintHardwareInfoCommand.java b/Launcher/src/main/java/pro/gravit/launcher/console/test/PrintHardwareInfoCommand.java new file mode 100644 index 00000000..2d7a879e --- /dev/null +++ b/Launcher/src/main/java/pro/gravit/launcher/console/test/PrintHardwareInfoCommand.java @@ -0,0 +1,48 @@ +package pro.gravit.launcher.console.test; + +import pro.gravit.launcher.utils.HWIDProvider; +import pro.gravit.utils.command.Command; +import pro.gravit.utils.helper.LogHelper; + +public class PrintHardwareInfoCommand extends Command { + @Override + public String getArgsDescription() { + return "[]"; + } + + @Override + public String getUsageDescription() { + return "print your hardware info and timings"; + } + + @Override + public void invoke(String... args) throws Exception { + LogHelper.info("Your Hardware ID:"); + long startTime = System.currentTimeMillis(); + long currentTime; + HWIDProvider provider = new HWIDProvider(); + currentTime = System.currentTimeMillis(); + LogHelper.info("Create HWIDProvider instance: %d ms", currentTime - startTime); + startTime = System.currentTimeMillis(); + int bitness = provider.getBitness(); + long totalMemory = provider.getTotalMemory(); + boolean isBattery = provider.isBattery(); + currentTime = System.currentTimeMillis(); + LogHelper.info("Bitness: %d, totalMemory: %d(%.3f GB), battery %s, TIME: %d ms", bitness, totalMemory, (double)totalMemory / (1024.0*1024.0*1024.0), Boolean.toString(isBattery), currentTime - startTime); + startTime = System.currentTimeMillis(); + int logicalProcessors = provider.getProcessorLogicalCount(); + int physicalProcessors = provider.getProcessorPhysicalCount(); + long processorMaxFreq = provider.getProcessorMaxFreq(); + currentTime = System.currentTimeMillis(); + LogHelper.info("Processors || logical: %d physical %d freq %d, TIME: %d ms", logicalProcessors, physicalProcessors, processorMaxFreq, currentTime - startTime); + startTime = System.currentTimeMillis(); + String hwDiskID = provider.getHWDiskID(); + currentTime = System.currentTimeMillis(); + LogHelper.info("HWDiskID %s, TIME: %d ms", hwDiskID, currentTime - startTime); + startTime = System.currentTimeMillis(); + String baseboardSerial = provider.getBaseboardSerialNumber(); + currentTime = System.currentTimeMillis(); + LogHelper.info("BaseboardSerial %s, TIME: %d ms", baseboardSerial, currentTime - startTime); + LogHelper.info("Hardware ID end"); + } +} diff --git a/Launcher/src/main/java/pro/gravit/launcher/managers/ConsoleManager.java b/Launcher/src/main/java/pro/gravit/launcher/managers/ConsoleManager.java index c0d6543d..641be710 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/managers/ConsoleManager.java +++ b/Launcher/src/main/java/pro/gravit/launcher/managers/ConsoleManager.java @@ -4,6 +4,7 @@ import pro.gravit.launcher.LauncherEngine; import pro.gravit.launcher.client.events.ClientUnlockConsoleEvent; import pro.gravit.launcher.console.UnlockCommand; +import pro.gravit.launcher.console.test.PrintHardwareInfoCommand; import pro.gravit.utils.command.CommandHandler; import pro.gravit.utils.command.JLineCommandHandler; import pro.gravit.utils.command.StdCommandHandler; @@ -44,6 +45,7 @@ public static void registerCommands() { handler.registerCommand("gc", new GCCommand()); handler.registerCommand("clear", new ClearCommand(handler)); handler.registerCommand("unlock", new UnlockCommand()); + handler.registerCommand("printhardware", new PrintHardwareInfoCommand()); } public static boolean checkUnlockKey(String key) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java index 3f8aa00d..bdf41d46 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java +++ b/Launcher/src/main/java/pro/gravit/launcher/utils/HWIDProvider.java @@ -1,6 +1,7 @@ package pro.gravit.launcher.utils; import oshi.SystemInfo; +import oshi.hardware.Display; import oshi.hardware.HWDiskStore; import oshi.hardware.HardwareAbstractionLayer; import oshi.hardware.PowerSource; @@ -63,6 +64,20 @@ public String getHWDiskID() } return null; } + public byte[] getDisplayID() + { + Display[] displays = hardware.getDisplays(); + if(displays == null || displays.length == 0) return null; + for(Display display : displays) + { + return display.getEdid(); + } + return null; + } + public String getBaseboardSerialNumber() + { + return hardware.getComputerSystem().getBaseboard().getSerialNumber(); + } public HardwareReportRequest.HardwareInfo getHardwareInfo(boolean needSerial) { HardwareReportRequest.HardwareInfo info = new HardwareReportRequest.HardwareInfo(); @@ -75,6 +90,8 @@ public HardwareReportRequest.HardwareInfo getHardwareInfo(boolean needSerial) if(needSerial) { info.hwDiskId = getHWDiskID(); + info.displayId = getDisplayID(); + info.baseboardSerialNumber = getBaseboardSerialNumber(); } return info; } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java index 857d6c97..2f7fd075 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/secure/HardwareReportRequest.java @@ -18,5 +18,7 @@ public static class HardwareInfo { public long processorMaxFreq; public boolean battery; public String hwDiskId; + public byte[] displayId; + public String baseboardSerialNumber; } } From 4592aeea2ded08244f7452ed6095c93938a98d14 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 12 Apr 2020 20:58:00 +0700 Subject: [PATCH 5/6] [FEATURE] May be fix old wrapper's --- .../launcher/client/ClientLauncherProcess.java | 12 ++++++++++-- .../gravit/launcher/guard/LauncherWrapperGuard.java | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java index 24a4bd0c..ea859503 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java @@ -34,6 +34,7 @@ public class ClientLauncherProcess { public Path executeFile; public Path workDir; public Path javaDir; + public boolean useLegacyJavaClassPathProperty; public boolean isStarted; private transient Process process; @@ -103,9 +104,16 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException { List processArgs = new LinkedList<>(); processArgs.add(executeFile.toString()); processArgs.addAll(jvmArgs); - processArgs.add("-cp"); //ADD CLASSPATH - processArgs.add(String.join(getPathSeparator(), systemClassPath)); + if(useLegacyJavaClassPathProperty) + { + processArgs.add("-Djava.class.path".concat(String.join(getPathSeparator(), systemClassPath))); + } + else + { + processArgs.add("-cp"); + processArgs.add(String.join(getPathSeparator(), systemClassPath)); + } processArgs.add(mainClass); processArgs.addAll(systemClientArgs); synchronized (waitWriteParams) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java index 22c10b02..762449a6 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java +++ b/Launcher/src/main/java/pro/gravit/launcher/guard/LauncherWrapperGuard.java @@ -34,6 +34,7 @@ public void applyGuardParams(ClientLauncherProcess process) { String projectName = Launcher.getConfig().projectName; String wrapperUnpackName = JVMHelper.JVM_BITS == 64 ? projectName.concat("64.exe") : projectName.concat("32.exe"); process.executeFile = DirBridge.getGuardDir().resolve(wrapperUnpackName); + process.useLegacyJavaClassPathProperty = true; } } } From d2ce49e41a40bf8eb66e70f8f8e0c87ee2a0afca Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 12 Apr 2020 20:59:24 +0700 Subject: [PATCH 6/6] [FIX] Missed = --- .../java/pro/gravit/launcher/client/ClientLauncherProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java index ea859503..a10dd91d 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/client/ClientLauncherProcess.java @@ -107,7 +107,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException { //ADD CLASSPATH if(useLegacyJavaClassPathProperty) { - processArgs.add("-Djava.class.path".concat(String.join(getPathSeparator(), systemClassPath))); + processArgs.add("-Djava.class.path=".concat(String.join(getPathSeparator(), systemClassPath))); } else {