469,645 Members | 1,193 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,645 developers. It's quick & easy.

IP net block ban script?

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

Jul 20 '05 #1
3 1752
Gary wrote:
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

Jul 20 '05 #2

"Brian Genisio" <Br**********@yahoo.com> wrote in message
news:40********@10.10.0.241...
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

Jul 20 '05 #3
Gary wrote:
"Brian Genisio" <Br**********@yahoo.com> wrote in message
news:40********@10.10.0.241...
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....


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
}

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jon W | last post: by
5 posts views Thread by Steve | last post: by
3 posts views Thread by sklett | last post: by
4 posts views Thread by drew197 | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.