mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Add Strafe check, improve KillAura, fix Elytra false positive, fix BadPackets false positive,
This commit is contained in:
1 parent
700c0145f3
commit
a6a39e352a
11 files changed
+112
-27
No files matched your search
@@ -154,6 +154,7 @@ public class Backend {
|
||||
MorePacketsCheck.EXEMPT_TIMINGS.remove(uuid);
|
||||
ElytraCheck.JUMP_Y_VALUE.remove(uuid);
|
||||
KillAuraCheck.ANGLE_FLAGS.remove(uuid);
|
||||
KillAuraCheck.PACKETORDER_FLAGS.remove(uuid);
|
||||
FlightCheck.MOVING_EXEMPT.remove(uuid);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ import org.bukkit.util.Vector;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
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;
|
||||
|
||||
@@ -40,6 +42,8 @@ public class KillAuraCheck {
|
||||
|
||||
// Angle check
|
||||
public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>();
|
||||
// PacketOrder check
|
||||
public static final Map<UUID, Integer> PACKETORDER_FLAGS = new HashMap<UUID, Integer>();
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult checkReach(Player player, Entity target) {
|
||||
@@ -118,6 +122,39 @@ public class KillAuraCheck {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkPacketOrder(Player player, Entity entity) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||
MovementManager movementManager = user.getMovementManager();
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
// Check if enabled
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "packetOrder"))
|
||||
return PASS;
|
||||
|
||||
if (user.isLagging() || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100
|
||||
|| AntiCheatReloaded.getPlugin().getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "packetOrder", "minimumTps"))
|
||||
return PASS;
|
||||
|
||||
long elapsed = System.currentTimeMillis() - movementManager.lastUpdate;
|
||||
if (elapsed < checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "minElapsedTime")) {
|
||||
if (!PACKETORDER_FLAGS.containsKey(uuid)) {
|
||||
PACKETORDER_FLAGS.put(uuid, 1);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
int flags = PACKETORDER_FLAGS.get(uuid);
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "vlBeforeFlag");
|
||||
if (flags >= vlBeforeFlag) {
|
||||
PACKETORDER_FLAGS.remove(uuid);
|
||||
return new CheckResult(Result.FAILED, "suspicious packet order (elapsed=" + elapsed + ")");
|
||||
}
|
||||
|
||||
PACKETORDER_FLAGS.put(uuid, flags + 1);
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static double calculateYawDifference(Location from, Location to) {
|
||||
Location clonedFrom = from.clone();
|
||||
Vector startVector = clonedFrom.toVector();
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class ElytraCheck {
|
||||
@@ -38,10 +39,9 @@ public class ElytraCheck {
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
// No elytra in server version
|
||||
if (VersionUtil.isBountifulUpdate()) {
|
||||
// No elytra in server version or not relevant
|
||||
if (VersionUtil.isBountifulUpdate() || Utilities.isNearWater(player))
|
||||
return PASS;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()) {
|
||||
|
||||
@@ -62,8 +62,7 @@ public class FlightCheck {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement
|
||||
|| Utilities.isNearClimbable(player))
|
||||
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player))
|
||||
return PASS;
|
||||
|
||||
int minAirTicks = 13;
|
||||
@@ -76,7 +75,7 @@ public class FlightCheck {
|
||||
|
||||
// Start AirFlight
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks
|
||||
&& !backend.justVelocity(player)) {
|
||||
&& !backend.justVelocity(player) && movementManager.elytraEffectTicks <= 25) {
|
||||
// Config default base is 1200ms
|
||||
// Ping clamped to max. 1000 to prevent spoofing for an advantage
|
||||
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||
@@ -144,8 +143,7 @@ public class FlightCheck {
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
|
||||
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock())
|
||||
&& movementManager.groundTicks > 2) {
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock()) && movementManager.groundTicks > 2) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"faked ground to fly (mY=" + movementManager.motionY + ", gt=" + movementManager.groundTicks + ")");
|
||||
}
|
||||
@@ -156,7 +154,7 @@ public class FlightCheck {
|
||||
&& movementManager.motionY < 0 && !backend.justVelocity(player)
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
|
||||
&& !Utilities.isInWeb(player)) {
|
||||
&& !Utilities.isInWeb(player) && movementManager.elytraEffectTicks <= 25) {
|
||||
double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
|
||||
double offset = Math.abs(gravitatedY - movementManager.motionY);
|
||||
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
|
||||
|
||||
@@ -24,7 +24,9 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
@@ -38,21 +40,28 @@ public class StrafeCheck {
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(Player player, double x, double z, Location from, Location to) {
|
||||
if (!Utilities.cantStandAtExp(from) || !Utilities.cantStandAtExp(to))
|
||||
if (!Utilities.cantStandAtExp(from) || !Utilities.cantStandAtExp(to) || Utilities.isNearWater(player)
|
||||
|| Utilities.isNearClimbable(player))
|
||||
return PASS;
|
||||
|
||||
|
||||
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getMovementManager();
|
||||
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
if (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig.getInteger(CheckType.STRAFE,
|
||||
"accountForTeleports") || movementManager.elytraEffectTicks >= 20)
|
||||
return PASS;
|
||||
|
||||
Vector oldAcceleration = new Vector(movementManager.lastDistanceX, 0, movementManager.lastDistanceZ);
|
||||
Vector newAcceleration = new Vector(x, 0, z);
|
||||
|
||||
// TODO fix false with bouncing off walls
|
||||
|
||||
float angle = newAcceleration.angle(oldAcceleration);
|
||||
double distance = newAcceleration.lengthSquared();
|
||||
if (angle > 0.25 && distance > 0.025)
|
||||
if (angle > checksConfig
|
||||
.getDouble(CheckType.STRAFE, "maxAngleChange") && distance > checksConfig
|
||||
.getDouble(CheckType.STRAFE, "minActivationDistance") && Utilities.cantStandFar(to.getBlock()))
|
||||
return new CheckResult(Result.FAILED, "switched angle in air (angle=" + angle + ", dist=" + distance + ")");
|
||||
return PASS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
public class BadPacketsCheck {
|
||||
@@ -39,9 +40,10 @@ public class BadPacketsCheck {
|
||||
public static void runCheck(Player player, PacketEvent event) {
|
||||
Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
// Confirm if we should even check for BadPackets
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS) || backend.isMovingExempt(player)) {
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
|
||||
|| backend.isMovingExempt(player) || player.isDead())
|
||||
return;
|
||||
}
|
||||
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
PacketContainer packet = event.getPacket();
|
||||
float pitch = packet.getFloat().read(1);
|
||||
@@ -50,13 +52,15 @@ public class BadPacketsCheck {
|
||||
flag(player, event, "had an illegal pitch");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
double tps = AntiCheatReloaded.getPlugin().getTPS();
|
||||
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")) {
|
||||
MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId())
|
||||
.getMovementManager();
|
||||
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")
|
||||
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 100))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
double x = packet.getDoubles().read(0);
|
||||
double y = packet.getDoubles().read(1);
|
||||
double z = packet.getDoubles().read(2);
|
||||
@@ -68,12 +72,13 @@ public class BadPacketsCheck {
|
||||
double maxDistance = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance");
|
||||
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 + ")");
|
||||
flag(player, event, "moved too far between packets (distance="
|
||||
+ new BigDecimal(distance).setScale(1, RoundingMode.HALF_UP) + ", max=" + maxDistance + ")");
|
||||
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");
|
||||
// flag(player, event, "sent the same packet twice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class CommandBase {
|
||||
execute(cs, args);
|
||||
} else {
|
||||
if (args == null) {
|
||||
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion());
|
||||
cs.sendMessage(GRAY + "Running " + GOLD + "" + "AntiCheatReloaded " + GRAY + "version " + AntiCheatReloaded.getVersion());
|
||||
} else {
|
||||
cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
|
||||
}
|
||||
|
||||
@@ -153,6 +153,14 @@ public class EntityListener extends EventListener {
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||
CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (noHack) {
|
||||
decrease(player);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,8 @@ public class MovementManager {
|
||||
public int sneakingTicks;
|
||||
// Ticks counter after being near a liquid
|
||||
public int nearLiquidTicks;
|
||||
// Time of last update
|
||||
public long lastUpdate;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void handle(Player player, Location from, Location to, Distance distance) {
|
||||
@@ -177,6 +179,7 @@ public class MovementManager {
|
||||
this.halfMovementHistoryCounter--;
|
||||
}
|
||||
|
||||
this.lastUpdate = System.currentTimeMillis();
|
||||
// Update "good location"
|
||||
AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId()).setGoodLocation(from);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user