security++, no more mixin leaking, also it launches now lol

This commit is contained in:
Daniella / Tove 2023-09-28 01:21:23 +02:00
parent 41510307da
commit e65e1e798d
Signed by: TudbuT
GPG key ID: 7D63D5634B7C417F
8 changed files with 54 additions and 40 deletions

View file

@ -29,11 +29,11 @@ import java.util.ArrayList;
@Mod(modid = "baseband")
public class BaseBand {
public static int majorVersion = 1;
public static int buildNumber = 230;
public static String hash = "ec94c2de63a0191e";
public static int buildNumber = 244;
public static String hash = "7e7800a2711492fc";
public static String name = "BaseBand";
public long timeOfCompile = 1695853741523L;
public long timeOfCompile = 1695856587011L;
public CommandManager commandRegistry;
public EventBus eventBus;
public ArrayList<Module> modules = new ArrayList<>();

View file

@ -1,6 +1,5 @@
package com.baseband.client.mixins;
import com.baseband.client.BaseBand;
import com.baseband.client.event.events.MoveEvent;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.entity.AbstractClientPlayer;
@ -21,9 +20,7 @@ public class MixinEntityPlayerSP extends AbstractClientPlayer {
@Redirect(method = "move", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/AbstractClientPlayer;move(Lnet/minecraft/entity/MoverType;DDD)V"))
public void move(AbstractClientPlayer abstractClientPlayer, MoverType type, double x, double y, double z) {
MoveEvent event = new MoveEvent(type, x, y, z);
BaseBand.INSTANCE.eventBus.publish(event);
MoveEvent event = MixinProxy.playerMove(type, x, y, z);
if(!event.isCancelled()) {
super.move(event.type, event.x, event.y, event.z);
}

View file

@ -1,6 +1,5 @@
package com.baseband.client.mixins;
import com.baseband.client.BaseBand;
import net.minecraft.client.Minecraft;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -14,7 +13,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinMinecraft {
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;checkGLError(Ljava/lang/String;)V", ordinal = 1, shift = At.Shift.AFTER))
private void onInit(CallbackInfo ci) {
new BaseBand();
BaseBand.INSTANCE.onInit();
MixinProxy.minecraftOnInit();
}
}

View file

@ -1,7 +1,5 @@
package com.baseband.client.mixins;
import com.baseband.client.BaseBand;
import com.baseband.client.event.events.PacketEvent;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
@ -15,20 +13,12 @@ public class MixinNetworkManager {
@Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true)
public void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_, CallbackInfo ci) {
PacketEvent.Read event = new PacketEvent.Read(p_channelRead0_2_);
BaseBand.INSTANCE.eventBus.publish(event);
if (event.isCancelled())
ci.cancel();
MixinProxy.networkChannelRead0(p_channelRead0_2_, ci);
}
@Inject(method = "sendPacket(Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
public void channelRead0(Packet<?> packetIn, CallbackInfo ci) {
PacketEvent.Write event = new PacketEvent.Write(packetIn);
BaseBand.INSTANCE.eventBus.publish(event);
if (event.isCancelled())
ci.cancel();
MixinProxy.networkSendPacket(packetIn, ci);
}
}

View file

@ -0,0 +1,38 @@
package com.baseband.client.mixins;
import com.baseband.client.BaseBand;
import com.baseband.client.event.events.MoveEvent;
import com.baseband.client.event.events.PacketEvent;
import net.minecraft.entity.MoverType;
import net.minecraft.network.Packet;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
public class MixinProxy {
public static void minecraftOnInit() {
new BaseBand();
BaseBand.INSTANCE.onInit();
}
public static void networkChannelRead0(Packet<?> p_channelRead0_2_, CallbackInfo ci) {
PacketEvent.Read event = new PacketEvent.Read(p_channelRead0_2_);
BaseBand.INSTANCE.eventBus.publish(event);
if (event.isCancelled())
ci.cancel();
}
public static void networkSendPacket(Packet<?> packetIn, CallbackInfo ci) {
PacketEvent.Write event = new PacketEvent.Write(packetIn);
BaseBand.INSTANCE.eventBus.publish(event);
if (event.isCancelled())
ci.cancel();
}
public static MoveEvent playerMove(MoverType type, double x, double y, double z) {
MoveEvent event = new MoveEvent(type, x, y, z);
BaseBand.INSTANCE.eventBus.publish(event);
return event;
}
}

View file

@ -91,19 +91,10 @@ public class CustomClassloader extends ClassLoader {
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);
//// TudbuT // using unsafe is a bad idea as it breaks DataKeeper
// try {
// Field b = Unsafe.class.getDeclaredField("theUnsafe");
// Unsafe unsafe = (Unsafe)b.get(null);
// Class<?> definedClass = unsafe.defineClass(name, data[0], 0, data[0].length, this, null);
if (definedClass == null) {
throw new ClassNotFoundException(name);
}
return definedClass;
// }catch (Exception e){
// return null;
// }
if (definedClass == null) {
throw new ClassNotFoundException(name);
}
return definedClass;
} else {
try {
return Launch.classLoader.findClass(name);
@ -127,7 +118,7 @@ public class CustomClassloader extends ClassLoader {
if(!accessControl.checkCaller(strictness)) {
accessControl.crash(strictness);
}
if (name.startsWith("com.baseband.client.mixin")) {
if (name.startsWith("com.baseband.client.mixin") || name.startsWith("com.baseband.client.event.events")) {
final byte[][] bytes = {null};
encryptedClasses.access(accessor -> Loader.classKey.access(classKey -> bytes[0] = classKey.getValue().decryptByte(accessor.getValue().get(name))));
if (bytes[0] != null) {
@ -142,7 +133,7 @@ public class CustomClassloader extends ClassLoader {
if(!accessControl.checkCaller(strictness)) {
accessControl.crash(strictness);
}
if (name.startsWith("com.baseband.client.mixin")) {
if (name.startsWith("com.baseband.client.mixin") || name.startsWith("com.baseband.client.event.events")) {
final byte[][] bytes = {null};
encryptedClasses.access(accessor -> Loader.classKey.access(classKey -> bytes[0] = classKey.getValue().decryptByte(accessor.getValue().get(name))));
if (bytes[0] != null) {

View file

@ -68,8 +68,8 @@ public class Loader {
objectKey = new DataKeeper<>(mainPermissionManager, defaultStrictness, new Key());
try {
//Socket socket = new Socket("127.0.0.1", 31212);
Socket socket = new Socket("88.208.243.108", 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());
DataOutputStream outputF = new DataOutputStream(socket.getOutputStream());

View file

@ -5,7 +5,7 @@ import de.tudbut.security.Strictness;
import de.tudbut.security.permissionmanager.Restriction;
public class MixinRestriction extends Restriction {
private static final String pkg = "org.spongepowered.mixin";
private static final String pkg = "org.spongepowered.asm.mixin.transformer";
public MixinRestriction(PermissionManager parent) {
super(parent);