TOR & THE DARK WEB
Onion routing · Hidden services · Bridges · OPSEC · Relay operation · Dark web intel · Attacks & limitations
How Tor Works
- Tor routes traffic through 3 relays (guard, middle, exit) with layered encryption - each relay only knows its immediate neighbours.
- Directory authorities (9 hardcoded servers) produce a consensus document that all Tor clients use to discover relays.
- Guard nodes are kept stable for months to reduce the window of traffic correlation attacks.
- Exit nodes see cleartext traffic to the destination - never trust exit nodes with sensitive unencrypted data.
- Tor protects network-layer identity but cannot protect against browser fingerprinting, JS exploits, or user behaviour mistakes.
Picture sending a parcel from Kisumu to a cousin in Mombasa by handing it down a line of three matatu conductors, with the parcel wrapped in three gunia sacks, one inside the next. The first conductor sees who gave it to him but not the final stop; the middle one simply passes it along; the last one knows the destination but never saw you. No single conductor knows both ends of the journey — that is exactly how Tor carries your traffic.
► Onion Routing - The Core Concept
Tor (The Onion Router) was originally developed by the US Naval Research Laboratory and is now maintained by the non-profit Tor Project. The fundamental idea is onion routing: your traffic is wrapped in multiple layers of encryption, like an onion, and each relay in a chain peels exactly one layer before forwarding to the next. No single relay knows both where you came from and where you are going.
When you connect through Tor, your client builds a 3-hop circuit: a guard node (entry), a middle relay, and an exit node. Your Tor client negotiates encryption keys separately with each of the three relays using Diffie-Hellman key exchange. The guard node knows your real IP but not your destination. The exit node knows your destination but not your real IP. The middle relay knows neither.
► The Three Hops
| Relay Position | Knows Your IP? | Knows Destination? | Role |
|---|---|---|---|
| Guard (Entry) | YES | NO | First hop - knows who you are, not where you go |
| Middle | NO | NO | Passes encrypted data - knows nothing useful alone |
| Exit | NO | YES | Last hop - connects to clearnet destination on your behalf |
► Encryption Layers
Your Tor client encrypts the payload three times - once for each relay - using the key agreed with each relay. The packet sent looks like: Encrypt(guard_key, Encrypt(middle_key, Encrypt(exit_key, actual_data))). The guard strips its layer and sees only an encrypted blob for the middle. The middle strips its layer. The exit strips the final layer and sees the original data in cleartext (if the destination is plain HTTP) or TLS-encrypted data (for HTTPS).
► Directory Authorities
How does your Tor client know which relays exist? There are 9 hardcoded directory authority servers distributed across multiple countries and organisations. Every few hours they vote on a consensus document listing all known relays, their bandwidth, uptime, flags (Fast, Stable, Guard, Exit), and public keys. Your Tor client downloads this consensus and uses it to select relays for circuits. The 9 DAs are intentionally controlled by different parties so no single entity can manipulate the relay list.
► Guard Node Selection and Persistence
Your Tor client selects a small set of guard nodes and keeps using them for months. This seems counter-intuitive - why not rotate guards? The reason is statistical: if you choose a new guard for every circuit, and an attacker controls even 5% of relays, over time they will eventually be your guard. By sticking to one guard, you either have a compromised guard or you do not - the outcome is decided once and stays fixed, limiting the attacker's opportunity.
► Tor Cells - Wire Format
Tor uses a fixed-size cell structure of 512 bytes. Fixed-size cells prevent traffic analysis based on packet size variation. Each cell has a circuit ID (identifying which circuit it belongs to), a command byte (RELAY, CREATE, CREATED, DESTROY, etc.), and a payload. Multiple application streams (HTTP requests, etc.) are multiplexed over a single circuit using stream IDs within RELAY cells.
+-----------+----------+-------------------------------------------+ | CircID | CMD | Payload (509 bytes) | | (4 bytes) | (1 byte) | StreamID + Digest + Len + Data | +-----------+----------+-------------------------------------------+ CMD values: 0x01 CREATE -- request to create new circuit 0x02 CREATED -- circuit created confirmation 0x03 RELAY -- relay cell (carries stream data) 0x04 DESTROY -- tear down circuit
► Latency vs Anonymity Tradeoff
Tor is slow compared to a VPN or direct connection. Each cell must be encrypted/decrypted three times and hop across three separate servers. Tor also deliberately avoids optimisations like persistent TCP connections that would make traffic correlation easier. This latency is the price of anonymity. High-latency mix networks (like remailers) provide stronger anonymity but are impractical for interactive use.
► Tor vs VPN - Fundamental Differences
| Property | VPN | Tor |
|---|---|---|
| Trust model | Trust the VPN provider entirely | No single point of trust |
| Who knows your IP | VPN server + all destinations | Only guard node |
| Who knows destination | VPN server | Only exit node |
| Speed | Near-native speed | Significantly slower (3 hops) |
| Anonymity | Pseudonymity only | Strong if used correctly |
| Hidden services | No equivalent | Yes (.onion addresses) |
| Exit compromise | N/A - VPN sees everything | Exit sees your cleartext (if HTTP) |
► What Tor Does NOT Protect Against
Exit nodes see cleartext if you use HTTP (not HTTPS). A malicious exit can modify traffic, inject content, or steal credentials. Even with HTTPS, an attacker who controls both your guard and your exit (end-to-end correlation) can correlate traffic timing to identify you. JavaScript in your browser can leak your real IP via WebRTC, reveal your timezone, canvas fingerprint, font list, screen resolution, and dozens of other identifying properties. Malware or exploits delivered over Tor bypass the anonymity entirely. Finally, your own behaviour - using the same username, writing style, or logging into personal accounts - can deanonymise you regardless of Tor.
- Tor routes traffic through 3 relays (guard, middle, exit) with layered encryption - each relay only knows its immediate neighbours.
- Directory authorities (9 hardcoded servers) produce a consensus document that all Tor clients use to discover relays.
- Guard nodes are kept stable for months to reduce the window of traffic correlation attacks.
- Exit nodes see cleartext traffic to the destination - never trust exit nodes with sensitive unencrypted data.
- Tor protects network-layer identity but cannot protect against browser fingerprinting, JS exploits, or user behaviour mistakes.