Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detection of encrypted RAR5 archives #1374

Closed
clover21 opened this issue Apr 27, 2020 · 11 comments
Closed

Detection of encrypted RAR5 archives #1374

clover21 opened this issue Apr 27, 2020 · 11 comments

Comments

@clover21
Copy link

clover21 commented Apr 27, 2020

Hi, I am currently trying to use libarchive (13.4.3) to test if an archive is password protected.
I used "archive_entry_is_encrypted", which is working for zip and 7z archives. My problem is that it doesn't work for RAR5 archives (I didn't try older versions of RAR), the method returns false even if there is a password.

Am I missing something ? Is there a way to detect encrypted RAR5 archives ?

@mmatuska
Copy link
Member

mmatuska commented May 1, 2020

@antekone could you please give an answer to this question? Thanks.

@clover21
Copy link
Author

My bad, I described the problem wrongly.
In fact libarchive cannot open my RAR5 archives at all (made with file-roler), encrypted or not.
I get a -30 return code when using "archive_read_open_filename" on them.
No wonder it cannot state about encryption then.

Is there a special way to open RAR5 files ? Is it not supposed to work ?

@mmatuska
Copy link
Member

What version of libarchive are you using? 13.4.3 is unknown to me and 3.4.3 was released on May, 20th. If you have bsdtar installed you can check the version number with bsdtar --version

@antekone
Copy link
Contributor

Sorry, from some reason I've missed this issue. Not sure why. @clover21 is it an option for you to share the RAR5 archives you're trying to open?

@clover21
Copy link
Author

I don't have bsdtar.
I am currently using libarchive.so.13.2.2 but I reinstalled my laptop since the first message, so I was probably using libarchive.so.13.4.3 then, which may be an explanation of how I described the problem the first time (or maybe not since you say that version was not released, my memory is not the best).
I can try to get the last version.

I tried to attach some rar archives with this message but it says "We don't support that file type".

@clover21
Copy link
Author

clover21 commented Jun 22, 2020

Well obviously the 3.2.2 was not yet managing RAR5 archives.
I think last time I built libarchive from git repo in my previous environment but since the laptop reinstall I went back to the version in Ubuntu repo.
I will try to get back the last version and confirm if the problem is as described first, a specific issue to detect if RAR5 archive is encrypted and not to open them in general.

@clover21
Copy link
Author

OK, so I upgraded with build from current master.
It was like I said in the first message, archive_read_open_filename works on RAR5 archives but not archive_entry_is_encrypted, which returns false even when a password was set for the archive.
Is there a place where I can share an example of encrypted RAR5 archive like you suggested ?

@antekone
Copy link
Contributor

Hi,

Current implementation of RAR5 unpacker in libarchive doesn't support encrypted archives.

I'm not an expert in libarchive's API, but I think it would be a nice addition to have some API to verify if a particular unpacker supports encryption or not. In current implementation, archive_entry_is_encrypted will always return false, since the unpacker reports 'unsupported':

static int rar5_has_encrypted_entries(struct archive_read *_a) {
    (void) _a;

    /* Unsupported for now. */
    return ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED;          
}  

I think if you're testing it on simple encrypted files, then there's no need to upload them anywhere.

If you only need to detect if RAR5 are encrypted or not, without actual decryption, I think it's possible to create small tool for it without much effort. Please give me a note if that's the case.

@clover21
Copy link
Author

Thanks for the answer.
I ended up using another way to deal with encrypted archives.
I call 7z from my application and parse the output.
It's not as clean as using a library but it does the job for now.

@zyphs21
Copy link

zyphs21 commented Sep 24, 2021

Thanks for the answer.
I ended up using another way to deal with encrypted archives.
I call 7z from my application and parse the output.
It's not as clean as using a library but it does the job for now.

@clover21 Hello, I am facing the same problem: Can not detect whether the rar5 is encrypted or not ? Could you please tell me more about how you solve this problem?

@clover21
Copy link
Author

Hi, like I said in my previous message, I execute 7z from my program (using exec in Golang) and parse the output of stdout to find relevant information. No clean, but it works somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants