Subscribe: Subscribe in NewsGator Online

Anonymous Proxies

Add

Anonymous proxies are a huge problem for operators of forums. I have developed an anonymous proxy blocker that will help block proxies from PHPBB forums. It is not a perfect solution and you should still be proactive in your efforts. The system works via 2 methods.

- First on login it scans the IP address for open ports associated with a proxy and attempts to send a proxy request if it finds one.
- Second it checks several reverse DNS blackhole lists for the IP

I only do this on login to minimize the load on the site, minimize the slow down in the user page loads, and not swamp the dn servers with requests.

You should check with your service provider if you are allowed to scan other computers. Some service providers will take this as hacking.

If so just comment out the very last line in the instructions.

In my implementation I have logging functions and maintain a database of discovered proxies. You may want to add that yourself or contact me and I’ll sell it to you.


- In the includes directory create a new file call proxyblocker_scan.php- Cut and paste the following into it.

< ?php
//
// Is this a new proxy using known proxy ports ?
// could have used port 80 but many dialups use it on their servers...
        $ports = array( 3128, 1080, 8080 );
        $target = $_SERVER['REMOTE_ADDR'];
        while( $port = array_pop( $ports ))
        {
                $isproxy = 0;
// open a  socket to the connecting host on well known proxy sockets
                $socket = @fsockopen( “tcp://$target”, $port, $errno, $errstr, 3 );
                if( $errno == 0 )
                {
                        $request = “GET http://www.google.com/ HTTP/1.0rn”;
                        $request .= “Proxy-Connection: Keep-Alivern”;
                        $request .= “Pragma: no-cachern”;
                        $request .= “Host: www.google.comrn”;
                        $request .= “User-Agent: MSIE 6.0rn”;
                        $request .= “rn”;

                        fputs($socket, $request);
                        $response = fputs($socket, 128);
                        if(strlen(stristr($response, “200″)) > 0){
                                $isproxy = 1;
                        }

                        if( $isproxy )
                        {
                                fclose($socket);
                                die();
                       } else {
                                 fclose($socket);
                       }
                }
        }
?>

- Save and close the file.

- In the includes directory create and open a file called proxyblocker_dnsbl.php
- Cut and paste the following into the file:

< ?php

        $reverse_ip = get_reversed_ip( $_SERVER['REMOTE_ADDR'] );

// array of rbl servers
        $rbl_dns_servers = array(
                ‘.http.dnsbl.sorbs.net’,
                ‘.socks.dnsbl.sorbs.net’,
                ‘.misc.dnsbl.sorbs.net’,
                ‘.proxies.blackholes.easynet.nl’,
                ‘.list.dsbl.org’
        );

// loop through list of rbl servers
        while( $reverse_dns = array_pop( $rbl_dns_servers ))
        {
// check for ip on a rbl server
                if( check_rbl( $reverse_ip, $reverse_dns ))
                {
// discovered a proxy on one of the servers
                        die();
                }
        }

?>

- Save and Close the File

- Create and Open file in includes directory called ‘functions_proxyblock.php’

- Cut and paste the following into file:

< ?php

// checks to see if a ip is on a dns server
function check_rbl( $reverse_ip, $reverse_dns )
{
        $is_bad_ip = FALSE;

        $rlookup = $reverse_ip . $reverse_dns;

        if( $rlookup == gethostbyname($rlookup))
        {
// returned the same info so not on list
        } else {
// returned information so is on list
                $is_bad_ip = TRUE;
        }
        return $is_bad_ip;
}

// takes an ip address passed to it and returns a revered ip
function get_reversed_ip( $ip )
{
        $ip_exploded = explode('.', $ip );
        $reverse_ip = "$ip_exploded[3].$ip_exploded[2].$ip_exploded[1].$ip_exploded[0]“;
        return $reverse_ip;
}

?>

- Open common.php

- FIND include($phpbb_root_path . ‘includes/db.’.$phpEx);
- AFTER WRITE include($phpbb_root_path . ‘includes/functions_proxyblock.’.$phpEx);
- SAVE & CLOSE common.php

- OPEN login.php
- FIND include($phpbb_root_path . ‘common.’.$phpEx);
- AFTER ADD
include($phpbb_root_path . ‘proxyblocker_scan.’.$phpEx);
include($phpbb_root_path . ‘proxyblocker_dnsbl.’.$phpEx);


Like it? Subscribe to the blog if you haven't already
Filed under: General — Scott @ May 20, 2005 12:53 pm Digg!

17 Comments
Comment by Michael Sakai
2006-04-15 23:57:25

You are genious! Great thanks!

 
Comment by Scott
2006-04-16 13:47:33

Glad you liked it :)

 
Comment by Mark
2006-07-19 08:43:23

Very nice :) A badly needed mod. Is there any way I can tweak this just to apply the block only to guest posters? I do not want to implement compulsory registration before posting is allowed.

I am on phpBB 2.0.21

 
Comment by Jason
2006-12-11 20:35:07

How would I only include this on the register page and not the login page?

 
Comment by Scott
2006-12-11 20:51:29

Jason I am sorry I don’t maintain this any longer. Last I checked there were several alternatives on phpbbhacks.com if memory serves. The code should still be good but you need to verify that for yourself.

Sorry :(

 
Comment by aladavlis
2006-12-16 21:25:29

Hello,
I am having trouble with my Internet explorer.It is doing some very odd things.Sometimes it will completely close the page i am visiting for no reason or it will be very slow loading pages and when i say slow i mean very very very slow for eg i tried to google something and after 10 minutes of the page trying to load i gave up.I thought that it was perhaps the topic i was searching so i tried putting in random things to see if that made any difference but it didn’t.Another problem i had was when i was on a forum and clicked on a link and nothing happened i tried to open a new tab and that wouldn’t work either and it would let me access any options that are in my tools menu.i had to restart my computer.Just to let you know i have high speed Internet connection.Thanks in advance to anyone that helps me with this problem.

 
Comment by Eric
2006-12-30 08:37:59

Greetings,

I’ve used your script for my website! Theres just a few errors in your script though. The

 
Comment by Eric
2006-12-30 08:38:25

Oh yeah you forgot to add the ‘includes’ directory in serveral includes.

 
Comment by Jade
2007-01-30 10:34:39

how do u get around blocks at school??

Comment by alison
2007-06-27 05:12:37

i know i need proxy

 
 
Comment by Scott
2007-01-30 10:53:25

Hi Jade.. I would recommend searching for a thing called “CGI proxies”.

 
Comment by leanne
2007-02-02 08:18:29

plz find me a good proxie that works

 
Comment by alison
2007-06-27 05:11:36

yeah me 2 plz hun im dieng skool is sooooo boring without bebo :-(

 
Comment by jmmbacon
2007-07-07 02:01:20

Does anyone know of a way to find out the owner of a cell phone if you know their number? I see many sites for reverse lookups for cell phones but they charge almost 100 bucks.

All of the free reverse phone number sites have a fee after you put in the phone number. Anywho.com or whitepages.com or any of that stuff does not work since you have to pay to get a report.

Are there any ACTUAL free ones out there?

 
Comment by TuseUpseheste
2007-08-29 23:02:16

Hi, people….! I find one beutiful sait…..

 
Comment by josh
2007-08-30 13:42:45

need a proxie

 
Comment by ememjammer
2007-09-18 11:02:33

So I was off work and surfing and found this place and thought I would join up. I don’t have much more to say right now except I need to start reading some of the older posts to get up to speed before I can start posting.

Em

 

Sorry, the comment form is closed at this time.