mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Fix #167, vastly improved aimbot check (experimental)
This commit is contained in:
1 parent
e2d0fbda18
commit
78ae04a2a8
12 files changed
+110
-70
No files matched your search
@@ -35,7 +35,6 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck;
|
||||
@@ -125,7 +124,6 @@ public class Backend {
|
||||
fastSneakViolations.remove(uuid);
|
||||
lastSneak.remove(uuid);
|
||||
levitatingEnd.remove(uuid);
|
||||
AimbotCheck.LAST_DELTA_YAW.remove(uuid);
|
||||
VelocityCheck.VIOLATIONS.remove(uuid);
|
||||
MorePacketsCheck.LAST_PACKET_TIME.remove(uuid);
|
||||
MorePacketsCheck.PACKET_BALANCE.remove(uuid);
|
||||
|
||||
@@ -18,54 +18,49 @@
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
/**
|
||||
* TODO redo this all - useless check
|
||||
/*
|
||||
* In development - expect issues
|
||||
*/
|
||||
public final class AimbotCheck {
|
||||
|
||||
public static final Map<UUID, Float> LAST_DELTA_YAW = new HashMap<UUID, Float>();
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(final Player player, final PlayerMoveEvent event) {
|
||||
public static CheckResult runCheck(final Player player, final EntityDamageByEntityEvent event) {
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (backend.isMovingExempt(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final float dYaw = Math.abs(event.getTo().getYaw() - event.getFrom().getYaw());
|
||||
final float dPitch = Math.abs(event.getTo().getPitch() - event.getFrom().getPitch());
|
||||
// Not interesting
|
||||
if (dYaw < 0.05 && dPitch < 0.05) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final float lastDeltaYaw = LAST_DELTA_YAW.getOrDefault(uuid, -1F);
|
||||
if (lastDeltaYaw == -1F) {
|
||||
LAST_DELTA_YAW.put(uuid, dYaw);
|
||||
return PASS;
|
||||
}
|
||||
LAST_DELTA_YAW.put(uuid, dYaw);
|
||||
|
||||
final float absoluteYawDifference = Math.abs(dYaw - lastDeltaYaw);
|
||||
final int minYaw = checksConfig.getInteger(CheckType.AIMBOT, "minYaw");
|
||||
final int maxYaw = checksConfig.getInteger(CheckType.AIMBOT, "maxYaw");
|
||||
if (absoluteYawDifference < 1E-8 && minYaw > 30 && dYaw < maxYaw) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "repeated yaw difference (dYaw=" + dYaw + ")");
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager()
|
||||
.getUser(player.getUniqueId());
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final float deltaPitch = movementManager.deltaPitch;
|
||||
final float deltaYaw = movementManager.deltaYaw;
|
||||
final float pitchAcceleration = Math.abs(deltaPitch - movementManager.lastDeltaPitch);
|
||||
final float yawAcceleration = Math.abs(deltaYaw - movementManager.lastDeltaYaw);
|
||||
|
||||
if (deltaYaw > 3.0F && deltaPitch <= 10.0F && pitchAcceleration > 2.0F && yawAcceleration > 2.0F
|
||||
&& deltaPitch < deltaYaw) {
|
||||
final double gcd = Utilities.computeGcd(deltaPitch, movementManager.lastDeltaPitch);
|
||||
final double mod = player.getLocation().getPitch() % gcd;
|
||||
final double maxGcd = checksConfig.getDouble(CheckType.AIMBOT, "maxGcd");
|
||||
final double maxMod = checksConfig.getDouble(CheckType.AIMBOT, "maxMod");
|
||||
if (gcd < maxGcd || mod < maxMod) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "failed computational check (gcd=" + gcd + ", mod=" + mod + ")");
|
||||
}
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public final class ElytraCheck {
|
||||
// Tident added in 1.13
|
||||
if (player.getInventory().getItemInMainHand().getType() == XMaterial.TRIDENT.parseMaterial()) {
|
||||
if (upwardMovement) {
|
||||
// TODO continue check here
|
||||
JUMP_Y_VALUE.remove(uuid);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
@@ -55,15 +54,13 @@ public final class FlightCheck {
|
||||
|| VersionUtil.isFlying(player) || player.getVehicle() != null
|
||||
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) {
|
||||
// This was a teleport or user is flying/using elytra/in a vehicle, so we don't
|
||||
// care
|
||||
// about it.
|
||||
// care about it.
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player)
|
||||
@@ -133,8 +130,6 @@ public final class FlightCheck {
|
||||
// End AirFlight
|
||||
|
||||
// Start AirClimb
|
||||
// TODO three hardcoded values here shouldn't be there, temp against false
|
||||
// positive
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0
|
||||
&& movementManager.motionY > 0 && movementManager.airTicks == 2
|
||||
&& Math.round(movementManager.lastMotionY * 1000) != 420
|
||||
@@ -153,7 +148,6 @@ public final class FlightCheck {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + movementManager.motionY + ")");
|
||||
|
||||
// TODO hardcoded value against false again..
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
|
||||
&& movementManager.airTicks > 2 && !velocityTracker.isVelocitized()
|
||||
&& !player.hasPotionEffect(PotionEffectType.JUMP)
|
||||
@@ -165,7 +159,6 @@ public final class FlightCheck {
|
||||
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
|
||||
// TODO hardcoded value against false
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
|
||||
&& movementManager.lastMotionY < 0 && movementManager.motionY > 0
|
||||
&& !velocityTracker.isVelocitized()
|
||||
@@ -176,6 +169,15 @@ public final class FlightCheck {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
|
||||
if (movementManager.airTicks >= minAirTicks && movementManager.motionY > 0
|
||||
&& velocityTracker.getVertical() <= 0.0D && movementManager.slimeInfluenceTicks <= 0
|
||||
&& movementManager.elytraEffectTicks <= 25
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + movementManager.motionY + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
// End AirClimb
|
||||
|
||||
// Start GroundFlight
|
||||
@@ -195,8 +197,8 @@ public final class FlightCheck {
|
||||
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
|
||||
&& !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25
|
||||
&& !VersionUtil.isSlowFalling(player)) {
|
||||
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
|
||||
double offset = Math.abs(gravitatedY - movementManager.motionY);
|
||||
final double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
|
||||
final double offset = Math.abs(gravitatedY - movementManager.motionY);
|
||||
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
|
||||
if (Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0))
|
||||
|| Utilities.isNearClimbable(distance.getFrom()) || Utilities.isNearWater(player)
|
||||
@@ -214,7 +216,7 @@ public final class FlightCheck {
|
||||
}
|
||||
} else {
|
||||
if (GRAVITY_VIOLATIONS.containsKey(player.getUniqueId())) {
|
||||
float vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0f);
|
||||
final float vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0f);
|
||||
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 0.5f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,18 +78,12 @@ public final class BadPacketsCheck {
|
||||
maxDistance *= 1.5D;
|
||||
}
|
||||
|
||||
final boolean hasNewLocation = packet.getBooleans().read(0);
|
||||
if (distance > maxDistance) {
|
||||
flag(player, event,
|
||||
"moved too far between packets (distance="
|
||||
+ new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance
|
||||
+ ", at=" + movementManager.airTicks + ")");
|
||||
return;
|
||||
} else if (distance < 1E-10 && !hasNewLocation) {
|
||||
// TODO this gives false positives when teleporting
|
||||
// Only found this in 1.8.8 though
|
||||
// flag(player, event, "sent the same packet twice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class EntityListener extends EventListener {
|
||||
@@ -107,6 +108,12 @@ public class EntityListener extends EventListener {
|
||||
if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.CRITICALS)) {
|
||||
CriticalsCheck.doDamageEvent(e, (Player)e.getDamager());
|
||||
}
|
||||
if (getCheckManager().willCheckQuick((Player)e.getDamager(), CheckType.AIMBOT)) {
|
||||
final CheckResult result = AimbotCheck.runCheck((Player)e.getDamager(), e);
|
||||
if (result.failed()) {
|
||||
log(result.getMessage(), (Player)e.getDamager(), CheckType.AIMBOT, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
@@ -63,7 +63,6 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.BoatFlyCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
|
||||
@@ -518,12 +517,6 @@ public final class PlayerListener extends EventListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
|
||||
final CheckResult result = AimbotCheck.runCheck(player, event);
|
||||
if (result.failed()) {
|
||||
log(result.getMessage(), player, CheckType.AIMBOT, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) {
|
||||
final CheckResult result = VelocityCheck.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
|
||||
@@ -59,6 +59,14 @@ public final class MovementManager {
|
||||
public double lastDistanceX;
|
||||
// Previous horizontal distance on z-axis of movement
|
||||
public double lastDistanceZ;
|
||||
// Delta pitch
|
||||
public float deltaPitch;
|
||||
// Delta yaw
|
||||
public float deltaYaw;
|
||||
// Previous delta pitch
|
||||
public float lastDeltaPitch;
|
||||
// Previous delta yaw
|
||||
public float lastDeltaYaw;
|
||||
// If the player touched the ground again this tick
|
||||
public boolean touchedGroundThisTick = false;
|
||||
// Last recorded distance
|
||||
@@ -117,6 +125,11 @@ public final class MovementManager {
|
||||
this.distanceXZ = Math.sqrt(x * x + z * z);
|
||||
this.distanceX = x;
|
||||
this.distanceZ = z;
|
||||
|
||||
this.lastDeltaPitch = this.deltaPitch;
|
||||
this.lastDeltaYaw = this.deltaYaw;
|
||||
this.deltaPitch = Math.abs(to.getPitch() - from.getPitch());
|
||||
this.deltaYaw = Math.abs(Utilities.computeAngleDifference(to.getYaw(), from.getYaw()));
|
||||
|
||||
// Account for standing on boat
|
||||
if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player)) {
|
||||
|
||||
@@ -101,11 +101,13 @@ public class UpdateManager {
|
||||
|
||||
public class VersionSplit implements Comparable<VersionSplit> {
|
||||
private final int major, minor, build;
|
||||
private boolean prerelease = false;
|
||||
|
||||
public VersionSplit(String version) throws Exception {
|
||||
if (version.endsWith("-ALPHA")) {
|
||||
version = version.substring(0, version.length() - 6);
|
||||
} else if (version.endsWith("-PRE")) {
|
||||
this.prerelease = true;
|
||||
version = version.substring(0, version.length() - 4);
|
||||
}
|
||||
|
||||
@@ -132,11 +134,15 @@ public class UpdateManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(VersionSplit other) {
|
||||
public int compareTo(final VersionSplit other) {
|
||||
if (other.major == this.major) {
|
||||
if (other.minor == this.minor) {
|
||||
if (other.build == this.build) {
|
||||
return 0;
|
||||
if (!this.prerelease) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (other.build > this.build) {
|
||||
return -1;
|
||||
|
||||
@@ -840,7 +840,40 @@ public final class Utilities {
|
||||
}
|
||||
return block.getType() == XMaterial.HONEY_BLOCK.parseMaterial();
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the difference between two angles
|
||||
* @param a Angle A
|
||||
* @param b Angle B
|
||||
* @return the difference between two angles
|
||||
*/
|
||||
public static float computeAngleDifference(final float a, final float b) {
|
||||
float diff = Math.abs(a - b);
|
||||
final float altDiff = b + 360 - a;
|
||||
final float altAltDiff = a + 360 - b;
|
||||
if (altDiff < diff) diff = altDiff;
|
||||
if (altAltDiff < diff) diff = altAltDiff;
|
||||
return diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the greatest common divider
|
||||
* @param a value a
|
||||
* @param b value b
|
||||
* @return the greatest common divider of a and b
|
||||
*/
|
||||
public static double computeGcd(final double a, final double b) {
|
||||
if (a < b) {
|
||||
return computeGcd(b, a);
|
||||
}
|
||||
|
||||
if (Math.abs(b) < 0.001) {
|
||||
return a;
|
||||
} else {
|
||||
return computeGcd(b, a - Math.floor(a / b) * b);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
MinecraftVersion currentVersion = MinecraftVersion.getCurrentVersion();
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ public class VersionUtil {
|
||||
}
|
||||
|
||||
static {
|
||||
SUPPORTED_VERSIONS = Arrays.asList(new String[] { "v1_17_R1", "v1_16", "v1_15", "v1_14", "v1_13", "v1_12" });
|
||||
SUPPORTED_VERSIONS = Arrays.asList(new String[] { "v1_17", "v1_16", "v1_15", "v1_14", "v1_13", "v1_12" });
|
||||
CURRENT_VERSION = MinecraftVersion.getCurrentVersion();
|
||||
}
|
||||
}
|
||||
@@ -99,9 +99,9 @@ strafe:
|
||||
# How many milliseconds to account for teleports
|
||||
accountForTeleports: 300
|
||||
# Maximum angle change when moving in air
|
||||
maxAngleChange: 0.5
|
||||
maxAngleChange: 0.58
|
||||
# Minimum movement distance for the strafe check to be active
|
||||
minActivationDistance: 0.04
|
||||
minActivationDistance: 0.05
|
||||
# WaterWalk check settings
|
||||
# Checks if a player is walking on water
|
||||
waterwalk:
|
||||
@@ -174,7 +174,7 @@ killaura:
|
||||
# Should this part of the check be enabled?
|
||||
enabled: true
|
||||
# Maximum difference in angle from the players view
|
||||
maxDifference: 50
|
||||
maxDifference: 60
|
||||
# Amount of illegally angled hits before flagging
|
||||
vlBeforeFlag: 3
|
||||
# Checks if the player has a suspicious packet order
|
||||
@@ -193,10 +193,10 @@ killaura:
|
||||
aimbot:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
# Minimum yaw difference when repeated
|
||||
minYaw: 30
|
||||
# Maximum yaw difference when repeated
|
||||
maxYaw: 355
|
||||
# Maximum gcd value for check to consider aim illegal
|
||||
maxGcd: 0.002
|
||||
# Maximum mod value for check to consider aim illegal
|
||||
maxMod: 0.003
|
||||
# Criticals check settings
|
||||
# Checks if the player tries to do a crit without needed conditions
|
||||
criticals:
|
||||
@@ -269,11 +269,11 @@ morepackets:
|
||||
# Should this check be enabled?
|
||||
enabled: true
|
||||
# Minimum server TPS needed for MorePackets to be active
|
||||
minimumTps: 17.5
|
||||
minimumTps: 18.5
|
||||
# Maximum amount of lag compensation a player can acquire (50ms = 1 tick)
|
||||
minimumClamp: 1200
|
||||
minimumClamp: 1250
|
||||
# The amount of milliseconds offset between packets before flagging (50ms = 1 tick)
|
||||
triggerBalance: 150
|
||||
triggerBalance: 200
|
||||
# The amount of milliseconds to compensate for a teleport (50ms = 1 tick)
|
||||
teleportCompensation: 500
|
||||
# Should this check be disabled for 'lagging' players?
|
||||
|
||||
Reference in new issue
Block a user