I'm trying to extract contents of password protected zip files that have been zipped using PKWARE SecureZip in Python. Modules that I've tried already are zipfile and pyzipper. But methods of these modules always return 'NotImplementedError: strong encryption (flag bit 6)'.
from pyzipper
with ZipFile('Test.zip') as tz:
tz.extractall(pwd=bytes('testpass', 'utf-8'))
Traceback (most recent call last):
File "D:/Pradeep/Python Workspace/Sandbox/EvoFileDownloader.py", line 4, in <module>
tz.extractall(pwd=bytes('testpass', 'utf-8'))
File "D:\Program Files\Python\lib\zipfile.py", line 1616, in extractall
self._extract_member(zipinfo, path, pwd)
File "D:\Program Files\Python\lib\zipfile.py", line 1669, in _extract_member
with self.open(member, pwd=pwd) as source, \
File "D:\Program Files\Python\lib\zipfile.py", line 1500, in open
raise NotImplementedError("strong encryption (flag bit 6)")
NotImplementedError: strong encryption (flag bit 6)
I have tried to work around this by checking for ways to extract these zip files from the command prompt. However, I don't see 'pkzipc.exe' in my installation directory (as explained in this document).
P.S: I do not have admin rights required to install additional software on my work computer (on which I'm trying this extraction).
Can anyone help me with a solution for this?
The file you are trying to decompress was compressed using commercial software PKWARE SecureZip. This is not standard zip archive so none of free zip software/libraries can extract it.
If you want to decompress it from your app/script there are 2 possible ways. Both requires having commercial PKWARE product installed.
Assuming that you have license to use it I guess the best idea would be to use SecureZIP SDK library provided by PKWARE. This is not python library so you will have to implement a python wrapper for using this sdk. Description of this SecureZIP toolkit for Windows mentions that it uses Microsoft’s Crypto API so perhaps windows.crypto python library might be usefull.
Second approach would require installing free-of-charge PKWARE zip reader and invoking this app with apropriate parameters (assuming it has any command line interface) from your python script using subprocess.call
similar to this post