Skip to content

Instantly share code, notes, and snippets.

@DarthPumpkin
Last active October 25, 2022 18:31
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save DarthPumpkin/293b3839fd2e796ac11b to your computer and use it in GitHub Desktop.
Save DarthPumpkin/293b3839fd2e796ac11b to your computer and use it in GitHub Desktop.
OS X shell script for routing all traffic through tor. Requires tor to be installed (brew install tor). Taken from https://kremalicious.com/simple-tor-setup-on-mac-os-x/, modified from http://leonid.shevtsov.me/en/an-easy-way-to-use-tor-on-os-x To stop using tor just terminate this script with Ctrl C
#!/usr/bin/env bash
# 'Wi-Fi' or 'Ethernet' or 'Display Ethernet'
INTERFACE=Wi-Fi
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Let's roll
sudo networksetup -setsocksfirewallproxy $INTERFACE 127.0.0.1 9050 off
sudo networksetup -setsocksfirewallproxystate $INTERFACE on
tor
sudo networksetup -setsocksfirewallproxystate $INTERFACE off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment