diff --git a/conf/Anticheat.conf.dist b/conf/Anticheat.conf.dist index f609bac..28dacee 100644 --- a/conf/Anticheat.conf.dist +++ b/conf/Anticheat.conf.dist @@ -161,7 +161,65 @@ Anticheat.AnnounceKick = 0 Anticheat.AnnounceBan = 0 Anticheat.AnnounceJail = 0 +# +################################################################################################### + +################################################################################################### +# ANTICHEAT COUNTER MEASURE +# # Anticheat Counter Measures +# +# Anticheat.CM.TIMEMANIPULATION +# +# Description: Counters Time Manipulation hacks. These hacks can cause server to crash. +# +# Default: 1 - (Enabled) +# 0 - (Disabled) +# + +Anticheat.CM.TIMEMANIPULATION = 1 + +# +# Anticheat.CM.Teleport +# +# Description: Sends player back to last gps position if player cheats and teleports. +# +# Default: 0 - (Disabled) +# 1 - (Enabled) +# + +Anticheat.CM.Teleport = 0 + +# +# Anticheat.CM.WriteLog +# +# Description: Enables Logging +# Default: 0 - (Disabled) +# 1 - (Enabled) +# + +Anticheat.CM.WriteLog = 0 + +# +# Anticheat.CM.ALERTSCREEN +# +# Description: Alerts online GMs of Counter Measure being deployed via screen alert +# Default: 0 - (Disabled) +# 1 - (Enabled) +# + +Anticheat.CM.ALERTSCREEN = 0 + +# +# Anticheat.CM.ALERTCHAT +# +# Description: Alerts online GMs of Counter Measure being deployed via chat alert +# Default: 0 - (Disabled) +# 1 - (Enabled) +# + +Anticheat.CM.ALERTCHAT= 0 + # # Anticheat.BG.StartAreaTeleport # @@ -172,3 +230,6 @@ Anticheat.AnnounceJail = 0 # Anticheat.BG.StartAreaTeleport = 0 + +# +################################################################################################### diff --git a/sql/updates/world/AC_2023_03_09_00.sql b/sql/updates/world/AC_2023_03_09_00.sql new file mode 100644 index 0000000..1e374c2 --- /dev/null +++ b/sql/updates/world/AC_2023_03_09_00.sql @@ -0,0 +1,3 @@ +DELETE FROM `acore_string` WHERE `entry`=30092; +INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES +(30092, '|cffffff00[|cffff0000COUNTER MEASURE ALERT|r|cffffff00]:|r |cFFFF8C00|r %s |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00]', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index fb23383..8ec9a0c 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -34,6 +34,7 @@ constexpr auto LANG_ANTICHEAT_TELEPORT = 30088; constexpr auto LANG_ANTICHEAT_IGNORECONTROL = 30089; constexpr auto LANG_ANTICHEAT_DUEL = 30090; constexpr auto LANG_ANTICHEAT_BG_EXPLOIT = 30091; +constexpr auto LANG_ANTICHEAT_COUNTERMEASURE = 30092; // Time between server sends acknowledgement, and client is actually acknowledged constexpr auto ALLOWED_ACK_LAG = 2000; @@ -210,30 +211,55 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) // how long the player took to move to here. uint32 timeDiff = getMSTimeDiff(m_Players[key].GetLastMovementInfo().time, movementInfo.time); - if (int32(timeDiff) < 0) + if (int32(timeDiff) < 0 && sConfigMgr->GetOption("Anticheat.CM.TIMEMANIPULATION", true)) { - if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) + if (sConfigMgr->GetOption("Anticheat.CM.WriteLog", true)) { uint32 latency = 0; 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:: Time Manipulation - Hack detected player {} ({}) - Latency: {} ms - IP: {} - Cheat Flagged At: {}", player->GetName(), player->GetGUID().ToString(), latency, player->GetSession()->GetRemoteAddress().c_str(), goXYZ); } - BuildReport(player, SPEED_HACK_REPORT); - if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) + if (sConfigMgr->GetOption("Anticheat.CM.WriteLog", true)) { LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Time Diff Corrected (Map: {}) (possible Out of Order Time Manipulation)", player->GetName(), player->GetMapId()); } + if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) + { // display warning at the center of the screen, hacky way? + std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + std::string(player->GetName().c_str()) + "|cFF00FFFF] TIME MANIPULATION COUNTER MEASURE ALERT"; + WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); + data << str; + sWorld->SendGlobalGMMessage(&data); + } + 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()); + } timeDiff = 1; + BuildReport(player, SPEED_HACK_REPORT); } - if (!timeDiff) + if (!timeDiff && sConfigMgr->GetOption("Anticheat.CM.TIMEMANIPULATION", true)) { if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: {} Time Diff Corrected (Map: {}) (possible Zero Time Manipulation)", player->GetName(), player->GetMapId()); } + if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) + { // display warning at the center of the screen, hacky way? + std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + std::string(player->GetName().c_str()) + "|cFF00FFFF] TIME MANIPULATION COUNTER MEASURE ALERT"; + WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); + data << str; + sWorld->SendGlobalGMMessage(&data); + } + 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()); + } timeDiff = 1; + BuildReport(player, SPEED_HACK_REPORT); } // this is the distance doable by the player in 1 sec, using the time done to move to this point. @@ -250,7 +276,7 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) // We check the last MovementInfo for the falling flag since falling down a hill and sliding a bit triggered a false positive if ((diffspeed >= _assignedspeeddiff) && !m_Players[key].GetLastMovementInfo().HasMovementFlag(MOVEMENTFLAG_FALLING)) { - if ((clientSpeedRate > speedRate * 1.05f) && !m_Players[key].GetLastMovementInfo().HasMovementFlag(MOVEMENTFLAG_FALLING)) + if (clientSpeedRate > speedRate * 1.05f) { if (!player->CanTeleport()) { @@ -571,7 +597,27 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn 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:: Teleport-Hack detected player {} ({}) - Latency: {} ms - IP: {} - GPS Diff X: {} Y: {} Z: {} - Cheat Flagged At: {}", player->GetName(), player->GetGUID().ToString(), latency, player->GetSession()->GetRemoteAddress().c_str(), xDiff, yDiff, zDiff, goXYZ); } - + if (sConfigMgr->GetOption("Anticheat.CM.Teleport", true)) + { + if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) + { + std::string LastgoXYZ = ".go xyz " + std::to_string(lastX) + " " + std::to_string(lastY) + " " + std::to_string(lastZ + 1.0f) + " " + std::to_string(player->GetMap()->GetId()) + " " + std::to_string(player->GetOrientation()); + 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" + std::string(player->GetName().c_str()) + "|cFF00FFFF] TELEPORT COUNTER MEASURE ALERT"; + WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); + data << str; + sWorld->SendGlobalGMMessage(&data); + } + 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()); + } + player->TeleportTo(player->GetMapId(), lastX, lastY, lastZ, player->GetOrientation()); + } BuildReport(player, TELEPORT_HACK_REPORT); } else if (player->CanTeleport()) @@ -971,15 +1017,29 @@ void AnticheatMgr::CheckStartPositions(Player* player) Position pos = player->GetPosition(); Position const* startPos = GetTeamStartPosition(player->GetBgTeamId()); - if (pos.GetExactDistSq(!startPos)) + if (sConfigMgr->GetOption("Anticheat.BG.StartAreaTeleport", true)) { - if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) + if (pos.GetExactDistSq(!startPos)) { - LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: Sending {} back to start location (BG Map: {}) (possible exploit)", player->GetName(), player->GetMapId()); + if (sConfigMgr->GetOption("Anticheat.CM.WriteLog", true)) + { + LOG_INFO("anticheat.module", "ANTICHEAT COUNTER MEASURE:: Sending {} back to start location (BG Map: {}) (possible exploit)", player->GetName(), player->GetMapId()); + } + if (sConfigMgr->GetOption("Anticheat.CM.ALERTSCREEN", true)) + { // display warning at the center of the screen, hacky way? + std::string str = "|cFFFFFC00[Playername:|cFF00FFFF[|cFF60FF00" + std::string(player->GetName().c_str()) + "|cFF00FFFF] BG START SPOT COUNTER MEASURE ALERT"; + WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); + data << str; + sWorld->SendGlobalGMMessage(&data); + } + 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()); + } + player->TeleportTo(player->GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation()); } - player->TeleportTo(player->GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation()); } - } void AnticheatMgr::BGStartExploit(Player* player, MovementInfo movementInfo)