A method for quickly recovering chat data based on chat software on Android platform

By querying the sqlite_master table and traversing internal pages on the Android platform, the chat data is restored using a string matching algorithm, which solves the problem of mistaken recovery and misalignment in chat data recovery and achieves fast and accurate data recovery.

CN114579359BActive Publication Date: 2024-10-18NANJING FIBERHOME STARRYSKY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210059501.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-19
Publication Date
2024-10-18
Estimated Expiration
2042-01-19

AI Technical Summary

Technical Problem

When restoring chat data on the Android platform with existing technology, it is easy to be unrecoverable due to the erasure of the record header length or first field, or the data is misplaced, and the existing methods are not efficient and accurate enough.

Method used

Query the sqlite_master table to obtain the creation SQL and root page number of the table to be restored, find all internal pages, convert the free block data into field storage type, use the simple string matching algorithm to match the type starting from the second field, and verify if it matches If the first field does not match, continue to traverse the leaf pages until the traversal of all pages is completed, calculate the field length, obtain the content one by one, and enter it into the new database.

Benefits of technology

The method achieves fast and accurate recovery of chat data. The method is simple, easy and highly stable, and avoids the problems of mistaken recovery and misalignment in the existing technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114579359B_ABST
    Figure CN114579359B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for fast recovery of chat data based on chat software on an Android platform, comprising the following steps: S1, querying the sqlite_master table to obtain the creation SQL and the root page number of the table to be recovered; S2, finding all internal pages through the root page, and obtaining all leaf page offset positions from the internal page; S3, converting the types of each field of the table SQL statement into an affinity type; S4, if the judgment result in S3 is that it can match, completing the entry of the configuration by pre-analyzing the data; S5, according to the length calculated by the field type, obtaining the content of each field one by one from the end position of the last field, and finally entering the data into a newly created database. This method for fast recovery of chat data based on chat software on an Android platform has the advantages of fast and accurate recovery of chat data, and the method is simple and easy to implement, has strong stability, and is highly secure.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of data recovery, and in particular to a method for quickly recovering chat data based on Android platform chat software. Background Art

[0002] SQLite is a lightweight database and a relational database management system that complies with ACID. It is contained in a relatively small C library. It can support mainstream operating systems such as Windows / Linux / Unix. Android SDK comes with SQLite, so Android applications use SQLite database to store data more widely. Because of the mechanism of deleting data in SQLite, the total length of the original record data will be rewritten, and the first field type and record header length may also be erased, making it difficult to locate the starting position of the record after deletion. Whether using the type matching method to find the starting position of the record from the first field or the second field, there is a probability of missing or erroneous recovery of data.

[0003] The problems existing in the commonly used data recovery methods in the prior art mainly include the following three points:

[0004] 1. Start matching from the first field type. After all field types are matched successfully, use the record header length for verification. After verification is successful, export and save. This method will cause irrecoverable problems once the record header length is erased;

[0005] 2. Start matching from the first field type, and export and save after all field types are matched successfully. This method will cause the problem of irrecoverable deletion once the first field is erased;

[0006] 3. Start matching from the second field type, and export and save after all field types are matched successfully. This method is more effective for data recovery with a numeric primary key as the first field, but it is easy to cause data misalignment in other cases. Summary of the invention

[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0008] The present invention provides a method for quickly recovering chat data based on Android platform chat software, comprising the following steps:

[0009] S1. Query the sqlite_master table to obtain the creation SQL and root page number of the table to be restored. The SQL can obtain the type of the field in the table and convert the declared type into an affinity type for subsequent matching.

[0010] S2. Find all internal pages through the root page, and obtain all leaf page offset positions from the internal pages. Specifically, obtain all page numbers from the cell content area through the number of cells and the cell pointer array in the page header until all leaf page numbers are obtained. Then, obtain all free block positions through the first free block offset in the page header.

[0011] S3. Convert all the data in the free blocks into field storage types, and convert the types of each field in the table SQL statement into affinity types. Then, starting from the second field, use a simple string matching algorithm to determine whether the two types match.

[0012] S4. If the result of S3 is that the match is possible, the configuration entry is completed by pre-analyzing the data. If there is a configuration, the configuration item is used to verify the first field. If they all match, it is indicated as deleted data. If there is no configuration, the length of the first field is 0 by default, and the verification of the first field is skipped. If the result of S3 is that the match is not possible, return to S2 until all leaf pages are traversed.

[0013] S5. According to the length calculated by the field type, the content of each field is obtained one by one starting from the end position of the last field, and finally the data is entered into the newly created database.

[0014] As a preferred technical solution of the present invention, S2 also includes judging the page type according to the first byte value of the page header. If the first byte value of the page header is 0D or 0A, the page type is a leaf page. If the first byte value of the page header is 05 or 02, the page type is an internal page.

[0015] As a preferred technical solution of the present invention, the affinity types in S3 include five types: NUMERIC, INT, REAL, TEXT and NONE.

[0016] As a preferred technical solution of the present invention, the storage types in S3 include eight types: NULL, INTEGER, REAL, BLOB, TEXT, CONST_INT0, CONST_INT1 and UNUSED.

[0017] As a preferred technical solution of the present invention, S5 also includes creating a table using an SQL creation statement of a message table, and entering the recovered records, and then using the SQLiteSpy tool to open the database file to see the recovered data.

[0018] The beneficial effects of the present invention are:

[0019] This method for quickly recovering chat data based on Android platform chat software can effectively solve the drawbacks of the existing technology, has the advantages of fast and accurate chat data recovery, and the method is simple and easy to implement, has strong stability and high security. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0021] Figure 1 It is a flow chart of a method for quickly recovering chat data based on Android platform chat software of the present invention;

[0022] Figure 2 It is to obtain the schematic diagram of the offset position of all leaf pages;

[0023] Figure 3 It is a diagram of the string matching algorithm. DETAILED DESCRIPTION

[0024] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0025] Example 1

[0026] like Figure 1 As shown, the present invention provides a method for quickly recovering chat data based on an Android platform chat software, comprising the following steps:

[0027] S1. Query the sqlite_master table to obtain the creation SQL and root page number of the table to be restored. The SQL can obtain the type of the field in the table and convert the declared type into an affinity type for subsequent matching.

[0028] SELECT sql, rootpage FROM sqlite_master WHERE name = 'name of table to be restored';

[0029] S2. Find all internal pages through the root page, and get the offset positions of all leaf pages from the internal pages, such as Figure 2 shown.

[0030] Method to determine the page type:

[0031] The first byte value of the header Page Type 0D Leaf Page 05 Internal Page 0A Leaf Page 02 Internal Page

[0032] Internal page format:

[0033]

[0034] Through the number of cells and the cell pointer array in the page header, all page numbers are obtained from the cell content area until all leaf page numbers are obtained. Leaf page format:

[0035]

[0036]

[0037] Get the positions of all free blocks through the first free block offset in the page header.

[0038] S3. Convert the data of the free blocks into field storage types as follows:

[0039] Type Value Represents the storage type Data width (bytes) 0 NULL 0 Nin1..4 INTEGER N 5 INTEGER 6 6 INTEGER 8 7 REAL 8 8 INTEGER 0 9 CONST_INT1 0 10-11 UNUSED N / A N>=12 and N is an even number BLOB (N-12) / 2 N>=13 and N is an odd number TEXT (N-13) / 2

[0040] Convert the types of each field in the table SQL statement to affinity types as follows:

[0041] Type conversion uppercase contains Representative affinity type (Default type) NUMERIC INT, UNSIGNED INT REAL、FLOA、DOUB REAL CHAR, CLOB, TEXT, BOOL, STRING TEXT BLOB NONE

[0042] Starting from the second field, use a simple string matching algorithm, such as Figure 3 As shown, whether the two types match is as follows:

[0043]

[0044]

[0045] Note: 1 indicates a successful match, 0 indicates a failed match.

[0046] S4. Pre-analyze the data to complete the configuration entry. If there is a configuration, use the configured items to verify the first field. If they all meet the requirements, it means the data is deleted. If there is no configuration, the default length of the first field is 0, and the verification of the first field is skipped. The configuration content is as follows:

[0047]

[0048] S5. According to the length calculated by the field type, the content of each field is obtained one by one starting from the end position of the last field. Finally, the data is entered into the newly created database.

[0049] Example 2

[0050] Taking WeChat deleted chat data recovery as an example, because the database is encrypted, it needs to be decrypted first to obtain an unencrypted database. Figure 1 The specific steps are as follows:

[0051] 1. The chat table is named "message". By querying the sqlite_master table, you can get the table's field type and root page number, as shown below:

[0052]

[0053] Use binary to open the entire database file. The 17th and 18th bytes are the page size, which is "1024", as shown below:

[0054]

[0055]

[0056] The page number multiplied by the page size is the offset of the page in the entire database file, so the offset of the root page is 110592 bytes.

[0057] 2. Check the root page data and traverse all pages to locate the page number "928" where the deleted data exists, as shown below:

[0058]

[0059] Since the size of each page is 1024 bytes, the offset position of page 928 can be calculated to be 949248 bytes.

[0060] 3. The 3rd and 4th bytes of the leaf page header, "0157", are the offset of the first free block (starting from the current page). The first two bytes of each free block are the offset of the next free block. All free blocks are collected to form a linked list. "0000" means that this free block is the last one.

[0061]

[0062] 4. Convert the data of the free blocks into field storage types as follows:

[0063] Free Block 00 06 09 01 08 … Storage Type NULL INTEGER CONST_INT1 INTEGER INTEGER …

[0064] Convert the field type in SQL to affinity type:

[0065]

[0066] The data that meets the conditions is located by matching, as follows:

[0067]

[0068] 5. By pre-analyzing the data in the table, it is found that the total length of a record requires at least two bytes.

[0069]

[0070] Description, all first field types will not be erased, so the generated configuration is as follows:

[0071] The first field is checked according to the configuration and it is found that "00" meets the rules.

[0072] 6. Calculate the data length by field type, and get the content of each field one by one starting from "7915E1". Create a new database, create a table using the SQL creation statement of the "message" table, and enter the recovered records. Use the "SQLiteSpy" tool to open the database file to see the recovered data.

[0073] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for quickly recovering chat data based on Android platform chat software, characterized in that: The steps include: S1. Query the sqlite_master table to obtain the creation SQL and root page number of the table to be restored. The SQL can obtain the type of the field in the table and convert the declared type into an affinity type for subsequent matching. S2. Find all internal pages through the root page, and obtain all leaf page offset positions from the internal pages. Specifically, obtain all page numbers from the cell content area through the number of cells and the cell pointer array in the page header until all leaf page numbers are obtained. Then, obtain all free block positions through the first free block offset in the page header. S3. Convert all the data in the free blocks into field storage types, and convert the types of each field in the table SQL statement into affinity types. Then, starting from the second field, use a simple string matching algorithm to determine whether the two types match. S4. If the result of S3 is that the match is possible, the configuration entry is completed by pre-analyzing the data. If there is a configuration, the configuration item is used to verify the first field. If they all match, it is indicated as deleted data. If there is no configuration, the length of the first field is 0 by default, and the verification of the first field is skipped. If the result of S3 is that the match is not possible, return to S2 until all leaf pages are traversed. S5. According to the length calculated by the field type, the content of each field is obtained one by one starting from the end position of the last field, and finally the data is entered into the newly created database.

2. A method for quickly recovering chat data based on Android platform chat software according to claim 1, characterized in that: The S2 also includes determining the page type according to the first byte value of the page header. If the first byte value of the page header is 0D or 0A, the page type is a leaf page. If the first byte value of the page header is 05 or 02, the page type is an internal page.

3. A method for quickly recovering chat data based on Android platform chat software according to claim 1, characterized in that: The affinity types in S3 include five types: NUMERIC, INT, REAL, TEXT and NONE.

4. A method for quickly recovering chat data based on Android platform chat software according to claim 1, characterized in that: The storage types in S3 include eight types: NULL, INTEGER, REAL, BLOB, TEXT, CONST_INT0, CONST_INT1 and UNUSED.

5. A method for quickly recovering chat data based on Android platform chat software according to claim 1, characterized in that: The S5 also includes creating a table using the SQL creation statement of the message table and entering the recovered records. After that, the database file is opened using the SQLiteSpy tool to view the recovered data.

Citation Information

Patent Citations

  • Data recovery method and device and Android equipment

    CN106155832A

  • Android system based webpage browsing record recovery method

    CN106547771A