yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] beracheng:
30 August 2022

Very interesting topic indeed. As a software engineer this thread has been very informative.

To the new people looking to make this work here are some noob pointers:

- Use V.4.7. The first version and the last version don't work.

- Download the legacy whatsapp version and copy it locally into temp with the rename

- Make sure java is on your pc by typing the java querry command (which you can see initially in this post) in your command console

- Also, very important. Enable internet on your phone. Else whatsapp legacy crashes. Whatsapp works both locally and on their servers.

Now for us developpers, let's get to the serious discussions. This method works, or at least it used to work / works in certain conditions.

For me, everthing worked except the key. They key was not found to be extracted. The database yes.

I thought this problem was a local problem for me, but it turned out that I'm not the only one experiencing this. There is a guy who forked this project and used python has opened an issue about this on his github.

Here's my use case: Whatsapp database on an old phone. Same whatsapp account used on another phone. Whatsapp no longer works on old phone.

It seems like "key" is either no longer named "key" or the folder it's placed into is no longer in /f/.

Is it related to the use case? Is, in specific cases, key moved or renamed?

Would be very interesting if the code did a /list command of all files present before extracting.

Under which circumstances this happens? I have no idea. But I'm definitely working on this, and if anyone has any clue on what is going on feel free to chip in.

edit: specifications Samsung S9 Android 10

There are no solutions I'm aware off to extract key for my phone, this was the last hopium, and I'm still hopeful someone smarter than me can figure this out. Rooting is the last thing that needs to be done as it wipes out everything including the key. The only solution is adb transfer.

Edit:

I just went through the code and modified it. I'm keeping the tar file to look personally.

I will keep you guys updated of my findings
[Android Apps and Games] beracheng:
Interdasting.

I found something called "keystore.xml" that has some encryption keys.

Edit: Don't think it's related. Not an expert on how whatsapp works. But unless that is the key, then unfortunately there is no key.
[Android Apps and Games] beracheng:
Okay my conclusions have been non conclusive.

Here's a warning to all new comers:

I repeat, if you want to retrieve the key of an old phone, DO NOT CONNECT your phone to the internet.

If whatsapp connects to the internet and finds out you use your whatsapp account on another phone, they will delete your key file (or change the name of it)

DO NOT CONNECT TO THE INTERNET OR THE KEY FILE WILL BE LOST
[Android Apps and Games] beracheng:
Adding a very generous bounty to whoever solves this problem by the way
[Android Apps and Games] nawaitesidah:
Same case for me, whatsapp get suspended / banned, then can't login. Is the key still there?

And what do you mean by registering same number, I thought if you're flagged, can't reregister again?

Any experience on flagged account? I've read a github issue here pointing out that he failed to get the key.

Btw with there's whatsapp desktop / web running around, is it possible to get the key from there?
[Android Apps and Games] beracheng:
If you haven't changed your account, you can get the key easily.

I have no idea how the user you quoted managed to decrypt msgdb without a key ( a huge mystery ) , but whatever you do, if you changed phones, don't connect to the internet.

I have modified the code and querried the files extracted. There are no keys at all under that specific circumstance. It immediately gets deleted, and then you can't retrieve anything at all.
[Android Apps and Games] frenstoc:
Having the same problem right now, did you manage it?
[Android Apps and Games] solemgar:
This method still works for Oneplus 9pro Android 13, but it has some new twists.

Latest whatsapp viewer can't decrypt backups or open the conversations as-is due to slight changes to the encryption plus messages format in the sql database.

Hope you find this helpful.

To decrypt .14 files, use this instead:

GitHub - ElDavoo/wa-crypt-tools: Manage WhatsApp .crypt12, .crypt14 and .crypt15 files.

Manage WhatsApp .crypt12, .crypt14 and .crypt15 files. - ElDavoo/wa-crypt-tools

github.com

Two different errors: older version of WhatsApp Viewer and no such table: chat_list · Issue #151 · andreas-mausch/whatsapp-viewer

Using the WhatsApp extractor (YuvrajRaghuvanshiS / WhatsApp-Key-Database-Extractor) which will output some files including the key and msgstore.db. So, using the version 1.15 to open the msgstore.d...

github.com

To open the new database file format after obtaining the files with the extractor, here are the instructions on how to create the needed tables in the SQL database so the viewer can process them:

Two different errors: older version of WhatsApp Viewer and no such table: chat_list · Issue #151 · andreas-mausch/whatsapp-viewer

Using the WhatsApp extractor (YuvrajRaghuvanshiS / WhatsApp-Key-Database-Extractor) which will output some files including the key and msgstore.db. So, using the version 1.15 to open the msgstore.d...

github.com
[Android Apps and Games] _tnt_:
Is there any way to extract the key file on Android 13 without rooting the phone? I have a Pixel 7 Pro and to root the phone I would need to reset it, but I would like to get the key without rooting/resetting the phone. Any chance?
[Android Apps and Games] dinamo1975:
Why appear these errors from JAVA?
[Android Apps and Games] alecxs:
read the first line. if you don't understand, search for it. proceed with next line.
[Android Apps and Games] borisvp:
Hello,

I have an old HTC Desice C with Android 4.0.3. WhatsApp version was 2.6.9458, the msgstore is a crypt8 file (msgstore.db.crypt8). It has a chat which I would very much like to revocer and save on PC. All files are in the folder WhatsApp in the phone's main storage.

As advised, I read the last 10 pages of this thread and tried a couple things, but with no success. I kept getting this message:

Please connect your Android device with USB Debugging enabled:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *

WhatsApp 2.6.9458 installed

Found legacy WhatsApp 2.11.431 in local folder

Backing up WhatsApp 2.6.9458
5185 KB/s (4787631 bytes in 0.901s)
Backup complete

Installing legacy WhatsApp 2.11.431
5284 KB/s (18329558 bytes in 3.386s)
pkg: /data/local/tmp/LegacyWhatsApp.apk
Success
rm failed for -f, No such file or directory
Install complete

Now unlock your device and confirm the backup operation.

Please enter your backup password (leave blank for none) and press Enter:

bin\tar.exe: apps/com.whatsapp/f/key: Not found in archive
bin\tar.exe: Error exit delayed from previous errors
bin\tar.exe: apps/com.whatsapp/db/msgstore.db: Not found in archive
bin\tar.exe: Error exit delayed from previous errors
bin\tar.exe: apps/com.whatsapp/db/wa.db: Not found in archive
bin\tar.exe: Error exit delayed from previous errors
bin\tar.exe: apps/com.whatsapp/db/axolotl.db: Not found in archive
bin\tar.exe: Error exit delayed from previous errors
bin\tar.exe: apps/com.whatsapp/db/chatsettings.db: Not found in archive
bin\tar.exe: Error exit delayed from previous errors

Cleaning up temporary files ...

Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor\tmp\whatsapp.ab
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor\tmp\whatsapp.tar
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor\tmp\waplen.txt
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor\tmp\sdpath.txt
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor\tmp\wapath.txt
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor\tmp\wapver.txt
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor\tmp\sdkver.txt

Done

Restoring WhatsApp 2.6.9458
5463 KB/s (4787631 bytes in 0.855s)
pkg: /data/local/tmp/com.whatsapp-2.apk
Success
rm failed for -f, No such file or directory

Restore complete

Removing WhatsApp 2.6.9458 temporary apk
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor\tmp\com.whatsapp-2.apk

Operation complete

On the last try, the script got somehow interrupted and faild to recover the old WhatsApp version. I'm now on 2.11.431 an only get this:

Please connect your Android device with USB Debugging enabled:

* daemon not running. starting it now on port 5037 *
* daemon started successfully *

WhatsApp 2.11.431 installed

Operation failed

Operation complete

Anything else I can do?

Boris
[Android Apps and Games] alecxs:
try a simple adb backup. it will work on Legacy v2.11.431 and should have worked all the time on lower versions.

adb backup com.whatsapp

(backup password is optional, can be left blank on the confirmation screen)

once you have the backup.ab extract it with java and tar with 7zip. you will find the plain unencrypted msgstore.db inside, and also the key for decrypting msgstore.db.crypt8 if still needed.

java.exe -jar abe.jar unpack backup.ab backup.tar [password]
[Android Apps and Games] borisvp:
I downloaded the ADB "platform tools" and opened a Power Shell in its folder.

adb backup creates a backup.ab with 1kB.

The second command says "unable to access jarfile abe.jar", so I'm obviously missing this file.

I'm no programmer and do not know which tools and files I need to do this. Anything else I can try?
[Android Apps and Games] alecxs:
something is wrong with adb backup, 1 Kb ist too less. try with another app first you know for sure it has android:allowBackup="true" in its manifest, for example org.fdroid.fdroid.

abe.jar must downloaded from here.
[Android Apps and Games] borisvp:
Which manifest and where do I find this?

What do I do with abe.jar?
[Android Apps and Games] WoKoschekk:
I did try it myself now for more than one hour and ran from one error to the next. it's horrible!!

Here is an EASY way to get that key file:

Install BlueStcks, install Whatsapp, root Bluestacks and grep that key. Done!
[Android Apps and Games] alecxs:
The AndroidManifest.xml file is part of the apk file of each app. The attribute is chosen by the app developer, you can't change that.

This wrapper script does uninstall WhatsApp (while preserving app data with the -k flag) and install the legacy WhatsApp version (the last version that allowed adb backup) then creates adb backup (which contains the app data) and extract the key. Due the changes in android the old script needs to adapted to run properly on recent android versions.

or just do the steps manually, where abe.jar comes in game. with this you extract the backup.
[Android Apps and Games] WoKoschekk:
and how to fix "installation error version downgrade" when installing the legacy apk?
[Android Apps and Games] alecxs:
downgrade used to be forced with -d flag but usage may have changed. if you read this thread you find that a reboot might necessary, but I am too lazy to search. some people managed on android 13 and I believe there is a updated script somewhere in this thread.
[Android Apps and Games] WoKoschekk:
...only for debuggable packages, see pm --help.

I'll try the reboot method. I'm editing the script already by myself to make it work by manually testing every line of it. Let's see...
[Android Apps and Games] alecxs:
How to Downgrade an App on Android - No Root Needed

How to easily downgrade an app on Android and retain all of its data. No root access needed on the device at all, just a simple ADB command!

www.xda-developers.com

The method might outdated, so on recent android could be it works only for debuggable apps ... same as the allowBackup flag which is also deprecated.

another thing is the location of apk must be /data/local/tmp otherwise install will fail.
[Android Apps and Games] WoKoschekk:
yes, I know... thx to adb's error output.
[Android Apps and Games] alecxs:
page 30 was the manual method and page 31 linked a fixed version with success. then there is another tool. https://xdaforums.com/t/tool-whatsa...ot-updated-october-2016.2770982/post-84433601 but I realized it's few years back lol

thus one confirmed android 11

https://xdaforums.com/t/tool-whatsa...ot-updated-october-2016.2770982/post-86421495

and here is an additional warning regarding the key

https://xdaforums.com/t/tool-whatsa...ot-updated-october-2016.2770982/post-87370493
[Android Apps and Games] WoKoschekk:
*********************************************************************

#####>>>>> WhatsApp-Key-DB-Extractor-REBOOT <<<<<#####

*********************************************************************​

by @TripCode​

UPDATE:

To allow VERSION_DOWNGRADE script does a reboot before installing LegacyWhatsApp.apk​

#####

more changes:

added ADB v1.0.41 (Platform Tools v33.0.2-8557947)​

added abe.jar (https://github.com/nelenkov/android...ownload/master-20221109063121-8fdfc5e/abe.jar) thx @alecxs for this link​

including /tmp/LegacyWhatsApp.apk v2.11.431​

Instructions:

Unpack the ZIP, connect your phone with ADB enabled and run the batch file.

Reboot will be initiated by the script

To continue the script after reboot just press any key

DO NOT UNPLUG THE DEVICE DURING REBOOT!!

UNLOCK YOUR DISPLAY AFTER REBOOT IS DONE AND BEFORE PROCEEDING FURTHER!!

Extracted files are valid (see screenshots) and WhatsApp gets fully restored.

*** Tested with Moto G6 Plus, Android 9, Stock ROM rooted ***

>>> THX @TripCode for creating and sharing this tool with us!!!

###################################################################################

!! EDIT: Be aware that the key also will be stored in your WhatsApp folder

beside your chat backups

on the internal storage of your device!!

up to Android 9:

/storage/emulated/0/WhatsApp/Databases/.nomedia

Android 10+:

/storage/emulated/0/Android/media/com.whatsapp/WhatsApp/Databases/.nomedia

Yes, it's the '.nomedia' file. By default such files are empty (but this file's not) and also hidden by a prefixed "." (see options of your file browser).

###################################################################################
[Android Apps and Games] borisvp:
OK, I installed Bluestacks and Whatsapp (current version from the store). I also can activate it forth and back between my phone and the PC. Where does the msgstore.db.crypt8 file go to access the chat I'm looking for?

Installing a WA backup from Google won't help, because that chat is not in the backup.
[Android Apps and Games] WoKoschekk:
why didn't try the tool above? it should copy the key within seconds.

if you wanna use BlueStacks it must be rooted first.
[Android Apps and Games] borisvp:
I already did. The extractor extracted nothing. Version 4.7 downgraded WA to 2.11.431 and does now nothing anymore, the REBOOT version does not even connect.

What does "ADB enabled" mean? What do I have to do for this?

I do not have a folder /storage/emulated/0/WhatsApp/Databases/.nomedia on my device (Android 4.0.3). There is just \WhatsApp and \Android\data\com.whatsapp
[Android Apps and Games] WoKoschekk:
Do you have any device with a newer version of Android??
[Android Apps and Games] borisvp:
I do. My current phone.

The old device (4.0.3) has the first part of a chat I would like to export somehow, preferably with Zapptales (that's a service which makes "books" from your chats). The rest of that chat (which went from 2015 to 2022) is already secured.
[Android Apps and Games] WoKoschekk:
you have a backup of this first part that is called "msgstore.db.crypt8"? Is that right?

You want to decrypt this backup and for that you need the key file?
[Android Apps and Games] borisvp:
Correct. I have this file on my PC.

On the old device, WA won't start anymore. The current phone / current WA won't open that file.
[Android Apps and Games] WoKoschekk:
Ok. And the first part of your chats (old) comes from the same mobile no./account that you still use on the current version of WhatsApp? You haven't changed the mobile no.?
[Android Apps and Games] alecxs:
WhatsApp does not open? Have you tried simply dating the time back to 2015 in flight mode?
[Android Apps and Games] WoKoschekk:
You need an online connection.
[Android Apps and Games] borisvp:
Still the same mobile number.

I tried and turned off automatic date/time, set it back to 03-04-2015, since 2.11.431 outdates on 04-04-2015. WA then wants to verify my number by sending an SMS to that numer (which would be my current phone), but fails due to no internet connection.

The device, however, is connected to WiFi and has internet access.
[Android Apps and Games] alecxs:
if it wants to verify your app data is maybe gone.
[Android Apps and Games] WoKoschekk:
Take your current phone and make a backup of WA. Then use that tool and extract the key. The key is the same as long as your mobile no. is the same. With that key you can decrypt your msgstore.db.crypt8.
[Android Apps and Games] alecxs:
that is the most promising information ever heard and a game changer.
[Android Apps and Games] WoKoschekk:
the key must remain the same. your account = your mobile no.
[Android Apps and Games] borisvp:
OK, I tried a backup on my current phone, which gave me a whatsapp.ab of about 51MB in the tmp folder.

Then I got this:

Please enter your backup password (leave blank for none) and press Enter:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/nick/abe/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now
bin\tar.exe: Cannot open tmp\whatsapp.tar: No such file or directory
bin\tar.exe: Error is not recoverable: exiting now

Cleaning up temporary files ...

Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor-REBOOT\tmp\whatsapp.ab
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor-REBOOT\tmp\waplen.txt
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor-REBOOT\tmp\sdpath.txt
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor-REBOOT\tmp\wapath.txt
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor-REBOOT\tmp\wapver.txt
Datei wurde gelöscht - C:\Users\boris\Downloads\WhatsApp-Key-DB-Extractor-REBOOT\tmp\sdkver.txt

Done

On my PC, I updated Java from the Java website, version is 1.8.0_371.

I saved the whatsapp.ab file before it got deleted, if this helps.
[Android Apps and Games] WoKoschekk:
install this one

https://www.oracle.com/de/java/technologies/downloads/#jdk20-windows

Java Development Kit 20
[Android Apps and Games] borisvp:
Now it did something. I got a "cipher key"

Pushing cipher key to: /sdcard/WhatsApp/Databases/.nomedia

I found it, however, in the internal storage in \WhatsApp\Databases, not on the SD card. It has 158B.

I got some more files in the "extracted" folder:

axolotl.db

chatsettings.db

msgstore.db (that one has 85MB now)

wa.db

whatsapp.cryptkey (which appears to be the same as the .nomedia file)

But none of the combinations of db files and keys work with WhatsApp Viewer. When I try to open msgstore.db with wa.db, it tells me that I tried to open an older WhatsApp database (u don't say!) and that I should use an older version of WhatsApp Viewer.

Which one might work here, if any? I have 1.15
[Android Apps and Games] borisvp:
Oh, and now WhatsApp has lost all my contacts. It just shown the phone numbers, not the names from my contact list. How do I get this back?
[Android Apps and Games] WoKoschekk:
grant the permission for contacts
[Android Apps and Games] WoKoschekk:
What did u extract? the old or the new WhatsApp?
[Android Apps and Games] borisvp:
Got my contact names back, thanks.

As per your advice, I extracted from the current phone to get the key, which should be the same as it was for the old phone, since my number didn't change.
[Android Apps and Games] WoKoschekk:
I don't know which tool is linked here in the thread but I used the one in the attachment a few years ago. Just try it.
[Android Apps and Games] borisvp:
When I use WhatsApp Viewer with the old crypt8 file and the key I extracted from my current phone, it tells me the key is invalid...