SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 27/02/2012, 02:26 PM   #1
Roperr
Huge Clucker
 
Roperr's Avatar
 
Join Date: Jan 2010
Location: Slovenia
Posts: 420
Reputation: 26
Post Anti bot attack + IP limits

Functions
This is a simple include which will prevent your server from getting attacked by those pesky join/part bots.
You can also limit how many connections can be made with your server from the same exact IP. This is because some bots do not flood connections, but instead join every few seconds, evading the Anti Flood.
pawn Code:
#define IP_LIMIT 3 // = Max connections from one single IP
#define Time_Limit 3500 // = The time span between connects, adjust it to your own specifications
Change the IP_LIMIT if you are affraid of banning brothers, altho unlikely somebody will join with 3 computers.

I believe this will be of much help to other server owners, as it is of help for myself.
I used to use Kick(playerid) and just kick the flooders, but that wouldn't stop them from reconnecting 20 more times, so I've changed it to instantly ban if it identifies these attacks.

This is pretty much secure and won't cause any threat to your regulars being banned. Tested & fully working.

EDIT:
After looking up some more information about these attacks I'd like to provide another simple piece of code that would help you against the attackers that use the samp NPC's.

Add this to the code of OnPlayerConnect.
pawn Code:
public OnPlayerConnect(playerid)
{
    if(IsPlayerNPC(playerid)) {
        new server_IP[16];
        format(server_IP, 16, "127.0.0.1");

        if(strcmp(ConnIP,server_IP,true) != 0) {
            Ban(playerid); // Ban is the safest thing here, as if you kick, they can still flood you with endless connections
            return 0;
        }
    }
    return 1;
}

What this does is check if the NPC connecting has the IP 127.0.0.1, this is the local IP of your server and NPC always connect from that. So if the IP isn't 127.0.0.1, it means the NPC connecting is an attacker's bot.

Have fun, seeya.

Downloads:
2shared link
Pastebin link
__________________
Community plans halted due to life.
Planned return: September 2013.

Last edited by Roperr; 03/06/2012 at 08:18 PM.
Roperr is offline   Reply With Quote
Old 27/02/2012, 04:31 PM   #2
Kurama
Big Clucker
 
Kurama's Avatar
 
Join Date: Feb 2012
Posts: 149
Reputation: 6
Default Respuesta: Anti flood + IP limits

Nice work.
__________________
My Nick In-game/Mi nick en el juego: Sharingan...
We HATE the audio stream message!
Together we are strong.
Together we can change Kalcor's mind.
Copy & paste if you agree!
Kurama is offline   Reply With Quote
Old 27/02/2012, 04:34 PM   #3
HeLiOn_PrImE
High-roller
 
HeLiOn_PrImE's Avatar
 
Join Date: Jul 2010
Location: Cluj Napoca, Romania
Posts: 3,034
Reputation: 462
Default Re: Anti flood + IP limits

The attack I am experiencing doesn't trigger the OnPlayerConnect function. It blocks my server somehow, and the players who are trying to connect afterwards, all have the same IP : 255.255.255.255 (this is a gateway in fact) and they all have the same -1 ping. Can your include stop that?
__________________

"It's only a game, but people are real. You have to respect them." - Mick88
"You don't deserve a +rep, if you ask for it. Those who deserve it, don't have to ask." - me
"And yet people will still start new threads for the "dying" subject." - me

HeLiOn_PrImE is offline   Reply With Quote
Old 27/02/2012, 05:15 PM   #4
Roperr
Huge Clucker
 
Roperr's Avatar
 
Join Date: Jan 2010
Location: Slovenia
Posts: 420
Reputation: 26
Default Re: Anti flood + IP limits

Quote:
Originally Posted by HeLiOn_PrImE View Post
The attack I am experiencing doesn't trigger the OnPlayerConnect function. It blocks my server somehow, and the players who are trying to connect afterwards, all have the same IP : 255.255.255.255 (this is a gateway in fact) and they all have the same -1 ping. Can your include stop that?
I've seen a solution to that somewhere. I believe they are using NPC's to perform that attack.

I'll look it up and get back to you if I get any information about this matter.
__________________
Community plans halted due to life.
Planned return: September 2013.
Roperr is offline   Reply With Quote
Old 27/02/2012, 05:51 PM   #5
Roperr
Huge Clucker
 
Roperr's Avatar
 
Join Date: Jan 2010
Location: Slovenia
Posts: 420
Reputation: 26
Default Re: Anti flood + IP limits

HeLiOn_PrImE, please show me your OnPlayerConnect.

I might have a way to fix it.
__________________
Community plans halted due to life.
Planned return: September 2013.
Roperr is offline   Reply With Quote
Old 27/02/2012, 05:58 PM   #6
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,251
Reputation: 137
Default Re: Anti flood + IP limits

Err, RyDeR's one is MUCH more efficient and effective.
About the NPC's. Use the maxnpc limit in server.cfg, should fix your problem.
wups is offline   Reply With Quote
Old 27/02/2012, 06:03 PM   #7
Roperr
Huge Clucker
 
Roperr's Avatar
 
Join Date: Jan 2010
Location: Slovenia
Posts: 420
Reputation: 26
Default Re: Anti flood + IP limits

Quote:
Originally Posted by wups View Post
Err, RyDeR's one is MUCH more efficient and effective.
About the NPC's. Use the maxnpc limit in server.cfg, should fix your problem.
I've seen RyDeR's just after I posted this one, and I believe it's quite the same. This was tested with actual attacks on some of our servers and it has proved itself to be trustworthy and reliable, so I don't see how RyDeR's one would be MUCH more efficient and effective. But hey, I released my own version in which I trust and so did he, both indeed do work, now it's up to the crowd who they choose to trust.

Once again this is fully working and it's been tested about 3-4 times in an actual server attack, and I can say that the attackers were pretty much owned.

About the maxnpc limit, that wouldn't solve his problem since I believe he has a endless loop in his OnPlayerConnect, that's why I'm asking for the code.
__________________
Community plans halted due to life.
Planned return: September 2013.
Roperr is offline   Reply With Quote
Old 27/02/2012, 06:08 PM   #8
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,251
Reputation: 137
Default Re: Anti flood + IP limits

Quote:
Originally Posted by Roperr View Post
I've seen RyDeR's just after I posted this one, and I believe it's quite the same. This was tested with actual attacks on some of our servers and it has proved itself to be trustworthy and reliable, so I don't see how RyDeR's one would be MUCH more efficient and effective. But hey, I released my own version in which I trust and so did he, both indeed do work, now it's up to the crowd who they choose to trust.

Once again this is fully working and it's been tested about 3-4 times in an actual server attack, and I can say that the attackers were pretty much owned.

About the maxnpc limit, that wouldn't solve his problem since I believe he has a endless loop in his OnPlayerConnect, that's why I'm asking for the code.
Basicly, your server has low player count. RyDeR's one creates a,lets say, database. We store the latest 50 IP's, while yours stores the last one. See the difference?
RyDeR's code would detect this one, and your's wouldn't.
Quote:
BOT ATTACK has joined.
Random Player has joined.
BOT ATTACK has joined.
BOT ATTACK has joined.
Random Player has joined.
BOT ATTACK has joined.
etc.
I hope you got the point.
wups is offline   Reply With Quote
Old 27/02/2012, 06:16 PM   #9
Roperr
Huge Clucker
 
Roperr's Avatar
 
Join Date: Jan 2010
Location: Slovenia
Posts: 420
Reputation: 26
Default Re: Anti flood + IP limits

Quote:
Originally Posted by wups View Post
Basicly, your server has low player count. RyDeR's one creates a,lets say, database. We store the latest 50 IP's, while yours stores the last one. See the difference?
RyDeR's code would detect this one, and your's wouldn't.

I hope you got the point.
I do understand your point now, I've checked and he indeed stores the 50 IPs.
But since these guys tend to attack with like over 20 bots, this would catch them for sure, because if 3 regular guys join the server at the time that the attack starts, half of the bot connections will be ignored by the code but the other half won't be. Even with over 100 players, this should be of help, since they do not tend to stop until they get banned.

Tho, this is the first version to help in case if people are looking for this, since this has been a regular thing at SAMP servers at this time.

I'll see to improve my work even for those big servers, even tho I believe this would work.
__________________
Community plans halted due to life.
Planned return: September 2013.
Roperr is offline   Reply With Quote
Old 27/02/2012, 06:28 PM   #10
HeLiOn_PrImE
High-roller
 
HeLiOn_PrImE's Avatar
 
Join Date: Jul 2010
Location: Cluj Napoca, Romania
Posts: 3,034
Reputation: 462
Default Re: Anti flood + IP limits

My onplayerconnect function looks like this....maybe with other textdraws and connect messages.
But it's not triggered because that thing doesn't fully connect like a normal player.
Check this topic, I posted my problem there and a guy posted a video with the exact thing that is happening to me (he posted 2 videos. The second video shows what is also happening to me)
I also posted there a pic with the rcon window of the server that shows the anomaly .
I see now that you posted there as well..
Code:
public OnPlayerConnect(playerid)




{
	GameTextForPlayer(playerid,"censored",5000,5);
	Pspawned[playerid] = 0;
	firstspawn[playerid]=1;
	GPSTimer[playerid] = 0;
	ClickedPlayerID[playerid] = -1;
    HaveGPS[playerid] = false;
	SendPlayerFormattedText(playerid, "Welcome to cenzoredt, for more please type /help and /tour", 0);
	SendClientMessage(playerid,0xB360FDFF,"Use /house to find information on our houses");
	SendClientMessage(playerid, COLOR_LIGHTBLUE,"Type /cmds for all commands (really)!");
	SendClientMessage(playerid, COLOR_ULTRARED,"Use /ro if you are român or /eng if you are English.");
	SendClientMessage(playerid, COLOR_YELLOW,"Type /teles to see teleportation on the server ");
	SendClientMessage(playerid, COLOR_ORANGERED,"If you need a vehicle type /V and if you want to tune cars write /tune");
	TextDrawShowForPlayer(playerid, Textdraw0);
	TextDrawShowForPlayer(playerid, Textdraw1);
	TextDrawShowForPlayer(playerid, Textdraw2);
	TextDrawShowForPlayer(playerid, Textdraw3);
	TogglePlayerControllable(playerid, false);
    TextDrawShowForPlayer(playerid, TheBoxy);
  	TextDrawShowForPlayer(playerid, Hin);
	TextDrawShowForPlayer(playerid, Weilcome);
	TextDrawShowForPlayer(playerid, thelp);
	TextDrawShowForPlayer(playerid, ttele);
	TextDrawShowForPlayer(playerid, trules);
	TextDrawShowForPlayer(playerid, byFarsek);
	TextDrawShowForPlayer(playerid, Commings);
	TextDrawShowForPlayer(playerid, Enjoyit);
	TextDrawShowForPlayer(playerid, tcmds);
	SetPlayerHealth(playerid,100);
	ResetPlayerWeapons(playerid);
	gActivePlayers[playerid]++;
	gLastGaveCash[playerid] = GetTickCount();
	GetPlayerName(playerid, pname, sizeof(pname));
    format(oyunism, sizeof(oyunism), "/Saver/%s.ini",pname);
    if(!dini_Exists(oyunism))
    {
    dini_Create(oyunism);
    dini_IntSet(oyunism, "Score", 0);
    dini_IntSet(oyunism, "Money", 0);
    SetPlayerScore(playerid, dini_Int(oyunism, "Score"));
    SetPlayerMoney(playerid, dini_Int(oyunism, "Money"));
    }
    else
    {
    SetPlayerScore(playerid, dini_Int(oyunism, "Score"));
    SetPlayerMoney(playerid, dini_Int(oyunism, "Money"));
    }
	return 1;
}
__________________

"It's only a game, but people are real. You have to respect them." - Mick88
"You don't deserve a +rep, if you ask for it. Those who deserve it, don't have to ask." - me
"And yet people will still start new threads for the "dying" subject." - me


Last edited by HeLiOn_PrImE; 27/02/2012 at 06:49 PM. Reason: more details
HeLiOn_PrImE is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Anti-Flood / Anti-Repeat + High Ping Kicker KoczkaHUN Filterscripts 21 25/01/2014 09:44 PM
[FilterScript] [FS]Zadmin2.0|Admin System + Anticheat + Anti-flood + Anti high ping [ZFM]Zuc Filterscripts 32 18/06/2012 05:29 PM
[PEDIDO] Sistema Anti-Flood/Anti-Spam ViCtOr_Mc Português/Portuguese 15 28/08/2011 01:27 PM
[Pedido] Anti-Flood+Anti CAPS LOOCK [Red]Maninho Português/Portuguese 12 10/07/2011 12:52 AM


All times are GMT. The time now is 10:28 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.