Transferring WhatsApp chat logs from Android to iOS using only open-source tools

Disclaimers⌗
If you think you can skip this, this is specifically for you!
- This will only restore text messages, no videos, no photos, no stickers, no This message was deleted (it’ll come as
<revoked>
, instead), just text messages, nothing more. - WhatsApp (at time of writing) has officially announced iOS to Android migration support with support for vice-versa presumed to be incoming, if this option is available to you, please use it, do not use this guide if you can help it!
- We are in essence, tampering with unencrypted iTunes backups, if that causes thermonuclear warfare or the spilling of state secrets, don’t point your finger at me
- These steps could break at any moment
The hardware we need⌗
-
An Android device with USB debugging enabled (this differs from platform to platform so there isn’t a catch-all method I can write about, some device manufacturers even change the tap-build-number-ten-times to access Developer Mode method to something else, so Google is your friend.)
P.S.: Some devices reset the Enable USB Debugging setting on every reboot, please ensure before executing any commands that you’ve re-enabled it in case your phone pulls such shenanigans
-
An iPhone with Find My disabled (you can’t restore an unencrypted iTunes backup using
AppleMobileBackup
otherwise) -
A computer that runs macOS (you can do this in a virtual machine if you need to but I’m afraid we can’t use Windows or Linux, if this changes, please let me know!)
-
The necessary cables (of decent quality, never cheap out on data cables) to attach said devices
The software we need⌗
-
MobileDevice.framework
'sAppleMobileBackup
, located at/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/Current/AppleMobileDeviceHelper.app/Contents/Resources/AppleMobileBackup
(we’ll use an alias so we don’t have to type so much), it comes installed on macOS -
A patched version of residentsummer’s WhatsApp Android To iOS Importer
Additional Note: Patches are courtesy of DennieTeMolder and LukasACH, my repo just cherry-picked them.
-
A terminal with Full Disk Access enabled (go to System Preferences > Security & Privacy > Privacy > Full Disk Access and add your terminal of choice using the + button)
Retrieving our chats⌗
We’re going to follow the instructions from the WhatsApp-Key-Database-Extractor’s repository. Once you’ve finished following the instructions in the README file, you’ll hopefully have:
- Enabled USB debugging on your Android device
- Created a “local backup” of your WhatsApp conversations, then switched off internet access (both Wifi & Cellular)
- Added your computer as a trusted system (this will pop up when the first
adb
commands launch) - Installed all the dependencies WhatsApp-Key-Database-Extractor needs
- Successfully run the first half script successfully the first time
- Have your phone reboot, with a legacy version of WhatsApp installed after (psst, if something goes wrong, check your Developer Settings again)
- Received a prompt asking for permission to backup your files, that you agreed to (I’d not bother setting a password but that’s up to you)
- Find a
.tar
archive inside theextracted
directory of WhatsApp-Key-Database-Extractor - Extract said archive, then go three directory layers deep (
apps/com.whatsapp/db
) and copy the path ofmsgstore.db
and note it down somewhere
Okay, we don’t need our Android device anymore, we’re now going to the iPhone.
Backing up our iPhone⌗
You could use iTunes or Finder (if you’re running more recent versions of macOS) but for some reason I was having constant freezes in Finder, so I needed to resort to using the command line. If iTunes and Finder work for you, then you can ignore these steps and do an unencrypted backup as usual, then skip forward. Go this route as a matter of last resort
- Create an alias for
AppleMobileBackup
alias amb="/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/Current/AppleMobileDeviceHelper.app/Contents/Resources/AppleMobileBackup"
- Fetch the UDID of our iPhone (after you’ve granted the computer permissions to access the contents of your iPhone)
system_profiler SPUSBDataType | sed -n -E -e '/(iPhone|iPad)/,/Serial/s/ *Serial Number: *(.+)/\1/p'
You’ll get a string akin to ffffffffffffffffffffffffffffffffffffffff
in length, copy it down, you’ll need it.
-
Open the “Enable Unified Log Private Data” profile you’ve downloaded, then go to System Preferences > Profiles > Install (this is because
AppleMobileBackup
only throws errors in the Console application, not to stdout/stderr and they’re hidden behind<private>
tags, this will reveal them, which will help us debug in case anything goes wrong.)Do remember to uninstall this profile after you’re done. See below for how your logs should look like after you uninstall the profile.
-
Now backup your iPhone using
AppleMobileBackup
, monitor its behaviour usingConsole.app
to make sure there aren’t any errors (but you can ignore theInfo.plist
warning)
amb --backup --source ffffffffffffffffffffffffffffffffffffffff # replace this with your UUID
Fetching a copy of WhatsApp from the App Store⌗
watoi
needs a copy of WhatsApp.ipa
(basically, the package that contains WhatsApp for iOS) to perform its magic and while
you could download it from a website claiming to mirror it from Apple’s servers, we’ll use Apple’s official utilities instead.
Do update WhatsApp on your local device so that we have the same version that’s installed from the App Store onto your device and
fetched from the App Store onto our Desktop.
These steps are screenshots courtesy of cormiertyshawn895’s Retroactive
Author’s note: I wanted to display the instructions given without asking users to download and run another application, especially since it isn’t directly related to the guide (iTunes dropped support for what we’re looking for, hence the need for Configurator 2) and the Wiki page redirects me to the README of the repository, if these steps are documented in writing, I’ll be more than happy to link there instead of using screenshots. Also, your program is amazing :) Much love!
- Open Apple Configurator 2 (you do have your iPhone plugged in, right?) and follow the steps below
-
Once you’ve copied
WhatsApp
to the Desktop, you’ll hopefully have something like thisNote: You should probably rename this file, I noticed that this file has some weird characters prefixed to it when running
ls
, so renaming it will get rid of that
Modifying the WhatsApp database of our iPhone backup⌗
It’s the same story as Retrieving our chats, we’re following the instructions provided on watoi
's README, hopefully, you’ll have:
- Cloned the repository and built
watoi
in the terminal - Verify that your unencrypted iPhone backup is stored to disk and is readable
- Provide the path of the recently downloaded
WhatsApp.ipa
and extract its contents to theapp
directory withinwatoi
- Backup your original WhatsApp chat database
- Find the path where
msgstore.db
is located (you did note it down, right?) and execute the migration script with that path (hopefully successfully, if not, then you’ll probably need additional patches) - Modify your iTunes backup to contain your “updated” WhatsApp message history
Restoring the modified iPhone backup⌗
This presumes you used AppleMobileBackup
to perform your backup, I dunno what the steps are for iTunes/Finder cause I run Big Sur and Finder
is buggy as all hell, hence my use of the terminal. Google is your friend ;)
-
Turn off Find My (iPhone),
AppleMobileBackup
does not play nice otherwise (see below) -
Run the restore command
amb --restore # use `--restore --target ffffffffffffffffffffffffffffffffffffffff` if this doesn't work for some reason
- Your iPhone should show you a white background, black logo and progress bar when restoring itself, then you’ll be greeted with a screen where you enter your iCloud credentials again, set up Siri, etc.
Hopefully we’re successful in restoring our WhatsApp conversation history. Like I said, it’s text conversations only so images will be replaced with <images>
and deleted messages with <revoked>
P.S: You should probably go to ~/Library/Application Support/MobileSync/Backup/
and delete your unencrypted iPhone backups, just saying