From 116fe097005df5892cf1ce891e3fb7e3a904c075 Mon Sep 17 00:00:00 2001 From: AoElite <20812471+AoElite@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:41:00 -0500 Subject: [PATCH] add CrashH --- .../grim/grimac/checks/impl/crash/CrashH.java | 47 +++++++++++++++++++ .../ac/grim/grimac/manager/CheckManager.java | 1 + 2 files changed, 48 insertions(+) create mode 100644 src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java diff --git a/src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java new file mode 100644 index 0000000000..1a43b9259f --- /dev/null +++ b/src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java @@ -0,0 +1,47 @@ +package ac.grim.grimac.checks.impl.crash; + +import ac.grim.grimac.checks.Check; +import ac.grim.grimac.checks.CheckData; +import ac.grim.grimac.checks.type.PacketCheck; +import ac.grim.grimac.player.GrimPlayer; +import com.github.retrooper.packetevents.event.PacketReceiveEvent; +import com.github.retrooper.packetevents.protocol.packettype.PacketType; +import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientTabComplete; + +@CheckData(name = "CrashH") +public class CrashH extends Check implements PacketCheck { + + public CrashH(GrimPlayer player) { + super(player); + } + + @Override + public void onPacketReceive(PacketReceiveEvent event) { + if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) { + WrapperPlayClientTabComplete wrapper = new WrapperPlayClientTabComplete(event); + String text = wrapper.getText(); + final int length = text.length(); + // general length limit + if (length > 2048) { + if (shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + flagAndAlert("(length) length=" + length); + return; + } + // paper's patch + final int index; + if (text.length() > 64 && ((index = text.indexOf(' ')) == -1 || index >= 64)) { + if (shouldModifyPackets()) { + event.setCancelled(true); + player.onPacketCancel(); + } + flagAndAlert("(invalid) length=" + length); + return; + } + } + } + + +} diff --git a/src/main/java/ac/grim/grimac/manager/CheckManager.java b/src/main/java/ac/grim/grimac/manager/CheckManager.java index e37b63cce0..92c4394057 100644 --- a/src/main/java/ac/grim/grimac/manager/CheckManager.java +++ b/src/main/java/ac/grim/grimac/manager/CheckManager.java @@ -143,6 +143,7 @@ public CheckManager(GrimPlayer player) { .put(CrashE.class, new CrashE(player)) .put(CrashF.class, new CrashF(player)) .put(CrashG.class, new CrashG(player)) + .put(CrashH.class, new CrashH(player)) .put(ExploitA.class, new ExploitA(player)) .put(ExploitB.class, new ExploitB(player)) .put(VehicleTimer.class, new VehicleTimer(player))