Anti-Brute Force...
#1

I am working on a system so my server doesn't get brute forced.. again..

Here's the code I came up with, but it doesn't seem to be working.

pawn Код:
new str[350];
    new one0 = random(30);
    new one1 = random(30);
    new one2 = random(30);
    new one3 = random(30);
    new one4 = random(30);
    new one5 = random(30);
    new one6 = random(30);
    new one7 = random(30);
    new one8 = random(30);
    new one9 = random(30);
   
    format(str, sizeof(str), "%d-%d-%d-%d-%d-%d-%d-%d-%d-%d",one0,one1,one2,one3,one4,one5,one6,one7,one8,one9);
    SendRconCommand(str);
    print(str);
Note: Print is there to be sure it's working.
Reply
#2

ur not defining what rcon command you want to execute, you just send a bunch of random ints to the console.
Reply
#3

That entire int should be rcon. Or do I have to set it as a string?
Reply
#4

are you trying to change the password? if so use this
pawn Код:
new str[350];
    new one0 = random(30);
    new one1 = random(30);
    new one2 = random(30);
    new one3 = random(30);
    new one4 = random(30);
    new one5 = random(30);
    new one6 = random(30);
    new one7 = random(30);
    new one8 = random(30);
    new one9 = random(30);
   
    format(str, sizeof(str), "rcon_password %d-%d-%d-%d-%d-%d-%d-%d-%d-%d",one0,one1,one2,one3,one4,one5,one6,one7,one8,one9);
    SendRconCommand(str);
    print(str);
Reply
#5

That's what I was missing.. thanks
Reply
#6

Quote:
Originally Posted by Daren_Jacobson
Посмотреть сообщение
are you trying to change the password? if so use this
pawn Код:
new str[350];
    new one0 = random(30);
    new one1 = random(30);
    new one2 = random(30);
    new one3 = random(30);
    new one4 = random(30);
    new one5 = random(30);
    new one6 = random(30);
    new one7 = random(30);
    new one8 = random(30);
    new one9 = random(30);
   
    format(str, sizeof(str), "rcon_password %d-%d-%d-%d-%d-%d-%d-%d-%d-%d",one0,one1,one2,one3,one4,one5,one6,one7,one8,one9);
    SendRconCommand(str);
    print(str);
do you want to prevent command flooding? or Rcon login?
I guess you want to implement excessive RCon Login attempt, I extracted some of my filterscript to help you


pawn Код:
public OnRconLoginAttempt( ip[], password[], success )
{
    #define R_IP_HASH 0
    #define R_FAILED_ATTEMPT 1
    #define R_PLAYER_ID 2
    static iptables[128][3], ip_index;
    new current_ip, playerid = INVALID_PLAYER_ID, str[128];
    current_ip = bernstein (ip);

    //search stored IP table
    for( new i = 0; i < ip_index && i < sizeof(iptables) ; i++ )
    {
        //IP exists in the table
        if( iptables[i][R_IP_HASH] == current_ip )
        {
            //if a player succeeded then just reset the attempt.
            if( success )
            {
                iptables[i][R_FAILED_ATTEMPT] = 0;
                return 1;
            }
            //Player failed to login. keep accumulating the number of failed attempt
            iptables[i][R_FAILED_ATTEMPT]++;
            playerid = iptables[i][R_PLAYER_ID];
            //if a false attempt exceeded the server tolerance
            if( iptables[i][R_FAILED_ATTEMPT] >= MAX_RCONLOGIN_ATTEMPT )
            {
                //follow the settings file configuration policy
                switch( POLICY_RCON_LOGINFAIL_INTERNAL )
                {
                    case 1://Kick
                    {
                        format( str, sizeof(str), "* %s(%d) is kicked due to excessive rcon login attempt.", GetPlayerNameEx(playerid), playerid );
                        SendAdminMessageAuth(AUTH_NOTICES,COLOR_RED,str);
                        printf("[rcon] %s(%d) is kicked due to excessive rcon login attempt.", GetPlayerNameEx(playerid), playerid );
                        Kick(playerid);
                        return 1;
                    }
                    case 2://Ban
                    {
                        format( str, sizeof(str), "* %s(%d) is Kick Banned due to excessive rcon login attempt.", GetPlayerNameEx(playerid), playerid );
                        SendAdminMessageAuth(AUTH_NOTICES,COLOR_RED,str);
                        printf("[rcon] %s(%d) is Kick Banned due to excessive rcon login attempt.", GetPlayerNameEx(playerid), playerid );
                        Ban(playerid);
                        return 1;
                    }
                }
            }
            //attempt didn't exceeded. notify it to administartors
            format( str, sizeof(str), "* %s(%d) failed to login to an administrator (%d times)",  GetPlayerNameEx(playerid), playerid, iptables[i][R_FAILED_ATTEMPT] );
            SendAdminMessageAuth(AUTH_NOTICES,COLOR_RED,str);
            printf("[rcon] %s(%d) failed to login to an administrator (%d times)", GetPlayerNameEx(playerid), playerid, iptables[i][R_FAILED_ATTEMPT] );
            return 1;
        }
    }
    //he/she's not on the list. and he/she succeeded to login. just passing.
    if( success ) return 1;
    //this is the first time to fail login.
    for( new i = 0; i < NUM_PLAYERS ; i++ ) // using foreach-relavent iteration, find a playerid with an IP.
    {
        if( !strcmp(GetPlayerIpEx(pITT[i]), ip, false) ) // precached GetPlayerIp() alternatives
        {
            playerid = pITT[i]; //get the playerid
            break;
        }
    }
    //store it in the blacklist
    iptables[ip_index][R_IP_HASH] = current_ip;
    iptables[ip_index][R_PLAYER_ID] = playerid;
    iptables[ip_index][R_FAILED_ATTEMPT]++;
    ip_index++;
    //send a administrative mesessage
    format( str, sizeof(str), "* %s(%d) failed to login to an administrator (first time)", GetPlayerNameEx(playerid), playerid );
    //a small function, that only send a message to admins that have 'AUTH_NOTICES' privilege
    SendAdminMessageAuth(AUTH_NOTICES,COLOR_RED,str);
    printf("[rcon] player %s(%d) failed to login to an administrator (first time)", GetPlayerNameEx(playerid), playerid );
    #undef R_IP_HASH
    #undef R_FAILED_ATTEMPT
    #undef R_PLAYER_ID
    return 1;
}
All you need to do is link the policy variable with your configuration profile
have a nice day
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)