A method and system for restoring WhatsApp data from an iOS device to an Android device, a storage medium, and a computer system

By obtaining and converting WhatsApp backup packets from the IOS side, encrypting and using uiautomator command to automatically process the Android page structure, the problem of high risk and low success rate in the migration process of WhatsApp data from IOS to Android is solved, and high efficiency is achieved , secure data migration.

CN116781819BActive Publication Date: 2025-02-11CHENGDU YIWO TECH DEV CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310750393.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-25
Publication Date
2025-02-11
Estimated Expiration
2043-06-25

AI Technical Summary

Technical Problem

The existing WhatsApp data migration methods have high risks, long processes, low success rates, and deep intervention of users to reduce success rates, especially during the migration process from IOS to Android.

Method used

A WhatsApp data restoration method is adopted from the IOS end to the Android end, which includes obtaining backup data packets from the IOS end and converting them into Android format, encrypting and forming an encrypted file, and automatically processing the page structure of the target Android end through the uiautomator command to realize data restoration.

Benefits of technology

It realizes WhatsApp data migration from the IOS end to the Android end, with strong adaptability and high success rate, no need to request secret keys from the server side, and the automated process reduces user intervention and improves security and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116781819B_ABST
    Figure CN116781819B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of data restoration, and discloses a method and system, storage medium, and computer system for restoring WhatsApp data from an IOS terminal to an Android terminal. The method comprises: obtaining a WhatsApp backup data packet from a source IOS terminal, and converting the backup data packet into an Android-formatted WhatsApp backup data packet; encrypting the Android-formatted WhatsApp backup data packet to form an encrypted file; transmitting the encrypted file to a target Android terminal, and starting WhatsApp to restore data. The local end-to-end 64-bit encryption algorithm described in the present invention does not need to request a secret key from a WhatsApp server, and uses client-side calculation to generate a 64-bit secret key, which does not involve user account secret key information and is safer. At the same time, the entire data restoration process is performed automatically, which greatly improves the convenience of use.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data restoration, and in particular relates to a method and system, a storage medium, and a computer system for restoring WhatsApp data from an iOS terminal to an Android terminal. Background Art

[0002] WhatsApp is a popular instant messaging application that allows users to send text messages, make voice and video calls, share photos, videos, documents and create group chats. It was acquired by Facebook in 2014 and currently has more than 2 billion active users worldwide. WhatsApp is available on Android and iOS devices, as well as desktop and web versions. It uses end-to-end encryption to protect the privacy and security of user data. Due to the differences in encryption methods between IOS and Android, users can only transfer data between Android and Android devices, or between IOS and IOS devices, but not from IOS to Android.

[0003] There are three main ways for existing third parties to migrate data across systems:

[0004] The first method is to restore the WhatsApp software by downgrading the app. The Android adb restore function is called to restore the constructed backup package to the directory of the WhatsApp software. The backup package contains the converted text data. After the restore, the latest WhatsApp software is reinstalled. After logging in to the account again, the migrated data will be loaded.

[0005] The second method is to modify and decompile the Android WhatsApp app to obtain the smali code, and then add custom code to copy the external chat record database to the data directory of WhatsApp through the custom code. Because the code of the original app has been modified, it needs to be recompiled, packaged and re-signed. Install the re-signed apk file on the Android device, and it will automatically copy the external chat records to the data directory of the WhatsApp software after startup, and then load the migrated data after re-login.

[0006] The third method is to use the user's WhatsApp account to complete the local authentication of the software client to request the encryption key from the WhatsApp server. The obtained encryption key is used to encrypt and compress the WhatsApp information database, and then the encrypted data package is copied to the WhatsApp memory backup directory of the Android device. After the WhatsApp data migration is completed, no further processing is done, and the remaining data recovery steps are left for the user to complete manually according to the prompts.

[0007] However, the above three methods all have obvious defects.

[0008] The first method is to restore the old version of WhatsApp by installing it. When installing a new old version of WhatsApp, the user's existing data may be automatically deleted. However, due to the cluttered Android application market and the proliferation of rogue applications, mobile phone manufacturers have strengthened restrictions on the installation of external applications, thereby restricting the installation of third-party applications, resulting in an increase in the failure rate of installation. In addition, the new old version of WhatsApp cannot be opened and used by itself, and the adb command needs to be called to install the application. Calling the adb restore command to restore Android data is a whole machine restore interface, which is risky and may delete and replace other data on the Android device. It can be seen that the migration process is long and the success rate is low.

[0009] The second method is to modify the original WhatsApp software by decompiling and adding data copying code. This also requires forcibly uninstalling the existing WhatsApp and installing a custom modified WhatsApp version, which poses the risk of deleting existing data. At the same time, because the WhatsApp app is decompiled, the code will be modified, the existing signature will be destroyed, and a custom signature will be added to pass the Android installation check, resulting in users using pirated apps, which poses legal risks, and subsequent pirated apps cannot be upgraded to the latest WhatsApp. As an untrusted third-party application, the installation success rate will also be reduced. In addition, WhatsApp versions are updated very quickly, with a new version basically every 2 to 3 days. Old versions before January cannot be logged in, so regular maintenance is required to make custom modifications based on the latest version.

[0010] Although the third method does not require uninstalling and installing the App, nor does it require decompiling and modifying the original WhatsApp software to add data copying code. However, the third method requires simulating the user account to request data from the WhatsApp server and simulate the user login process. This process poses a risk to user privacy. This solution requires the user to provide WhatsApp account information and authorize it, which may involve the risk of user privacy leakage. Although the official software in this solution claims that it will not store the user's encryption key, user information still needs to be transmitted in the client local authentication, which poses certain security risks. From the perspective of encryption key security, this solution uses the method of obtaining encryption keys to encrypt and compress the WhatsApp information database. Although this solution uses encryption compression and other technologies to ensure data security, it does not use the most advanced encryption technology and there is a risk of being attacked. In short, this solution has certain shortcomings and deficiencies in terms of user privacy and encryption key security, and data security measures need to be further improved and strengthened. In particular, after completing the data migration, the user needs to perform a lot of manual operations according to the prompt page to achieve the WhatsApp data migration on the Android device. The deep involvement of the user will lead to a lower success rate and increased complexity, and the solution needs to be further optimized.

[0011] It can be seen that the three commonly used methods of WhatsApp software data migration all have obvious high risks, long processes, and shortcomings such as users' deep involvement in operations that reduce the success rate. Summary of the invention

[0012] In view of this, the present invention provides a method and system, a storage medium, and a computer system for restoring WhatsApp data from an iOS terminal to an Android terminal, which have strong adaptability, a high restoration success rate, no need to request a secret key from a server, and high security.

[0013] In order to solve the above technical problems, the technical solution of the present invention is to adopt a method for restoring WhatsApp data from an iOS terminal to an Android terminal, comprising:

[0014] Obtain a WhatsApp backup data package from a source iOS device, and convert the backup data package into a WhatsApp backup data package in an Android format;

[0015] Encrypt the WhatsApp backup data package in Android format to form an encrypted file, including:

[0016] Compress the WhatsApp backup data package in Android format to form a compressed data file;

[0017] Get the version information of WhatsApp on the target Android device and the login account to be restored;

[0018] Generate the 16-byte encryption initial vector data required by the AES GCM encryption algorithm through a random function;

[0019] Write the WhatsApp version number, the last two characters of the login account, and the encrypted initial vector data as header information into the encrypted file header;

[0020] A 32-byte encryption key is randomly generated and converted into hexadecimal data to form a 64-bit encryption key;

[0021] Use the 64-bit encryption key to encrypt the compressed data file using the AES GCM algorithm;

[0022] Add the encrypted compressed data file to the encrypted file after the header file information as a data segment;

[0023] Calculate the HASH value of the encrypted file and add the HASH value to the encrypted file after the compressed data file as the file tail;

[0024] Transfer the encrypted file to the target Android device and launch WhatsApp to restore the data.

[0025] As an improvement, the method of starting WhatsApp to restore data includes:

[0026] Launch WhatsApp on the target Android device, send the uiautomator command to grab the device's current page hierarchy to find the login button, and automatically simulate clicking the login button to jump to the account login page;

[0027] Send the uiautomator command to grab the current page hierarchy of the device to find the account input box and the next button, and use the adb shell input text command to automatically enter the login account to be restored and simulate clicking the next button to jump to the verification code page;

[0028] Determine whether WhatsApp has permission to read SMS messages. If so, read the SMS verification code and enter the verification code through the adbshell input text command; if not, remind the user to enter the verification code manually;

[0029] Send the uiautomator command to grab the current page hierarchy of the device to find the authorization pop-up window and the authorization button on the authorization pop-up window, simulate clicking the authorization button to obtain authorization to access the address book and media of the target Android terminal and jump to the restore backup page;

[0030] Send the uiautomator command to grab the current page hierarchy of the device to find the restore button, and simulate the restore button to enter the backup decryption page;

[0031] Send the uiautomator command to grab the device's current page hierarchy to find the end-to-end encryption password item and simulate the selection;

[0032] Enter the 64-bit encryption key through the adb shell input text command for decryption;

[0033] After decryption is complete, send the uiautomator command to grab the current page hierarchy of the device and find the next button to enter the personal information page, thereby completing the WhatsApp data restoration.

[0034] As an improvement, before restoring data, use the adb command to determine whether the target Android device is in landscape mode. If so, turn off the landscape mode setting to restore the target Android device to portrait mode.

[0035] As another further improvement, when transferring the encrypted file to the target Android terminal, if the Android system version of the target Android terminal is 11 or higher, the encrypted file is transferred to the target Android terminal: / sdcard / Android / media / com.whatsapp / WhatsApp;

[0036] If the target Android device has an Android system version lower than 11, the encrypted file will be transferred to the target Android device: / sdcard / WhatsApp.

[0037] As an improvement, before transferring the encrypted file to the target Android terminal, the WhatsApp login account on the target Android terminal is reset so that the WhatsApp application on the target Android terminal is restored to the initial installation state.

[0038] As an improvement, the libimobiledevice protocol is called to obtain the WhatsApp backup data package on the source iOS side.

[0039] As an improvement, before obtaining the WhatsApp backup data package of the source iOS end, the source iOS end and the target Android end are identified and trusted authorization is obtained.

[0040] The present invention also provides a WhatsApp data restoration system from an iOS terminal to an Android terminal, comprising:

[0041] The device identification module is used to identify the source iOS device and the target Android device and obtain trust authorization; obtain the WhatsApp version information of the target Android device;

[0042] An underlying data conversion module, used for converting the backup data into a WhatsApp backup data package in an Android format;

[0043] The encryption module is used to encrypt the WhatsApp backup data package in Android format to form an encrypted file, including: compressing the WhatsApp backup data package in Android format to form a compressed data file, generating 16-byte encryption initial vector data required by the AES GCM encryption algorithm through a random function; writing the WhatsApp version number, the last two characters of the login account, and the encryption initial vector data as header file information into the encrypted file header; randomly generating a 32-byte encryption key, and converting it into hexadecimal data to form a 64-bit encryption key; using the 64-bit encryption key to encrypt the compressed data file using the AES GCM algorithm; adding the encrypted compressed data file to the encrypted file after the header file information as a data segment; calculating the HASH value of the encrypted file, and adding the HASH value to the encrypted file after the compressed data file as a file tail;

[0044] The recovery module is used to transfer the encrypted files to the target Android device and start WhatsApp to restore the data; it includes:

[0045] Use the adb command to determine whether the target Android device is in landscape mode. If so, turn off the landscape mode setting to restore the target Android device to portrait mode.

[0046] Launch WhatsApp on the target Android device, send the uiautomator command to grab the device's current page hierarchy to find the login button, and automatically simulate clicking the login button to jump to the account login page;

[0047] Send the uiautomator command to grab the current page hierarchy of the device to find the account input box and the next button, and use the adb shell input text command to automatically enter the login account to be restored and simulate clicking the next button to jump to the verification code page;

[0048] Determine whether WhatsApp has permission to read SMS messages. If so, read the SMS verification code and enter the verification code through the adbshell input text command; if not, remind the user to enter the verification code manually;

[0049] Send the uiautomator command to grab the current page hierarchy of the device to find the authorization pop-up window and the authorization button on the authorization pop-up window, simulate clicking the authorization button to obtain authorization to access the address book and media of the target Android terminal and jump to the restore backup page;

[0050] Send the uiautomator command to grab the current page hierarchy of the device to find the restore button, and simulate the restore button to enter the backup decryption page;

[0051] Send the uiautomator command to grab the device's current page hierarchy to find the end-to-end encryption password item and simulate the selection;

[0052] Enter the 64-bit encryption key through the adb shell input text command for decryption;

[0053] After decryption is complete, send the uiautomator command to grab the current page hierarchy of the device and find the next button to enter the personal information page, thereby completing the WhatsApp data restoration.

[0054] The present invention also provides a storage medium, in which a computer program is stored. When the computer program is executed, the above-mentioned method for restoring WhatsApp data from an iOS terminal to an Android terminal can be implemented.

[0055] The present invention also provides a computer system, comprising a processor and a memory, wherein a computer program is stored in the memory, and when the processor executes the computer program, the above-mentioned method for restoring WhatsApp data from an iOS terminal to an Android terminal can be implemented.

[0056] The present invention is beneficial in that:

[0057] The local end-to-end 64-bit encryption algorithm described in the present invention does not need to request a key from the WhatsApp server, but uses client-side calculation to generate a 64-bit key, does not involve user account key information, and is safer. In addition, the local end-to-end 64-bit encryption algorithm is more efficient and has a fast encryption speed, which shortens the entire data transfer time.

[0058] In addition, the present invention adds an automated processing process for the data restoration process, automatically captures and analyzes the target device page structure, and automatically issues script commands to achieve device-side data recovery without user intervention. The fully automated process includes the following key links: WhatsApp startup to login, automatic page jump, migration data search and recovery, automatic issuance of 64-bit end-to-end secret keys, data decryption and analysis until WhatsApp data recovery is completed. The automated process avoids problems such as slow user input and possible errors, can greatly reduce process time, and effectively improve the success rate of data restoration. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 It is a flow chart of the present invention.

[0060] Figure 2 Flowchart for forming an encrypted file.

[0061] Figure 3 Flowchart for automatic data restoration.

[0062] Figure 4 It is a structural principle diagram of the present invention. DETAILED DESCRIPTION

[0063] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is further described in detail below in conjunction with specific implementation methods.

[0064] Chinese patent application CNCN114281805A discloses a data migration method, device and terminal device based on WhatsApp software, the method comprising: the software client opens the permissions of two devices; backs up WhatsApp software data locally; parses WhatsApp software data, converts text data into a newly created information database, and through local authentication, requests the WhatsApp server to obtain an encryption key; encrypts and compresses to obtain an information database encrypted file; constructs file header data of the information database encrypted file; reads the information database, compresses it together with the information database encrypted file with the file header data written in it, and then writes it into a temporary file; encrypts the temporary file to generate a migration file; and completes the WhatsApp data migration by copying the migration file to the WhatsApp memory backup directory of the Android device.

[0065] The above-mentioned prior art completes the local authentication of the software client through the WhatsApp account to request the WhatsApp server to obtain the encryption key, and uses the encryption key officially returned by WhatsApp to encrypt and compress the information database, wherein the version number of the encryption key, the server and the account are derived from the file data of the encryption key. These data are deeply associated with the user account and stored in the WhatsApp official server. Therefore, this solution has user account security issues and involves user privacy.

[0066] In order to solve the above technical problems, Figure 1 As shown, the present invention provides a method for restoring WhatsApp data from an iOS terminal to an Android terminal, and the specific steps thereof include:

[0067] S1 identifies the source iOS device and the target Android device and obtains trust authorization.

[0068] Connect the iOS device (e.g., iPhone, iPad, Mac, etc.) to which WhatsApp data needs to be transferred, and the target Android device (e.g., an Android phone) to the computer. After the computer recognizes the above devices and obtains trust authorization from both devices, it will facilitate subsequent operations.

[0069] S2 calls the libimobiledevice protocol to obtain the WhatsApp backup data package on the source iOS side.

[0070] Through the libimobiledevice protocol, the WhatsApp backup data package stored in the iOS terminal can be copied to the computer disk.

[0071] S3 converts the backup data package into a WhatsApp backup data package in an Android format.

[0072] Prepare the Android WhatsApp restore empty data template backup package on the computer, import the IOS WhatsApp backup data into the empty data template backup package to form the Android WhatsApp data backup package, and process all other non-text messages or attachments, such as pictures, videos, etc.

[0073] S4 encrypts the Android-formatted WhatsApp backup data package to form an encrypted file, including:

[0074] The encryption methods of the iOS and Android are different, so the data between the two ends cannot be verified and cannot be used interchangeably. The purpose of this step is to disguise the data on the iOS side so as to deceive the verification of the Android side.

[0075] like Figure 2 As shown, this step specifically includes:

[0076] S41 compresses the WhatsApp backup data package in Android format to form a compressed data file, which is later encrypted as a data segment of the encrypted file.

[0077] The encrypted file is divided into three parts: file header, data segment and file trailer. The file header is used to store file related information, the data segment is used to store file data, and the file trailer is used to store the check digit.

[0078] In the present invention, an encrypted file needs to be reconstructed, and the encrypted file must comply with the verification rules of the Android-side WhatsApp software.

[0079] S42 obtains the version information of WhatsApp on the target Android device and the login account to be restored.

[0080] During verification, the WhatsApp version information and some information of the login account to be restored will be required, so they need to be obtained in advance.

[0081] S43 generates the 16-byte encryption initial vector data required by the AES GCM encryption algorithm through a random function.

[0082] S44 writes the WhatsApp version number, the last two characters of the login account, and the encrypted initial vector data into the encrypted file header.

[0083] In this step, the WhatsApp version number, the last two characters of the login account, the encrypted initial vector data, and other file header information are written into the file header of the encrypted file according to the rules.

[0084] S45 randomly generates a 32-byte encryption key and converts it into hexadecimal data to form a 64-bit encryption key;

[0085] S46 uses a 64-bit encryption key to encrypt the compressed data file using the AES GCM algorithm;

[0086] S47 adds the encrypted compressed data file into the encrypted file after the header file information as a data segment;

[0087] S48 calculates the HASH value of the encrypted file, and adds the HASH value to the encrypted file after the compressed data file as the file tail.

[0088] After the above steps, an Android backup data package is built. All operations in the process are performed locally on the computer without connecting to the WhatsApp server, which greatly improves security.

[0089] S5 transfers the encrypted file to the target Android device and starts WhatsApp to restore the data. Before the transfer, the WhatsApp login account on the target Android device is reset so that the WhatsApp application on the target Android device is restored to the initial installation state.

[0090] Depending on your Android version, the transfer location will vary slightly.

[0091] If the target Android device's Android system version is 11 or higher, transfer the encrypted file to the target Android device: / sdcard / Android / media / com.whatsapp / WhatsApp;

[0092] If the target Android device has an Android system version lower than 11, the encrypted file will be transferred to the target Android device: / sdcard / WhatsApp.

[0093] In addition, the process of starting WhatsApp to restore data in the present invention is fully automatic, without the need for the user to click or select. The principle is to send a uiautomator command to grab the current page hierarchy dump of the device, analyze the page structure, and thus simulate selection and confirmation. Figure 3 As shown, specifically including:

[0094] S51 determines whether the device is in landscape mode through an adb command. If so, it sends a command to turn off the landscape mode setting, so that the Android device returns to the portrait mode.

[0095] S52 starts WhatsApp on the target Android device, sends the uiautomator command to grab the device's current page hierarchy to find the login button, and automatically simulates clicking the login button to jump to the account login page;

[0096] S53 sends a uiautomator command to grab the current page hierarchy of the device to find the account input box and the next button, automatically inputs the login account to be restored through the adb shell input text command, and simulates clicking the next button to jump to the verification code page;

[0097] S54 determines whether WhatsApp has permission to read SMS messages. If so, it reads the SMS verification code and inputs the verification code through the adbshell input text command; if not, it reminds the user to manually input the verification code;

[0098] S55 sends the uiautomator command to grab the current page hierarchy of the device to find the authorization pop-up window and the authorization button on the authorization pop-up window, simulates clicking the authorization button to obtain authorization to access the address book and media of the target Android terminal and jumps to the restore backup page;

[0099] This page will push the encrypted files transferred in the above steps, as well as operation items such as whether to choose to restore.

[0100] S56 sends the uiautomator command to grab the device's current page hierarchy to find the restore button, and simulates the restore button to enter the backup decryption page;

[0101] S57 sends the uiautomator command to grab the device's current page hierarchy to find the end-to-end encryption password item and simulate the selection;

[0102] S58 uses the adb shell input text command to input the 64-bit encryption key for decryption;

[0103] After S59 decryption is completed, it sends the uiautomator command to grab the current page hierarchy of the device and find the next button to enter the personal information page. The page prompts the user to enter personal information (name and avatar, etc.) to complete the WhatsApp data restoration.

[0104] like Figure 4 As shown, the present invention also provides a WhatsApp data restoration system from an iOS terminal to an Android terminal, comprising:

[0105] The device identification module is used to identify the source iOS device and the target Android device and obtain trust authorization; obtain the WhatsApp version information of the target Android device;

[0106] An underlying data conversion module, used for converting the backup data into a WhatsApp backup data package in an Android format;

[0107] The encryption module is used to encrypt the WhatsApp backup data package in Android format to form an encrypted file, including: compressing the WhatsApp backup data package in Android format to form a compressed data file; generating 16-byte encryption initial vector data required by the AES GCM encryption algorithm through a random function; writing the WhatsApp version number, the last two characters of the login account, and the encryption initial vector data into the encrypted file header as header file information; randomly generating a 32-byte encryption key, and converting it into hexadecimal data to form a 64-bit encryption key; using the 64-bit encryption key to encrypt the compressed data file using the AES GCM algorithm; adding the encrypted compressed data file to the encrypted file after the header file information as a data segment; calculating the HASH value of the encrypted file, and adding the HASH value to the encrypted file after the compressed data file as a file tail;

[0108] The recovery module is used to transfer the encrypted files to the target Android device and start WhatsApp to restore the data; it includes:

[0109] Use the adb command to determine whether the target Android device is in landscape mode. If so, turn off the landscape mode setting to restore the target Android device to portrait mode.

[0110] Launch WhatsApp on the target Android device, send the uiautomator command to grab the device's current page hierarchy to find the login button, and automatically simulate clicking the login button to jump to the account login page;

[0111] Send the uiautomator command to grab the current page hierarchy of the device to find the account input box and the next button, and use the adb shell input text command to automatically enter the login account to be restored and simulate clicking the next button to jump to the verification code page;

[0112] Determine whether WhatsApp has permission to read SMS messages. If so, read the SMS verification code and enter the verification code through the adbshell input text command; if not, remind the user to enter the verification code manually;

[0113] Send the uiautomator command to grab the current page hierarchy of the device to find the authorization pop-up window and the authorization button on the authorization pop-up window, simulate clicking the authorization button to obtain authorization to access the address book and media of the target Android terminal and jump to the restore backup page;

[0114] Send the uiautomator command to grab the current page hierarchy of the device to find the restore button, and simulate the restore button to enter the backup decryption page;

[0115] Send the uiautomator command to grab the device's current page hierarchy to find the end-to-end encryption password item and simulate the selection;

[0116] Enter the 64-bit encryption key through the adb shell input text command for decryption;

[0117] After decryption is complete, send the uiautomator command to grab the current page hierarchy of the device and find the next button to enter the personal information page, thereby completing the WhatsApp data restoration.

[0118] The present invention also provides a storage medium, in which a computer program is stored. When the computer program is executed, the above-mentioned method for restoring WhatsApp data from an iOS terminal to an Android terminal can be implemented.

[0119] The present invention also provides a computer system, comprising a processor and a memory, wherein a computer program is stored in the memory, and when the processor executes the computer program, the above-mentioned method for restoring WhatsApp data from an iOS terminal to an Android terminal can be implemented.

[0120] The above are only preferred embodiments of the present invention. It should be noted that the above preferred embodiments should not be regarded as limiting the present invention, and the protection scope of the present invention should be based on the scope defined by the claims. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the spirit and scope of the present invention, and these improvements and modifications should also be regarded as the protection scope of the present invention.

Claims

1. A method for restoring WhatsApp data from an iOS device to an Android device, characterized in that include: Obtain a WhatsApp backup data package from a source iOS device, and convert the backup data package into a WhatsApp backup data package in an Android format; Encrypt the WhatsApp backup data package in Android format to form an encrypted file, including: Compress the WhatsApp backup data package in Android format to form a compressed data file; Get the version information of WhatsApp on the target Android device and the login account to be restored; Generate the 16-byte encryption initial vector data required by the AES GCM encryption algorithm through a random function; Write the WhatsApp version number, the last two characters of the login account, and the encrypted initial vector data as header information into the encrypted file header; A 32-byte encryption key is randomly generated and converted into hexadecimal data to form a 64-bit encryption key; Use the 64-bit encryption key to encrypt the compressed data file using the AES GCM algorithm; Add the encrypted compressed data file to the encrypted file after the header file information as a data segment; Calculate the HASH value of the encrypted file and add the HASH value to the encrypted file after the compressed data file as the file tail; Transfer the encrypted file to the target Android device and launch WhatsApp to restore the data; The method of starting WhatsApp to restore data includes: Launch WhatsApp on the target Android device, send the uiautomator command to grab the device's current page hierarchy to find the login button, and automatically simulate clicking the login button to jump to the account login page; Send the uiautomator command to grab the current page hierarchy of the device to find the account input box and the next button, and use the adb shell input text command to automatically enter the login account to be restored and simulate clicking the next button to jump to the verification code page; Determine whether WhatsApp has permission to read SMS messages. If so, read the SMS verification code and enter the verification code through the adb shellinput text command; if not, remind the user to enter the verification code manually; Send the uiautomator command to grab the current page hierarchy of the device to find the authorization pop-up window and the authorization button on the authorization pop-up window, simulate clicking the authorization button to obtain authorization to access the address book and media of the target Android terminal and jump to the restore backup page; Send the uiautomator command to grab the current page hierarchy of the device to find the restore button, and simulate the restore button to enter the backup decryption page; Send the uiautomator command to grab the device's current page hierarchy to find the end-to-end encryption password item and simulate the selection; Enter the 64-bit encryption key through the adb shell input text command for decryption; After decryption is complete, send the uiautomator command to grab the current page hierarchy of the device and find the next button to enter the personal information page, thereby completing the WhatsApp data restoration.

2. A method for restoring WhatsApp data from an iOS device to an Android device according to claim 1, characterized in that: Before restoring data, use the adb command to determine whether the target Android device is in landscape mode. If so, turn off the landscape mode setting to restore the target Android device to portrait mode.

3. A method for restoring WhatsApp data from an iOS device to an Android device according to claim 1, characterized in that: When transferring the encrypted file to the target Android device, if the Android system version of the target Android device is 11 or higher, transfer the encrypted file to the target Android device: / sdcard / Android / media / com.whatsapp / WhatsApp; If the target Android device has an Android system version lower than 11, the encrypted file will be transferred to the target Android device: / sdcard / WhatsApp.

4. A method for restoring WhatsApp data from an iOS device to an Android device according to claim 1, characterized in that: Before transferring the encrypted file to the target Android device, reset the WhatsApp login account on the target Android device so that the WhatsApp application on the target Android device is restored to the initial installation state.

5. A method for restoring WhatsApp data from an iOS device to an Android device according to claim 1, characterized in that: Call the libimobiledevice protocol to obtain the WhatsApp backup data package on the source iOS side.

6. A method for restoring WhatsApp data from an iOS device to an Android device according to claim 1, characterized in that: Before obtaining the WhatsApp backup data package from the source iOS device, perform device identification on the source iOS device and the target Android device and obtain trust authorization.

7. A WhatsApp data restoration system from an iOS terminal to an Android terminal, characterized in that include: Device identification module, used to identify the source iOS device and the target Android device and obtain trust authorization; Get the WhatsApp version information of the target Android device; The underlying data conversion module is used to obtain the WhatsApp backup data package of the source iOS terminal and convert the backup data package into the WhatsApp backup data package in Android format; The encryption module is used to encrypt the WhatsApp backup data package in Android format to form an encrypted file, including: compressing the WhatsApp backup data package in Android format to form a compressed data file, generating 16-byte encryption initial vector data required by the AESGCM encryption algorithm through a random function; writing the WhatsApp version number, the last two characters of the login account, and the encryption initial vector data as header file information into the encrypted file header; randomly generating a 32-byte encryption key, and converting it into hexadecimal data to form a 64-bit encryption key; using the 64-bit encryption key to encrypt the compressed data file using the AES GCM algorithm; adding the encrypted compressed data file to the encrypted file after the header file information as a data segment; calculating the HASH value of the encrypted file, and adding the HASH value to the encrypted file after the compressed data file as the file tail; The recovery module is used to transfer the encrypted files to the target Android device and start WhatsApp to restore the data, including: Use the adb command to determine whether the target Android device is in landscape mode. If so, turn off the landscape mode setting to restore the target Android device to portrait mode. Launch WhatsApp on the target Android device, send the uiautomator command to grab the device's current page hierarchy to find the login button, and automatically simulate clicking the login button to jump to the account login page; Send the uiautomator command to grab the current page hierarchy of the device to find the account input box and the next button, and use the adb shell input text command to automatically enter the login account to be restored and simulate clicking the next button to jump to the verification code page; Determine whether WhatsApp has permission to read SMS messages. If so, read the SMS verification code and enter the verification code through the adb shellinput text command; if not, remind the user to enter the verification code manually; Send the uiautomator command to grab the current page hierarchy of the device to find the authorization pop-up window and the authorization button on the authorization pop-up window, simulate clicking the authorization button to obtain authorization to access the address book and media of the target Android terminal and jump to the restore backup page; Send the uiautomator command to grab the current page hierarchy of the device to find the restore button, and simulate the restore button to enter the backup decryption page; Send the uiautomator command to grab the device's current page hierarchy to find the end-to-end encryption password item and simulate the selection; Enter the 64-bit encryption key through the adb shell input text command for decryption; After decryption is complete, send the uiautomator command to grab the current page hierarchy of the device and find the next button to enter the personal information page, thereby completing the WhatsApp data restoration.

8. A storage medium, characterized in that: The storage medium stores a computer program, which, when executed, can implement the method for restoring WhatsApp data from an iOS device to an Android device as described in any one of claims 1 to 7.

9. A computer system comprising a processor and a memory, characterized in that: The memory stores a computer program. When the processor executes the computer program, the method for restoring WhatsApp data from an iOS device to an Android device as described in any one of claims 1 to 7 can be implemented.

Citation Information

Patent Citations

  • Data migration method and device based on WhatsApp software and terminal equipment

    CN114281805A