Skip to main content

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


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)

Uploaded Source

Built Distribution

tgnet-0.1.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

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

Hashes for tgnet-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cf3f30fe403162041a8976410cc6efeb665a99661af9255571f01d3a199f1ae2
MD5 10f7e980e0dc70e2632d2c35f1baed35
BLAKE2b-256 02a7b6846a98a016152a8247bce6faa025b0345277d8871c5c89c4a04f4c9731

See more details on using hashes here.

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

Hashes for tgnet-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4ae211e4ad6ce039cb9932669406096c0272220fdcce4dc9e5919c9380d5fbeb
MD5 d60d19a15a14b31e30ef3863bc732037
BLAKE2b-256 78c138bd0339864a3d5643b72953cf574942618341cf50a9b420a476f8cfbf19

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page