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. -_-