0

Problem

Accepting incoming connections over Tor through the Tor proxy. I'm developing a socks client in rust for tokio tcp streams. Like https://crates.io/crates/tokio-socks but with upgraded libraries and support for resolving onion addresses.

Tor proxy does not support the SOCKS BIND command. However, I know it's possible to accept incoming requests through the proxy because zeroMQ does it (on a high level by setting the SOCKS proxy, and "binding" to an onion address).

Figuring out the protocol

The SOCKS CONNECT and BIND protocols are implemented and work (using 3proxy to test). When it comes to tor (which doesn't have BIND), this is currently where I'm stuck:

  1. Authentication method selection [0x05, 0x01, 0x00] or [0x05, 0x02, 0x00, 0x02] ([version], [nmethods], [methods...])
  2. Receive the accepted auth method (so [0x05, 0x00] No auth)

Here's where I'm not sure. I need the socks protocol to notify me when someone connects to the hidden service. So far, I don't receive anything from the socks proxy when attempting to connect to the hidden service.

Tor proxy only supports CONNECT and the tor extensions RESOLVE and RESOLVE_PTR. I tried to CONNECT to the hidden service first (maybe to "register"?) but that, as expected, returns a SOCKS error (HostUnreachable). Perhaps the tor proxy will send an OK(0x00) response when someone connects to the hidden service. So far, that appears not to be happening.

What is the correct protocol for "listening" for connections on a hidden service through the SOCKS proxy?

0

So I'm obviously overthinking it ;) Your application must bind on the port forwarded by tor HiddenServicePort 8080 127.0.0.1:5671 and requests to the hidden service will end up there.

Bonus: It appears that A hidden service can be created on-the-fly by communicating with the tor control port using the ADD_ONION command.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.