Skip to content

Commit

Permalink
Uncomment Bad Packets implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjlintkh committed Jan 24, 2022
1 parent b4ee4f3 commit b8f35fc
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 57 deletions.
75 changes: 44 additions & 31 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
import { Packet } from "bdsx/bds/packet";
import { MinecraftPacketIds } from "bdsx/bds/packetids";
import { events } from "bdsx/event";
import { Aniketos } from "./src/loader";
import AutoClicker from "./src/modules/combat/autoclicker";
import Reach from "./src/modules/combat/reach";
import BadPackets from "./src/modules/misc/bad_packets";
import Crasher from "./src/modules/misc/crasher";
import EditionFaker from "./src/modules/misc/edition_faker";
import Namespoof from "./src/modules/misc/namespoof";
import NoSwing from "./src/modules/misc/no_swing";
import Spammer from "./src/modules/misc/spammer";
import Toolbox from "./src/modules/misc/toolbox";
import AntiImmobile from "./src/modules/movement/anti_immobile";
import Flight from "./src/modules/movement/flight";
import Freecam from "./src/modules/movement/freecam";
import InventoryMove from "./src/modules/movement/inventory_move";
import Gamemode from "./src/modules/world/gamemode";
import Give from "./src/modules/world/give";
import Nuker from "./src/modules/world/nuker";
import XpOrb from "./src/modules/world/xp_orb";


export const aniketos = new Aniketos();
aniketos.loadModule(new AntiImmobile);
aniketos.loadModule(new AutoClicker);
aniketos.loadModule(new BadPackets);
aniketos.loadModule(new Crasher);
aniketos.loadModule(new EditionFaker);
aniketos.loadModule(new Flight);
aniketos.loadModule(new Freecam);
aniketos.loadModule(new Gamemode);
aniketos.loadModule(new Give);
aniketos.loadModule(new InventoryMove);
aniketos.loadModule(new Namespoof);
Expand All @@ -31,35 +40,39 @@ aniketos.loadModule(new Spammer);
aniketos.loadModule(new Toolbox);
aniketos.loadModule(new XpOrb);

// for (let i = 1; i < 164; i++) {
// switch (i) {
// //case MinecraftPacketIds.MovePlayer:
// case MinecraftPacketIds.PlayerAuthInput:
// case MinecraftPacketIds.ClientCacheBlobStatus:
// case MinecraftPacketIds.ClientCacheMissResponse:
// case MinecraftPacketIds.LevelChunk:
// case MinecraftPacketIds.MoveActorDelta:
const packetLogger = false;

// case MinecraftPacketIds.LevelSoundEvent:
// case MinecraftPacketIds.SetActorData:
// case MinecraftPacketIds.NetworkChunkPublisherUpdate:
// case MinecraftPacketIds.SetTime:
// case MinecraftPacketIds.UpdateAttributes:
// case MinecraftPacketIds.SetActorMotion:
// continue;
// }
// events.packetAfter(i).on((pk: Packet, ni) => {
// if (pk.getId() === MinecraftPacketIds.InventoryTransaction) {
// console.log("RECV", "Inv Tran", new Date());
// return;
// }
// console.log("RECV", pk, new Date());
// });
// // events.packetSend(i).on((pk: Packet, ni) => {
// // if (pk.getId() === MinecraftPacketIds.InventoryTransaction) {
// // console.log("RECV", "Inv Tran", new Date());
// // return;
// // }
// // console.log("SEND", pk.getName(), new Date());
// // });
// }
if (packetLogger) {
for (let i = 1; i < 164; i++) {
switch (i) {
//case MinecraftPacketIds.MovePlayer:
case MinecraftPacketIds.PlayerAuthInput:
case MinecraftPacketIds.ClientCacheBlobStatus:
case MinecraftPacketIds.ClientCacheMissResponse:
case MinecraftPacketIds.LevelChunk:
case MinecraftPacketIds.MoveActorDelta:

case MinecraftPacketIds.LevelSoundEvent:
case MinecraftPacketIds.SetActorData:
case MinecraftPacketIds.NetworkChunkPublisherUpdate:
case MinecraftPacketIds.SetTime:
case MinecraftPacketIds.UpdateAttributes:
case MinecraftPacketIds.SetActorMotion:
continue;
}
events.packetAfter(i).on((pk: Packet, ni) => {
//console.log("RECV", pk, new Date());
});
// events.packetSend(i).on((pk: Packet, ni) => {
// if (pk.getId() === MinecraftPacketIds.InventoryTransaction) {
// console.log("RECV", "Inv Tran", new Date());
// return;
// }
// console.log("SEND", pk.getName(), new Date());
// });
}

// events.packetBefore(MinecraftPacketIds.ItemStackRequest).on((pk, ni) => {
// console.log("DROP", pk);
// });
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bdsx/aniketos",
"version": "2.1.1",
"version": "2.2.0",
"description": "An anti-cheat plugin for bdsx",
"main": "index.js",
"keywords": [],
Expand Down
40 changes: 17 additions & 23 deletions src/modules/misc/bad_packets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class BadPackets extends ModuleBase {
suspect.chat.invalidType=Chat message is not of type chat.
suspect.chat.mismatchedNames=Chat author and player name do not match.
*/};

load(): void {
this.listen(events.packetBefore(MinecraftPacketIds.Text), (pk, ni) => {
if (pk.message.length > 512) {
Expand All @@ -34,35 +34,29 @@ export default class BadPackets extends ModuleBase {
}
const name = ni.getActor()!.getName();
if (pk.name !== name) {
this.suspect(ni, this.translate("suspect.chat.invalidType"));
this.suspect(ni, this.translate("suspect.chat.mismatchedNames"));
pk.name = name;
return;
}
});
{
// @ts-expect-error
if (ServerPlayer.prototype.isRiding !== undefined) {
this.listen(events.packetBefore(MinecraftPacketIds.MoveActorAbsolute), (pk, ni) => {
const player = ni.getActor()!;
// @ts-ignore
if (player.isRiding()) {
return CANCEL;
}
});
}
this.listen(events.packetBefore(MinecraftPacketIds.MoveActorAbsolute), (pk, ni) => {
const player = ni.getActor()!;
if (player.isRiding()) {
return CANCEL;
}
});
}
{
// @ts-expect-error
if (ServerPlayer.prototype.stopSleepInBed !== undefined) {
const original = LL.hooking("?changeDimension@ServerPlayer@@UEAAXV?$AutomaticID@VDimension@@H@@_N@Z", void_t, null, ServerPlayer, int32_t, bool_t)
((player, dimensionId: DimensionId, useNetherPortal) => {
if (useNetherPortal && (player.getSleepTimer() > 0)) {
// @ts-ignore
player.stopSleepInBed(true, true);
}
return original(player, dimensionId, useNetherPortal);
});
}
const original = LL.hooking("?changeDimension@ServerPlayer@@UEAAXV?$AutomaticID@VDimension@@H@@_N@Z", void_t, null, ServerPlayer, int32_t, bool_t)
((player, dimensionId: DimensionId, useNetherPortal) => {
// if (useNetherPortal && (player.getSleepTimer() > 0)) {
if (useNetherPortal && player.isSleeping()) {
// player.stopSleepInBed(true, true);
player.setSleeping(false);
}
return original(player, dimensionId, useNetherPortal);
});
}
}
unload(): void {
Expand Down
19 changes: 17 additions & 2 deletions src/texts/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ base.command.output.moduleEnable=Module %s has been enabled.
base.command.output.moduleDisable=Module %s has been disabled.
base.command.output.moduleReload=Reloaded all modules.
base.command.output.configChange=%s has been changed.
base.module.command.desc.generic=Configures module %s of Aniketos.
modules.AntiImmobile.name=Anti-Immobile
modules.AntiImmobile.description=Detects if players still moves with immobile flag.
modules.AntiImmobile.suspect.generic=Player still moves with immobile flag.
modules.AutoClicker.name=Auto Clicker
modules.AutoClicker.description=Checks if players are clicking too fast or consistently.
modules.AutoClicker.suspect.tooFast=Clicking too fast at [%s CPS].
Expand All @@ -37,13 +41,16 @@ modules.Flight.suspect.invalidPositionMode=Invalid player position mode [144], p
modules.Freecam.name=Freecam
modules.Freecam.description=Detects if players stop sending packets.
modules.Freecam.suspect.generic=Client stopped sending movement packets for [%s ms].
modules.Gamemode.name=Gamemode
modules.Gamemode.description=Blocks client-side gamemode setting.
modules.Gamemode.suspect.generic=Set self gamemode from [%1] to [%2].
modules.Give.name=Give
modules.Give.description=Blocks Toolbox give and enchant, Horion give, nbt, rename, repair and enchant.
modules.Give.suspect.Toolbox=Matched cheating-like container ids, the action will be cancelled if it really is.
modules.Give.suspect.Horion=Matched hex of [02 9F 8D 06 09] at position [%s], the action will be cancelled if it really is.
modules.Give.broadcast.cancelled=An inventory transaction is detected to be cheating and is cancelled.
modules.InventoryMove.name=Inventory Move
modules.InventoryMove.description=Detects if players still move when opening inventory screens. (Does not work for Horion)
modules.InventoryMove.description=Detects if players still move when opening inventory screens.
modules.InventoryMove.suspect.generic=Player still moving when opening inventory screen.
modules.InventoryMove.punish.generic=Do not move when opening inventory screen.
modules.Namespoof.name=Namespoof
Expand All @@ -61,7 +68,7 @@ modules.Nuker.name=Nuker
modules.Nuker.description=Checks if players destroy blocks faster than expected time.
modules.Nuker.suspect.instabreak=Invoked creative block destruction in survival mode.
modules.Nuker.suspect.tooFast=Destroyed block [%1] in [%2 ticks] but expected to be [%3 ticks].
modules.Nuker.suspect.didNotStart=Destroyed block [%1] before starting.
modules.Nuker.suspect.didNotStart=Desktroyed block [%1] before starting.
modules.Reach.name=Reach
modules.Reach.description=Checks if players aim entities further than expected distance.
modules.Reach.suspect.tooFarAway=Aiming too far away from [%s Blocks].
Expand All @@ -75,3 +82,11 @@ modules.Toolbox.punish.generic=Do not use Toolbox.
modules.XpOrb.name=Xp Orb
modules.XpOrb.description=Blocks illegal XP orbs.
modules.XpOrb.suspect.generic=Spawned XP orbs of amount [%s].
modules.XpOrb.suspect.level=Give self [%s] levels of XP.
modules.AntiImmobile.punish.generic=You are not allowed to move.
modules.Gamemode.punish.generic=Do not spoof your gamemode.
modules.BadPackets.name=Bad Packets
modules.BadPackets.description=Detects packets with invalid data and some bug fixes.
modules.BadPackets.suspect.chat.messageTooLong=Chat message is longer than 512 characters.
modules.BadPackets.suspect.chat.invalidType=Chat message is not of type chat.
modules.BadPackets.suspect.chat.mismatchedNames=Chat author and player name do not match.

0 comments on commit b8f35fc

Please sign in to comment.