Niraj Choubey
Niraj Choubey

Reputation: 4040

unzip password protected file

how to unzip a password protected file using dotnetzip or sharpziplib (if the password is not known).

Upvotes: 4

Views: 12792

Answers (3)

Cheeso
Cheeso

Reputation: 192637

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.

Upvotes: 7

sarnold
sarnold

Reputation: 104090

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).

Upvotes: 8

Andreas Dolk
Andreas Dolk

Reputation: 114817

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.

Upvotes: 2

Related Questions