Shashwat Kumar
Shashwat Kumar

Reputation: 5297

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.

Upvotes: 4

Views: 4761

Answers (1)

Shashwat Kumar
Shashwat Kumar

Reputation: 5297

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)

Upvotes: 2

Related Questions