Damaged cfb document repairing method and device, equipment and storage medium
By extracting and filtering the sector configuration table and other information of the cfb file, and constructing the repaired header information, the problem of repairing the damaged cfb file in the existing technology is solved, and the effective repair and recovery of the file is achieved.
Patent Information
- Application Number
- CN202410597568.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-14
- Publication Date
- 2024-08-23
AI Technical Summary
Existing data recovery software is difficult to effectively repair damaged cfb documents, especially doc, xls, and ppt files, resulting in files that cannot be opened or are incomplete, and lack effective repair technology.
By extracting the directory entries in the cfb document, determining the format type, and constructing the repaired header information based on the sector configuration table, short sector configuration table and main sector configuration table information, the damaged cfb document can be repaired. Specific steps include obtaining directory entries, filtering sector configuration table and short sector configuration table information, and constructing repaired header information to restore files.
It realizes the repair of damaged cfb documents, restores the availability and integrity of the files, and solves the problem that the files cannot be opened or are incomplete in the existing technology.
Smart Images

Figure CN118535386A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method, device, equipment and storage medium for repairing a damaged CFB document. Background Art
[0002] CFB documents are composite files, including doc, xls, and ppt files. In the data recovery industry, most data recovery software recovers user data by scanning the user's disk, but the doc, xls, and ppt files retrieved in this way often have some damage, such as some data in doc, xls, and ppt files being overwritten, causing the recovered files to be unable to open. Some are interrupted during the download or transfer of doc, xls, and ppt files, and the files will be truncated or incomplete. After invading, some ransomware viruses will overwrite the files, causing doc, xls, and ppt files to be unable to open.
[0003] Hard disk problems can also lead to doc, xls, ppt or data corruption. Sometimes, the problem is not with the file, but with the computer itself. This type of failure includes unstable power supply. When the computer suddenly shuts down due to power outage, the files opened at this time may be corrupted or have other problems.
[0004] When the above situations occur, users often directly think that doc, xls, ppt files are invalid and abandon the document. Currently, there is no ready-made technical solution to repair doc, xls, ppt files. Summary of the invention
[0005] The main purpose of the present invention is to solve the technical problem of how to repair.
[0006] A first aspect of the present invention provides a method for repairing a damaged cfb document, the method comprising:
[0007] Obtain a cfb document and extract directory items in the cfb document;
[0008] Determine the format type of the cfb document according to the extracted directory item;
[0009] If all the sector configuration tables and short sector configuration tables in the cfb document are normal, and the header of the cfb document is damaged, a sat set is extracted, where the sat set is a sector set obtained according to the commonality of the sector configuration table, the short sector configuration table and the main sector configuration table of the cfb document;
[0010] Filtering and screening the sat-like set, extracting all the sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document;
[0011] According to all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document, the header information is constructed, and according to the format type and the header information, the repaired cfb document is obtained.
[0012] Optionally, in a first implementation of the first aspect of the present invention, the extracted directory items are filtered once according to structural features of the directory items;
[0013] According to the directory entry after the primary filtering, the short stream container size in the cfb document is obtained, and according to the short stream container size, the maximum sector identifier in the short sector configuration table is calculated;
[0014] Performing secondary filtering on the directory entry according to the maximum sector identifier in the short sector configuration table;
[0015] The format type of the cfb document is determined according to the directory items after secondary filtering.
[0016] Optionally, in a second implementation of the first aspect of the present invention, it is determined whether there is a preset character in the sat class in the sat class set;
[0017] If yes, then obtain the maximum sector identifier in the sat class, and determine whether all common sector identifiers in the sat class are smaller than the maximum sector identifier in the sat class;
[0018] If not, the sat class is filtered out from the sat class set to obtain a first sat class set;
[0019] The first type of sat set is filtered and screened to extract all sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document.
[0020] Optionally, in a third implementation of the first aspect of the present invention, filtering and screening the first type of sat set to extract all sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document includes:
[0021] Sequentially taking out class sats from the first class sat set, if each sector identifier in the taken out class sats appears in the first class sat set, putting the taken out class sats into the second class sat set, and filtering out the taken out class sats from the first class sat set;
[0022] Otherwise, put the removed class sat back into the first class sat set;
[0023] According to the second type of sat set, all main sector configuration table information in the damaged cfb file is obtained;
[0024] According to the filtered first type sat set, a third type sat set is obtained, and according to the third type sat set, all the sector configuration table and short sector configuration table information in the damaged cfb document is obtained.
[0025] Optionally, in a fourth implementation of the first aspect of the present invention, obtaining all sector configuration tables and short sector configuration table information in the damaged cfb document according to the third type sat set includes:
[0026] Obtaining the maximum sector identifier in the short sector configuration table, and determining whether there is a sector identifier in each class SAT in the third class SAT set that is greater than the maximum sector identifier in the short sector configuration table;
[0027] If so, the class SAT whose sector identifier is greater than the maximum sector identifier in the short sector configuration table is filtered out from the third class SAT set to obtain a fourth class SAT set, and partial sector configuration table information is obtained based on the class SAT filtered from the third class SAT set;
[0028] According to the directory entry, the sector identification chain of all short stream files is extracted, and according to the sector identification chain of all short stream files, each class sat in the fourth class sat set is scored, and the first n class sats are taken out in descending order of scores;
[0029] The first n class sats are filtered out from the fourth class sat set to obtain a fifth class sat set, and all the short sector configuration table information in the damaged cfb file is obtained according to the filtered first n class sats;
[0030] All sector configuration table information is obtained according to the fifth type of sat set and the partial sector configuration table information.
[0031] Optionally, in a fifth implementation of the first aspect of the present invention, obtaining all sector configuration table information according to the fifth type of sat set and the partial sector configuration table information includes:
[0032] Obtain the maximum sector identifier in the damaged cfb file, and determine whether there is a sector identifier in each class sat in the fifth class sat set that is greater than the maximum sector identifier in the damaged cfb file;
[0033] If so, the class sats whose sector identifier is greater than the maximum sector identifier in the damaged cfb file are filtered out from the fifth class sat set;
[0034] All sector configuration table information is obtained according to the filtered fifth category sat set and the partial sector configuration table information.
[0035] Optionally, in a sixth implementation of the first aspect of the present invention, the method further includes:
[0036] If all the sector configuration tables and short sector configuration tables in the cfb document are normal and more than the header of the cfb document is damaged, a core file is obtained according to the format type;
[0037] A repaired cfb document is obtained according to the core file, all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document.
[0038] A second aspect of the present invention provides a damaged CFB document repair device, comprising: a memory and at least one processor, wherein instructions are stored in the memory, and the memory and the at least one processor are interconnected via a line; the at least one processor calls the instructions in the memory so that the damaged CFB document repair device executes the above-mentioned damaged CFB document repair method.
[0039] A third aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned damaged cfb document repairing method.
[0040] In an embodiment of the present invention, a cfb document is obtained, and directory entries in the cfb document are extracted; the format type of the cfb document is determined according to the extracted directory entries; if all sector configuration tables and short sector configuration tables in the cfb document are normal, and the header of the cfb document is damaged, a sat set is extracted, and the sat set is a sector set obtained according to the commonalities of the sector configuration table, the short sector configuration table and the main sector configuration table of the cfb document; the sat set is filtered and screened to extract all sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document; header information is constructed according to all sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document, and a repaired cfb document is obtained according to the format type and the header information. In the present invention, when the header of a cfb document is damaged, a class sat set is extracted, the class sat set is filtered and screened, and all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document are extracted. Then, according to all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document, the header information is constructed, and the header of the damaged cfb document can be restored, thereby realizing the repair of the damaged cfb document. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of an embodiment of a method for repairing a damaged cfb document in an embodiment of the present invention;
[0042] Figure 2 This is a schematic diagram of the cfb document header parsing;
[0043] Figure 3 It is a schematic diagram of releasing files for cfb documents;
[0044] Figure 4 A schematic diagram of an embodiment of a damaged cfb document repairing device according to an embodiment of the present invention;
[0045] Figure 5 It is a schematic diagram of an embodiment of a damaged cfb document repairing device in an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The embodiments of the present invention provide a damaged cfb document repair method, device, equipment and storage medium.
[0047] The embodiments disclosed in the present invention will be described in more detail below with reference to the accompanying drawings. Although certain embodiments disclosed in the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments disclosed in the present invention are only for exemplary purposes and are not intended to limit the scope of protection disclosed in the present invention.
[0048] In the description of the embodiments disclosed in the present invention, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The terms "first", "second", etc. may refer to different or the same objects. Other explicit and implicit definitions may also be included below.
[0049] The cfb compound document is like a file system (file system: such as FAT and NTFS). The compound document divides the data into many streams, which are stored in different storages. Imagine the compound document as the D drive, which uses the NTFS format. The streams are equivalent to the files in the D drive, and the storage is equivalent to the folders in the D drive. The naming rules of streams and storages are similar to the file system. The streams and storages under the same storage cannot have the same name, but different storages can have streams with the same name. Each compound document has a root storage.
[0050] All streams are divided into smaller data blocks, called data sectors. Sectors may contain control data or user data. The entire file consists of a header structure and all sectors that follow it. The size of sectors is determined in the header, and the size of each sector is the same. The index of a sector (starting from 0) is called a sector identifier (sid), which is a signed 32-bit integer value. If the value of a sid is non-negative, it indicates the real sector; if it is negative, it means a special meaning. The list of all sectors used to store stream data is called a sector chain. These sectors can be unordered. Therefore, the SID array used to specify the order of sectors of a stream is called a SID Chain. A SID Chain always ends with End Of ChainSID (-2). SID will appear in the master sector configuration table (disat, also called msat), sector configuration table (sat), and short sector configuration table (minisat). The sid that appears in disat is used to indicate which sectors contain the sat table. The sid that appears in sat will form multiple sector chains to indicate which sectors in the file are continuous, used to indicate the file's data. The sid that appears in minisat will form multiple sector chains to indicate which sectors in the file's short stream container are continuous, used to indicate the file's data.
[0051] The compound document header is at the beginning of the file and its size must be 512 bytes. This means that the offset of the first Sector relative to the file is 512 bytes.
[0052] When the size of a stream is less than a specified threshold (specified in the header), it is called a short-stream. Short streams do not directly use sectors to store data, but are contained in a special internal control stream - the short-stream container stream. The short-stream storage stream is like other user streams: first get the first used sector from the root storage entry in the directory, and its SID chain is obtained from the SAT. Then this stream divides the sectors it occupies into short-sectors to store short streams. If the short-stream storage stream is regarded as a compound document, then short streams correspond to streams and short-sectors correspond to sectors. The only difference is that compound documents have a header structure, while short-stream storage streams do not. The size of the short-sector is specified in the header, so the offset of the short-sector relative to the short-stream storage stream can be calculated based on the SID. Minisat contains the SID chains of all short flows, which is very similar to SAT. The SID of the first sector used to store the minisat is specified in the header, and the remaining SID chains are obtained from SAT.
[0053] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of the damaged cfb document repair method in the embodiment of the present invention includes:
[0054] S100, obtaining a cfb document and extracting directory items in the cfb document.
[0055] In this embodiment, the directory stream is an internal control stream consisting of a series of directory entries. Each directory entry points to a repository or stream of a compound document. The directory entries are listed in the order in which they appear in the directory stream. A directory entry index starting with 0 is called a directory entry identifier (DID). The position of the directory entry does not change due to the existence or non-existence of the repository or stream it points to. If a repository or stream is deleted, its corresponding directory entry is marked as empty. There is a special directory entry at the beginning of the directory, called the root storage entry, which points to the root repository. The directory entry indicating the directory structure in the directory entry places the direct members of each repository (repository or stream) in an independent red-black tree.
[0056] S200, judging the format type of the cfb document according to the extracted directory entry.
[0057] In this embodiment, the extracted directory items are filtered and screened, and the format of the cfb document is determined based on the filtered directory items, where the formats include doc, xls, and ppt. Because some files have errors due to suffix mismatch, such files occupy the majority of files on the server. At this time, the observed file suffix names are extracted for use, where doc needs to satisfy WordDocument and 0Table or 1Table, xls needs to satisfy Workbook after excluding doc interference, and ppt needs to satisfy PowerPoint after excluding doc interference.
[0058] S300: If all the sector configuration tables and short sector configuration tables in the cfb document are normal and the header of the cfb document is damaged, extract the sat set.
[0059] In this embodiment, it is necessary to extract the minisat, sat, and disat information in the file to obtain the header information. Analysis of minisat, sat, and disat shows that they all have commonalities: they all store sids, and there is only one copy of the stored sid (except for special sids), and all are 512 bytes as a unit block. And sid has a characteristic: the value is between 0 and the larger value of (sat maximum sid and minisat maximum sid), or it is a special sid, and the common sat class set is extracted based on this. The present invention assumes that the data is complete but covered: it is expected to be able to repair the situation where the redundant space is covered (extreme repair, because this type of file has almost no holes, but when it is observed that the local core important data is damaged, the document with lost part of the data can still be taken out), redundant space: header, disat, unused part of sat, minisat, non-core file data area.
[0060] S400, filtering and screening the sat-like set to extract all the sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document.
[0061] In this embodiment, the sat-like set includes the sector configuration table, short sector configuration table and main sector configuration table information of the cfb document, so the sector configuration table, short sector configuration table and main sector configuration table information are filtered out from the sat-like set. Specifically, disat is first filtered out from the sat-like set. After filtering, only minisat, sat and some illegal sats that look like sat are left in the sat-like set. Then the filtered sat-like set is filtered again to take out all minisat and sat.
[0062] S500, constructing header information according to all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document, and obtaining a repaired cfb document according to the format type and the header information.
[0063] In this embodiment, if the header of the cfb document is damaged, the header needs to be reconstructed, such as Figure 2 As shown, the information needed to construct the header is the information not framed by the blue box, including: the total number of sectors (2CH-2FH) for storing the sector configuration table (SAT); the SID (30H-33H) for storing the first sector of the directory stream; the SID (3CH-3FH) for storing the first sector of the short sector configuration table (SSAT); the total number of sectors (40H-43H) for storing the short sector configuration table (SSAT); the SID (-2 if there is no additional sector) for storing the first sector of the main sector configuration table (44H-47H); the total number of sectors (48H-4BH) for storing the main sector configuration table; the first part (starting from 4CH, the end position is determined according to the specific situation) for storing the main sector configuration table (MSAT). Among them, SAT is sat, SSAT is minisat, and MSAT is disat. Paste the constructed file header back and modify the suffix of the source file according to the observed file suffix.
[0064] In an optional implementation of the first aspect of the present invention, judging the format type of the cfb document according to the extracted directory item includes:
[0065] According to the structural characteristics of the directory items, the extracted directory items are filtered once; according to the directory items after the primary filtering, the short stream container size in the cfb document is obtained, and according to the short stream container size, the maximum sector identifier in the short sector configuration table is calculated; according to the maximum sector identifier in the short sector configuration table, the directory items are filtered twice; according to the directory items after the secondary filtering, the format type of the cfb document is determined.
[0066] In this embodiment, the extracted directory entries are filtered once according to the structural characteristics of the directory entries. The purpose of filtering the directory entries once is to find data blocks that may be directory entries from the file. The filtering rules are:
[0067] 1. The name_valid_size field must be between 0 and 64;
[0068] 2. All bytes in the name field except name_valid_size are 0;
[0069] 3. The IDs of left and right brothers and children are all values in the range of 1-10000 or -1;
[0070] 4. stream_size cannot exceed file_size-512;
[0071] 5. If stream_size is greater than 4096, start_sid can only be the maximum sid value from 0 to sat.
[0072] Among them, the name field is the name represented by the directory entry, with a total length of 64 bytes, but only the first name_valid_size bytes are valid. The name_valid_size field is the length of the name represented by the directory entry, which occupies two bytes. In the directory entry, the name field is a 64-byte Microsoft unicode encoding string. A Microsoft unicode character occupies two bytes to represent a character. Only the first name_valid_size characters in the name field are valid, and the remaining bytes are all filled with 0. stream_size field: The function of the directory entry is to specify the concept of folders or files. If a directory entry indicates a folder and is not a root directory entry, the stream_size field of the directory entry is 0. If a directory entry indicates a root directory entry, that is, a root folder, then the stream_size field refers to the size of the short stream container. We can understand the short stream container as a virtual file, which is used to store some small files. If a directory entry indicates an ordinary file, then the stream_size field refers to the size of this ordinary file.
[0073] Scan the filtered directory entries once to find the root directory entry. If it can be found, get the short stream container size based on the directory entry, and calculate the maximum sid and the number of minisats in the minisat based on the short stream container size. If it cannot be found, it means that the file is unrepairable or is not a cfb file at all. Perform a secondary filter on the directory entries to filter out the stream_size in the directory entries that is less than 4096 and the sid that is greater than the maximum sid in the minisat. According to the directory entries after the secondary filtering, determine the format type of the cfb document. Specifically, the repair is that the default short stream cutoff size is 4096. This short stream cutoff size is used to indicate the segmentation point of large and small files. That is, a file less than or equal to 4096 bytes is a small file, and if it is larger, it is a large file. Small files are placed in short stream containers, and short stream containers are based on 64 bytes per sector. If the stream_size field in a directory entry is less than 4096, then it represents a small file, and small files are placed in short stream containers. In other words, the starting sid is a minisat sid. If this sid is larger than the "minisat's maximum sid", it indicates a contradiction. This directory entry is not a normal directory entry and can be filtered out at this time.
[0074] In an optional implementation of the first aspect of the present invention, filtering and screening the sat-like set, extracting all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document includes:
[0075] Determine whether there is a preset character in the class SAT in the class SAT set; if so, obtain the maximum sector identifier in the class SAT, and determine whether the common sector identifiers in the class SAT are all smaller than the maximum sector identifier in the class SAT; if not, filter out the class SAT from the class SAT set to obtain the first class SAT set; filter and screen the first class SAT set to extract all sector configuration table, short sector configuration table and main sector configuration table information in the damaged CFB document.
[0076] In this embodiment, some sats are classified from the sat class set, and some garbage "classes" are erased. It is determined whether each sat class in the sat class set contains a preset character, which is -3 or -4. If there is a preset character in the sat class, it is determined to be a sat unit block. At this time, it is necessary to check whether the common sids in the sat class are all smaller than the maximum sid in the sat class. If not, the sat class is filtered out from the sat class set. If so, it is a sid unit block, kicked out from the sat class set, and added to the first sat class set. Then the first sat class set is filtered and screened to extract all the sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document.
[0077] In an optional implementation of the first aspect of the present invention, filtering and screening the first type of sat set, extracting all sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document includes:
[0078] Take out the class sats from the first class sat set in turn. If each sector identifier in the taken out class sat appears in the first class sat set, put the taken out class sat into the second class sat set, and filter out the taken out class sat from the first class sat set; otherwise, put the taken out class sat back into the first class sat set; according to the second class sat set, get all the main sector configuration table information in the damaged cfb document; according to the filtered first class sat set, get the third class sat set, and according to the third class sat set, get all the sector configuration table and short sector configuration table information in the damaged cfb document.
[0079] In this embodiment, all disats are taken out, and the first-category sat set obtained after filtering becomes smaller. On this basis, the disat feature is used, that is, each sid in the disat points to a sat. Specifically, the class sats are taken out from the first-category sat set in turn, and each class sat is examined. If every sid in a class sat appears in the first-category sat set, it is considered that the current class sat is a disat, and it is kicked out of the first-category sat set and put into the second-category sat set. Otherwise, the taken-out class sat is put back into the first-category sat set. According to the filtered first-category sat set, the third-category sat set is obtained, and filtering and screening are continued according to the third-category sat set to obtain all sector configuration tables and short sector configuration table information in the damaged cfb document.
[0080] In an optional implementation of the first aspect of the present invention, according to the third type of sat set, all the sector configuration tables and short sector configuration table information in the damaged cfb file are obtained, including:
[0081] Obtain the maximum sector identifier in the short sector configuration table, and determine whether there is a sector identifier greater than the maximum sector identifier in the short sector configuration table in each class SAT in the third class SAT set; if so, filter out the class SAT whose sector identifier is greater than the maximum sector identifier in the short sector configuration table from the third class SAT set to obtain the fourth class SAT set, and obtain partial sector configuration table information based on the class SAT filtered from the third class SAT set; extract the sector identifier chain of all short stream files according to the directory entry, and score each class SAT in the fourth class SAT set according to the sector identifier chain of all short stream files, and take out the first n class SATs in descending order of scores; filter out the first n class SATs from the fourth class SAT set to obtain the fifth class SAT set, and obtain all short sector configuration table information in the damaged CFB document based on the filtered first n class SATs; obtain all sector configuration table information based on the fifth class SAT set and partial sector configuration table information.
[0082] In this embodiment, the third category sat set is filtered, and part of the sats are filtered out. The characteristics between minisat and sat are relatively vague. At this time, with the help of the information of "maximum sid in minisat" in the "extract directory item" step, the third category sat set is filtered once. Specifically, it is determined whether there is a sid in each class sat in the third category sat set that is greater than the maximum sid in minisat. If so, the class sat is filtered out from the third category sat set to obtain the fourth category sat set. The filtered class sat is a partial sat, which is put into the "sat" set. The fourth category sat set is filtered again to filter out all minisats. Specifically, the sid chains of all short stream files are extracted according to the directory items, and each category sat in the fourth category sat set is examined and scored. The scoring rule is the number of short stream chain short sequences satisfied by the current category sat divided by the sum of all short sequences. The first n category sats are picked out in descending order of scores, and the first n category sats are filtered out from the fourth category sat set to obtain the fifth category sat set, and these first n category sats are put into the "minisat" set.
[0083] In an optional implementation of the first aspect of the present invention, all sector configuration table information is obtained according to the fifth type of sat set and part of the sector configuration table information, including:
[0084] Get the maximum sector identifier in the damaged cfb document, and determine whether there is a sector identifier in each class sat in the fifth class sat set that is greater than the maximum sector identifier in the damaged cfb document; if so, filter out the class sat whose sector identifier is greater than the maximum sector identifier in the damaged cfb document from the fifth class sat set; obtain all sector configuration table information based on the filtered fifth class sat set and part of the sector configuration table information.
[0085] In this embodiment, after filtering, only "sat" or junk sats are left in the fifth category sat set. At this time, each category sat in the fifth category sat set is examined. If there is a SID in this category sat that is greater than the largest SID of the file, it will be kicked out of the fifth category sat set, otherwise it will be added to the "sat" set.
[0086] In an optional implementation of the first aspect of the present invention, the method further includes:
[0087] If all the sector configuration tables and short sector configuration tables in the cfb document are normal and more than the header of the cfb document is damaged, a core file is obtained according to the format type; based on the core file, all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document, a repaired cfb document is obtained.
[0088] In this embodiment, if the header is damaged, the header information is constructed and the repaired file 1 is output; if more than the header of the file is damaged, all files are released according to the sat, minisat, disat information and the core directory items, and then the cfb file is synthesized and the corresponding file suffix is used to output the repaired file 2. For example, the directory items can be known from the folder. If the data of each item is less than 4096, it is a small file. All the small files in this folder can be put together to know how big the short stream container should be. Then, the minisat and sat that describe the layout of these files in the cfb file are sorted out, and disat is generated according to sat. Finally, the header is generated, and these small components are spliced into a completed cfb file. According to the core file, the resource information such as text and pictures in the file is extracted, and a file is sorted out, and the repaired file 3 is output. In essence, the repaired file 2 is better than the repaired file 1 in content and quality. In fact, the repaired file 1 may not be needed. The reason why file 1 exists is that the io operation of file 1 is less than that of file 2, and it can be repaired quickly. This is just a strategy for selecting and releasing in the product. For example, the product may consider the repair time and choose to block the second half of the logic. The user uses the previous function. That is to say, if the user scenario only damages the file header, only repair file one. File three is re-synthesized after files one and two are repaired because the core file data is damaged, causing us to use the files to re-synthesize and cannot be opened. At this time, the bottom line is to extract the useful data in the file to ensure that the user can obtain useful information. For example, a web page is composed of html, js, css, and referenced pictures, audio and video. The damage of the core file means the damage of html, js, and css. However, at this time, we can still try to take out useful things such as pictures, audio and video and reorganize them into a web page. Although the layout is no longer the same as before, at least the resource information is still there.
[0089] The core files in a cfb file are all different. For example, doc is WordDocument and 0Table or 1Table, xls is Workbook, and ppt is PowerPoint. Since xls and ppt may be embedded in doc, sometimes the released doc may contain Workbook and PowerPoint. Therefore, when determining the specific type of the cfb format, the interference of doc will be eliminated first. For example, if a file contains WordDocument and 0Table or 1Table, it is doc. Otherwise, check whether there is Workbook. If so, it is xls. Otherwise, check whether there is PowerPoint. If so, it is ppt. Each doc file may be different when released, but at least there will be a core file. If the core file exists, the re-synthesis may be successful, although it may fail because not all files are core. For example, Figure 3 As shown, assuming that the above file is lost, _05H_SummaryInformation is missing. After resynthesis (File 2), it can still be opened normally, and the file content is not lost at all; for example, if it loses Data, after resynthesis (File 2), it cannot be opened. Although its core file exists, the data file referenced by the core file is lost. This is because when the reader parses that a certain data file is needed and cannot find it, it will think that an error has occurred and the file is damaged. However, the Data file is lost, but its core file exists, such as the WordDocument core file. At this time, you can scan this file and extract the useful information in it. This is File 3. Similarly, the xls format and ppt format have their own core files in their respective formats. The information of these core files is introduced in Microsoft official documents.
[0090] See also Figure 4 The second aspect of the present invention provides a damaged cfb document repairing device, the damaged cfb document repairing device comprising:
[0091] The directory entry extraction module 10 is used to obtain the cfb document and extract the directory entries in the cfb document;
[0092] The format type determination module 20 is used to determine the format type of the cfb document according to the extracted directory items;
[0093] The data set extraction module 30 is used to extract a sat set if all the sector configuration tables and short sector configuration tables in the cfb document are normal and the header of the cfb document is damaged. The sat set is a sector set obtained according to the commonality of the sector configuration table, the short sector configuration table and the main sector configuration table of the cfb document.
[0094] The data filtering module 40 is used to filter and screen the sat-like set, and extract all the sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document;
[0095] The header information construction module 50 is used to construct header information according to all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document, and obtain the repaired cfb document according to the format type and the header information.
[0096] In an optional implementation of the second aspect of the present invention, the format type judgment module 20 is also used to filter the extracted directory items once according to the structural characteristics of the directory items; obtain the short stream container size in the cfb document according to the directory items after the primary filtering, and calculate the maximum sector identifier in the short sector configuration table according to the short stream container size; perform a secondary filtering on the directory items according to the maximum sector identifier in the short sector configuration table; and judge the format type of the cfb document according to the directory items after the secondary filtering.
[0097] In an optional implementation of the second aspect of the present invention, the data filtering and screening module 40 is also used to determine whether there is a preset character in the class SAT in the class SAT set; if so, obtain the maximum sector identifier in the class SAT, and determine whether the ordinary sector identifiers in the class SAT are all smaller than the maximum sector identifier in the class SAT; if not, filter out the class SAT from the class SAT set to obtain a first class SAT set; filter and screen the first class SAT set to extract all sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged CFB document.
[0098] In an optional implementation of the second aspect of the present invention, the data filtering and screening module 40 is also used to sequentially extract class SATs from the first class SAT set. If each sector identifier in the extracted class SAT appears in the first class SAT set, the extracted class SAT is placed in the second class SAT set, and the extracted class SAT is filtered out from the first class SAT set; otherwise, the extracted class SAT is placed back into the first class SAT set; based on the second class SAT set, all main sector configuration table information in the damaged CFB document is obtained; based on the filtered first class SAT set, a third class SAT set is obtained, and based on the third class SAT set, all sector configuration table and short sector configuration table information in the damaged CFB document is obtained.
[0099] In an optional implementation of the second aspect of the present invention, the data filtering and screening module 40 is also used to obtain the maximum sector identifier in the short sector configuration table, and determine whether there is a sector identifier greater than the maximum sector identifier in the short sector configuration table in each class SAT in the third class SAT set; if so, the class SAT with a sector identifier greater than the maximum sector identifier in the short sector configuration table is filtered out from the third class SAT set to obtain a fourth class SAT set, and partial sector configuration table information is obtained based on the class SAT filtered from the third class SAT set; according to the directory entry, the sector identifier chain of all short stream files is extracted, and according to the sector identifier chain of all short stream files, each class SAT in the fourth class SAT set is scored, and the first n class SATs are taken out in descending order of scores; the first n class SATs are filtered out from the fourth class SAT set to obtain a fifth class SAT set, and all short sector configuration table information in the damaged CFB document is obtained based on the filtered first n class SATs; all sector configuration table information is obtained based on the fifth class SAT set and partial sector configuration table information.
[0100] In an optional implementation of the second aspect of the present invention, the data filtering and screening module 40 is also used to obtain the maximum sector identifier in the damaged cfb document, and determine whether there is a sector identifier in each class SAT in the fifth class SAT set that is greater than the maximum sector identifier in the damaged cfb document; if so, the class SAT with a sector identifier greater than the maximum sector identifier in the damaged cfb document is filtered out from the fifth class SAT set; based on the filtered fifth class SAT set and part of the sector configuration table information, all sector configuration table information is obtained.
[0101] In an optional implementation of the second aspect of the present invention, the damaged cfb document repairing device further includes:
[0102] The file repair module is used to obtain the core file according to the format type if all the sector configuration tables and short sector configuration tables in the cfb document are normal and more than the header of the cfb document is damaged; and to obtain the repaired cfb document according to the core file, all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document.
[0103] Figure 51 is a schematic diagram of the structure of a damaged cfb document repair device provided by an embodiment of the present invention. The damaged cfb document repair device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 510 (for example, one or more processors) and a memory 520, and one or more storage media 530 (for example, one or more mass storage devices) storing application programs 533 or data 532. Among them, the memory 520 and the storage medium 530 may be temporary storage or permanent storage. The program stored in the storage medium 530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the damaged cfb document repair device 500. Furthermore, the processor 510 may be configured to communicate with the storage medium 530 to execute a series of instruction operations in the storage medium 530 on the damaged cfb document repair device 500.
[0104] The damaged cfb file repair device 500 may also include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input and output interfaces 560, and / or one or more operating systems 531, such as Windows Serve, Mac OS X, Unix, Linux, Free BSD, etc. Those skilled in the art will appreciate that Figure 5 The structure of the damaged CFB file repairing device shown does not constitute a limitation on the damaged CFB file repairing device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0105] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the damaged CFB document repair method.
[0106] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0107] In addition, although each operation is described in a specific order, this should be understood as requiring such operation to be performed in the specific order shown or in a sequential order, or requiring that all illustrated operations should be performed to obtain desired results. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single implementation in combination. On the contrary, the various features described in the context of a single implementation can also be implemented in multiple implementations individually or in any suitable sub-combination mode.
[0108] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A damaged cfb document repair method, characterized in that: The damaged cfb document repair method comprises: Obtain a cfb document and extract directory items in the cfb document; Determine the format type of the cfb document according to the extracted directory item; If all the sector configuration tables and short sector configuration tables in the cfb document are normal, and the header of the cfb document is damaged, a sat set is extracted, where the sat set is a sector set obtained according to the commonality of the sector configuration table, the short sector configuration table and the main sector configuration table of the cfb document; Filtering and screening the sat-like set, extracting all the sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document; According to all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document, the header information is constructed, and according to the format type and the header information, the repaired cfb document is obtained.
2. The damaged cfb document repair method according to claim 1, characterized in that: The determining the format type of the cfb document according to the extracted directory items includes: According to the structural characteristics of the directory items, the extracted directory items are filtered once; According to the directory entry after the primary filtering, the short stream container size in the cfb document is obtained, and according to the short stream container size, the maximum sector identifier in the short sector configuration table is calculated; Performing secondary filtering on the directory entry according to the maximum sector identifier in the short sector configuration table; The format type of the cfb document is determined according to the directory items after secondary filtering.
3. The damaged cfb document repair method according to claim 1, characterized in that: The filtering and screening of the sat-like set to extract all the sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document includes: Determine whether there is a preset character in the class sat in the class sat set; If yes, then obtain the maximum sector identifier in the sat class, and determine whether all common sector identifiers in the sat class are smaller than the maximum sector identifier in the sat class; If not, the sat class is filtered out from the sat class set to obtain a first sat class set; The first type of sat set is filtered and screened to extract all sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document.
4. The damaged cfb document repair method according to claim 3, characterized in that: The filtering and screening of the first type of sat set to extract all the sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document includes: Sequentially taking out class sats from the first class sat set, if each sector identifier in the taken out class sats appears in the first class sat set, putting the taken out class sats into the second class sat set, and filtering out the taken out class sats from the first class sat set; Otherwise, put the removed class sat back into the first class sat set; According to the second type of sat set, all main sector configuration table information in the damaged cfb file is obtained; According to the filtered first type sat set, a third type sat set is obtained, and according to the third type sat set, all the sector configuration table and short sector configuration table information in the damaged cfb document is obtained.
5. The damaged cfb document repair method according to claim 4, characterized in that: The information of all the sector configuration tables and short sector configuration tables in the damaged cfb file is obtained according to the third type sat set, including: Obtaining the maximum sector identifier in the short sector configuration table, and determining whether there is a sector identifier in each class SAT in the third class SAT set that is greater than the maximum sector identifier in the short sector configuration table; If so, the class SAT whose sector identifier is greater than the maximum sector identifier in the short sector configuration table is filtered out from the third class SAT set to obtain a fourth class SAT set, and partial sector configuration table information is obtained based on the class SAT filtered from the third class SAT set; According to the directory entry, the sector identification chain of all short stream files is extracted, and according to the sector identification chain of all short stream files, each class sat in the fourth class sat set is scored, and the first n class sats are taken out in descending order of scores; The first n class sats are filtered out from the fourth class sat set to obtain a fifth class sat set, and all the short sector configuration table information in the damaged cfb file is obtained according to the filtered first n class sats; All sector configuration table information is obtained according to the fifth type sat set and the partial sector configuration table information.
6. The damaged cfb document repair method according to claim 5, characterized in that: The obtaining of all sector configuration table information according to the fifth type sat set and the partial sector configuration table information includes: Obtain the maximum sector identifier in the damaged cfb file, and determine whether there is a sector identifier in each class sat in the fifth class sat set that is greater than the maximum sector identifier in the damaged cfb file; If so, the class sats whose sector identifier is greater than the maximum sector identifier in the damaged cfb file are filtered out from the fifth class sat set; All sector configuration table information is obtained according to the filtered fifth category sat set and the partial sector configuration table information.
7. The damaged cfb document repair method according to claim 1, characterized in that: Also includes: If all the sector configuration tables and short sector configuration tables in the cfb document are normal and more than the header of the cfb document is damaged, a core file is obtained according to the format type; A repaired cfb document is obtained according to the core file, all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document.
8. A damaged cfb document repair device, characterized in that: The damaged cfb document repairing device comprises: A directory entry extraction module is used to obtain a cfb document and extract directory entries from the cfb document; A format type determination module, used to determine the format type of the cfb document according to the extracted directory items; A data set extraction module, for extracting a sat set if all the sector configuration tables and short sector configuration tables in the cfb document are normal and the header of the cfb document is damaged, wherein the sat set is a sector set obtained according to the commonality of the sector configuration table, the short sector configuration table and the main sector configuration table of the cfb document; A data filtering module is used to filter and screen the sat-like set, and extract all the sector configuration table, short sector configuration table and main sector configuration table information in the damaged cfb document; The header information construction module is used to construct header information according to all the sector configuration tables, short sector configuration tables and main sector configuration table information in the damaged cfb document, and obtain the repaired cfb document according to the format type and the header information.
9. A damaged cfb file repair device, characterized in that: The damaged CFB document repairing device comprises: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor calls the instruction in the memory to enable the damaged cfb document repairing device to execute the damaged cfb document repairing method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the damaged cfb document repair method according to any one of claims 1 to 7 is implemented.
