mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-09 06:50:32 +08:00
OBFHELPERS (#4733)
This commit is contained in:
parent
56d8811924
commit
0e73fdbf72
@ -5,16 +5,27 @@ Subject: [PATCH] Fix exploit that allowed colored signs to be created
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index b92449c7035ebb330eb3aaa48e91a6d0b3873c5c..e72a519645e9383c989fc3ad8059c1c88c1b6382 100644
|
||||
index 453128ea031cea72d3fd57fb64938bd20aa1e7f3..32076076b39b6c408b0ee95afb7ef11b71e373dc 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -2631,7 +2631,8 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
@@ -2631,7 +2631,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
String[] lines = new String[4];
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
- lines[i] = EnumChatFormat.a(new ChatComponentText(EnumChatFormat.a((String) list.get(i))).getString());
|
||||
+ // Paper TODO(Proximyst): Add obfhelper when 1.16.4 runs
|
||||
+ lines[i] = SharedConstants.a(list.get(i)); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
|
||||
+ lines[i] = SharedConstants.filterAllowedChatCharacters(list.get(i)); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
|
||||
}
|
||||
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines);
|
||||
this.server.getPluginManager().callEvent(event);
|
||||
diff --git a/src/main/java/net/minecraft/server/SharedConstants.java b/src/main/java/net/minecraft/server/SharedConstants.java
|
||||
index 9663e8c10662c9660964afda62d8a65812fae69d..470690dbe19db1622eca44f6801ece37d7ad7426 100644
|
||||
--- a/src/main/java/net/minecraft/server/SharedConstants.java
|
||||
+++ b/src/main/java/net/minecraft/server/SharedConstants.java
|
||||
@@ -19,6 +19,7 @@ public class SharedConstants {
|
||||
return c0 != 167 && c0 >= ' ' && c0 != 127;
|
||||
}
|
||||
|
||||
+ public static String filterAllowedChatCharacters(String input) { return a(input); } // Paper - OBFHELPER
|
||||
public static String a(String s) {
|
||||
StringBuilder stringbuilder = new StringBuilder();
|
||||
char[] achar = s.toCharArray();
|
||||
|
@ -22,7 +22,7 @@ it only impacts data sent from the client.
|
||||
Set -DPaper.maxSignLength=XX to change limit or -1 to disable
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index b1faac1e2465cdae624ca5d8d999db3cdedfe3de..fccde94e0ccd0964a051383bd1fc38d7b5967cd4 100644
|
||||
index aca3aae216308544e527a6325b9a02a9a05c2551..040ed989dcfc59c8cb58d81070ea9c6cd493e47d 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -110,6 +110,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
@ -33,10 +33,11 @@ index b1faac1e2465cdae624ca5d8d999db3cdedfe3de..fccde94e0ccd0964a051383bd1fc38d7
|
||||
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
|
||||
|
||||
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
|
||||
@@ -2696,8 +2697,18 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
@@ -2696,7 +2697,17 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
String[] lines = new String[4];
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
- lines[i] = SharedConstants.filterAllowedChatCharacters(list.get(i)); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
|
||||
+ // Paper start - cap line length - modified clients can send longer data than normal
|
||||
+ String currentLine = list.get(i);
|
||||
+ if (MAX_SIGN_LINE_LENGTH > 0 && currentLine.length() > MAX_SIGN_LINE_LENGTH) {
|
||||
@ -47,9 +48,7 @@ index b1faac1e2465cdae624ca5d8d999db3cdedfe3de..fccde94e0ccd0964a051383bd1fc38d7
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
// Paper TODO(Proximyst): Add obfhelper when 1.16.4 runs
|
||||
- lines[i] = SharedConstants.a(list.get(i)); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
|
||||
+ lines[i] = SharedConstants.a(currentLine); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
|
||||
+ lines[i] = SharedConstants.filterAllowedChatCharacters(currentLine); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
|
||||
}
|
||||
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines);
|
||||
this.server.getPluginManager().callEvent(event);
|
||||
|
@ -63,10 +63,10 @@ index 1175f23558fe694bfb77dd478b0a3ec15109dd9b..1439b874b9a825ea605c15aaacaecaed
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index bf052016d7ca4d2012bafe86909f4d581498d403..0c1b4932f14e58bc6d418cf20f23e7915525430b 100644
|
||||
index d224bdc5bf05e3688467dab1dd22f722445ebc6a..3c989cdbbdf95f4629445a6b4d22a8ad8dcc958a 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -2873,7 +2873,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
@@ -2872,7 +2872,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
public void a(PacketPlayInDifficultyChange packetplayindifficultychange) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayindifficultychange, this, this.player.getWorldServer());
|
||||
if (this.player.k(2) || this.isExemptPlayer()) {
|
||||
|
@ -5,7 +5,7 @@ Subject: [PATCH] Brand support
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 3dc5b0279f4c50138e7f85b8aff182b6ed2e2c61..f6c04946aa752b9db4e0c81dbb74334618c955ad 100644
|
||||
index 789a41b900640add7adbc216c65a4133e54e88b0..72a3f0219c5c29229d75357db37d569615e8e43d 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -5,6 +5,7 @@ import com.google.common.primitives.Doubles;
|
||||
@ -25,7 +25,7 @@ index 3dc5b0279f4c50138e7f85b8aff182b6ed2e2c61..f6c04946aa752b9db4e0c81dbb743346
|
||||
public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) {
|
||||
this.minecraftServer = minecraftserver;
|
||||
this.networkManager = networkmanager;
|
||||
@@ -2832,6 +2835,8 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
@@ -2831,6 +2834,8 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
private static final MinecraftKey CUSTOM_REGISTER = new MinecraftKey("register");
|
||||
private static final MinecraftKey CUSTOM_UNREGISTER = new MinecraftKey("unregister");
|
||||
|
||||
@ -34,7 +34,7 @@ index 3dc5b0279f4c50138e7f85b8aff182b6ed2e2c61..f6c04946aa752b9db4e0c81dbb743346
|
||||
@Override
|
||||
public void a(PacketPlayInCustomPayload packetplayincustompayload) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayincustompayload, this, this.player.getWorldServer());
|
||||
@@ -2859,6 +2864,16 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
@@ -2858,6 +2863,16 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
try {
|
||||
byte[] data = new byte[packetplayincustompayload.data.readableBytes()];
|
||||
packetplayincustompayload.data.readBytes(data);
|
||||
@ -51,7 +51,7 @@ index 3dc5b0279f4c50138e7f85b8aff182b6ed2e2c61..f6c04946aa752b9db4e0c81dbb743346
|
||||
server.getMessenger().dispatchIncomingMessage(player.getBukkitEntity(), packetplayincustompayload.tag.toString(), data);
|
||||
} catch (Exception ex) {
|
||||
PlayerConnection.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
||||
@@ -2868,6 +2883,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
@@ -2867,6 +2882,12 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user