added hackish challenge-response-alike compatible with 0.5.2 clients. against the slot blocking exploit.

This commit is contained in:
fisted 2010-10-25 10:55:56 +02:00 committed by GreYFoXGTi
parent 6505e21a0d
commit 9f8cf21c33
4 changed files with 32 additions and 1 deletions

View file

@ -1,5 +1,8 @@
// copyright (c) 2007 magnus auvinen, see licence.txt for more info
#include <cstdlib>
#include <ctime>
#include <base/system.h>
#include <engine/shared/config.h>
@ -687,6 +690,12 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
}
m_aClients[ClientId].m_State = CClient::STATE_CONNECTING;
int num = m_NetServer.getSlot(ClientId).m_Fagpings = (rand() % (g_Config.m_SvMaxFagpings - g_Config.m_SvMinFagpings + 1)) + g_Config.m_SvMinFagpings;
while(num--) {
CMsgPacker Ping(NETMSG_PING);
SendMsgEx(&Ping, 0, ClientId, true);
}
SendMap(ClientId);
}
}
@ -892,6 +901,11 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
CMsgPacker Msg(NETMSG_PING_REPLY);
SendMsgEx(&Msg, 0, ClientId, true);
}
else if(Msg == NETMSG_PING_REPLY)
{
if (m_aClients[ClientId].m_State == CClient::STATE_CONNECTING)
m_NetServer.getSlot(ClientId).m_Fagpings--;
}
else
{
char aHex[] = "0123456789ABCDEF";
@ -1593,7 +1607,7 @@ int main(int argc, const char **argv) // ignore_convention
}
}
#endif
srand(time(NULL)); //we need this only for slot blocker exploit protection
// init the engine
dbg_msg("server", "starting...");
CServer *pServer = CreateServer();

View file

@ -63,6 +63,8 @@ MACRO_CONFIG_INT(GfxFinish, gfx_finish, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, ""
MACRO_CONFIG_INT(InpMousesens, inp_mousesens, 100, 5, 100000, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Mouse sensitivity", -1)
MACRO_CONFIG_INT(SvMaxFagpings, sv_max_fagpings, 8, 0, 255, CFGFLAG_SERVER, "Maximum amount of fagpings which will be sent")
MACRO_CONFIG_INT(SvMinFagpings, sv_min_fagpings, 2, 0, 255, CFGFLAG_SERVER, "Maximum amount of fagpings which will be sent")
MACRO_CONFIG_STR(SvName, sv_name, 128, "DDRace Test Trunk 0.5 Server", CFGFLAG_SERVER, "Server name", 3)
MACRO_CONFIG_STR(SvBindaddr, sv_bindaddr, 128, "", CFGFLAG_SERVER, "Address to bind the server to", 3)
MACRO_CONFIG_INT(SvPort, sv_port, 8303, 0, 0, CFGFLAG_SERVER, "Port to use for the server", 3)

View file

@ -224,6 +224,7 @@ private:
{
public:
CNetConnection m_Connection;
int m_Fagpings;
};
class CBan
@ -287,6 +288,8 @@ public:
//
void SetMaxClientsPerIP(int Max);
CSlot& getSlot(int ClientID) { return m_aSlots[ClientID]; }
};

View file

@ -369,6 +369,18 @@ int CNetServer::Recv(CNetChunk *pChunk)
m_pfnNewClient(i, m_UserPtr);
break;
}
else
{
if (m_aSlots[i].m_Fagpings) {
dbg_msg("netsrv","dropping a fag (id %i, state %i)\n",i,m_aSlots[i].m_Connection.State());
Drop(i,"GTFO");
m_aSlots[i].m_Connection.Feed(&m_RecvUnpacker.m_Data, &Addr);
if(m_pfnNewClient)
m_pfnNewClient(i, m_UserPtr);
Found=1;
break;
}
}
}
if(!Found)