From 95a1e71cf41b1879182a6ede54693c9a0f17bfa8 Mon Sep 17 00:00:00 2001 From: acidmanifesto Date: Fri, 11 Feb 2022 10:29:30 -0500 Subject: [PATCH] Updated: Teleport Detection, New Sql, New Conf New Detection Type for Teleport Hack, New SQL column, new conf to enable detection logging of teleport hack. Add notice since new hack detection requires the new teleport helpers introduced with c50f7feda --- README.md | 4 ++ conf/Anticheat.conf.dist | 1 + .../base/charactersdb_anticheat.sql | 37 ++++++++++--------- src/AnticheatMgr.cpp | 37 +++++++++++++++++-- src/AnticheatMgr.h | 6 ++- src/cs_anticheat.cpp | 3 +- 6 files changed, 64 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index cf32f22..175e00b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ This is a port of the PassiveAnticheat Script from lordpsyan's repo to [AzerothCore](http://www.azerothcore.org) +## Notice + +Requires revision [c50f7feda](https://github.com/azerothcore/azerothcore-wotlk/commit/c50f7feda0ee360f7bcca7f004bf6fb22abde533) or newer. + ## How to install ### 1) Simply place the module under the `modules` folder of your AzerothCore source folder. diff --git a/conf/Anticheat.conf.dist b/conf/Anticheat.conf.dist index a3ade82..89b2647 100644 --- a/conf/Anticheat.conf.dist +++ b/conf/Anticheat.conf.dist @@ -61,6 +61,7 @@ Anticheat.DetectJumpHack = 1 Anticheat.DetectTelePlaneHack = 1 Anticheat.DetectSpeedHack = 1 Anticheat.DetectClimbHack = 0 +Anticheat.DetectTelePortHack =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 3504594..65b0380 100644 --- a/sql/characters/base/charactersdb_anticheat.sql +++ b/sql/characters/base/charactersdb_anticheat.sql @@ -1,21 +1,5 @@ -DROP TABLE IF EXISTS `players_reports_status`; - -CREATE TABLE `players_reports_status` ( - `guid` int(10) unsigned NOT NULL DEFAULT '0', - `creation_time` int(10) unsigned NOT NULL DEFAULT '0', - `average` float NOT NULL DEFAULT '0', - `total_reports` bigint(20) unsigned NOT NULL DEFAULT '0', - `speed_reports` bigint(20) unsigned NOT NULL DEFAULT '0', - `fly_reports` bigint(20) unsigned NOT NULL DEFAULT '0', - `jump_reports` bigint(20) unsigned NOT NULL DEFAULT '0', - `waterwalk_reports` bigint(20) unsigned NOT NULL DEFAULT '0', - `teleportplane_reports` bigint(20) unsigned NOT NULL DEFAULT '0', - `climb_reports` bigint(20) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`guid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=''; - DROP TABLE IF EXISTS `daily_players_reports`; -CREATE TABLE `daily_players_reports` ( +CREATE TABLE IF NOT EXISTS `daily_players_reports` ( `guid` int(10) unsigned NOT NULL DEFAULT '0', `creation_time` int(10) unsigned NOT NULL DEFAULT '0', `average` float NOT NULL DEFAULT '0', @@ -26,5 +10,22 @@ CREATE TABLE `daily_players_reports` ( `waterwalk_reports` bigint(20) unsigned NOT NULL DEFAULT '0', `teleportplane_reports` bigint(20) unsigned NOT NULL DEFAULT '0', `climb_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `teleporthack_reports` bigint(20) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`guid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=''; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +DROP TABLE IF EXISTS `players_reports_status`; +CREATE TABLE IF NOT EXISTS `players_reports_status` ( + `guid` int(10) unsigned NOT NULL DEFAULT '0', + `creation_time` int(10) unsigned NOT NULL DEFAULT '0', + `average` float NOT NULL DEFAULT '0', + `total_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `speed_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `fly_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `jump_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `waterwalk_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `teleportplane_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `climb_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + `teleporthack_reports` bigint(20) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`guid`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 47ef305..9d6d34c 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -182,6 +182,34 @@ void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movem } } +void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementInfo) +{ + if (!sConfigMgr->GetOption("Anticheat.DetectTelePortHack", true)) + return; + + ObjectGuid key = player->GetGUID(); + + if (m_Players[key].GetLastMovementInfo().pos.GetPositionX() == movementInfo.pos.GetPositionX()) + return; + + 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(); + + float xDiff = fabs(lastX - newX); + float yDiff = fabs(lastY - newY); + + if ((xDiff >= 50.0f || yDiff >= 50.0f) && !player->CanTeleport()) + { + LOG_INFO("module", "AnticheatMgr:: Teleport-Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + BuildReport(player, TELEPORT_HACK_REPORT); + } + else if (player->CanTeleport()) + player->SetCanTeleport(false); +} + void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo, uint32 opcode) { if (!sConfigMgr->GetOption("Anticheat.Enabled", 0)) @@ -205,7 +233,7 @@ void AnticheatMgr::StartHackDetection(Player* player, MovementInfo movementInfo, JumpHackDetection(player, movementInfo, opcode); TeleportPlaneHackDetection(player, movementInfo); ClimbHackDetection(player, movementInfo, opcode); - + TeleportHackDetection(player, movementInfo); m_Players[key].SetLastMovementInfo(movementInfo); m_Players[key].SetLastOpcode(opcode); } @@ -317,7 +345,7 @@ void AnticheatMgr::HandlePlayerLogout(Player* player) void AnticheatMgr::SavePlayerData(Player* player) { - CharacterDatabase.Execute("REPLACE INTO players_reports_status (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_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()].GetCreationTime()); + CharacterDatabase.Execute("REPLACE INTO players_reports_status (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_reports,teleporthack_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()].GetCreationTime()); } uint32 AnticheatMgr::GetTotalReports(ObjectGuid guid) @@ -340,6 +368,9 @@ bool AnticheatMgr::MustCheckTempReports(uint8 type) if (type == JUMP_HACK_REPORT) return false; + if (type == TELEPORT_HACK_REPORT) + return false; + return true; } @@ -392,7 +423,7 @@ void AnticheatMgr::BuildReport(Player* player, uint8 reportType) { if (!m_Players[key].GetDailyReportState()) { - CharacterDatabase.Execute("REPLACE INTO daily_players_reports (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_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()].GetCreationTime()); + CharacterDatabase.Execute("REPLACE INTO daily_players_reports (guid,average,total_reports,speed_reports,fly_reports,jump_reports,waterwalk_reports,teleportplane_reports,climb_reports,teleporthack_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()].GetCreationTime()); m_Players[key].SetDailyReportState(true); } } diff --git a/src/AnticheatMgr.h b/src/AnticheatMgr.h index 4e13c49..2f06905 100644 --- a/src/AnticheatMgr.h +++ b/src/AnticheatMgr.h @@ -35,6 +35,7 @@ enum ReportTypes JUMP_HACK_REPORT, TELEPORT_PLANE_HACK_REPORT, CLIMB_HACK_REPORT, + TELEPORT_HACK_REPORT, // MAX_REPORT_TYPES }; @@ -46,7 +47,8 @@ enum DetectionTypes WALK_WATER_HACK_DETECTION = 4, JUMP_HACK_DETECTION = 8, TELEPORT_PLANE_HACK_DETECTION = 16, - CLIMB_HACK_DETECTION = 32 + CLIMB_HACK_DETECTION = 32, + TELEPORT_HACK_DETECTION = 64 }; // GUID is the key. @@ -86,7 +88,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 TeleportHackDetection(Player* player, MovementInfo movementInfo); void BuildReport(Player* player,uint8 reportType); bool MustCheckTempReports(uint8 type); diff --git a/src/cs_anticheat.cpp b/src/cs_anticheat.cpp index ab5f313..95b1612 100644 --- a/src/cs_anticheat.cpp +++ b/src/cs_anticheat.cpp @@ -209,12 +209,13 @@ public: uint32 waterwalk_reports = sAnticheatMgr->GetTypeReports(guid, 2); uint32 teleportplane_reports = sAnticheatMgr->GetTypeReports(guid, 4); uint32 climb_reports = sAnticheatMgr->GetTypeReports(guid, 5); + uint32 teleporthack_reports = sAnticheatMgr->GetTypeReports(guid, 6); handler->PSendSysMessage("Information about player %s",player->GetName().c_str()); 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); - handler->PSendSysMessage("Climb Reports: %u", climb_reports); + handler->PSendSysMessage("Climb Reports: %u || Teleport Hack Reports: %u", climb_reports, teleporthack_reports); return true; }