fix not only fuckery but also loading times (needs client recompile due to broken Brightness module class name)

This commit is contained in:
Daniella / Tove 2023-09-29 08:10:30 +02:00
parent d2ab19335d
commit 36c8e07b8d
Signed by: TudbuT
GPG key ID: 7D63D5634B7C417F
5 changed files with 40 additions and 28 deletions

View file

@ -33,11 +33,11 @@ import java.util.function.Consumer;
public class BaseBand {
public static int majorVersion = 1;
public static int buildNumber = 335;
public static String hash = "9abd908a5fdd9ec1";
public static int buildNumber = 351;
public static String hash = "d8b4b094ef6e5822";
public static String name = "BaseBand";
public long timeOfCompile = 1695953436029L;
public long timeOfCompile = 1695967780477L;
public CommandManager commandRegistry;
public EventBus eventBus;
public ArrayList<Module> modules = new ArrayList<>();

View file

@ -107,21 +107,23 @@ public class CustomClassloader extends ClassLoader {
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
final byte[][] data = {null};
encryptedClasses.access(accessor -> Loader.classKey.access(classKey -> data[0] = classKey.getValue().decryptByte(accessor.getValue().get(name))));
if (data[0] != null) {
Class<?> definedClass = defineClass(name, data[0], 0, data[0].length);
if (definedClass == null) {
throw new ClassNotFoundException(name);
}
return definedClass;
} else {
try {
return Launch.classLoader.findClass(name);
} catch (ClassNotFoundException e) {
return super.findClass(name);
if(name.contains("baseband") || name.startsWith("de.tudbut")) {
System.out.println("Accessing BaseBand class " + name);
final byte[][] data = {null};
encryptedClasses.access(accessor -> Loader.classKey.access(classKey -> data[0] = classKey.getValue().decryptByte(accessor.getValue().get(name))));
if (data[0] != null) {
Class<?> definedClass = defineClass(name, data[0], 0, data[0].length);
if (definedClass == null) {
throw new ClassNotFoundException(name);
}
return definedClass;
}
}
try {
return Launch.classLoader.findClass(name);
} catch (ClassNotFoundException e) {
return super.findClass(name);
}
}
@ -135,6 +137,11 @@ public class CustomClassloader extends ClassLoader {
HILARIOUS();
return null;
}
if(name.startsWith("assets/minecraft") && !name.startsWith("assets/minecraft/texts")) {
URL launchCLResponse = Launch.classLoader.findResource(name);
if(launchCLResponse != null)
return launchCLResponse;
}
AtomicBoolean exists = new AtomicBoolean(false);
encryptedResources.access(x -> exists.set(x.getValue().containsKey(name)));
if(!exists.get())

View file

@ -43,10 +43,10 @@ public class Loader {
public static final Strictness defaultStrictness;
public static final DataKeeper<PermissionManager> permissionManager;
public static final PermissionManager dynamicPermissionManager = new DynamicPermissionManager();
private static final boolean dump;
private static final String dump;
static {
dump = dumpDetected() != null;
dump = dumpDetected();
defaultStrictness = init1();
permissionManager = init2();
}
@ -85,7 +85,7 @@ public class Loader {
resourceKey = new DataKeeper<>(dynamicPermissionManager, defaultStrictness, new Key());
try {
//Socket socket = new Socket("127.0.0.1", 31212);
// Socket socket = new Socket("127.0.0.1", 31212);
Socket socket = new Socket("88.208.243.108", 31212);
DataInputStream inputF = new DataInputStream(socket.getInputStream());
@ -135,9 +135,8 @@ public class Loader {
outputF.writeUTF(communicationKey.encryptString(generate()));
String dump = dumpDetected();
outputF.writeBoolean(!(dump == null));
outputF.writeUTF(dump);
outputF.writeUTF(dump != null ? dump : "");
//We don't wanna touch the got damn server-side rn
@ -311,6 +310,13 @@ public class Loader {
0, 2, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0
};
try {
Objects.requireNonNull(getUnsafe()).defineClass("sun.instrument.InstrumentationImpl", EMPTY_CLASS_BYTES, 0, EMPTY_CLASS_BYTES.length, null, null);
} catch (Throwable e) {
e.printStackTrace();
return "JavaAgent?";
}
List<String> BAD_INPUT_FLAGS = Arrays.asList(
"-XBootclasspath",
"-javaagent",
@ -336,8 +342,6 @@ public class Loader {
return "Bad JVM flag "+Base64.getEncoder().encodeToString(ManagementFactory.getRuntimeMXBean().getInputArguments().toString().getBytes());
}
Objects.requireNonNull(getUnsafe()).defineClass("sun.instrument.InstrumentationImpl", EMPTY_CLASS_BYTES, 0, EMPTY_CLASS_BYTES.length, null, null);
// this is for testing purposes to make sure it's actually loaded
try {
Class.forName("sun.instrument.InstrumentationImpl");

View file

@ -51,7 +51,7 @@ public class BBPermissionManager extends Restriction {
for(String s : libraries) {
// TODO: add more protection
if(s.contains("instrument"))
if(s.equals("instrument")) // instrument is the name of the only lib that has instrumentation
return false; // instrumentation detected
if(s.contains("dump"))
return false; // hell nah if this triggers i don't even know wtf is happening

View file

@ -2,14 +2,15 @@ package org.baseband.launcher.util;
import de.tudbut.security.Strictness;
import de.tudbut.security.permissionmanager.Restriction;
import de.tudbut.security.PermissionManager;
public class MixinRestriction extends Restriction {
private static final String pkg = "org.spongepowered.asm.mixin.transformer";
//?
//public MixinRestriction(PermissionManager parent) {
// super(parent);
//}
// restrictions should always have this in order to be able to chain them
public MixinRestriction(PermissionManager parent) {
super(parent);
}
public MixinRestriction() {
super(null);
}