selmf / unarr

A decompression library for rar, tar, zip and 7z archives
GNU Lesser General Public License v3.0
70 stars 13 forks source link

RAR 5.0 support needed #3

Open VictorVG opened 5 years ago

VictorVG commented 5 years ago

RAR 5.0 format support needed, Your can see example for unpack code in to source tarball unrarsrc-5.7.4.tar.gz (ftp://Anonymous:user@server.com@ftp.rarlabs.com:21/rar/unrarsrc-5.7.4.tar.gz) on FTP RarLabs.com. Starting on Rar/WinRAR v5.00 (22.08.2013 year) RAR5 is default compression format fo rar archives (see WhatsNew.txt for details and have different in to RAR 2.9 (used up to Rar v2.5 - Rar v4.20 as default) format.

Please, update unarr library for support this Rar archive default format.

selmf commented 5 years ago

Yes, RAR5 is needed. I am working on it, but this takes time. The structure and algorithms of the new format are different from the previous versions and I can't use the unrar source code as a reference (license problems), so I can't really tell when this will be finished.

VictorVG commented 5 years ago

Your can see as example source Far Manager plug-in MultiArc - rar.fmt - rar.cpp - this module used for detect any RAR version. But RAR5 have large size of SFX module ~ 200 - 250 Kb then old RAR format - ~ 80 - 90 Kb in to start of archive.

VictorVG commented 5 years ago

I asked for a consultation from the RAR developer - EugeneRoshal (Eugene Roshal) and this is what he answered:

EugeneRoshal (Eugene Roshal)

We have laid out the sources of our unpacker under our license. The same 7-Zip calmly uses them with the addition of a link to the UnRAR license in its License.txt.

If they include the "unRAR license restriction" clause in their license, as is done in 7-Zip license.txt, they can use the unrar source code.

selmf commented 5 years ago

No, I can't use it. The whole point of unarr as a rar extraction library is that it provides rar support without the UnRAR license restriction. This allows other open source software that can't use the UnRAR license to use unarr instead. If I start using UnRAR code I have to add the license restriction and unarr will be useless for these projects, including SumatraPDF.

FYI, the current rar extraction code is based on reverse engineering done by TheUnarchiver and they have added rar5 support, so I can use that as a reference.

VictorVG commented 5 years ago

It is clear that there are already legal issues, and I am a computer systems engineer and I don’t undertake to give advice to someone else’s area of knowledge in order not to harm.

selmf commented 5 years ago

Don't worry, it's not that bad. I have no plans to implement a rar compressor, so Mr. Roshal shouldn't have any reasons to complain about unarr. I just have to be careful to avoid using the UnRAR licensed code, so I don't 'taint' the project.

VictorVG commented 5 years ago

On this and we stumbled. We can help with technology, but licensing issues are beyond our power and we gave a hint on the example of the algorithm - and as it turned out both think the same way - take the algorithm from the 7-Zip library as an example. There is also the main thing - methods of working with a container, and they are usually the most difficult to come up with.

selmf commented 5 years ago

Yes. I have some support for rar5 on a local, unpublished branch. Parsing rar5 and reading stored files is already possible, but extraction of compressed files is not as I'm still investigating the details of the algorithm and filters. I have TheUnarchiver as an example, but this is written in ObjectiveC, so understanding it is not straightforward for me. But I need this feature myself, so it will happen sooner or later.

VictorVG commented 5 years ago

In theory, it is better to look at the algorithms in unrar - it’s on c / C ++ and I think it’s clearer, the very way of recognizing with parsing the signature (the format of the RAR container was changed in RAR 1.4, RAR 1.50, RAR 2.50 and RAR 5.00) is probably easier to see in the UnRAR plugin - everything is commented out in contrast to my habits :) (I can easily write several tens of thousands of microcode lines and no comments - this is usually faster, and then when I redid the block scheme itself and the old microcode doesn’t seem to be necessary - it’s wise to look at the inputs of logic elements, adders and triggers with encoders even e e in relation to sinrosignalam? Faster and easier to write new :))

tm681 commented 5 years ago

Виктор, я очень извиняюсь что не по теме пишу - не знаю Ваш емейл. Сможете ли помочь с проблемой - не копируются сессии в панель Netbox - вот тут я расписал подробно https://forum.farmanager.com/viewtopic.php?f=5&t=6317&start=2480 в конце темы: Far 3.0.5445 x64 (NetBox 2.4.5.531)

Не могу импортировать в NetBox фтп-аккаунты. С него можно скопировать, в него - нельзя. Нажимаю F5, появляется красная табличка "Import session(s) from selected file(s)?" Нажимаю "Да" - ничего не происходит.

Переименование папок (shift-F6) также не срабатывает, переименовываются только фтп-аккаунты.

VictorVG commented 5 years ago

@tm681

Ответил на багтрекере NetBox https://github.com/michaellukashov/Far-NetBox/issues/291 куда и прошу перейти по всем вопросам NetBox. Так же можно задать мне вопросы на моём багтрекере .

@selmf

Please, sorry on offtopic. I move this question in to NetBox bug-tracker.

pashifika commented 2 years ago

@selmf Here is a go-based implementation: https://github.com/nwaples/rardecode/blob/master/decode50.go

dejlek commented 2 years ago

Could perhaps a fallback to using unrar/rar (if present on the system) tools be an option? No legal issues with that approach either.

selmf commented 2 years ago

Thanks for your continued interest. There are two things that I want to finish before I re-tackle the RAR5 support:

Thankfully, the amount of open source software supporting rar5 has increased so I have some references to work with. I do not plan to add any dependencies on a command line tool but the option to provide a fallback using libunrar (based on official rar) or an open source implementation as fallback is a possibility.

Dennis-Zhang-SH commented 1 year ago

Any updates on this issue?

VictorVG commented 1 year ago

/rar/rar.c str 205 - 224:

ar_archive *ar_open_rar_archive(ar_stream *stream)
{
    char signature[FILE_SIGNATURE_SIZE];
    if (!ar_seek(stream, 0, SEEK_SET))
        return NULL;
    if (ar_read(stream, signature, sizeof(signature)) != sizeof(signature))
        return NULL;
    if (memcmp(signature, "Rar!\x1A\x07\x00", sizeof(signature)) != 0) {
        if (memcmp(signature, "Rar!\x1A\x07\x01", sizeof(signature)) == 0)
            warn("RAR 5 format isn't supported");
        else if (memcmp(signature, "RE~^", 4) == 0)
            warn("Ancient RAR format isn't supported");
        else if (memcmp(signature, "MZ", 2) == 0 || memcmp(signature, "\x7F\x45LF", 4) == 0)
            warn("SFX archives aren't supported");
        return NULL;
    }

    return ar_open_archive(stream, sizeof(ar_archive_rar), rar_close, rar_parse_entry, rar_get_name, rar_uncompress, NULL, FILE_SIGNATURE_SIZE);
}
milahu commented 1 year ago
rant against rar's shitty license honestly, fuck Eugene Roshal and his shitty license. i have never accepted his license, and i have never accepted any copyright law or patent law. lets move to the darknet (example: [darktea](http://it7otdanqu7ktntxzm427cba6i53w6wlanlh23v5i3siqmos47pzhvyd.onion)), and reverse-engineer winrar, to write a fully-open-source rar compressor and decompressor. possible names: - openrar - fossrar - fuckeugenerar - rarminuseugene it should be possible to use a cracked winrar, to generate a corpus of test files... it should be possible to reverse-engineer winrar with ida/ghidra, to get the algorithms...
VictorVG commented 1 year ago

milahu

You first look at what and why. With the support of the RAR5 in unaar, the "problem" comes down to the choice of a license, and the source of the unpacker has long been on ftp.rarlabs.com/rar/unrarsrc-*.tar.gz or is this discovery for you?

You read the issues and you will see everything.