From 11379cb5d0309f58a619bd6e103ac6ace4f495d4 Mon Sep 17 00:00:00 2001 From: "hamecyn@gmail.com" Date: Fri, 9 Jun 2023 20:22:49 -0400 Subject: [PATCH 1/2] Remove duplicate messages in middle of the screen + remove lowest average from anticheat global command --- src/AnticheatMgr.cpp | 275 ++++++++++++++----------------------------- src/AnticheatMgr.h | 1 + 2 files changed, 89 insertions(+), 187 deletions(-) diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index f3e26b5..4e9efdb 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -135,6 +135,13 @@ void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo, m_Players[key].SetLastInformations(movementInfo, opcode, GetPlayerCurrentSpeedRate(player)); } +void AnticheatMgr::SendMiddleScreenGMMessage(std::string str) +{ + WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); + data << str; + sWorld->SendGlobalGMMessage(&data); +} + uint32 AnticheatMgr::GetTeleportSkillCooldownDurationInMS(Player* player) const { switch (player->getClass()) @@ -261,16 +268,13 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Time Diff Corrected (Map: {}) (possible Out of Order Time Manipulation) - Flagged at: {}", player->GetName(), player->GetMapId(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] TIME MANIPULATION COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] TIME MANIPULATION COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 TIME MANIPULATION COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 TIME MANIPULATION COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } timeDiff = 1; BuildReport(player, COUNTER_MEASURES_REPORT); @@ -284,16 +288,13 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Time Diff Corrected (Map: {}) (possible Zero Time Manipulation) - Flagged at: {}", player->GetName(), player->GetMapId(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] TIME MANIPULATION COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] TIME MANIPULATION COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 TIME MANIPULATION COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 TIME MANIPULATION COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } timeDiff = 1; BuildReport(player, COUNTER_MEASURES_REPORT); @@ -352,16 +353,13 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Speed Hack Countered and has been set to Server Rate - Flagged at: {}", player->GetName(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] SPEED COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] SPEED COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 SPEED HACK COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 SPEED HACK COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } BuildReport(player, COUNTER_MEASURES_REPORT); } @@ -403,12 +401,7 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) } if (sConfigMgr->GetOption("Anticheat.CM.FLYHACK", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] FLY HACK COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); - + { WorldPacket cheater(12); cheater.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY); cheater << player->GetPackGUID(); @@ -420,16 +413,13 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Fly Hack Countered and has Opcode set to SMSG_MOVE_UNSET_CAN_FLY - Flagged at: {}", player->GetName(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] FLY HACK COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] FLY HACK COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 FLY HACK COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 FLY HACK COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } BuildReport(player, COUNTER_MEASURES_REPORT); } @@ -463,12 +453,7 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo movementInfo, LOG_INFO("anticheat.module", "AnticheatMgr:: Jump-Hack detected player {} ({}) - Latency: {} ms - IP: {} - Cheat Flagged At: {}", player->GetName(), player->GetGUID().ToString(), latency, player->GetSession()->GetRemoteAddress().c_str(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.JUMPHACK", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] JUMP HACK COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); - + { player->GetMotionMaster()->MoveFall(); if (sConfigMgr->GetOption("Anticheat.CM.WriteLog", true)) @@ -477,16 +462,13 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo movementInfo, LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} JUMP Hack Countered and has been set to fall - Flagged at: {}", player->GetName(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] JUMP COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] JUMP HACK COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 JUMP HACK COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 JUMP HACK COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } BuildReport(player, COUNTER_MEASURES_REPORT); } @@ -510,10 +492,8 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo movementInfo, if (m_Players[key].GetLastOpcode() == MSG_MOVE_JUMP && !player->IsFalling()) return; - uint32 distance2D = (uint32)movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos); - // This is necessary since MovementHandler fires if you rotate the camera in place - if (!distance2D) + if (!movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos)) return; if (!player->HasUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY) && movementInfo.jump.zspeed < -10.0f) @@ -534,12 +514,7 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo movementInfo, LOG_INFO("anticheat.module", "AnticheatMgr:: Stricter Check Jump-Hack detected player {} ({}) - Latency: {} ms - IP: {} - Cheat Flagged At: {}", player->GetName(), player->GetGUID().ToString(), latency, player->GetSession()->GetRemoteAddress().c_str(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ADVJUMPHACK", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] ADVANCE JUMP HACK COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); - + { player->GetMotionMaster()->MoveFall(); if (sConfigMgr->GetOption("Anticheat.CM.WriteLog", true)) @@ -548,16 +523,13 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo movementInfo, LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} ADVANCE JUMP Hack Countered and has been set to fall - Flagged at: {}", player->GetName(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] ADVANCE JUMP COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] ADVANCE JUMP HACK COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 ADVANCE JUMP HACK COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 ADVANCE JUMP HACK COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } BuildReport(player, COUNTER_MEASURES_REPORT); } @@ -592,11 +564,9 @@ void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movem ObjectGuid key = player->GetGUID(); - uint32 distance2D = (uint32)movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos); - // We don't need to check for a water walking hack if the player hasn't moved // This is necessary since MovementHandler fires if you rotate the camera in place - if (!distance2D) + if (!movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos)) return; if (m_Players[key].GetLastOpcode() == MSG_MOVE_JUMP) @@ -748,10 +718,8 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn { Player* opponent = player->duel->Opponent; - std::string str = "|cFFFFFC00[DUEL ALERT Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible Teleport Hack Detected! While Dueling [|cFF60FF00" + opponent->GetName() + "|cFF00FFFF]"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + SendMiddleScreenGMMessage("|cFFFFFC00[DUEL ALERT Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible Teleport Hack Detected! While Dueling [|cFF60FF00" + opponent->GetName() + "|cFF00FFFF]"); + uint32 latency = player->GetSession()->GetLatency(); std::string goXYZ = ".go xyz " + std::to_string(player->GetPositionX()) + " " + std::to_string(player->GetPositionY()) + " " + std::to_string(player->GetPositionZ() + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation()); std::string goXYZ2 = ".go xyz " + std::to_string(opponent->GetPositionX()) + " " + std::to_string(opponent->GetPositionY()) + " " + std::to_string(opponent->GetPositionZ() + 1.0f) + " " + std::to_string(opponent->GetMap()->GetId()) + " " + std::to_string(opponent->GetOrientation()); @@ -780,15 +748,12 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn _alertFrequency = 1; if (++_counter % _alertFrequency == 0) { - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible Teleport Hack Detected!"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); - uint32 latency = player->GetSession()->GetLatency(); + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible Teleport Hack Detected!"); + // need better way to limit chat spam if (m_Players[key].GetTotalReports() >= sConfigMgr->GetOption("Anticheat.ReportinChat.Min", 70) && m_Players[key].GetTotalReports() <= sConfigMgr->GetOption("Anticheat.ReportinChat.Max", 80)) { + uint32 latency = player->GetSession()->GetLatency(); sWorld->SendGMText(LANG_ANTICHEAT_TELEPORT, player->GetName().c_str(), player->GetName().c_str(), latency, xDiff, yDiff, zDiff); } _counter = 0; @@ -808,16 +773,13 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} TELEPORT HACK REVERTED PLAYER BACK TO {}", player->GetName(), LastgoXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] TELEPORT HACK COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] TELEPORT HACK COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 TELEPORT COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 TELEPORT COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } player->TeleportTo(player->GetMapId(), lastX, lastY, lastZ, player->GetOrientation()); BuildReport(player, COUNTER_MEASURES_REPORT); @@ -832,12 +794,6 @@ void AnticheatMgr::IgnoreControlHackDetection(Player* player, MovementInfo movem { ObjectGuid key = player->GetGUID(); - float lastX = m_Players[key].GetLastMovementInfo().pos.GetPositionX(); - float newX = movementInfo.pos.GetPositionX(); - - float lastY = m_Players[key].GetLastMovementInfo().pos.GetPositionY(); - float newY = movementInfo.pos.GetPositionY(); - if (!sConfigMgr->GetOption("Anticheat.IgnoreControlHack", true)) return; @@ -850,10 +806,17 @@ void AnticheatMgr::IgnoreControlHackDetection(Player* player, MovementInfo movem if (movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_SWIMMING)) return; - bool hasBadLatency = player->GetSession()->GetLatency() >= 400; + uint32 latency = player->GetSession()->GetLatency(); + bool hasBadLatency = latency >= 400; if (player->HasAuraType(SPELL_AURA_MOD_ROOT) && !player->GetVehicle() && !hasBadLatency) { + float lastX = m_Players[key].GetLastMovementInfo().pos.GetPositionX(); + float newX = movementInfo.pos.GetPositionX(); + + float lastY = m_Players[key].GetLastMovementInfo().pos.GetPositionY(); + float newY = movementInfo.pos.GetPositionY(); + bool unrestricted = newX != lastX || newY != lastY; if (unrestricted) { @@ -865,15 +828,11 @@ void AnticheatMgr::IgnoreControlHackDetection(Player* player, MovementInfo movem _alertFrequency = 1; if (++_counter % _alertFrequency == 0) { - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible Ignore Control Hack Detected!"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible Ignore Control Hack Detected!"); + // need better way to limit chat spam if (m_Players[key].GetTotalReports() >= sConfigMgr->GetOption("Anticheat.ReportinChat.Min", 70) && m_Players[key].GetTotalReports() <= sConfigMgr->GetOption("Anticheat.ReportinChat.Max", 80)) { - uint32 latency = player->GetSession()->GetLatency(); sWorld->SendGMText(LANG_ANTICHEAT_IGNORECONTROL, player->GetName().c_str(), latency); } _counter = 0; @@ -881,7 +840,6 @@ void AnticheatMgr::IgnoreControlHackDetection(Player* player, MovementInfo movem } if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - uint32 latency = player->GetSession()->GetLatency(); std::string goXYZ = ".go xyz " + std::to_string(player->GetPositionX()) + " " + std::to_string(player->GetPositionY()) + " " + std::to_string(player->GetPositionZ() + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation()); LOG_INFO("anticheat.module", "AnticheatMgr:: Ignore Control - Hack detected player {} ({}) - Latency: {} ms - IP: {} - Cheat Flagged At: {}", player->GetName(), player->GetGUID().ToString(), latency, player->GetSession()->GetRemoteAddress().c_str(), goXYZ); } @@ -922,11 +880,9 @@ void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo movemen ObjectGuid key = player->GetGUID(); - uint32 distance2D = (uint32)movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos); - // We don't need to check for a water walking hack if the player hasn't moved // This is necessary since MovementHandler fires if you rotate the camera in place - if (!distance2D) + if (!movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos)) return; if (player->GetLiquidData().Status == LIQUID_MAP_WATER_WALK && !player->IsFlying()) @@ -1013,11 +969,9 @@ void AnticheatMgr::ZAxisHackDetection(Player* player, MovementInfo movementInfo) ObjectGuid key = player->GetGUID(); - uint32 distance2D = (uint32)movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos); - // We don't need to check for a ignore z if the player hasn't moved // This is necessary since MovementHandler fires if you rotate the camera in place - if (!distance2D) + if (!movementInfo.pos.GetExactDist2d(&m_Players[key].GetLastMovementInfo().pos)) return; // This is Black Magic. Check only for x and y difference but no z difference that is greater then or equal to z +2.5 of the ground @@ -1032,11 +986,8 @@ void AnticheatMgr::ZAxisHackDetection(Player* player, MovementInfo movementInfo) _alertFrequency = 1; if (++_counter % _alertFrequency == 0) { - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible Ignore Zaxis Hack Detected!"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible Ignore Zaxis Hack Detected!"); + // need better way to limit chat spam if (m_Players[key].GetTotalReports() >= sConfigMgr->GetOption("Anticheat.ReportinChat.Min", 70) && m_Players[key].GetTotalReports() <= sConfigMgr->GetOption("Anticheat.ReportinChat.Max", 80)) { @@ -1053,12 +1004,7 @@ void AnticheatMgr::ZAxisHackDetection(Player* player, MovementInfo movementInfo) LOG_INFO("anticheat.module", "AnticheatMgr:: Ignore Zaxis Hack detected player {} ({}) - Latency: {} ms - IP: {} - Cheat Flagged At: {}", player->GetName(), player->GetGUID().ToString(), latency, player->GetSession()->GetRemoteAddress().c_str(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.IGNOREZ", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] IGNORE-Z HACK COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); - + { player->GetMotionMaster()->MoveFall(); if (sConfigMgr->GetOption("Anticheat.CM.WriteLog", true)) @@ -1067,16 +1013,13 @@ void AnticheatMgr::ZAxisHackDetection(Player* player, MovementInfo movementInfo) LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} IGNORE-Z Hack Countered and has been set to fall - Flagged at: {}", player->GetName(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] IGNORE-Z COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] IGNORE-Z HACK COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 IGNORE-Z HACK COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 IGNORE-Z HACK COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } BuildReport(player, COUNTER_MEASURES_REPORT); } @@ -1206,15 +1149,12 @@ void AnticheatMgr::BGreport(Player* player) { ObjectGuid key = player->GetGUID(); - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Player Outside of Starting SPOT before BG has started!"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); - uint32 latency = player->GetSession()->GetLatency(); + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Player Outside of Starting SPOT before BG has started!"); + // need better way to limit chat spam if (m_Players[key].GetTotalReports() >= sConfigMgr->GetOption("Anticheat.ReportinChat.Min", 70) && m_Players[key].GetTotalReports() <= sConfigMgr->GetOption("Anticheat.ReportinChat.Max", 80)) { + uint32 latency = player->GetSession()->GetLatency(); sWorld->SendGMText(LANG_ANTICHEAT_BG_EXPLOIT, player->GetName().c_str(), player->GetName().c_str(), latency); } _counter = 0; @@ -1250,16 +1190,13 @@ void AnticheatMgr::CheckStartPositions(Player* player) LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: Sending {} back to start location (BG Map: {}) (possible exploit) - Flagged at: {}", player->GetName(), player->GetMapId(), goXYZ); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) - { // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] BG START SPOT COUNTER MEASURE ALERT"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + { + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] BG START SPOT COUNTER MEASURE ALERT"); } if (sConfigMgr->GetOption("Anticheat.CM.ALERTCHAT", true)) { - std::string str = "|cFFFFFC00 BG START SPOT COUNTER MEASURE ALERT"; - sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); + const char* str = "|cFFFFFC00 BG START SPOT COUNTER MEASURE ALERT"; + sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str, player->GetName().c_str(), player->GetName().c_str()); } BuildReport(player, COUNTER_MEASURES_REPORT); player->TeleportTo(player->GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation()); @@ -1595,15 +1532,12 @@ void AnticheatMgr::BuildReport(Player* player, ReportTypes reportType) _alertFrequency = 1; if (++_counter % _alertFrequency == 0) { - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible cheater!"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); - uint32 latency = player->GetSession()->GetLatency(); + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Possible cheater!"); + // need better way to limit chat spam if (m_Players[key].GetTotalReports() >= sConfigMgr->GetOption("Anticheat.ReportinChat.Min", 70) && m_Players[key].GetTotalReports() <= sConfigMgr->GetOption("Anticheat.ReportinChat.Max", 80)) { + uint32 latency = player->GetSession()->GetLatency(); sWorld->SendGMText(LANG_ANTICHEAT_ALERT, player->GetName().c_str(), player->GetName().c_str(), latency); } _counter = 0; @@ -1616,11 +1550,8 @@ void AnticheatMgr::BuildReport(Player* player, ReportTypes reportType) { LOG_INFO("anticheat.module", "AnticheatMgr:: Reports reached assigned threshhold and counteracted by kicking player {} ({})", player->GetName(), player->GetGUID().ToString()); } - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Auto Kicked for Reaching Cheat Threshhold!"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Auto Kicked for Reaching Cheat Threshhold!"); player->GetSession()->KickPlayer(true); if (sConfigMgr->GetOption("Anticheat.AnnounceKick", true)) @@ -1642,11 +1573,8 @@ void AnticheatMgr::BuildReport(Player* player, ReportTypes reportType) { LOG_INFO("anticheat.module", "AnticheatMgr:: Reports reached assigned threshhold and counteracted by banning player {} ({})", player->GetName(), player->GetGUID().ToString()); } - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Auto Banned Account for Reaching Cheat Threshhold!"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Auto Banned Account for Reaching Cheat Threshhold!"); std::string accountName; AccountMgr::GetName(player->GetSession()->GetAccountId(), accountName); @@ -1671,11 +1599,8 @@ void AnticheatMgr::BuildReport(Player* player, ReportTypes reportType) { LOG_INFO("anticheat.module", "AnticheatMgr:: Reports reached assigned threshhold and counteracted by jailing player {} ({})", player->GetName(), player->GetGUID().ToString()); } - // display warning at the center of the screen, hacky way? - std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Auto Jailed Account for Reaching Cheat Threshhold!"; - WorldPacket data(SMSG_NOTIFICATION, str.size() + 1); - data << str; - sWorld->SendGlobalGMMessage(&data); + + SendMiddleScreenGMMessage("|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + player->GetName() + "|cFF00FFFF] Auto Jailed Account for Reaching Cheat Threshhold!"); // GM Jail Location is uncommit and used as default for the jailing. Feel free to commit it out with double forward slashes (//) and uncommit, // removing the double forward slashes (//) if you wish to use the other locations. @@ -1718,45 +1643,15 @@ void AnticheatMgr::AnticheatGlobalCommand(ChatHandler* handler) { // save All Anticheat Player Data before displaying global stats for (SessionMap::const_iterator itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr) + { if (Player* plr = itr->second->GetPlayer()) { sAnticheatMgr->SavePlayerData(plr); sAnticheatMgr->SavePlayerDataDaily(plr); } - - QueryResult resultDB = CharacterDatabase.Query("SELECT guid,average,total_reports FROM players_reports_status WHERE total_reports != 0 ORDER BY average ASC LIMIT 3;"); - if (!resultDB) - { - handler->PSendSysMessage("No players found."); - return; - } - else - { - handler->SendSysMessage("============================="); - handler->PSendSysMessage("Players with the lowest averages:"); - do - { - Field* fieldsDB = resultDB->Fetch(); - - ObjectGuid guid = ObjectGuid::Create(fieldsDB[0].Get()); - float average = fieldsDB[1].Get(); - uint32 total_reports = fieldsDB[2].Get(); - - if (Player* player = ObjectAccessor::FindConnectedPlayer(guid)) - handler->PSendSysMessage("Player: %s Average: %f Total Reports: %u", player->GetName().c_str(), average, total_reports); - - } while (resultDB->NextRow()); } - resultDB = CharacterDatabase.Query("SELECT guid,average,total_reports FROM players_reports_status WHERE total_reports != 0 ORDER BY total_reports DESC LIMIT 3;"); - - // this should never happen - if (!resultDB) - { - handler->PSendSysMessage("No players found."); - return; - } - else + if (QueryResult resultDB = CharacterDatabase.Query("SELECT `guid`, `average`, `total_reports` FROM `players_reports_status` WHERE `total_reports` != 0 ORDER BY `total_reports` DESC LIMIT 3;")) { handler->PSendSysMessage("============================="); handler->PSendSysMessage("Players with the most reports:"); @@ -1773,6 +1668,12 @@ void AnticheatMgr::AnticheatGlobalCommand(ChatHandler* handler) } while (resultDB->NextRow()); } + else + { + // this should never happen + handler->PSendSysMessage("No players found."); + return; + } } void AnticheatMgr::AnticheatDeleteCommand(ObjectGuid guid) diff --git a/src/AnticheatMgr.h b/src/AnticheatMgr.h index 256e49d..e87dd95 100644 --- a/src/AnticheatMgr.h +++ b/src/AnticheatMgr.h @@ -131,6 +131,7 @@ class AnticheatMgr void BGStartExploit(Player* player, MovementInfo movementInfo); void BuildReport(Player* player, ReportTypes reportType); bool MustCheckTempReports(ReportTypes type); + void SendMiddleScreenGMMessage(std::string str); [[nodiscard]] uint32 GetTeleportSkillCooldownDurationInMS(Player* player) const; [[nodiscard]] float GetTeleportSkillDistanceInYards(Player* player) const; [[nodiscard]] float GetPlayerCurrentSpeedRate(Player* player) const; From b2e96bc08f7f4a39df49fc772c13712d1ec1eed5 Mon Sep 17 00:00:00 2001 From: "hamecyn@gmail.com" Date: Sat, 10 Jun 2023 15:21:04 -0400 Subject: [PATCH 2/2] ignore gnomeregan, scarlet monastery armory, shadow labs and botanica for z-hack detection --- src/AnticheatMgr.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 4e9efdb..338ba57 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -947,21 +947,23 @@ void AnticheatMgr::ZAxisHackDetection(Player* player, MovementInfo movementInfo) return; // We exempt select areas found in 335 to prevent false hack hits - if (player->GetAreaId()) + switch (player->GetAreaId()) { - switch (player->GetAreaId()) - { - case 4273: //Celestial Planetarium Observer Battle has a narrow path that false flags - case 495: //Ring of Judgement just being in the area false flags - case 4161: //Wymrest Temple just being in the area false flags - case 10: // Duskwood bridge - case 40: // Westfall bridge - case 321: // Hammerfall wooden balcony - return; - } + case 10: // Duskwood bridge + case 40: // Westfall bridge + case 321: // Hammerfall wooden balcony + case 495: // Ring of Judgement just being in the area false flags + case 721: // Gnomeregan, some corridor inside the instance, .go xyz -466.640076 260.263092 -208.009796 + case 796: // Scarlet Monastery, armory, .go xyz 1744.680786 -364.786957 8.011654 + case 3789: // Shadow Labyrinth, boxes inside the instance, .go xyz -409.122559 -120.865135 15.713029 + case 3847: // Botanica, Laj's platform, .go xyz -204.576462 391.573334 -11.178043 + case 4161: // Wymrest Temple just being in the area false flags + case 4273: // Celestial Planetarium Observer Battle has a narrow path that false flags + return; + default: + break; } - // We want to exclude this LiquidStatus from detection because it leads to false positives on boats, docks etc. // Basically everytime you stand on a game object in water if (player && player->GetLiquidData().Status == LIQUID_MAP_ABOVE_WATER)