Skip to main content

Test and monitors the status of Tor Onion Services

Project description

Onionprobe

Onionprobe is a tool for testing and monitoring the status of Tor Onion Services sites.

It can run a single time or continuously to probe a set of onion services endpoints and paths, optionally exporting to Prometheus.

Requirements

Onionprobe requires the following software:

On Debian, they can be installed using

sudo apt install python3 python3-prometheus-client \
                 python3-stem python3-cryptography \
                 python3-yaml python3-requests     \
                 python3-socks tor

Installation

Onionprobe is available on PyPI:

pip install onionprobe

It's also possible to run it directly from the Git repository:

git clone https://gitlab.torproject.org/tpo/onion-services/onionprobe
cd onionprobe

Usage

Simply ask Onionprobe to try an Onion Service site:

onionprobe -e http://2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion

It's possible to supply multiple addresses:

onionprobe -e <onion-address1> <onionaddress2> ...

Onionprobe also accepts a configuration file with a list of .onion endpoints and options. A detailed sample config is provided and can be invoked with:

onionprobe -c configs/tor.yaml

By default, Onionprobe starts it's own Tor daemon instance, so the tor binary must be available in the system.

See the manual page for the complete list of options and available metrics.

Standalone monitoring node

Onionprobe comes with full monitoring environment based on Docker Compose with:

  • An Onionprobe instance continuously monitoring endpoints.
  • Metrics are exported to a Prometheus instance.
  • Alerts are managed using Alertmanager.
  • A Grafana Dashboard is available for browsing the metrics and using a PostgreSQL service container as the database backend.

Configuring the monitoring node

By default, the monitoring node periodically compiles the Onionprobe configuration from the official Tor Project Onion Services into contrib/tpo.yaml, by using the tpo.py script.

This and other configurations can be changed by creating an .env file in the toplevel project folder.

Check the sample .env for an example.

Starting the monitoring node

The monitoring node may be started using docker-compose:

docker-compose up -d   # Remove "-d" to not fork into the background
docker-compose logs -f # View container logs

The monitoring node sets up storage volumes, which means that the monitoring dataset collected is persistent across service container reboots.

Accessing the monitoring dashboards and the exporter

Once the dashboards are started, point your browser to the following addresses if you're running locally:

These services are also automatically exported as Onion Services, which addresses can be discovered by running the following commands when the services are running:

docker exec -ti onionprobe_tor_1 cat /var/lib/tor/prometheus/hostname
docker exec -ti onionprobe_tor_1 cat /var/lib/tor/alertmanager/hostname
docker exec -ti onionprobe_tor_1 cat /var/lib/tor/grafana/hostname
docker exec -ti onionprobe_tor_1 cat /var/lib/tor/onionprobe/hostname

You can also get this info from the host by browsing directly the onionprobe_tor volume.

It's also possible to replace the automatically generated Onion Service addresses by using keys with vanity addresses using a tool like Onionmine.

Protecting the monitoring dashboards and the exporter

By default, all dashboards and the are accessible without credentials.

You can protect them by setting up Client Authorization:

  1. Enter in the tor service container: docker exec -ti onionprobe_tor_1 /bin/bash.

  2. Setup your client credentials according to the docs. The tor service container already comes with all programs to generate it. Onionprobe ships with a handy generate-auth-keys-for-all-onion-services available at the tor service container and which can be invoked with docker exec -ti onionprobe_tor_1 /usr/local/bin/generate-auth-keys-for-all-onion-services (it also accepts an optional auth name parameter allowing multiple credentials to be deployed).

  3. Place the .auth files at the Onion Services authorized_clients folder if you did not created them with the generate-auth-keys-for-all-onion-services script:

    • Prometheus: /var/lib/tor/prometheus/authorized_clients.
    • Alertmanager: /var/lib/tor/alertmanager/authorized_clients.
    • Grafana: /var/lib/tor/grafana/authorized_clients.
    • Onionprobe: /var/lib/tor/onionprobe/authorized_clients.
  4. Restart the tor service container from the host to ensure that this new configuration is applied:

     docker compose stop tor
     docker compose up -d
    

Note that the Grafana dashboard also comes with it's own user management system, whose default user and password is admin. You might change this default user and not setup the Client Authorization for Grafana, or maybe use both depending or your security needs.

Managing the monitoring node with systemd

The monitoring node can be managed with systemd. A sample service file is provided and can be adapted..

Using the monitoring node

Once your monitoring node is up and running, you can create your dashboards an visualizations as usual, getting the data compiled by Onionprobe using Prometheus as the data source.

Grafana already comes with a basic default dashboard as it's homepage:

Compiled configurations

Besides the sample config containing sites listed at https://onion.torproject.org, Onionprobe comes also with other example configs:

  1. Official Tor Project Onion Service Sites, generated by the tpo.py script.
  2. Real-World Onion Sites .onions at real-world-onion-sites.yaml, generated by the real-world-onion-sites.py script.
  3. The SecureDrop API .onions at securedrop.yaml, generated by the securedrop.py script.

You can build your own configuration compiler by using the OnionprobeConfigCompiler class.

Folder structure and files

Relevant folders and files in this repository:

  • assets: logos and other stuff.
  • configs: miscelaneous configurations.
  • contrib: folder reserved for storing contributed code and configuration.
  • containers: container configurations.
  • debian: debian packaging.
  • docs: documentation.
  • packages: python packages codebase.
  • scripts: provisioning and other configuration scripts.
  • tests: test procedures.
  • vendors: other third-party libraries and helpers.
  • kvmxfile: please ignore this if you're not a KVMX user.
  • docker-compose.yml: service container configuration.

Tasks

Check the issue tracker.

Acknowledgements

Thanks to:

  • @irl for the idea/specs/tasks.
  • @hiro for suggestions.
  • @arma and @juga for references.
  • @anarcat and @georg for Python and Debian packaging guidance and review.

Alternatives

Known issues

From Stem:

References

Related software and libraries with useful routines:

Relevant issues:

Research questions:

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

onionprobe-1.0.0.tar.gz (123.1 kB view hashes)

Uploaded Source

Built Distribution

onionprobe-1.0.0-py3-none-any.whl (61.9 kB view hashes)

Uploaded Python 3

Supported by

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