mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Can't extract encrypted 7z LZMA2 files #155
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ciriousjoker on GitHub (Feb 5, 2017).
I have an encrypted 7zip archive (linked below) encrypted with the password "dontgoout", but whenever I try to extract it, it throws an error at MoveToNextEntry.
Here's a screenshot of the stack trace:
https://gyazo.com/6fb0b0c0731d6e23d04a26e301cc2dbe
I created the archive using the 7zip client for Windows using these settings:
https://gyazo.com/ca4e67e6a259d79cdf0675dc42fd8268
Original name was 0.tmp, but Github only allows zip files.
0.tmp.encrypted.zip
Extracting the same archive without any password works perfectly fine and I can extract the encrypted 7z archive using the 7zip desktop client, so this has to be a bug in the library (Or I'm just too dumb for life and I missed something I should have done)
Here's the code I used to extract that archive:
@adamhathcock commented on GitHub (Feb 5, 2017):
I was about to say "sharpcompress doesn't support encrypted 7zip files" but honestly I can't remember.
However, the error you got is fixable because it's using a stream that doesn't support seeking though 7zip requires seeking.
@ciriousjoker commented on GitHub (Feb 5, 2017):
But if the library requires seekable streams (which totally makes sense the way 7z works), why did it work with unencrypted files? I mean they'd have to be seekable too, right?
@ciriousjoker commented on GitHub (Feb 5, 2017):
Woops
@adamhathcock commented on GitHub (Feb 5, 2017):
It must be that the decryption code just needs to know the length for some reason and it's using a different stream class.
The class with the error is one I wrote for the purpose of ensuring no seekable stream was used in other parts of the code.
I haven't done much with the 7zip code personally. I really hate the 7zip archive format.
@ciriousjoker commented on GitHub (Feb 5, 2017):
Can you point me in the right direction please? I tried using your API examples, but they only seem to work with zip archives ..
(Aka replacing
var archive = ...;
with
var archive = ArchiveFactory.Open(...);
doesn't work either)
SevenZipArchive.Open(new FileStream(...));
also didn't work
@adamhathcock commented on GitHub (Feb 5, 2017):
It's not going to work without a code change. You're going to get the exception you posted always with that encrypted 7zip file
@ciriousjoker commented on GitHub (Feb 5, 2017):
So I'd have to fix your library? Or are you saying that my encrypted 7zip file is broken?
By the way, no matter what 7zip file I use (encrypted or not doesn't matter), I get this weird thing in the locals tab:
https://gyazo.com/363d6b37b9dd0ff79df69d602d04fa52
Not sure if it has something to do with this error, but it always throws that error. However, with unencrypted 7z files it still extracts the whole thing
@adamhathcock commented on GitHub (Feb 5, 2017):
I have a feeling encrypted 7zip just isn't supported. I don't recall putting that in the supported formats matrix
@ciriousjoker commented on GitHub (Feb 5, 2017):
Ye, I just assumed that encrypted 7zips wouldn't make a difference to the 7z.dll ...
Anyway, I "fixed" it now by encrypting the final 7z with AES. For my purposes that's acceptable
@adamhathcock commented on GitHub (Feb 5, 2017):
This code doesn't used the 7z dll. That's why he behavior is different than other libraries as others do use the native dll.