Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unzip password protected zip in unix

Tags:

shell

unix

unzip

I need to create a shell script wherein I will unzip a password protected zip file. I know the password, and need to automate the unzip process.

How can I achieve this using Unix shell scripting?

like image 272
Murugesh Anand Avatar asked Feb 12 '17 10:02

Murugesh Anand


People also ask

How do I unzip a .ZIP file in Unix?

You can use the unzip or tar command to extract (unzip) the file on Linux or Unix-like operating system. Unzip is a program to unpack, list, test, and compressed (extract) files and it may not be installed by default.

How do I bypass a password on a ZIP file?

If you put the files you'd like to protect in a zip file, you can then apply a password. In Windows Explorer, highlight and right-click on the files you would like to put into a zipped file. Select Send to, then Zip folder (compressed). Double-click the zipped file, then select File and Add Password.

Can you crack a password protected ZIP file?

But, there are multiple methods to crack a password protected zip file to access its content. Cracking of passwords requires a lot of your time depending upon the length and complexity of the password when using the Brute-force method, which we are using for the current tutorial.

How do I unzip a zip 001 file in Linux?

To unzip the example above, you can right-click on the MyImageData. zip. 001 file (after you've installed 7-Zip), select the 7-Zip menu, and then choose one of the "extract" options.


4 Answers

unzip -P your-password zipfile.zip

man unzip

-P password

use password to decrypt encrypted zipfile entries (if any). THIS IS INSECURE! Many multi-user operating systems provide ways for any user to see the current command line of any other user; even on stand-alone systems there is always the threat of over-the-shoulder peeking. Storing the plaintext password as part of a command line in an automated script is even worse. Whenever possible, use the non-echoing, interactive prompt to enter passwords. (And where security is truly important, use strong encryption such as Pretty Good Privacy instead of the relatively weak encryption provided by standard zipfile utilities.)

like image 156
Yaron Avatar answered Oct 22 '22 06:10

Yaron


In Ubuntu, I've to install 7zip (7z) archive tool using following command:

sudo apt-get install p7zip-full

Then, you can use Ubuntu's default Archive Manager to unzip the password protected zip files

like image 33
Atul Khanduri Avatar answered Oct 22 '22 06:10

Atul Khanduri


I ran into problem using unzip saying need PK compat. v5.1 (can do v4.6). Installed p7zip instead and unzipped using following command:

7z x archive.zip -ppassword
like image 17
kub1x Avatar answered Oct 22 '22 06:10

kub1x


To unzip multiple password protected files, this command WILL NOT WORK

unzip -P PASSWORD *.zip

To make it work, you need to include the *.zip in quotes because whenever you use a wildcard (*), the shell itself will expand that and pass the results to the program. This is because, unlike most programs in UNIX, unzip cannot take more than one file at a time.

Read more here https://chrisjean.com/unzip-multiple-files-from-linux-command-line/.

Therefore, to unzip multiple protected files, use this

unzip -P PASSWORD  '*.zip'    
like image 9
R. Mogire Avatar answered Oct 22 '22 06:10

R. Mogire