Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrypt sent binary message by whatsapp web

I am trying to decode WhatsApp web sending and receiving messages. I am able to decrypt binary messages received via websocket using encKey and macKey but not able to search a way to decrypt sent messages. I am using google chrome dev tools to copy the messages.

enter image description here

The ones in white are received messages and green are sent. Please explain or provide some resource where I can get this info.

like image 896
Shashwat Kumar Avatar asked Sep 06 '25 03:09

Shashwat Kumar


1 Answers

I removed the first two bytes from sent binary data and the rest got decrypted properly.

As per the code here,

payload = bytearray(messageId) + bytearray(",") + bytearray(to_bytes(WAMetrics.MESSAGE, 1)) + bytearray(
      [0x80]) + encryptedMessage

The WebSocket payload to be sent is concatenation of messageid and comma followed by two bytes i.e. bytearray(to_bytes(WAMetrics.MESSAGE, 1)) and bytearray([0x80]) and then the encrypted message.

Considering this format, I copied payload from Google Chrome, splitted on first comma and then removed two bytes as above. The remaining binary was encrypted message which could be directly decrypted by the keys.

 def reverseDecryptMessage(message):
    messageSplit = message.split(",", 1)
    if len(messageSplit) == 1:
      return
    messageContent = messageSplit[1]
    messageContent = messageContent[2:]
    decryptBinary(messageContent)
like image 166
Shashwat Kumar Avatar answered Sep 07 '25 21:09

Shashwat Kumar