tomer8007 / whatsapp-web-incognito

A Chrome extension that disables read receipts and presence updates on WhatsApp Web
MIT License
312 stars 74 forks source link

signalDecryptPrekeyWhisperMessage function is not working #94

Closed wangsen2020 closed 1 year ago

wangsen2020 commented 2 years ago

`var messageKey = await MultiDevice.signalGetMessageKey(chainKeyData, message.counter, messageKeys); var keys = await libsignal.HKDF.deriveSecrets(messageKey, new ArrayBuffer(32), "WhisperMessageKeys");

// here is  throw except
var plaintext = await libsignal.crypto.decrypt(keys[0], toArrayBuffer(message.ciphertext), keys[2].slice(0, 16));
// plaintext makes sense? good.
return plaintext;`

I tried to fix it but it was too complicated. if you have time, please check it, maybe it's a bug

tomer8007 commented 2 years ago

Do you have a javascript exception to show? How to reproduce this?

wangsen2020 commented 2 years ago

Do you have a javascript exception to show? How to reproduce this?

image

when I send a message by celephone, the whatsapp web will throw error in the consle。 I track this error and found it happen at signalDecryptPrekeyWhisperMessage

I wanted to listen to receiving and sending messages and found this error

tomer8007 commented 2 years ago

But it says that WhisperMessage is not defined. It's like it didn't inject this line: https://github.com/tomer8007/whatsapp-web-incognito/blob/90272e1602becc1b0421a481fdeb1355e95b88d6/core/parsing/protobuf/WhisperTextProtocol.js#L5

What do you see on your end?

wangsen2020 commented 2 years ago

I use the master branch, in core_injections.js inject this script

image

I mean when I receive a message,it break at var plaintext = await libsignal.crypto.decrypt(keys[0], toArrayBuffer(message.ciphertext), keys[2].slice(0, 16)); you can try it I found the whatsapp js code and found it's right,I think the parameter is wrong

tomer8007 commented 2 years ago

Can you figure out why it's not injected in your case? Also how is the line var plaintext = await libsignal.crypto.decrypt(keys[0], toArrayBuffer(message.ciphertext), keys[2].slice(0, 16)); relevant? I don't see it in the exception you sent.

wangsen2020 commented 2 years ago

it's injected my case,The problem with my feedback is that: when I receive a message from others or from my whatsapp mobile, I can't get this message text. so I debug this source code and found the code above throw a exception, this exception was caught by interceptions.js. so I screenshot a picture of console to you,The location where the exception happen at: var plaintext = await libsignal.crypto.decrypt(keys[0], toArrayBuffer(message.ciphertext), keys[2].slice(0, 16));

tomer8007 commented 2 years ago

Do you have a screenshot of the exception with the var plaintext = await libsignal.crypto.decrypt(keys[0], toArrayBuffer(message.ciphertext), keys[2].slice(0, 16)); line?

wangsen2020 commented 2 years ago

Jun-17-2022 21-23-06

tomer8007 commented 2 years ago

OK, but what is the exception message (exception.message)?

wangsen2020 commented 2 years ago
image
tomer8007 commented 2 years ago

Unfortunately a DOMException probably means that it's trying to decrypt the incoming message with a bad key or IV. But I just tried to send a message and receive it and it works fine. Can you guess what are the special circumstances at which this happens?

wangsen2020 commented 2 years ago

It's work normally in waincognito, but when others send message to you or you send message to others by your whatsapp mobile. I want to get the message that others send to me, but it's wrong when decrypt message, certainly you can ignore,because it don't affect waincognito functions

wangsen2020 commented 2 years ago

I would be grateful if you can decrypt the message, because I really need to listen to the returned event, of course, if it is difficult, just ignore it

tomer8007 commented 2 years ago

Does this happen only with voice message? How about groups? Can you make some tests? Anything that can help me understand the scenario is going to help.

wangsen2020 commented 2 years ago

I don't understand why you can't understand my feedback, maybe you've been addicted to your wacognito product, what I'm feeding is not the read receipt, what I'm feeding back is that this code can't decrypt the returned information, I made it very clear , when someone sends you a message, you can't decrypt the content of the message, how do I describe this to you? You can find this problem as long as you debug it yourself

wangsen2020 commented 2 years ago

the code can‘t decrypt content of the message,if you can solve it,it's very wonderful, If you don't know how to solve the decryption problem, just ignore it

wangsen2020 commented 2 years ago

But I just tried to send a message and receive it and it works fine. Can you guess what are the special circumstances at which this happens

if you check your code,you will find when the code throw exception, you will return the original object——messageEvent which does not affect the parsing process of whatsapp,so you think it works fine.

As long as the message is decrypted, the error will be reported. obviously

tomer8007 commented 2 years ago

My trouble is that, the decryption works for me:

image

There are no Passing through errors. I'm sure there is a way to reproduce the bug, just not sure about the difference here.

wangsen2020 commented 2 years ago

my whatsapp account 8618976917166,you send a message for me,I use common account not business account,whatsapp version 版本 2.2220.8

tomer8007 commented 2 years ago

It seems like I that I encountered a similar problem in signalGetMessageKey/signalDecryptPrekeyWhisperMessage, looking into this.

wangsen2020 commented 1 year ago

did you resolved this bug ?

tomer8007 commented 1 year ago

Sadly, no. It still works for me.

It sounds like somehow there is a problem with the Signal database state. Does re-logging in change anything? Also did this bug start appearing for you right from the beginning?

wangsen2020 commented 1 year ago

Sadly, no. It still works for me.

It sounds like somehow there is a problem with the Signal database state. Does re-logging in change anything? Also did this bug start appearing for you right from the beginning?

Is this source code give you some inspiration? https://github.com/pedroslopez/whatsapp-web.js

tomer8007 commented 1 year ago

Is this source code give you some inspiration?

No, it doesn't seem to do Signal message decryption. Have you tried the extension on other computers? It looks like message decryption works for other people.

tomer8007 commented 1 year ago

Closing because I can't reproduce this.