[New-bugs-announce] [issue24430] ZipFile.read() cannot decrypt multiple members from Windows 7zfm
era
report at bugs.python.org
Thu Jun 11 15:53:41 CEST 2015
New submission from era:
The attached archive from the Windows version of the 7z file manager (7zFM version 9.20) cannot be decrypted into memory. The first file succeeds, but the second one fails.
The following small program is able to unzip other encrypted zip archives (tried one created by Linux 7z version 9.04 on Debian from the package p7zip-full, and one from plain zip 3.0-3 which comes from the InfoZip distribution, as well as a number of archives of unknown provenance) but fails on the attached one.
from zipfile import ZipFile
from sys import argv
container = ZipFile(argv[1])
for member in container.namelist():
print("member %s" % member)
try:
extracted = container.read(member)
print("extracted %s" % repr(extracted)[0:64])
except RuntimeError, err:
extracted = container.read(member, 'hello')
container.setpassword('hello')
print("extracted with password 'hello': %s" % repr(extracted)[0:64])
Here is the output and backtrace:
member hello/
extracted ''
member hello/goodbye.txt
Traceback (most recent call last):
File "./nst.py", line 13, in <module>
extracted = container.read(member, 'hello')
File "/usr/lib/python2.6/zipfile.py", line 834, in read
return self.open(name, "r", pwd).read()
File "/usr/lib/python2.6/zipfile.py", line 901, in open
raise RuntimeError("Bad password for file", name)
RuntimeError: ('Bad password for file', 'hello/goodbye.txt')
The 7z command is able to extract it just fine:
$ 7z -phello x /tmp/hello.zip
7-Zip 9.04 beta Copyright (c) 1999-2009 Igor Pavlov 2009-05-30
p7zip Version 9.04 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU)
Processing archive: /tmp/hello.zip
Extracting hello
Extracting hello/goodbye.txt
Extracting hello/hello.txt
Everything is Ok
Folders: 1
Files: 2
Size: 15
Compressed: 560
----------
files: hello.zip
messages: 245165
nosy: era
priority: normal
severity: normal
status: open
title: ZipFile.read() cannot decrypt multiple members from Windows 7zfm
Added file: http://bugs.python.org/file39680/hello.zip
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24430>
_______________________________________
More information about the New-bugs-announce
mailing list