From 9e81a435d4869c6191f78e85e35f6f345b5f58f2 Mon Sep 17 00:00:00 2001 From: M'Dic Date: Wed, 5 Apr 2023 16:53:21 -0400 Subject: [PATCH] add (db\gm cmd): CM DB Logging\GM CM Display added counter measure report type in database added new row when using .anticheat player to show deployed counter measures on player as some countermeasures will not count the actual cheat count in the db --- sql/updates/characters/AC_2023_04_05_00.sql | 38 +++++++++++++++++++++ src/AnticheatData.h | 2 +- src/AnticheatMgr.cpp | 31 ++++++++++------- src/AnticheatMgr.h | 4 +-- src/cs_anticheat.cpp | 3 ++ 5 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 sql/updates/characters/AC_2023_04_05_00.sql diff --git a/sql/updates/characters/AC_2023_04_05_00.sql b/sql/updates/characters/AC_2023_04_05_00.sql new file mode 100644 index 0000000..90f8bf8 --- /dev/null +++ b/sql/updates/characters/AC_2023_04_05_00.sql @@ -0,0 +1,38 @@ +-- run on Characters DB + +DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; +DELIMITER // +CREATE PROCEDURE updatemodanticheatdb() +proc:BEGIN +SELECT COUNT(*) INTO @COLEXISTS +FROM information_schema.COLUMNS +WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'daily_players_reports' AND COLUMN_NAME = 'counter_measures_reports'; +IF @COLEXISTS = 1 THEN LEAVE proc; END IF; +START TRANSACTION; + +ALTER TABLE `daily_players_reports` + ADD COLUMN `counter_measures_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `op_ack_hack_reports`; + +END // +DELIMITER ; + +CALL updatemodanticheatdb(); + +DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; +DELIMITER // +CREATE PROCEDURE updatemodanticheatdb() +proc:BEGIN +SELECT COUNT(*) INTO @COLEXISTS +FROM information_schema.COLUMNS +WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'players_reports_status' AND COLUMN_NAME = 'counter_measures_reports'; +IF @COLEXISTS = 1 THEN LEAVE proc; END IF; +START TRANSACTION; + +ALTER TABLE `players_reports_status` + ADD COLUMN `counter_measures_reports` BIGINT UNSIGNED NOT NULL DEFAULT 0 AFTER `op_ack_hack_reports`; + +END // +DELIMITER ; + +CALL updatemodanticheatdb(); +DROP PROCEDURE IF EXISTS `updatemodanticheatdb`; diff --git a/src/AnticheatData.h b/src/AnticheatData.h index c6ad6e4..accd58e 100644 --- a/src/AnticheatData.h +++ b/src/AnticheatData.h @@ -27,7 +27,7 @@ #include "AnticheatMgr.h" -#define MAX_REPORT_TYPES 14 +#define MAX_REPORT_TYPES 15 class AnticheatData { diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 6f43c50..e968f6f 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -238,7 +238,7 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); } timeDiff = 1; - BuildReport(player, SPEED_HACK_REPORT); + BuildReport(player, COUNTER_MEASURES_REPORT); } if (!timeDiff && sConfigMgr->GetOption("Anticheat.CM.TIMEMANIPULATION", true)) @@ -260,7 +260,7 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); } timeDiff = 1; - BuildReport(player, SPEED_HACK_REPORT); + BuildReport(player, COUNTER_MEASURES_REPORT); } // this is the distance doable by the player in 1 sec, using the time done to move to this point. @@ -299,7 +299,6 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) { slowcheater->SetDuration(1000); } - BuildReport(player, SPEED_HACK_REPORT); if (sConfigMgr->GetOption("Anticheat.CM.WriteLog", true)) { LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Speed Hack Countered and has been set to Server Rate.", player->GetName()); @@ -316,6 +315,7 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) 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()); } + BuildReport(player, COUNTER_MEASURES_REPORT); } BuildReport(player, SPEED_HACK_REPORT); } @@ -387,7 +387,7 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) 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()); } - BuildReport(player, FLY_HACK_REPORT); + BuildReport(player, COUNTER_MEASURES_REPORT); } BuildReport(player, FLY_HACK_REPORT); @@ -446,7 +446,7 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo movementInfo, 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()); } - BuildReport(player, JUMP_HACK_REPORT); + BuildReport(player, COUNTER_MEASURES_REPORT); } BuildReport(player, JUMP_HACK_REPORT); } @@ -513,7 +513,7 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo movementInfo, 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()); } - BuildReport(player, JUMP_HACK_REPORT); + BuildReport(player, COUNTER_MEASURES_REPORT); } BuildReport(player, JUMP_HACK_REPORT); } @@ -739,6 +739,7 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn sWorld->SendGMText(LANG_ANTICHEAT_COUNTERMEASURE, str.c_str(), player->GetName().c_str(), player->GetName().c_str()); } player->TeleportTo(player->GetMapId(), lastX, lastY, lastZ, player->GetOrientation()); + BuildReport(player, COUNTER_MEASURES_REPORT); } BuildReport(player, TELEPORT_HACK_REPORT); } @@ -995,7 +996,7 @@ void AnticheatMgr::ZAxisHackDetection(Player* player, MovementInfo movementInfo) 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()); } - BuildReport(player, ZAXIS_HACK_REPORT); + BuildReport(player, COUNTER_MEASURES_REPORT); } BuildReport(player, ZAXIS_HACK_REPORT); } @@ -1187,6 +1188,7 @@ void AnticheatMgr::CheckStartPositions(Player* player) 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()); } + BuildReport(player, COUNTER_MEASURES_REPORT); player->TeleportTo(player->GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation()); } } @@ -1419,15 +1421,15 @@ void AnticheatMgr::CheckForOrderAck(uint32 opcode) void AnticheatMgr::SavePlayerData(Player* player) { AnticheatData playerData = m_Players[player->GetGUID()]; - // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 - CharacterDatabase.Execute("REPLACE INTO players_reports_status (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_reports,teleport_reports,ignorecontrol_reports,zaxis_reports,antiswim_reports,gravity_reports,antiknockback_reports,no_fall_damage_reports,op_ack_hack_reports,creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), playerData.GetAverage(), playerData.GetTotalReports(), playerData.GetTypeReports(SPEED_HACK_REPORT), playerData.GetTypeReports(FLY_HACK_REPORT), playerData.GetTypeReports(JUMP_HACK_REPORT), playerData.GetTypeReports(WALK_WATER_HACK_REPORT), playerData.GetTypeReports(TELEPORT_PLANE_HACK_REPORT), playerData.GetTypeReports(CLIMB_HACK_REPORT), playerData.GetTypeReports(TELEPORT_HACK_REPORT), playerData.GetTypeReports(IGNORE_CONTROL_REPORT), playerData.GetTypeReports(ZAXIS_HACK_REPORT), playerData.GetTypeReports(ANTISWIM_HACK_REPORT), playerData.GetTypeReports(GRAVITY_HACK_REPORT), playerData.GetTypeReports(ANTIKNOCK_BACK_HACK_REPORT), playerData.GetTypeReports(NO_FALL_DAMAGE_HACK_REPORT), playerData.GetTypeReports(OP_ACK_HACK_REPORT), playerData.GetCreationTime()); + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + CharacterDatabase.Execute("REPLACE INTO players_reports_status (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_reports,teleport_reports,ignorecontrol_reports,zaxis_reports,antiswim_reports,gravity_reports,antiknockback_reports,no_fall_damage_reports,op_ack_hack_reports,counter_measures_reports, creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), playerData.GetAverage(), playerData.GetTotalReports(), playerData.GetTypeReports(SPEED_HACK_REPORT), playerData.GetTypeReports(FLY_HACK_REPORT), playerData.GetTypeReports(JUMP_HACK_REPORT), playerData.GetTypeReports(WALK_WATER_HACK_REPORT), playerData.GetTypeReports(TELEPORT_PLANE_HACK_REPORT), playerData.GetTypeReports(CLIMB_HACK_REPORT), playerData.GetTypeReports(TELEPORT_HACK_REPORT), playerData.GetTypeReports(IGNORE_CONTROL_REPORT), playerData.GetTypeReports(ZAXIS_HACK_REPORT), playerData.GetTypeReports(ANTISWIM_HACK_REPORT), playerData.GetTypeReports(GRAVITY_HACK_REPORT), playerData.GetTypeReports(ANTIKNOCK_BACK_HACK_REPORT), playerData.GetTypeReports(NO_FALL_DAMAGE_HACK_REPORT), playerData.GetTypeReports(OP_ACK_HACK_REPORT), playerData.GetTypeReports(COUNTER_MEASURES_REPORT), playerData.GetCreationTime()); } void AnticheatMgr::SavePlayerDataDaily(Player* player) { AnticheatData playerData = m_Players[player->GetGUID()]; - // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 - CharacterDatabase.Execute("REPLACE INTO daily_players_reports (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_reports,teleport_reports,ignorecontrol_reports,zaxis_reports,antiswim_reports,gravity_reports,antiknockback_reports,no_fall_damage_reports,op_ack_hack_reports,creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), playerData.GetAverage(), playerData.GetTotalReports(), playerData.GetTypeReports(SPEED_HACK_REPORT), playerData.GetTypeReports(FLY_HACK_REPORT), playerData.GetTypeReports(JUMP_HACK_REPORT), playerData.GetTypeReports(WALK_WATER_HACK_REPORT), playerData.GetTypeReports(TELEPORT_PLANE_HACK_REPORT), playerData.GetTypeReports(CLIMB_HACK_REPORT), playerData.GetTypeReports(TELEPORT_HACK_REPORT), playerData.GetTypeReports(IGNORE_CONTROL_REPORT), playerData.GetTypeReports(ZAXIS_HACK_REPORT), playerData.GetTypeReports(ANTISWIM_HACK_REPORT), playerData.GetTypeReports(GRAVITY_HACK_REPORT), playerData.GetTypeReports(ANTIKNOCK_BACK_HACK_REPORT), playerData.GetTypeReports(NO_FALL_DAMAGE_HACK_REPORT), playerData.GetTypeReports(OP_ACK_HACK_REPORT), playerData.GetCreationTime()); + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + CharacterDatabase.Execute("REPLACE INTO players_reports_status (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_reports,teleport_reports,ignorecontrol_reports,zaxis_reports,antiswim_reports,gravity_reports,antiknockback_reports,no_fall_damage_reports,op_ack_hack_reports,counter_measures_reports, creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), playerData.GetAverage(), playerData.GetTotalReports(), playerData.GetTypeReports(SPEED_HACK_REPORT), playerData.GetTypeReports(FLY_HACK_REPORT), playerData.GetTypeReports(JUMP_HACK_REPORT), playerData.GetTypeReports(WALK_WATER_HACK_REPORT), playerData.GetTypeReports(TELEPORT_PLANE_HACK_REPORT), playerData.GetTypeReports(CLIMB_HACK_REPORT), playerData.GetTypeReports(TELEPORT_HACK_REPORT), playerData.GetTypeReports(IGNORE_CONTROL_REPORT), playerData.GetTypeReports(ZAXIS_HACK_REPORT), playerData.GetTypeReports(ANTISWIM_HACK_REPORT), playerData.GetTypeReports(GRAVITY_HACK_REPORT), playerData.GetTypeReports(ANTIKNOCK_BACK_HACK_REPORT), playerData.GetTypeReports(NO_FALL_DAMAGE_HACK_REPORT), playerData.GetTypeReports(OP_ACK_HACK_REPORT), playerData.GetTypeReports(COUNTER_MEASURES_REPORT), playerData.GetCreationTime()); } uint32 AnticheatMgr::GetTotalReports(ObjectGuid guid) { @@ -1467,6 +1469,9 @@ bool AnticheatMgr::MustCheckTempReports(uint8 type) if (type == OP_ACK_HACK_REPORT) return false; + if (type == COUNTER_MEASURES_REPORT) + return false; + return true; } @@ -1532,8 +1537,8 @@ void AnticheatMgr::BuildReport(Player* player, uint16 reportType) if (!m_Players[key].GetDailyReportState()) { AnticheatData playerData = m_Players[player->GetGUID()]; - // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 - CharacterDatabase.Execute("REPLACE INTO daily_players_reports (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_reports,teleport_reports,ignorecontrol_reports,zaxis_reports,antiswim_reports,gravity_reports,antiknockback_reports,no_fall_damage_reports,op_ack_hack_reports,creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), playerData.GetAverage(), playerData.GetTotalReports(), playerData.GetTypeReports(SPEED_HACK_REPORT), playerData.GetTypeReports(FLY_HACK_REPORT), playerData.GetTypeReports(JUMP_HACK_REPORT), playerData.GetTypeReports(WALK_WATER_HACK_REPORT), playerData.GetTypeReports(TELEPORT_PLANE_HACK_REPORT), playerData.GetTypeReports(CLIMB_HACK_REPORT), playerData.GetTypeReports(TELEPORT_HACK_REPORT), playerData.GetTypeReports(IGNORE_CONTROL_REPORT), playerData.GetTypeReports(ZAXIS_HACK_REPORT), playerData.GetTypeReports(ANTISWIM_HACK_REPORT), playerData.GetTypeReports(GRAVITY_HACK_REPORT), playerData.GetTypeReports(ANTIKNOCK_BACK_HACK_REPORT), playerData.GetTypeReports(NO_FALL_DAMAGE_HACK_REPORT), playerData.GetTypeReports(OP_ACK_HACK_REPORT), playerData.GetCreationTime()); + // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 + CharacterDatabase.Execute("REPLACE INTO players_reports_status (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_reports,teleport_reports,ignorecontrol_reports,zaxis_reports,antiswim_reports,gravity_reports,antiknockback_reports,no_fall_damage_reports,op_ack_hack_reports,counter_measures_reports, creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), playerData.GetAverage(), playerData.GetTotalReports(), playerData.GetTypeReports(SPEED_HACK_REPORT), playerData.GetTypeReports(FLY_HACK_REPORT), playerData.GetTypeReports(JUMP_HACK_REPORT), playerData.GetTypeReports(WALK_WATER_HACK_REPORT), playerData.GetTypeReports(TELEPORT_PLANE_HACK_REPORT), playerData.GetTypeReports(CLIMB_HACK_REPORT), playerData.GetTypeReports(TELEPORT_HACK_REPORT), playerData.GetTypeReports(IGNORE_CONTROL_REPORT), playerData.GetTypeReports(ZAXIS_HACK_REPORT), playerData.GetTypeReports(ANTISWIM_HACK_REPORT), playerData.GetTypeReports(GRAVITY_HACK_REPORT), playerData.GetTypeReports(ANTIKNOCK_BACK_HACK_REPORT), playerData.GetTypeReports(NO_FALL_DAMAGE_HACK_REPORT), playerData.GetTypeReports(OP_ACK_HACK_REPORT), playerData.GetTypeReports(COUNTER_MEASURES_REPORT), playerData.GetCreationTime()); m_Players[key].SetDailyReportState(true); } } diff --git a/src/AnticheatMgr.h b/src/AnticheatMgr.h index d19d14e..7352f4b 100644 --- a/src/AnticheatMgr.h +++ b/src/AnticheatMgr.h @@ -51,8 +51,8 @@ enum ReportTypes GRAVITY_HACK_REPORT = 10, ANTIKNOCK_BACK_HACK_REPORT = 11, NO_FALL_DAMAGE_HACK_REPORT = 12, - OP_ACK_HACK_REPORT = 13 - + OP_ACK_HACK_REPORT = 13, + COUNTER_MEASURES_REPORT = 14 // MAX_REPORT_TYPES }; diff --git a/src/cs_anticheat.cpp b/src/cs_anticheat.cpp index 8c05498..6e9cde6 100644 --- a/src/cs_anticheat.cpp +++ b/src/cs_anticheat.cpp @@ -227,6 +227,7 @@ public: uint32 antiknockback_reports = sAnticheatMgr->GetTypeReports(guid, 11); uint32 no_fall_damage_reports = sAnticheatMgr->GetTypeReports(guid, 12); uint32 op_ack_reports = sAnticheatMgr->GetTypeReports(guid, 13); + uint32 counter_measures_reports = sAnticheatMgr->GetTypeReports(guid, 14); Player* playerTarget = player->GetConnectedPlayer(); uint32 latency = 0; @@ -288,6 +289,7 @@ public: { handler->PSendSysMessage("|cffff0000Macro Requiring Lua Unlock Detected: |cffffff00No"); } + handler->PSendSysMessage("|cffff0000Counter Measures Deployed: |cffffff00%u", counter_measures_reports); handler->PSendSysMessage("|cffff0000Average: |cffffff00%f |cffff0000Total Reports: |cffffff00%u ", average, total_reports); handler->PSendSysMessage("|cffff0000Speed Reports: |cffffff00%u |cffff0000Fly Reports: |cffffff00%u |cffff0000Jump Reports: |cffffff00%u ", speed_reports, fly_reports, jump_reports); handler->PSendSysMessage("|cffff0000Walk On Water Reports:|cffffff00 %u |cffff0000Teleport To Plane Reports: |cffffff00%u", waterwalk_reports, teleportplane_reports); @@ -354,6 +356,7 @@ public: { handler->PSendSysMessage("Macro Requiring Lua Unlock Detected: No"); } + handler->PSendSysMessage("Counter Measures Deployed: %u", counter_measures_reports); handler->PSendSysMessage("Average: %f || Total Reports: %u ", average, total_reports); handler->PSendSysMessage("Speed Reports: %u || Fly Reports: %u || Jump Reports: %u ", speed_reports, fly_reports, jump_reports); handler->PSendSysMessage("Walk On Water Reports: %u || Teleport To Plane Reports: %u", waterwalk_reports, teleportplane_reports);