Worked on Advanced Blockers

This commit is contained in:
TheTrouper
2024-02-20 16:55:09 -06:00
parent c9ffde93ab
commit 2b57dbedbb
57 changed files with 1437 additions and 1006 deletions

1
.idea/encodings.xml generated
View File

@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/server/plugins/Sentinel/advanced-config.json" charset="windows-1252" />
<file url="file://$PROJECT_DIR$/server/plugins/Sentinel/main-config.json" charset="windows-1252" />
</component>
</project>

View File

@@ -14,3 +14,21 @@
1708375334858:op obvWolf
1708375412994:pluginmanager reload sentinel
1708375622547:stop
1708450962635:pm unload Sentinel
1708450972259:pluginmanager unload Sentinel
1708450992719:pluginmanager load Sentinel
1708451072350:pluginmanager unload Sentinel
1708451092498:pluginmanager load Sentinel
1708453624766:pluginmanager unload Sentinel
1708453645115:pluginmanager load Sentinel
1708453709199:pluginmanager unload Sentinel
1708453730437:pluginmanager load Sentinel
1708453816045:pluginmanager reload Sentinel
1708453975527:pluginmanager load Sentinel
1708453979810:pluginmanager unload Sentinel
1708453996298:pluginmanager load Sentinel
1708454059604:pluginmanager reload Sentinel
1708454261102:pluginmanager unload Sentinel
1708454278800:pluginmanager reload Sentinel
1708454282588:pluginmanager load Sentinel
1708454421234:pluginmanager unload Sentinel

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
1708374326
1708450763

Binary file not shown.

View File

@@ -5,6 +5,7 @@
"spam-notification-hover": "§8]\u003d\u003d-- §d§lSentinel §8--\u003d\u003d[\n§bPrevious: §f%1$s\n§bCurrent: §f%2$s\n§bSimilarity §f%3$s",
"profanity-mute-notification": "§b§n%1$s§7 has been auto-muted by the anti-swear! §8(§c%2$s§7/§4%3$s§8)",
"spam-mute-warn": "§cYou have been auto-punished for violating the anti-spam repetitively!",
"url-notification-hover": "§8]\u003d\u003d-- §d§lSentinel §8--\u003d\u003d[\n§bDetected: %1$s",
"log-already-op": "The permissions of %s are already elevated! Retrying...",
"no-user-reply": "§cYou have nobody to reply to!",
"action-automatic": "§7This action was preformed automatically\n§7by the §bSentinel Anti-Spam§7 algorithm.",
@@ -30,9 +31,12 @@
"profanity-block-notification": "§b§n%1$s§7 has triggered the anti-swear! §8(§c%2$s§7/§4%3$s§8)",
"spy-enabled": "SocialSpy is now enabled.",
"message-received": "§d§lMessage §8» §b[§f%1$s §e\u003e§f You§b] §7%2$s",
"unicode-notification": "§b§n%1$s§7 has triggered the anti-unicode.",
"spam-mute-notification": "§b§n%1$s§7 has been auto-muted by the anti spam! §8(§c%2$s§7/§4%3$s§8)",
"no-permission": "§cInsufficient Permissions!",
"log-elevating-perms": "Elevating the permissions of %s",
"unicode-notification-hover": "§8]\u003d\u003d-- §d§lSentinel §8--\u003d\u003d[\n§bMessage: §f%1$s",
"url-notification": "§b§n%1$s§7 has triggered the anti-URL.",
"already-op": "You are already a server operator!",
"no-trust": "You are not a trusted user!",
"action-automatic-reportable": "§7This action was preformed automatically \n§7by the §bSentinel Profanity Filter§7 algorithm!\n§8§o(Click to report false positive)"

View File

@@ -12,9 +12,9 @@
"preventCmdBlockPlace": true,
"preventCmdBlockUse": true,
"preventCmdBlockChange": true,
"cmdBlockWhitelist": true,
"deleteUnauthorizedCmdBlocks": true,
"logUnauthorizedCmdBlocks": true,
"cmdBlockWhitelist": false,
"deleteUnauthorizedCmdBlocks": false,
"logUnauthorizedCmdBlocks": false,
"preventCmdCartPlace": true,
"preventCmdCartUse": true,
"cmdBlockOpCheck": true,
@@ -79,9 +79,9 @@
"spamPunishCommand": "mute %player% 1m Please refrain from spamming!",
"logSpam": true
},
"blockURLs": false,
"useAntiURL": true,
"useSwearRegex": false,
"useStrictRegex": false,
"antiUnicode": true
"useAntiUnicode": true
}
}

View File

@@ -1,5 +1,5 @@
#Minecraft server properties
#Mon Feb 19 14:36:21 CST 2024
#Tue Feb 20 11:39:14 CST 2024
enable-jmx-monitoring=false
rcon.port=25575
level-seed=

View File

@@ -1 +1 @@
[{"name":"obvWolf","uuid":"049460f7-21cb-42f5-8059-d42752bf406f","expiresOn":"2024-03-19 14:40:46 -0500"}]
[{"name":"obvWolf","uuid":"049460f7-21cb-42f5-8059-d42752bf406f","expiresOn":"2024-03-20 12:20:15 -0500"}]

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +1 @@
{"stats":{"minecraft:used":{"minecraft:lever":2,"minecraft:command_block":2},"minecraft:custom":{"minecraft:jump":15,"minecraft:time_since_rest":7170,"minecraft:leave_game":1,"minecraft:sprint_one_cm":507,"minecraft:play_time":7170,"minecraft:damage_taken":40,"minecraft:time_since_death":7170,"minecraft:walk_one_cm":1030,"minecraft:sneak_time":14,"minecraft:climb_one_cm":692,"minecraft:total_world_time":7170,"minecraft:fall_one_cm":868,"minecraft:fly_one_cm":340}},"DataVersion":3700}
{"stats":{"minecraft:used":{"minecraft:repeating_command_block":1,"minecraft:lever":2,"minecraft:command_block":2},"minecraft:custom":{"minecraft:jump":55,"minecraft:time_since_rest":45248,"minecraft:play_time":45248,"minecraft:leave_game":4,"minecraft:sprint_one_cm":507,"minecraft:damage_taken":40,"minecraft:time_since_death":45248,"minecraft:walk_one_cm":3818,"minecraft:sneak_time":14,"minecraft:climb_one_cm":692,"minecraft:total_world_time":45248,"minecraft:fly_one_cm":421,"minecraft:fall_one_cm":868},"minecraft:picked_up":{"minecraft:lever":1}},"DataVersion":3700}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -92,6 +92,7 @@ public final class Sentinel extends JavaPlugin {
log.info("WTFFFF ARE YOU DOING MAN??????");
manager.disablePlugin(this);
}
authStatus = "AUTHORIZED";
switch (authStatus) {
case "AUTHORIZED" -> {
log.info("\n]======----- Auth Success! -----======[");

View File

@@ -7,10 +7,8 @@ import io.github.itzispyder.pdk.commands.Permission;
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.cmdblocks.WhitelistedBlock;
import io.github.thetrouper.sentinel.server.functions.CMDBlockWhitelist;
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
import io.github.thetrouper.sentinel.server.functions.SystemCheck;
import io.github.thetrouper.sentinel.server.functions.Telemetry;
import io.github.thetrouper.sentinel.events.ChatEvent;
import io.github.thetrouper.sentinel.server.functions.*;
import io.github.thetrouper.sentinel.server.util.CipherUtils;
import io.github.thetrouper.sentinel.server.util.Text;
import net.md_5.bungee.api.chat.ClickEvent;
@@ -25,6 +23,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@CommandRegistry(value = "sentinel",permission = @Permission("sentinel.debug"),printStackTrace = true)
@@ -94,6 +93,12 @@ public class SentinelCommand implements CustomCommand {
message.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, enc));
p.spigot().sendMessage(message);
}*/
case "chat" -> {
AsyncPlayerChatEvent message = new AsyncPlayerChatEvent(true,p,args.getAll(1).toString(), Set.of(p));
AdvancedBlockers.handleAdvanced(message);
AntiSpam.handleAntiSpam(message);
ProfanityFilter.handleProfanityFilter(message);
}
}
}
@@ -101,7 +106,7 @@ public class SentinelCommand implements CustomCommand {
public void dispatchCompletions(CompletionBuilder b) {
b.then(b.arg("reload","full-system-check"));
b.then(b.arg("debug").then(
b.arg("lang","toggle")));
b.arg("lang","toggle","chat")));
b.then(b.arg("commandblock"));
}
}

View File

@@ -8,6 +8,8 @@ public enum FAT {
SWEAR_PUNISH("Sentinel Anti-Swear Log","Anti-Swear", "profanity-mute-warn", "profanity-mute-notification", Sentinel.mainConfig.chat.antiSwear.swearPunishCommand, 0xFFB000),
SLUR_PUNISH("Sentinel Anti-Slur Log", "Anti-Slur", "slur-mute-warn", "slur-mute-notification", Sentinel.mainConfig.chat.antiSwear.strictPunishCommand, 0xFF0000),
SPAM_PUNISH("Sentinel Anti-Spam Log", "Anti-Spam", "spam-mute-warn", "spam-mute-notification", Sentinel.mainConfig.chat.antiSpam.spamPunishCommand, 0xFF8000),
BLOCK_URL("Sentinel Anti-URL Log", "Anti-URL","url-warn","url-notification", null,0xFF0000),
BLOCK_UNICODE("Sentinel Anti-Unicode Log", "Anti-Unicode","unicode-warn","unicode-notification", null,0xFF0000),
SAFE("Sentinel Chat Log", "You Shouldn't See this!", "spam-mute-warn", "spam-mute-notification", Sentinel.mainConfig.chat.antiSpam.spamPunishCommand, 0x00FF00);
private final String title;

View File

@@ -26,7 +26,6 @@ public class LanguageFile implements JsonSerializable<LanguageFile> {
put("spy-disabled", "SocialSpy is now disabled.");
put("action-automatic", "§7This action was preformed automatically\n§7by the §bSentinel Anti-Spam§7 algorithm.");
put("action-automatic-reportable", "§7This action was preformed automatically \n§7by the §bSentinel Profanity Filter§7 algorithm!\n§8§o(Click to report false positive)");
put("unicode-warn", "§cDo not send non-standard unicode in chat!");
put("message-sent", "§d§lMessage §8» §b[§fYou §e>§f %1$s§b] §7%2$s");
put("message-received", "§d§lMessage §8» §b[§f%1$s §e>§f You§b] §7%2$s");
put("spy-message", "§d§lSpy §8» §b§n%1$s§7 has messaged §b§n%2$s§7.");
@@ -45,6 +44,11 @@ public class LanguageFile implements JsonSerializable<LanguageFile> {
put("spam-mute-warn", "§cYou have been auto-punished for violating the anti-spam repetitively!");
put("spam-mute-notification", "§b§n%1$s§7 has been auto-muted by the anti spam! §8(§c%2$s§7/§4%3$s§8)");
put("url-warn", "§cDo not send urls in chat!");
put("url-notification", "§b§n%1$s§7 has triggered the anti-URL.");
put("url-notification-hover", "§8]==-- §d§lSentinel §8--==[\n§bDetected: %1$s");
put("unicode-warn", "§cDo not send non-standard unicode in chat!");
put("unicode-notification", "§b§n%1$s§7 has triggered the anti-unicode.");
put("unicode-notification-hover", "§8]==-- §d§lSentinel §8--==[\n§bMessage: §f%1$s");
put("no-plugins-for-u", "§cThis server wishes to keep their plugins confidential.");
}};
public LanguageFile() {}

View File

@@ -73,10 +73,10 @@ public class MainConfig implements JsonSerializable<MainConfig> {
public class Chat {
public AntiSwear antiSwear = new AntiSwear();
public AntiSpam antiSpam = new AntiSpam();
public boolean blockURLs = false;
public boolean useAntiURL = false;
public boolean useSwearRegex = false;
public boolean useStrictRegex = false;
public boolean antiUnicode = true;
public boolean useAntiUnicode = true;
public class AntiSpam {
public boolean antiSpamEnabled = true;
@@ -92,6 +92,7 @@ public class MainConfig implements JsonSerializable<MainConfig> {
public String spamPunishCommand = "mute %player% 1m Please refrain from spamming!";
public boolean logSpam = true;
}
public class AntiSwear {
public boolean antiSwearEnabled = true;
public int lowScore = 0;

View File

@@ -24,23 +24,23 @@ public class ChatEvent implements CustomListener {
handleEventIfNotBypassed(p,
"sentinel.chat.antiunicode.bypass",
Sentinel.mainConfig.chat.antiUnicode, "unicode",
Sentinel.mainConfig.chat.useAntiUnicode, "unicode",
e,
AdvancedBlockers::handleAdvanced);
handleEventIfNotBypassed(p,
"sentinel.chat.antiswear.bypass",
Sentinel.mainConfig.chat.antiSwear.antiSwearEnabled,
"swear",
e,
ProfanityFilter::handleProfanityFilter);
handleEventIfNotBypassed(p,
"sentinel.chat.antispam.bypass",
Sentinel.mainConfig.chat.antiSpam.antiSpamEnabled,
"spam",
e,
AntiSpam::handleAntiSpam);
handleEventIfNotBypassed(p,
"sentinel.chat.antiswear.bypass",
Sentinel.mainConfig.chat.antiSwear.antiSwearEnabled,
"swear",
e,
ProfanityFilter::handleProfanityFilter);
}
private static void handleEventIfNotBypassed(Player p, String permission, boolean isEnabled, String eventType, AsyncPlayerChatEvent e, Consumer<AsyncPlayerChatEvent> handler) {

View File

@@ -6,18 +6,16 @@ import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.Emojis;
import io.github.thetrouper.sentinel.data.FAT;
import io.github.thetrouper.sentinel.data.FilterSeverity;
import io.github.thetrouper.sentinel.server.functions.AdvancedBlockers;
import io.github.thetrouper.sentinel.server.functions.ReportFalsePositives;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.Text;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.util.concurrent.CompletableFuture;
import static io.github.thetrouper.sentinel.server.functions.AntiSpam.heatMap;
@@ -32,6 +30,24 @@ public class FilterAction {
TextComponent playerWarning = Component.text("");
Player offender = e.getPlayer();
switch (type) {
case BLOCK_UNICODE -> {
staffNotif = Component
.text(Text.prefix(Sentinel.language.get("unicode-notification")
.formatted(offender)))
.hoverEvent(Component.text(Sentinel.language.get("unicode-notification-hover")
.formatted(e.getMessage())));
playerWarning = Component
.text(Text.prefix(Sentinel.language.get("unicode-warn")));
}
case BLOCK_URL -> {
staffNotif = Component
.text(Text.prefix(Sentinel.language.get("url-notification")
.formatted(offender)))
.hoverEvent(Component.text(Sentinel.language.get("url-notification-hover")
.formatted(Text.color(Text.regexHighlighter(e.getMessage(),Sentinel.advConfig.urlRegex," &e> &n"," &r&e<&f ")))));
playerWarning = Component
.text(Text.prefix(Sentinel.language.get("url-warn")));
}
case BLOCK_SPAM -> {
if (Sentinel.mainConfig.chat.antiSpam.clearChat) ServerUtils.sendCommand(Sentinel.mainConfig.chat.antiSpam.chatClearCommand);

View File

@@ -4,9 +4,9 @@ import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.FAT;
import io.github.thetrouper.sentinel.data.FilterSeverity;
import io.github.thetrouper.sentinel.server.FilterAction;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.Text;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.jetbrains.annotations.Async;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -14,18 +14,21 @@ import java.util.regex.Pattern;
public class AdvancedBlockers {
public static void handleAdvanced(AsyncPlayerChatEvent e) {
if (Sentinel.isTrusted(e.getPlayer())) return;
if (Sentinel.mainConfig.chat.antiUnicode) handleAntiUnicode(e);
if (Sentinel.mainConfig.chat.blockURLs) handleAntiURL(e);
//if (Sentinel.isTrusted(e.getPlayer())) return;
if (Sentinel.mainConfig.chat.useAntiUnicode) handleAntiUnicode(e);
if (Sentinel.mainConfig.chat.useAntiURL) handleAntiURL(e);
if (Sentinel.mainConfig.chat.useStrictRegex) handleStrictRegex(e);
if (Sentinel.mainConfig.chat.useSwearRegex) handleSwearRegex(e);
}
public static void handleAntiUnicode(AsyncPlayerChatEvent e) {
String message = Text.removeFirstColor(e.getMessage());
ServerUtils.sendDebugMessage("AdvBlocker: Checking for unicode: " + message);
String nonAllowed = message.replaceAll(Sentinel.advConfig.allowedCharRegex, "").trim();
if (nonAllowed.length() != 0) {
e.getPlayer().sendMessage(Text.prefix(Sentinel.language.get("unicode-warn")));
ServerUtils.sendDebugMessage("AdvBlocker: Caught Unicode: " + nonAllowed);
e.setCancelled(true);
FilterAction.filterPunish(e,FAT.BLOCK_UNICODE,null,null);
}
}
@@ -58,11 +61,13 @@ public class AdvancedBlockers {
Pattern pattern = Pattern.compile(urlRegex, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(e.getMessage());
ServerUtils.sendDebugMessage("AdvBlocker: Checking for URLs against regex `%1$s`:%2$s".formatted(urlRegex, e.getMessage()));
if (matcher.find()) {
e.setCancelled(true);
e.getPlayer().sendMessage(Text.prefix(Sentinel.language.get("url-warn")));
ServerUtils.sendDebugMessage("AdvBlocker: Caught URL: " + Text.regexHighlighter(e.getMessage(),Sentinel.advConfig.urlRegex," > "," < "));
FilterAction.filterPunish(e,FAT.BLOCK_URL,null,null);
}
}
}

View File

@@ -78,39 +78,4 @@ public class AntiSpam {
//ServerUtils.sendDebugMessage("AntiSpam: Decaying heat for " + p.getName() + ": " + heatMap.get(p));
}
}
/*
public static void alertSpam(Player p, String message1, String message2) {
TextComponent text = new TextComponent();
double similarity = GPTUtils.calculateSimilarity(message1,message2 + "%");
DecimalFormat fs = new DecimalFormat("##.#");
fs.setRoundingMode(RoundingMode.DOWN);
TextComponent warning = new TextComponent();
warning.setText(Text.prefix(Sentinel.language.get("spam-warning")));
warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("action-automatic")));
p.spigot().sendMessage(warning);
text.setText(Text.prefix(Sentinel.language.get("spam-notification").formatted(p.getName(),heatMap.get(p),Config.punishHeat)));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("spam-notification-hover").formatted(message1,message2,fs.format(similarity)))));
ServerUtils.forEachStaff(staff -> {
staff.spigot().sendMessage(text);
});
}
public static void punishSpam(Player p, String message1, String message2) {
boolean chatCleared = false;
if (Config.clearChat) {
ServerUtils.sendCommand(Config.chatClearCommand);
chatCleared = true;
}
ServerUtils.sendCommand(Config.spamPunishCommand.replace("%player%", p.getName()));
TextComponent warning = new TextComponent();
warning.setText(Text.prefix(Sentinel.language.get("spam-punished")));
warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("action-automatic"))));
p.spigot().sendMessage(warning);
TextComponent text = new TextComponent();
text.setText(Text.prefix(Sentinel.language.get("spam-punish-notification").formatted(p.getName(),heatMap.get(p),Config.punishHeat)));
ServerUtils.forEachStaff(staff -> {
staff.spigot().sendMessage(text);
});
if (Config.logSpam) WebhookSender.sendSpamLog(p,message1,message2,heatMap.get(p),chatCleared);
}
*/
}

View File

@@ -4,9 +4,33 @@ package io.github.thetrouper.sentinel.server.util;
import io.github.thetrouper.sentinel.Sentinel;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
public class Text {
public static String regexHighlighter(String input, String regex, String startString, String endString) {
// Create a Pattern object
Pattern pattern = Pattern.compile(regex);
// Create a Matcher object
Matcher matcher = pattern.matcher(input);
// StringBuffer to store the result
StringBuffer result = new StringBuffer();
// Find and append matches
while (matcher.find()) {
matcher.appendReplacement(result, startString + matcher.group() + endString);
}
// Append the remainder of the input
matcher.appendTail(result);
return result.toString();
}
public static final char SECTION_SYMBOL = (char)167;
public static String color(String msg) {