From e799b7d09343288ee2a9730b1c794f7638c81345 Mon Sep 17 00:00:00 2001 From: Dawson Hessler Date: Thu, 17 Sep 2020 21:51:45 -0400 Subject: [PATCH] Revert "Revert "Push"" This reverts commit b6bacad4a9644acbdec1de2e1c0ec696aca74a6e. --- .../brighten/anticheat/check/FreeChecks.java | 1 + .../check/impl/packets/badpackets}/Timer.java | 4 +-- .../utils/ExponentialMovingAverage.java | 19 ++++++++++ .../anticheat/premium/impl/VelocityB.java | 8 +++-- .../anticheat/check/RegularChecks.java | 4 +-- .../impl/movement/velocity/VelocityC.java | 8 +++-- .../anticheat/check/impl/packets/TimerB.java | 36 +++++++++++++++++++ 7 files changed, 70 insertions(+), 10 deletions(-) rename {Regular/src/main/java/dev/brighten/anticheat/check/impl/packets => Free/src/main/java/dev/brighten/anticheat/check/impl/packets/badpackets}/Timer.java (91%) create mode 100644 Impl/src/main/java/dev/brighten/anticheat/utils/ExponentialMovingAverage.java create mode 100644 Regular/src/main/java/dev/brighten/anticheat/check/impl/packets/TimerB.java diff --git a/Free/src/main/java/dev/brighten/anticheat/check/FreeChecks.java b/Free/src/main/java/dev/brighten/anticheat/check/FreeChecks.java index 7b14df3de..db46d8d5b 100644 --- a/Free/src/main/java/dev/brighten/anticheat/check/FreeChecks.java +++ b/Free/src/main/java/dev/brighten/anticheat/check/FreeChecks.java @@ -93,6 +93,7 @@ public void registerChecks() { Check.register(new BadPacketsK()); Check.register(new BadPacketsL()); Check.register(new BadPacketsM()); + Check.register(new Timer()); //Check.register(new BadPacketsN()) } } diff --git a/Regular/src/main/java/dev/brighten/anticheat/check/impl/packets/Timer.java b/Free/src/main/java/dev/brighten/anticheat/check/impl/packets/badpackets/Timer.java similarity index 91% rename from Regular/src/main/java/dev/brighten/anticheat/check/impl/packets/Timer.java rename to Free/src/main/java/dev/brighten/anticheat/check/impl/packets/badpackets/Timer.java index 8999aff21..a2af3d8a3 100644 --- a/Regular/src/main/java/dev/brighten/anticheat/check/impl/packets/Timer.java +++ b/Free/src/main/java/dev/brighten/anticheat/check/impl/packets/badpackets/Timer.java @@ -1,4 +1,4 @@ -package dev.brighten.anticheat.check.impl.packets; +package dev.brighten.anticheat.check.impl.packets.badpackets; import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInFlyingPacket; import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInTransactionPacket; @@ -12,7 +12,7 @@ import dev.brighten.api.check.CheckType; import lombok.val; -@CheckInfo(name = "Timer", description = "Checks the rate of packets coming in.", +@CheckInfo(name = "Timer (A)", description = "Checks the rate of packets coming in.", checkType = CheckType.BADPACKETS, vlToFlag = 4, developer = true) @Cancellable public class Timer extends Check { diff --git a/Impl/src/main/java/dev/brighten/anticheat/utils/ExponentialMovingAverage.java b/Impl/src/main/java/dev/brighten/anticheat/utils/ExponentialMovingAverage.java new file mode 100644 index 000000000..ee02aa1a8 --- /dev/null +++ b/Impl/src/main/java/dev/brighten/anticheat/utils/ExponentialMovingAverage.java @@ -0,0 +1,19 @@ +package dev.brighten.anticheat.utils; + +public class ExponentialMovingAverage { + private double alpha; + private Double oldValue; + public ExponentialMovingAverage(double alpha) { + this.alpha = alpha; + } + + public double average(double value) { + if (oldValue == null) { + oldValue = value; + return value; + } + double newValue = oldValue + alpha * (value - oldValue); + oldValue = newValue; + return newValue; + } +} \ No newline at end of file diff --git a/Premium/src/main/java/dev/brighten/anticheat/premium/impl/VelocityB.java b/Premium/src/main/java/dev/brighten/anticheat/premium/impl/VelocityB.java index d1287e9b1..d8d84213c 100644 --- a/Premium/src/main/java/dev/brighten/anticheat/premium/impl/VelocityB.java +++ b/Premium/src/main/java/dev/brighten/anticheat/premium/impl/VelocityB.java @@ -25,9 +25,11 @@ public class VelocityB extends Check { @Packet public void velocity(WrappedOutVelocityPacket packet) { - pvX = packet.getX(); - pvY = packet.getY(); - pvZ = packet.getZ(); + if(packet.getId() == data.getPlayer().getEntityId()) { + pvX = packet.getX(); + pvY = packet.getY(); + pvZ = packet.getZ(); + } } @Packet diff --git a/Regular/src/main/java/dev/brighten/anticheat/check/RegularChecks.java b/Regular/src/main/java/dev/brighten/anticheat/check/RegularChecks.java index 43c2ef7ce..860fd40af 100644 --- a/Regular/src/main/java/dev/brighten/anticheat/check/RegularChecks.java +++ b/Regular/src/main/java/dev/brighten/anticheat/check/RegularChecks.java @@ -21,7 +21,7 @@ import dev.brighten.anticheat.check.impl.movement.speed.SpeedC; import dev.brighten.anticheat.check.impl.movement.velocity.VelocityA; import dev.brighten.anticheat.check.impl.movement.velocity.VelocityC; -import dev.brighten.anticheat.check.impl.packets.Timer; +import dev.brighten.anticheat.check.impl.packets.TimerB; import dev.brighten.anticheat.check.impl.packets.exploits.*; @Init(priority = Priority.LOWEST) @@ -57,7 +57,7 @@ public void registerChecks() { Check.register(new KillauraE()); Check.register(new KillauraF()); Check.register(new OmniSprint()); - Check.register(new Timer()); + Check.register(new TimerB()); Check.register(new VelocityA()); Check.register(new VelocityC()); Check.register(new HandA()); diff --git a/Regular/src/main/java/dev/brighten/anticheat/check/impl/movement/velocity/VelocityC.java b/Regular/src/main/java/dev/brighten/anticheat/check/impl/movement/velocity/VelocityC.java index ccf44c96f..4cd56d9df 100644 --- a/Regular/src/main/java/dev/brighten/anticheat/check/impl/movement/velocity/VelocityC.java +++ b/Regular/src/main/java/dev/brighten/anticheat/check/impl/movement/velocity/VelocityC.java @@ -25,9 +25,11 @@ public class VelocityC extends Check { @Packet public void velocity(WrappedOutVelocityPacket packet) { - pvX = packet.getX(); - pvY = packet.getY(); - pvZ = packet.getZ(); + if(packet.getId() == data.getPlayer().getEntityId()) { + pvX = packet.getX(); + pvY = packet.getY(); + pvZ = packet.getZ(); + } } @Packet diff --git a/Regular/src/main/java/dev/brighten/anticheat/check/impl/packets/TimerB.java b/Regular/src/main/java/dev/brighten/anticheat/check/impl/packets/TimerB.java new file mode 100644 index 000000000..c5b39fdd9 --- /dev/null +++ b/Regular/src/main/java/dev/brighten/anticheat/check/impl/packets/TimerB.java @@ -0,0 +1,36 @@ +package dev.brighten.anticheat.check.impl.packets; + +import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInFlyingPacket; +import cc.funkemunky.api.tinyprotocol.packet.in.WrappedInTransactionPacket; +import cc.funkemunky.api.tinyprotocol.packet.out.WrappedOutPositionPacket; +import cc.funkemunky.api.utils.MathUtils; +import cc.funkemunky.api.utils.math.RollingAverage; +import cc.funkemunky.api.utils.objects.evicting.EvictingList; +import dev.brighten.anticheat.Kauri; +import dev.brighten.anticheat.check.api.Cancellable; +import dev.brighten.anticheat.check.api.Check; +import dev.brighten.anticheat.check.api.CheckInfo; +import dev.brighten.anticheat.check.api.Packet; +import dev.brighten.anticheat.utils.ExponentialMovingAverage; +import dev.brighten.anticheat.utils.MiscUtils; +import dev.brighten.api.check.CheckType; +import lombok.val; + +@CheckInfo(name = "Timer (B)", description = "Checks the rate of packets coming in.", + checkType = CheckType.BADPACKETS, vlToFlag = 4, developer = true) +@Cancellable +public class TimerB extends Check { + + private int ticks, buffer; + private ExponentialMovingAverage average = new ExponentialMovingAverage(50); + private long lastFlying = System.currentTimeMillis(); + + @Packet + public void onPacket(WrappedInFlyingPacket packet, long current) { + + double avg = average.average(current - lastFlying); + + debug("std=%v.5", avg); + lastFlying = current; + } +} \ No newline at end of file