开发者

Obtaining IP addresses in Bittorrent

开发者 https://www.devze.com 2022-12-26 09:38 出处:网络
I am trying to get a list of IP addresses serving or downloading a file. What I did was to contact a tracker like openbittorrent.com to get the following (as part of the scrape file):

I am trying to get a list of IP addresses serving or downloading a file. What I did was to contact a tracker like openbittorrent.com to get the following (as part of the scrape file):

B%00%00%0C%5F%B1%B1l%CAGa%84S%CB%B0%9BG%84%3BE:0:1

Now, the long string in the beginning is the info hash. As a next step, I did this:

http://tracker.sometracker.com/announce?info_hash=B%00%00%0C%5F%B1%B1l%CAGa%84S%CB%B0%9BG%84%3BE

It gave me back the following. So far so good. The message contained this:

d8:complete开发者_开发技巧i0e10:downloadedi0e10:incompletei2e8:intervali1931e12:min intervali965e5:peers12:U���ٿ��ӣǣ^@^@e

Can someone tell me what should I be doing after this to get the IP addresses currently serving the file or downloading it?


That's not a torrent file, that's an announce response. They're both bencode (use bencode to decode them), but the announce response contains only peer information. That's not enough information to be able to download the contents of the torrent: to do that you will need the torrent file itself.

The peers member of the bencoded dictionary contains groups of 6 bytes which you can unpack with struct. First four bytes are the IP address, followed by two bytes for the port. This is a compact announce response, which is common (but IPv4 only, obviously). You may also see non-compact responses which give you a transparent dictionary.

Many trackers today won't talk to you with the non-specific scrape announce you're sending, or the initial announce request that doesn't include compact, port or event. You should probably read over the protocol a bit before going further.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号