[Network]: Check who sent print OOB (#969)

This commit is contained in:
Edo 2023-04-24 23:42:36 +02:00 committed by GitHub
parent b33d5912a9
commit f8acea54d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 3 deletions

View File

@ -22,7 +22,7 @@ namespace Components
void Logger::Print_Stub(const int channel, const char* message, ...) void Logger::Print_Stub(const int channel, const char* message, ...)
{ {
char buf[4096] = {0}; char buf[4096]{};
va_list va; va_list va;
va_start(va, message); va_start(va, message);

View File

@ -360,9 +360,13 @@ namespace Components
Utils::Hook::Set<std::uint8_t>(0x5AA5B6, 0xEB); // CL_SteamServerAuth Utils::Hook::Set<std::uint8_t>(0x5AA5B6, 0xEB); // CL_SteamServerAuth
Utils::Hook::Set<std::uint8_t>(0x5AA69F, 0xEB); // echo Utils::Hook::Set<std::uint8_t>(0x5AA69F, 0xEB); // echo
Utils::Hook::Set<std::uint8_t>(0x5AAA82, 0xEB); // SP Utils::Hook::Set<std::uint8_t>(0x5AAA82, 0xEB); // SP
Utils::Hook::Set<std::uint8_t>(0x5A9F77, 0xEB); // CL_WeNowCantHearSomeone
Utils::Hook::Set<std::uint8_t>(0x5A9F18, 0xEB); // CL_VoiceConnectionTestPacket Utils::Hook::Set<std::uint8_t>(0x5A9F18, 0xEB); // CL_VoiceConnectionTestPacket
Utils::Hook::Set<std::uint8_t>(0x5A9FF3, 0xEB); // CL_HandleRelayPacket Utils::Hook::Set<std::uint8_t>(0x5A9FF3, 0xEB); // CL_HandleRelayPacket
// For security reasons check the sender of the 'print' OOB
Utils::Hook::Set<std::uint8_t>(0x5AA729, 0xEB);
// Com_GetProtocol // Com_GetProtocol
Utils::Hook::Set<std::uint32_t>(0x4FB501, PROTOCOL); Utils::Hook::Set<std::uint32_t>(0x4FB501, PROTOCOL);
@ -381,9 +385,24 @@ namespace Components
Utils::Hook::Set<std::uint8_t>(0x682170, 0xC3); // Telling LSP that we're playing a private match Utils::Hook::Set<std::uint8_t>(0x682170, 0xC3); // Telling LSP that we're playing a private match
Utils::Hook::Nop(0x4FD448, 5); // Don't create lsp_socket Utils::Hook::Nop(0x4FD448, 5); // Don't create lsp_socket
OnClientPacket("resolveAddress", [](const Address& address, [[maybe_unused]] const std::string& data) OnClientPacket("resolveAddress", []([[maybe_unused]] const Address& address, [[maybe_unused]] const std::string& data)
{ {
SendRaw(address, address.getString()); SendRaw(address, address.getString());
}); });
OnClientPacket("print", []([[maybe_unused]] const Address& address, [[maybe_unused]] const std::string& data)
{
auto* clc = Game::CL_GetLocalClientConnection(0);
if (!Game::NET_CompareBaseAdr(clc->serverAddress, *address.get()))
{
return;
}
char buffer[2048]{};
Game::I_strncpyz(clc->serverMessage, data.data(), sizeof(clc->serverMessage));
Game::Com_sprintf(buffer, sizeof(buffer), "%s", data.data());
Game::Com_PrintMessage(Game::CON_CHANNEL_CLIENT, data.data(), 0);
});
} }
} }

View File

@ -12,6 +12,7 @@ namespace Game
Com_PrintError_t Com_PrintError = Com_PrintError_t(0x4F8C70); Com_PrintError_t Com_PrintError = Com_PrintError_t(0x4F8C70);
Com_PrintWarning_t Com_PrintWarning = Com_PrintWarning_t(0x4E0200); Com_PrintWarning_t Com_PrintWarning = Com_PrintWarning_t(0x4E0200);
Com_PrintMessage_t Com_PrintMessage = Com_PrintMessage_t(0x4AA830); Com_PrintMessage_t Com_PrintMessage = Com_PrintMessage_t(0x4AA830);
Com_sprintf_t Com_sprintf = Com_sprintf_t(0x413DE0);
Com_EndParseSession_t Com_EndParseSession = Com_EndParseSession_t(0x4B80B0); Com_EndParseSession_t Com_EndParseSession = Com_EndParseSession_t(0x4B80B0);
Com_BeginParseSession_t Com_BeginParseSession = Com_BeginParseSession_t(0x4AAB80); Com_BeginParseSession_t Com_BeginParseSession = Com_BeginParseSession_t(0x4AAB80);
Com_ParseOnLine_t Com_ParseOnLine = Com_ParseOnLine_t(0x4C0350); Com_ParseOnLine_t Com_ParseOnLine = Com_ParseOnLine_t(0x4C0350);

View File

@ -29,6 +29,9 @@ namespace Game
typedef void(*Com_PrintMessage_t)(int channel, const char* msg, int error); typedef void(*Com_PrintMessage_t)(int channel, const char* msg, int error);
extern Com_PrintMessage_t Com_PrintMessage; extern Com_PrintMessage_t Com_PrintMessage;
typedef int(*Com_sprintf_t)(char* dest, int size, const char* fmt, ...);
extern Com_sprintf_t Com_sprintf;
typedef void(*Com_EndParseSession_t)(); typedef void(*Com_EndParseSession_t)();
extern Com_EndParseSession_t Com_EndParseSession; extern Com_EndParseSession_t Com_EndParseSession;

View File

@ -109,6 +109,7 @@ namespace Game
NET_AdrToString_t NET_AdrToString = NET_AdrToString_t(0x469880); NET_AdrToString_t NET_AdrToString = NET_AdrToString_t(0x469880);
NET_CompareAdr_t NET_CompareAdr = NET_CompareAdr_t(0x4D0AA0); NET_CompareAdr_t NET_CompareAdr = NET_CompareAdr_t(0x4D0AA0);
NET_CompareBaseAdr_t NET_CompareBaseAdr = NET_CompareBaseAdr_t(0x455510);
NET_DeferPacketToClient_t NET_DeferPacketToClient = NET_DeferPacketToClient_t(0x4C8AA0); NET_DeferPacketToClient_t NET_DeferPacketToClient = NET_DeferPacketToClient_t(0x4C8AA0);
NET_ErrorString_t NET_ErrorString = NET_ErrorString_t(0x4E7720); NET_ErrorString_t NET_ErrorString = NET_ErrorString_t(0x4E7720);
NET_Init_t NET_Init = NET_Init_t(0x491860); NET_Init_t NET_Init = NET_Init_t(0x491860);

View File

@ -275,6 +275,9 @@ namespace Game
typedef bool(*NET_CompareAdr_t)(netadr_t a, netadr_t b); typedef bool(*NET_CompareAdr_t)(netadr_t a, netadr_t b);
extern NET_CompareAdr_t NET_CompareAdr; extern NET_CompareAdr_t NET_CompareAdr;
typedef int(*NET_CompareBaseAdr_t)(netadr_t a, netadr_t b);
extern NET_CompareBaseAdr_t NET_CompareBaseAdr;
typedef void(*NET_DeferPacketToClient_t)(netadr_t*, msg_t*); typedef void(*NET_DeferPacketToClient_t)(netadr_t*, msg_t*);
extern NET_DeferPacketToClient_t NET_DeferPacketToClient; extern NET_DeferPacketToClient_t NET_DeferPacketToClient;