1

I got a torrent file. Its info_hash value is 87bebe2a6dfa25c8d8075893c4c6e05878cccb4a.

I need to get peers from UDP trackers, but in UDP Tracker Protocol, the size of info_hash should be 20. So how to transform it?

I used bitcomet to download and wireshark to Capture message.

Here is the thing I got:

0000   80 f6 2e cd a7 81 8c ec 4b 6d 8f 0f 08 00 45 00   .ö.ͧ..ìKm....E.
0010   00 7e 41 a9 00 00 80 11 00 00 c0 a8 29 49 6d 4a   .~A©......À¨)ImJ
0020   46 bc 41 cd 4c 3e 00 6a 9e 73 64 31 3a 61 64 32   F¼AÍL>.j.sd1:ad2
0030   3a 69 64 32 30 3a f7 66 44 1b 73 41 09 0d 1b 10   :id20:÷fD.sA....
0040   84 1d a6 7f 47 e8 4c b7 63 86 36 3a 74 61 72 67   ..¦.GèL·c.6:targ
0050   65 74 32 30 3a 08 99 bb e4 8c be f6 f2 e4 ef 7b   et20:..»ä.¾öòäï{
0060   e2 59 80 b8 17 b3 48 9c 78 65 31 3a 71 39 3a 66   âY.¸.³H.xe1:q9:f
0070   69 6e 64 5f 6e 6f 64 65 31 3a 74 38 3a 0f ea 8a   ind_node1:t8:.ê.
0080   c2 86 ff 4c 37 31 3a 79 31 3a 71 65               Â.ÿL71:y1:qe

According to UDP Tracker Protocol, the info_hash I capture is 7341090d1b1084 1da67f47e84cb76386363a7461. it is totally different from the actual value which is 87bebe2a6dfa25c8d8075893c4c6e05878cccb4a. Am I wrong? I am sure that the message's destination is a UDP tracker because it's length is 98.

I tried to transform using Java. Here is the code:

public static String IHToString(String v) throws Exception{
    byte[] b=new byte[20];
    for(int i=0;i<b.length;i++) {
        String n=v.substring(i*2, i*2+2);
        int j=(byte)Integer.parseInt(n, 16) & 0xff;
        b[i]=(byte)j;
    }

    return new String(b,"ASCII");
}
String s1=IHToString("87bebe2a6dfa25c8d8075893c4c6e05878cccb4a");
byte[] b1=s1.getByte("ASCII");

Obviously wrong.

The result is neither 7341090d1b1084 1da67f47e84cb76386363a7461 nor 87bebe2a6dfa25c8d8075893c4c6e05878cccb4a. I am really tired about this. Please help me. -_-

Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84
  • The BT info hash appears to be for a copyrighted movie... – Alnitak Feb 12 '19 at 11:17
  • The Wireshark capture is a DHT message. – Encombe Feb 12 '19 at 16:16
  • Possible duplicate of [How to UrlEncode a Sha1 string for a torrent tracker](https://stackoverflow.com/questions/40021493/how-to-urlencode-a-sha1-string-for-a-torrent-tracker) – the8472 Feb 15 '19 at 00:14
  • I've captured some udp messsges of which the len is 101.these messages contain the right info_hash.but it should be a DHT message not for UDP tracker.really tired – wukang feng Feb 15 '19 at 07:23

1 Answers1

2

The info_hash of your file (87bebe...) already has 20 bytes. One byte can be represented by two hexadecimal digits. SHA-1 hashes have a length of 160 bit (20 byte).

This hash is different from the info_hash you get from the UDP Tracker Protocol, because it is computed differently. Hashes can't be reversed.

For more details, see: http://www.bittorrent.org/beps/bep_0003.html and What exactly is the info_Hash in a torrent file

vollkorntomate
  • 638
  • 1
  • 8
  • 17
  • you mean the hash i get through the UDP Tracker Protocol is different from the hash i should send to an UDP tracker?if so how to transform bytes(87bebe...) to bytes(734109...) or how to compute the hash(734109...) by my file? – wukang feng Feb 15 '19 at 07:42