Jump to content

Proxy Detection - fsockopen. How effective?


slyte33

Recommended Posts

I've searched google for hours and finally found a code that has blocked over 50+ proxies that i've tried from accessing my site:

if( @fsockopen( $_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1 ) )
{
echo "Not allowed, using proxy!";
ext();

}

 

What I am asking is, how effective is this? Can it be bypassed or anything?

 

All help on this would be appreciated, thanks!

Link to comment
https://forums.phpfreaks.com/topic/193974-proxy-detection-fsockopen-how-effective/
Share on other sites

Well, that would work for HTTP proxies, that are web-based.

There are also Socks proxies, and some other's using different ports.

 

Here are some other commonly used ports by proxies:

80
88
443
554
808
1080
3124
3127
3128
3246
6588
8000
8008
8080
8085
8088
8118
9188
36673

Sorry, but I don't reply with PM's.

 

You could use this to search with each port;

<?php

$ports = array(80, 88, 443, 554, 808, 1080, 3124, 3127, 3128, 3246, 6588, 8000, 8008, 8080, 8085, 8088, 8118, 9188, 36673);

foreach($ports as $port) {
    if (@fsockopen( $_SERVER['REMOTE_ADDR'], $port, $errno, $errstr, 1)) $proxy = true;
}

if (!empty($proxy)) {
    echo 'You have been detected to be using a proxy!<br />Please contact an administrator if you feel this is incorrect.';
    exit;
}

 

Just to make something more clear, even with just those commonly used ports it would take 19 seconds to check.

I'd suggest caching the valid IP's somewhere after validation.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.