-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7ce57a
commit efe47d9
Showing
8 changed files
with
60 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 25 additions & 60 deletions
85
...in/java/net/kyrptonaught/serverutils/mixin/personatus/ServerLoginNetworkHandlerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,48 @@ | ||
package net.kyrptonaught.serverutils.mixin.personatus; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import com.mojang.authlib.yggdrasil.ProfileResult; | ||
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; | ||
import com.mojang.util.UndashedUuid; | ||
import net.fabricmc.fabric.mixin.networking.accessor.ServerLoginNetworkHandlerAccessor; | ||
import net.kyrptonaught.serverutils.personatus.PersonatusModule; | ||
import net.minecraft.network.packet.c2s.login.LoginHelloC2SPacket; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.kyrptonaught.serverutils.personatus.PersonatusProfile; | ||
import net.minecraft.server.network.ServerLoginNetworkHandler; | ||
import org.objectweb.asm.Opcodes; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ServerLoginNetworkHandler.class) | ||
public class ServerLoginNetworkHandlerMixin { | ||
import java.util.UUID; | ||
|
||
@Shadow | ||
GameProfile profile; | ||
|
||
@Final | ||
@Shadow | ||
MinecraftServer server; | ||
|
||
private boolean profileChecked = false; | ||
@Mixin(targets = "net.minecraft.server.network.ServerLoginNetworkHandler$1") | ||
public abstract class ServerLoginNetworkHandlerMixin { | ||
|
||
|
||
@Inject(method = "onHello", at = @At(value = "FIELD", target = "Lnet/minecraft/server/network/ServerLoginNetworkHandler;profileName:Ljava/lang/String;", opcode = Opcodes.PUTFIELD, shift = At.Shift.AFTER)) | ||
public void requestSpoof(LoginHelloC2SPacket packet, CallbackInfo ci) { | ||
if (!PersonatusModule.isEnabled()) { | ||
profileChecked = true; | ||
} | ||
|
||
/* | ||
new Thread(() -> { | ||
if (server.getSessionService() instanceof YggdrasilMinecraftSessionService sessionService) { | ||
String responseName = PersonatusModule.URLGetValue(false, "kvs/get/personatus/" + profile.getName(), "value"); | ||
@Shadow | ||
@Final | ||
ServerLoginNetworkHandler field_14176; | ||
|
||
@Redirect(method = "run", at = @At(value = "INVOKE", target = "Lcom/mojang/authlib/yggdrasil/ProfileResult;profile()Lcom/mojang/authlib/GameProfile;")) | ||
public GameProfile requestSpoof(ProfileResult instance) { | ||
if (PersonatusModule.isEnabled()) { | ||
GameProfile oldProfile = instance.profile(); | ||
if (((ServerLoginNetworkHandlerAccessor)field_14176).getServer().getSessionService() instanceof YggdrasilMinecraftSessionService sessionService) { | ||
String responseName = PersonatusModule.URLGetValue(false, "kvs/get/personatus/" + oldProfile.getName(), "value"); | ||
if (responseName != null) { | ||
String responseUUID = PersonatusModule.URLGetValue(true, "https://api.mojang.com/users/profiles/minecraft/" + responseName, "id"); | ||
if (responseUUID != null) { | ||
UUID uuid = UUIDTypeAdapter.fromString(responseUUID); | ||
GameProfile spoofed = sessionService.fillProfileProperties(new GameProfile(uuid, responseName), true); | ||
UUID uuid = UndashedUuid.fromString(responseUUID); | ||
GameProfile spoofed = sessionService.fetchProfile(uuid, true).profile(); | ||
|
||
((PersonatusProfile) spoofed).setRealProfile(profile); | ||
profile = spoofed; | ||
((PersonatusProfile) spoofed).setRealProfile(oldProfile); | ||
return spoofed; | ||
} | ||
} | ||
} | ||
profileChecked = true; | ||
}).start(); | ||
*/ | ||
} | ||
|
||
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerLoginNetworkHandler;sendSuccessPacket(Lcom/mojang/authlib/GameProfile;)V"), cancellable = true) | ||
public void delayAcceptUntilCheck(CallbackInfo ci) { | ||
if (!PersonatusModule.isEnabled()) return; | ||
if (!profileChecked) | ||
ci.cancel(); | ||
} | ||
|
||
/* | ||
@Inject(method = "getVerifiedPublicKey", at = @At("HEAD"), cancellable = true) | ||
private static void noKey4u(PlayerPublicKey.PublicKeyData publicKeyData, UUID playerUuid, SignatureVerifier servicesSignatureVerifier, boolean shouldThrowOnMissingKey, CallbackInfoReturnable<PlayerPublicKey> cir) { | ||
cir.setReturnValue(null); | ||
} | ||
@Dynamic("Fabric Proxy Mixin") | ||
@Inject(method = "setRealUUID", at = @At("HEAD"), cancellable = true, require = 0) | ||
public void stopThatFabricProxyItsverysilly(UUID uuid, CallbackInfo ci) { | ||
if (PersonatusModule.isEnabled()) | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Dynamic("Fabric Proxy Mixin") | ||
@Inject(method = "setProfile", at = @At("HEAD"), cancellable = true, require = 0) | ||
public void stopThatFabricProxyItsverysilly2(GameProfile profile, CallbackInfo ci) { | ||
if (PersonatusModule.isEnabled()) | ||
ci.cancel(); | ||
return instance.profile(); | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters