zipfile.BadZipfile:文件的错误CRC-32 |只读文件

时间:2018-02-12 11:20:09

标签: python zip extract zipfile brute-force

在zip文件中有一个受密码保护的只读文件,我需要将其解压缩到/ tmp目录。

我收到一个CRC-32错误,表明该文件已损坏,但我知道它不是,并且实际上是一个只读文件。有什么建议吗?

错误:

Traceback (most recent call last):
File "/tmp/usercode.py", line 45, in <module>
zip.extractall('/tmp',pwd = "piso")
File "/usr/lib64/python2.7/zipfile.py", line 1040, in extractall
self.extract(zipinfo, path, pwd)
File "/usr/lib64/python2.7/zipfile.py", line 1028, in extract
return self._extract_member(member, path, pwd)
File "/usr/lib64/python2.7/zipfile.py", line 1084, in _extract_member
shutil.copyfileobj(source, target)
File "/usr/lib64/python2.7/shutil.py", line 49, in copyfileobj
buf = fsrc.read(length)
File "/usr/lib64/python2.7/zipfile.py", line 632, in read
data = self.read1(n - len(buf))
File "/usr/lib64/python2.7/zipfile.py", line 672, in read1
self._update_crc(data, eof=(self._compress_left==0))
File "/usr/lib64/python2.7/zipfile.py", line 647, in _update_crc
raise BadZipfile("Bad CRC-32 for file %r" % self.name)
zipfile.BadZipfile: Bad CRC-32 for file 'alien-12.txt'

代码:

# importing required modules
from zipfile import ZipFile

# specifying the zip file name
file_name = "/tmp/alien-12.zip"

# opening the zip file in READ mode
with ZipFile(file_name, 'r') as zip:
    # printing all the contents of the zip file
    zip.printdir()

    # extracting all the files
    print('Extracting all the files now...')
    zip.extractall('/tmp',pwd = "piso")
    print('Done!')

如果我更改以下行:

    zip.extractall('/tmp',pwd = "piso")

然后我得到错误:

IOError: [Errno 30] Read-only file system: 

然后通过尝试输出zip文件中的内容来继续尝试修复它。

zipfile.testzip() returns which then errors

错误:

 RuntimeError: File alien-12.txt is encrypted, password required for extraction

0 个答案:

没有答案