Which binary bits tells the file is password protected zip or rar file?

3

1

I am looking for the bit flags to detect the file is password-protected, not a regular .zip or .rar.

jerry

Posted 2010-07-30T21:04:08.073

Reputation: 31

What OS/environment/language are you on? Do you want to be able to figure this out from the shell, programmatically, etc.? – Matthew Flaschen – 2010-07-30T21:09:03.197

Answers

3

You can use zipinfo and unrar to test whether a ZIP file is encrypted. E.g.:

zipinfo -v file.zip |grep 'file security status:\s*encrypted'
unrar v -p- file.rar 2>&1|grep 'Encrypted file'

Matthew Flaschen

Posted 2010-07-30T21:04:08.073

Reputation: 2 370

1

You can read about the header structure of rar here

And about the zip header structure here

It helps to download the source code of opensource unpackers to read some code examples.

matthias krull

Posted 2010-07-30T21:04:08.073

Reputation: 2 394