From 6f04399d90ff5eba034731fabc9c063b1c1f9809 Mon Sep 17 00:00:00 2001 From: Permisos <55111245+PermisosDev@users.noreply.github.com> Date: Thu, 15 Apr 2021 08:41:41 -0300 Subject: [PATCH 1/5] Patches. --- 0025-Check-if-packetID-is-invalid.patch | 25 +++++++++++++++++++ ...necraftDecoder-if-ByteBuf-is-readabl.patch | 21 ++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 0025-Check-if-packetID-is-invalid.patch create mode 100644 0026-Skip-bytes-in-MinecraftDecoder-if-ByteBuf-is-readabl.patch diff --git a/0025-Check-if-packetID-is-invalid.patch b/0025-Check-if-packetID-is-invalid.patch new file mode 100644 index 0000000..6569d94 --- /dev/null +++ b/0025-Check-if-packetID-is-invalid.patch @@ -0,0 +1,25 @@ +From e4a35d4d710e5781cb384e3ad08309f43c0f4b44 Mon Sep 17 00:00:00 2001 +From: PermisosDev <55111245+PermisosDev@users.noreply.github.com> +Date: Thu, 15 Apr 2021 08:34:57 -0300 +Subject: [PATCH] Check if packetID is invalid. + + +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +index dd089abd..b3de7a7b 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +@@ -65,7 +65,10 @@ public class MinecraftDecoder extends MessageToMessageDecoder + + int packetId = DefinedPacket.readVarInt( in ); + packetTypeInfo = packetId; +- ++ // FlameCord Start - Check if packetId is invalid. ++ if (packetId < 0 || packetId > 255) ++ throw new BadPacketException("[" + ctx.channel().remoteAddress() + "] <-> MinecraftDecoder received invalid packet #1, id " + packetId); ++ // Flamecord End + DefinedPacket packet = prot.createPacket( packetId, protocolVersion, supportsForge ); + if ( packet != null ) + { +-- +2.29.2.windows.3 + diff --git a/0026-Skip-bytes-in-MinecraftDecoder-if-ByteBuf-is-readabl.patch b/0026-Skip-bytes-in-MinecraftDecoder-if-ByteBuf-is-readabl.patch new file mode 100644 index 0000000..a5b6c94 --- /dev/null +++ b/0026-Skip-bytes-in-MinecraftDecoder-if-ByteBuf-is-readabl.patch @@ -0,0 +1,21 @@ +From 47c853f657b01df7a8202cd2a17bb7bfc8f8bc7c Mon Sep 17 00:00:00 2001 +From: PermisosDev <55111245+PermisosDev@users.noreply.github.com> +Date: Thu, 15 Apr 2021 08:38:32 -0300 +Subject: [PATCH] Skip bytes in MinecraftDecoder if ByteBuf is readable. + + +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +index b3de7a7b..5d9be1ba 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +@@ -83,6 +83,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder + throw PACKET_NOT_READ_TO_END; + } + // Waterfall end ++ in.skipBytes(in.readableBytes()); // Flamecord - Skip bytes. + throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot.getDirection() ); + } + } else +-- +2.29.2.windows.3 + From dc33fa190e0ea2e27c6943f739c081ceddff226e Mon Sep 17 00:00:00 2001 From: Permisos <55111245+PermisosDev@users.noreply.github.com> Date: Thu, 15 Apr 2021 14:12:33 -0300 Subject: [PATCH 2/5] Fix. --- 0025-Check-if-packetID-is-invalid.patch | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 0025-Check-if-packetID-is-invalid.patch diff --git a/0025-Check-if-packetID-is-invalid.patch b/0025-Check-if-packetID-is-invalid.patch deleted file mode 100644 index 6569d94..0000000 --- a/0025-Check-if-packetID-is-invalid.patch +++ /dev/null @@ -1,25 +0,0 @@ -From e4a35d4d710e5781cb384e3ad08309f43c0f4b44 Mon Sep 17 00:00:00 2001 -From: PermisosDev <55111245+PermisosDev@users.noreply.github.com> -Date: Thu, 15 Apr 2021 08:34:57 -0300 -Subject: [PATCH] Check if packetID is invalid. - - -diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -index dd089abd..b3de7a7b 100644 ---- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -@@ -65,7 +65,10 @@ public class MinecraftDecoder extends MessageToMessageDecoder - - int packetId = DefinedPacket.readVarInt( in ); - packetTypeInfo = packetId; -- -+ // FlameCord Start - Check if packetId is invalid. -+ if (packetId < 0 || packetId > 255) -+ throw new BadPacketException("[" + ctx.channel().remoteAddress() + "] <-> MinecraftDecoder received invalid packet #1, id " + packetId); -+ // Flamecord End - DefinedPacket packet = prot.createPacket( packetId, protocolVersion, supportsForge ); - if ( packet != null ) - { --- -2.29.2.windows.3 - From 6a20b1da977e0865f2fb618b14380052ea817243 Mon Sep 17 00:00:00 2001 From: Permisos <55111245+PermisosDev@users.noreply.github.com> Date: Thu, 15 Apr 2021 14:12:43 -0300 Subject: [PATCH 3/5] Fix. --- ...necraftDecoder-if-ByteBuf-is-readabl.patch | 21 ------------------- 1 file changed, 21 deletions(-) delete mode 100644 0026-Skip-bytes-in-MinecraftDecoder-if-ByteBuf-is-readabl.patch diff --git a/0026-Skip-bytes-in-MinecraftDecoder-if-ByteBuf-is-readabl.patch b/0026-Skip-bytes-in-MinecraftDecoder-if-ByteBuf-is-readabl.patch deleted file mode 100644 index a5b6c94..0000000 --- a/0026-Skip-bytes-in-MinecraftDecoder-if-ByteBuf-is-readabl.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 47c853f657b01df7a8202cd2a17bb7bfc8f8bc7c Mon Sep 17 00:00:00 2001 -From: PermisosDev <55111245+PermisosDev@users.noreply.github.com> -Date: Thu, 15 Apr 2021 08:38:32 -0300 -Subject: [PATCH] Skip bytes in MinecraftDecoder if ByteBuf is readable. - - -diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -index b3de7a7b..5d9be1ba 100644 ---- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -@@ -83,6 +83,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder - throw PACKET_NOT_READ_TO_END; - } - // Waterfall end -+ in.skipBytes(in.readableBytes()); // Flamecord - Skip bytes. - throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot.getDirection() ); - } - } else --- -2.29.2.windows.3 - From cf60bfba66079e935545af3e80eaf97945c56711 Mon Sep 17 00:00:00 2001 From: Permisos <55111245+PermisosDev@users.noreply.github.com> Date: Thu, 15 Apr 2021 14:13:14 -0300 Subject: [PATCH 4/5] Patches Fixed. --- .../0025-Check-if-packetID-is-invalid.patch | 25 +++++++++++++++ ...n-PACKET_NOT_READ_TO_END-and-changed.patch | 31 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 Waterfall-Proxy-Patches/0025-Check-if-packetID-is-invalid.patch create mode 100644 Waterfall-Proxy-Patches/0026-Add-skip-bytes-on-PACKET_NOT_READ_TO_END-and-changed.patch diff --git a/Waterfall-Proxy-Patches/0025-Check-if-packetID-is-invalid.patch b/Waterfall-Proxy-Patches/0025-Check-if-packetID-is-invalid.patch new file mode 100644 index 0000000..6569d94 --- /dev/null +++ b/Waterfall-Proxy-Patches/0025-Check-if-packetID-is-invalid.patch @@ -0,0 +1,25 @@ +From e4a35d4d710e5781cb384e3ad08309f43c0f4b44 Mon Sep 17 00:00:00 2001 +From: PermisosDev <55111245+PermisosDev@users.noreply.github.com> +Date: Thu, 15 Apr 2021 08:34:57 -0300 +Subject: [PATCH] Check if packetID is invalid. + + +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +index dd089abd..b3de7a7b 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +@@ -65,7 +65,10 @@ public class MinecraftDecoder extends MessageToMessageDecoder + + int packetId = DefinedPacket.readVarInt( in ); + packetTypeInfo = packetId; +- ++ // FlameCord Start - Check if packetId is invalid. ++ if (packetId < 0 || packetId > 255) ++ throw new BadPacketException("[" + ctx.channel().remoteAddress() + "] <-> MinecraftDecoder received invalid packet #1, id " + packetId); ++ // Flamecord End + DefinedPacket packet = prot.createPacket( packetId, protocolVersion, supportsForge ); + if ( packet != null ) + { +-- +2.29.2.windows.3 + diff --git a/Waterfall-Proxy-Patches/0026-Add-skip-bytes-on-PACKET_NOT_READ_TO_END-and-changed.patch b/Waterfall-Proxy-Patches/0026-Add-skip-bytes-on-PACKET_NOT_READ_TO_END-and-changed.patch new file mode 100644 index 0000000..af8925c --- /dev/null +++ b/Waterfall-Proxy-Patches/0026-Add-skip-bytes-on-PACKET_NOT_READ_TO_END-and-changed.patch @@ -0,0 +1,31 @@ +From fe675f579c624b8639741339676713bea14dfc8d Mon Sep 17 00:00:00 2001 +From: PermisosDev <55111245+PermisosDev@users.noreply.github.com> +Date: Thu, 15 Apr 2021 14:11:24 -0300 +Subject: [PATCH] Add skip bytes on PACKET_NOT_READ_TO_END and changed 255 to + MAX_PACKET_ID + + +diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +index b3de7a7b..9b7934b8 100644 +--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java ++++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +@@ -66,7 +66,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder + int packetId = DefinedPacket.readVarInt( in ); + packetTypeInfo = packetId; + // FlameCord Start - Check if packetId is invalid. +- if (packetId < 0 || packetId > 255) ++ if (packetId < 0 || packetId > Protocol.MAX_PACKET_ID) + throw new BadPacketException("[" + ctx.channel().remoteAddress() + "] <-> MinecraftDecoder received invalid packet #1, id " + packetId); + // Flamecord End + DefinedPacket packet = prot.createPacket( packetId, protocolVersion, supportsForge ); +@@ -83,6 +83,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder + throw PACKET_NOT_READ_TO_END; + } + // Waterfall end ++ in.skipBytes(in.readableBytes()); // Flamecord - Skip bytes. + throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot.getDirection() ); + } + } else +-- +2.29.2.windows.3 + From fef5bcbbe15e76b717b1509fd59f6319f8fccf5f Mon Sep 17 00:00:00 2001 From: LinsaFTW Date: Thu, 15 Apr 2021 14:28:01 -0300 Subject: [PATCH 5/5] Fixed patch 0025 --- .../0025-Check-if-packetID-is-invalid.patch | 2 +- ...n-PACKET_NOT_READ_TO_END-and-changed.patch | 31 ------------------- 2 files changed, 1 insertion(+), 32 deletions(-) delete mode 100644 Waterfall-Proxy-Patches/0026-Add-skip-bytes-on-PACKET_NOT_READ_TO_END-and-changed.patch diff --git a/Waterfall-Proxy-Patches/0025-Check-if-packetID-is-invalid.patch b/Waterfall-Proxy-Patches/0025-Check-if-packetID-is-invalid.patch index 6569d94..3d2795b 100644 --- a/Waterfall-Proxy-Patches/0025-Check-if-packetID-is-invalid.patch +++ b/Waterfall-Proxy-Patches/0025-Check-if-packetID-is-invalid.patch @@ -14,7 +14,7 @@ index dd089abd..b3de7a7b 100644 packetTypeInfo = packetId; - + // FlameCord Start - Check if packetId is invalid. -+ if (packetId < 0 || packetId > 255) ++ if (packetId < 0 || packetId > Protocol.MAX_PACKET_ID) + throw new BadPacketException("[" + ctx.channel().remoteAddress() + "] <-> MinecraftDecoder received invalid packet #1, id " + packetId); + // Flamecord End DefinedPacket packet = prot.createPacket( packetId, protocolVersion, supportsForge ); diff --git a/Waterfall-Proxy-Patches/0026-Add-skip-bytes-on-PACKET_NOT_READ_TO_END-and-changed.patch b/Waterfall-Proxy-Patches/0026-Add-skip-bytes-on-PACKET_NOT_READ_TO_END-and-changed.patch deleted file mode 100644 index af8925c..0000000 --- a/Waterfall-Proxy-Patches/0026-Add-skip-bytes-on-PACKET_NOT_READ_TO_END-and-changed.patch +++ /dev/null @@ -1,31 +0,0 @@ -From fe675f579c624b8639741339676713bea14dfc8d Mon Sep 17 00:00:00 2001 -From: PermisosDev <55111245+PermisosDev@users.noreply.github.com> -Date: Thu, 15 Apr 2021 14:11:24 -0300 -Subject: [PATCH] Add skip bytes on PACKET_NOT_READ_TO_END and changed 255 to - MAX_PACKET_ID - - -diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -index b3de7a7b..9b7934b8 100644 ---- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java -@@ -66,7 +66,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder - int packetId = DefinedPacket.readVarInt( in ); - packetTypeInfo = packetId; - // FlameCord Start - Check if packetId is invalid. -- if (packetId < 0 || packetId > 255) -+ if (packetId < 0 || packetId > Protocol.MAX_PACKET_ID) - throw new BadPacketException("[" + ctx.channel().remoteAddress() + "] <-> MinecraftDecoder received invalid packet #1, id " + packetId); - // Flamecord End - DefinedPacket packet = prot.createPacket( packetId, protocolVersion, supportsForge ); -@@ -83,6 +83,7 @@ public class MinecraftDecoder extends MessageToMessageDecoder - throw PACKET_NOT_READ_TO_END; - } - // Waterfall end -+ in.skipBytes(in.readableBytes()); // Flamecord - Skip bytes. - throw new BadPacketException( "Did not read all bytes from packet " + packet.getClass() + " " + packetId + " Protocol " + protocol + " Direction " + prot.getDirection() ); - } - } else --- -2.29.2.windows.3 -