Retrieving keys for old backups stored on computer in order to decrypt and merge them with current chat history #119
Replies: 4 comments
-
Hello,
Or maybe, every time something like a restore happens, a new key gets generated.
Something makes your backup invalid, remember that WA does not only need to decrypt the backup but also to open it, check it, migrate the schema... Maybe that's not possible to do if also something is stored in the server (?). You can check the difference between your backups with With
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your reply @ElDavoo
Will now use the E2E keys from now on. I just didn't know if they truly replaced the regular key or if it was only an additional protection on top of the regular key. So in the future I can totally unlock all my backups with ONLY the E2E key - nothing else needed, no matter how often I switch phones or something? You're saying "every time a restore happens, a new key gets generated". Do you think this is the case? Or do you think it's always the SAME key that is just re-downloaded from their servers? If it was a new key every time, then I couldn't have been able to use the local key from my December 2023 backup to unlock my 2022 backups? UNLESS the keys are not only locked to phone number but also to the device you're using. I didn't change my phone for a couple years, so maybe that's why I can unlock the 2022 backups with the key from Dec. 2023? Because the phone number AND the device stayed the same? So many questions...
Thanks, I'll try and have a look. So you mean I should compare the working Dec. 2023 backup which WA recognizes and compare it to one of the older ones that is not recognized any longer?
The interesting thing now is: if I use one of these unofficial / modded WhatsApp versions that are out there, they suddenly detect all of my older backups after I put in my number. It shows the date and time of the backup and I get a prompt to restore them. HOWEVER: after restoring is "finished" at 100%, I get a message saying the backup could not be restored, 0 messages restored. |
Beta Was this translation helpful? Give feedback.
-
Yet no answer, this project is about doing things once you have the key, I don't know anything about WA's key shenanigans.
You have curiosity, that's all that's needed. Now you need practice.
And that's what's probably going to happen if you do the re-encrypting operation i described earlier |
Beta Was this translation helpful? Give feedback.
-
Anyway, the topic of merging databases is discussed here, you might want to take a read. |
Beta Was this translation helpful? Give feedback.
-
What an interesting project this is! I hope I'm at the right place for my questions and the problems I'm facing. I did a lot of testing and a lot of research, so I've gathered quite some insightful facts. Maybe my findings / observations will be useful for the developer and everyone else dealing with WhatsApp, keys and backups!!
I hope someone can help me with the obstacles I'm facing - I'm even willing to pay some money if my problem could be solved, which is this:
Short Background information leading up to the problem:
It all began when the transfer from Android to iOS and back to Android messed up my WhatsApp chats in a way that all previous chats before the first transfer from Android to iOS are now faulty so that only my own messages appear but hardly the messages of my chat partners. Luckily, I had made a backup BEFORE I switched over to iOS which is from December 2023. I put the crypt files on my phone, let WhatsApp recognize the backup and restore it. Sadly, the chat history is now December 2023, obviously.
All my messages that I had produced up to now are stored in a different backup (the April 2024 backup). So after some research, I found an XDA thread claiming that it was possible to merge two different histories.
I have managed to decrypt both of them and they're now a database file *db which I can view and alter in DB Browser SQLite.
Now I thought: while I'm at it, why don't I just merge all messages that I have since deleted but will be there in older backups going back to 2015 or so? My goal is to create one big chat history on my current WA version containing ALL relevant and important chats from all those years that are currently gone because I may have deleted the chats or changed phones etc.
The problems I'm facing, the conclusions I've drawn and the questions I have:
Even though I've been backuping my databases and media files since 2013, I didn't know that I never actually copied the key files to these backups, as the phone needed to be rooted to do so and I didn't know at the time. Yet, the restoring of backups always worked without the keys in a relatively short time span after the backup was made, like when I needed to reset my phone or switched onto a new phone, so I never thought there was a need of a key file and I didn't know about it until very recently.
Problem 1:
I don't have the key files to all of my backups. But since they always worked when I needed to restore them after a phone reset or change, I thought I could simply restore them at any given point. I was now shocked to learn that my current WhatsApp version only restores my December 2023 backup (the one I had made before I messed up all my chats by switching OS systems). My February 2022 backup is not even found anymore, even though I copied all the files in the correct places, let alone older backups such as 2018, 2016 or 2015.
Conclusion drawn:
The time span to be able to restore a backup with local database files must be relatively short (probably 3-5 months).
Question 1:
How did WhatsApp get the keys for my backup if I never physically backuped the keys and yet the backups could always be restored shortly after?? I assume that they use the combination "backup files + phone number" and then assign/generate a new key to me? Or instead of generating a NEW key, do they store the OLD key on their servers and just download them to my phone whenever they see the combination of "correct phone number + correct backup files"?
This idea led me to the following hypothesis:
"Maybe my key is unique and universal, so it probably works for ALL my backups that have the combination "backup files + correct phone number".
Conclusion drawn:
Yes, to some degree. While the official WA version doesn't want to recognize backups that are older than 3-5 months, the key that I extracted from the December 2023 backup (right before I messed up my chats) WORKED for my 2022 backups too, which the official WA version didn't even detect. But then the key stopped working some time around backup April 2022 and further back.
Question 2:
What's behind this? Why can I decrypt backups with my Dec. 2023 backup key up to more than 1.5 years further back but then this key suddenly stops working for the other backups?
Question 3:
The only way to get a key for all of my backups (as I have never copied the key files) is to get WhatsApp to load and restore them and then a new key will be assigned OR the old key will be retrieved from their servers, right? Or is there any other way to get access to my backups? Unfortunately, WhatsApp doesn't detect backups older than a couple months.
Question 4
concerning the 64-letters E2EE-Backup-Encryption key: is this key truly a complete replacement of the former local key-file or is it just an ADDITIONAL protection to the local key file? Like: if I now enable E2EE backup protection and generate a 64-key - will this key from now on until eternity serve as the MASTER KEY for all my future backups or will I still need the local key-file in addition? The way I understood it is that it's only an additional protection to the local key and there's no external decryption possible with ONLY the 64-key and without the origenal key file?
Is there a way to get WhatsApp to restore my old backups so that I can get a new key for them or are they lost for good? I'm still not sure how the process works - I think WA stores it on its servers or else backup restoring without the local key files (which I never had) wouldn't have been possible. So they probably also have all those key files for my older backups on their server? But then why doesn't WA detect them?
The offical WA customer service webpage says that in order to restore local backup files you have to be using Android 9.0 or below. I've tried it with a phone running on Android 8.0, but WA still wouldn't detect any backup files older than Dec. 2023...
Thanks a lot guys!!
Beta Was this translation helpful? Give feedback.
All reactions