Jump to content
MakeWebGames

[mccode] BLIP Tables (Blocked IPv4 Addresses by CIDR)


Guest Anonymous

Recommended Posts

Guest Anonymous

Well this one is sure to cause a stir...

We know that individual IP addresses can be blocked easily, however as a host running several machines I occasionally need to block a range of IP addresses, and the BLIP tables performs this job for me.

With this extension, you can block individual IP(v4) addresses AND block entire ranges.

For example, you could add 127.0.0.1 which would just block 127.0.0.1 or you could add 127.0.0.0/8 which would block the entire 127.0.0.0 - 127.255.255.255 range.

Now, some caveats. You CANNOT block private IP addresses. This is for safety. These addresses are:

127/8 -- 127.0.0.0 - 127.255.255.255

10/8 -- 10.0.0.0 - 10.255.255.255

172.16/12 -- 172.16.0.0 - 172.31.255.255

196.168/16 -- 192.168.0.0 - 192.168.255.255

When blocking an IP address using the CIDR notation, be very careful. If you were to (say) block 86.0.0.0/8 then you would probably have upset a LOT of the UK based players as the 86.x.x.x is mostly part of British Telecoms DHCP address range.

Images available from http://nyna.co.uk/gallery/

Installation is a little more complex than my usual stuff, but it should be fairly simple...

Step 1 - The data tables:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Step 2 - The blip function library (blip.php)

Place this in your htdocs folder...

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Step #3 - Modify your header.php

This is a little tricky - You will have to choose exactly where you want this to go, I won't offer any advice, but you must ensure that these few lines get called AFTER the global $db variable has been initialized...

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

You should obviously change the message to suit, perhaps with a link to an email address in case someone believes they

have been blocked by mistake.

Step #4 - Modify your staff menu (smenu.php)

You need to add a line to allow staff access to the blip staff console:

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Again, it is up to you where to place this, but I generally restrict this to full administrators only.

Step #5 - The BLIP staff console (staff_blip.php)

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

And there it is...

Any queries with this should be directed here (the forums) not PM as I'm sure other people will benefit from any points raised.

Enjoy

Link to comment
Share on other sites

Guest Anonymous

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

A few guidelines on how to use this...

Blocking a single IP address is simple - Just type it in.

eg. 127.0.0.1 (This is actually stored as 127.0.0.1/32)

Blocking a range is a little more complex, you have to use the CIDR notation:

127.0.0.0/32 Blocks just 127.0.0.0 (1 host)

127.0.0.0/30 Blocks 127.0.0.0 - 127.0.0.3 (4 hosts)

127.0.0.0/28 Blocks 127.0.0.0 - 127.0.0.15 (16 hosts)

and so on...

BTW, if you "mouse over" the CIDR in the tables, you will see the effective range of blocked IP's in a tooltip.

Link to comment
Share on other sites

Guest Anonymous

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

 

ok, i will have a look in a bit, also where do i add idstead of htdocs?

Huh - I hope you realize the complexity of this script ... It's not really designed for people without a fair bit of knowledge as it can have some adverse effects.

Link to comment
Share on other sites

Guest Anonymous

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

For those of you who are obviously not following the plot ... your htdocs folder is where all your source files for the game live.. Possibly public_html? I don't know *your* configuration and not being in possession of a set of crystal balls...

Link to comment
Share on other sites

  • 3 weeks later...
Guest Anonymous

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

Hosts is the actual number if IP's within a given CIDR range.

So 10/8 or 10.0.0.0/8 would have a hosts value of 16,777,216, so blocking 10/8 would prevent all those hosts (from 10.0.0.0 to 10.255.255.255) from accessing your site.

I use it purely as a guideline to see how many hosts (or computers) are blocked for each entry.

Link to comment
Share on other sites

  • 4 weeks later...
Guest Anonymous

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

Guess that will be a simple case of not understanding how this works... or what CIDRs are.

This facility is not designed for even semi-pro programmers - it is used in a lot more advanced sites as a method of protection prior to insertion into kernel level firewall rules.

Link to comment
Share on other sites

Guest Anonymous

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

 

...

include_once("blip.php");

if (blip_is_blocked())

die("<tt>Your IP address has been blocked</tt>");

$IP = ($_SERVER['HTTP_X_FORWARDED_FOR'])

? $_SERVER['HTTP_X_FORWARDED_FOR']

: $_SERVER['REMOTE_ADDR'];

...

So um...how would I use it then? xD

See, this demonstrates my point.

You've obviously not even taken the time read through my code MTG, and have even less of an understanding of the language than I suspected. Shame really. I thought at one point you might have showed promise, but you have managed to disappoint me again.

if you don't understand or understand the ludicrousness of MTG's code snippet above *and* see the obvious mistake and solution, I suggest you go away for a few years and learn the language.

Link to comment
Share on other sites

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

 

this is basically ur version of cpanels ip deny manager right?

Not really, Nyna's app makes use of a database to check whether the IP should be granted access or not.

cPanels IP Deny Manger uses apache access files, many people block IP ranges via apache's access files.

It is also a bit easier to use than this, if you ask me.

To block an IP range of 50.12.0.0 - 50.12.255.255:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Blocking IP range of 50.12.36.0 - 50.12.36.255:

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

Link to comment
Share on other sites

Guest Anonymous

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

 

this is basically ur version of cpanels ip deny manager right?

Never having used any control panel in anger until a few days ago - no idea.

Spud is right to an extend, that dropping simple DENY statements into a dot htaccess file is easier, however this was designed for a specific purpose (totally outside of gaming), and is here more to present some conceptual ideas.

Link to comment
Share on other sites

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

so say someone god forbid hacked a admins account went into staff panel and banned the owners/staff ips then removing them ips would be abit difficult right? that would give the "hacker" control for quite awhile if people never understood this modification right?

not being picky but seems like cpanel is there because its outa game and take a alternate password making it more safer correct?

im not dissing but your the one who say security is the best thing but this seems more unsafe than anything to me anyways im not the expert

and if this offends you im sorry id just like to see if im right here or not

Link to comment
Share on other sites

Guest Anonymous

Re: Free 2 - BLIP Tables (Blocked IPv4 Addresses by CIDR)

Lol - you can't offend me like that... I'm not really at liberty to explain what the original environment this was used in, however it formed part and parcel of a much larger set of security utilities. As such, it performed it's job perfectly.

IP blocking in games is at best a very poor mechanism, at worse liable to upset large amounts of players. The principal here is to try and get people to understand IPs and CIDRs. I presented the code as an simple extension to DBS/MCcodes systems as there have been various requests along those lines and this fitted the bill pretty well.

I don't say use it - or don't use, I only ask that people who do use it - look at the code and try to understand what is going on. With that, hopefully I will have passed on a little knowledge.

As for single passwords -- well assuming you have basic username/password combination and that's all - I agree, once you have those - you are in. However we don't just use username/password combis - On a lot of sites, I force the use of static IP matching, client-side certificates, https protocol, time-frame matching etc. This makes it a lot more complex even with having access to the correct u/p combi.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...