bool SecurityPatches::WriteBytes(Memory address, std::initializer_list<uint8_t> bytes) {
std::vector<uint8_t> data(bytes);
DWORD oldProtection = 0;
if (!VirtualProtect(address.ToType<void*>(), data.size(), PAGE_EXECUTE_READWRITE, &oldProtection))
return false;
memcpy(address.ToType<void*>(), data.data(), data.size());
VirtualProtect(address.ToType<void*>(), data.size(), oldProtection, &oldProtection);
return true;
}
void SecurityPatches::Apply() {
/* CPlugin::Load */
static auto pluginLoadAddressPatched = Globals::Modules::engineModule.FindSignature(_("31 C0 C2 04 00 90 90 90 90 8D 85 F8 FE FF FF 53 8B 5D 08 8B D3 56 8B F1 8B C8 57 2B D1"), false);
static auto pluginLoadAddress = Globals::Modules::engineModule.FindSignature(_("55 8B EC 81 EC 08 01 00 00 8D 85 F8 FE FF FF 53 8B 5D 08 8B D3 56 8B F1 8B C8 57 2B D1"), pluginLoadAddressPatched.ToAddress() == 0);
if (pluginLoadAddress.ToAddress()) {
/* prevent the usage of "plugin_load <filename>", as this isn't used by clients anyways */
/* this has been used to load malware during rce chains, known to be used recently / 23th November 2026? */
WriteBytes(pluginLoadAddress, {
0x31, 0xC0, /* xor eax, eax */
0xC2, 0x04, 0x00, /* ret 0x4 */
0x90, 0x90, 0x90, 0x90 /* nop x4 */
});
}
/* CBaseClientState::ProcessConnectionlessPacket */
static auto redirectSkipPatched = Globals::Modules::engineModule.FindSignature(_("E9 D8 00 00 00 00 8D 8F"), false);
static auto redirectSkip = Globals::Modules::engineModule.FindSignature(_("0F 84 ?? ?? ?? ?? 8D 8F"), redirectSkipPatched.ToAddress() == 0);
if (redirectSkip.ToAddress()) {
/* prevent servers from forcing a redirected, as they might buffer cvars for us to execute when we redirect. */
/* this has been used to cause the loading of malware during rce chains, known to be used recently / 23th November 2026? */
WriteBytes(redirectSkip, {
0xE9, 0xD8, 0x00, 0x00, 0x00, /* jmp 0xDD */
0x90 /* nop */
});
}
/* ShouldPreventServerCommand */
static auto maxClientsCheckPatched = Globals::Modules::engineModule.FindSignature(_("0F 94 C0 84 C0 75 ?? 85 D2"), false);
static auto maxClientsCheck = Globals::Modules::engineModule.FindSignature(_("0F 94 C0 84 C0 75 ?? 85 D2"), maxClientsCheckPatched.ToAddress() == 0);
if (maxClientsCheck.ToAddress()) {
/* patch the inlined "Host_IsSinglePlayerGame" check, that considers maxClients m_nMaxClients == 1 to be singleplayer. */
/* this has been used to give the server unrestricted access to any cvars on the clients, last usage date unknown */
WriteBytes(maxClientsCheck, {
0xB0, 0x00, /* mov al, 0x0 */
0x90 /* nop */
});
}
}