Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BadPackets3 #1530

Open
wants to merge 2 commits into
base: 2.0
Choose a base branch
from
Open

Add BadPackets3 #1530

wants to merge 2 commits into from

Conversation

ManInMyVan
Copy link
Contributor

Can detect some wtaps/superknockbacks

@Anthony01M
Copy link
Contributor

avoid breaking how things are atm.

/* 
import them non static;

import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
*/

@Override
    public void onPacketReceive(PacketReceiveEvent event) {
        if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && !player.packetStateData.lastPacketWasTeleport) {
            sprints = 0;
            sneaks = 0;
            return;
        }

        if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) {
            switch (new WrapperPlayClientEntityAction(event).getAction()) {
                case START_SNEAKING:
                case STOP_SNEAKING:
                    sneaks++;
                    if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && sneaks > 1) {
                        if (flagAndAlert("sneak") && shouldModifyPackets()) {
                            event.setCancelled(true);
                            player.onPacketCancel();
                        }
                    }
                    break;
                case START_SPRINTING:
                case STOP_SPRINTING:
                    sprints++;
                    if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && sprints > 1) {
                        if (flagAndAlert("sprint") && shouldModifyPackets()) {
                            event.setCancelled(true);
                            player.onPacketCancel();
                        }
                    }
                    break;
            }
        }
    }

@Anthony01M
Copy link
Contributor

Wouldn't this check be better off under velocity as SuperKnockbackHandler?
You could even rename it to SuperKnockbackAHandler or better than any of what I suggested would be making a folder alone, I don't see a reason this is to be under BadPackets to be honest as it would also mess things up ngl

// detects: LiquidBounce SuperKnockback (PACKET)
@CheckData(name = "SuperKnockback", alternativeName = "AntiKnockbackB", configName = "KnockbackB")
public class SuperKnockbackHandler extends Check implements PacketCheck, PostPredictionCheck {
    public SuperKnockbackHandler(GrimPlayer player) {
        super(player);
    }

    private float sprints = 0,
            sneaks = 0;

    @Override
    public void onPredictionComplete(final PredictionComplete predictionComplete) {
        // we don't need to check pre-1.9 players here (no tick skipping)
        if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9)) return;

        if (player.skippedTickInActualMovement) {
            sprints *= 0.05f;
            sneaks *= 0.05f;
        }

        for (; sneaks > 1; sneaks--) flagAndAlert("sneak");
        for (; sprints > 1; sprints--) flagAndAlert("sprint");
        sneaks = 0;
        sprints = 0;
    }

    @Override
    public void onPacketReceive(PacketReceiveEvent event) {
        if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && !player.packetStateData.lastPacketWasTeleport) {
            sprints = 0;
            sneaks = 0;
            return;
        }

        if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) {
            switch (new WrapperPlayClientEntityAction(event).getAction()) {
                case START_SNEAKING:
                case STOP_SNEAKING:
                    sneaks++;
                    if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && sneaks > 1) {
                        if (flagAndAlert("sneak") && shouldModifyPackets()) {
                            event.setCancelled(true);
                            player.onPacketCancel();
                        }
                    }
                    break;
                case START_SPRINTING:
                case STOP_SPRINTING:
                    sprints++;
                    if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && sprints > 1) {
                        if (flagAndAlert("sprint") && shouldModifyPackets()) {
                            event.setCancelled(true);
                            player.onPacketCancel();
                        }
                    }
                    break;
            }
        }
    }
}

@MachineBreaker
Copy link
Collaborator

Wouldn't this check be better off under velocity as SuperKnockbackHandler? You could even rename it to SuperKnockbackAHandler or better than any of what I suggested would be making a folder alone, I don't see a reason this is to be under BadPackets to be honest as it would also mess things up ngl

// detects: LiquidBounce SuperKnockback (PACKET)
@CheckData(name = "SuperKnockback", alternativeName = "AntiKnockbackB", configName = "KnockbackB")
public class SuperKnockbackHandler extends Check implements PacketCheck, PostPredictionCheck {
    public SuperKnockbackHandler(GrimPlayer player) {
        super(player);
    }

    private float sprints = 0,
            sneaks = 0;

    @Override
    public void onPredictionComplete(final PredictionComplete predictionComplete) {
        // we don't need to check pre-1.9 players here (no tick skipping)
        if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9)) return;

        if (player.skippedTickInActualMovement) {
            sprints *= 0.05f;
            sneaks *= 0.05f;
        }

        for (; sneaks > 1; sneaks--) flagAndAlert("sneak");
        for (; sprints > 1; sprints--) flagAndAlert("sprint");
        sneaks = 0;
        sprints = 0;
    }

    @Override
    public void onPacketReceive(PacketReceiveEvent event) {
        if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType()) && player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && !player.packetStateData.lastPacketWasTeleport) {
            sprints = 0;
            sneaks = 0;
            return;
        }

        if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) {
            switch (new WrapperPlayClientEntityAction(event).getAction()) {
                case START_SNEAKING:
                case STOP_SNEAKING:
                    sneaks++;
                    if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && sneaks > 1) {
                        if (flagAndAlert("sneak") && shouldModifyPackets()) {
                            event.setCancelled(true);
                            player.onPacketCancel();
                        }
                    }
                    break;
                case START_SPRINTING:
                case STOP_SPRINTING:
                    sprints++;
                    if (player.getClientVersion().isOlderThan(ClientVersion.V_1_9) && sprints > 1) {
                        if (flagAndAlert("sprint") && shouldModifyPackets()) {
                            event.setCancelled(true);
                            player.onPacketCancel();
                        }
                    }
                    break;
            }
        }
    }
}

Sounds very specific... BadPackets is good imo

@Anthony01M
Copy link
Contributor

Anthony01M commented Jul 6, 2024 via email

@SamB440
Copy link
Collaborator

SamB440 commented Jul 6, 2024

BadPackets makes more sense because it's impossible to send more than 1 sprint packet in a tick, which is what this detects. I'm more concerned about the stability of this on 1.9+. For example, if the simulation falses, we might miss a tick skip, or there is more than 1 skipped tick.

@MatrixU5er
Copy link

MatrixU5er commented Jul 17, 2024

This can not only be used to check features like WTAP, but cheaters from China like to bypass Grimac. For example, some achieve a 0% 100% (noxz) velocity effect by resetting sprint and sneak, which Using badpackts3 can only detect cheaters before version 1.9. When cheaters cross versions( viaversion to 1.9+), this check will not detect cheaters. So let badpackts3 detect cheaters in version 1.9+?

@ManInMyVan
Copy link
Contributor Author

This can not only be used to check features like WTAP, but cheaters from China like to bypass Grimac. For example, some achieve a 0% 100% (noxz) velocity effect by resetting sprint and sneak, which Using badpackts3 can only detect cheaters before version 1.9. When cheaters cross versions( viaversion to 1.9+), this check will not detect cheaters. So let badpackts3 detect cheaters in version 1.9+?

1.9+ isn't exempt, it's just more lenient due to tick skipping

@overkidding
Copy link

falses while leaving from spectating player (click player while in spectator and next sneak and move you will false)


if (!player.skippedTickInActualMovement) {
for (; flags > 0; flags--) {
if (flagAndAlert()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some data in the flag or a bad choice? it would spam both ways so adding something that can help debugging the check wouldn't be a bad idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants