From 05ff193afb8abe53de7f04876c522abdfea5cda7 Mon Sep 17 00:00:00 2001 From: MDIC Date: Tue, 3 May 2022 17:07:13 -0400 Subject: [PATCH] feat (new detection\char sql\conf): Anti-swim Detection added rerun sql for character db to support the new collumn. new conf Anticheat.AntiSwimClimbHack = 1 --- conf/Anticheat.conf.dist | 1 + .../base/charactersdb_anticheat.sql | 2 ++ src/AnticheatData.h | 2 +- src/AnticheatMgr.cpp | 32 ++++++++++++++++--- src/AnticheatMgr.h | 4 ++- src/cs_anticheat.cpp | 2 ++ 6 files changed, 37 insertions(+), 6 deletions(-) diff --git a/conf/Anticheat.conf.dist b/conf/Anticheat.conf.dist index 07d8090..601870c 100644 --- a/conf/Anticheat.conf.dist +++ b/conf/Anticheat.conf.dist @@ -80,6 +80,7 @@ Anticheat.DetectClimbHack = 1 Anticheat.DetectTelePortHack = 1 Anticheat.IgnoreControlHack = 1 Anticheat.DetectZaxisHack =1 +Anticheat.AntiSwimClimbHack = 1 # Anticheat.StricterFlyHackCheck # Description: Checks moveflag ascending (may give false positives) diff --git a/sql/characters/base/charactersdb_anticheat.sql b/sql/characters/base/charactersdb_anticheat.sql index 4855dcc..f04ed1f 100644 --- a/sql/characters/base/charactersdb_anticheat.sql +++ b/sql/characters/base/charactersdb_anticheat.sql @@ -13,6 +13,7 @@ CREATE TABLE IF NOT EXISTS `daily_players_reports` ( `teleport_reports` bigint unsigned NOT NULL DEFAULT 0, `ignorecontrol_reports` bigint unsigned NOT NULL DEFAULT 0, `zaxis_reports` bigint unsigned NOT NULL DEFAULT 0, + `antiswim_reports` bigint unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`guid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; @@ -31,5 +32,6 @@ CREATE TABLE IF NOT EXISTS `players_reports_status` ( `teleport_reports` bigint unsigned NOT NULL DEFAULT 0, `ignorecontrol_reports` bigint unsigned NOT NULL DEFAULT 0, `zaxis_reports` bigint unsigned NOT NULL DEFAULT 0, + `antiswim_reports` bigint unsigned NOT NULL DEFAULT 0, PRIMARY KEY (`guid`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/src/AnticheatData.h b/src/AnticheatData.h index 676caf7..7ba4a56 100644 --- a/src/AnticheatData.h +++ b/src/AnticheatData.h @@ -3,7 +3,7 @@ #include "AnticheatMgr.h" -#define MAX_REPORT_TYPES 9 +#define MAX_REPORT_TYPES 10 class AnticheatData { diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 034b638..2900bc2 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -421,6 +421,10 @@ void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo, { ZAxisHackDetection(player, movementInfo); } + if (player->GetLiquidData().Status == LIQUID_MAP_UNDER_WATER) + { + AntiSwimHackDetection(player, movementInfo); + } m_Players[key].SetLastMovementInfo(movementInfo); m_Players[key].SetLastOpcode(opcode); } @@ -467,6 +471,26 @@ void AnticheatMgr::ClimbHackDetection(Player* player, MovementInfo movementInfo, } } +// basic detection +void AnticheatMgr::AntiSwimHackDetection(Player* player, MovementInfo movementInfo) +{ + if (!sConfigMgr->GetOption("Anticheat.AntiSwimClimbHack", true)) + return; + + if (player->GetLiquidData().Status == LIQUID_MAP_UNDER_WATER && !movementInfo.HasMovementFlag(MOVEMENTFLAG_SWIMMING)) + { + if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) + { + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Anti-Swim-Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); + } + + BuildReport(player, ANTISWIM_HACK_REPORT); + + } +} + void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) { if (!sConfigMgr->GetOption("Anticheat.DetectSpeedHack", true)) @@ -594,8 +618,8 @@ void AnticheatMgr::HandlePlayerLogout(Player* player) } void AnticheatMgr::SavePlayerData(Player* player) -{// 1 2 3 4 5 6 7 8 9 10 11 12 13 - 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,creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), m_Players[player->GetGUID()].GetAverage(), m_Players[player->GetGUID()].GetTotalReports(), m_Players[player->GetGUID()].GetTypeReports(SPEED_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(FLY_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(JUMP_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(WALK_WATER_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(TELEPORT_PLANE_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(CLIMB_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(TELEPORT_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(IGNORE_CONTROL_REPORT), m_Players[player->GetGUID()].GetTypeReports(ZAXIS_HACK_REPORT), m_Players[player->GetGUID()].GetCreationTime()); +{// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + 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,creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), m_Players[player->GetGUID()].GetAverage(), m_Players[player->GetGUID()].GetTotalReports(), m_Players[player->GetGUID()].GetTypeReports(SPEED_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(FLY_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(JUMP_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(WALK_WATER_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(TELEPORT_PLANE_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(CLIMB_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(TELEPORT_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(IGNORE_CONTROL_REPORT), m_Players[player->GetGUID()].GetTypeReports(ZAXIS_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(ANTISWIM_HACK_REPORT), m_Players[player->GetGUID()].GetCreationTime()); } uint32 AnticheatMgr::GetTotalReports(ObjectGuid guid) @@ -686,8 +710,8 @@ void AnticheatMgr::BuildReport(Player* player, uint16 reportType) if (sConfigMgr->GetOption("Anticheat.MaxReportsForDailyReport", 70) < m_Players[key].GetTotalReports()) { if (!m_Players[key].GetDailyReportState()) - {// 1 2 3 4 5 6 7 8 9 10 11 12 13 - 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,creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), m_Players[player->GetGUID()].GetAverage(), m_Players[player->GetGUID()].GetTotalReports(), m_Players[player->GetGUID()].GetTypeReports(SPEED_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(FLY_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(JUMP_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(WALK_WATER_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(TELEPORT_PLANE_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(CLIMB_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(TELEPORT_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(IGNORE_CONTROL_REPORT), m_Players[player->GetGUID()].GetTypeReports(ZAXIS_HACK_REPORT), m_Players[player->GetGUID()].GetCreationTime()); + {// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 + 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,creation_time) VALUES ({},{},{},{},{},{},{},{},{},{},{},{},{},{});", player->GetGUID().GetCounter(), m_Players[player->GetGUID()].GetAverage(), m_Players[player->GetGUID()].GetTotalReports(), m_Players[player->GetGUID()].GetTypeReports(SPEED_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(FLY_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(JUMP_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(WALK_WATER_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(TELEPORT_PLANE_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(CLIMB_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(TELEPORT_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(IGNORE_CONTROL_REPORT), m_Players[player->GetGUID()].GetTypeReports(ZAXIS_HACK_REPORT), m_Players[player->GetGUID()].GetTypeReports(ANTISWIM_HACK_REPORT), m_Players[player->GetGUID()].GetCreationTime()); m_Players[key].SetDailyReportState(true); } } diff --git a/src/AnticheatMgr.h b/src/AnticheatMgr.h index ea84dca..333333c 100644 --- a/src/AnticheatMgr.h +++ b/src/AnticheatMgr.h @@ -36,7 +36,8 @@ enum ReportTypes CLIMB_HACK_REPORT = 5, TELEPORT_HACK_REPORT = 6, IGNORE_CONTROL_REPORT = 7, - ZAXIS_HACK_REPORT = 8 + ZAXIS_HACK_REPORT = 8, + ANTISWIM_HACK_REPORT = 9 // MAX_REPORT_TYPES }; @@ -76,6 +77,7 @@ class AnticheatMgr void JumpHackDetection(Player* player, MovementInfo movementInfo,uint32 opcode); void TeleportPlaneHackDetection(Player* player, MovementInfo); void ClimbHackDetection(Player* player,MovementInfo movementInfo, uint32 opcode); + void AntiSwimHackDetection(Player* player, MovementInfo movementInfo); void TeleportHackDetection(Player* player, MovementInfo movementInfo); void IgnoreControlHackDetection(Player* player, MovementInfo movementInfo); void ZAxisHackDetection(Player* player, MovementInfo movementInfo); diff --git a/src/cs_anticheat.cpp b/src/cs_anticheat.cpp index bbafb73..27bf6dd 100644 --- a/src/cs_anticheat.cpp +++ b/src/cs_anticheat.cpp @@ -207,6 +207,7 @@ public: uint32 teleport_reports = sAnticheatMgr->GetTypeReports(guid, 6); uint32 ignorecontrol_reports = sAnticheatMgr->GetTypeReports(guid, 7); uint32 zaxis_reports = sAnticheatMgr->GetTypeReports(guid, 8); + uint32 antiswim_reports = sAnticheatMgr->GetTypeReports(guid, 9); Player* playerTarget = player->GetConnectedPlayer(); uint32 latency = 0; latency = playerTarget->GetSession()->GetLatency(); @@ -216,6 +217,7 @@ public: handler->PSendSysMessage("Walk On Water Reports: %u || Teleport To Plane Reports: %u", waterwalk_reports, teleportplane_reports); handler->PSendSysMessage("Teleport Reports: %u || Climb Reports: %u", teleport_reports, climb_reports); handler->PSendSysMessage("Ignore Control Reports: %u || Ignore Z-Axis Reports: %u", ignorecontrol_reports, zaxis_reports); + handler->PSendSysMessage("Ignore Anti-Swim Reports: %u", antiswim_reports); return true; } else