MTProto MITM server
Telegram mtproto mitm server.
This project must be used for research purposes only.
Installation
Requirements:
- Python 3.11+
pip install mtproto-mitm
TODO
- Record mtproto connections to files to allow reviewing them later
- Add cli interface
- Add web interface ?
Usage
-
Install mtproto-mitm
-
Get your telegram auth key:
- Telethon or Pyrogram: you need session file and any sqlite reader. Open session file with sqlite reader and run "SELECT HEX(auth_key) FROM sessions;"
- Telegram for Android (not Telegram X): you need root access. Copy tgnet.dat file from telegram directory (/data/data/<package name>/files/tgnet.dat) from your android device to your pc. Now you can use tgnet to extract key: use code from example.
- Telegram Desktop: you can use opentele to extract auth key from tdata folder. From Telegram Desktop version 5 and newer, seems like Telegram uses exclusively temp auth keys that are generated at runtime and not stored anywhere; that means once you close Telegram Desktop application, you won't be able to access decryption keys, so you need to extract them from memory while Telegram is running, and only then start mtproto-mitm with those keys; also, note that temp keys work for at most 1 day (iirc) and even if you won't restart Telegram application, you'll need to extract keys again later. To extract keys from memory, you can use tdesktop-keys-extract script.
-
Run MTProto-MITM:
Usage: python -m mtproto_mitm [OPTIONS] Options: -h, --host TEXT Proxy host to run on. -p, --port INTEGER Proxy port to run on. -k, --key TEXT Hex-encoded telegram auth key. -f, --keys-file TEXT File with telegram auth keys. -q, --quiet Do not show requests in real time. -o, --output TEXT Directory to which mtproto requests will be saved. --proxy-no-auth Disable authentication for proxy. --proxy-user TEXT Proxy user in login:password format. --help Show this message and exit.
-
Set socks5 proxy settings on your telegram client to host/port/user you specified on last step.
Examples
python -m mtproto_mitm --host 127.0.0.1 --port 1080 --key 0F5B...A38F --keys-file ./auth_keys
Metadata
Release files for mtproto-mitm 0.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mtproto_mitm-0.2.4.tar.gz | 5.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mtproto_mitm-0.2.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.0 MB
Release files / mtproto_mitm-0.2.4.tar.gz
| Download URL | mtproto_mitm-0.2.4.tar.gz |
|---|---|
| Size | 5.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34416f2311bbe6ef394e407285632d67273c34c7d08b21a5e1b9b2799596171f
|
|
BLAKE2b-256 checksum How to use checksums |
17170df5d5fbd3f315baba71e128218759ecc5097cc2683618d8138f3c23bc1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.14.2 Linux/6.17.12-300.fc43.x86_64
|
Release files / mtproto_mitm-0.2.4-py3-none-any.whl
| Download URL | mtproto_mitm-0.2.4-py3-none-any.whl |
|---|---|
| Size | 2.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0bdf69e4149194e52f35b76ef0f9f49280ec345774a2c9b373e4e742144d0e26
|
|
BLAKE2b-256 checksum How to use checksums |
9e0a7baa175ba559e8975bd4334c1e2c4d1fa1439089e9ab9358a6c08ba64fee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.4 CPython/3.14.2 Linux/6.17.12-300.fc43.x86_64
|