Deserializes/serializes Telegram tgnet.dat format. Can be used to extract/replace authKey and dcId.
Project description
tgnet
Deserializes/serializes Telegram tgnet.dat format. Can be used to extract/replace authKey and dcId.
This is fork of batreller/telegram_android_session_converter with support of serialization and zero dependencies.
To convert the session all you need is just tgnet.dat file from the root directory of your telegram app on the phone, it's located at /data/data/org.telegram.messenger.web (or another package name, if you're using an unofficial client), it can be extracted using ADB (Android Debug Bridge).
Usage
>>> from tgnet import TGAndroidSession, NativeByteBuffer
>>> with open("tgnet.dat", "rb") as f:
... buf = NativeByteBuffer(f)
... tgdata = TGAndroidSession.deserialize(buf)
...
>>> currentDcId = tgdata.headers.currentDatacenterId
>>> currentDc = tgdata.datacenters[currentDcId - 1] # or tgdata.currentDc()
>>> print(currentDc.auth.authKeyPerm.hex())
'72a9808fb4a9e51e6ca57259714c14fa83546fc9d56fcb9d7de77c59fa13b6d6...'
Running tests
pytest -s -x --disable-warnings --cov=tgnet/ test.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tgnet-0.1.1.tar.gz
(10.3 kB
view details)
Built Distribution
tgnet-0.1.1-py3-none-any.whl
(8.0 kB
view details)
File details
Details for the file tgnet-0.1.1.tar.gz
.
File metadata
- Download URL: tgnet-0.1.1.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.6 Linux/6.6.4-100.fc38.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf3f30fe403162041a8976410cc6efeb665a99661af9255571f01d3a199f1ae2 |
|
MD5 | 10f7e980e0dc70e2632d2c35f1baed35 |
|
BLAKE2b-256 | 02a7b6846a98a016152a8247bce6faa025b0345277d8871c5c89c4a04f4c9731 |
File details
Details for the file tgnet-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: tgnet-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.6 Linux/6.6.4-100.fc38.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ae211e4ad6ce039cb9932669406096c0272220fdcce4dc9e5919c9380d5fbeb |
|
MD5 | d60d19a15a14b31e30ef3863bc732037 |
|
BLAKE2b-256 | 78c138bd0339864a3d5643b72953cf574942618341cf50a9b420a476f8cfbf19 |