GHOSTNET›MOD-01 // TOR & DARKNET
MOD-02: OSINT & SURVEILLANCE →
MODULE 01 · TOR & DARKNET

TOR & THE DARK WEB

Onion routing · Hidden services · Bridges · OPSEC · Relay operation · Dark web intel · Attacks & limitations

8
CHAPTERS
~2.5hr
TOTAL READ
BEGINNER
DIFFICULTY
MOD-01
IDENTIFIER
BEGINNER~12 min READCHAPTER 1 OF 8

How Tor Works

KEY POINTS · THE QUICK VERSION
  • 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.
Scan these first, then read below for the depth and examples — or jump straight to the lab.
◈ PICTURE IT — MTAANI EDITION

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 PositionKnows Your IP?Knows Destination?Role
Guard (Entry)YESNOFirst hop - knows who you are, not where you go
MiddleNONOPasses encrypted data - knows nothing useful alone
ExitNOYESLast 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).

👁 WATCH THIS · you don't need to run it yet — just read along
CONCEPTUAL ENCRYPTION LAYERS
Client builds:  [ Guard_Layer [ Middle_Layer [ Exit_Layer [ YOUR DATA ] ] ] ]

Guard  receives: [ Guard_Layer [ ... opaque ... ] ]
Guard  decrypts: [ Middle_Layer [ Exit_Layer [ YOUR DATA ] ] ]  -- forwards to Middle

Middle receives: [ Middle_Layer [ ... opaque ... ] ]
Middle decrypts: [ Exit_Layer [ YOUR DATA ] ]                   -- forwards to Exit

Exit   receives: [ Exit_Layer [ YOUR DATA ] ]
Exit   decrypts: [ YOUR DATA ]                                  -- sends to destination
What you're seeing: Read it top to bottom. Your Tor client wraps your data in three layers, like three envelopes sealed one inside another. Each relay opens only its own envelope and finds another sealed one to pass on — so no relay ever sees who you are and what you sent at the same time.
↪ You'll watch a real circuit build these layers hop by hop in the ↪ MOD-01 lab.

► 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.

TOR CELL STRUCTURE (512 bytes)
+-----------+----------+-------------------------------------------+
| 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

PropertyVPNTor
Trust modelTrust the VPN provider entirelyNo single point of trust
Who knows your IPVPN server + all destinationsOnly guard node
Who knows destinationVPN serverOnly exit node
SpeedNear-native speedSignificantly slower (3 hops)
AnonymityPseudonymity onlyStrong if used correctly
Hidden servicesNo equivalentYes (.onion addresses)
Exit compromiseN/A - VPN sees everythingExit sees your cleartext (if HTTP)

► What Tor Does NOT Protect Against

CRITICAL
Tor anonymises your network connection - it does not make you magically anonymous. Many deanonymisation vectors exist at the application layer.

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.

RECAP · CHECK YOURSELF
  • 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.
Read to the end to count this chapter
▸ READY TO PRACTISE
You've now covered enough for Lab steps 1–2 of 17. Try them in the lab while it's fresh.
OPEN LAB ▸
⚡ TEST YOURSELF
End-of-chapter quiz
A dozen questions — recall and practical. Graded, earns up to 20 XP.
PRACTISE IN THE LAB ▸
READY TO PRACTICE?
MOD-01 Interactive Lab
17 steps · 345 XP · Real commands · Flag captures
LAUNCH LAB →
MOD-02: OSINT →