Skip to content

Commit

Permalink
bunch of checks are added or fixed
Browse files Browse the repository at this point in the history
also command now working (only /sentry ping, alerts)
  • Loading branch information
mgmgprndev committed Sep 7, 2024
1 parent a4e019a commit 501065f
Show file tree
Hide file tree
Showing 23 changed files with 507 additions and 137 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.mogukun</groupId>
<artifactId>Sentry</artifactId>
<version>0.0.3</version>
<version>0.1.1</version>
<packaging>jar</packaging>

<name>Sentry</name>
Expand Down
24 changes: 18 additions & 6 deletions src/main/java/com/mogukun/sentry/check/CheckManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

import com.mogukun.sentry.Sentry;
import com.mogukun.sentry.check.checks.combats.aura.AuraA;
import com.mogukun.sentry.check.checks.combats.aura.AuraB;
import com.mogukun.sentry.check.checks.combats.aura.AuraC;
import com.mogukun.sentry.check.checks.combats.autoclicker.AutoClickerA;
import com.mogukun.sentry.check.checks.combats.reach.ReachA;
import com.mogukun.sentry.check.checks.movements.fly.FlyA1;
import com.mogukun.sentry.check.checks.movements.fly.FlyA2;
import com.mogukun.sentry.check.checks.movements.fly.FlyB;
import com.mogukun.sentry.check.checks.movements.fly.*;
import com.mogukun.sentry.check.checks.movements.motion.MotionA;
import com.mogukun.sentry.check.checks.movements.fly.FlyC;
import com.mogukun.sentry.check.checks.movements.speed.SpeedA;
import com.mogukun.sentry.check.checks.movements.speed.SpeedB;
import com.mogukun.sentry.check.checks.movements.speed.SpeedC;
import com.mogukun.sentry.check.checks.movements.speed.SpeedD;
import com.mogukun.sentry.check.checks.movements.wallclimb.WallClimbA;
import com.mogukun.sentry.check.checks.movements.waterwalk.WaterWalkA;
import com.mogukun.sentry.check.checks.players.badpackets.BadPacketA;
import com.mogukun.sentry.check.checks.players.badpackets.BadPacketB;
import com.mogukun.sentry.check.checks.players.badpackets.BadPacketC;
import com.mogukun.sentry.check.checks.players.badpackets.BadPacketD;
import com.mogukun.sentry.check.checks.players.groundspoof.GroundSpoofA;
import com.mogukun.sentry.check.checks.players.groundspoof.GroundSpoofB;
import com.mogukun.sentry.check.checks.players.groundspoof.GroundSpoofC;
Expand Down Expand Up @@ -42,17 +45,26 @@ public class CheckManager {
public CheckManager(){

checks.add( new AuraA() );
checks.add( new AuraB() );
checks.add( new AuraC() );

checks.add( new AutoClickerA() );
checks.add( new ReachA() );

checks.add( new FlyA1() );
checks.add( new FlyA2() );
checks.add( new FlyB() );
checks.add( new FlyC() );
checks.add( new FlyD() );
checks.add( new FlyE() );

checks.add( new SpeedA() );
checks.add( new SpeedB() );
checks.add( new SpeedC() );
checks.add( new SpeedD() );

checks.add( new MotionA() );
checks.add( new FlyC() );


checks.add( new WaterWalkA() );
checks.add( new WallClimbA() );
Expand All @@ -62,11 +74,11 @@ public CheckManager(){
checks.add( new GroundSpoofC() );

checks.add( new TimerA() );
//checks.add( new TimerB() );

checks.add( new BadPacketA() );
checks.add( new BadPacketB() );
checks.add( new BadPacketC() );
checks.add( new BadPacketD() );

checks.add( new InventoryA() );
checks.add( new NoSlowA() );
Expand Down
27 changes: 26 additions & 1 deletion src/main/java/com/mogukun/sentry/check/MovementData.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.Iterator;

public class MovementData {

Expand Down Expand Up @@ -55,9 +56,13 @@ public class MovementData {
public int standingOnBoatTick = 0, sinceStandingOnBoatTick = 0;
public int vehicleTick = 0, sinceVehicleTick = 0;

public boolean isOnStair = false;
public int onStairTick = 0, sinceOnStairTick = 0;


public double lastGroundY = 0, serverFallDistance = 0;

public int teleportTick = 0, sinceVelocityTaken = 0, respawnTick = 0;

public long ping = 0;

Expand All @@ -71,6 +76,10 @@ public MovementData(Player player,
this.player = player;
this.ping = Sentry.instance.dataManager.getPlayerData(player).ping;

teleportTick = Sentry.instance.dataManager.getPlayerData(player).teleportTick++;
sinceVelocityTaken = Sentry.instance.dataManager.getPlayerData(player).sinceVelocityTakenTick++;
respawnTick = Sentry.instance.dataManager.getPlayerData(player).respawnTick++;

Location playerLoc = new Location(player.getWorld(),x,y,z);

colliding = getCollidingBlock( playerLoc );
Expand Down Expand Up @@ -126,6 +135,11 @@ public MovementData(Player player,
if ( block.getType() == Material.WEB ) {
isInWeb = true;
}

if ( block.getType().toString().contains("STAIR") || block.getType().toString().contains("SLAB") ){
isOnStair = true;
}

}

for ( Entity e : collidingEntity ) {
Expand Down Expand Up @@ -244,6 +258,15 @@ public MovementData(Player player,
sinceVehicleTick = 0;
}

onStairTick = lastMovementData.onStairTick + 1;
if ( !isOnStair ) {
onStairTick = 0;
}

sinceOnStairTick = lastMovementData.sinceOnStairTick + 1;
if ( isOnStair ) {
sinceOnStairTick = 0;
}

serverFallDistance = lastMovementData.serverFallDistance;
if ( !serverGround && currentY < lastY ) {
Expand All @@ -256,7 +279,9 @@ public MovementData(Player player,

public ArrayList<Entity> getCollidingEntities(Location playerLocation) {
ArrayList<Entity> temp = new ArrayList<>();
for ( Entity e : new ArrayList<>(playerLocation.getWorld().getEntities()) ) {
Iterator<Entity> iterator = playerLocation.getWorld().getEntities().iterator();
while ( iterator.hasNext() ) {
Entity e = iterator.next();
Location el = e.getLocation().clone();
double dist = el.distance(playerLocation);
if ( dist < 1.6 && e.getUniqueId() != player.getUniqueId() ) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/mogukun/sentry/check/PlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public PlayerData() {}

public long lastOutKeepAlive;
public long lastInKeepAlive;
public long ping;
public long ping = Long.MAX_VALUE;

public int teleportTick = 0, sinceVelocityTakenTick = 0, respawnTick = 0;

}
4 changes: 2 additions & 2 deletions src/main/java/com/mogukun/sentry/check/PlayerDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public PlayerDataUtil(Player player) {

public int getAmplifier(PotionEffectType type) {
for ( PotionEffect e : player.getActivePotionEffects() ) {
if ( e.getType() == type ) return e.getAmplifier();
if ( e.getType().equals(type) ) return e.getAmplifier();
}
return 0;
return -1;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.mogukun.sentry.check.checks.combats.aura;

import com.mogukun.sentry.check.Category;
import com.mogukun.sentry.check.Check;
import com.mogukun.sentry.check.CheckInfo;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;

@CheckInfo(
name = "Aura (B)",
description = "Badly Coded KillAura detection",
category = Category.COMBAT
)
public class AuraB extends Check {

long lastFlyingPacket = 0;

@Override
public void handle(Packet packet) {
long now = System.currentTimeMillis();
if ( packet instanceof PacketPlayInFlying ) {
lastFlyingPacket = now;
}
if ( packet instanceof PacketPlayInUseEntity ) {
long diff = now - lastFlyingPacket;
if ( diff < 5 ) flag("diff=" + diff);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.mogukun.sentry.check.checks.combats.aura;

import com.mogukun.sentry.check.Category;
import com.mogukun.sentry.check.Check;
import com.mogukun.sentry.check.CheckInfo;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInArmAnimation;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;

@CheckInfo(
name = "Aura (C)",
description = "No Swing KillAura Detection",
category = Category.COMBAT
)
public class AuraC extends Check {

long lastArm = 0;

@Override
public void handle(Packet packet) {
long now = System.currentTimeMillis();
if ( packet instanceof PacketPlayInArmAnimation) {
lastArm = now;
}
if ( packet instanceof PacketPlayInUseEntity ) {
long diff = now - lastArm;

if ( diff > 10 ) {
flag("diff=" + diff);
}

}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import org.bukkit.event.entity.EntityDamageByEntityEvent;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedDeque;

@CheckInfo(
name = "Reach (A)",
description = "A Shit Reach Check",
category = Category.COMBAT,
experimental = true
category = Category.COMBAT
)
public class ReachA extends Check {

Expand All @@ -33,7 +33,9 @@ public void handle(MovementData data)
Location playerLocation = player.getLocation().clone();
ping = data.ping;

for ( Entity ent : new ArrayList<>(player.getWorld().getEntities()) ) {
Iterator<Entity> iterator = player.getWorld().getEntities().iterator();
while ( iterator.hasNext() ) {
Entity ent = iterator.next();
Location entLocation = ent.getLocation().clone();
double dist = entLocation.distance(playerLocation);
if ( dist < 10 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
@CheckInfo(
name = "Fly (C)",
description = "Incorrect Air Vertical Motion",
category = Category.MOVEMENT,
experimental = true
category = Category.MOVEMENT
)
public class FlyC extends Check {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.mogukun.sentry.check.checks.movements.fly;

import com.mogukun.sentry.check.Category;
import com.mogukun.sentry.check.Check;
import com.mogukun.sentry.check.CheckInfo;
import com.mogukun.sentry.check.MovementData;

@CheckInfo(
name = "Fly (D)",
description = "Predication Check",
category = Category.MOVEMENT
)
public class FlyD extends Check {

double buffer = 0;

@Override
public void handle(MovementData data)
{
if ( !data.moving ) return;
if ( data.currentDeltaY > 1 ) return;
if ( data.serverAirTick <= 16 ) {
buffer = 0;
return;
}
if ( data.sinceVehicleTick <= 10 || data.sinceStandingOnBoatTick <= 10 || data.sinceWebTick <= 10 || data.sinceWaterTick <= 10 || data.sinceClimbTick <= 10 ) return;

// Credit: CheatGuard @DerRedstoner
double predicated = ( data.lastDeltaY - 0.08 ) * 0.9800000190734863;
double difference = Math.abs(predicated - data.currentDeltaY);

if ( difference > 0.001 ) {
buffer += difference * 10;
if ( buffer > 10 ) {
flag("pred=" + predicated + " real=" + data.currentDeltaY + " diff=" + difference );
buffer -= 1;
}
} else {
buffer -= buffer > 0 ? 0.5 : 0;
}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.mogukun.sentry.check.checks.movements.fly;

import com.mogukun.sentry.check.Category;
import com.mogukun.sentry.check.Check;
import com.mogukun.sentry.check.CheckInfo;
import com.mogukun.sentry.check.MovementData;
import com.mogukun.sentry.models.Counter;

@CheckInfo(
name = "Fly (E)",
description = "Unusual DeltaY Detection",
category = Category.MOVEMENT
)
public class FlyE extends Check {

Counter counter = new Counter();

@Override
public void handle(MovementData data)
{
if ( data.serverAirTick <= 6 ) {
counter.reset();
return;
}

if ( data.sinceVehicleTick <= 10 || data.sinceStandingOnBoatTick <= 10 || data.sinceWebTick <= 10 || data.sinceWaterTick <= 10 || data.sinceClimbTick <= 10 ) return;

if ( data.currentY < data.lastY && data.currentDeltaY <= data.lastDeltaY ) {
if ( counter.count() > 5 ) {
flag();
}
}

}
}


Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
@CheckInfo(
name = "Motion (A)",
description = "Impossible Movement",
category = Category.MOVEMENT,
experimental = true
category = Category.MOVEMENT
)
public class MotionA extends Check {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mogukun.sentry.check.checks.movements.speed;

import com.mogukun.sentry.Sentry;
import com.mogukun.sentry.check.*;
import org.bukkit.potion.PotionEffectType;

Expand All @@ -15,12 +16,12 @@ public class SpeedA extends Check {
@Override
public void handle(MovementData data)
{
if ( data.sinceVehicleTick <= 5 ) return;
if ( data.sinceVehicleTick <= 5 || data.teleportTick <= 5 || data.respawnTick <= 5 ) return;

PlayerDataUtil dataUtil = new PlayerDataUtil(data.player);

double maxDeltaXZ = data.lastDeltaXZ * 1.8;
maxDeltaXZ += dataUtil.getAmplifier(PotionEffectType.SPEED) * 0.1F;
maxDeltaXZ += 0.13 * dataUtil.getAmplifier(PotionEffectType.SPEED) * 0.2F;

if ( data.currentDeltaXZ > maxDeltaXZ ) {

Expand Down
Loading

0 comments on commit 501065f

Please sign in to comment.