From 6737879221c8ea44b2037b10da0e0e08e80363cc Mon Sep 17 00:00:00 2001 From: MDIC Date: Fri, 29 Apr 2022 17:34:14 -0400 Subject: [PATCH] feat (module): Include Latency with Log Spam --- sql/world/Acore_strings.sql | 8 ++--- src/AnticheatMgr.cpp | 67 +++++++++++++++++++++++++++---------- src/cs_anticheat.cpp | 5 ++- 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/sql/world/Acore_strings.sql b/sql/world/Acore_strings.sql index eaa83a3..e0f4db9 100644 --- a/sql/world/Acore_strings.sql +++ b/sql/world/Acore_strings.sql @@ -1,9 +1,9 @@ DELETE FROM `acore_string` WHERE `entry` IN (30087,30088,30089,30090); INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES -(30087, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r |cFFFF8C00|r |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00]:', NULL, NULL, NULL, NULL, NULL, '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r |cFFFF8C00|r |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00]:', '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r |cFFFF8C00|r |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00]:', NULL), -(30088, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r POSSIBLE TELEPORT HACK DETECTED|cFFFF8C00 %s|r', NULL, NULL, NULL, NULL, NULL, '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r POSIBLE HACK DE TELEPORTE DETECTADO|cFFFF8C00 %s|r', '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r POSIBLE HACK DE TELEPORTE DETECTADO|cFFFF8C00 %s|r', NULL), -(30089, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r POSSIBLE IGNORE CONTROL HACK DETECTED|cFFFF8C00 %s|r', NULL, NULL, NULL, NULL, NULL, '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r POSIBLE CONTROL DE HACK DETECTADO IGNORARADO|cFFFF8C00 %s|r', '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r POSIBLE CONTROL DE HACK DETECTADO IGNORARADO|cFFFF8C00 %s|r', NULL), -(30090, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r TELEPORT HACK USED WHLE DUELING|cFFFF8C00 %s|r vs |cFFFF8C00 %s|r.', NULL, NULL, NULL, NULL, NULL, '', '', NULL); +(30087, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r |cFFFF8C00|r |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00] - Latency: %u ms', NULL, NULL, NULL, NULL, NULL, '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r |cFFFF8C00|r |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00] - Latency: %u ms', '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r |cFFFF8C00|r |cFFFF8C00[|Hplayer:%s|h%s|h|r|cFFFF8C00] - Latency: %u ms', NULL), +(30088, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r POSSIBLE TELEPORT HACK DETECTED|cFFFF8C00 %s|r - Latency: %u ms', NULL, NULL, NULL, NULL, NULL, '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r POSIBLE HACK DE TELEPORTE DETECTADO|cFFFF8C00 %s|r - Latency: %u ms', '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r POSIBLE HACK DE TELEPORTE DETECTADO|cFFFF8C00 %s|r - Latency: %u ms', NULL), +(30089, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r POSSIBLE IGNORE CONTROL HACK DETECTED|cFFFF8C00 %s|r - Latency: %u ms', NULL, NULL, NULL, NULL, NULL, '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r POSIBLE CONTROL DE HACK DETECTADO IGNORARADO|cFFFF8C00 %s|r - Latency: %u ms', '|cffffff00[|cffff0000ALERTA ANTITRAMPAS|r|cffffff00]:|r POSIBLE CONTROL DE HACK DETECTADO IGNORARADO|cFFFF8C00 %s|r - Latency: %u ms', NULL), +(30090, '|cffffff00[|cffff0000ANTICHEAT ALERT|r|cffffff00]:|r TELEPORT HACK USED WHLE DUELING|cFFFF8C00 %s|r - Latency: %u ms vs |cFFFF8C00 %s|r - Latency: %u ms.', NULL, NULL, NULL, NULL, NULL, '', '', NULL); DELETE FROM `command` WHERE `name`='anticheat jail'; DELETE FROM `command` WHERE `name`='anticheat delete'; diff --git a/src/AnticheatMgr.cpp b/src/AnticheatMgr.cpp index 44f826e..2785dff 100644 --- a/src/AnticheatMgr.cpp +++ b/src/AnticheatMgr.cpp @@ -54,8 +54,10 @@ void AnticheatMgr::JumpHackDetection(Player* player, MovementInfo /* movementInf if (m_Players[key].GetLastOpcode() == MSG_MOVE_JUMP && opcode == MSG_MOVE_JUMP) { + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); BuildReport(player, JUMP_HACK_REPORT); - LOG_INFO("module", "AnticheatMgr:: Jump-Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + LOG_INFO("module", "AnticheatMgr:: Jump-Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } } @@ -79,7 +81,9 @@ void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo moveme { if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Walk on Water - Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Walk on Water - Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, WALK_WATER_HACK_REPORT); } @@ -110,7 +114,9 @@ void AnticheatMgr::WalkOnWaterHackDetection(Player* player, MovementInfo moveme if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Walk on Water - Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Walk on Water - Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, WALK_WATER_HACK_REPORT); } @@ -141,7 +147,9 @@ void AnticheatMgr::FlyHackDetection(Player* player, MovementInfo movementInfo) if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Fly-Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Fly-Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, FLY_HACK_REPORT); @@ -171,7 +179,9 @@ void AnticheatMgr::TeleportPlaneHackDetection(Player* player, MovementInfo movem { if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Teleport To Plane - Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Teleport To Plane - Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, TELEPORT_PLANE_HACK_REPORT); @@ -206,17 +216,21 @@ void AnticheatMgr::IgnoreControlHackDetection(Player* player, MovementInfo movem WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); data << str; sWorld->SendGlobalGMMessage(&data); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); // 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)) { - sWorld->SendGMText(LANG_ANTICHEAT_IGNORECONTROL, player->GetName().c_str()); + sWorld->SendGMText(LANG_ANTICHEAT_IGNORECONTROL, player->GetName().c_str(), latency); } _counter = 0; } } if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Ignore Control - Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Ignore Control - Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, IGNORE_CONTROL_REPORT); @@ -273,14 +287,18 @@ void AnticheatMgr::ZAxisHackDetection(Player* player, MovementInfo movementInfo) // 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)) { - sWorld->SendGMText(LANG_ANTICHEAT_ALERT, player->GetName().c_str(), player->GetName().c_str()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + sWorld->SendGMText(LANG_ANTICHEAT_ALERT, player->GetName().c_str(), player->GetName().c_str(), latency); } _counter = 0; } } if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Ignore Zaxis Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Ignore Zaxis Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, ZAXIS_HACK_REPORT); @@ -317,13 +335,16 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); data << str; sWorld->SendGlobalGMMessage(&data); - - sWorld->SendGMText(LANG_ANTICHEAT_DUEL, player->GetName().c_str(), opponent->GetName().c_str()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + uint32 latency2 = 0; + latency2 = opponent->GetSession()->GetLatency(); + sWorld->SendGMText(LANG_ANTICHEAT_DUEL, player->GetName().c_str(), latency, opponent->GetName().c_str(), latency2); if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: DUEL ALERT Teleport-Hack detected player {} ({}) while dueling {}", player->GetName(), player->GetGUID().ToString(), opponent->GetName()); - LOG_INFO("module", "AnticheatMgr:: DUEL ALERT Teleport-Hack detected player {} ({}) while dueling {}", opponent->GetName(), opponent->GetGUID().ToString(), player->GetName()); + LOG_INFO("module", "AnticheatMgr:: DUEL ALERT Teleport-Hack detected player {} ({}) while dueling {} - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), opponent->GetName(), latency); + LOG_INFO("module", "AnticheatMgr:: DUEL ALERT Teleport-Hack detected player {} ({}) while dueling {} - Latency: {} ms", opponent->GetName(), opponent->GetGUID().ToString(), player->GetName(), latency2); } BuildReport(player, TELEPORT_HACK_REPORT); BuildReport(opponent, TELEPORT_HACK_REPORT); @@ -347,17 +368,21 @@ void AnticheatMgr::TeleportHackDetection(Player* player, MovementInfo movementIn WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); data << str; sWorld->SendGlobalGMMessage(&data); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); // 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)) { - sWorld->SendGMText(LANG_ANTICHEAT_TELEPORT, player->GetName().c_str()); + sWorld->SendGMText(LANG_ANTICHEAT_TELEPORT, player->GetName().c_str(), latency); } _counter = 0; } } if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Teleport-Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Teleport-Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, TELEPORT_HACK_REPORT); @@ -431,7 +456,9 @@ void AnticheatMgr::ClimbHackDetection(Player* player, MovementInfo movementInfo, { if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Climb-Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Climb-Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, CLIMB_HACK_REPORT); @@ -532,7 +559,9 @@ void AnticheatMgr::SpeedHackDetection(Player* player, MovementInfo movementInfo) { if (sConfigMgr->GetOption("Anticheat.WriteLog", true)) { - LOG_INFO("module", "AnticheatMgr:: Speed-Hack detected player {} ({})", player->GetName(), player->GetGUID().ToString()); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); + LOG_INFO("module", "AnticheatMgr:: Speed-Hack detected player {} ({}) - Latency: {} ms", player->GetName(), player->GetGUID().ToString(), latency); } BuildReport(player, SPEED_HACK_REPORT); } @@ -674,10 +703,12 @@ void AnticheatMgr::BuildReport(Player* player, uint16 reportType) WorldPacket data(SMSG_NOTIFICATION, (str.size() + 1)); data << str; sWorld->SendGlobalGMMessage(&data); + uint32 latency = 0; + latency = player->GetSession()->GetLatency(); // 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)) { - sWorld->SendGMText(LANG_ANTICHEAT_ALERT, player->GetName().c_str(), player->GetName().c_str()); + sWorld->SendGMText(LANG_ANTICHEAT_ALERT, player->GetName().c_str(), player->GetName().c_str(), latency); } _counter = 0; } diff --git a/src/cs_anticheat.cpp b/src/cs_anticheat.cpp index 2c41e52..7c7560f 100644 --- a/src/cs_anticheat.cpp +++ b/src/cs_anticheat.cpp @@ -200,7 +200,10 @@ public: uint32 teleport_reports = sAnticheatMgr->GetTypeReports(guid, 6); uint32 ignorecontrol_reports = sAnticheatMgr->GetTypeReports(guid, 7); uint32 zaxis_reports = sAnticheatMgr->GetTypeReports(guid, 8); - handler->PSendSysMessage("Information about player %s", player->GetName().c_str()); + Player* playerTarget = player->GetConnectedPlayer(); + uint32 latency = 0; + latency = playerTarget->GetSession()->GetLatency(); + handler->PSendSysMessage("Information about player %s || Latency %u ms", player->GetName().c_str(), latency); 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);