-
-
Notifications
You must be signed in to change notification settings - Fork 90
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Invalid key" error while trying to restore re-encrypted database in WhatsApp #109
Comments
Hi,
Probably the feature list is incorrect? As you correctly guessed, you should copy it from the backup file you want to modify and re-encrypt it using the same feature list with the
This is assuming the feature list is incorrect. It might also be:
Because unfortunately the application won't tell you what exactly is wrong. Unfortunately, |
Thanks a lot for you detailed explanation, @ElDavoo
I think I am able to try that and see what happens. The first point does not sound too difficult to achieve and the third one is easy when you already have the feature list. However, the second point worries me a little already. Altough using a logical OR does seem to be the natural choice at first glance, it might cause the backup process to fail again. Could you maybe elaborate a little more on what is known about the features?
Well, hopefully point one and two are not the case for my database (or anybody's database). But concerning point one, I am confident that the encryption process itself is fine, since I could decrypt the re-encrypted database successfully. |
Nothing except their names unfortunately.
They're taken from the official app, but I didn't study their effects on the DB files as it goes out of the scope of this project.
I only tested re-encrypting the exact same DB without modification, so going further is untested.
Well, the jid option is mandatory, as it identifies the phone number linked to your account. If it doesn't match, WA should recognize it's not your backup and not restore it. The WA version could change without the restore failing (unless the version is more recent than your current app version (?). For the other things you said, I know as much as you. |
Where exactly can one find those names? I would like to have a closer look at it because I am quite unsure whether or not I have all features now. I mean I now added these lines of code to get the feature vector by inspecting all implemented features. The result is that my new database supports all of them and my old database supports all except for |
So, I am happy to help testing 😆
Actually I think, it's pretty strange that the jid option is mandatory. I mean, imagine you have a backup from on old phone and you bought a new one with a new number. Why should it be forbidden to load a backup. That does not make too much sense, since you would need the key anyway, assuming it is end to end encrypted. |
By decompiling the app with jadx and looking at the decompiled source code.
I don't think it's the right way to do that, I would change the proto message |
Interesting. If I am unsuccessful with the current approach, I might have a look at that, too.
Yeah, unfortuantely it seems that it is not that easy to sum up all the bytes that the header contains up to feature So, I think I am close to start a new try for making WhatsApp restore my merged database. |
Ladies and gentlemen, I can happily report that my test was successful and I have just made WhatsApp recoginize my re-encrypted merged (i.e. modified) database. 🥳 For those of you who want to follow my steps, here is what I did:
@ElDavoo |
Well done! I will take a look at that after the 22nd |
Hey there, Then after all the installing and figuring out how to actually type stuff in cmd i managed to test my abilites with a newly created backupfile from whatsapp. (got backup from com.whatsapp\Whatsapp\Databases and noted the 64-digit keyfile in a textfile.) do i have to somehow reinstall the wa-crypt-tools with your changed stuff and if so, how? :D Also is the step with the merging msgstore.db files necessary to "convert" my old msgstore.db into a newer version of ".db" so it can correctly apply the crypt15 thing? I am very sorry if you read this and have to facepalm at the usage of my "progamming terms" and also at my english (i'm german) I look forward to a response, TY |
No worries, we all have different skill levels and I guess I can understand you. Moreover your english is pretty decent.
Well, if you have a copy of the entire "com.whatsapp" folder, then you also have your encrypted database
I would assume that you can't see the header infos here because the header is technically no part of the actual database.
Yes, just replacing the files won't help, You need to rebuild the executable files |
Hey, thank you first of all for your fast reply! <3
I only have the com.whatsapp from i guess was the install directory. there is no .crypt file anywhere to be seen, since i did not make a "backup" via whatsapp apparently :/ the Media Folder by itself is empty now ...
so i successfully re-installed this package with the PR#112 update and the decrypted --header-info worked out well. now all i have to do is this "merging" part you were talking about, so i convert my msgstore.db into the new .db from to encrypt it with the 64-key or does the old msgstore.db work with the 64 key by itself? Thanks in Advance <3 |
Edit: waencrypt: error: unrecognized arguments: --backup-version 1 what to do? :/ |
Great, the sounds good!
Well no, actually you don't really want to do the merging process as far as I can see.
Well, you are very close, bro. For using the |
Hey, thanks for your kind words and im really proud of myself already hehe
ok, can u please show me step by step how to properly uninstall + install this pull request, because i cant seem to get it working :( C:>git clone https://github.com/kingbtcvl/wa-crypt-tools/tree/headerinfo C:>git clone https://github.com/kingbtcvl/wa-crypt-tools/tree/headerinfo.git this is the stuff i get from cd... |
Should be exactly the same as before when you successfully uninstalled the original version and installed the one which allowed you to get the header-info |
ok, i figured it out somehow, sorry if i ask weird stuff because i dont have the knowledge and i dont write everything down what i do. It is alot to know/do which for a non-programmer just looks really funky haha when i enter the waencrypt command with all the proper header info, i get this: ...... is there something wrong here or should i try to get this backup working on my phone now? |
That's exactlly the output you want to have, so you can go with this re-encrypted backup and try to restore it in WhatsApp.
Well, actually you need to completely uninstall WhatsApp I guess. At least that is how it worked for me. I did the following steps on Android to make WhatsApp read the re-encrypted database:
|
thanks alot! i will have to try that this evening unfortunately, because i have reinstalled whatsapp too much apparently, so i cant receive SMS verification code and the calling thing does not work (the computervoice telling me to press 4 and even if i press it in the call-numberpad it does not do anything and the call ends after 20 seconds -.-) |
Right here i also want to add something, which worked for me, but not sure if needed. described in this reddit post: https://www.reddit.com/r/whatsapp/comments/11oiwse/working_as_of_march_2023_method_for_restoring_a/?sort=new
Settings >Apps>see all apps>Navigate to "google Play Services">open>Force Stop>clear Cache>Clear Data. Settings >Apps>see all apps>Navigate to "google">open>Force Stop>clear Cache>Clear Data. (Note, this step will also clear stuff like Wallet data) This step is important as far as i can tell, because it will disconnect your phone from google drive backup system. BUT just to be sure i also went in my google drive and then navigated to the "wheel in top right corner"(maybe called Settings aswell)>settings>then on the left side Manage Apps>then find whatsapp backup in the list and click on options and remove backup services. and i also found several reddit users mentioning thisfollowing step:
Settings >Apps>see all apps>Navigate to and tap "WhatsApp">Permissions>Allow access to ALL PERMISSIONS (you can deactivate permissions when everything works out well ;) )
same for me, it showed a backup was found, then the option to restore, which i clicked obviously (fingers shaking...) I am so glad that i finally managed to do this and really hope in the future to not have to do it again. But atleast in that case i know where to find helpful people like @kingbtcvl In Case any other Person like myself (total noob in programm or any related stuff) finds this post, i believe in you and if you put effort in it, i am sure you can make it work! Good Luck to all of you! |
Nice to see, that you made it! Congratulations, @haare123 |
We are trying go get our existing WA backup to a new phone number, since the old phone number is not accessible by WA anymore. |
🤔 That comes unexpected, but restoring a re-ecrypted crypt14 database is untested terretority. It might be that this does not work at all, does not work on a new phones or new number or does not work in your specific case.
Could you elaborate on that? What exactly do you mean when you say the old phone number is not accessible by WA anymore? Was it officially blocked by WA? Did you officially switch your phone number in WA before the old number got unacessible? Probably not, right? My intuition tells me that this is the root of your problem... |
Many thanks @kingbtcvl,
|
Ok, that sounds all quite complicated and indeed it could be that there is some kind of difference concerning a normal WA backup and a business account WA backup. But then again, the difference does not necessarily need to be written in the header, but might be written into the acutal database itself. I don't know.
|
Many thanks @kingbtcvl for you fast reply! I have been trying all day to download the missing media files from Google Drive Backup - finally successfully: So with all the latest data, I will try your suggestion to "convert" the crypt14 database in a crypt15 database (hopefully next week). |
This is in essence what i did some posts above hehe, just with 1 phone (and obviously same number). |
Edit: I thought the last answer was from @Sarmingsteiner, too, so parts of my answer did not make sense and I therefore delted them and edited the rest.
My guess is that the smilarity of the phone numbers i neither advantageous nor disadvantageous. From WA point of view @Sarmingsteiner's new phone number was respectively is not related to any WA Business account and especially not to the old WA business account hist old number was related to. Hence WA sees that as the normal number of a normal person. Therefore my guess is that if he gets the header info of a crypt15 file of clean fresh WA installation with that new number he kind of has a clean header. If he copies that clean header to his old decrypted database by "converting" it from a crypt14 to a crypt15 then he might be able to pretend to always have had a clean backup. At least that would be my hope here.
What do you mean that? I don't see how he could get screwed irreversiblely here. I mean I have no idea if he gets lucky and this will work out for a database that orginally comes from a businees acount, but the state he has right now can't get worse, can it? |
Many thanks again @kingbtcvl , your solution worked and we were able to restore our chats on the phone!
|
Nice to see yet another person successfully restoring their old WA chats! Congratulations! |
That's strange, I think the user's phone number is stored multiple times / in many ways in the actual database file, so even if changed in the header it would cause all sorts of problem if not treated correctly. |
As #9 is the reference issue for encryption and we only discussed on something not really technical i'm converting this issue to a discussion. |
anyway now the header is printed in verbose |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Hey guys, I have the following problem concerning the encryption function:
I have and old database
msgstore_old.db.crypt14
and the corresponding key file. Using the decryption functionwadecrypt
I can successfully obtain the databasemsgstore_old.db
.Moreover I have my recent database
msgstore_new.db.crypt15
which is end-to-end encrypted with a 64 characters keya69f...
that I know. Again usingwadecrypt
with this key I can successfully obtain the databasemsgstore_new.db
.Now I want to merge this two database. Using Julia and its
SQLite
package, I can execute a bunch of SQL commands which yields a merged databasemsgstore_merged.db
. After achieving that I want to restore this merged database in WhatsApp, of course.So I use
waencrypt
with my keya69f..
. to getmsgstore_merged.db.crypt15
. I checked that everything is fine by decrypting this database withwadecrypt
again as a little test and it worked, so I felt I was ready to restore this merged and encrypted database in WhatsApp.Consequently I deinstalled WhatsApp completely, put my
msgstore_merged.db.crypt15
asmsgstore.db.crypt15
in newly createdWhatsApp\Database
folder and also copied the oldWhatsApp\Media
folder where I put the new media, too. Now I installed WhatsApp again, opened it, regestired wiht my phone number until I took me to the backup dialog. Since I am on Android WhatsApp wanted me to backup from my Google Account, but no problem. I closed WhatsApp, switched to airplane mode, opened WhatsApp again, waited a bit, skipped the error connection message and there we go, WhatsApp trying to find a local backup. My backup was recoginized by WhatsApp, too. So far, so good.Now WhatsApp asks me to provide a password for encryption. I tell it that I have used a 64 character key instead in it leads me to the dialogue where I am finally supposed to put in my key. I typed that key
a69f...
in and it failed telling me it would be invalid :-(I tried that a second time, double and triple checking that there was no typo and after being absoltely sure I again failed and WhatsApp told me that the key I put in was wrong again.
(I even made a third attempt decrypting
msgstore_merged.db
with a key5555....
that consits of 64 times a 5, but this did not work either while encrypting it in WhatsApp).So, it seems like altough I can successfully redecrypt my encrypted file
msgstore_merged.db.crypt15
using thewadecrypt
function from this repo, WhatsApp still hates the encrypted file.I read through the issues in this repo and reading issue #9 I found out that WhatsApp obiously requires the correct header in the encrypted file to be able to read it successfully.
This means that I see some light at the end of the tunnel. However I haven't figured out yet, how to get the correct header into my encrypted file.
Due to the comments in #9 I gained some hope that the command
waencrypt a69f... msgstore_merged.db msgstore_merged.db.crypt13 --reference msgstore_new.db.crypt13 --type 13
would do the job, but looking at the current source code I feel that the
--reference
option is just an empty dummy at the moment?! Am I correct in this assumption or did I simply miss the part of the code where this option effectively does something?I mean I could simply try it and see what happens, of course, but I don't want to waste a try here because WhatsApp already started to complain about me regestering the same phone number to often in a row. Therefore I had to swicht from SMS verification to get call verfication already and I am a little afraid of getting banned permanently :D
So any clues on how to make my merged database get accepted by WhatsApp would be highly appreciated!
The text was updated successfully, but these errors were encountered: