Skip to main content

macOS hardening, privacy & anonymity CLI (Python shim)

Project description

better-anonymity

MacOS Security, Privacy & Anonymity Tools

This repository contains scripts and configuration files to automate the hardening of MacOS (Intel and Apple Silicon). It aims to enhance security, privacy, and anonymity by applying best practices inspired by the drduh/macOS-Security-and-Privacy-Guide and privacy.sexy.

Credits & Influences

A significant portion of the aggressive privacy tuning and "Privacy Over Security" configurations found within this toolkit's macOS hardening logic is directly influenced by and adapted from the excellent work over at privacy.sexy by undergroundwires. We highly recommend checking out their project for comprehensive cross-platform privacy scripts.

Command Aliases

When you run better-anonymity install (or "Install CLI Aliases"), the following shortcuts are added to your shell (~/.zshrc):

Alias Equivalent Command Description
torify export ALL_PROXY=... Enables Tor SOCKS5 proxy for current shell session
untorify unset ALL_PROXY Disables Tor proxy for current shell session
tor-run <cmd> env ALL_PROXY=... <cmd> Runs a single command through Tor (e.g., tor-run curl ifconfig.me)
stay-connected b-a captive monitor Monitoring tool for flaky Wi-Fi / Captive Portals
i2pify export http_proxy=... Enables I2P HTTP proxy for current shell session

Disclaimer

USE AT YOUR OWN RISK.

These scripts modify system settings, network configurations, and application preferences. While every effort has been made to ensure safety, applying these settings may break functionality (e.g., Handoff, AirDrop, certain iCloud features).

  • Always backup your data before running these scripts.
  • Review the scripts before execution to understand what changes will be applied.
  • It is recommended to test in a Virtual Machine first.

Features

  • OS Hardening: Disables telemetry, enables firewall, configures secure boot requirements.
  • Network Privacy: DNS configuration, Privoxy setup for local proxying, MAC Spoofing.
  • Browser Hardening: user.js for Firefox privacy.
  • Anonymity: Scripts to assist with Tor configuration and I2P installation.
  • UX: Automatic Sudo Keep-Alive to minimize password prompts during setup.

Installation

First, clone the repository:

git clone https://github.com/johnpatrickroach/better-anonymity.git
cd better-anonymity

Then choose your preferred installation method:

Option 1: Homebrew (Recommended)

Install using our custom tap:

brew tap johnpatrickroach/better-anonymity
brew install better-anonymity

Option 2: Pip (Python)

If you have Python 3 installed, you can install directly:

pip install .

Note: On newer macOS versions, you might encounter an "externally-managed-environment" error. If so, use pipx install . or pip install . --break-system-packages (if you are sure).

This will verify dependencies and install the better-anonymity (and b-a) commands to your Python bin path. Note: Ensure your Python bin directory is in your PATH.

Option 3: Manual Install

If you don't use Homebrew or Pip, manually install the global aliases:

./bin/better-anonymity install

This will create symlinks in /usr/local/bin, allowing you to run the tool from anywhere using any of the following aliases:

  • better-anonymity
  • better-anon
  • b-a

Configuration

By default, running better-anonymity harden will comprehensively execute every macOS privacy and security countermeasure built into the toolkit.

However, you can surgically customize exactly which actions execute by modifying the config/settings.json file natively included in the repository.

{
    "hardening": {
        "enable_firewall": true,
        "disable_analytics": false,
        "anonymize_hostname": true,
        "ensure_lockdown": false
    }
}

If you set any specific module to false, the hardening script will structurally bypass that component during execution without prompt. This is ideal for building tailored execution baselines that don't intrude on explicit network features you rely on.

Quick Start (Recommended)

  1. First Run Setup: Launch the interactive wizard to apply the security baseline.

    better-anonymity setup
    
  2. Check Your Score: Analyze your system's current privacy/anonymity status.

    better-anonymity diagnose
    
  3. Interactive Menu: Explore all features via the dashboard.

    better-anon
    

Usage

You can use the interactive menu or individual commands. CLI aliases better-anonymity, better-anon, and b-a are interchangeable.

Common Commands

  • Diagnosis:

    b-a diagnose
    b-a --version
    
  • Explaining Commands: Use the --explain flag with any command to see what it does without running it.

    b-a setup --explain
    b-a network-anon --explain
    
  • Hardening:

    b-a harden    # Apply macOS hardening
    b-a ssh       # SSH Hardening menu
    
  • Tools:

    b-a tor install
    b-a install signal
    b-a dns quad9
    b-a network-open  # Restore network defaults
    b-a network-anon  # Enable all anonymity services
    b-a captive monitor # Launch connectivity monitor
    

Updates

Keep your installation current:

b-a check-update    # Check if updates are available
b-a update          # Auto-upgrades via Brew, Pip, or Git natively
b-a test            # Run unit tests

Uninstallation & Restore

To remove the CLI aliases (b-a, better-anon) from your system:

better-anonymity uninstall

New: You will be prompted to:

  1. Restore System State: Revert Hostname, DNS, and Firewall to their original values (captured during setup).
  2. Uninstall Tools: Automatically remove tools installed by better-anonymity (e.g., Tor, Privoxy).
  3. Scrub Environment: Remove the ~/.better-anonymity cache and dynamically wipe the convenience alias blocks from your ~/.zshrc.

Note: Manual verification is recommended after uninstallation to ensure all desired changes are reverted.

Documentation

For detailed information on each module, please refer to the specific documentation:

Shell Completions

To enable zsh completions (tab-autocomplete), add the following to your .zshrc:

# Add better-anonymity completions to fpath
echo 'fpath=(/path/to/better-anonymity/completions $fpath)' >> ~/.zshrc
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

better_anonymity-1.0.0.tar.gz (181.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

better_anonymity-1.0.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file better_anonymity-1.0.0.tar.gz.

File metadata

  • Download URL: better_anonymity-1.0.0.tar.gz
  • Upload date:
  • Size: 181.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for better_anonymity-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c4c8c41bf2ce67f0c4b37f7c3b1f706ef1cbfab4636b9ed3db2eeeacbd503066
MD5 e1832c84fe607edfcdd142e046d41999
BLAKE2b-256 d02b03aa6bce361cea9c5003b4cb891cf9880a4659e8ec8c76a587a8c159ef0e

See more details on using hashes here.

File details

Details for the file better_anonymity-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for better_anonymity-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5a5b703c5da6b55a768d7b90c857de67a582fa6ac525eeb3fb62c812fc05d597
MD5 8ad0235c8e4aae5e834fb3ed03068b55
BLAKE2b-256 1ee7e9fbcc608b7b15fc5be596694cb91ef8b63abe856f1a4036ffb9474d6b7d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page