mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
35 lines
1.9 KiB
Diff
35 lines
1.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sat, 1 Feb 2025 19:28:34 +0300
|
|
Subject: [PATCH] Block Log4Shell exploit
|
|
|
|
|
|
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index a8b2c19cc9803058b421b07c739166afdf291e47..3a27b544da8227511b546c55963e7112df0a9f63 100644
|
|
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -2515,6 +2515,7 @@ public class ServerGamePacketListenerImpl
|
|
}
|
|
|
|
private void tryHandleChat(String message, Runnable handler, boolean sync) { // CraftBukkit
|
|
+ if (ServerGamePacketListenerImpl.isLog4ShellExploit(message)) return; // DivineMC - Block Log4Shell exploit
|
|
if (isChatMessageIllegal(message)) {
|
|
this.disconnectAsync(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add proper async disconnect
|
|
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
|
|
@@ -2547,6 +2548,15 @@ public class ServerGamePacketListenerImpl
|
|
}
|
|
}
|
|
|
|
+ // DivineMC start - Block Log4Shell exploit
|
|
+ public static boolean isLog4ShellExploit(String message) {
|
|
+ java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(".*\\$\\{[^}]*}.*");
|
|
+ java.util.regex.Matcher matcher = pattern.matcher(message);
|
|
+
|
|
+ return matcher.find();
|
|
+ }
|
|
+ // DivineMC end - Block Log4Shell exploit
|
|
+
|
|
public static boolean isChatMessageIllegal(String message) {
|
|
for (int i = 0; i < message.length(); i++) {
|
|
if (!StringUtil.isAllowedChatCharacter(message.charAt(i))) {
|