Bash: check if a zip or a rar file has password-protection


ZIP
crypted=$( 7z l -slt -- $file | grep -i -c "Encrypted = +" )
if [ "$crypted" -eq "1" ]; then
    protected=1
fi

RAR
unrar x -p- -y -o+ "$file" 1> /dev/null 2> /dev/null
if [ "$?" -eq "3" ] ; then
    unrar x -p$password -y -o+ "$file" 1> /dev/null 2> /dev/null
fi

Source: https://supportex.net/blog/2011/08/bash-check-zip-rar-file-password-protection/

Facebook Comments
,

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x