1

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?

  • Can you attach a sample zip file such that we can test it? – Molitoris Jul 31 '20 at 09:37
  • 1
    @Molitoris I would advise to not download and open up files given in examples. I would instead ask of a way to replicate the file / archive via code or one provided from a reputable source. – Hampus Larsson Jul 31 '20 at 09:39
  • Does this answer your question? [Python unzip AES-128 encrypted file](https://stackoverflow.com/questions/15553150/python-unzip-aes-128-encrypted-file) – running.t Jul 31 '20 at 09:45
  • Especially take a look at [this](https://stackoverflow.com/a/15554407/2018369) answer – running.t Jul 31 '20 at 09:46
  • [This](https://stackoverflow.com/a/15554407/2018369) solution requires 7zip to be installed, but as I mentioned in the question, I'm attempting the extraction in a work computer for which I do not have admin rights (needed to install any new software). – Pradeep Kumar N Jul 31 '20 at 10:04
  • I downloaded the 7zip exe and executed the following command: `7za x -ptestpass "C:\Users\prade\Desktop\Test.zip"` However, this returns the following error: `Extracting archive: C:\Users\prade\Desktop\Test.zip` `ERROR: Unsupported Method : Test\1.jpg` `ERROR: Unsupported Method : Test\2.jpg` `ERROR: Unsupported Method : Test\3.jpg` `Sub items Errors: 3` `Archives with Errors: 1` `Sub items Errors: 3` 1.jpg, 2.jpg and 3.jpg are files within Test.zip – Pradeep Kumar N Jul 31 '20 at 10:45
  • So the key information here, that I missed is that it was zipped using PKWARE SecureZip. So I guess the only way to unzip is to use this particular softrware. I know it's enterprise class software and you might not have license for it purchased. If that is the case consider using free of charge [PKWARE Zip reader](https://www.pkware.com/zip-reader) for extracting. And... I dont know if it's possible to use it without instalation and later to use command line version in python. – running.t Jul 31 '20 at 12:06

1 Answers1

1

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

running.t
  • 5,329
  • 3
  • 32
  • 50