Avanguard выброшен

This commit is contained in:
Gravit 2018-11-27 18:19:09 +07:00
parent 1e35e89d1c
commit 3cd15a6168
8 changed files with 10 additions and 220 deletions

View file

@ -254,7 +254,7 @@ private void stdBuild() throws IOException {
throw new IOException(String.format("Missing init script file ('%s')", Launcher.INIT_SCRIPT_FILE)); throw new IOException(String.format("Missing init script file ('%s')", Launcher.INIT_SCRIPT_FILE));
// Write launcher guard dir // Write launcher guard dir
IOHelper.walk(runtimeDir, new RuntimeDirVisitor(output, runtime), false); IOHelper.walk(runtimeDir, new RuntimeDirVisitor(output, runtime), false);
IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false); //IOHelper.walk(guardDir, new GuardDirVisitor(output, runtime), false);
} }
// Create launcher config file // Create launcher config file
byte[] launcherConfigBytes; byte[] launcherConfigBytes;

View file

@ -1,104 +0,0 @@
package ru.gravit.launcher;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import cpw.mods.fml.SafeExitJVMLegacy;
import net.minecraftforge.fml.SafeExitJVM;
import ru.gravit.launcher.hasher.DirWatcher;
import ru.gravit.launcher.hasher.HashedDir;
import ru.gravit.utils.NativeJVMHalt;
import ru.gravit.utils.helper.*;
import ru.zaxar163.GuardBind;
public class AvanguardStarter {
static class SecurityThread implements Runnable {
static long macID = GuardBind.avnGetMacId();
@Override
public void run() {
while (!Thread.interrupted()) {
try {
if (macID != GuardBind.avnGetMacId()) {
LogHelper.error("MacID changed");
safeHalt(8);
}
if (!GuardBind.avnIsStarted()) {
LogHelper.error("Avanguard stopped! Process stopped");
safeHalt(5);
}
} catch (NullPointerException e) {
LogHelper.error("Avanguard unloaded! Process stopped");
safeHalt(6);
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
GuardBind.avnGetMacId();
if (!GuardBind.avnIsStarted()) {
LogHelper.error("Thread stopped! Process stopped");
safeHalt(7);
}
}
}
}
}
static void safeHalt(int exitcode) {
try {
SafeExitJVMLegacy.exit(exitcode);
} catch (Throwable ignored) {
}
try {
SafeExitJVM.exit(exitcode);
} catch (Throwable ignored) {
}
NativeJVMHalt halt = new NativeJVMHalt(exitcode);
halt.halt();
}
public static final String NAME = Launcher.getConfig().projectname;
public static Path wrapper = null, avanguard = null;
public static void main(boolean init) {
if (init)
GuardBind.init();
GuardBind.avnRegisterThreatNotifier((int threatType) -> {
System.err.println("Threat " + GuardBind.ThreatType.getThreat(threatType).name());
LogHelper.error("Cheating == crash!");
try {
SafeExitJVM.exit(threatType + 7000);
} catch (Throwable e) {
SafeExitJVMLegacy.exit(threatType + 7000);
}
return false;
});
// нужно делать до пуска таймера!
GuardBind.avnStartDefence();
CommonHelper.newThread("Security Thread", true, new SecurityThread()).start();
}
public static void load() {
GuardBind.startAbs(avanguard.toString());
}
public static void start(Path path1) throws IOException {
Path path = path1.resolve("guard");
if (!IOHelper.exists(path))
Files.createDirectories(path);
Path avanguard = path.resolve(JVMHelper.JVM_BITS == 64 ? "Avanguard64.dll" : "Avanguard32.dll");
Path wrapper = path.resolve(JVMHelper.JVM_BITS == 64 ? NAME + "64.exe" : NAME + "32.exe");
String avanguardResource = JVMHelper.JVM_BITS == 64 ? "Avanguard64.dll" : "Avanguard32.dll";
String wrapperResource = JVMHelper.JVM_BITS == 64 ? "wrapper64.exe" : "wrapper32.exe";
UnpackHelper.unpack(Launcher.getResourceURL(avanguardResource, "guard"), avanguard);
UnpackHelper.unpack(Launcher.getResourceURL(wrapperResource, "guard"), wrapper);
AvanguardStarter.wrapper = wrapper;
AvanguardStarter.avanguard = avanguard;
HashedDir guard = new HashedDir(path, null, true, false);
DirWatcher dirWatcher = new DirWatcher(path, guard, null, false);
CommonHelper.newThread("Guard Directory Watcher", true, dirWatcher).start();
}
}

View file

@ -217,11 +217,6 @@ public void start(String... args) throws Throwable {
loadScript(Launcher.INIT_SCRIPT_FILE); loadScript(Launcher.INIT_SCRIPT_FILE);
LogHelper.info("Invoking start() function"); LogHelper.info("Invoking start() function");
Invocable invoker = (Invocable) engine; Invocable invoker = (Invocable) engine;
if (Launcher.isUsingAvanguard()) {
AvanguardStarter.start(DirBridge.dir);
AvanguardStarter.load();
AvanguardStarter.main(false);
}
Launcher.modulesManager.postInitModules(); Launcher.modulesManager.postInitModules();
invoker.invokeFunction("start", (Object) args); invoker.invokeFunction("start", (Object) args);
} }

View file

@ -334,8 +334,8 @@ public static Process launch(
List<String> args = new LinkedList<>(); List<String> args = new LinkedList<>();
boolean wrapper = isUsingWrapper(); boolean wrapper = isUsingWrapper();
Path javaBin; Path javaBin;
if (wrapper) javaBin = AvanguardStarter.wrapper; /*if (wrapper) javaBin = AvanguardStarter.wrapper;
else if (isDownloadJava) { else*/ if (isDownloadJava) {
//Linux и Mac не должны скачивать свою JVM //Linux и Mac не должны скачивать свою JVM
if (JVMHelper.OS_TYPE == OS.MUSTDIE) if (JVMHelper.OS_TYPE == OS.MUSTDIE)
javaBin = IOHelper.resolveJavaBin(JavaBinPath); javaBin = IOHelper.resolveJavaBin(JavaBinPath);
@ -405,11 +405,6 @@ public static void main(String... args) throws Throwable {
engine.loadScript(Launcher.API_SCRIPT_FILE); engine.loadScript(Launcher.API_SCRIPT_FILE);
engine.loadScript(Launcher.CONFIG_SCRIPT_FILE); engine.loadScript(Launcher.CONFIG_SCRIPT_FILE);
Launcher.modulesManager.preInitModules(); Launcher.modulesManager.preInitModules();
if (Launcher.isUsingAvanguard()) {
AvanguardStarter.start(DirBridge.dir);
AvanguardStarter.load();
AvanguardStarter.main(false);
}
checkJVMBitsAndVersion(); checkJVMBitsAndVersion();
JVMHelper.verifySystemProperties(ClientLauncher.class, true); JVMHelper.verifySystemProperties(ClientLauncher.class, true);
EnvHelper.checkDangerousParams(); EnvHelper.checkDangerousParams();

View file

@ -14,7 +14,6 @@
import ru.gravit.launcher.serialize.HInput; import ru.gravit.launcher.serialize.HInput;
import ru.gravit.launcher.serialize.HOutput; import ru.gravit.launcher.serialize.HOutput;
import ru.gravit.launcher.serialize.SerializeLimits; import ru.gravit.launcher.serialize.SerializeLimits;
import ru.zaxar163.GuardBind;
public final class AuthRequest extends Request<Result> { public final class AuthRequest extends Request<Result> {
public static final class Result { public static final class Result {
@ -72,9 +71,9 @@ protected Result requestDo(HInput input, HOutput output) throws IOException {
if (Launcher.profile != null) if (Launcher.profile != null)
output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT); output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT);
output.writeInt(auth_id); output.writeInt(auth_id);
output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetHddId() : 0); output.writeLong(0);
output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetCpuid() : 0); output.writeLong(0);
output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetSmbiosId() : 0); output.writeLong(0);
output.writeByteArray(encryptedPassword, SecurityHelper.CRYPTO_MAX_LENGTH); output.writeByteArray(encryptedPassword, SecurityHelper.CRYPTO_MAX_LENGTH);
output.flush(); output.flush();

View file

@ -1,95 +0,0 @@
package ru.zaxar163;
import java.nio.file.Path;
import ru.gravit.launcher.LauncherAPI;
import ru.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.LogHelper;
@LauncherAPI
public final class GuardBind {
public interface ThreatNotifier {
boolean call(int threatType);
}
public enum ThreatType {
UNKNOWN_THREAT(0),
REMOTE_THREAD(1),
WINDOWS_HOOKS_INJECTION(2),
UNKNOWN_TRACE_LOAD_LIBRARY(3),
CONTEXT_MANIPULATION(4),
CRITICAL_MODULE_CHANGED(5),
UNKNOWN_INTERCEPTION(6),
UNKNOWN_MEMORY_REGION(7),
UNKNOWN_APC_DESTINATION(8);
public static ThreatType getThreat(int threatType) {
return ThreatType.values()[threatType];
}
private final int id;
ThreatType(int value) {
id = value;
}
public int getValue() {
return id;
}
}
@LauncherAPI
public static native void avnEliminateThreat(int threatType);
@LauncherAPI
public static native long avnGetCpuid();
@LauncherAPI
public static native long avnGetHash(byte[] data);
@LauncherAPI
public static native long avnGetHddId();
@LauncherAPI
public static native long avnGetMacId();
@LauncherAPI
public static native long avnGetSmbiosId();
@LauncherAPI
public static native boolean avnIsStarted();
@LauncherAPI
public static native boolean avnIsStaticLoaded();
@LauncherAPI
public static native void avnRegisterThreatNotifier(ThreatNotifier notifier);
@LauncherAPI
public static native boolean avnStartDefence();
@LauncherAPI
public static native void avnStopDefence();
public static void init() {
LogHelper.debug("Anti-Cheat loading");
if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE)
if (JVMHelper.JVM_BITS == 32)
System.loadLibrary("Avanguard32");
else if (JVMHelper.JVM_BITS == 64)
System.loadLibrary("Avanguard64");
LogHelper.debug("Anti-Cheat loaded");
}
public static void start(Path path) {
LogHelper.debug("Anti-Cheat loading");
System.load(path.normalize().toAbsolutePath().toFile().getAbsolutePath());
LogHelper.debug("Anti-Cheat loaded");
}
public static void startAbs(String path) {
LogHelper.debug("Anti-Cheat loading");
System.load(path);
LogHelper.debug("Anti-Cheat loaded");
}
}

View file

@ -57,10 +57,10 @@ public final class Launcher {
private static final Pattern UUID_PATTERN = Pattern.compile("-", Pattern.LITERAL); private static final Pattern UUID_PATTERN = Pattern.compile("-", Pattern.LITERAL);
public static int MAJOR = 4; public static int MAJOR = 4;
public static int MINOR = 0; public static int MINOR = 1;
public static int PATCH = 8; public static int PATCH = 0;
public static int BUILD = 0; public static int BUILD = 0;
public static Version.Type RELEASE = Version.Type.STABLE; public static Version.Type RELEASE = Version.Type.DEV;
@LauncherAPI @LauncherAPI
public static LauncherConfig getConfig() { public static LauncherConfig getConfig() {

@ -1 +1 @@
Subproject commit f4ff154d105248c5bcb3a4cb217b38eed01b3a27 Subproject commit dd97153ee53813078391aa07d1700f890e979e3f