Esempio n. 1
0
 def _prepare_address(self, address):
     if isinstance(address[0], HiddenService):
         return address[0], (address[0].onion, address[1])
     elif address[0].endswith('.onion'):
         descriptor_cookie, auth_type = self._auth_data.get(address[0], (None, AuthType.No))
         return HiddenService(address[0], descriptor_cookie, auth_type), address
     else:
         return None, address
Esempio n. 2
0
 def _prepare_address(self, address):
     if isinstance(address[0], HiddenService):
         return address[0], (address[0].onion, address[1])
     elif address[0].endswith('.onion'):
         host_key = hostname_key(address[0])
         descriptor_cookie, auth_type = self._auth_data.get(host_key, HiddenService.HS_NO_AUTH)
         return HiddenService(address[0], descriptor_cookie, auth_type), address
     else:
         return None, address
Esempio n. 3
0
def test_stealth_auth():
    """Connecting to Hidden Service with 'Stealth' authorization."""
    if not HS_STEALTH_HOST or not HS_STEALTH_AUTH:
        logger.warning('Skip test_stealth_auth()')
        return

    hs = HiddenService(HS_STEALTH_HOST, HS_STEALTH_AUTH, AuthType.Stealth)
    tor = TorClient()
    # Choose random guard node and create 3-hops circuit
    with tor.create_circuit(3) as circuit:
        # Create tor stream to host
        with circuit.create_stream((hs, 80)) as stream:
            # Send some data to it
            stream.send(b'GET / HTTP/1.0\r\nHost: %s\r\n\r\n' % hs.hostname.encode())
            recv = recv_all(stream).decode()
            logger.warning('recv: %s', recv)