Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » How to block Tor users from accessing your website
- jvvg
-
1000+ posts
How to block Tor users from accessing your website
Currently, there is an issue of people trying to use Tor (an advanced proxy software) to bypass bans on websites.
However, I have devised a way to prevent Tor from being used to access your website (I am currently piloting this software on futuresight.org). It is fairly easy - it only involves downloading one file to your server and adding a few lines of code.
First, you need to download the list of Tor exit node IPs. The one I used is located at http://torstatus.blutmagie.de/ip_list_all.php/Tor_ip_list_ALL.csv. If you use a different one, you need to update the code accordingly.
Then, on each Tor-protected page, add the following code:
That is the basic code. On the FutureSight website, I did something a bit more advanced to optimize performance: it saves a cookie on your computer if your IP is not detected to be a Tor exit node, and instead of just killing the page as in the above example, it autobans the user from the website for a few days.
However, I have devised a way to prevent Tor from being used to access your website (I am currently piloting this software on futuresight.org). It is fairly easy - it only involves downloading one file to your server and adding a few lines of code.
First, you need to download the list of Tor exit node IPs. The one I used is located at http://torstatus.blutmagie.de/ip_list_all.php/Tor_ip_list_ALL.csv. If you use a different one, you need to update the code accordingly.
Then, on each Tor-protected page, add the following code:
$ips = explode("\n", file_get_contents('/path/to/tor-ips.csv');
if (in_array($_SERVER['REMOTE_ADDR'], $ips)) {
echo 'Please do not use Tor to access this website.'; die;
}
That is the basic code. On the FutureSight website, I did something a bit more advanced to optimize performance: it saves a cookie on your computer if your IP is not detected to be a Tor exit node, and instead of just killing the page as in the above example, it autobans the user from the website for a few days.
- bobbybee
-
1000+ posts
How to block Tor users from accessing your website
I honestly don't like this. The code is fine (just arguably poor performance), but I don't think you should block Tor exit nodes. Some users have legitimate reasons for using them.
- nXIII
-
1000+ posts
How to block Tor users from accessing your website
I agree with bobbybee. Many people use Tor to protect their privacy and their personal freedom; please don't prevent them from doing so.
- jvvg
-
1000+ posts
How to block Tor users from accessing your website
Oh, the reason I'm implementing it is that spambots often like to use Tor, and that people I know are attempting to post harmful stuff on the forums, and this is to prevent them from getting around IP bans. The people I know that use Tor are only trying to protect their freedom to be harmful. I agree with bobbybee. Many people use Tor to protect their privacy and their personal freedom; please don't prevent them from doing so.

- BigBlueBlock
-
500+ posts
How to block Tor users from accessing your website
I honestly don't like this. The code is fine (just arguably poor performance), but I don't think you should block Tor exit nodes. Some users have legitimate reasons for using them.

- scratchisthebest
-
1000+ posts
How to block Tor users from accessing your website
$ips = explode("\n", file_get_contents('/path/to/tor-ips.csv'); if (in_array($_SERVER['REMOTE_ADDR'], $ips)) { echo 'Please do not use Tor to access this website. If you have a legitimate reason for using Tor, please email xxx (at) fgsdfgsdfgfds.com. '; die; }
fix'd
- lallaway12
-
100+ posts
How to block Tor users from accessing your website
roter blocking whould be nicer
Mod edit: Removed excessive blank space. Please don't use more space than is necessary for your post!
@Mod Edit: Sorry it was a bug
Mod edit: Removed excessive blank space. Please don't use more space than is necessary for your post!
@Mod Edit: Sorry it was a bug
Last edited by lallaway12 (Aug. 21, 2013 05:07:14)
- jvvg
-
1000+ posts
How to block Tor users from accessing your website
What is roter? roter blocking whould be nicer
Mod edit: Removed excessive blank space. Please don't use more space than is necessary for your post!
- chocolatepenguin
-
1000+ posts
How to block Tor users from accessing your website
Router?What is roter? roter blocking whould be nicer
Mod edit: Removed excessive blank space. Please don't use more space than is necessary for your post!
- lallaway12
-
100+ posts
How to block Tor users from accessing your website
YeahRouter?What is roter? roter blocking whould be nicer
Mod edit: Removed excessive blank space. Please don't use more space than is necessary for your post!
- alwayspaytaxes
-
500+ posts
How to block Tor users from accessing your website
Is this still a good idea
- PPPDUD
-
1000+ posts
How to block Tor users from accessing your website
Yes. If info about a subject is available, it should be easy to access. And this project helps accomplish that belief. Is this still a good idea
- Ribbun
-
4 posts
How to block Tor users from accessing your website
Did you Is this still a good ideareally have to bump a decade old thread?
- imfh
-
1000+ posts
How to block Tor users from accessing your website
Instead of using the provided script, I would use something like CloudFlare which will automatically handle it for you and be much faster. Is this still a good idea
- DifferentDance8
-
1000+ posts
How to block Tor users from accessing your website
CloudFlare is just generally bad in terms of privacy, however this is the only information I can find about Cloudflare and privacy that doesn't have anything to do with their DNS (that's a whole separate issue):Instead of using the provided script, I would use something like CloudFlare which will automatically handle it for you and be much faster. Is this still a good idea
Cloudflare basically decrypts the data between you and the instance to compress it to send it faster, a CDN basically. In other words, Cloudflare can see your data in Plain text even with HTTPS.
Last edited by DifferentDance8 (Oct. 22, 2023 04:42:41)
- alwayspaytaxes
-
500+ posts
How to block Tor users from accessing your website
Oh yeah I almost forgot about that. It probably also doesn't assume that Tor == badInstead of using the provided script, I would use something like CloudFlare which will automatically handle it for you and be much faster. Is this still a good idea
Yes lolololololDid you Is this still a good ideareally have to bump a decade old thread?
Any basis for that claim? CloudFlare is just generally bad in terms of privacy, however this is the only information I can find about Cloudflare and privacy that doesn't have anything to do with their DNS (that's a whole separate issue):
Cloudflare's network and all of our products are built with data protection in mind. Cloudflare does not sell personal data we process on customers' behalf, or use it for any purpose other than to provide our services.https://www.cloudflare.com/trust-hub/us-privacy-compliance
- Discussion Forums
- » Advanced Topics
-
» How to block Tor users from accessing your website