domingo, 10 de março de 2013

0 Anti-DDos Bot

Anti DDOS Bots


Agora sim !! Está funcionando e foi testado.

Quote:
[17:38:04] Incoming connection: 127.0.0.1:58125
[17:38:04] Incoming connection: 127.0.0.1:58126
[17:38:04] Incoming connection: 127.0.0.1:58127
[17:38:04] Incoming connection: 127.0.0.1:58128
[17:38:04] Incoming connection: 127.0.0.1:58129
[17:38:04] Incoming connection: 127.0.0.1:58130
[17:38:05] Incoming connection: 127.0.0.1:58131
[17:38:05] Incoming connection: 127.0.0.1:58132
[17:38:05] Incoming connection: 127.0.0.1:58133
[17:38:05] Incoming connection: 127.0.0.1:58134
[17:38:07] [join] bRUNO_(QlP4 has joined the server (100:127.0.0.1)
[17:38:07] [join] bRUNO_NQw)Y has joined the server (101:127.0.0.1)
[17:38:07] 101 Entrou em menos de 2 segundos
[17:38:07] [join] bRUNO_yq8OD has joined the server (102:127.0.0.1)
[17:38:07] 102 Entrou em menos de 2 segundos
[17:38:07] BOT: ID -> 102 IP -> 127.0.0.
[17:38:08] [part] bRUNO_yq8OD has left the server (102:2)
Quote:
Originally Posted by Victor' View Post
Agora funcionou

PHP Code:
[17:42:35] [join] DtvugjacniUnwk has joined the server (2:127.0.0.1)
[17:42:35] [join] TN2oDpmjCzIKfu has joined the server (2:127.0.0.1)
[17:42:35] 2 Entrou em menos de 2 segundos
[17:42:35] [join] CmkIKzeN71xKUx has joined the server (2:127.0.0.1)
[17:42:35] 2 Entrou em menos de 2 segundos
[17:42:35] BOT: ID -> 2 IP -> 127.0.0. 




Código:
PHP Code:

#include a_samp

#if !defined varGet
#define varGet(%0)      getproperty(0,%0)
#endif

// http://forum.sa-mp.com/showthread.php?p=1925909


#if !defined varSet
#define varSet(%0,%1) setproperty(0, %0, %1)
#endif

stock botGetIP[24];

#define IsPlayerBot(%0)\
            GetPlayerPing(%0) == 65535 && (gettime() - varGet((GetPlayerIp(%0, botGetIP, sizeof botGetIP), botGetIP)) > 5)


public OnPlayerConnect(playerid) {

    if(IsPlayerNPC(playerid)) return false;

    static
        playerip[24]
    ;

    GetPlayerIp(playerid, playerip, 24);

    if(gettime() - varGet(playerip) < 2) {

        
        strcat(playerip, "di_S");

        if(gettime() - varGet(playerip) < 3) {
            return false;
        }
        
        printf("%d Entrou em menos de 2 segundos", playerid);

        GetPlayerIp(playerid, playerip, 20);

        varSet(playerip, gettime());

        strcat(playerip, "x");

        static timers ;
        timers = varGet(playerip);

        varSet(playerip, 1+ timers);

        if(timers > 2) {

            playerip[strlen(playerip) - 2] = 0;

            printf("BOT: ID -> %d IP -> %s", playerid, playerip);
            BanEx(playerid, "Bot Connect");
        }
    }
    return varSet(playerip, gettime());
}


public OnPlayerDisconnect(playerid, reason) {
    if(reason == 2) {

        static
            playerip[20]
        ;


        GetPlayerIp(playerid, playerip, 20);
        strcat(playerip, "di_S");

        varSet(playerip, gettime());
    }
    return false;


Ele detecta após o cara fazer 2 a 5 conexões. É via IP, ela registra usando varSet e varGet (uma biblioteca minha) e após uma nova conexão checa o tempo desses dois caras.

----

Também é aconselhável que você coloca o seguinte no topo de cada callback que use playerid:
pawn Code:
if(IsPlayerBOT(playerid)) return false;

Assim evita outros possíveis bots

0 comentários: