atilaromero / telegram-desktop-decrypt

Tool to decrypt tdata files.
MIT License
182 stars 63 forks source link

"keytype not treated" #3

Open snout opened 5 years ago

snout commented 5 years ago

Using the latest TG app as of today, 1.8.2, MX Linux (Debian derivative). Built the decryptor with plain downloading go and installing in /usr/local as per the golang.org instructions. "go build" in the directory where main.go is at. mkdir decrypted ./telegram-desktop-decrypt bulkdecrypt ~/.local/share/TelegramDesktop/tdata/D877F783D5D3EF8C/map0 decrypted/ could not decrypt file '/home/[myname]/.local/share/TelegramDesktop/tdata/D877F783D5D3EF8C/map0': keytype not treated: 154048071

This is all.. greek.. to me. What might this be?

atilaromero commented 5 years ago

In https://github.com/atilaromero/telegram-desktop-decrypt/blob/d3c9d4a2671f3df3de66de5ccd2b2526f7b10487/tdata/decrypted/map.go#L46 , while the decrypted map0 file is parsed, it reads a 4 bytes that should correspond to a "keytype". The map0 says, for each of the other files in his directory, those with strange names, which filetype it is, using this number. It should be a number between 0x00 and 0x15, but you got 0x92e9647.

Those numbers were extracted from https://github.com/telegramdesktop/tdesktop/blob/fa3117e41ed4862541a94b4df50710490247fe7a/Telegram/SourceFiles/storage/localstorage.cpp#L497 at version 1.5.1, but the list on 1.8.8 seems to be the same.

Maybe something else changed in a new version of telegram desktop, or the decrypted map parsing should be doing something else, or your file may be corrupt. I'm not sure which of these options is happening here.

exander77 commented 4 years ago

Have exactly the same problem and my file is not corruted.

atilaromero commented 4 years ago

Then the map parsing is definitively lacking something.

XamarinDeveloper commented 4 years ago

Hey, I know what is that number, you shouldn't change it to hex format, it's user's telegram number id, now you know this, can you make it work? I reeeeeeeeeeeeally need it, thanks :)

I changed your code a bit and made it print every keytype that it couldn't parse in the default case of switch I put this : fmt.Printf("%d is %d\n", x, keytype) and got this output :

1 is 114740646
2 is 114740646
3 is 456240660
4 is 2147483648
5 is 52
6 is 265825
7 is 342033
8 is 0
9 is 114740646
10 is 0
11 is 0
12 is 0
13 is 464025500
14 is 0
15 is 0
16 is 4294967295
17 is 160
18 is 160
20 is 486844209
21 is 4294967295
22 is 24
23 is 3735608
24 is 3735601
25 is 3145779
26 is 3342391
27 is 3538998
28 is 3211316
29 is 34
30 is 5767265
31 is 7143521
32 is 7471209
33 is 7209055
34 is 4456549
35 is 7733349
36 is 7077999
37 is 7340133
38 is 7511812
39 is 848113394
40 is 1247674368
41 is 477888511
42 is 4294925831
43 is 1329790976
44 is 131071
45 is 4294901760
46 is 6291540
47 is 5177412
48 is 4259929
49 is 2097257
50 is 7536672
51 is 7602280
52 is 6619168
53 is 6684777
54 is 7471219
55 is 7602208
56 is 6553697
57 is 7929888
58 is 7274598
59 is 2097268
60 is 6815845
61 is 2097266
62 is 6619251
63 is 7602208
64 is 7274598
65 is 2097273
66 is 7274613
67 is 7471136
68 is 4980809
69 is 4587589
70 is 2162688
71 is 277998
72 is 3811314939
73 is 1006632960
74 is 1053368
75 is 1377614866
76 is 2850285318
77 is 2678913762
78 is 3242013910
79 is 234139854
80 is 3110009705
81 is 2014044098
82 is 1474887680
83 is 999980
84 is 1062263316
85 is 3288334336
86 is 1323259
87 is 995712607
88 is 2863661056
89 is 0
90 is 0
91 is 628318
92 is 1753608417
93 is 1560084480
94 is 663334
95 is 1379741591
2019/12/28 16:12:14 could not decrypt file '/home/xamarindev/snap/telegram-desktop/994/.local/share/TelegramDesktop/tdata/D877F783D5D3EF8C/map0': unexpected EOF

it's clear that none of them is a correct keytype, but why? please answer and help me through there is an image that I need it and its very important, thanks :)

mhm233 commented 4 years ago

Same here. Your thing doesn't work

atilaromero commented 4 years ago

The fix should be the XamarinDeveloper's suggestion, to accept the number as the telegram number ID. But to to that, I (or someone else) will have to revise the parser, which should be expecting this. It will be likely necessary to compare it with an updated version of Telegram Desktop source code, to follow what it does. Unfortunately, I will not have the spare time to do this any time soon. Hopefully someone else could send a push request, who knows!

atilaromero commented 4 years ago

It is on my todo list, the thing is that it is already too long.