improving word lists to make them all regex
This commit is contained in:
@@ -18,6 +18,15 @@ public class AdvancedConfig implements JsonSerializable<AdvancedConfig> {
|
|||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean pluginCloakingWhitelist = false;
|
||||||
|
|
||||||
|
public List<String> intendedCommands = Arrays.asList(
|
||||||
|
"tpa",
|
||||||
|
"msg",
|
||||||
|
"rtp"
|
||||||
|
);
|
||||||
|
|
||||||
public List<String> fakePlugins = Arrays.asList(
|
public List<String> fakePlugins = Arrays.asList(
|
||||||
"Nocheatplus",
|
"Nocheatplus",
|
||||||
"Negativity",
|
"Negativity",
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package me.trouper.sentinel.server.events.violations.players;
|
|||||||
import com.github.retrooper.packetevents.event.*;
|
import com.github.retrooper.packetevents.event.*;
|
||||||
import com.github.retrooper.packetevents.protocol.chat.Node;
|
import com.github.retrooper.packetevents.protocol.chat.Node;
|
||||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientChatCommand;
|
||||||
|
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientChatCommandUnsigned;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientTabComplete;
|
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientTabComplete;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDeclareCommands;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDeclareCommands;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerTabComplete;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerTabComplete;
|
||||||
@@ -15,32 +17,64 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
public class PluginCloakingPacket implements PacketListener {
|
public class PluginCloakingPacket implements PacketListener {
|
||||||
|
|
||||||
public static final List<UUID> tabReplaceQueue = new ArrayList<>();
|
public static final ConcurrentLinkedQueue<UUID> tabReplaceQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceive(PacketReceiveEvent event) {
|
public void onPacketReceive(PacketReceiveEvent event) {
|
||||||
if (!Sentinel.getInstance().getDirector().io.mainConfig.plugin.pluginHider) return;
|
if (!Sentinel.getInstance().getDirector().io.mainConfig.plugin.pluginHider) return;
|
||||||
if (event.getPacketType() != PacketType.Play.Client.TAB_COMPLETE) return;
|
switch (event.getPacketType()) {
|
||||||
|
case PacketType.Play.Client.TAB_COMPLETE -> {
|
||||||
|
WrapperPlayClientTabComplete wrapper = new WrapperPlayClientTabComplete(event);
|
||||||
|
Player player = (Player) event.getPlayer();
|
||||||
|
if (player == null) return;
|
||||||
|
if (PlayerUtils.isTrusted(player)) return;
|
||||||
|
|
||||||
WrapperPlayClientTabComplete wrapper = new WrapperPlayClientTabComplete(event);
|
String text = wrapper.getText();
|
||||||
Player player = (Player) event.getPlayer();
|
if (text.startsWith("/")) text = text.substring(1);
|
||||||
if (player == null) return;
|
text = text.split(" ")[0];
|
||||||
if (PlayerUtils.isTrusted(player)) return;
|
|
||||||
|
|
||||||
String text = wrapper.getText();
|
List<String> intendedCommands = Sentinel.getInstance().getDirector().io.advConfig.intendedCommands;
|
||||||
for (String versionAlias : Sentinel.getInstance().getDirector().io.advConfig.pluginTabCompletions) {
|
List<String> pluginTabCompletions = Sentinel.getInstance().getDirector().io.advConfig.pluginTabCompletions;
|
||||||
if (!text.contains(versionAlias)) continue;
|
|
||||||
ServerUtils.verbose("Caught a version command tab completion. (%s -> %s)".formatted(text,versionAlias));
|
if (Sentinel.getInstance().getDirector().io.advConfig.pluginCloakingWhitelist) {
|
||||||
tabReplaceQueue.add(player.getUniqueId());
|
boolean whitelisted = false;
|
||||||
break;
|
for (String pattern : intendedCommands) {
|
||||||
|
if (text.matches(pattern)) {
|
||||||
|
whitelisted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!whitelisted) {
|
||||||
|
ServerUtils.verbose("Caught a non-whitelisted tab completion. (%s)".formatted(text));
|
||||||
|
tabReplaceQueue.add(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String pattern : pluginTabCompletions) {
|
||||||
|
if (text.matches(pattern)) {
|
||||||
|
ServerUtils.verbose("Caught a plugin listing command tab completion. (%s -> %s)".formatted(text, pattern));
|
||||||
|
tabReplaceQueue.add(player.getUniqueId());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case PacketType.Play.Client.CHAT_COMMAND, PacketType.Play.Client.CHAT_COMMAND_UNSIGNED -> {
|
||||||
|
WrapperPlayClientChatCommandUnsigned wrapper = new WrapperPlayClientChatCommandUnsigned(event);
|
||||||
|
WrapperPlayClientChatCommand wrappers = new WrapperPlayClientChatCommand(event);
|
||||||
|
wrapper.getCommand();
|
||||||
|
wrappers.getCommand();
|
||||||
|
}
|
||||||
|
default -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSend(PacketSendEvent event) {
|
public void onPacketSend(PacketSendEvent event) {
|
||||||
if (!Sentinel.getInstance().getDirector().io.mainConfig.plugin.pluginHider) return;
|
if (!Sentinel.getInstance().getDirector().io.mainConfig.plugin.pluginHider) return;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ softdepend:
|
|||||||
- ViaBackwards
|
- ViaBackwards
|
||||||
- ViaRewind
|
- ViaRewind
|
||||||
- Geyser-Spigot
|
- Geyser-Spigot
|
||||||
|
- NoChatReports
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
permissions:
|
permissions:
|
||||||
sentinel.admin:
|
sentinel.admin:
|
||||||
|
|||||||
Reference in New Issue
Block a user