how to unzip a password protected file using dotnetzip or sharpziplib (if the password is not known).
-
I would expect that to be impossible - else what is the use of that password? – Hans Kesting Jul 06 '10 at 11:21
-
Programattically, or at all? There's zip password crackers like http://www.lostpassword.com/zip.htm, probably more – Rup Jul 06 '10 at 11:22
-
can we list the names of files present in the zip files – Niraj Choubey Jul 06 '10 at 11:26
3 Answers
GPL-3 zip password-cracking code: http://oldhome.schmorp.de/marc/fcrackzip.html
Using the Ubuntu-supplied packages, it took my machine 19 seconds to crack the password of the supplied sample .zip file (as described in the README).

- 102,305
- 22
- 181
- 238
Passwords in the zip file format are applied to the compressed file entry data. This means that there is not a single password for a zip file. There are N zip entries in a zip file, and each one can have a distinct password, or no password at all. Sometimes you get zipfiles that use the same password for all entries, but this is not required by the specification, nor is it forced by DotNetZip.
Using DotNetZip, you can implicitly read the "central directory" of the zip file to get the list of files (or entries) in the zip file, without using any password. Once again, remember the password applies to the zip entry, not to the zip file itself.
So, something like this:
using (var zip = ZipFile.Read("myzip.zip")) {
foreach (var e in zip.Entries) {
System.Console.WriteLine("Entry: {0}", e.FileName);
}
}
... will print out the list of the names of the entries in a zip file, whether or not any of the entries are protected by a password.
If you want to try to "crack" the password for a password-protected entry, you can repeatedly call ZipEntry.ExtractWithPassword(password)
. It will throw an exception for an incorrect password.
I think if you were serious about cracking a zip, you'd do it in C or C++, using a much smarter algorithm.

- 189,189
- 101
- 473
- 713
No way. You need the password, either you remember the password or the person who knows it or you need a password recovery tool, which should exist somewhere on the dark side of the web.

- 113,398
- 19
- 180
- 268
-
1
-
Sure - create a passwort protected zip archive and open the archive with winzip, winrar, 7zip, ... they all display the content. Password is required to extract a file from the archive. – Andreas Dolk Jul 06 '10 at 11:38
-
-
1Hope someone with dotnetzip experience follows this discussion. BTW - have you just tried reading the directory of a password protected file with dotnetzip? – Andreas Dolk Jul 06 '10 at 11:48