1

I want to check, if an onion address (in my case an ID from torchat) is online. How can I achieve this, since simple pings are not working.

I try to get a status response with the following python code:

import requests

url = 'http://rrcc5uuudhh4oz3c.onion'

resp = requests.get(url, 
                proxies=dict(http='socks5h://127.0.0.1:9050',
                             https='socks5h://127.0.0.1:9050'))

print(resp)

The output is: <Response [200]>, which is exactly what I want.

However, when I try to connect to a Torchat-ID, to see, whether it is reachable, I get: Failed to establish a new connection: 0x05: Connection refused.

Is there another way to get a status-code response from a Torchat-ID to see, if it is still alive?

About Torchat-ID: https://www.deepdotweb.com/jolly-rogers-security-guide-for-beginners/tor-chat/

Below you can see the Torchat. Users can be active resp. inactive. If they are active, one should be able to get a status response. Torchat-IDs are plain .onion addresses.

Quote (link):

the first time you open TorChat your computer might generate 
d0dj309jfj94jfgf.onion and from here on out, d0dj309jfj94jfgf will be 
your TorChat ID that you give out to people that you want to be able 
to message you

enter image description here

BeldCode
  • 67
  • 1
  • 7
  • Maybe related: https://stackoverflow.com/questions/12601316/how-to-make-python-requests-work-via-socks-proxy – Havenard Aug 14 '18 at 01:39

2 Answers2

1

If you get the ProxySchemeUnknown exception when attempting to use socks or socks5h with python-requests, it is either because the version is too old, or you need to also install the requests[socks] package.

To install the necessary socks proxy support for requests, run:

pip3 install -U requests[socks]
# or for Python 2
pip install -U requests[socks]

Also, because you will be using requests' SOCKS support, you should not "monkey patch" the default socket with a SOCKS socket. This isn't necessary and might interfere with other socket interactions that shouldn't use Tor. To fix this, simply delete the following two lines:

socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 9150)
socket.socket = socks.socksocket

That isn't necessary when using requests' proxies option.

drew010
  • 64,915
  • 11
  • 121
  • 148
1

You could trying using httping for a super simple way to check if a site is up that doesn't respond to a normal ping request.

For example, install on linux like this: sudo apt install httping or on OSX brew install httping.

Then, to check a particular url, run: httping -g rrcc5uuudhh4oz3c.onion -x 127.0.0.1:9050 which would check to see if Intel Exchange (a popular dark web destination) is available and active. This assumes you have Tor running and the SOCKS proxy is the default 9050 on localhost.

In my case, the result was:

PING rrcc5uuudhh4oz3c.onion:80 (/):
connected to rrcc5uuudhh4oz3c.onion:80 (89 bytes), seq=0 time=  0.56 ms
connected to rrcc5uuudhh4oz3c.onion:80 (89 bytes), seq=1 time=  0.89 ms
connected to rrcc5uuudhh4oz3c.onion:80 (89 bytes), seq=2 time=  0.71 ms
connected to rrcc5uuudhh4oz3c.onion:80 (89 bytes), seq=3 time=  0.85 ms
connected to rrcc5uuudhh4oz3c.onion:80 (89 bytes), seq=4 time=  0.73 ms
connected to rrcc5uuudhh4oz3c.onion:80 (89 bytes), seq=5 time=  1.06 ms
connected to rrcc5uuudhh4oz3c.onion:80 (89 bytes), seq=6 time=  1.04 ms

Hope that helps. You can use the call command or subprocess command in python and invoke this same call programmatically.

jamescampbell
  • 9,349
  • 4
  • 30
  • 41
  • 1
    Also, just a side note beyond scope slightly, to test a curl of the site, you need to pass in the special `--socks5-hostname` flag, like so: `curl --socks5-hostname 127.0.0.1:9050 rrcc5uuudhh4oz3c.onion` – jamescampbell Aug 14 '18 at 01:42
  • Thank you for your replies! When I try: `$ curl -I --socks5-hostname 127.0.0.1:9050 rrcc5uuudhh4oz3c.onion` it works perfectly. I get exactly what I want (a status response for an onion address). So far so good. However, as soon as I want to ping an onion address from Torchat, I get the follwing error: `curl: (7) Can't complete SOCKS5 connection to 0.0.0.0:0. (5) `. As I understand it, Torchat-IDs are onion addresses. I cannot find a solution... The following article describes Torchat and Torchat-IDs: https://www.deepdotweb.com/jolly-rogers-security-guide-for-beginners/tor-chat/ – BeldCode Aug 17 '18 at 06:38
  • When I use `httping -g
    .onion -x 127.0.0.1:9050`, I ALWAYS get successful pings, no matter, what .onion addresses I use. For example `$ httping -g rrccffdrgdshsst5uuudhh4oz3c.onion -x 127.0.0.1:9050` does work as well. Although it is not a correct .onion address at all...
    – BeldCode Aug 20 '18 at 07:26