Replies: 53 comments 21 replies
-
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, |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
Well done! I will take a look at that after the 22nd |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
Edit: waencrypt: error: unrecognized arguments: --backup-version 1 what to do? :/ |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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... |
Beta Was this translation helpful? Give feedback.
-
That's how open source works. Nobody pays open-source developers, they work in their free time. I developed wa-crypt-tools because of personal necessity and it's has been somewhat easy, but dealing with a complex DB schema that will change at every update is something nobody is going to do for free, for free time or for hobby. The guys that developed the proprietary tools got paid for doing that and worked 8 hours a day, and still as you noticed their tools have bugs. For someone that has 1-2 hours of free time a week, it will take a lot before an open-source program would work. Even when it works, it's going to be a hassle to maintain. For example, in whapa there is a CLI tool whamerge, it doesn't look maintained, but you can try it and see what happens. |
Beta Was this translation helpful? Give feedback.
-
Yes, I understand. I didn't mean to sound accusing or anything, I didn't even mean you guys. I was just generally wondering why something that sophisticated such as Skyperious exists for Skype but not yet for WhatsApp. As I understand it, Skype is not any less complex than WhatsApp I suppose? Well, anyway. I'm still hoping there might be a way to fix this without needing to ask their support and giving them my chats. I mean, both on this thread as well on the XDA super thread there have been successful attempts merging databases and getting them to work even though the methodology seems to be varying over the years and with every WA update. |
Beta Was this translation helpful? Give feedback.
-
PS: I just contacted MobileTrans via Chat... Don't know how tech-savy those support chat people are but it doesn't seem to be going anywhere. They just asked if I had tried to run the transfer progress again.. Which I cant do because I don't even have the iPhone anymore as it was only for testing. I sent them the tables from above with my markings, now they just remain silent. |
Beta Was this translation helpful? Give feedback.
-
Well, looking at your screenshots and remembering the things I leanred when I dealt with my databases I have a rough idea what happened here. The converting process completely messed up and did obviously convert some columns incorrectly leaving out values. Where this is rather harmless for some columns like Having said this, the earlier part of your database is completely messed up and useless. Theres is no realistic chance to repair that. But since you have your original android backup for that part, this is not that bad. However chances are that the other part from January to April was also converted poorly are not too low eventough everything seemed fine in WA with that part. Anyway, if there is a chance to merge a completely flawless database at all, you best chances are starting with the old android backup and append that one with the (hopefully) uncoruppted part of your from-ios-to-android-converted backup. In my opinion trying this only makes sense if the ids of the ios-to-android-converted backup remained unchanged. To check this compare the tables
@ElDavoo made a great comment here. You paid for their tool and therefore have some right for being supported by them. Tough you should definitely not send them you database for privacy reasons I would bug them so long until someone looks at the code and makes it up to date. It is not good sign though that they already stopped reacting, but bein persistent often leads to success. |
Beta Was this translation helpful? Give feedback.
-
Thanks for still making me at least a bit of hope there!! I was all discouraged now. Well, the iPhone chat part (everything from January 5th up to the end of testing in late March) was displayed fine in WhatsApp, even AFTER I restored it back to Android. My assumption is that everything made on iOS was good and was transfered back to Android correctly, but then everything that was made before going to iOS was messed up upon returning back to Android. And here we can see the threshold or border between the faulty chats leading up to Jan. 5th and "good" chats, then produced with the iPhone after the transfer to iOS. As far as I remember the OLD chats prior to the first transfer were displayed right too on the iPhone, so the error must have happened during the SECOND transfer (back to Android). Left table is the correct database, right side the faulty one which is then followed by the correct ones after the switch to iOS: I'm lacking the knowledge on whether this is serious or not, but my amateurish attempt would be to just copy everything that is correct after Jan. 5 and extend it to the correct database which stops on Jan 5. But I don't know HOW. I know that on the XDA thread they did it with the DB Browser software somehow, but I'm not familiar with that one either. I don't know how to cut out all these columns and insert them in a different database. Then I would have to repeat that because in the meantime I've been using WA of course and new data has been produced...
They answered back and asked me to send the log files of the software, which I did. I also sent them the screenshots from above with my markings as well as an SQL export of both the databases in DB Browser (I exported "scheme only" so as not to give them the chats). Don't know if only the schemes might be useful to them without the chats, but whatever. I'm not counting on them though and even if they can somehow fix it, I'd still have to merge some databases myself as I have been producing continous data on WhatsApp of course. |
Beta Was this translation helpful? Give feedback.
-
I have opened both the CHAT and the JID table in DB browser. But I don't really know what I should be looking out for. Both look rather similiar to me. Since no chat-text is being displayed in both of these tables, I have a hard time navigating and finding the "threshold" between faulty chats and good chats just based on displayed phone numbers and some strange values. As we can see, the FAULTY Database displays an orderly count beginning from 1, whereas the CORRECT database begins at 11 and has a more chaotic numbering in the jid_row_id column. But both show the beginning of the database. Like I said, I have difficulties finding that "threshold" between faulty chats and good chats on Jan. 05. As for the JID tables: both show about the same kind of content (sometimes phone numbers, sometimes other numbers I can't recognize). The only difference I can see is that the corrupt database has a shorter list inside the JID table whereas the GOOD database has much more content to scroll down (331 vs. 1137 entries), but I have been using the "good" database for chatting up until today, like I said so naturally there would be more entries.. I still have a tiny bit of hope that something can be done about this problem. I just haven't figured it all out yet. |
Beta Was this translation helpful? Give feedback.
-
Well, at first glance it looks as if you are in trouble and just copying the data starting from January will not work and yield a flawed database again. (Besides that the process of copying unmodified (or even simpliy deleting) data from one WA database to another is way more complicated then you think because you need to handle the triggers of the database and will need to work with SQL commands. It's not an easy ctrl+c and ctrl+v 😂) However in order to give a final judgement of what is going on in your database, I would need to see the first lines of the |
Beta Was this translation helpful? Give feedback.
-
Oh yes, I'm aware of this. I've been trying to work my way through this SQL merging stuff and couldn't make any sense of it.
Thanks so much in advance for all the effort you're putting into my silly little problem!! So here's the faulty database, one is the beginning (top), one is the ending (bottom): JID Beginning (Faulty Database): The ones for the correct database will follow in a few minutes! |
Beta Was this translation helpful? Give feedback.
-
Here is the "correct database" - beginning and ending: |
Beta Was this translation helpful? Give feedback.
-
No good news, unfortunately. My guess that just copying things will not work out seems to be correct. 😒 So let me try to explain you how WA reads all this data in order to display it and then you might understand why things don't look good and just copying data will not work and you would be forced to also make modifications concerning the IDs of the tables if you wanted to have a flawless merged database. WA starts by looking at the Altough this is an extremly simplified explanation it should give you a clue of how the database is read by WA. Do you see the problem here?! Therefore I am quite sorry to tell you that the merging process here is way harder the you think because you need to take care and modify the IDs of the uncorrupted part of the faulty database so that they are consistent with the correct database. |
Beta Was this translation helpful? Give feedback.
-
Yeah, probably they won't be able to help you. But then again they might be able to idtenify what went wrong when you converted your database back from ios to android, fix it and you could then convert it again assuming you still have the ios database, of course. There is also some chance they identify it without access to your database, though chance are not too high to be honest.
Well, yes, I do think it's very likely possible that a good programmer who is also familiar with SQL would be able to write an automated script that puts together your chat history pieces so that the database works flawlessy. I mean you seem to have them all, the part before January is in your correct old database, the part between January and March seems to be uncourrupted in your ios converted database (though having different IDs) and the very latest chats are in your current database with the gap between Januaray and Februrary.
Unfortunately I don't konw of any good WA viewing programm either and I don't think that any really useful exists at the moment. Concerning your related note not my guess is that this would be possible in principle, too. I mean as I have explained to you the telephone numbers are kind of masked by the |
Beta Was this translation helpful? Give feedback.
-
Dude, that's complete madness. 😂
Yes, that's the smartest way to go. The chat table would need modifications, too tough in that case. And one more warning. The darabase contains a lot of triggers. Whenever something is added or updated in the database some triggers might get active, moifying, updating or deleting other data in the database. That happens automatically wihout you having any real control. Since there were too many I never had a closer look at them, but my gut feeling is that they might mess up things even more when you try to correct things. To put it differently when you modify your database to become correct you definitely do not want the behaviour of the triggern altough many might be harmless. |
Beta Was this translation helpful? Give feedback.
-
On an unrelated note that has nothing to do with the above-mentioned problem: I've been trying to restore older backups but as I never copied their key file (my phone was never rooted and also I never knew about that until recently), I now ended up having over 10 years of "backups" on my computer (databases & media files) and as I could always restore them in a relatively short time period after they were created (for example after a phone reset, new phone etc), this led me to believe, these backups could be restored ANYTIME as long as the phone number is the same for identification. Well, how wrong I was.. The other day I tried to restore a backup from 2015 (same phone number, but missing key file) and WhatsApp just did not even detect the backup let alone offer me an option to restore. I tested this several times with countless backups and ended up making the following observation: The last backup WA detects is from December 2023 (!). A backup from February 2023 isn't detected anymore as well as all the other backups further back. Even though the phone number always stayed the same over the years. It seems as if WA backups only work for a very small period of time (enough time for a phone reset or change of devices), but if you wait for too long, somehow, they cant be detected and restored anymore. Apparently WA changes or deletes the keys for these backups on their servers. That's how I tried to explain it to myself, because why else would they now stop working even though the phone number stayed the same all the time? Is there now any way left to get old backups restored or are they now lost forever? |
Beta Was this translation helpful? Give feedback.
-
Yes, I shortly used one of those modded Fouad WA versions too, and the funny thing is: they ALL detect my old backups and offer me to restore them after I enter the phone number unlike the official version. Strangely, even those backups were detected which were almost certainly made on a different phone number, which I thought was weird. Having used one of those modded versions, too, but only for like a couple minutes, I now hope that WA hasn't already flagged my number or account and that they won't ban me from using my official account even... I read a lot of "ban threads" on r/WhatsApp on reddit where people seem to get banned using their official accounts for apparently no reason.
Oh damn it :D
And that's the next question I'm having: that 64-letters-key - is it really truly the new "MASTER KEY", meaning it replaces the former key file?? Or is it (and that's what I read many times) only an ADDITIONAL protection of the regular / former key file? Meaning, just with the 64-letters-key alone, you can NEVER restore a database, as you would always need the regular key file as foundation?? Most stuff I read about it is that the 64-letters-key only serves as some sort of key-protected, "first entrance" to get to the database for which you would still need the regular key file to decrypt it. If it wasn't like that, then there would not be any use for the regular / former key file once you enable E2EE-backup encryption, HOWEVER, even with that enabled, the regular key file is still stored in the WhatsApp directory, as I found out by extracting it.
A thought that was just coming to my mind how to detect if WA still saves old keys on their servers: As far as I understand it, the key for a backup (if available on the server) is re-assigned DURING or AFTER restoring the backup. Since I never saved any keys and all those backups always worked on a new device shortly after, this means, WA gets a new (or same) key from its servers during or after restoring the backup. So that seems to be the only way to find out, if they're still there on their server. In order to do that, though, I would need to get WhatsApp to "see" and "detect" the old backup in the first place, which currently it doesn't. Reading posts on here where a user even (successfully) switched to an entirely new number using an old backup from a different number, I believe there kind of must be a way to get those old backups running again, even if my phone number wasn't the same anymore? Since I still have the same number though, this would probably make things a bit easier in the beginning: so changing the header/footer of an old backup with the information of the most recent one and then hoping that this will trigger WhatsApp to "see" the backup. If they still have a key for that backup, then restoring should work just as it always did for me, never having saved the actual local keys, right? Or am I missing something? |
Beta Was this translation helpful? Give feedback.
-
Update: So I finally found someone who claims to know about WA databases and SQL and who said he'd merged several databases himself before. For example: I was trying to merge a few chats WITHIN THE SAME database together (it's not the main task that I've been outlining above with the messed up JIDs and all that, but a small side quest). A contact of mine has changed numbers 3 times which led to WA creating new chats for the same contact with every number. On Termux I navigated to the path where I placed the database on the phone and entered:
So I wanted to replace all 39s with 38s and it did work. However, this only applied to the message-table and not to all the other tables containing chat_row_ids. So that guy helping me wrote a script that would affect ALL tables containing chat-row-Ids, looking like this:
Luckily, I could root an old phone of mine so I didn't have to go through the troubles of re-encrypting the databases. I simply put the modified database into ROOT data/data/whatsapp.com/Databases where whatsapp stores all the databases unencrypted. However, after opening WhatsApp I got an error message claiming that there has been a problem with my database and it asked me whether I want to restore or skip. By tapping restore it will restore the stage as it was before I put the modified version. Probably it's using the encrypted crypt15 backup in the database folder to restore. If I tap on skip, it will reset the entire database and all the chats are gone - only the group chats are left, but empty. And now the funny thing: But WhatsApp itself doesn't want to accept the modified database in the ROOT directory. The guy who's helping me tested it for himself and merged his own chats and for him it's working, with the exact same script and by putting the modified db into the ROOT directory (he's rooted too). He said I should try and make very minor changes to the original DB just to test if WA still comes up with an error. So I opened up the original db and made tiny changes to 1 text message in Text_Data. I only changed one letter or two. Then saved it with DB Browser and inserted it into the ROOT directory. And yes.. even those tiny letter changes (with all the rest of the DB being original) was enough for WA to again show me the message and asking me to either skip or restore the chat history as there has been a problem. So it seems as if even the tiniest changes to my original DB would not be accepted by WA. For him, it seems to work, though. Would you know what the problem might be? He's almost on the same WA version like me. Did you encounter the same problems while modifying your database? Did we overlook something? Thanks a lot for your thoughts and help! |
Beta Was this translation helpful? Give feedback.
-
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!
Beta Was this translation helpful? Give feedback.
All reactions