Skip to content

Commit

Permalink
add CrashH
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Feb 8, 2024
1 parent 49baa0f commit 116fe09
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/main/java/ac/grim/grimac/checks/impl/crash/CrashH.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}


}
1 change: 1 addition & 0 deletions src/main/java/ac/grim/grimac/manager/CheckManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 116fe09

Please sign in to comment.