Im trying to implement a simple c# application that is based on tor protocol, without identity changes every few minutes etc. just to create a circuit and make a request. I created the onion hidden service, and i want to try make a http request to it and receive an answer first. I have read all the specs, and i looked up the tor source code, but its really hard, because it is using very low-level C. So far what i understood from the technical point of view is this, if i want to fetch the main page of my onion hidden service i have to:
1) Choose a random directory server that is serving onion routers microdescriptors ( there are 10 hardcoded, but 1 is serving only the bridges )
2) Connect to dir server, fetch a consesus document
/tor/status-vote/current/consensus/ using HTTP protocol, close the
3) Parse the list of onion routers, construct the curicuit from 3 nodes.
4) Parse the entry node with the attributes
Fast Guard HSDir Running Stable Valid
5) Parse the exit node with the attributes
Fast Exit HSDir Running Stable Valid
6) Parse the random middle node? Is it just a OR in the list without
Guardattributes? Or any OR with attributes
Guardcan also be used as a middle node?
- 7) Create a tcp socket and connecto to the parsed entry node with
the given ip port. Then Create a cell packet with the command
CREATEwith the payload of Diffie-Hellman handshake. Receive a command
CREATEDwit the encryption key.
- 8) Form a relay cell packet with command
RELAY_EXTENDcontaining the ip port of the middle node, and encrypted half handshake for the middle relay, with the key we parsed from previous action, send it to the connected entry node, receive an answer as
RELAY_EXTENDEDpacket, parse new encryption key from it. And use it later to encrypt last diffie hellman handhskae payload.
- 9) Do the previous action, send
RELAY_EXTEND, to the guard node, but with the address of the exit node, and encrypted diffie helman handhskae with the key we received from middle node.
- 10) I guess that is it? The curcuit is ready? Now i can use a relay
cell packets,sending them to my guard node socket connection, encrypted with the key i received from exit node with
RELAY_BEGINto connect to hosts,
RELAY_DATAto send data to them?