Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » How to block Tor users from accessing your website
- jvvg
- Scratcher
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.
Professional web developer and lead engineer on the Scratch Wiki
Maybe the Scratch Team isn't so bad — Why the April Fools' Day forum didn't work last year
- bobbybee
- Scratcher
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.
“Ooo, can I call you Señorita Bee?” ~Chibi-Matoran
- jvvg
- Scratcher
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.
Professional web developer and lead engineer on the Scratch Wiki
Maybe the Scratch Team isn't so bad — Why the April Fools' Day forum didn't work last year
- BigBlueBlock
- Scratcher
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
- Scratcher
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
I am a Lava Expert
- lallaway12
- Scratcher
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)
See my blog ITS MAD so subscribe comment and enjoy http://lallawayrandom.blogspot.co.uk/ ask me what to put up there
Feed my dragons
- jvvg
- Scratcher
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!
Professional web developer and lead engineer on the Scratch Wiki
Maybe the Scratch Team isn't so bad — Why the April Fools' Day forum didn't work last year
- chocolatepenguin
- Scratcher
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
- Scratcher
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!
See my blog ITS MAD so subscribe comment and enjoy http://lallawayrandom.blogspot.co.uk/ ask me what to put up there
Feed my dragons
- alwayspaytaxes
- Scratcher
100+ posts
How to block Tor users from accessing your website
Is this still a good idea
-\{:)_/-
play sound [bad to the bone riff.wav v]
- PPPDUD
- Scratcher
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
Fun fact: If you have malware on a Windows NT device, it's possible that deleting system32 will severely damage the malware. It will also damage your Windows install.
Help keep this topic alive!
The rest of my signature was eaten by an evil kumquat attacked by a terrible president who ate my banana shot down this signature instead of shooting down the TikTok Cell Tower white balloon that probably had a camera bundled with it.
https://img-s-msn-com.akamaized.net/tenant/amp/entityid/AA1isnZw.img?w=800&h=435&q=60&m=2&f=jpg
- Ribbun
- New to Scratch
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?
define ribbun
set [ pronouns] to [she/her]
set [ interests] to [linux, web development, domains]
- imfh
- Scratcher
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
Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/
- DifferentDance8
- Scratcher
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)
R.I.P Zydrolic, 2023-2024
- alwayspaytaxes
- Scratcher
100+ 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
-\{:)_/-
play sound [bad to the bone riff.wav v]
- Discussion Forums
- » Advanced Topics
- » How to block Tor users from accessing your website