.TORRENT BitTorrent Metainfo
.torrent

BitTorrent Metainfo

A .torrent file is a bencoded metadata file containing tracker URLs, file listings, and SHA-1 piece hashes used by BitTorrent clients to coordinate peer-to-peer downloads.

بنية الصيغة
Header schema
Records structured data
x-bittorrent2001مفتوح
بواسطة FileDex
غير قابل للتحويل

BitTorrent metadata file. Not a data format that can be converted.

أسئلة شائعة

How do I inspect the contents of a .torrent file without downloading anything?

Use a tool like `transmission-show` on Linux or open the file in a BitTorrent client like qBittorrent, which displays metadata (file list, piece size, tracker URL) before starting any download. Since .torrent files are bencoded text, you can also decode them with Python's bencodepy library to read the raw structure.

What is an info_hash and why does it matter?

The info_hash is a SHA-1 digest of the bencoded info dictionary inside the .torrent file. It uniquely identifies a torrent across the entire BitTorrent network. Clients send this hash to trackers and DHT nodes to find other peers sharing the same content. Changing any byte in the info dict produces a different hash, effectively creating a different torrent.

What is the difference between a .torrent file and a magnet link?

A .torrent file contains the full metadata including piece hashes and file structure. A magnet link contains only the info_hash and optionally tracker URLs, requiring the client to download the metadata from peers before it can begin the actual transfer. Magnet links are more convenient to share but depend on DHT or trackers to bootstrap.

Can a .torrent file become outdated?

The file metadata (names, sizes, piece hashes) never changes, but tracker URLs can go offline. If all trackers listed in the announce and announce-list fields are unreachable and no peers are available via DHT, the client cannot find the swarm. The content itself may also become unavailable if no seeders remain.

ما يميز .TORRENT

BitTorrent metainfo files act as instruction sets that tell a client where to find peers and how to verify downloaded data. Torrent files use bencoding, a simple serialization format invented by Bram Cohen that represents data as dictionaries (d...e), lists (l...e), integers (i...e), and byte strings (length:data) -- the entire .torrent file is a single bencoded dictionary containing tracker URLs and SHA-1 piece hashes.

اكتشف التفاصيل التقنية

Bencoded Structure

The top-level dictionary always contains an info key whose value is another dictionary describing the shared content. For single-file torrents, the info dict holds name, piece length, length, and pieces (a concatenation of 20-byte SHA-1 hashes, one per piece). Multi-file torrents replace length with a files list, where each entry specifies a path array and length. The file has no fixed magic bytes; it simply starts with the ASCII character d (0x64), the bencoding marker for dictionary.

Tracker Communication and info_hash

The announce key holds the primary tracker URL. An optional announce-list provides fallback trackers in tiered priority. Clients compute the info_hash by taking the SHA-1 digest of the raw bencoded info dictionary. This 20-byte hash uniquely identifies the torrent across the entire BitTorrent network and is sent to trackers during announce requests to find peers sharing the same content.

Magnet Links and Trackerless Operation

Magnet links encode the info_hash as a URN, eliminating the need for a .torrent file entirely. The client uses Distributed Hash Table (DHT) lookups to discover peers from the info_hash alone. Peer Exchange (PEX) supplements DHT by allowing connected peers to share addresses of other known peers. Together, DHT and PEX enable fully trackerless swarm formation.

Piece Verification

After downloading each piece, the client computes its SHA-1 hash and compares it against the corresponding 20-byte entry in the pieces field. Any mismatch triggers a re-download of that piece from a different peer. This per-piece integrity check means corrupted or tampered data is caught immediately, long before the full download completes. Typical piece sizes range from 256 KiB to 4 MiB, chosen by the torrent creator to balance verification overhead against metadata size.

المرجع التقني

نوع MIME
application/x-bittorrent
Magic Bytes
64 38 3A Starts with bencoded dictionary (d8: for 8-char announce key).
المطوّر
Bram Cohen
سنة التقديم
2001
معيار مفتوح
نعم — عرض المواصفات
0000000064383A d8:

Starts with bencoded dictionary (d8: for 8-char announce key).

البنية الثنائية

A bencoded dictionary starting with byte 0x64 ('d'), containing string keys mapped to bencoded values. The top-level dictionary holds announce URLs and an info dictionary with piece length, SHA-1 piece hashes, and file metadata, all terminated by the byte 0x65 ('e').

Dump torrent metadata as JSON أخرى
python3 -c "import sys, json, hashlib, bencodepy; t=bencodepy.decode(open(sys.argv[1],'rb').read()); print(json.dumps({k.decode():('...' if k==b'pieces' else v.decode() if isinstance(v,bytes) else v) for k,v in t.items()}, indent=2))" file.torrent

Decodes the bencoded .torrent file using the bencodepy library and prints the top-level keys as formatted JSON. The pieces field is replaced with a placeholder since it contains raw binary SHA-1 hashes that are not printable.

Compute the info_hash of a torrent أخرى
python3 -c "import sys, hashlib, bencodepy; t=bencodepy.decode(open(sys.argv[1],'rb').read()); print(hashlib.sha1(bencodepy.encode(t[b'info'])).hexdigest())" file.torrent

Extracts the info dictionary, re-encodes it, and computes the SHA-1 hash. This info_hash is the same value used in magnet links and tracker announce requests to identify the torrent.

منخفض

نقاط الضعف

  • Tracker URL fields pointing to internal network addresses for SSRF if a client blindly resolves announce URLs
  • Misleading file path entries in multi-file torrents that use directory traversal sequences (e.g., ../../../etc/passwd) to write outside the download directory

الحماية: FileDex does not parse, render, or execute these files. Reference page only.