mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 09:01:08 +03:00
[FIX] Подарок читерам.
This commit is contained in:
parent
dea036a574
commit
555c6a6c0b
3 changed files with 14 additions and 145 deletions
|
@ -83,7 +83,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
}
|
}
|
||||||
Collections.addAll(args, MAGIC_ARG);
|
Collections.addAll(args, MAGIC_ARG);
|
||||||
Collections.addAll(args, "-XX:+DisableAttachMechanism");
|
Collections.addAll(args, "-XX:+DisableAttachMechanism");
|
||||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher).concat("=pr"));
|
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||||
Collections.addAll(args, "-cp");
|
Collections.addAll(args, "-cp");
|
||||||
Collections.addAll(args, pathLauncher);
|
Collections.addAll(args, pathLauncher);
|
||||||
Collections.addAll(args, LauncherEngine.class.getName());
|
Collections.addAll(args, LauncherEngine.class.getName());
|
||||||
|
|
|
@ -1,25 +1,11 @@
|
||||||
package pro.gravit.launcher;
|
package pro.gravit.launcher;
|
||||||
|
|
||||||
import static org.objectweb.asm.Opcodes.ACONST_NULL;
|
|
||||||
import static org.objectweb.asm.Opcodes.ARETURN;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.lang.instrument.Instrumentation;
|
import java.lang.instrument.Instrumentation;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
import org.objectweb.asm.tree.InsnNode;
|
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
|
||||||
|
|
||||||
import cpw.mods.fml.SafeExitJVMLegacy;
|
import cpw.mods.fml.SafeExitJVMLegacy;
|
||||||
import net.minecraftforge.fml.SafeExitJVM;
|
import net.minecraftforge.fml.SafeExitJVM;
|
||||||
import pro.gravit.launcher.utils.NativeJVMHalt;
|
import pro.gravit.launcher.utils.NativeJVMHalt;
|
||||||
|
@ -52,138 +38,17 @@ public static void premain(String agentArgument, Instrumentation instrumentation
|
||||||
SafeExitJVM.class.getName();
|
SafeExitJVM.class.getName();
|
||||||
NativeJVMHalt.class.getName();
|
NativeJVMHalt.class.getName();
|
||||||
NativeJVMHalt.initFunc();
|
NativeJVMHalt.initFunc();
|
||||||
isAgentStarted = true;
|
JVMHelper.checkStackTrace(LauncherAgent.class);
|
||||||
if (System.getProperty("java.vm.name").toUpperCase(Locale.US).contains("HOTSPOT"))
|
boolean bad = false;
|
||||||
try {
|
try {
|
||||||
if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) {
|
for (StackTraceElement e : new Throwable().getStackTrace())
|
||||||
boolean pb = true;
|
if (Class.forName(e.getClassName()).getClassLoader() != Runtime.class.getClassLoader() && Class.forName(e.getClassName()) != LauncherAgent.class) bad = true;
|
||||||
boolean rt = true;
|
} catch(Throwable e) { bad = true; }
|
||||||
if (agentArgument != null) {
|
if (bad) NativeJVMHalt.haltA(-17);
|
||||||
String trimmedArg = agentArgument.trim();
|
else isAgentStarted = true;
|
||||||
if (!trimmedArg.isEmpty()) {
|
|
||||||
if (trimmedArg.contains("p")) pb = false;
|
|
||||||
if (trimmedArg.contains("r")) rt = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
replaceClasses(pb, rt);
|
|
||||||
} else replaceClasses(false, false);
|
|
||||||
} catch (Error e) {
|
|
||||||
NativeJVMHalt.haltA(294);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isStarted() {
|
public static boolean isStarted() {
|
||||||
return isAgentStarted;
|
return isAgentStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void replaceClasses(boolean pb, boolean rt) {
|
|
||||||
java.awt.Robot.class.getName();
|
|
||||||
List<java.lang.instrument.ClassDefinition> defs = new ArrayList<>();
|
|
||||||
if (rt) {
|
|
||||||
try {
|
|
||||||
defs.add(new java.lang.instrument.ClassDefinition(java.lang.Runtime.class, transformClass(java.lang.Runtime.class.getName(), getClassFile(java.lang.Runtime.class))));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new Error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pb) {
|
|
||||||
try {
|
|
||||||
defs.add(new java.lang.instrument.ClassDefinition(java.lang.ProcessBuilder.class, transformClass(java.lang.ProcessBuilder.class.getName(), getClassFile(java.lang.ProcessBuilder.class))));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new Error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
defs.add(new java.lang.instrument.ClassDefinition(java.awt.Robot.class, transformClass(java.awt.Robot.class.getName(), getClassFile(java.awt.Robot.class))));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new Error(e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
inst.redefineClasses(defs.toArray(new java.lang.instrument.ClassDefinition[0]));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new Error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author https://github.com/Konloch/JVM-Sandbox
|
|
||||||
* Use ASM to modify the byte array
|
|
||||||
*/
|
|
||||||
private static byte[] transformClass(String className, byte[] classBytes) {
|
|
||||||
switch (className) {
|
|
||||||
case "java.lang.Runtime": {
|
|
||||||
ClassReader cr = new ClassReader(classBytes);
|
|
||||||
ClassNode cn = new ClassNode();
|
|
||||||
cr.accept(cn, ClassReader.EXPAND_FRAMES);
|
|
||||||
|
|
||||||
for (Object o : cn.methods.toArray()) {
|
|
||||||
MethodNode m = (MethodNode) o;
|
|
||||||
if (m.name.equals("exec")) {
|
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
|
||||||
cn.accept(cw);
|
|
||||||
return cw.toByteArray();
|
|
||||||
}
|
|
||||||
case "java.lang.ProcessBuilder": {
|
|
||||||
ClassReader cr = new ClassReader(classBytes);
|
|
||||||
ClassNode cn = new ClassNode();
|
|
||||||
cr.accept(cn, ClassReader.EXPAND_FRAMES);
|
|
||||||
|
|
||||||
for (Object o : cn.methods.toArray()) {
|
|
||||||
MethodNode m = (MethodNode) o;
|
|
||||||
if (m.name.equals("start")) {
|
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
|
||||||
cn.accept(cw);
|
|
||||||
return cw.toByteArray();
|
|
||||||
}
|
|
||||||
case "java.awt.Robot": {
|
|
||||||
ClassReader cr = new ClassReader(classBytes);
|
|
||||||
ClassNode cn = new ClassNode();
|
|
||||||
cr.accept(cn, ClassReader.EXPAND_FRAMES);
|
|
||||||
|
|
||||||
for (Object o : cn.methods.toArray()) {
|
|
||||||
MethodNode m = (MethodNode) o;
|
|
||||||
if (m.name.equals("createScreenCapture") || m.name.equals("getPixelColor") ||
|
|
||||||
m.name.equals("keyPress") || m.name.equals("keyRelease") ||
|
|
||||||
m.name.equals("mouseMove") || m.name.equals("mousePress") ||
|
|
||||||
m.name.equals("mouseWheel")) {
|
|
||||||
m.instructions.insert(new InsnNode(ARETURN));
|
|
||||||
m.instructions.insert(new InsnNode(ACONST_NULL));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
|
||||||
cn.accept(cw);
|
|
||||||
return cw.toByteArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return classBytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param clazz
|
|
||||||
* @return array, respending this class in bytecode.
|
|
||||||
* @throws IOException
|
|
||||||
* @author https://github.com/Konloch/JVM-Sandbox
|
|
||||||
* Do not remove this method. Do not to cause classloading!
|
|
||||||
* Grab the byte array from the loaded Class object
|
|
||||||
*/
|
|
||||||
private static byte[] getClassFile(Class<?> clazz) throws IOException {
|
|
||||||
try (InputStream is = clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".class");
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
|
||||||
int r;
|
|
||||||
byte[] buffer = new byte[8192];
|
|
||||||
while ((r = is.read(buffer)) >= 0) {
|
|
||||||
baos.write(buffer, 0, r);
|
|
||||||
}
|
|
||||||
return baos.toByteArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
import pro.gravit.launcher.hwid.HWIDProvider;
|
import pro.gravit.launcher.hwid.HWIDProvider;
|
||||||
import pro.gravit.launcher.managers.ClientGsonManager;
|
import pro.gravit.launcher.managers.ClientGsonManager;
|
||||||
import pro.gravit.launcher.managers.ClientHookManager;
|
import pro.gravit.launcher.managers.ClientHookManager;
|
||||||
import pro.gravit.launcher.modules.events.PostInitPhase;
|
|
||||||
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
||||||
import pro.gravit.launcher.profiles.ClientProfile;
|
import pro.gravit.launcher.profiles.ClientProfile;
|
||||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||||
|
@ -55,6 +54,7 @@
|
||||||
import pro.gravit.launcher.serialize.HOutput;
|
import pro.gravit.launcher.serialize.HOutput;
|
||||||
import pro.gravit.launcher.serialize.stream.StreamObject;
|
import pro.gravit.launcher.serialize.stream.StreamObject;
|
||||||
import pro.gravit.launcher.utils.DirWatcher;
|
import pro.gravit.launcher.utils.DirWatcher;
|
||||||
|
import pro.gravit.launcher.utils.NativeJVMHalt;
|
||||||
import pro.gravit.utils.PublicURLClassLoader;
|
import pro.gravit.utils.PublicURLClassLoader;
|
||||||
import pro.gravit.utils.Version;
|
import pro.gravit.utils.Version;
|
||||||
import pro.gravit.utils.helper.CommonHelper;
|
import pro.gravit.utils.helper.CommonHelper;
|
||||||
|
@ -463,6 +463,10 @@ public static void main(String... args) throws Throwable {
|
||||||
LauncherEngine.modulesManager.initModules(null);
|
LauncherEngine.modulesManager.initModules(null);
|
||||||
initGson(LauncherEngine.modulesManager);
|
initGson(LauncherEngine.modulesManager);
|
||||||
//Launcher.modulesManager.preInitModules();
|
//Launcher.modulesManager.preInitModules();
|
||||||
|
if (!LauncherAgent.isStarted()) {
|
||||||
|
NativeJVMHalt.haltA(100);
|
||||||
|
return;
|
||||||
|
}
|
||||||
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
||||||
JVMHelper.verifySystemProperties(ClientLauncher.class, true);
|
JVMHelper.verifySystemProperties(ClientLauncher.class, true);
|
||||||
EnvHelper.checkDangerousParams();
|
EnvHelper.checkDangerousParams();
|
||||||
|
|
Loading…
Reference in a new issue