Skip to main content

A tool for exploring the Tor network

Project description

Overview

torscope is a tool for exploring the Tor network.

It implements the Tor directory protocol and OR (Onion Router) protocol, allowing you to explore relay information, create circuits, and study the Tor specification in practice.

Features

Implemented

Directory Protocol

  • List all Tor directory authorities and fallback directories
  • Fetch and parse network consensus documents (v3)
  • View detailed relay information and server descriptors
  • Fetch extra-info descriptors (bandwidth history, statistics)
  • Filter relays by flags (Guard, Exit, Fast, Stable, etc.)
  • Microdescriptor fetching and parsing
  • Exit policy matching and port filtering
  • Consensus signature verification
  • Consensus caching to disk (.torscope/ directory)
  • Directory fetching over circuits (BEGIN_DIR)

OR Protocol - Link Layer

  • TLS connections to Tor relays (TLS 1.2+)
  • Link protocol handshake (VERSIONS, CERTS, AUTH_CHALLENGE, NETINFO)
  • Link protocol versions 4 and 5
  • VPADDING cells (variable-length link padding)

OR Protocol - Circuit Layer

  • Circuit creation with CREATE2/CREATED2 (ntor handshake)
  • One-hop circuits with CREATE_FAST/CREATED_FAST
  • Circuit extension with RELAY_EXTEND2/EXTENDED2 via RELAY_EARLY
  • Multi-hop circuits (1-3 hops)
  • Layered encryption/decryption (AES-128-CTR)
  • Circuit teardown (DESTROY) with reason codes
  • Circuit padding negotiation (PADDING_NEGOTIATE/PADDING_NEGOTIATED)
  • DROP cells (long-range dummy traffic)

OR Protocol - Handshakes

  • ntor handshake (Curve25519 + HMAC-SHA256)
  • ntor-v3 handshake (Curve25519 + SHA3-256 + SHAKE-256)
  • hs-ntor handshake for hidden services

OR Protocol - Streams

  • Stream creation (RELAY_BEGIN/CONNECTED)
  • BEGIN flags for IPv6 preferences (ipv6-ok, ipv4-not-ok, ipv6-preferred)
  • Data transfer (RELAY_DATA)
  • Stream termination (RELAY_END) with reason codes
  • DNS resolution (RELAY_RESOLVE/RESOLVED)
  • Directory streams (RELAY_BEGIN_DIR)
  • Flow control (SENDME cells) with authenticated SENDME v1

Path Selection

  • Bandwidth-weighted random selection
  • Guard/middle/exit role assignment
  • Family and subnet exclusion
  • Port-based exit filtering

Bridge Relays

  • Bridge line parsing (direct and pluggable transport formats)
  • Direct bridge connections (no obfuscation)
  • WebTunnel pluggable transport (HTTPS/WebSocket tunneling)
  • obfs4 pluggable transport (traffic obfuscation with Elligator2)
  • Circuit building through bridges with CREATE_FAST

Hidden Services (v3)

  • Onion address parsing and validation
  • Blinded key derivation (SHAKE-256)
  • HSDir hashring selection
  • Descriptor fetching from HSDir
  • Outer descriptor parsing and signature verification
  • Inner descriptor decryption (introduction point extraction)
  • Client authorization for private services (x25519 auth keys)
  • Full rendezvous protocol (ESTABLISH_RENDEZVOUS, INTRODUCE1, RENDEZVOUS2)
  • hs-ntor handshake (Curve25519 + SHA3-256 + SHAKE-256)
  • Proof-of-Work for hidden service DoS protection (Proposal 327, Equi-X)

Cryptography

  • Curve25519 key exchange
  • AES-128-CTR and AES-256-CTR encryption
  • SHA-1, SHA-256, SHA3-256 hashing
  • SHAKE-256 key derivation
  • RSA and Ed25519 signature verification

Not Implemented

Other

  • REST API

Won't Implement

  • Running as a Tor relay
  • Control protocol (stem-like interface)
  • Connection pooling/reuse
  • Onion service publication (server-side)
  • Pluggable transports: meek, Snowflake (require external dependencies like WebRTC/CDN)
  • XOFF/XON congestion control (sender-side mechanism, not needed for receiving)
  • RTT-based congestion control (Proposal 324, sender-side performance optimization)
  • Conflux (multi-path circuits, performance optimization)
  • AUTHENTICATE cell (relay-to-relay authentication, not needed for clients)
  • TAP handshake (obsolete RSA-based CREATE/CREATED)
  • Legacy EXTEND/EXTENDED (obsolete, using EXTEND2)
  • AUTHORIZE cell (reserved, not needed for clients)
  • TRUNCATE/TRUNCATED cells (circuit truncation, not useful for short-lived connections)

Installation

pip install torscope

Usage

# List directory authorities
torscope authorities

# List routers with specific flags
torscope routers --flags Guard,Exit

# Show router details
torscope router moria1

# Build a 3-hop circuit
torscope circuit

# Resolve hostname through Tor
torscope resolve example.com

# Connect to a website through Tor
torscope open-stream example.com:80 --http-get

# Connect with IPv6 preferences
torscope open-stream example.com:80 --http-get --ipv6-ok --ipv6-preferred

# Access a hidden service
torscope hidden-service duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion

# Connect to a hidden service
torscope open-stream duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion:80 --http-get

# Access a private hidden service with client authorization
torscope hidden-service private.onion --auth-key-file ~/.tor/onion_auth/private.auth_private
torscope open-stream private.onion:80 --auth-key-file ~/.tor/onion_auth/private.auth_private

# Build circuit through a direct bridge (no transport)
torscope circuit --bridge "192.0.2.1:443 4352E58420E68F5E40BF7C74FADDCCD9D1349413"

# Build circuit through a WebTunnel bridge
torscope circuit --bridge "webtunnel 192.0.2.1:443 FINGERPRINT url=https://example.com/secret-path"

# Build circuit through an obfs4 bridge
torscope circuit --bridge "obfs4 192.0.2.1:443 FINGERPRINT cert=ABC...xyz iat-mode=0"

# Open stream through a bridge
torscope open-stream example.com:80 --bridge "192.0.2.1:443 FINGERPRINT" --http-get

# Open stream through an obfs4 bridge
torscope open-stream example.com:80 --bridge "obfs4 192.0.2.1:443 FINGERPRINT cert=... iat-mode=0" --http-get

Verbosity Flags

-e, --explain   # Brief explanations of what's happening
-v              # Protocol-level information
-vv             # Raw debug information (implies -v)

Example Onion Addresses

  • duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion
  • 2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid.onion
  • torscope75efu4gls3m24xezterv7nhj36ibnjlrocqeslclwbxgs7yd.onion

License

torscope Tor Network Exploration Tool

Copyright (C) 2025-2026 Mete Balci

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

References

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

torscope-0.7.0.tar.gz (183.7 kB view details)

Uploaded Source

Built Distribution

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

torscope-0.7.0-py3-none-any.whl (168.9 kB view details)

Uploaded Python 3

File details

Details for the file torscope-0.7.0.tar.gz.

File metadata

  • Download URL: torscope-0.7.0.tar.gz
  • Upload date:
  • Size: 183.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for torscope-0.7.0.tar.gz
Algorithm Hash digest
SHA256 f42251a148fde61430efe9b02a062be6b234cbea1361204abddab51dc908d0e0
MD5 cdeea49465833da53ebec31a392d1926
BLAKE2b-256 75a8f0178e30db67a2f6ef2c2b4d153e7fb99e72cb39dbd7a93597ff55af99d9

See more details on using hashes here.

File details

Details for the file torscope-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: torscope-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 168.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for torscope-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a272a781a3a058af05f019dc97654aa39dc3a04806fafd67fb4e428ad960aa46
MD5 197ce5b16d5f2b09d46f0210c56528f5
BLAKE2b-256 42d5132b7ddabd1330c2a8d567ca4934ff960014fd4925a2b425e55c64941a27

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