Ping router.utorrent.com DHT node using netcat

I'm just trying to get a response from router.utorrent.com to potentially make the DHT service lower. For example, taking into account magnetic coupling with:

 xt=urn:btih:a78c852bcc0379e612e1bd794e1fd19061b84d11 

hash:

 a78c852bcc0379e612e1bd794e1fd19061b84d11 

Then in the terminal I entered this:

 nc -u router.utorrent.com 6881 d1:ad2:id20:a78c852bcc0379e612e1bd794e1fd19061b84d11e1:q4:ping1:t1:01:y1:qe 

based on this documentation, but I don't get any response. I even tried Wireshark to check if any package returned, and still nothing. Why is ฮผTorrent not talking to me?

+4
source share
2 answers

The hash must be binary. When encoding, the number + colon is the length prefix for the string. Sha1 in hex is 40 bytes long, since it should actually be 20 bytes, it should be the raw output of the hash function.

You basically need to convert the hexadecimal string to binary (40 hex โ†’ 20 binary) for it to work.

+3
source

As explained in another answer, bencoding is a binary format, not a text format. It seems you are trying to enter the message body in netcat using a terminal. Terminals are intended for entering text input into programs, not binary ones, and therefore you cannot directly enter this sequence into netcat stdin.

The identifier in your ping request should not be torrent-infohash. It must be a unique identifier to identify your customer on the DHT network. For testing, you can really just choose an identifier consisting of 20 ASCII characters and avoid these encoding problems, but in practice you will need uniform random binary identifiers.

If you want to use the binary identifier in the terminal, you should not try to enter it directly into netcat. Instead, you can use the shell echo command and hexadecimal encoding to get the data in the intended format and transfer it to netcat. For example, in bash:

echo -n $'d1:ad2:id20:\x23\x71\x0c\x1c\xb4\x50\x7d\x87\x29\xb8\x3f\x87\x2c\xc6\xa2\xa4\x4c\x39\x73\x67e1:q4:ping1:t1:01:y1:qe' | nc -u router.utorrent.com 6881

Please note that the answer you get from node will be unescaped binary, not necessarily text, so displaying it directly in your terminal as we do this may cause things to appear strange or your current the terminal session will be spoiled in some way.

+1
source

Source: https://habr.com/ru/post/1441982/


All Articles