painor / telethon-secret-chat

Secret chat plugin for telethon
MIT License
45 stars 10 forks source link

[Question] 'Padding' in send message #10

Closed majidmc2 closed 3 years ago

majidmc2 commented 3 years ago

I want to see Padding when I send/receive a text message. At first I edited this line: padding_data = os.urandom(padding) print("padding data: ", padding_data) message += padding_data print("+ message: ", message)

Then I print the decrypted data after this line print("decrypted data:", decrypted_data)

I used two client for test but message!=decrypted_data and I can't see the padding on decrypted_data ! This is depends on protocol design (MTProto 2.0, part 2) or I am mistake in read 'decrypted_data' or 'padding'?

painor commented 3 years ago

why would you want to do that ? to save data in it ? I don't think telegram will allow that;

majidmc2 commented 3 years ago

Yes @painor, I research on strengths and weaknesses of MTProto 2.0. I read this and I think telegram doesn't validate the payload.

painor commented 3 years ago

well yeah they don't actually validate anything and your client is both the server and client depending on who started the chat. So you can send custom objects if the other party understands them but most official clients won't.

I remember when I was writing the code I would use static values not random and I would verify them when received so I think it's possible.

majidmc2 commented 3 years ago

Could you please help me which function I should overwrite for this purpose (send/receive a custom objects in custom client)?

majidmc2 commented 3 years ago

Could you please help me which function I should overwrite for this purpose (send/receive a custom objects in custom client)?

@painor

painor commented 3 years ago

Are you sure you're not seeing it there ? message_data_length should have the actual length while decrypted_data should have the ecnrypted+padding so to get the padding you'll need to do something like decrypted_data[message_data_length:]

painor commented 3 years ago

in any case if you want to talk more about this you can use the official telethon telegram group or it's offtopic group .

majidmc2 commented 3 years ago

Thanks for your help.

Are you sure you're not seeing it there ? message_data_length should have the actual length while decrypted_data should have the ecnrypted+padding so to get the padding you'll need to do something like decrypted_data[message_data_length:]