Skip to content

Instantly share code, notes, and snippets.

@MuntashirAkon
Last active October 7, 2022 03:26
Show Gist options
  • Save MuntashirAkon/c9844c0c3095a4f28500b1d3115f0124 to your computer and use it in GitHub Desktop.
Save MuntashirAkon/c9844c0c3095a4f28500b1d3115f0124 to your computer and use it in GitHub Desktop.
LittleSnitchToggler
#!/bin/bash
#
# LittleSnitchToggler
# Script to enable/disable Little Snitch
# (c) Muntashir Al-Islam
# License: MIT License
#
# Alert if not a root user
#
if ! [ `id -u` -eq 0 ]; then
echo "The script must be run as root!"
exit 1
fi
daemon="/Library/LaunchDaemons/at.obdev.littlesnitchd.plist"
home=`echo ~`
wd="${home}/.ls"
agent_loc="/Library/LaunchAgents/"
helper="at.obdev.LittleSnitchHelper.plist"
ui_agent="at.obdev.LittleSnitchUIAgent.plist"
app_loc="/Library/Little Snitch"
function moveToWD(){
sudo mv $agent_loc$helper "$wd"
sudo mv $agent_loc$ui_agent "$wd"
sudo mv "$app_loc"/* "$wd/"
# in case anything goes wrong
killall "Little Snitch Network Monitor"
}
function restore(){
sudo mv "$wd/$helper" $agent_loc
sudo mv "$wd/$ui_agent" $agent_loc
sudo mv "$wd"/* "$app_loc/"
sleep 5
open "$app_loc/Little Snitch Agent.app"
open "$app_loc/Little Snitch Helper.app"
}
if [ -e $daemon ]; then
sudo launchctl list | grep at.obdev.littlesnitchd > /dev/null 2>&1
status=$?
# make working folder
mkdir "$wd" > /dev/null 2>&1
if [ $status -eq 1 ]; then #disabled
#enable it
sudo launchctl load -w $daemon
restore
echo -e "ENABLED"
exit 0
else
sudo launchctl unload -w $daemon
moveToWD
echo -e "DISABLED"
exit 0
fi
else
echo -e "NOT FOUND";
exit 1
fi
@MuntashirAkon
Copy link
Author

The latest version of Little Snitch doesn't include any sort of disabler to disable it temporarily. This script can be used to do so.

My recommended way of installing this small tool:

sudo curl -o /usr/bin/togglelittlesnitch -L https://gist.github.com/MuntashirAkon/c9844c0c3095a4f28500b1d3115f0124/raw/a149dccd21f3c136b6224dac0572e20f61d38304/littlesnitchtoggler.sh

and now make it executable:

sudo chmod +x /usr/bin/togglelittlesnitch

Now, simply running sudo togglelittlesnitch will enable/disable Little Snitch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment