Is there a possibility like in jDownloader, where password protected files are automatically extracted by trying all passwords one by one which are provided by the user?

Something like this:

$ unarchive foo.rar --password-list baz.txt
  • Which specific unarchiver are you using? – nohillside Jan 2 '16 at 15:22
  • @patrix Thanks for your comment! There is no specific unarchiver I use, because the ones I use don't provide this functionality, thus I'm searching for one, which can already do that, if there is any. – user163919 Jan 2 '16 at 15:27
  • You should provide your edited solution as an answer, not by editing the question. – grg Jan 3 '16 at 15:05
  • @grgarside Alright, I added it as an answer. I don't have to check it as solution do I? – user163919 Jan 3 '16 at 15:32
  • 1
    @Byte No, it's fine to leave the other answer as accepted. Putting your answer as an answer makes it easier to see the development of the solution and is less confusing to search/SEO. – grg Jan 3 '16 at 15:37
  • Get unar from http://unarchiver.c3.cx/commandline
  • Extract the archive and put unar (and lsar) somewhere your shell can find it.
  • Run

    while IFS= read pwd; do
        unar -p "$pwd" ARCHIVE
    done < password-list.txt

The solution from @patrix works perfect, except for the case, when the password is not available in the provided list, then the archive will produce a lot of 0 byte files. My changed solution checks, if a password matches, then it's continues to unarchive.

while IFS= read pwd; do
    if lsar -t "$1" -p "$pwd" | grep "[1-9][0-9]* passed" -E -q; then
        unar -p "$pwd" "$1"
done < password-list.txt
  • Ah, great. I didn't have any password-protected archives to test it with. – nohillside Jan 4 '16 at 13:24

You must log in to answer this question.