Thread: DDoS Protection - Oh noes!

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 DDoS Protection - Oh noes! 
    Fasga
    Guest
    Not really (@ title). To be honest, nobody here has the resources to come up with a particularly dangerous DDoS force, and DoS attacks simply don't do anything. That is, for anything written with the slightest bit of intelligence. Apparently, modern RS2 private servers do not fit into that category. Therefore, you only need very simply (and minimal) protection. The code:


    RecentConnectionManager.java
    Code:
    import java.net.InetAddress;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import java.util.LinkedList;
    import java.util.List;
    
    public class RecentConnectionManager {
    	public static final int SECONDS_UNTIL_RECONNECT = 5;
    	
    	private static List<RecentConnection> connections = new LinkedList<RecentConnection>();
    	
    	public static boolean isValidConnection(InetAddress source) {
    		RecentConnection connection = getOrCreateConnection(source);
    		boolean ret = getSecondsFromLastConnection(connection) >= SECONDS_UNTIL_RECONNECT;
    		connection.setTime(new GregorianCalendar());
    		return ret;
    	}
    	
    	private static RecentConnection getOrCreateConnection(InetAddress source) {
    		for(RecentConnection connection : connections) {
    			if(connection.getSource().equals(source)) {
    				return connection;
    			}
    		}
    		RecentConnection connection = new RecentConnection(source);
    		connections.add(connection);
    		return connection;
    	}
    	
    	private static int getSecondsFromLastConnection(RecentConnection connection) {
    		return Calendar.getInstance().get(Calendar.SECOND) - connection.getTime().get(Calendar.SECOND);
    	}
    }
    RecentConnection.java
    Code:
    import java.net.InetAddress;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    
    public class RecentConnection {
    	private InetAddress source = null;
    	private Calendar time = null;
    	
    	protected RecentConnection(InetAddress _source) {
    		this(_source, null);
    	}
    	
    	protected RecentConnection(InetAddress _source, Calendar _time) {
    		if(_time == null) {
    			time = new GregorianCalendar();
    			time.set(Calendar.SECOND, time.get(Calendar.SECOND) - RecentConnectionManager.SECONDS_UNTIL_RECONNECT);
    		}
    		source = _source;
    	}
    
    	protected InetAddress getSource() {
    		return source;
    	}
    	
    	protected void setTime(Calendar _time) {
    		time = _time;
    	}
    	
    	protected Calendar getTime() {
    		return time;
    	}
    }
    Unfortunately, it became slightly more complex than I was hoping to keep it, but it works fine and is still quite simple. You should be able to easily interpret what it does by glancing at the code, so I won't need to explain the details. All that you need to do to integrate it with your server is:

    1. Grab the InetAddress instance from a connecting client (Socket.getInetAddress())
    2. Call RecentConnectionManager.isValidConnection(inetAddr ess), which will return true or false depending on the validity of the connection
    3. Block all connections that return false, and continue if true
     

  2. #2  
    Tnt Pk
    Guest
    good i guess =)
     

  3. #3  
    Registered Member
    BraydenF's Avatar
    Join Date
    Feb 2008
    Posts
    651
    Thanks given
    0
    Thanks received
    0
    Rep Power
    90
    riiiiiiiiiiiiiiiiiight........

    No...no, I totally follow you.


    (In 10 years maybe i'll understand this)
     

  4. #4  
    my rep is h4x0r3d


    Join Date
    Dec 2006
    Posts
    1,760
    Thanks given
    10
    Thanks received
    8
    Rep Power
    207
    Hah nice. Better than any other protection that just blocks names
    Quote Originally Posted by super_ View Post
    this is shit. you are shit. gtfo retard.
     

  5. #5  
    brb ridin da storm

    blakeman8192's Avatar
    Join Date
    Dec 2012
    Age
    28
    Posts
    2,010
    Thanks given
    802
    Thanks received
    1,357
    Rep Power
    286
    Not bad, but it could be much more simple.
    rest in peace Qemist, Izzy, TeChNo PuNk, Impulser, & bootnecklad
     

  6. #6  
    Fasga
    Guest
    Quote Originally Posted by Stormrider View Post
    Not bad, but it could be much more simple.
    Sure, but the simple way isn't always the best way.
     

  7. #7  
    Registered Member samy's Avatar
    Join Date
    Sep 2006
    Age
    29
    Posts
    133
    Thanks given
    0
    Thanks received
    1
    Rep Power
    30
    Great job. Thanks!
     

  8. #8  
    Banned

    Join Date
    Jul 2007
    Age
    28
    Posts
    1,438
    Thanks given
    43
    Thanks received
    21
    Rep Power
    0
    Well i came tro with my ddos program =)
     

  9. #9  
    SERGEANT OF THE MASTER SERGEANTS MOST IMPORTANT PERSON OF EXTREME SERGEANTS TO THE MAX!

    cube's Avatar
    Join Date
    Jun 2007
    Posts
    8,881
    Thanks given
    1,854
    Thanks received
    4,741
    Rep Power
    5000
    Nice job, Fasga



     

  10. #10  
    Banned
    Join Date
    Nov 2006
    Posts
    1,132
    Thanks given
    5
    Thanks received
    17
    Rep Power
    0
    Lol at Ikin; 99.999% of the attacking programs on here could do nothing other then crash a server or maybe slightly lag an smf forum.
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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