feat: Security improvements for spoofed packets (#1201)

* Add cheat detection for spoofed packets

* Add config option for ip loggin

* remove packet saving
This commit is contained in:
David Markowitz
2023-09-28 10:16:11 -07:00
committed by GitHub
parent bd65fc6e33
commit b24775f472
9 changed files with 237 additions and 25 deletions

View File

@@ -33,6 +33,7 @@
#include "Database.h"
#include "eGameMasterLevel.h"
#include "eReplicaComponentType.h"
#include "CheatDetection.h"
void ClientPackets::HandleChatMessage(const SystemAddress& sysAddr, Packet* packet) {
User* user = UserManager::Instance()->GetUser(sysAddr);
@@ -65,8 +66,18 @@ void ClientPackets::HandleChatMessage(const SystemAddress& sysAddr, Packet* pack
std::string playerName = user->GetLastUsedChar()->GetName();
bool isMythran = user->GetLastUsedChar()->GetGMLevel() > eGameMasterLevel::CIVILIAN;
if (!user->GetLastChatMessageApproved() && !isMythran) return;
bool isOk = Game::chatFilter->IsSentenceOkay(GeneralUtils::UTF16ToWTF8(message), user->GetLastUsedChar()->GetGMLevel()).empty();
Game::logger->LogDebug("ClientPackets", "Msg: %s was approved previously? %i", GeneralUtils::UTF16ToWTF8(message).c_str(), user->GetLastChatMessageApproved());
if (!isOk) {
// Add a limit to the string converted by general utils because it is a user received string and may be a bad actor.
CheatDetection::ReportCheat(
user,
sysAddr,
"Player %s attempted to bypass chat filter with message: %s",
playerName.c_str(),
GeneralUtils::UTF16ToWTF8(message, 512).c_str());
}
if (!isOk && !isMythran) return;
std::string sMessage = GeneralUtils::UTF16ToWTF8(message);
Game::logger->Log("Chat", "%s: %s", playerName.c_str(), sMessage.c_str());