1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP protects proxy, bots ... visits?

Discussion in 'PHP & Perl' started by crazymonster, Oct 1, 2013.

  1. crazymonster

    crazymonster Junior Member

    Joined:
    Apr 8, 2011
    Messages:
    132
    Likes Received:
    20
    Home Page:
    How to protect my php site from proxies (unreal visits).

    What is the most effective method? And exampe code please!
     
  2. three3211

    three3211 Newbie

    Joined:
    Feb 8, 2012
    Messages:
    41
    Likes Received:
    3
    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]);
             }
         }
     
  3. crazymonster

    crazymonster Junior Member

    Joined:
    Apr 8, 2011
    Messages:
    132
    Likes Received:
    20
    Home Page:
    Method 2 can forbide Google and similar bots or?
     
  4. barigain

    barigain Junior Member

    Joined:
    Aug 23, 2012
    Messages:
    100
    Likes Received:
    12
    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
     
  5. Repulsor

    Repulsor Power Member

    Joined:
    Jun 11, 2013
    Messages:
    708
    Likes Received:
    267
    Location:
    PHP Scripting ;)
    List of public proxies? Are you kidding me? There are hundred thousand public proxies lol.
     
  6. rutix

    rutix Junior Member

    Joined:
    Sep 6, 2012
    Messages:
    102
    Likes Received:
    12
    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.
     
  7. Brainiac101

    Brainiac101 Newbie

    Joined:
    Jun 15, 2013
    Messages:
    46
    Likes Received:
    22
    Occupation:
    Entrenepeur
    Location:
    UK
    There is no way to stop it.
     
  8. fuad_2000

    fuad_2000 Registered Member

    Joined:
    Mar 13, 2010
    Messages:
    90
    Likes Received:
    9
    i will test it thank you
     
  9. dannyduberstein

    dannyduberstein Junior Member

    Joined:
    Nov 1, 2011
    Messages:
    189
    Likes Received:
    105
    Block Script found here http://www.blocked.com/

    this is a great professional script that can block proxy visits as well as other unwanted visitors.
     
  10. funque

    funque Newbie

    Joined:
    Dec 27, 2013
    Messages:
    21
    Likes Received:
    1
    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.