Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tecnio committed Feb 9, 2021
1 parent d3838b7 commit 0e86127
Show file tree
Hide file tree
Showing 31 changed files with 201 additions and 147 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>com.github.retrooper</groupId>
<artifactId>packetevents</artifactId>
<version>dev-59aa347e4e-1</version>
<version>v1.8-pre-3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/me/tecnio/antihaxerman/AntiHaxerman.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ private void setupPacketEvents() {
.injectAsync(Config.ASYNC_INJECT_UNINJECT)
.ejectAsync(Config.ASYNC_INJECT_UNINJECT)
.injectEarly(Config.EARLY_INJECT)
.injectAndEjectThreadCount(1)
.checkForUpdates(true)
.injectionFailureMessage("We were unable to inject you. Rejoin and problem should be fixed.")
.backupServerVersion(ServerVersion.v_1_7_10);

PacketEvents.get().load();
Expand All @@ -127,7 +124,7 @@ private void runPacketEvents() {
}

private void stopPacketEvents() {
PacketEvents.get().stop();
PacketEvents.get().terminate();
}

private void registerEvents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void handle(final Packet packet) {
final boolean invalid = gcd < 131072L && deltaPitch > 0.5F && deltaPitch < 20.0F && !cinematic;

if (invalid) {
if (increaseBuffer() > 6) {
if (increaseBuffer() > 7) {
fail();
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,17 @@ public void handle(final Packet packet) {
final float deltaYaw = data.getRotationProcessor().getDeltaYaw();

final boolean exempt = isExempt(ExemptType.TELEPORT_DELAY, ExemptType.TELEPORT);
final boolean invalid = deltaYaw < 3.0F && lastDeltaYaw > 20F && lastLastDeltaYaw < 3.0F;
final boolean invalid = deltaYaw < 2.5F && lastDeltaYaw > 20F && lastLastDeltaYaw < 2.5F;

if (exempt) {
lastDeltaYaw = deltaYaw;
lastLastDeltaYaw = deltaYaw;
}

if (invalid && !exempt) fail();

lastLastDeltaYaw = lastDeltaYaw;
lastDeltaYaw = deltaYaw;
this.lastLastDeltaYaw = lastDeltaYaw;
this.lastDeltaYaw = deltaYaw;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public void handle(final Packet packet) {
final double pitch = data.getRotationProcessor().getPitch();
final double moduloPitch = Math.abs(pitch % constantPitch);

if (moduloPitch < 1.0E-4) {
if (increaseBuffer() > 4) {
if (moduloPitch < 1.0E-5) {
if (increaseBuffer() > 2) {
fail(moduloPitch);
}
} else {
decreaseBufferBy(0.2);
decreaseBufferBy(0.05);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
/*
* Copyright (C) 2020 - 2021 Tecnio
* Copyright (C) 2020-2021 Tecnio
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This check is different than others, you can't take it or include it in any other application/project.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* The license may allow you to use this check but in this scenario the license is not effective.
* And for anyone who opposes claiming license is GPLv3 I clearly have written a different license here.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
* Be aware.
*/

package me.tecnio.antihaxerman.check.impl.combat.aim;

import me.tecnio.antihaxerman.check.Check;
import me.tecnio.antihaxerman.check.api.CheckInfo;
import me.tecnio.antihaxerman.data.PlayerData;
import me.tecnio.antihaxerman.exempt.type.ExemptType;
import me.tecnio.antihaxerman.packet.Packet;
import me.tecnio.antihaxerman.util.MathUtil;

@CheckInfo(name = "Aim", type = "G", description = "Checks for unlikely yaw deltas.")
@CheckInfo(name = "Aim", type = "G", description = "GCD bypass flaw detected (KEKW)")
public final class AimG extends Check {

public AimG(final PlayerData data) {
Expand All @@ -31,18 +27,27 @@ public AimG(final PlayerData data) {

@Override
public void handle(final Packet packet) {
if (packet.isRotation()) {
final float deltaPitch = data.getRotationProcessor().getDeltaPitch();
if (packet.isRotation() && isExempt(ExemptType.COMBAT, ExemptType.BUKKIT_PLACING)) {
final float deltaYaw = data.getRotationProcessor().getDeltaYaw();
final float lastDeltaYaw = data.getRotationProcessor().getLastDeltaYaw();

final boolean invalid = deltaYaw == 0.0F && deltaPitch >= 15.0F;
if (deltaYaw < 0.5) {
final long expandedYaw = (long) (deltaYaw * MathUtil.EXPANDER);
final long lastExpandedYaw = (long) (lastDeltaYaw * MathUtil.EXPANDER);

if (invalid) {
if (increaseBuffer() > 4) {
fail();
final double divisorYaw = MathUtil.getGcd(expandedYaw, lastExpandedYaw);
final double constantYaw = divisorYaw / MathUtil.EXPANDER;

final double yaw = data.getRotationProcessor().getYaw();
final double moduloYaw = Math.abs(yaw % constantYaw);

if (moduloYaw < 1.0E-5) {
if (increaseBuffer() > 3) {
fail(moduloYaw);
}
} else {
decreaseBufferBy(0.05);
}
} else {
decreaseBufferBy(0.1);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
/*
* Copyright (C) 2020-2021 Tecnio
* Copyright (C) 2020 - 2021 Tecnio
*
* This check is different than others, you can't take it or include it in any other application/project.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The license may allow you to use this check but in this scenario the license is not effective.
* And for anyone who opposes claiming license is GPLv3 I clearly have written a different license here.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Be aware.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/

package me.tecnio.antihaxerman.check.impl.combat.aim;
Expand All @@ -16,18 +22,28 @@
import me.tecnio.antihaxerman.data.PlayerData;
import me.tecnio.antihaxerman.packet.Packet;

@CheckInfo(name = "Aim", type = "H", description = "L ez kot")
@CheckInfo(name = "Aim", type = "H", description = "Checks for unlikely yaw deltas.")
public final class AimH extends Check {

// Read the license above
private float lastDeltaYaw;

public AimH(final PlayerData data) {
super(data);
}

@Override
public void handle(final Packet packet) {
if (packet.isRotation()) {
final float deltaPitch = data.getRotationProcessor().getDeltaPitch();
final float deltaYaw = data.getRotationProcessor().getDeltaYaw();

final boolean invalid = deltaYaw == 0.0F && deltaPitch >= 20.0F;

if (invalid) {
if (increaseBuffer() > 1) {
fail();
}
} else {
decreaseBufferBy(0.05);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import me.tecnio.antihaxerman.check.Check;
import me.tecnio.antihaxerman.check.api.CheckInfo;
import me.tecnio.antihaxerman.data.PlayerData;
import me.tecnio.antihaxerman.exempt.type.ExemptType;
import me.tecnio.antihaxerman.packet.Packet;
import me.tecnio.antihaxerman.util.MathUtil;
import me.tecnio.antihaxerman.util.PlayerUtil;
Expand Down Expand Up @@ -72,7 +73,7 @@ public void handle(final Packet packet) {
})
.min().orElse(-1);

final boolean exempt = data.getCombatProcessor().getDistance() < 1.8;
final boolean exempt = data.getCombatProcessor().getDistance() < 1.8 || isExempt(ExemptType.LAGGING);
final boolean invalid = angle > 0.6;

if (invalid && !exempt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import me.tecnio.antihaxerman.check.Check;
import me.tecnio.antihaxerman.check.api.CheckInfo;
import me.tecnio.antihaxerman.data.PlayerData;
import me.tecnio.antihaxerman.exempt.type.ExemptType;
import me.tecnio.antihaxerman.packet.Packet;
import me.tecnio.antihaxerman.util.MathUtil;
import me.tecnio.antihaxerman.util.PlayerUtil;
Expand Down Expand Up @@ -71,7 +72,7 @@ public void handle(final Packet packet) {
})
.min().orElse(-1);

final boolean invalid = distance > maxDistance;
final boolean invalid = distance > maxDistance && !isExempt(ExemptType.LAGGING);

if (invalid) {
if (increaseBuffer() > 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ public void handle(final Packet packet) {
final double velocityY = data.getVelocityProcessor().getVelocityY();
final double limit = isExempt(ExemptType.VELOCITY_ON_TICK) ? velocityY + 0.45 + 0.001 : 0.001;

final boolean exempt = isExempt(ExemptType.PISTON, ExemptType.VEHICLE, ExemptType.TELEPORT, ExemptType.LIQUID,
ExemptType.BOAT, ExemptType.FLYING, ExemptType.WEB, ExemptType.SLIME, ExemptType.CLIMBABLE, ExemptType.CHUNK);
final boolean exempt = isExempt(ExemptType.PISTON, ExemptType.VEHICLE, ExemptType.TELEPORT,
ExemptType.LIQUID, ExemptType.BOAT, ExemptType.FLYING, ExemptType.WEB,
ExemptType.SLIME, ExemptType.CLIMBABLE, ExemptType.CHUNK, ExemptType.VOID);
final boolean invalid = difference > limit && (serverAirTicks > airTicksLimit || clientAirTicks > airTicksLimit);

if (invalid && !exempt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void handle(final Packet packet) {

final double maximum = 0.6 + modifierJump + modifierVelocity;

final boolean exempt = isExempt(ExemptType.PISTON, ExemptType.LIQUID, ExemptType.FLYING, ExemptType.WEB, ExemptType.TELEPORT, ExemptType.SLIME, ExemptType.CHUNK);
final boolean exempt = isExempt(ExemptType.PISTON, ExemptType.LIQUID,
ExemptType.FLYING, ExemptType.WEB, ExemptType.TELEPORT, ExemptType.SLIME, ExemptType.CHUNK);
final boolean invalid = deltaY > maximum;

if (invalid && !exempt) fail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ public void handle(final Packet packet) {

final double limit = 1.0 + modifierJump + modifierVelocity;

final boolean exempt = isExempt(ExemptType.TELEPORT, ExemptType.PISTON, ExemptType.VEHICLE, ExemptType.BOAT, ExemptType.VEHICLE, ExemptType.SLIME, ExemptType.CHUNK);
final boolean exempt = isExempt(ExemptType.TELEPORT, ExemptType.PISTON,
ExemptType.VEHICLE, ExemptType.BOAT, ExemptType.VEHICLE,
ExemptType.SLIME, ExemptType.CHUNK, ExemptType.FLYING);
final boolean invalid = deltaY > limit && lastDeltaY < 0.5;

if (invalid && !exempt) fail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,18 @@

package me.tecnio.antihaxerman.check.impl.player.badpackets;

import me.tecnio.antihaxerman.AntiHaxerman;
import me.tecnio.antihaxerman.check.Check;
import me.tecnio.antihaxerman.check.api.CheckInfo;
import me.tecnio.antihaxerman.data.PlayerData;
import me.tecnio.antihaxerman.exempt.type.ExemptType;
import me.tecnio.antihaxerman.packet.Packet;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;

@CheckInfo(name = "BadPackets", type = "N", description = "Checks for disablers.")
public final class BadPacketsN extends Check implements Listener {
public final class BadPacketsN extends Check {
public BadPacketsN(final PlayerData data) {
super(data);
AntiHaxerman.INSTANCE.getPlugin().getServer().getPluginManager().registerEvents(this, AntiHaxerman.INSTANCE.getPlugin());
}

@Override
public void handle(final Packet packet) {
}

@EventHandler
public void handleTeleport(final PlayerTeleportEvent event) {
if (event.getPlayer() == data.getPlayer()) {
if (event.getCause() == PlayerTeleportEvent.TeleportCause.UNKNOWN) {
final double deltaXZ = Math.abs(data.getPositionProcessor().getDeltaXZ());
final double lastDeltaXZ = Math.abs(data.getPositionProcessor().getLastDeltaXZ());

final double deltaY = Math.abs(data.getPositionProcessor().getDeltaY());
final double lastDeltaY = Math.abs(data.getPositionProcessor().getLastDeltaY());

final boolean exempt = isExempt(ExemptType.JOINED);
final boolean invalid = deltaXZ > 10.0 || lastDeltaXZ > 10.0 || deltaY > 10.0 || lastDeltaY > 10.0;

if (invalid && !exempt) fail();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,18 @@

package me.tecnio.antihaxerman.check.impl.player.fastplace;

import me.tecnio.antihaxerman.AntiHaxerman;
import me.tecnio.antihaxerman.check.Check;
import me.tecnio.antihaxerman.check.api.CheckInfo;
import me.tecnio.antihaxerman.data.PlayerData;
import me.tecnio.antihaxerman.packet.Packet;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;

@CheckInfo(name = "FastPlace", type = "A", description = "Checks if player placing blocks too fast.")
public final class FastPlaceA extends Check implements Listener {
public final class FastPlaceA extends Check {

private int blocks, movements;

public FastPlaceA(final PlayerData data) {
super(data);
AntiHaxerman.INSTANCE.getPlugin().getServer().getPluginManager().registerEvents(this, AntiHaxerman.INSTANCE.getPlugin());
}

@Override
Expand All @@ -43,19 +37,14 @@ public void handle(final Packet packet) {
++movements;

if (movements >= 20) {
if (blocks > 18) {
if (blocks > 16) {
fail();
}

movements = 0;
blocks = 0;
}
}
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockPlace(final BlockPlaceEvent event) {
if (event.getPlayer() == data.getPlayer()) {
} else if (packet.isBukkitBlockPlace()) {
++blocks;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public void handle(final Packet packet) {
if (packet.isFlying()) {
final boolean onGround = data.getPositionProcessor().isOnGround();
final boolean inAir = data.getPositionProcessor().getAirTicks() > 3;
final boolean mathGround = data.getPositionProcessor().isMathematicallyOnGround();

final boolean exempt = isExempt(ExemptType.TELEPORT, ExemptType.BOAT, ExemptType.WEB, ExemptType.LIQUID, ExemptType.PISTON, ExemptType.CHUNK);
final boolean invalid = onGround && inAir;
final boolean invalid = onGround && inAir && !mathGround;

if (invalid && !exempt) fail();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public void handle(final Packet packet) {
private boolean interactedCorrectly(final Location blockLoc, final Location playerLoc, final Direction face) {
switch (face) {
case UP: {
final double limit = blockLoc.getY() + 0.03;
return playerLoc.getY() > limit;
//final double limit = blockLoc.getY() + 0.03;
return true;/*playerLoc.getY() > limit;*/
}
case DOWN: {
final double limit = blockLoc.getY() - 0.03;
Expand Down
Loading

0 comments on commit 0e86127

Please sign in to comment.