A tool to recover as much data as possible from partially downloaded or corrupted .torrent files. Runs entirely in the browser via WebAssembly — no data is uploaded anywhere.
- Info hash & magnet link (computed from raw bytes, works even with outer corruption)
- Name, trackers, piece info
- File list with sizes (multi-file torrents)
- Metadata: comment, created by, creation date, source, private flag
- Raw byte scan fallback for severely damaged files (extracts URLs and strings via pattern matching)
Three-layer recovery strategy:
- Fault-tolerant bencode parser — handles truncated strings/ints, missing terminators, leading garbage, and malformed keys without crashing
- Raw info dict extraction — scans for the
4:infodbyte pattern and walks the bencode structure to compute the SHA-1 info hash, independent of outer file corruption - Regex fallback — when bencode parsing fails entirely, scans raw bytes for tracker URLs and known key/value patterns
├── src/lib.rs # Rust WASM library (bencode parser + recovery logic)
├── Cargo.toml
├── web/index.html # Website (dev, imports from ../pkg/)
├── docs/ # GitHub Pages deployment
│ ├── index.html
│ └── pkg/ # Built WASM artifacts
├── torrent_recovery.py # Original Python CLI script
└── test_recovery.py # Generates 16 corrupted variants and tests recovery
Requirements: Rust and wasm-pack
# Build the WASM module
wasm-pack build --target web --release
# Copy artifacts for GitHub Pages
cp pkg/torrent_recovery.js docs/pkg/
cp pkg/torrent_recovery_bg.wasm docs/pkg/
# Serve locally
cd docs && python3 -m http.server 8080The test suite generates 16 corrupted variants from a reference torrent file and verifies the recovery script handles each without crashing:
python3 test_recovery.pyTest cases include: truncated at 25/50/75%, header-only, random byte corruption, garbage prepended/appended, middle chunk removed, broken terminators, zeroed sections, info-dict-only, tiny fragments, and empty files.
The original Python script works standalone with no dependencies:
python3 torrent_recovery.py damaged_file.torrentMIT