andreas-mausch / whatsapp-viewer

Small tool to display chats from the Android msgstore.db database (crypt12)
https://andreas-mausch.de/whatsapp-viewer/
MIT License
1.23k stars 381 forks source link

Cant open database anymore on latest whatsapp #138

Open wjp79 opened 2 years ago

wjp79 commented 2 years ago

When opening a database I get a message that I am using an older version of the viewer. When opening the database with a sql viewer I saw they changed and hashed a lot of data like phone numbers etc.

I hope you get this working with the latest changes....

andreas-mausch commented 2 years ago

Uff. :( Thanks, I'll check out what they've changed.

ghost commented 2 years ago

I believe it is related to the legacy_available_messages_view view.

GeorgFleig commented 2 years ago

@andreas-mausch you can check out the necessary changes here: https://github.com/residentsummer/watoi/pull/47/files

wjp79 commented 2 years ago

Hi, So I used the sql command (thanks venusjivani) to insert the legacy-avaiable_messages_view to be inserted into the msgstore.db. But when I open the msgstore.db file with whatsapp viewer, I still get the "you seem to open an older whatsapp database" message. Is there a debug switch or something to find out what is going on?

I get the msgstore directly from my rooted phone. (I dont decrypt the file)

Thank you

wjp79 commented 2 years ago

So I manual added the missing tables and now I can open the database with whatsapp viewer. But now to figure out how to add the content of the new tables to the old tables so I can view them in whatsapp viewer. Piece of cake....:-( (I really need to learn how to code...)

andreas-mausch commented 2 years ago

I've taken a new backup on my test phone. Unfortunately, WhatsApp banned my phone number (most likely because I was using the Android Emulator with no real SIM). Luckily, they responded quickly to my support ticket and unbanned the number again.

So, I have a dump of a new database schema: A lot of things changed.

I managed to update WhatsApp Viewer to get the basic functionality work again with the new database schema. However, only with the new one. I need to put more time in to make it compatible with the old version(s), too.

My plan is to make a release just for the new schema nevertheless, so WhatsApp Viewer at least works again for more recent backups.

wjp79 commented 2 years ago

Hi, thank you for the update! Looking forward to this release.

ElDavoo commented 2 years ago

That program does a lot of checks that were skipped before. The important problem is that we ignored the database header completely, so when its length changes, we can not decrypt anymore. It also does many more checks you don't need.

Correct and boring solution

The important stuff that you need to do is to:

  1. Read the first byte of the db, which is the length of the upcoming protobuf message.
  2. If the second byte is 0x01, you need to skip it (not sure why)
  3. Read and parse the protobuf message. You can use .proto files in the linked repo to generate classes for this program. Of course you are only interested in the IV.
  4. The rest of the file is the encrypted db to decrypt as usual

Quick and dirty solution

A much hackier, cheaper solution is to just use a list of hardcoded offsets instead of a single pair of offsets lol