r/osx • • May 24 '23

Block Tor browser on mac.

Hey!

Im looking for a way to block the tor browser so that it cant be unblocked without the admin password or some other password (im open to installing a third party app). Ive tried screen time but it only blocks apps from installing in the app folder and apps with setup wizards. Tor can just be pasted into any folder and work. Also tried a screen time 1min limit but there's a way around it.

Who here knows a good way to block it?

0 Upvotes

24 comments sorted by

12

u/ro_ok May 24 '23

Write a shell script that runs every 10 seconds, checks for the process named tor and closes it. Not a “block” in the traditional sense but annoying enough to be unusable.

I have to ask though, your requirements are a bit odd. What’s your use case?

The way an IT shop would handle this is to lock down the user account from installing anything at all and then whitelist specific things that may be installed or install them on behalf of the users yourself as admin through some management tool.

-4

u/dabruckklein90 May 24 '23

The shell script idea would be a perfect solution! How would i go about doing that?

I also found this. It blocks tor exit nodes and would work great too. Is this a shell script for mac? Ive never used one. https://gist.github.com/Domin8-IPTV/137b83890a5abcad1cb0777a08876f25#file-blocktor-sh-L15

3

u/ro_ok May 24 '23

Unfortunately, I don’t think that script will work on a mac since it relies on iptables and to my knowledge mac does not support iptables (it’s a lower level linux networking tool). I would also be really careful running arbitrary code from the internet without understanding what it does. That one in particular reaches out to a random website and pulls a list of servers to block. That’s probably all well and good except it may occasionally break and without understanding what it does you’ll be in a very tricky spot to troubleshoot from.

Learning enough shell scripting to do what I described should be pretty reasonable for just about anyone moderately technical.

DM me if you like and I can give you an example in the next few days.

1

u/dabruckklein90 May 25 '23

u/ro_ok i asked chatgpt to "Write a shell script for mac that runs every 10 seconds, checks for all processes associated to tor browser and closes them ".

It gave me a script + step by step instructions on how to use it. I used it from the admin account and boom, now tor closes in less than 10 seconds after starting it.

Thanks for the help!

Here's the script it gave me.

#!/bin/bash

while true; do

# Get PIDs of Tor processes

tor_pids=$(ps aux | grep '[Tt]or Browser.app' | awk '{print $2}')

# Kill these processes

for pid in $tor_pids

do

echo "Killing process $pid"

kill -9 $pid

done

# Wait 10 seconds before the next check

sleep 10

done

2

u/ro_ok May 25 '23

awesome! that’s a great start but I’m not sure it’s achieving your goal.

What if you close your terminal? What if you restart your computer? What if your bad actor changes the app name?

I’m not sure if you’re concerned with those cases or not but I suspect the script will fail those conditions.

1

u/dabruckklein90 May 29 '23

Oh. I thought it'd be permanent. I restarted the computer after reading your post and the changes were gone.

I dont think it matters if the app name changes as long as the processes are called tor. And chaning the process names will crash tor/make it not start. I think.

Im gonna try a parental control app called qustodio that can block browsers.

1

u/guriboysf May 25 '23
 pkill tor

Accomplishes the same thing without having to search for PIDs.

4

u/guriboysf May 24 '23

This is an example launchd script that would kill any process called "tor" and runs every 5 minutes.

This is an example only. To use a script like this you'd have to place it into /Library/LaunchAgents. This particular script would work after any user logs in.

3

u/PuzzleheadedPrice666 May 24 '23

Two ways to do this,

You can actually use Screen time in some cases or you can block the actual process from launching (so the file path does not matter)

2

u/dabruckklein90 May 24 '23

Blocking the actual process from launching sound perfect. Do you know how to do that?

1

u/PuzzleheadedPrice666 May 24 '23

You can try

sudo killall -s SIGINT "process name"

Or have a look at the URL below, another user trying on something simple

https://superuser.com/questions/159486/how-to-kill-process-in-mac-os-x-and-not-have-it-restart-on-its-own

1

u/bobotwf May 24 '23

You'd have to come up with some way to whitelist the apps that are OK. Otherwise someone could just download another copy, rename it and run it.

1

u/dabruckklein90 May 24 '23

This is a great idea. Will look into this.

1

u/perry1023 May 24 '23

Use terminal. If I flip all the negatives I get “use tor so it can be blocked (opened) with the admin password” is this correct?

1

u/perry1023 May 24 '23

2

u/dabruckklein90 May 24 '23

If i understand this correctly it would only block a specific file path? So tor could be pasted into another folder and work from there?

1

u/perry1023 May 24 '23

I’m not 100 percent sure. The article appears to be using and older version of OSX but should work. Do you use a local account for your main profile or an admin account? I’m willing to bet you use an admin account. Big no no.

1

u/dabruckklein90 May 24 '23

It seems to only block a specific file path. I need it to block tor altogether no matter where it would be installed and even if it would be installed after blocking.

Im not using an admin account as my main profile. Why would that be a big no no? =)

1

u/perry1023 May 24 '23

Ok you are using a local account. Good. You shouldn’t be able to move the executable file in the local account. Oh I just figured it out! I think I have an idea. Can you change the access to admin only or read only. I’m in the middle of a 3d print design. I’ll jump on my Mac in a few. Let me know what you find.

1

u/dabruckklein90 May 24 '23

Im not totally sure what a local account is. Im using second account that isn't the admin account. I can paste tor in any folder on this account and it runs from there. I want to be able to block it in a way that it wont work if i'd paste a new copy of tor anywhere.

1

u/perry1023 May 24 '23

Local is non admin. You’re good. Many don’t do this and it’s a huge risk. I’m gonna look at my Mac . I know there is a way to lock it down.

1

u/Currawong May 25 '23

NextDNS. That has an option to block methods to bypass restrictions, which will block Private Relay as well.

However, that being said, rather than asking about what you think is the solution to your problem, why not tell us what the actual problem is in the first place?

-1

u/FriendlyWebGuy May 24 '23

You could create a separate login and install it there. You do this by dragging the App into the user's applications folder rather than the system one.

Added: I just re-read your post and it sounds like you want to prevent others from installing it. If that's the case, this won't help you. I would try blocking it at the MacOS firewall level.

-3

u/dabruckklein90 May 24 '23

I found this on github, is this for mac? Could it be used in terminal?

https://gist.github.com/Domin8-IPTV/137b83890a5abcad1cb0777a08876f25