【发布时间】:2013-12-14 08:06:10
【问题描述】:
试图理解/反向工程 torrent/tracker 对话。我已经设法让一些简单的代码运行起来,它会触发跟踪器并打印响应;
>>> import urllib2
>>> import urllib
>>> import binascii
>>> hash = "0221caf96aa3cb94f0f58d458e78b0fc344ad8bf"
>>> url = "http://torrent.ubuntu.com:6969/scrape?info_hash="
>>> url += urllib.quote(binascii.a2b_hex(hash))
>>> f=urllib2.urlopen(url).read()
>>> print f
d5:filesd20:☻!╩∙jú╦ö≡⌡ìEÄx░ⁿ4J╪┐d8:completei4e10:downloadedi0e10:incompletei1e4:name20:dapper-dvd-amd64.isoeee
根据BitTorrent Tracker Protocol,我扩展了代码以尝试获取同行列表;参数是从 wireshark 嗅探中逐字提取的(更多内容见下文)。
>>> hash = "0221caf96aa3cb94f0f58d458e78b0fc344ad8bf"
>>> url = "http://torrent.ubuntu.com:6969/announce?info_hash="
>>> url += urllib.quote(binascii.a2b_hex(hash))
>>> url +="&peer_id=-UT3320-_vO%21lS%a7%07%876%18%99&port=53965&uploaded=0&downloaded=18874368&left=2850752512&corrupt=0&key=F0E51CD9&event=stopped&numwant=0&compact=1&no_peer_id=1"
>>> f=urllib2.urlopen(url).read()
>>> print f
d8:completei4e10:incompletei2e8:intervali1800e5:peerslee
使用wireshark,我嗅探了一个“已知的工作”源(相同的torrent / info_hash 信息,但使用了utorrent),然后嗅探了我愚蠢的小程序;在这两种情况下,跟踪器都会以 3 个数据包([ACK]、[PSH、ACK] 和 [FIN ACK] 的形式)的一组类似数据进行响应;但是使用我的 python 程序,我没有看到任何过去第一个 [ACK]。
对网络或数据包操作不是特别流利,所以我很感激任何指点!
【问题讨论】:
-
如果 regular 通告请求之间的间隔小于第一个跟踪器通告查询响应的 interval 字段的值,某些 HTTP 跟踪器可能不会响应。
-
自从应用已回答的“修复”后,我还没有遇到过这个问题,但下次我撞到墙上时会记住这一点。感谢您的信息!
标签: python bittorrent