batreller / AndroidTelePorter

Converts Android's telegram session into telethon / tdata session, can also be used to exctract any data from mobile session (auth key, dc id, user id and other)
MIT License
92 stars 28 forks source link

I can't log in using a mobile session #13

Open Doutuq opened 4 months ago

Doutuq commented 4 months ago

Hello and thanks for your work!

In your code I added my variables: user id, dc id, auth key. I received the file: tgnet.dat and then moved it to the Android emulator in the folder /data/data/org.telegram.messenger

But I didn’t get the authorization in telegram, tell me where the problem could be?

batreller commented 4 months ago

You need to replace all original files in that directory with all files that AndroidTelePorter created for you, not just tgnet

Just delete all folders from /data/data/org.telegram.web and copy new session files made with AndroidTelePorter to this folder

Doutuq commented 4 months ago

I tested the file placement options:

Added to /data/data/org.telegram.messenger

option 1: I immediately added the “tgnet” folder (in “tgnet” I have 2 folders “files” (here is the “tgnet” file) and “shared_prefs (here is the “userconfing” file”)

option 2: added only the "tgnet" and "userconfing" files

option 3: added two folders "files" and "shared_prefs" with files inside, respectively

Please tell me, did I get everything I needed from AndroidTelePorter? Perhaps there are some other details?

Thanks for the answer.

batreller commented 4 months ago

Option 3 is the one you need, have you tried it? Does it not work?

Did you close Telegram before replacing files?

Doutuq commented 4 months ago

image

Yes of course, I did everything right! Perhaps I should look towards converting TDATA into a mobile session? but I also entered all the variables correctly there.

I tested this on an Android emulator and on a physical device, no result.

batreller commented 4 months ago

In that case I would suggest you making sure that session you are trying to use is valid

notraiday commented 3 weeks ago

Just delete all folders from /data/data/org.telegram.web and copy new session files made with AndroidTelePorter to this folder

Is there any way to ADD session? / Create multiple-session config with AndroidTelePorter

batreller commented 3 weeks ago

Do you mean a few sessions? Like when you open Telegram and there are a few sessions? Yes you can just look at how Telegram stores them and do the same thing, but there is no built-in function that will do that for you

If you read main.py in this repository there will be documentation on how sessions are stored in Telegram. You can just locate sessions this way and it should work, I might think about adding this feature in future though

notraiday commented 3 weeks ago

might think about adding this feature in future though

I think it is more complicated. You can store multiple accounts in telegram desktop as well but nobody had written software to create "tdata" with multiple accounts afaik, It's sad

batreller commented 3 weeks ago

As you can see in main.py There are 4 locations of tgnet.dat file: /data/data/org.telegram.messenger.web/files/tgnet.dat /data/data/org.telegram.messenger.web/files/account1/tgnet.dat /data/data/org.telegram.messenger.web/files/account2/tgnet.dat /data/data/org.telegram.messenger.web/files/account3/tgnet.dat

and 4 locations of userconfing.xml file: /data/data/org.telegram.messenger.web/shared_prefs/userconfing.xml /data/data/org.telegram.messenger.web/shared_prefs/userconfig1.xml /data/data/org.telegram.messenger.web/shared_prefs/userconfig2.xml /data/data/org.telegram.messenger.web/shared_prefs/userconfig3.xml

These are locations you will have if you have 3 accounts.

/data/data/org.telegram.messenger.web/files/tgnet.dat and /data/data/org.telegram.messenger.web/shared_prefs/userconfing.xml are files of session that will be started when you open Telegram app, all other sessions (account1, account2, account3) are used when you switch to another session and they probable replace org.telegram.messenger.web/files/tgnet.dat and /data/data/org.telegram.messenger.web/shared_prefs/userconfing.xml the moment you switch between sessions, but I have not manually tried this but I am almost sure there is nothing else needed apart from these files

About tdata - you can create many sessions with opentele and that's exactly how AndroidTelePorter converts mobile session to tdata

jolieprince commented 2 weeks ago

do i need to create API_ID and API_Hash if I need to use .session file with telethon?

batreller commented 2 weeks ago

You can just use official ones

Or you can create yours But it will be suspicious for telegram that you changed your api_id and api_hash without changing actual session

jolieprince commented 2 weeks ago

Can you provide me official id and hash. Or where can I find them? I tried but couldn't find anywhere.

jolieprince commented 1 week ago

Can you provide me official id and hash. Or where can I find them? I tried but couldn't find anywhere.

jolieprince commented 1 week ago

Can you tell me please how to find official api_id and api_hash?