mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-30 20:39:53 -05:00
Security Issue
This commit is contained in:
1 parent
55d50be632
commit
82fea053ce
4 files changed
+36
-27
No files matched your search
@@ -3,6 +3,7 @@ package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -25,15 +26,11 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
public void onPlayerCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
String rawCommand = event.getMessage(), command = rawCommand.replaceFirst("/", ""), worldName = world.getName();
|
||||
String rawCommand = event.getMessage(), command = rawCommand, worldName = world.getName();
|
||||
|
||||
if(command.contains(" ")) {
|
||||
String[] split = command.split(" ");
|
||||
if(split.length > 0) command = split[0];
|
||||
}
|
||||
|
||||
if(command.contains("\n"))
|
||||
command = command.replace("\n", "\\n");
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
command = StringUtils.getFirstArg(command);
|
||||
command = StringUtils.replace(command, "\\", "<", ">", "&");
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getName(), "%command%", command, "%world%", worldName);
|
||||
|
||||
@@ -63,7 +60,7 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED || rawCommand.equals("/")) return;
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", rawCommand.replaceFirst("/", ""));
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command);
|
||||
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
if(Storage.Blacklist.isListed(command, true)) return;
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@@ -24,15 +25,11 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
|
||||
String rawCommand = event.getMessage(), command = rawCommand.replaceFirst("/", "").toLowerCase();
|
||||
String rawCommand = event.getMessage(), command = rawCommand.toLowerCase();
|
||||
|
||||
if(command.contains(" ")) {
|
||||
String[] split = command.split(" ");
|
||||
if(split.length > 0) command = split[0];
|
||||
}
|
||||
|
||||
if(command.contains("\n"))
|
||||
command = command.replace("\n", "\\n");
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
command = StringUtils.getFirstArg(command);
|
||||
command = StringUtils.replace(command, "\\", "<", ">", "&");
|
||||
|
||||
if(rawCommand.equals("/")) return;
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
@@ -54,7 +51,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED) return;
|
||||
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", rawCommand.replaceFirst("/", ""));
|
||||
List<String> cancelCommandMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Settings.CANCEL_COMMAND.MESSAGE, "%command%", command);
|
||||
if(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
if(Storage.Blacklist.doesGroupBypass(player, command, true, player.getServer().getInfo().getName())) return;
|
||||
if(Storage.Blacklist.isListed(player, command, true, player.getServer().getInfo().getName())) return;
|
||||
|
||||
+4
-7
@@ -6,6 +6,7 @@ import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -31,13 +32,9 @@ public class VelocityBlockCommandListener {
|
||||
String command = event.getCommand(),
|
||||
serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
|
||||
|
||||
if(command.contains(" ")) {
|
||||
String[] split = command.split(" ");
|
||||
if(split.length > 0) command = split[0];
|
||||
}
|
||||
|
||||
if(command.contains("\n"))
|
||||
command = command.replace("\n", "\\n");
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
command = StringUtils.getFirstArg(command);
|
||||
command = StringUtils.replace(command, "\\", "<", ">", "&");
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(Storage.ConfigSections.Messages.NOTIFICATION.ALERT, "%player%", player.getUsername(), "%command%", command, "%server%", serverName);
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package de.rayzs.pat.utils;
|
||||
public class StringUtils {
|
||||
|
||||
public static String replaceFirst(String input, String trigger, String replacement) {
|
||||
if(input.contains(trigger)) {
|
||||
if (input.contains(trigger)) {
|
||||
String[] split = input.split(trigger);
|
||||
if(split.length >= 1) {
|
||||
if (split.length >= 1) {
|
||||
int pointAfter = split[0].length() + trigger.length();
|
||||
input = split[0] + replacement + input.substring(pointAfter);
|
||||
} else input = input.replace(trigger, replacement);
|
||||
@@ -13,4 +13,22 @@ public class StringUtils {
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
public static String replace(String input, String... triggers) {
|
||||
for (String trigger : triggers) {
|
||||
if(!input.contains(trigger)) continue;
|
||||
input = input.replace(trigger, "");
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
public static String getFirstArg(String input) {
|
||||
if(input.contains(" ")) {
|
||||
String[] split = input.split(" ");
|
||||
if(split.length > 0) input = split[0];
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user