From eba1762fd0768c2315a90419b24863f57fc6efeb Mon Sep 17 00:00:00 2001 From: Diavolo Date: Sun, 12 Sep 2021 15:16:41 +0200 Subject: [PATCH] Add fields to client_t structs, might be useful --- src/Components/Modules/Network.cpp | 16 +++++++++------- src/Components/Modules/Network.hpp | 2 +- src/Game/Functions.hpp | 4 ++-- src/Game/Structs.hpp | 4 +++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index ae4d00fd..dc429d27 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -342,13 +342,14 @@ namespace Components Game::NET_DeferPacketToClient(from, msg); } - void Network::SVExecuteClientMessageStub(Game::client_t* client, Game::msg_t* msg) + void Network::SV_ExecuteClientMessageStub(Game::client_t* client, Game::msg_t* msg) { - const char* message = Utils::String::VA("ServerID: %d, Sequence: %d, Acknowledge: %d, Sent: %d, Message: %d\n", client->serverID, - client->reliableSequence, client->reliableAcknowledge, - client->reliableSent, client->messageAcknowledge); - - OutputDebugStringA(message); + if (client->reliableAcknowledge < 0 || client->reliableAcknowledge > 0xFF) + { + client->reliableAcknowledge = 0; + Game::NET_OutOfBandPrint(Game::NS_SERVER, client->netchan.remoteAddress, "disconnect"); + return; + } Utils::Hook::Call(0x414D40)(client, msg); } @@ -392,7 +393,8 @@ namespace Components // Fix packets causing buffer overflow Utils::Hook(0x6267E3, Network::NET_DeferPacketToClientStub, HOOK_CALL).install()->quick(); - Utils::Hook(0x626996, Network::SVExecuteClientMessageStub, HOOK_CALL).install()->quick(); + // Fix server freezer exploit + Utils::Hook(0x626996, Network::SV_ExecuteClientMessageStub, HOOK_CALL).install()->quick(); Network::Handle("resolveAddress", [](Address address, const std::string& /*data*/) { diff --git a/src/Components/Modules/Network.hpp b/src/Components/Modules/Network.hpp index a3a30779..f3248817 100644 --- a/src/Components/Modules/Network.hpp +++ b/src/Components/Modules/Network.hpp @@ -90,7 +90,7 @@ namespace Components static void PacketErrorCheck(); static void NET_DeferPacketToClientStub(Game::netadr_t* from, Game::msg_t* msg); - static void SVExecuteClientMessageStub(Game::client_t* client, Game::msg_t* msg); + static void SV_ExecuteClientMessageStub(Game::client_t* client, Game::msg_t* msg); }; } diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 3536a4b7..d235a120 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -495,10 +495,10 @@ namespace Game typedef bool(__cdecl * NET_StringToAdr_t)(const char *s, netadr_t *a); extern NET_StringToAdr_t NET_StringToAdr; - typedef void(__cdecl* NET_OutOfBandPrint_t)(netsrc_t sock, netadr_t adr, const char *data); + typedef void(__cdecl * NET_OutOfBandPrint_t)(netsrc_t sock, netadr_t adr, const char *data); extern NET_OutOfBandPrint_t NET_OutOfBandPrint; - typedef void(__cdecl* NET_OutOfBandData_t)(netsrc_t sock, netadr_t adr, const char *format, int len); + typedef void(__cdecl * NET_OutOfBandData_t)(netsrc_t sock, netadr_t adr, const char *format, int len); extern NET_OutOfBandData_t NET_OutOfBandData; typedef void(__cdecl * Live_MPAcceptInvite_t)(_XSESSION_INFO *hostInfo, const int controllerIndex, bool fromGameInvite); diff --git a/src/Game/Structs.hpp b/src/Game/Structs.hpp index 6ae3e930..a928735e 100644 --- a/src/Game/Structs.hpp +++ b/src/Game/Structs.hpp @@ -4665,7 +4665,9 @@ namespace Game int messageAcknowledge; // 134760 char __pad4[1080]; // 134764 char name[16]; // 135844 - char __pad5[12]; // 135860 + char __pad5[4]; // 135860 + int lastPacketTime; // 135864 + int lastConnectTime; // 135868 int snapNum; // 135872 int __pad6; // 135876 short ping; // 135880