classification
Title: Zip password issue
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: neologix, sbojchuk, terry.reedy
Priority: normal Keywords:

Created on 2011-03-08 19:53 by sbojchuk, last changed 2011-03-09 11:40 by sbojchuk. This issue is now closed.

Files
File name Uploaded Description Edit
data.zip sbojchuk, 2011-03-08 20:00 Zip password is "pass"
Messages (6)
msg130361 - (view) Author: Yaroslav (sbojchuk) Date: 2011-03-08 19:53
There's issue while setting password.
I brute-force different passwords for that arhive-file, and it pass with different, not correct password. For that arhive password is: "pass", but that arhive is correct in python and even extract files from that with not correct passwords:
('Password is:', 'aafy')
('Password is:', 'aakv')
('Password is:', 'aavu')
('Password is:', 'aazs')
('Password is:', 'abgj')
('Password is:', 'abmr')
('Password is:', 'abzo')
('Password is:', 'acds')
('Password is:', 'acdu')
('Password is:', 'ace')
('Password is:', 'achc')
('Password is:', 'acue')
('Password is:', 'acxi')
('Password is:', 'adcj')
('Password is:', 'adcl')
('Password is:', 'adde')
('Password is:', 'advx')
('Password is:', 'aenu')
('Password is:', 'afbl')
('Password is:', 'afqg')
('Password is:', 'afyl')
('Password is:', 'agef')
('Password is:', 'agtv')
('Password is:', 'aimo')
('Password is:', 'aizr')
('Password is:', 'ajjt')
('Password is:', 'ajlj')
('Password is:', 'akqr')
...
Of course content of file is not correct ("Q1E85�ڳM��ژo��H*]	5Q���
                             ����X">_+x�������I�k�~L>��
").

z = zipfile.ZipFile("data.zip", 'r')
z.setpassword("aafy")
print(z.read("secretfile.txt"))
msg130366 - (view) Author: Yaroslav (sbojchuk) Date: 2011-03-08 20:00
I forgot zip file
msg130368 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011-03-08 20:19
The check is done in py3k:

Traceback (most recent call last):
  File "/home/cf/test_zip.py", line 7, in <module>
    print(z.read("secretfile.txt"))
  File "/home/cf/py3k/Lib/zipfile.py", line 889, in read
    with self.open(name, "r", pwd) as fp:
  File "/home/cf/py3k/Lib/zipfile.py", line 975, in open
    raise RuntimeError("Bad password for file", name)
RuntimeError: ('Bad password for file', 'secretfile.txt')

Try with Python 3.2.
msg130375 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-03-08 21:40
2.6/2.7 only get security fixes. I do not think this qualifies
msg130393 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-03-09 00:51
I meant 2.5/2.6 of course.
msg130449 - (view) Author: Yaroslav (sbojchuk) Date: 2011-03-09 11:40
Ok, i try that example in new versions 3+, and it works there. Thanks
History
Date User Action Args
2011-03-09 11:40:57sbojchuksetstatus: open -> closed

messages: + msg130449
2011-03-09 00:51:09terry.reedysetmessages: + msg130393
2011-03-08 21:40:22terry.reedysettype: behavior
components: + Library (Lib)
versions: - Python 2.6, Python 2.5
nosy: + terry.reedy

messages: + msg130375
stage: test needed
2011-03-08 20:19:10neologixsetnosy: + neologix
messages: + msg130368
2011-03-08 20:00:36sbojchuksetfiles: + data.zip

messages: + msg130366
2011-03-08 19:53:20sbojchukcreate