Rcon protection
#1

Can someone help me make a rcon protection system,so I want to make when a player enters the wrong rcon password,he gets auto ip baned.Execption for admins
Reply
#2

Accomplishable with minimal modifcations of the example on the SA-MP wiki:
Код:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true) && !PlayerInfo[i][pAdmin]) //If a player's IP is the IP that failed the login AND they aren't an admin
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Of course you'll need to replace '!PlayerInfo[i][pAdmin])' with the variable that matches your script/admin system.

I'd HIGHLY advise you use foreach instead if you use that, and if you don't use it, what are you waiting for?
Reply
#3

PHP код:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!
success)
    {
        new 
string[128];
        
format(string,sizeof(string),"banip %s",ip);
                
SendRconCommand(string);
         }
          return 
1;

Reply
#4

Код:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) 
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) 
        {
if(PlayerInfo[i][pAdmin] >= 1) return 1;
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) 
            {   new str[128], name[MAX_PLAYER_NAME];
				GetPlayerName(i, name, sizeof(name));
				format(str, sizeof(str), "{37DB45}%s {FF0000}was auto-banned by {0000FF}GOD{FF0000}. Reason: {DB881A}Attepmt to hack Rcon{FF0000}.", name);
				SendClientMessageToAll(0xFFFFFFFF,str);
                SendClientMessage(i, 0xFFFFFFFF, "You're banned.");
                Ban(i); 
            }
        }
    }
    return 1;
}
This shall work, You can refer to this https://sampforum.blast.hk/showthread.php?tid=309482
Reply
#5

Quote:
Originally Posted by yeehao98
Посмотреть сообщение
Код:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) 
    {
        printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) 
        {
if(PlayerInfo[i][pAdmin] >= 1) return 1;
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) 
            {   new str[128], name[MAX_PLAYER_NAME];
				GetPlayerName(i, name, sizeof(name));
				format(str, sizeof(str), "{37DB45}%s {FF0000}was auto-banned by {0000FF}GOD{FF0000}. Reason: {DB881A}Attepmt to hack Rcon{FF0000}.", name);
				SendClientMessageToAll(0xFFFFFFFF,str);
                SendClientMessage(i, 0xFFFFFFFF, "You're banned.");
                Ban(i); 
            }
        }
    }
    return 1;
}
This shall work, You can refer to this https://sampforum.blast.hk/showthread.php?tid=309482
I get this error

C:\Users\Korisnik\Desktop\Yugoslavia Trucking v.0.3.7\gamemodes\YT.pwn(2854) : error 017: undefined symbol "pAdmin"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#6

Perhaps you'll need to replace that part with whatever variable you're holding your admin level integer in.
Reply
#7

I have this code but it just kicks them,no ipban.Any suggestions?
Код:
public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {

        printf("NEUSPIJELI POKUSAJ LOGIRANJA U RCON IP %s KORISTECI SIFRU %s",ip, password);
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {   new str[128], name[MAX_PLAYER_NAME];
				GetPlayerName(i, name, sizeof(name));
				format(str, sizeof(str), "{37DB45}%s {FF0000}je automatski banan {0000FF}GOD{FF0000}. Razlog: {DB881A}Pokusava provaliti u RCON{FF0000}.", name);
				SendClientMessageToAll(0xFFFFFFFF,str);
                SendClientMessage(i, 0xFFFFFFFF, "{FF0000}Kriva Lozinka. {0xFFFFFFFF}Automatski {FF0000}banan."); //Send a message
                SendClientMessage(i, 0xFFFFFFFF, "{DB881A}Za unban uslikajte ovo sa F8,i postavite na nasu fb grupu."); //Send a message
                Ban(i); //They are now banned.
            }
        }
    }
    return 1;
}
Reply
#8

It MUST ban them. Bans will appear in samp.ban file. Maybe you think they are not banned because there is no message sent to them?
Reply
#9

I tested it on my server i ban myself it says server closed the connection then i enter the server again,no ban...
Reply
#10

Quote:
Originally Posted by NexySamp
Посмотреть сообщение
I tested it on my server i ban myself it says server closed the connection then i enter the server again,no ban...
Do you have samp.ban file in your server directory?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)