Generate a rule group for Little Snitch from one of Steven Black's host blocklists.
We assume the raw host file takes the following form:
# Comment lines
127.0.0.1 normal.hosts
# Blacklist hosts start
0.0.0.0 bad.domain.com
0.0.0.0 another.domain.com
# More blacklist hosts
0.0.0.0 suspicious.org
All blacklist hosts have the IP address 0.0.0.0
. The script parses out the hostnames and adds them
to a JSON template representing the Little Snitch rule group. This is written to stdout.
The template looks like this:
{
"description" : "Generated from $URL",
"name" : "$NAME",
"denied-remote-hosts" : [
$HOSTS
]
}
./snitcher.sh
The following environment variables affect the behaviour of snitcher
:
URL
: the source URL, which should produce what looks like a regular UNIX hosts file. Defaults tohttps://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
.NAME
: the name for this rule group. Defaults toSteven Black
.