mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-08 11:44:11 +00:00
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:
@@ -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());
|
||||
|
Reference in New Issue
Block a user