From b8f35fced941e1fe8da8115e34c771e87024da05 Mon Sep 17 00:00:00 2001 From: PneuJai <53138480+Rjlintkh@users.noreply.github.com> Date: Mon, 24 Jan 2022 10:57:04 +0800 Subject: [PATCH] Uncomment Bad Packets implementations --- index.ts | 75 +++++++++++++++++++-------------- package.json | 2 +- src/modules/misc/bad_packets.ts | 40 ++++++++---------- src/texts/en_US.lang | 19 ++++++++- 4 files changed, 79 insertions(+), 57 deletions(-) diff --git a/index.ts b/index.ts index 6e91b0f..1b2458c 100644 --- a/index.ts +++ b/index.ts @@ -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); @@ -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()); -// // }); -// } \ No newline at end of file +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); + // }); +} \ No newline at end of file diff --git a/package.json b/package.json index 0335b0a..5cdb794 100644 --- a/package.json +++ b/package.json @@ -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": [], diff --git a/src/modules/misc/bad_packets.ts b/src/modules/misc/bad_packets.ts index 9fb3b12..312aa85 100644 --- a/src/modules/misc/bad_packets.ts +++ b/src/modules/misc/bad_packets.ts @@ -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) { @@ -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 { diff --git a/src/texts/en_US.lang b/src/texts/en_US.lang index b3da34e..571912a 100644 --- a/src/texts/en_US.lang +++ b/src/texts/en_US.lang @@ -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]. @@ -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 @@ -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]. @@ -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.