Resultados 1 a 1 de 1

Tópico: Anti Syn flood

  1. #1
    Iniciante herobk's Avatar
    Data de Ingresso
    Sep 2020
    Posts
    8
    Thanks Thanks Given 
    16
    Thanks Thanks Received 
    2
    Thanked in
    1 Post
    Mencionado
    2 Post(s)
    País
    Singapore

    Cool Anti Syn flood

    IpManager.h

    // Reemplazar la struct IP_ADDRESS_INFO por la siguiente:
    struct IP_ADDRESS_INFO
    {
    char IpAddress [16];
    WORD IpAddressCount;
    WORD IpFloodAttemps;
    WORD IpBlocked;
    DWORD IpBlockedTime;
    DWORD IpTime;
    DWORD IpTime2;
    DWORD IpFloodLastTime;
    };



    IpManager.cpp

    #include "Log.h"
    #include "Util.h"
    // Reemplazar func entera:
    bool CIpManager :: CheckIpAddress (char * IpAddress) // OK
    {
    std :: map <std :: string, IP_ADDRESS_INFO>: : iterator it = this-> m_IpAddressInfo.find (std :: string (IpAddress));


    if (it == this-> m_IpAddressInfo.end ())
    {
    return ((gServerInfo.m_MaxIpConnection == 0)? 0: 1);
    }
    // keep time between each connection received
    if (it-> second.IpTime! = 0)
    {
    it-> second.IpTime2 = it-> second.IpTime;
    it-> second.IpTime = GetTickCount ();
    }
    // block if it receives 2 connections in less than 1 second, blood measurement.
    if (abs ((int) ((it-> second.IpTime-it-> second.IpTime2)) <1000))
    {
    it-> second.IpBlocked = 1;
    it-> second.IpBlockedTime = GetTickCount ();
    gLog.Output (LOG_HACK, "FLOOD ATTEMPT DETECTED - BAN IP:% s", IpAddress);
    LogAdd (LOG_RED, "FLOOD ATTEMPT DETECTED - BAN IP:% s", IpAddress);
    return 0;
    }
    // work to unban el ip
    if (it-> second.IpBlockedTime! = 0 && abs ((int) ((GetTickCount () - it-> second.IpBlockedTime)))> 600000) // 600000 del blocking time ip
    {
    gLog.Output (LOG_HACK, "IP IS UNBAN:% s", IpAddress);
    LogAdd (LOG_RED, "IP IS UNBAN:% s", IpAddress);
    it-> second.IpBlocked = 0;
    it-> second.IpBlockedTime = 0;
    }
    // function to reject the blocked ip
    if (it-> second.IpBlocked> 0)
    {
    return 0;


    if (it-> second.IpFloodAttemps> 0 && (abs ((int) ((GetTickCount () - it-> second.IpFloodLastTime))) <60000))
    {
    it-> second.IpBlocked = 1;
    it-> second.IpBlockedTime = GetTickCount ();
    gLog.Output (LOG_HACK, "FLOOD ATTEMPT DETECTED - BAN IP:% s", IpAddress);
    LogAdd (LOG_RED, "FLOOD ATTEMPT DETECTED - BAN IP:% s", IpAddress);
    return 0;
    }
    else
    {
    if (it-> second.IpAddressCount> = gServerInfo.m_MaxIpConnection)
    {
    // saves connection attempts by overcoming maxipconnection
    it-> second.IpFloodAttemps ++;
    it-> second.
    return 0;
    }
    return 1;
    }

    }



    Find:
    void CIpManager :: InsertIpAddress (char * IpAddress) // OK

    // Add info info.IpAddressCount = 1;
    info.IpFloodAttemps = 0;
    info.IpBlocked = 0;
    info.IpTime = GetTickCount ();
    info.IpBlockedTime = 0;
    info.IpFloodLastTime = 0;
    info.IpTime2 = 0;


    Replace whole function:

    void CIpManager :: RemoveIpAddress (char * IpAddress) // OK
    {
    std :: map <std :: string, IP_ADDRESS_INFO> :: iterator it = this-> m_IpAddressInfo.find (std :: string (IpAddress)) ;


    if (it! = this-> m_IpAddressInfo.end ())
    {
    // only smudges the ip if it is not blocked.
    if ((- - it-> second.IpAddressCount) == 0 && it-> second.IpBlocked == 0)
    {
    this-> m_IpAddressInfo.erase (it);
    }
    }
    }

    enjoy

  2. The Following 2 Users Say Thank You to herobk For This Useful Post:


Tags para este Tópico

Permissões de Postagem

  • Você não pode iniciar novos tópicos
  • You may not post Resposta(s)
  • Você não pode enviar anexos
  • Você não pode editar suas mensagens
  •  
Sobre nós
Somos uma comunidade em atividade a 8 anos que aborda assuntos relacionados a games em geral, principalmente games MMORPG. e que busca sempre ajudar os membros através de conteúdos, tutoriais e suporte...
Nossos anunciantes
Hinetworks
VelozHost
InovHost
Rede Sociais