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, "-XX:+DisableAttachMechanism");
|
||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher).concat("=pr"));
|
||||
Collections.addAll(args, "-javaagent:".concat(pathLauncher));
|
||||
Collections.addAll(args, "-cp");
|
||||
Collections.addAll(args, pathLauncher);
|
||||
Collections.addAll(args, LauncherEngine.class.getName());
|
||||
|
|
|
@ -1,25 +1,11 @@
|
|||
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.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
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 net.minecraftforge.fml.SafeExitJVM;
|
||||
import pro.gravit.launcher.utils.NativeJVMHalt;
|
||||
|
@ -52,138 +38,17 @@ public static void premain(String agentArgument, Instrumentation instrumentation
|
|||
SafeExitJVM.class.getName();
|
||||
NativeJVMHalt.class.getName();
|
||||
NativeJVMHalt.initFunc();
|
||||
isAgentStarted = true;
|
||||
if (System.getProperty("java.vm.name").toUpperCase(Locale.US).contains("HOTSPOT"))
|
||||
JVMHelper.checkStackTrace(LauncherAgent.class);
|
||||
boolean bad = false;
|
||||
try {
|
||||
if (JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE) {
|
||||
boolean pb = true;
|
||||
boolean rt = true;
|
||||
if (agentArgument != null) {
|
||||
String trimmedArg = agentArgument.trim();
|
||||
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;
|
||||
}
|
||||
for (StackTraceElement e : new Throwable().getStackTrace())
|
||||
if (Class.forName(e.getClassName()).getClassLoader() != Runtime.class.getClassLoader() && Class.forName(e.getClassName()) != LauncherAgent.class) bad = true;
|
||||
} catch(Throwable e) { bad = true; }
|
||||
if (bad) NativeJVMHalt.haltA(-17);
|
||||
else isAgentStarted = true;
|
||||
}
|
||||
|
||||
public static boolean isStarted() {
|
||||
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.managers.ClientGsonManager;
|
||||
import pro.gravit.launcher.managers.ClientHookManager;
|
||||
import pro.gravit.launcher.modules.events.PostInitPhase;
|
||||
import pro.gravit.launcher.modules.events.PreConfigPhase;
|
||||
import pro.gravit.launcher.profiles.ClientProfile;
|
||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||
|
@ -55,6 +54,7 @@
|
|||
import pro.gravit.launcher.serialize.HOutput;
|
||||
import pro.gravit.launcher.serialize.stream.StreamObject;
|
||||
import pro.gravit.launcher.utils.DirWatcher;
|
||||
import pro.gravit.launcher.utils.NativeJVMHalt;
|
||||
import pro.gravit.utils.PublicURLClassLoader;
|
||||
import pro.gravit.utils.Version;
|
||||
import pro.gravit.utils.helper.CommonHelper;
|
||||
|
@ -463,6 +463,10 @@ public static void main(String... args) throws Throwable {
|
|||
LauncherEngine.modulesManager.initModules(null);
|
||||
initGson(LauncherEngine.modulesManager);
|
||||
//Launcher.modulesManager.preInitModules();
|
||||
if (!LauncherAgent.isStarted()) {
|
||||
NativeJVMHalt.haltA(100);
|
||||
return;
|
||||
}
|
||||
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
|
||||
JVMHelper.verifySystemProperties(ClientLauncher.class, true);
|
||||
EnvHelper.checkDangerousParams();
|
||||
|
|
Loading…
Reference in a new issue