PHP protects proxy, bots ... visits?

crazymonster

Junior Member
Joined
Apr 8, 2011
Messages
167
Reaction score
30
How to protect my php site from proxies (unreal visits).

What is the most effective method? And exampe code please!
 
Use the following 2 solutions in PHP:

Method 1 = quick but does not work with anonymous proxies
Code:
$proxy_headers = array(
        [COLOR=#800000]'HTTP_VIA'[/COLOR],
        [COLOR=#800000]'HTTP_X_FORWARDED_FOR'[/COLOR],
        [COLOR=#800000]'HTTP_FORWARDED_FOR'[/COLOR],
        [COLOR=#800000]'HTTP_X_FORWARDED'[/COLOR],
        [COLOR=#800000]'HTTP_FORWARDED'[/COLOR],
        [COLOR=#800000]'HTTP_CLIENT_IP'[/COLOR],
        [COLOR=#800000]'HTTP_FORWARDED_FOR_IP'[/COLOR],
        [COLOR=#800000]'VIA'[/COLOR],
        [COLOR=#800000]'X_FORWARDED_FOR'[/COLOR],
        [COLOR=#800000]'FORWARDED_FOR'[/COLOR],
        [COLOR=#800000]'X_FORWARDED'[/COLOR],
        [COLOR=#800000]'FORWARDED'[/COLOR],
        [COLOR=#800000]'CLIENT_IP'[/COLOR],
        [COLOR=#800000]'FORWARDED_FOR_IP'[/COLOR],
        [COLOR=#800000]'HTTP_PROXY_CONNECTION'[/COLOR]
    );
    [COLOR=#00008B]foreach[/COLOR]($proxy_headers [COLOR=#00008B]as[/COLOR] $x){
        [COLOR=#00008B]if[/COLOR] (isset($_SERVER[$x])) [COLOR=#00008B]die[/COLOR]([COLOR=#800000]"You are using a proxy!"[/COLOR]);
    }

Method 2 = portscan back to the origin IP at the normal proxy ports used
Code:
[/FONT]


$ports = array([COLOR=#800000]8080[/COLOR],[COLOR=#800000]80[/COLOR],[COLOR=#800000]81[/COLOR],[COLOR=#800000]1080[/COLOR],[COLOR=#800000]6588[/COLOR],[COLOR=#800000]8000[/COLOR],[COLOR=#800000]3128[/COLOR],[COLOR=#800000]553[/COLOR],[COLOR=#800000]554[/COLOR],[COLOR=#800000]4480[/COLOR]);
    [COLOR=#00008B]foreach[/COLOR]($ports [COLOR=#00008B]as[/COLOR] $port) {
         [COLOR=#00008B]if[/COLOR] ([COLOR=#800000]@fsockopen[/COLOR]($_SERVER[[COLOR=#800000]'REMOTE_ADDR'[/COLOR]], $port, $errno, $errstr, [COLOR=#800000]30[/COLOR])) {
              [COLOR=#00008B]die[/COLOR]([COLOR=#800000]"You are using a proxy!"[/COLOR]);
         }
     }
 
Method 2 can forbide Google and similar bots or?
 
Second method is more risky, because any computer with Skype have 443 port opened.
Additionally, it's very slow method = you should try to open 10 connections and wait for timeout..
I prefer first method + list of public proxies
 
List of public proxies? Are you kidding me? There are hundred thousand public proxies lol.

so what?
one check in a database with 100K proxies will finish in less than a second...

the main problem is that he needs to find all public proxies and save them in db, which is crazy idea.
 
Blocking IP's is a waste of time. There are thousands of proxies out there and they come and go with new IP's daily. You would end up blocking half the internet.

What you need is proxy detection software so that it blocks anyone coming in on a proxy.
 
Back
Top