/snitcher

Create Little Snitch rule group from list of hostnames

Primary LanguageShellBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Snitcher

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
  ]
}

Usage

./snitcher.sh

Environment variables

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 to https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts.
  • NAME: the name for this rule group. Defaults to Steven Black.