News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Proxy Blocker

Started by simmaster, December 21, 2009, 04:47:52 AM

Previous topic - Next topic

simmaster

Quote from: qtime on December 23, 2009, 07:10:30 AM
great news!!! I will test it within a few hours, I asked for a spanish member to help to translate, unfortunately no responds, yet...

Let me know when he gets a translation, because I need one ASAP. ;)
I'm going to be in school until 3:40 so I might not be online. (unless I manage to sneak in through the library connection :D)

qtime

 Block registration if using proxy
bloquear registro si usas proxy

Block forum if using proxy
bloquear foro si usas proxy

qtime

Tested it at my forum and it's blocking great, the proxy sites and proxies added to the browser!!! Thanks a lot.

markd

Actually, there's an error in your coding of the index.php file.  It places the IsTorExitPoint() function at the bottom of the file, outside of the close php script statement ?>

Caused a blank white screen for me, and the error logs stated a call to undefined function in index.php, which made me look at it for the error.  I just simply moved the ?> to after the function and the forum lit right back up.

You might want to check this in the modification.xml file.

Thanks tho.  Really needed this.  In the past month, we've had over 1500 registrations all from proxies.

cheers and happy holidays!

-mark

simmaster

Quote from: markd on December 23, 2009, 02:05:56 PM
Actually, there's an error in your coding of the index.php file.  It places the IsTorExitPoint() function at the bottom of the file, outside of the close php script statement ?>

Caused a blank white screen for me, and the error logs stated a call to undefined function in index.php, which made me look at it for the error.  I just simply moved the ?> to after the function and the forum lit right back up.

You might want to check this in the modification.xml file.

Thanks tho.  Really needed this.  In the past month, we've had over 1500 registrations all from proxies.

cheers and happy holidays!

-mark

Odd issue you have there. I'm not sure if this is a glitch in your package manager since qtime and I installed it fine, but the install xml files place the edits at the end of the file before ?> (<search position="end" />)

Tokzu

Nice mod, thanks. ;D

By the way, what theme is that of this image? I am looking for a theme to change the design of my web and that I liked it. =P
"I don't need a knight in a shinny armor, I need a angel in a trench coat"

My mods:

Arantor

#26
That appears to be a WordPress theme, Arclite, spliced into SMF.

Oh, random thought. I see in the latest code, you have a large block of conditions, which amounts to (condition || condition || condition) && condition.

Since it requires the last part to be true, put that first. If it fails, the rest of the stuff is never executed, so it's faster.


Also:
function IsTorExitPoint()
{
if (
gethostbyname(ReverseIPOctets($_SERVER['REMOTE_ADDR']) . "." .
$_SERVER['SERVER_PORT'] . "." .
ReverseIPOctets($_SERVER['SERVER_ADDR']) .
".ip-port.exitlist.torproject.org")
== "127.0.0.2"
)
return true;
else
return false;
}


Can be simplified without any loss of functionality or meaning:
function IsTorExitPoint()
{
return (
gethostbyname(ReverseIPOctets($_SERVER['REMOTE_ADDR']) . "." .
$_SERVER['SERVER_PORT'] . "." .
ReverseIPOctets($_SERVER['SERVER_ADDR']) .
".ip-port.exitlist.torproject.org")
== "127.0.0.2"
);
}
Holder of controversial views, all of which my own.


markd

#27
Hmm.. the error log is being flooded now.  What browser did you test this on?

The httpd server variables:

$_SERVER['HTTP_X_FORWARDED_FOR']
                || $_SERVER['HTTP_X_FORWARDED']
                || $_SERVER['HTTP_FORWARDED_FOR']
                || $_SERVER['HTTP_VIA']
$_SERVER['HTTP_CONNECTION']

are not being passed by the browsers (most likely firefox), thus resulting in undefined index errors in the SMF error log with EVERY CLICK (log is up to 1000 pages as I type this).  I even tried turning registered globals on, and making adjustments to your code to no avail.

Any insight into this?

-mark

edit:  it appears that REMOTE_ADDR is empty, thus causing the undefined errors.  looking into a fix.


Arantor

!empty($_SERVER['HTTP_X_FORWARDED_FOR'])
                || !empty($_SERVER['HTTP_X_FORWARDED'])
                || !empty($_SERVER['HTTP_FORWARDED_FOR'])
                || !empty($_SERVER['HTTP_VIA'])
!empty($_SERVER['HTTP_CONNECTION'])

^^ might do the trick.

empty() should be checked in more places than it is right now, really. If there's a chance the variable doesn't exist, check with empty() first.
Holder of controversial views, all of which my own.


markd

okay, I edited my post above to state that it appears as if REMOTE_ADDR is always empty.

I added the empty check to all the statements and the errors ceased, and i also had to add it to $modSettings['proxyblock_index'].  I also had to make the changes in Register.php too.

Now, I just kinda wonder if it's broken and won't work anyway if REMOTE_ADDR is always empty.


markd

nevermind.. REMOTE_ADDR is being populated.  it was the empty check.  If someone is using a proxy those variables will be present (not empty)

Thank you.

-mark


markd

and it works.. caught one right away!  :)

IP address     Display name     Message     Date
91.77.195.249    Guest    Sorry, but the administrator has blocked access by proxies. Other causes of this error include using an intranet (school connections), registering on a cell phone, or using a browser that does not support compression or does not accept encoding.
?action=register    Today at 04:51:22 PM

markd

ugh.. now its blocking all registrations, even for me.

back to square one.  :)


simmaster

#33
Quote from: The Grinch on December 23, 2009, 03:50:40 PM
That appears to be a WordPress theme, Arclite, spliced into SMF.
Correctomundo.
Quote
Oh, random thought. I see in the latest code, you have a large block of conditions, which amounts to (condition || condition || condition) && condition.

Since it requires the last part to be true, put that first. If it fails, the rest of the stuff is never executed, so it's faster.

Will do.

Quote
Also:
function IsTorExitPoint()
{
if (
gethostbyname(ReverseIPOctets($_SERVER['REMOTE_ADDR']) . "." .
$_SERVER['SERVER_PORT'] . "." .
ReverseIPOctets($_SERVER['SERVER_ADDR']) .
".ip-port.exitlist.torproject.org")
== "127.0.0.2"
)
return true;
else
return false;
}


Can be simplified without any loss of functionality or meaning:
function IsTorExitPoint()
{
return (
gethostbyname(ReverseIPOctets($_SERVER['REMOTE_ADDR']) . "." .
$_SERVER['SERVER_PORT'] . "." .
ReverseIPOctets($_SERVER['SERVER_ADDR']) .
".ip-port.exitlist.torproject.org")
== "127.0.0.2"
);
}


Arantor, you're better at fixing my code than I am ::)

Quote from: markd on December 23, 2009, 05:16:54 PM
ugh.. now its blocking all registrations, even for me.

back to square one.  :)

Manually remove every edit from the mod, uninstall the package and delete it, then get the newest package and reinstall that. I accidentally uploaded a premature package that blocked everyone and took it down within a few minutes, but you may have downloaded it.

DarkLite

So have the Firefox bugs been fixed?

simmaster

As of Firefox 3.5.5 and Proxy Blocker 1.1.2, Firefox isn't blocked. Yet, it wasn't blocked to begin with.

DoctorMalboro

the new spanish translation  ;D

$txt['proxyblock_reg'] = 'Bloquear registro si usan proxy';
$txt['proxyblock_index'] = 'Bloquear foro si usan proxy';

ddarrell

Installed 1.1.2 version of this mod.  Within a couple of hours, error log flooded (60 pages).
It appears to generate an error with every click.  I saw my own errors generated with
Firefox 3.5.6.  I didn't study the others before clearing the error log.

Uninstalled this mod.

Hope you get it fixed, good idea. Although it appears to have the potential to be wormy as is.

:)

i know just enough to really screw up ;D

simmaster

Yeah, SMF 2.0 seems to make an undefined index error for empty $_SERVER variables.

Arantor

Of course it does. It's a regular variable. You still need to check if it's empty or not.
Holder of controversial views, all of which my own.


Advertisement: