Replaced falsing GCD check, started aimbot check. Added "symbiosis" metric.

This commit is contained in:
Rammelkast committed 2020-05-13 14:52:36 +02:00
1 parent 3538b8934c
commit 7d13aae057
9 files changed
+154 -123

No files matched your search

@@ -37,6 +37,7 @@ import org.bukkit.potion.PotionEffectType;
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.GlideCheck;
@@ -152,6 +153,7 @@ public class Backend {
inventoryClicks.remove(uuid);
lastFallPacket.remove(uuid);
fastSneakViolations.remove(uuid);
AimbotCheck.LAST_DELTA_YAW.remove(uuid);
VelocityCheck.VIOLATIONS.remove(uuid);
MorePacketsCheck.MOVE_COUNT.remove(uuid);
GlideCheck.LAST_MOTION_Y.remove(uuid);
@@ -160,8 +162,6 @@ public class Backend {
SpeedCheck.SPEED_VIOLATIONS.remove(uuid);
ElytraCheck.JUMP_Y_VALUE.remove(uuid);
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
KillAuraCheck.PITCH_MOVEMENTS_CACHE.remove(uuid);
KillAuraCheck.GCD_CACHE.remove(uuid);
FlightCheck.MOVING_EXEMPT.remove(uuid);
FlightCheck.ASCENSION_COUNT.remove(uuid);
FlightCheck.BLOCKS_OVER_FLIGHT.remove(uuid);
@@ -65,7 +65,8 @@ public enum CheckType {
CRITICALS(Permission.CHECK_CRITICALS),
CHAT_UNICODE(Permission.CHECK_UNICODE),
ILLEGAL_INTERACT(Permission.CHECK_ILLEGAL_INTERACT),
FASTLADDER(Permission.CHECK_FASTLADDER);
FASTLADDER(Permission.CHECK_FASTLADDER),
AIMBOT(Permission.CHECK_AIMBOT);
private final Permission permission;
private final Map<UUID, Integer> level = new HashMap<UUID, Integer>();
@@ -18,9 +18,7 @@
*/
package com.rammelkast.anticheatreloaded.check.combat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -29,22 +27,15 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.util.User;
import com.rammelkast.anticheatreloaded.util.Utilities;
public class KillAuraCheck {
// Angle check
public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>();
// Aimbot check
public static final Map<UUID, List<Float>> PITCH_MOVEMENTS_CACHE = new HashMap<UUID, List<Float>>();
public static final Map<UUID, Float> GCD_CACHE = new HashMap<UUID, Float>();
// Not used as of now, code not committed yet
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
public static CheckResult checkAngle(Player player, EntityDamageEvent event) {
@@ -75,43 +66,6 @@ public class KillAuraCheck {
}
return PASS;
}
/**
* Check idea by Hawk AntiCheat (https://github.com/HawkAnticheat/Hawk)
*/
public static CheckResult checkAimbot(Player player, PlayerMoveEvent event) {
UUID uuid = player.getUniqueId();
float pitchMovement = event.getTo().getPitch() - event.getFrom().getPitch();
if (!PITCH_MOVEMENTS_CACHE.containsKey(uuid)) {
PITCH_MOVEMENTS_CACHE.put(uuid, new ArrayList<Float>());
return PASS;
}
List<Float> pitchMovements = PITCH_MOVEMENTS_CACHE.get(uuid);
if (pitchMovement != 0 && Math.abs(pitchMovement) <= 10 && Math.abs(event.getTo().getPitch()) != 90) {
pitchMovements.add(Math.abs(pitchMovement));
}
if (pitchMovements.size() >= 20) {
float greatestCommonDivisor = Utilities.gcdRational(pitchMovements);
if (!GCD_CACHE.containsKey(uuid)) {
GCD_CACHE.put(uuid, greatestCommonDivisor);
}
float divisorDifference = Math.abs(greatestCommonDivisor - GCD_CACHE.get(uuid));
if (divisorDifference > 0.00425 || greatestCommonDivisor < 0.00001) {
pitchMovements.clear();
GCD_CACHE.put(uuid, greatestCommonDivisor);
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
return new CheckResult(CheckResult.Result.FAILED, "performed aimbot-like movements (divisor-diff=" + divisorDifference + ")");
}
pitchMovements.clear();
GCD_CACHE.put(uuid, greatestCommonDivisor);
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
}
PITCH_MOVEMENTS_CACHE.put(uuid, pitchMovements);
return PASS;
}
public static double calculateYawDifference(Location from, Location to) {
Location clonedFrom = from.clone();
@@ -0,0 +1,59 @@
/*
* AntiCheatReloaded for Bukkit and Spigot.
* Copyright (c) 2012-2015 AntiCheat Team
* Copyright (c) 2016-2020 Rammelkast
*
* 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 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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 com.rammelkast.anticheatreloaded.check.CheckResult;
public 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(Player player, PlayerMoveEvent event) {
UUID uuid = player.getUniqueId();
float dYaw = Math.abs(event.getTo().getYaw() - event.getFrom().getYaw());
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);
float absoluteYawDifference = Math.abs(dYaw - lastDeltaYaw);
if (absoluteYawDifference < 1E-8 && dYaw > 30 && dYaw < 360) {
return new CheckResult(CheckResult.Result.FAILED, "repeated yaw difference (dYaw=" + dYaw + ")");
}
return PASS;
}
}