fix: support obfuscated clients via detection, Loader ASM relocation and remapper exclude

This commit is contained in:
xiaozhou233 committed 2026-08-20 11:34:25 +08:00
1 parent 6eb9ca8240
commit b3e7000bf0
7 files changed
+126 -12

No files matched your search

+1
View File
@@ -17,4 +17,5 @@ dependencies {
shadowJar {
archiveFileName = 'Loader.jar'
relocate 'org.objectweb.asm', 'cn.xiaozhou233.asm9'
}
@@ -0,0 +1,52 @@
package cn.xiaozhou233.orangex.loader;
public class Detector {
private static boolean classExists(String className) {
String resourceName = className.replace('.', '/') + ".class";
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = Detector.class.getClassLoader();
}
return classLoader.getResource(resourceName) != null;
}
public static DetectorType detect() {
// Lunar Client Detection
if (classExists("com.moonsworth.lunar.genesis.Genesis")) {
System.out.println("Lunar class found!");
return DetectorType.LUNAR;
}
System.out.println("Lunar class not found");
// Badlion Detection
if (classExists("net.badlion.client.Wrapper")) {
System.out.println("Badlion class found!");
return DetectorType.BADLION;
}
System.out.println("Badlion class not found");
// MCP Detection
if (classExists("net.minecraft.client.Minecraft")) {
System.out.println("MCP class found!");
return DetectorType.MCP;
}
System.out.println("MCP class not found");
// Vanilla Detection
if (classExists("ave")) {
System.out.println("Vanilla class found!");
return DetectorType.VANILLA;
}
System.out.println("Vanilla class not found");
return DetectorType.UNKNOWN;
}
}
@@ -0,0 +1,9 @@
package cn.xiaozhou233.orangex.loader;
public enum DetectorType {
BADLION,
LUNAR,
VANILLA,
MCP,
UNKNOWN
}
@@ -4,6 +4,7 @@ package cn.xiaozhou233.orangex.loader;
import cn.xiaozhou233.juiceagent.api.JuiceAgent;
import cn.xiaozhou233.juiceremapper.JuiceRemapper;
import javax.swing.*;
import java.io.File;
public class Loader {
@@ -31,17 +32,34 @@ public class Loader {
// Check Obfuscation
// Only Check MCP or Vanilla Obfuscation
try {
Class.forName("ave");
System.out.println("Obfuscation detected");
// Load JuiceRemapper Native
System.load(new File(userDir, "/.orangex/libremapper.dll").getAbsolutePath());
switch (Detector.detect()) {
case MCP:
break;
case VANILLA:
System.load(new File(userDir, "/.orangex/libremapper.dll").getAbsolutePath());
JuiceRemapper.init();
JuiceRemapper.addInclude("cn/xiaozhou233/orangex/");
JuiceRemapper.addExclude("cn/xiaozhou233/orangex/mixin/");
break;
case LUNAR:
break;
case BADLION:
System.load(new File(userDir, "/.orangex/libremapper.dll").getAbsolutePath());
JuiceRemapper.init();
JuiceRemapper.addInclude("cn/xiaozhou233/orangex/");
JuiceRemapper.addExclude("cn/xiaozhou233/orangex/mixin/");
break;
case UNKNOWN:
JOptionPane.showMessageDialog(
null,
"Inject Failed! Cause: Unknown Obfuscation",
"Unknown Obfuscation",
JOptionPane.ERROR_MESSAGE
);
throw new IllegalStateException("Unknown Obfuscation");
JuiceRemapper.init();
JuiceRemapper.addInclude("cn/xiaozhou233/orangex/");
JuiceRemapper.addExclude("cn/xiaozhou233/orangex/mixin");
} catch (ClassNotFoundException e) {
System.out.println("Obfuscation not detected");
}