Pure Rust parser for Telegram Desktop's tdata storage.
Extract sessions and authentication keys from Telegram Desktop's local storage (tdata) without launching the official client, using Qt, or relying on Python.
- Pure Rust: No dependencies on Qt, C++, or Python. Statically linked and blazing fast.
- Cross-Platform: Works on Linux, Windows, and macOS tdata folders.
- Cryptography: Full implementation of TDesktop's custom encryption scheme:
- PBKDF2-SHA512 key derivation with custom parameters.
- AES-256-IGE encryption implementation.
- Custom MD5/SHA1 file integrity verification.
- MTP Parsing:
- Parses
key_data(local keys). - Parses
mapfiles (account data). - Extracts
AuthKey,UserId, andDcId. - Supports new (64-bit ID) and legacy tdata formats.
- Parses
- Interoperability:
- Generates session strings compatible with
grammers(Rust). - Easily adaptable for
telethonorpyrogram.
- Generates session strings compatible with
- Multi-Account: Automatically detects and extracts all active accounts.
Add this to your Cargo.toml:
[dependencies]
tdata-rs = "0.1"use tdata_rs::TDesktop;
use std::path::PathBuf;
fn main() -> Result<(), tdata_rs::Error> {
// 1. Path to tdata (Linux example)
let tdata_path = PathBuf::from(std::env::var("HOME").unwrap())
.join(".local/share/TelegramDesktop/tdata");
// 2. Load TDesktop storage
let tdata = TDesktop::from_path(&tdata_path)?;
println!("Found {} accounts!", tdata.accounts().len());
// 3. Iterate accounts
for account in tdata.accounts() {
println!("User ID: {}", account.user_id());
// 4. Generate session string for Grammers
let session = account.to_session_string()?;
println!("Session: {}", session);
// 5. Or get raw auth key
let auth_key = account.auth_key_bytes();
println!("Auth Key: {}", hex::encode(auth_key));
}
Ok(())
}This crate includes a ready-to-use CLI tool to inspect tdata and extract sessions.
# Clone and run
git clone https://github.com/stranmor/tdata-rs
cd tdata-rs
# Run with default tdata path
cargo run --example cli
# Or specify a custom path
cargo run --example cli -- /path/to/tdata
# With passcode
cargo run --example cli -- --passcode "secret123"Output example:
📂 Reading tdata from: "/home/user/.local/share/TelegramDesktop/tdata"
✅ Successfully loaded TDesktop storage!
App Version: 6004001
Passcode: NO
Accounts: 2
👤 Account #1 (Index 0)
User ID: 123456789
DC ID: 2
Session: 1BQAz... (ready for grammers)
👤 Account #2 (Index 1)
User ID: 987654321
DC ID: 2
Session: 1BQBm...
This library deals with sensitive authentication keys.
⚠️ Never share yourtdatafolder or the output of this tool.⚠️ Anyone with theAuthKeycan access your Telegram account without 2FA.- ✅ This tool runs locally on your machine and does not transmit keys anywhere.
- opentele (Python) - Protocol reference.
- tdesktop (C++) - The source of truth.
- grammers (Rust) - Session format compatibility.
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.