mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-12-01 04:49:44 -05:00
Fix Spoof-Exploit
This commit is contained in:
1 parent
161dc98b90
commit
2a356c8bd2
3 files changed
+40
-36
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package de.rayzs.pat.plugin.netty;
|
||||
|
||||
import de.rayzs.pat.plugin.netty.handlers.LegacyPacketHandler;
|
||||
import de.rayzs.pat.plugin.netty.handlers.ModernPacketHandler;
|
||||
import de.rayzs.pat.utils.PermissionUtil;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.Storage;
|
||||
@@ -14,6 +16,7 @@ public class PacketAnalyzer {
|
||||
|
||||
public static final ConcurrentHashMap<UUID, Channel> INJECTED_PLAYERS = new ConcurrentHashMap<>();
|
||||
public static final String CHANNEL_NAME = "pat-packethandler", HANDLER_NAME = "packet_handler";
|
||||
private static final PacketHandler PACKET_HANDLER = Reflection.getMinor() >= 18 ? new ModernPacketHandler() : new LegacyPacketHandler();
|
||||
|
||||
public static void injectAll() {
|
||||
Bukkit.getOnlinePlayers().forEach(PacketAnalyzer::inject);
|
||||
@@ -25,7 +28,6 @@ public class PacketAnalyzer {
|
||||
}
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
if(Reflection.getMinor() >= 18) return true;
|
||||
try {
|
||||
Channel channel = Reflection.getPlayerChannel(player);
|
||||
if(channel == null) {
|
||||
@@ -42,7 +44,6 @@ public class PacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(UUID uuid) {
|
||||
if(Reflection.getMinor() >= 18) return;
|
||||
if(PacketAnalyzer.INJECTED_PLAYERS.containsKey(uuid)) {
|
||||
Channel channel = PacketAnalyzer.INJECTED_PLAYERS.get(uuid);
|
||||
if(channel != null) {
|
||||
@@ -57,8 +58,8 @@ public class PacketAnalyzer {
|
||||
|
||||
private static class PacketDecoder extends ChannelDuplexHandler {
|
||||
|
||||
Player player;
|
||||
PacketDecoder(Player player) {
|
||||
private final Player player;
|
||||
private PacketDecoder(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@@ -67,40 +68,11 @@ public class PacketAnalyzer {
|
||||
try {
|
||||
if (!player.hasPermission("proantitab.bypass") && packetObj.getClass() != null) {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
if (packetName.equals("PacketPlayOutTabComplete")) {
|
||||
for (Field field : Reflection.getFields(packetObj)) {
|
||||
field.setAccessible(true);
|
||||
Object result = field.get(packetObj);
|
||||
if (packetName.equals("PacketPlayOutTabComplete"))
|
||||
PACKET_HANDLER.handlePacket(player, packetObj);
|
||||
|
||||
if (!(result instanceof String[])) continue;
|
||||
List<String> newResultList = new ArrayList<>();
|
||||
String[] tR = (String[]) result;
|
||||
|
||||
String tempName;
|
||||
|
||||
for (String s : tR) {
|
||||
tempName = s.replaceFirst("/", "");
|
||||
|
||||
if(Storage.TURN_BLACKLIST_TO_WHITELIST) {
|
||||
if(!Storage.isCommandBlockedPrecise(tempName)) continue;
|
||||
if(PermissionUtil.hasBypassPermission(player, tempName)) continue;
|
||||
newResultList.add(s);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tempName.contains(":")) tempName = tempName.split(":")[1];
|
||||
|
||||
if (!Storage.isCommandBlocked(tempName)
|
||||
|| Storage.isCommandBlocked(tempName)
|
||||
&& PermissionUtil.hasBypassPermission(player, tempName))
|
||||
newResultList.add(s);
|
||||
}
|
||||
|
||||
field.set(packetObj, newResultList.toArray(new String[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) { }
|
||||
} catch (Throwable exception) { exception.printStackTrace(); }
|
||||
super.write(channel, packetObj, promise);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package de.rayzs.pat.plugin.netty;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface PacketHandler {
|
||||
|
||||
void handlePacket(Player player, Object packetObj) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.rayzs.pat.plugin.netty.handlers;
|
||||
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import de.rayzs.pat.plugin.netty.PacketHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.lang.reflect.Field;
|
||||
import de.rayzs.pat.utils.*;
|
||||
|
||||
public class ModernPacketHandler implements PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handlePacket(Player player, Object packetObj) throws Exception {
|
||||
Field suggestionsField = Reflection.getFirstFieldByType(packetObj.getClass(), "Suggestions", Reflection.SearchOption.ENDS);
|
||||
if(suggestionsField == null) return;
|
||||
|
||||
Suggestions suggestions = (Suggestions) suggestionsField.get(packetObj);
|
||||
suggestions.getList().removeIf(suggestion -> {
|
||||
String command = suggestion.getText();
|
||||
if(Storage.TURN_BLACKLIST_TO_WHITELIST)
|
||||
return !Storage.isCommandBlockedPrecise(command) && !PermissionUtil.hasBypassPermission(player, command);
|
||||
else return Storage.isCommandBlocked(command) && !PermissionUtil.hasBypassPermission(player, command);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user