From 695758aa187df8f4872d49411a4742ad96c2ae27 Mon Sep 17 00:00:00 2001 From: Zaxar163 <35835496+Zaxar163@users.noreply.github.com> Date: Thu, 28 Mar 2019 11:54:18 +0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=92=D0=BB=D0=B5=D0=B7=D0=B0=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=B2=20=D0=BB=D0=B0=D1=83=D0=BD=D1=87=D0=B5=D1=80=20?= =?UTF-8?q?=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20agent.=20(#202)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [FIX] Правки градла. * [FEATURE] Скрипт для скачивания. * [DOCS] Правки readme. * [FIX][DOCS] Удален неактуальная папка docs. * [DOCS] Готов readme. * [FIX] Launcher sign. * [FEATURE] Модули по новому. * [FIX] Способ влезть в лаунчер через agent. * [ANY] Обновлены модули (там фикс JarSigner). * [FEATURE] ListDownloader. --- LaunchServer/build.gradle | 2 + .../launcher/ClientLauncherWrapper.java | 4 ++ .../launcher/client/ClientLauncher.java | 12 ++--- LauncherAPI/build.gradle | 1 + .../launcher/downloader/ListDownloader.java | 52 +++++++++++++++++++ README.md | 7 ++- docs/EN-changes.md | 19 ------- docs/RU-changes.md | 19 ------- get_it.sh | 4 ++ module.gradle | 7 +++ modules | 2 +- 11 files changed, 81 insertions(+), 48 deletions(-) create mode 100644 LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java delete mode 100644 docs/EN-changes.md delete mode 100644 docs/RU-changes.md create mode 100755 get_it.sh create mode 100644 module.gradle diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index 228ffe3c..090eb514 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -1,6 +1,8 @@ def mainClassName = "ru.gravit.launchserver.LaunchServer" def mainAgentName = "ru.gravit.launchserver.StarterAgent" +evaluationDependsOn(':Launcher') + repositories { maven { url "https://oss.sonatype.org/content/repositories/snapshots" diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index eb0f6aa9..36af51a6 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -15,6 +15,8 @@ import java.util.List; public class ClientLauncherWrapper { + public static final String MAGIC_ARG = "-Djdk.attach.allowAttachSelf"; + public static void main(String[] arguments) throws IOException, InterruptedException { LogHelper.printVersion("Launcher"); LogHelper.printLicense("Launcher"); @@ -36,6 +38,8 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep JVMHelper.addSystemPropertyToArgs(args, DirBridge.CUSTOMDIR_PROPERTY); JVMHelper.addSystemPropertyToArgs(args, DirBridge.USE_CUSTOMDIR_PROPERTY); JVMHelper.addSystemPropertyToArgs(args, DirBridge.USE_OPTDIR_PROPERTY); + Collections.addAll(args, MAGIC_ARG); + Collections.addAll(args, "-XX:+DisableAttachMechanism"); Collections.addAll(args, "-javaagent:".concat(pathLauncher)); Collections.addAll(args, "-cp"); Collections.addAll(args, pathLauncher); 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 f684ec33..354ed894 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -11,6 +11,7 @@ import ru.gravit.launcher.profiles.ClientProfile; import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.request.Request; +import ru.gravit.launcher.request.update.LegacyLauncherRequest; import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.stream.StreamObject; @@ -34,8 +35,6 @@ import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.PosixFilePermission; import java.util.*; -import java.util.Timer; -import java.util.concurrent.TimeUnit; public final class ClientLauncher { private static Gson gson = new Gson(); @@ -301,7 +300,6 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl public static Process launch( HashedDir assetHDir, HashedDir clientHDir, ClientProfile profile, Params params, boolean pipeOutput) throws Throwable { - // Write params file (instead of CLI; Mustdie32 API can't handle command line > 32767 chars) LogHelper.debug("Writing ClientLauncher params"); ClientLauncherContext context = new ClientLauncherContext(); clientStarted = false; @@ -368,6 +366,7 @@ public static Process launch( // Add classpath and main class String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); context.pathLauncher = pathLauncher; + Collections.addAll(context.args, ClientLauncherWrapper.MAGIC_ARG); Collections.addAll(context.args, profile.getJvmArgs()); profile.pushOptionalJvmArgs(context.args); Collections.addAll(context.args, "-Djava.library.path=".concat(params.clientDir.resolve(NATIVES_DIR).toString())); // Add Native Path @@ -434,7 +433,6 @@ public static void main(String... args) throws Throwable { engine.runtimeProvider.init(true); engine.runtimeProvider.preLoad(); LauncherGuardManager.initGuard(true); - // Read and delete params file LogHelper.debug("Reading ClientLauncher params"); Params params; ClientProfile profile; @@ -445,8 +443,6 @@ public static void main(String... args) throws Throwable { try (HInput input = new HInput(socket.getInputStream())) { params = new Params(input); profile = gson.fromJson(input.readString(0), ClientProfile.class); - - // Read hdirs assetHDir = new HashedDir(input); clientHDir = new HashedDir(input); } @@ -462,8 +458,8 @@ public static void main(String... args) throws Throwable { Launcher.modulesManager.initModules(); // Verify ClientLauncher sign and classpath LogHelper.debug("Verifying ClientLauncher sign and classpath"); - //TODO: GO TO DIGEST - //SecurityHelper.verifySign(LegacyLauncherRequest.BINARY_PATH, params.launcherDigest, publicKey); + //Warning - experimental. + SecurityHelper.verifySign(LegacyLauncherRequest.BINARY_PATH, params.launcherDigest, Launcher.getConfig().publicKey); LinkedList classPath = resolveClassPathList(params.clientDir, profile.getClassPath()); for (Path classpathURL : classPath) { LauncherAgent.addJVMClassPath(classpathURL.toAbsolutePath().toString()); diff --git a/LauncherAPI/build.gradle b/LauncherAPI/build.gradle index 1a9366f9..95d23990 100644 --- a/LauncherAPI/build.gradle +++ b/LauncherAPI/build.gradle @@ -4,6 +4,7 @@ dependencies { compile project(':libLauncher') compile 'org.java-websocket:Java-WebSocket:1.3.9' + compile 'org.apache.httpcomponents:httpclient:4.5.7' compileOnly 'com.google.guava:guava:26.0-jre' compile files('../compat/authlib/authlib-clean.jar') } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java b/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java new file mode 100644 index 00000000..b1a54412 --- /dev/null +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/downloader/ListDownloader.java @@ -0,0 +1,52 @@ +package ru.gravit.launcher.downloader; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.util.List; + +import org.apache.http.HttpResponse; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.ResponseHandler; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.client.LaxRedirectStrategy; + +import ru.gravit.utils.helper.IOHelper; + +public class ListDownloader { + public void download(String base, List applies, Path dstDirFile) throws IOException, URISyntaxException { + try(CloseableHttpClient httpclient = HttpClients.custom() + .setRedirectStrategy(new LaxRedirectStrategy()) + .build()) { + + HttpGet get = null; + for (String apply : applies) { + URI u = new URL(base.concat(apply)).toURI(); + if (get == null) get = new HttpGet(u); + else { + get.reset(); + get.setURI(u); + } + httpclient.execute(get, new FileDownloadResponseHandler(dstDirFile.resolve(apply))); + } + } + } + + static class FileDownloadResponseHandler implements ResponseHandler { + private final Path target; + public FileDownloadResponseHandler(Path target) { + this.target = target; + } + @Override + public Path handleResponse(HttpResponse response) throws ClientProtocolException, IOException { + InputStream source = response.getEntity().getContent(); + IOHelper.transfer(source, this.target); + return this.target; + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index e786a5d3..051f38c6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ # Modification of the launcher sashok724's v3 from Gravit [![Build Status](https://travis-ci.com/GravitLauncher/Launcher.svg?branch=master)](https://travis-ci.com/GravitLauncher/Launcher) * Discord channel: https://discord.gg/aJK6nMN * [See license](LICENSE) -* Changes: [ru-ru](docs/RU-changes.md#Изменения) [en-us](docs/EN-changes.md#changes) +* [See code of conduct](CODE_OF_CONDUCT.md) +* [WIKI](https://launcher.gravit.pro) +* Get it (requires cURL): +```sh +curl -s https://raw.githubusercontent.com/GravitLauncher/Launcher/master/get_it.sh | sh +``` diff --git a/docs/EN-changes.md b/docs/EN-changes.md deleted file mode 100644 index e82d12df..00000000 --- a/docs/EN-changes.md +++ /dev/null @@ -1,19 +0,0 @@ -# Changes -* Build with Gradle -* The code is free of many dirty "hacks" that depend on the implementation and undocumented features of a particular JVM -* Removed JVM installation -* Brute-force attack protection -* Launcher compiles and runs with JDK 10 -* Patched launchwrapper with Java 10 support -* ClassPath is not visible in the start line -* Symlinks are fully allowed without restrictions -* Removed an undocumented feature which allowed to use JavaScript plugins on server side -* Various improvements and bugfixes -* Split into 5 modules instead of two -* The old bypasses don't work -* Partially modified structure of the classes -* Bug fixes in the main branch of the launcher -* Ability to install different skins on different servers -* Send HWID -* Flexible exe settings when building -* And much more! diff --git a/docs/RU-changes.md b/docs/RU-changes.md deleted file mode 100644 index 617f628e..00000000 --- a/docs/RU-changes.md +++ /dev/null @@ -1,19 +0,0 @@ -# -* Gradle -* "", JVM -* JVM -* -* JDK 10 -* launchwrapper Java 10 -* ClassPath -* -* JavaScript -* -* 5 -* -* -* -* -* HWID -* exe -* ! \ No newline at end of file diff --git a/get_it.sh b/get_it.sh new file mode 100755 index 00000000..f37055af --- /dev/null +++ b/get_it.sh @@ -0,0 +1,4 @@ +#!/bin/sh +git clone https://github.com/GravitLauncher/Launcher.git +sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules +git submodule update --init --recursive diff --git a/module.gradle b/module.gradle new file mode 100644 index 00000000..a5690396 --- /dev/null +++ b/module.gradle @@ -0,0 +1,7 @@ +dependencies { + compileOnly project(':LaunchServer') +} +jar { + from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } } +} + diff --git a/modules b/modules index be22f5b7..8df678be 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit be22f5b74912bda8df26ce888af994f330cc8934 +Subproject commit 8df678bed74b671ba0f0866f8f215fd42e467c03