IP net block ban script?

G

Gary

I wish to add this to a few sites to make access irksome (rather than
impossible of course) for users from certain IP address blocks. There are
plenty of ready-made scripts for specific IP addresses, but I can't find any
for doing this for a *range* of IP addresses. BTW, I can only use client
side scripting.

Any source of such a script appreciated.

TIA
Gary
 
B

Brian Genisio

Gary said:
I wish to add this to a few sites to make access irksome (rather than
impossible of course) for users from certain IP address blocks. There are
plenty of ready-made scripts for specific IP addresses, but I can't find any
for doing this for a *range* of IP addresses. BTW, I can only use client
side scripting.

Any source of such a script appreciated.

TIA
Gary

First, if any such beast exists for one IP, it can easily be modified
for a range. No need to write something from scratch. What are some
examples that you have found?

Second, any/all client-side methods will fail... because it assumes that
the user has already downloaded the page, in order to execute the
javascript, therefore they have the code, and you cannot block them. If
you figure something out, they can turn off javascript, or easily hack
something.

For instance, I can download all of your code, make a slight
modification like replace if(trusted) with if(true)... or trusted =
true... and I am on my way.

It is not worth the effort... unless you do it server-side, which you
say you cannot do.

Brian
 
G

Gary

Brian Genisio said:
Gary wrote:
First, if any such beast exists for one IP, it can easily be modified
for a range.

It's not so easy (at least for me), given the dotted-decimal-notation of an
IP address. Single IP addresses are a doddle, but within a range? I'll have
to get busy with some octet routines....
Second, any/all client-side methods will fail... because it assumes that
the user has already downloaded the page, in order to execute the
javascript, therefore they have the code, and you cannot block them. If
you figure something out, they can turn off javascript, or easily hack
something.

As I said, it's intended to be irritating, *not* a serious attempt at
thwarting access. The group of users I wish to block *I know* are
particularly clueless technically, so for them it will not be that easy ;-)

Regards
Gary
 
B

Brian Genisio

Gary said:
It's not so easy (at least for me), given the dotted-decimal-notation of an
IP address. Single IP addresses are a doddle, but within a range? I'll have
to get busy with some octet routines....

Ok, it would be useful to see the code you want to modify, but take a
look at this *un-tested* code... it will check an IP for a range. If
you want more testing capability, you might want to use a more
sophisticated masking method, using bit-wise operators, and netmasks.
Without really knowing what you want to do, here is an example.

BTW, how are you getting the IP in the first place?
Brian

////////////////////////////////////////////////////////////////
myIp = "192.168.169.220";

// Put the octets in an array
myOctets = myIp.split(".");

// Block 192.168.100.* to 192.168.200.*
if((myOctets[0] == 192) && (myOctets[1] == 168) &&
((myOctets[2] >= 100) && (myOctets[2] <= 200)))
{
// Block code
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top