Anti Multi User

Status
Not open for further replies.

T!G3R

Member
Joined
Jan 1, 2015
Messages
10
Reaction score
0
hi guys

my enemys attack to my server with Multi mod (RakSAMP)

they are send many bot to my server with insult name and if i banned him (auto banned ip) he restart modem to change their ip and login again

i need anti multi then work like this:

if 2 member whit 1 ip login to server , this ip was banned

thanks  :somuchwin:
 

.silent

Well-known member
Joined
Apr 14, 2013
Messages
339
Reaction score
13
To check for duplicate IP addreses:
Code:
public OnPlayerConnect(playerid)
{
    new currentIP[16], tempIP[16];
    GetPlayerIp(playerid, currentIP, 16);
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
         if(!IsPlayerConnected(i) || i == playerid) continue;
         GetPlayerIp(i, tempIP, 16);
         if(!strcmp(currentIP, tempIP))
         {
              // Duplicate IP here, however I wouldn't sugggest banning that IP as I think that it is pretty normal to see players with same IPs (unless there are more than 2 or 3 of them xd)
             // You could add break; here, or let it go to check for any more players with the same IP (i'd go with break)
         }
    }
}

Also, I would suggest using something like this to stop spoofed RPC_ClientJoin attacks (milions of players joining but it is just one physical player sending join info xd)
Code:
// Global array for all players
new bool:pProperConnect[MAX_PLAYERS]; // redefine MAX_PLAYERS to match the amount of slots you have

public OnPlayerConnect(playerid)
{
    // right at the top!
    if(pProperConnect[playerid])
    {
        Ban(playerid); // Someone sends join info twice on the same slot without leaving, not possible at all!
        return 0;
    }
    pProperConnect[playerid] = true;
    // rest of OPC code
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    pProperConnect[playerid] = false; // 'free' this slot
    return 1;
}
 

Kyance

Member
Joined
May 26, 2013
Messages
10
Reaction score
0
you can combine them both.


Code:
enum pInfo
{
    Connected,
    PlayerIP[ 16 ], PlayerName[ 24 ]
};

new
    IPUsers,
    PlayerInfo[ MAX_PLAYERS ][ pInfo ]
;

public OnPlayerConnect(playerid)
{
    GetPlayerName(playerid, PlayerInfo[ playerid ][ PlayerName ], MAX_PLAYER_NAME);
    GetPlayerIp(playerid, PlayerInfo[ playerid ][ PlayerIP ], 16);
    if(PlayerInfo[ playerid ][ Connected ] == 1) return Kick(playerid);
    else
    {
        PlayerInfo[ playerid ][ Connected ] = 1;

        IPUsers = GetNumberOfPlayersOnThisIP(PlayerInfo[ playerid ][ PlayerIP ]);
        if(IPUsers >= 3)
        {
            foreach(Player, i)
            {
                if(strcmp(PlayerInfo[ playerid ][ PlayerIP ], PlayerInfo[ i ][ PlayerIP ])) continue;
                Kick(i);
            }
        }
        else
        {
            //rest of the code here.
        }
    }
    return 1;
}

//Reset 'Connected' @ OnPlayerDisconnect

stock GetNumberOfPlayersOnThisIP(ip[])
{
	new ip_count;
	foreach(Player,i)
	{
		if(strcmp(PlayerInfo[ i ][ PlayerIP ],ip)) continue;
		ip_count++;
	}
	return ip_count;
}

Dunno if i missed anything -- taken from gamemode :L
 

0B36

Expert
Joined
Jan 6, 2014
Messages
1,324
Reaction score
8
Jesus ! Just use a filterscript which limits connection limit to 1 IP per user. All Raksamp bots do is make multiple connections via a single IP.

MaxIP Filterscript will kick any player/bot who connects via a single IP for the second time or as per your choice for the "n"th time. Here N = number of connections allowed per IP by you.

Code:
#include <a_samp>

#define MAX_CONNECTIONS_FROM_IP 1 // Change this if you wanna allow more connections per IP.


public OnFilterScriptInit()
{
	printf("\n*** Player IP limiting FS (maxips) Loaded. Max connections from 1 IP = %d\n",MAX_CONNECTIONS_FROM_IP);
}



stock GetNumberOfPlayersOnThisIP(test_ip[])
{
	new against_ip[32+1];
	new x = 0;
	new ip_count = 0;
	for(x=0; x<MAX_PLAYERS; x++) {
		if(IsPlayerConnected(x)) {
		    GetPlayerIp(x,against_ip,32);
		    if(!strcmp(against_ip,test_ip)) ip_count++;
		}
	}
	return ip_count;
}


public OnPlayerConnect(playerid)
{
	new connecting_ip[32+1];
	GetPlayerIp(playerid,connecting_ip,32);
	new num_players_on_ip = GetNumberOfPlayersOnThisIP(connecting_ip);

	if(num_players_on_ip > MAX_CONNECTIONS_FROM_IP) {
		printf("MAXIPs: Connecting player(%d) exceeded %d IP connections from %s.", playerid, MAX_CONNECTIONS_FROM_IP, connecting_ip);
	    Kick(playerid); // Ban or Kick whatever you wanna do here
	    return 1;
	}

	return 0;
}
 
Status
Not open for further replies.
Top