Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Banning IP Address

Author
Message
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 29th Jun 2006 20:39 Edited at: 29th Jun 2006 20:43
Is there a free PHP script anywhere which can ban ip adresses with wild cards in e.g 10.18.**.** i searched on google but there werent any wildcard ip bans on there.
Thanks,
Alex


Flindiana Jones
20
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Bosnian Power
Posted: 29th Jun 2006 20:56
I think I'm seeing a trend here; first ask about creating a mod, add that they may be dangerous, then you ask about IP bans...very interesting.

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 29th Jun 2006 20:59
LOL, there not related


PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 29th Jun 2006 21:22 Edited at: 29th Jun 2006 21:24
You can do it easily, I think. This code may or may not work as there are probably a few errors...but this is without documentation to refer to...



This would need to be modified for other domains etc. Also, this can be used to ALLOW access also.

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 30th Jun 2006 00:45 Edited at: 30th Jun 2006 00:47
I think rich did something like:



Science, Mathematics, and Physics do not lie - only people do.
ionstream
20
Years of Service
User Offline
Joined: 4th Jul 2004
Location: Overweb
Posted: 30th Jun 2006 01:03
CattleRustler made a funny.

Richard Davey
Retired Moderator
22
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 30th Jun 2006 01:35
Quote: "response.redirect('http://www.barbie.com')"


Rich would never stoop so low as to use ASP

But yeah, in PHP the $_SERVER['REMOTE_ADDR']; environment variable is the one you want, it will contain the IP address of the requesting client. This isn't always THEIR IP address of course - AOL users are passed through a whole network of proxy and caching servers for example, but it's pretty solid. It's passed up to PHP from the Apache network layer, i.e. you'd have to be one good hacker to fake it well.

Cheers,

Rich

Bite my shiny metal ass
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 30th Jun 2006 02:03
Just make sure you ban there subnet ip, if they are on say cable for example, they can simply use a proxy to change there IP addy. But if you ban there subnet ip they won't beable to access the site even if they change there IP's.

I think thats correct anyways.

Host your site for free www.darkuniverse.net

E-mail UnderLord @ UnderLord AT darkuniverse DOT net
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 30th Jun 2006 02:07
alternatively, if you can use .htaccess files - try something like:


the first deny is for a specific IP - the second is for a "subnet", so in that case, all the 192.168.1.* addresses get blocked. This works more efficiently than PHP as it doesn't touch the parser - gets blocked before then.
As google is everyone's friend, I'll let you search for a tool which converts human friendly IP ranges into IP/subnet. If you haven't found it by tomorrow when I get to work I'll post it then (as I cant remember now and I need sleep... MAJOR PINK EYE!!)

[center]
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 30th Jun 2006 02:11
Quote: "MAJOR PINK EYE!!"


When I was in the army I knew a guy who had pink eye (we all had it for about a month, on and off) he refused to go to the clinic and his eye eventually swelled up and was about the size of my fist. So get it taken care of.

Host your site for free www.darkuniverse.net

E-mail UnderLord @ UnderLord AT darkuniverse DOT net
Nicholas Thompson
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Bognor Regis, UK
Posted: 30th Jun 2006 02:16
Good advice... *flops sideways from chair to bed...*

[center]
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 30th Jun 2006 02:36


Science, Mathematics, and Physics do not lie - only people do.
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 30th Jun 2006 08:24 Edited at: 30th Jun 2006 08:25
Would this work


and that would that block 10.18.**.**
Thanks,
Alex


PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 30th Jun 2006 08:33 Edited at: 30th Jun 2006 08:43
Yes it would work.

[edit]
Probably should have checked the operands :p

Richard Davey
Retired Moderator
22
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 30th Jun 2006 08:41
Quote: "if($iparray[0] = "10" && $iparray[1] = "18")

{
header('http://www.barbie.com');
}"


It won't work (or at least not in the way you are expecting) because PHP requires double operators for comparisons. I.e. you need:

$iparray[0] == '10'

(note the two ==)

Ideally you'd cast to an int first, then do a strict comparison (===) but the above will work well enough.

Bite my shiny metal ass
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 30th Jun 2006 09:23
Sorry I am a noob at php, will this work



Richard Davey
Retired Moderator
22
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 30th Jun 2006 09:30
Yes.

Bite my shiny metal ass
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 30th Jun 2006 09:35 Edited at: 30th Jun 2006 09:35
Somthing's wrong
Quote: "Error 500: Script Execution Failure"

Any one know?
Thanks,
alex


PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 30th Jun 2006 09:36
Server problem. You can tell that by the '5' IIRC...

Richard Davey
Retired Moderator
22
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 30th Jun 2006 09:42
Change this line:

header('http://www.fireproductions.co.uk/bantest/ban.htm');

to:

header('Location: http://www.fireproductions.co.uk/bantest/ban.htm');

Bite my shiny metal ass
AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 30th Jun 2006 18:01
sorry , Error 500: Script Execution Failure it was my .htaccess.
Thanks,
Alex


Login to post a reply

Server time is: 2024-11-17 06:19:48
Your offset time is: 2024-11-17 06:19:48