跳至正文
DATA RECOVERY

专业数据恢复,值得信赖

面向全球数据恢复实验室、取证机构与企业的高科技工具。

FLASH EXTRACTOR

闪存芯片数据恢复,专业之选

支持 U 盘、固态硬盘、存储卡与手机等各类 NAND 闪存芯片,兼容数千种主控并持续更新。

CHIP-OFF TECHNOLOGY

芯片级恢复,精准高效

针对损坏闪存介质与主控的高级提取技术,最大限度还原关键数据。

ORACLE EXTRACTOR

Oracle 数据库精准恢复

从受损或损坏的 Oracle 数据库中精准还原表、模式与数据,助力关键业务快速恢复。

FORENSICS READY

取证级数据提取

为取证与执法机构提供可靠、可追溯的闪存与数据库证据提取能力。

TRUSTED WORLDWIDE

全球数据恢复实验室与取证团队的信赖之选

多语言技术支持、完善的文档资料与持续更新,服务全球专业用户。

ENTERPRISE GRADE

企业级数据安全保障

帮助 IT 与企业团队快速恢复关键业务数据,最大限度降低停机损失。

GET STARTED

立即体验专业数据恢复工具

下载免费试用版,或直接购买正版授权,开启高效数据恢复之旅。

7Z文件损坏了怎么办?数据结构解析

How to recover corrupted 7z archive

Try latest version of 7-Zip

It's possible that new version of 7-Zip can solve your problems with 7z archives. So download latest version of 7-Zip and try to use that new version. You can try also latest alpha or beta version. If new version also doesn't help, read this manual.

Required software:

  • 7-Zip (latest version, that can be stable, alpha or beta version).
  • Some program with hex viewer or editor, for example, FAR Manager.

7z archive structure

7z archive consists of 4 main blocks of data:

  1. Start Header (32 bytes): it contains signature and link to End Header
  2. Compressed Data of files
  3. Compressed Metadata Block for files: it contains links to Compressed Data, information about compression methods, CRC, file names, sizes, timestamps and so on.
  4. End Header: it contains link to Compressed Metadata Block.

Note: If 7z archive contains only one file without encryption, 7-Zip stores Metadata for that file in End Header in uncompressed form, and there are only 3 main blocks in that case.

Archive example

Archive example: a.7z (3740 bytes) that contains 5 files compressed with LZMA method.

Start of archive:

0000000000: 37 7A BC AF 27 1C 00 04 5B 38 BE F9 59 0E 00 00 
0000000010: 00 00 00 00 23 00 00 00 00 00 00 00 7A 63 68 FD 
0000000020: 00 21 16 89 6C 71 3D AB 7D 89 E6 3C 2E BE 60 24 

00: 6 bytes: 37 7A BC AF 27 1C        - Signature 
06: 2 bytes: 00 04                    - Format version
08: 4 bytes: 5B 38 BE F9              - CRC of the following 12 bytes
0C: 8 bytes: 59 0E 00 00 00 00 00 00  - relative offset of End Header
14: 8 bytes: 23 00 00 00 00 00 00 00  - the length of End Header
1C: 4 bytes: 7A 63 68 FD              - CRC of the End Header

Relative offset of End Header is relative from the end of Start Header,
that is at offset 0x20 (32 in decimal).
Real offset of End Header in example archive = 0x20 + 0x0E59 = 0x0E79

20: 00 21 16 89 ... - start of compressed data. 
    Note: if the file was compressed with LZMA method, the first byte 
          is always 00. If first byte is not 00, then archive uses
          another method (it can be LZMA2 or encrypted data with AES).

End of archive:

End Header (offset = 0x0E59, length = 0x23):

0000000E70:                            17 06 8D AD 01 09 80 
0000000E80: AC 00 07 0B 01 00 01 23 03 01 01 05 5D 00 10 00 
0000000E90: 00 0C 81 1A 0A 01 3C 70 52 F7 00 00             

Possible values for first byte in End Header:
   17 - End Header contains the link to Metadata Block.
   01 - Metadata block is stored in End Header.

Corruption types

There are some possible cases when archive is corrupted:

  • You can open archive and you can see the list of files, but when you press Extract or Test command, there are some errors: Data Error or CRC Error.
  • When you open archive, you get message "Can not open file 'a.7z' as archive"

Corruption case: Data errors or CRC errors for files inside archive

Here we describe the case, when you can open archive and you see the list of files, but when you press Extract or Test command, there are some errors: Data Error or CRC Error.

It's pretty difficult to recover data for that case.

If archive was compressed in "Solid" mode, and you have exact copies of some files from archive, you can create similar archive with good copies of files with same settings and in same order, and replace "bad" parts of bad.7z with "good" parts from another good.7z. You must look listings of files in bad and good archives, logs of "test" command, and think about ways to replace bad parts.

The are no more instructions here for that corruption case.

Corruption case: Can not open file 'a.7z' as archive

If you try to open or extract archive and you see the message "Can not open file 'a.7z' as archive", it means that 7-Zip can't open some header from the start or from the end of archive.

In that case you must open archive in hex editor and look to Start Header and End Header.

Possible cases:

  • Case: If start of archive is corrupted, then there is no link to End Header. But if the End Header is OK, and the size of archive is also correct, you can replace data in Start Header in hex editor to the following values:
    0000000000: 37 7A BC AF 27 1C 00 04 00 00 00 00 00 00 00 00
    0000000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    

    Then try to open archive, if you can open and you see the list of files, try Test or Extract command. Look also "Data errors or CRC errors" section in this page.

  • Case: Start Header and End Header are OK, but total size of archive is not OK. You can calculate correct size of archive from values in Start Header. Then you must recover correct size. You can insert some data or remove some data somewhere in archive (for example, at offset of several MBs before the end of archive).

    For example, if you have multi-volume archive: a.7z.001, … , a.7z.009, but one part a.7z.008 is missing, just copy a.7z.007 to file a.7z.008, and 7-Zip will see correct size of archive. Or if some part was reduced, look the size of another parts and restore original (correct) size of "bad" part, so total size will be correct again, and 7-zip will be able to open headers.

  • Case: The end of archive is corrupted or missing. The following text describes that case.

There is no correct End Header at the end of archive

7-Zip writes full Start Header only at the end of archive creation operation.

You can look to Start Header. If you see signature with version and zeros in another fields:

0000000000: 37 7A BC AF 27 1C 00 04 00 00 00 00 00 00 00 00
0000000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

then archive creation operation probably was interrupted by some reason. And in that case probably there are no Metadata Block and End Header at the end of archive.

Note: If archive is multi-volume, uncompleted Start Header is also possible, if first volume was copied before end of archive (last volume) was written. In that case archive is not corrupted. And 7-Zip can unpack such archive, if total size is correct and if there is correct End Header.

If Start Header is OK, you can calculate correct archive size and compare with the size of archive that you have.

If there is no End Header, you can not recover file names, timestamps, and another metadata, but probably it's possible to recover some data as raw file, and then it's possible to recover data from raw file with some parser.

We describe all steps with example:

  1. Create good 7z archive
  2. Corrupt archive
  3. Recover files from corrupted archive

Create good archive

We create some good archive. We use readme.txt (1565 bytes) form 7-Zip 9.20 as example file.

Create readme.txt.bz2, readme.zip, readme.txt.gzip and readme.txt.xz archives from readme.txt.

 

Create a.7z with LZMA method that contains all files:

  readme.txt.bz2
  readme.txt.gz
  readme.zip
  readme.txt
  readme.txt.xz

We have a.7z (3740 bytes). You can look that file in hex editor. It must have structure similar to structure of 7z file described above.

Corrupt archive

Now we currupt a.7z archive. We want to split archive into two parts:

  • a.7z.001: Start Header, some part of Compressed Data
  • a.7z.002: Some part of Compressed Data, Metadata, End Header

Metadata block with End Header are not big for our test archive (smaller than 300 bytes).

We call "Split file…" command in 7-Zip File Manager and type "3000 100G" in "Split to volumes, bytes:" field (100G means that second part can not be larger than 100 GB).

We have two parts: a.7z.001 (3000 bytes) and a.7z.002 (740 bytes). Then we copy a.7z.001 to bad.7z and try to open bad.7z. And we get the message "Can not open file 'bad.7z' as archive", so we have corrupted archive.

Recover archive

We open bad.7z in hex editor

0000000000: 37 7A BC AF 27 1C 00 04 5B 38 BE F9 59 0E 00 00
0000000010: 00 00 00 00 23 00 00 00 00 00 00 00 7A 63 68 FD
0000000020: 00 21 16 89 6C 71 3D AB 7D 89 E6 3C 2E BE 60 24

We see that Start Header is OK.

We calculate correct archive size from Start Header fields values:

0x0E59 + 0x20 + 0x23 = 0x0E9C = 3740

Correct size is 3740 bytes, but our "bad.7z" is only 3000 bytes.

We look to the end of archive:

0000000B60: 55 73 EA 87 45 18 FC AD 67 0D 40 EF F4 41 49 63
0000000B70: 6A 87 54 70 32 6C B0 8F 76 2A 63 BF 12 5D 88 CD
0000000B80: 22 76 9F 97 05 3B 37 BE 49 CD F8 0A CC 67 FB FE
0000000B90: 17 2E 16 D5 1F 8C 5A 30 08 7F C6 E9 98 9F 00 F1
0000000BA0: A6 99 F9 ED 01 62 84 48 77 69 C7 65 21 21 42 66
0000000BB0: 48 F1 FE 79 06 08 25 68

And we don't see End Header at the end of archive.

Conclusion: archive probably was truncated.

Now we want to create another "good" 7z archive that contains good Start Header, End Header. and we want to place Compressed Data block from bad.7z inside that new "good" archive.

At first we look start of Compressed Data block in bad.7z:

0000000020: 00 21 16 89 6C 71 3D AB 7D 89 E6 3C 2E BE 60 24

If LZMA method was used, then first byte in compressed data is always 0 and high bit of second byte is also 0. So if we see 00 in first byte and from 00 to 7F in second byte, probably LZMA method was used (not LZMA2).

If first byte in compressed data is not 0 or if the value of second byte is higher then 7F, then it's not LZMA stream. It can be LZMA2 (or AES encrypted stream).

We must create new "good" 7z archive with same method as in bad.7z, and new archive must be much larger than bad.7z

So we select some big file for that new archive. In some cases you can use even bad.7z as that big file. But we use 7-zip.chm. We rename 7-zip.chm (91020 bytes) to file raw.dat and we compress raw.dat to raw.7z with LZMA method with big dictionary size value. The dictionary size must be equal or larger than dictionary size in bad.7z.

raw.7z is (84898 bytes) that is much larger than bad.7z, as required. if raw.7z is smaller than "bad.7z", you must create another raw.7z with another raw.dat that is larger.

We call "Split file…" function for bad.7z and type "32 100G" in "Split to volumes, bytes:" field.

It creates 2 parts:

  • bad.7z.001: 32 bytes : Start Header
  • bad.7z.002: 2968 bytes : start of Compressed Data

We call "Split file…" function for raw.7z and type "32 2968 100G" in "Split to volumes, bytes:" field. Note that the value 2968 is equal to size of "bad.7z.002". When you recover real archive, you must use exact size of your bad.7z.002.

It creates 3 parts:

  • raw.7z.001: 32 bytes : Start Header
  • raw.7z.002: 2968 bytes : start of Compressed Data
  • raw.7z.003: 81898 bytes : end of Compressed Data, Metadata Block, End Header

Then we rename bad.7z.002 file to raw.7z.002

Now multi-volume "raw.7z.*" archive contains good headers from raw.7z and compressed data from "bad.7z"

We press "Extact" for raw.7z.001 file. It will extract raw.dat file and probably it will show "Data Error" message.

Now we have raw.dat file that contains recovered stream from bad.7z.

Most of 7z archives are solid. If bad.7z archive was solid, then recovered stream consists of concatenated original files

If bad.7z archive is not solid, then recovered stream contains data for one file. It can also contain some garbage data at the end.

Parsing raw stream for recovered solid archive

No we must use some parser software that will look raw.dat, search file signatures and extract some files from that file.

You can try to use parser from 7-Zip.

You need 7-Zip 9.34 alpha or later version.

Select raw.dat and call context menu command "7-Zip > Open Archive > #"

It shows:

 

  1.bz2
  2.readme.txt.gz
  3.zip
  4
  5.xz

Press Extract command to extract these files.

So we have recovered some of the original files, but without original names.

7-Zip parser can find archives in raw file. But it doesn't recognize another files, like xml, html, jpg, png files and so on. So probably you need some another parser software to extract files from raw file.

Recovering non-solid archives and archives with multiple solid blocks

If there are more than one solid block in 7z archive, you must detect exact end of solid block, and start of next solid block.

The recovering procedure for that case will be described in future

常见问题解答

7z文件损坏后如何恢复?

首先尝试下载最新版本的7-Zip,包括稳定版、alpha或beta版,因为新版本可能修复了导致损坏的兼容性问题。如果新版本仍无法打开,建议使用十六进制查看器(如FAR Manager)检查文件结构,并参考专业数据恢复工具(如Flash Extractor)的指导手册进行手动修复。

7z归档文件由哪些主要数据块组成?

7z归档文件主要由4个数据块组成:起始头(32字节),包含文件签名和指向其他块的链接;后续块包括头、内容和尾部信息。理解这些结构有助于定位损坏位置,从而使用十六进制编辑器进行针对性修复。

为什么最新版7-Zip可能解决损坏问题?

7-Zip的每个新版本都会改进解压算法和错误处理机制,可能兼容更多压缩参数或修复已知的解压bug。因此,当遇到7z文件无法打开时,升级到最新版(包括alpha/beta)是成本最低的尝试,往往能解决因版本不兼容导致的伪损坏问题。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

分享微博XFacebookLinkedIn

需要专业数据恢复工具?

了解我们的旗舰产品,或购买正版授权,立即开始。

查看产品立即购买