Skip to content

Commit

Permalink
Validate serial on player join (multitheftauto#3804)
Browse files Browse the repository at this point in the history
This will help prevent cheaters that use a particular type of spoofer, from connecting. Server owners are recommended to upgrade MTA server to a version with this change included.
  • Loading branch information
Fernando-A-Rocha authored Oct 16, 2024
1 parent 733683d commit 84437e4
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include "version.h"
#include "net/SimHeaders.h"
#include <signal.h>
#include <regex>

#define MAX_BULLETSYNC_DISTANCE 400.0f
#define MAX_EXPLOSION_SYNC_DISTANCE 400.0f
Expand Down Expand Up @@ -1783,7 +1784,21 @@ void CGame::Packet_PlayerJoinData(CPlayerJoinDataPacket& Packet)

SString strIP = pPlayer->GetSourceIP();
SString strIPAndSerial("IP: %s Serial: %s Version: %s", strIP.c_str(), strSerial.c_str(), strPlayerVersion.c_str());
if (!CheckNickProvided(szNick)) // check the nick is valid

// Prevent player from connecting if serial is invalid
const std::regex serialRegex("^[A-F0-9]{32}$");
if (!std::regex_match(strSerial, serialRegex))
{
// Tell the console
CLogger::LogPrintf("CONNECT: %s failed to connect (Invalid serial) (%s)\n", szNick, strIPAndSerial.c_str());

// Tell the player the problem
DisconnectPlayer(this, *pPlayer, CPlayerDisconnectedPacket::SERIAL_VERIFICATION);
return;
}

// Check the nick is valid
if (!CheckNickProvided(szNick))
{
// Tell the console
CLogger::LogPrintf("CONNECT: %s failed to connect (Invalid nickname) (%s)\n", szNick, strIPAndSerial.c_str());
Expand Down

0 comments on commit 84437e4

Please sign in to comment.