Register for your free account! | Forgot your password?

You last visited: Today at 10:54

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[RELEASE] BruteForce Protection

Discussion on [RELEASE] BruteForce Protection within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
[RELEASE] BruteForce Protection

Hello.

I came up with the idea to create a class that will help you protect your server from brute force hackers. Chances aren't very big this will happen to you, but still, a good server should be prepared.
Well this release includes the base for it.

Explanation:
When a wrong password is entered, a new Entry is created, and added to a dictionary, every time a wrong password is entered, this entry will be updated and the TimesTried integer will increase by 1. When this integer reaches a maximum, which is integer MaxTrials in the Bruteforce class, the IP will be banned for 15 minutes.

Usage:
In the Main void (Load function) add Bruteforce.Start();
In your packet processor, check if the IP is banned, and also when a wrong password is used, so when the wrong password packet it sent, make sure it adds a trial for the IP connected.

Credits:
- InfamousNoone, I studied his sources before I made this, and I have a strong memory, so it did influence me for sure.


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace AuthServer.Protection
{
    /// <summary>
    /// Bruteforce Entry which holds all necessary information.
    /// </summary>
    public class BruteforceEntry
    {
        public string IPAddress;
        public int TimesTried;
        public DateTime Unbantime;
        public DateTime AddedTimeRemove;
    }

    public static class Bruteforce
    {
        public static int MaxTrials;
        public static IDictionary<string, BruteforceEntry> Entries = new Dictionary<string, BruteforceEntry>();

        private static readonly ThreadStart ThreadStart = ThreadExecute;

        private static void ThreadExecute()
        {
            while (true)
            {
                lock (Entries)
                {
                    DateTime now = DateTime.Now;
                    foreach(BruteforceEntry be in Entries.Values.ToList())
                    {
                        if (be.AddedTimeRemove <= now)
                            Entries.Remove(be.IPAddress);
                        else if (be.Unbantime <= now && be.Unbantime.Day == DateTime.Now.Day)
                            Entries.Remove(be.IPAddress);
                    }
                }
                Thread.Sleep(1500);
            }
        }

        /// <param name="value">Amount of false logins somebody can have before getting banned.</param>
        public static void Start(byte value = (byte) 11)
        {
            MaxTrials = value;
            new Thread(ThreadStart).Start();
        }

        public static void AddTry(string IPAddress)
        {
            lock (Entries)
            {
                BruteforceEntry be;
                if (!Entries.TryGetValue(IPAddress, out be))
                {
                    be = new BruteforceEntry
                             {
                                 IPAddress = IPAddress,
                                 AddedTimeRemove = DateTime.Now.AddMinutes(5),
                                 Unbantime = new DateTime()
                             };
                    Entries.Add(IPAddress, be);
                }
                else
                {
                    be.TimesTried++;
                    if (be.TimesTried >= MaxTrials)
                        be.Unbantime = DateTime.Now.AddMinutes(15);
                }
            }
        }

        public static bool IsBanned(string IPAddress)
        {
            bool isBanned = false;
            BruteforceEntry be;
            if (Entries.TryGetValue(IPAddress, out be))
                isBanned = (be.Unbantime.Day == DateTime.Now.Day);
            return isBanned;
        }
    }
}
- Do NOT PM me for help, if you cannot get it to work, post it here, I'm not a officer of leechure. (I made that word up, perhaps leechinity sounds better =P)
- Do press thanks if you like this to show your appreciation, it might just be the reason I will release more.
- Do ask questions in this thread if there are problems.
- You are allowed to modify this.

~Bas.
Basser is offline  
Thanks
10 Users
Old 08/17/2010, 15:44   #2
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,224
Received Thanks: 868
I just made Kayne west a happy boy!
_DreadNought_ is offline  
Old 08/17/2010, 17:16   #3
 
elite*gold: 0
Join Date: Oct 2008
Posts: 342
Received Thanks: 66
Me too (its yuki)
µ~Xero~µ is offline  
Old 08/17/2010, 17:51   #4
 
CØĐ£Ř||Mã©hÍñє's Avatar
 
elite*gold: 0
Join Date: May 2010
Posts: 248
Received Thanks: 36
great thanks brother
CØĐ£Ř||Mã©hÍñє is offline  
Old 08/17/2010, 17:51   #5
 
.Beatz's Avatar
 
elite*gold: 0
Join Date: May 2006
Posts: 1,190
Received Thanks: 516
Good release Basser +k
.Beatz is offline  
Old 08/17/2010, 20:15   #6
 
~*NewDuuDe*~'s Avatar
 
elite*gold: 111
Join Date: Feb 2008
Posts: 2,161
Received Thanks: 646
Great release, mate. Seems someone forgot their e*pvp password? :P
Note to the guy above me: There isn't karma anymore.
~*NewDuuDe*~ is offline  
Old 08/17/2010, 21:46   #7
 
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
#EDIT:
I made a copy when iterating through it, cause else you might get an exception because you are modifying and iterating through a dictionary.
Basser is offline  
Old 08/17/2010, 22:13   #8
 
Sp!!ke's Avatar
 
elite*gold: 0
Join Date: Nov 2009
Posts: 380
Received Thanks: 58
great Basser +k
Sp!!ke is offline  
Old 08/17/2010, 22:36   #9
 
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
Quote:
Originally Posted by I<3Salad View Post
Error: Default parameter spcifiers are not permitted
What .NET Framework are you using?
Either configure .NET Framework 4.0 to the project, or if you don't want to.

Just do this:
Code:
        public static void Start()
        {
            MaxTrials = 11;
            new Thread(ThreadStart).Start();
        }
Not the best way, but I don't want to post a huge edit.
Basser is offline  
Old 08/17/2010, 23:27   #10
 
.Beatz's Avatar
 
elite*gold: 0
Join Date: May 2006
Posts: 1,190
Received Thanks: 516
I know there is no Karma anymore lmao just showing my appreciation Might implement this into my source
.Beatz is offline  
Old 08/18/2010, 20:52   #11
 
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
Did anyone successfully use this code yet?
Basser is offline  
Old 08/18/2010, 21:42   #12
 
.Beatz's Avatar
 
elite*gold: 0
Join Date: May 2006
Posts: 1,190
Received Thanks: 516
Not yet. I am working out bugs and making sure things run fine before I add anything else
.Beatz is offline  
Old 08/19/2010, 21:51   #13
 
elite*gold: 0
Join Date: Sep 2008
Posts: 1,683
Received Thanks: 505
Should I add anything?
Basser is offline  
Reply


Similar Threads Similar Threads
[Release][Method]Aeria - Bypass Attack speed hack protection
07/23/2023 - 12Sky2 Hacks, Bots, Cheats & Exploits - 69 Replies
Heya all as you are now awear alt1 has patched the attack speed hack. This is how I have worked arround it. Please Alt1 Patch it SERVER SIDE for once. First I found the attack speed buff as one usally does. Had help from jax on that :D. 010d0ecb Then we noticed it had a limiter when we tried to freeze it to anything above 20 or 21 it just did not work. Here is how to bypass it.
[Release] processor.php protection for potential security risk
08/24/2010 - Shaiya PServer Guides & Releases - 6 Replies
if you are useing the processor.php script, you need to know that is potentially attackable with code ijections. Here is a little solution that may help ya to fix SQL code injection, put this code at the beginning of your processor.php function sql_quote( $value ) { if( get_magic_quotes_gpc() ) { $value = stripslashes( $value ); }
BRUTEFORCE
02/25/2007 - Main - 1 Replies
Huhu leute also bei euch gibts ja sicher ein paar die Brute-force beherrschen Also ich habe Brutus AET2 Und weiss wies funzt also ich brings zum laufen :D Nur hab ich folgende Probleme wenn ich z.b einen Account hacken will von z.b www.gmx.de geht das ja net dann muss ich irgendwie über ftp oder irgendwie so z.b ftp.gmx.de oder kA Nun wie finde ich die ftp oder die HTTP adresse raus ???



All times are GMT +2. The time now is 10:54.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.