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

@@ -64,6 +64,7 @@ public class AntiCheatReloaded extends JavaPlugin {
private static UpdateManager updateManager;
private double tps = -1;
private String symbiosisMetric = "None";
@Override
public void onEnable() {
@@ -109,32 +110,44 @@ public class AntiCheatReloaded extends JavaPlugin {
verboseLog("Finished loading.");
// Metrics
try {
Metrics metrics = new Metrics(this, 202);
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked", new Callable<Integer>() {
@Override
public Integer call() throws Exception {
int kicked = playersKicked;
// Reset so we don't keep sending the same value
playersKicked = 0;
return kicked;
getServer().getScheduler().runTaskLater(this, new Runnable() {
@Override
public void run() {
checkForSymbiosis();
try {
Metrics metrics = new Metrics(AntiCheatReloaded.this, 202);
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked", new Callable<Integer>() {
@Override
public Integer call() throws Exception {
int kicked = playersKicked;
// Reset so we don't keep sending the same value
playersKicked = 0;
return kicked;
}
}));
metrics.addCustomChart(new Metrics.SimplePie("protocollib_version", new Callable<String>() {
@Override
public String call() throws Exception {
return Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
}
}));
metrics.addCustomChart(new Metrics.SimplePie("nms_version", new Callable<String>() {
@Override
public String call() throws Exception {
return VersionUtil.getVersion();
}
}));
metrics.addCustomChart(new Metrics.SimplePie("symbiosis", new Callable<String>() {
@Override
public String call() throws Exception {
return symbiosisMetric;
}
}));
} catch (Exception e) {
e.printStackTrace();
}
}));
metrics.addCustomChart(new Metrics.SimplePie("protocollib_version", new Callable<String>() {
@Override
public String call() throws Exception {
return Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
}
}));
metrics.addCustomChart(new Metrics.SimplePie("nms_version", new Callable<String>() {
@Override
public String call() throws Exception {
return VersionUtil.getVersion();
}
}));
} catch (Exception e) {
e.printStackTrace();
}
}
}, 90L);
// Launch TPS check
new BukkitRunnable() {
@@ -269,6 +282,49 @@ public class AntiCheatReloaded extends JavaPlugin {
this.playersKicked++;
}
/**
* Creates metric that checks for anti-cheat symbiosis
* I use this to see if AntiCheatReloaded is actively being used
* together with other anti-cheats, so I can account for that.
*/
protected void checkForSymbiosis() {
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "NoCheatPlus";
} else {
this.symbiosisMetric += ", NoCheatPlus";
}
}
if (Bukkit.getPluginManager().getPlugin("Matrix") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "Matrix";
} else {
this.symbiosisMetric += ", Matrix";
}
}
if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "AAC";
} else {
this.symbiosisMetric += ", AAC";
}
}
if (Bukkit.getPluginManager().getPlugin("Spartan") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "Spartan";
} else {
this.symbiosisMetric += ", Spartan";
}
}
if (Bukkit.getPluginManager().getPlugin("Negativity") != null) {
if (this.symbiosisMetric.equals("None")) {
this.symbiosisMetric = "Negativity";
} else {
this.symbiosisMetric += ", Negativity";
}
}
}
public static void sendToMainThread(Runnable runnable) {
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
}
@@ -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;
}
}
@@ -58,6 +58,7 @@ import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
import com.rammelkast.anticheatreloaded.check.CheckResult;
import com.rammelkast.anticheatreloaded.check.CheckType;
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
@@ -465,10 +466,10 @@ public class PlayerListener extends EventListener {
user.setGoodLocation(event.getFrom());
}
}
if (getCheckManager().willCheckQuick(player, CheckType.KILLAURA)) {
CheckResult result = KillAuraCheck.checkAimbot(player, event);
if (getCheckManager().willCheckQuick(player, CheckType.AIMBOT)) {
CheckResult result = AimbotCheck.runCheck(player, event);
if (result.failed()) {
log(result.getMessage(), player, CheckType.KILLAURA);
log(result.getMessage(), player, CheckType.AIMBOT);
}
}
}
@@ -1,44 +0,0 @@
/*
* 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.util;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class NameGenerator {
private static final List<String> BEGIN = Arrays.asList(new String[] { "Pixel", "Pro", "NoHax", "Just", "That",
"New", "Ultra", "Killer", "Swift", "Anarchy", "Yolo", "Rammel" });
private static final List<String> END = Arrays.asList(new String[] { "Gamer", "PvP", "JustYolo", "Gaming",
"Minecraft", "Games", "Bawz", "Tech", "Noob", "Extra", "kast", "" + new Random().nextInt(100) });
public static String generateName() {
Random r = new Random();
String begin = BEGIN.get(r.nextInt(BEGIN.size() - 1));
String end = END.get(r.nextInt(END.size() - 1));
if (r.nextBoolean())
return begin + end + r.nextInt(9);
else
return begin + end;
}
}
@@ -26,7 +26,7 @@ public enum Permission {
CHECK_FLIGHT, CHECK_ELYTRA, CHECK_WATERWALK, CHECK_NOSWING, CHECK_FASTBREAK,
CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT, CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP,
CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL, CHECK_KILLAURA, CHECK_LONGREACH, CHECK_UNICODE,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT, CHECK_FASTLADDER,
CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_VISUAL, CHECK_FASTINVENTORY, CHECK_AUTOTOOL, CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGAL_INTERACT, CHECK_FASTLADDER, CHECK_AIMBOT,
/* System Nodes */
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_ALERT, SYSTEM_NOTICE,