[FIX] Anti-Flood

#1
Agregar en Game.cpp

Code: Select all

BOOL CGame::CheckDenialServiceAttack(int iClientH, DWORD dwClientTime)
{DWORD dwTime = timeGetTime();
   if (m_pClientList[iClientH]->m_dwDSLAT == 0)
   {   m_pClientList[iClientH]->m_dwDSLAT    = dwClientTime;
      m_pClientList[iClientH]->m_dwDSLATOld = dwClientTime;
      m_pClientList[iClientH]->m_dwDSLATS   = dwTime;
      m_pClientList[iClientH]->m_iDSCount   = 0;
   }else 
   {   if (dwClientTime >= m_pClientList[iClientH]->m_dwDSLAT)
      {   m_pClientList[iClientH]->m_dwDSLAT = dwClientTime;
      }else
      {   if (m_pClientList[iClientH]->m_dwDSLATOld == dwClientTime)
         {   m_pClientList[iClientH]->m_iDSCount ++;
            if (((dwTime - m_pClientList[iClientH]->m_dwDSLATS) > 10*1000)
               && (m_pClientList[iClientH]->m_iDSCount > 5))
            {   wsprintf(G_cTxt, "DS check: PC(%s) - Denial of service attack! (Disc.) \tIP(%s)"
                  , m_pClientList[iClientH]->m_cCharName
                  , m_pClientList[iClientH]->m_cIPaddress);
                  DeleteClient(iClientH, TRUE, TRUE);  
               PutHackLogFileList(G_cTxt);
               PutLogList(G_cTxt);
               return FALSE;
            }
         }else
         {   m_pClientList[iClientH]->m_dwDSLATOld = dwClientTime;
            m_pClientList[iClientH]->m_iDSCount   = 1;
            m_pClientList[iClientH]->m_dwDSLATS   = dwTime;
   }   }   }
   return TRUE;
}
En la función: void CGame::ClientMotionHandler(int iClientH, char * pData)

abajo de:

Code: Select all

   dwp = (DWORD *)cp;
   dwClientTime = *dwp;
   cp += 4;
agregar:

Code: Select all

if (!CheckDenialServiceAttack(iClientH, dwClientTime)) return;
En la función: void CGame::CheckConnectionHandler(int iClientH, char *pData)

abajo de:

Code: Select all

	dwTime = timeGetTime();
	cp = (char *)(pData + DEF_INDEX2_MSGTYPE + 2);
	dwp = (DWORD *)cp;
	dwTimeRcv = *dwp;
agregar:

Code: Select all

if (!CheckDenialServiceAttack(iClientH, dwTimeRcv)) return;
En Game.h agregar:

Code: Select all

BOOL CheckDenialServiceAttack(int iClientH, DWORD dwClientTime);
En client.h agregar:

Code: Select all

   DWORD m_dwDSLAT, m_dwDSLATOld, m_dwDSLATS;
   int m_iDSCount;
En Client.cpp agregar:

Code: Select all

   m_dwDSLAT = m_dwDSLATOld = m_dwDSLATS = 0;
   m_iDSCount = 0;
Centuu.-

Sol Lucet Omnibus.-

Who is online

Users browsing this forum: No registered users and 0 guests