Skip to content

Commit 47b300a

Browse files
committedJun 23, 2024
update instructions in README.md
1 parent c6662f3 commit 47b300a

File tree

2 files changed

+58
-8
lines changed

2 files changed

+58
-8
lines changed
 

‎README.md

+57-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,62 @@
11
# AndroidTelePorter
2-
Converts Android's telegram session into telethon / pyrogram session, also can be used to exctract AuthKey from Android's session
32

4-
# There are no currently working analogues on the internet.
5-
##### The software can be used to convert mobile android sessions to any other type of session (pyrogram, telethon, TDATA etc.) or just to extract auth key from the session
3+
Serializer and deserializer for mobile telegram session
64

7-
##### 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, it ca be extracted using ADB (Android Debug Bridge)
5+
## Table of Contents
86

9-
##### You can download example file just for tests here: https://drive.google.com/file/d/13xy2EQ_F1ScdFQNONqLoWwbY-ltOk8HF/view?usp=sharing
10-
###### ps. the software will work and will return you the string session and auth key of that session, but as that session is public, it may already be invalid
7+
- [Project Name](#project-name)
8+
- [Table of Contents](#table-of-contents)
9+
- [Description](#description)
10+
- [Installation](#installation)
11+
- [Usage](#usage)
1112

12-
Technically it is a copy of [Telegram's class NativeByteBuffer](https://github.com/DrKLO/Telegram/blob/master/TMessagesProj/jni/tgnet/NativeByteBuffer.cpp)
13+
## Description
14+
15+
This tool can be used to serialize and deserialize session on original Telegram client for Android phones.
16+
17+
It can extract any information stored in files/tgnet.dat and all needed information from shared_prefs/userconfing.xml
18+
19+
It also can deserialize existing session into object and convert it into other session formats (currently supported tdata, telethon and tgnet)
20+
21+
And you can serialize session manually into mobile tgnet format, all you need is just auth key, datacenter id and user id, it is minimum information needed for almost any session format
22+
23+
## Installation
24+
25+
You can easily set up this package as it is available on pypi by running the following command
26+
```bash
27+
pip install AndroidTelePorter
28+
```
29+
30+
## Usage
31+
32+
#### Converting existing mobile session into other format
33+
```python
34+
from AndroidTelePorter import AndroidSession
35+
36+
# both tgnet.dat and userconfing.xml are stored in /data/data/org.telegram.messenger directory
37+
# if you have more than 1 account you would need to use tgnet.dat from /files/account(account_number)/tgnet.dat
38+
# and corresponding userconfig.xml file from /shared_prefs/userconfig(account_number).xml
39+
session = AndroidSession.from_tgnet(
40+
tgnet_path=r'files\tgnet.dat', # contains auth key and dc id
41+
userconfig_path=r'shared_prefs\userconfing.xml' # contains user id
42+
)
43+
44+
session.to_tgnet('converted/tgnet') # will create all needed files right in directory that you specified
45+
# or
46+
session.to_tdata('converted/pc') # will create another folder "tdata" inside directory that you specified
47+
# or
48+
session.to_telethon('converted/telethon.session') # must end with .session
49+
```
50+
51+
#### Creating mobile session from auth key, dc id and user id
52+
```python
53+
from AndroidTelePorter import AndroidSession
54+
55+
session = AndroidSession.from_manual(
56+
auth_key=bytes.fromhex('hex auth key'),
57+
dc_id=0, # datacenter id (from 1 to 5)
58+
user_id=12345678 # telegram user id
59+
) # can be used to create any session (tgnet / tdata / telethon) from auth key, dc id and user id
60+
61+
session.to_tgnet('converted/tgnet') # will create all needed files right in directory that you specified
62+
```

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
88
long_description = "\n" + fh.read()
99

10-
VERSION = '1.0.0'
10+
VERSION = '1.0.1'
1111
DESCRIPTION = 'Serializer and deserializer for mobile telegram session'
1212

1313
setup(

0 commit comments

Comments
 (0)