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

Port ScanZip improvements to ScanRar, Fix Password Cracking, Port Password Caching to ScanZip #442

Merged
merged 9 commits into from
Mar 11, 2024

Conversation

ryanohoro
Copy link
Collaborator

@ryanohoro ryanohoro commented Mar 7, 2024

Describe the change

  • Fixes broken password cracking in ScanRar [BUG] ScanRar Emits Exception on Password-Protected Archives #441
  • Ports ScanZip improvements to ScanRar, including limits and multi-password archive support
  • Outputs filenames of encrypted member files
  • Add archive comments
  • Add archive timestamps (datetime is a copy of mtime for compatibility)
  • Add tag for encrypted headers
  • Allow ScanZip to only load the password file once
  • Upgrades rarfile 4.0 to 4.1
  • New ScanRar tests and fixtures

Known Limitation: Archives with encrypted headers, but containing an unencrypted member file will fail to extract properly. This is a limitation of the underlying rarfile library.

Describe testing procedures

New tests are passing on build. Password cracking functions when crack_pws: True in backend.yaml set in a running container.

Sample output

./strelka-oneshot -l - -f src/python/strelka/tests/fixtures/test_comment_time.rar 
{
    "rar": {
        "comment": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        "compression_rate": 63.19,
        "elapsed": 0.006044,
        "files": [{
                "atime": "2024-03-06T19:10:07.865616500+00:00",
                "compression_rate": 63.19,
                "compression_size": 1478,
                "ctime": "2024-03-06T19:10:07.865616500+00:00",
                "datetime": "2022-12-12T03:12:55.499569400+00:00",
                "encrypted": false,
                "extracted": true,
                "file_name": "lorem.txt",
                "file_size": 4015,
                "mtime": "2022-12-12T03:12:55.499569400+00:00"
            }
        ],
        "host_os": "RAR_OS_WIN32",
        "total": {
            "extracted": 1,
            "files": 1
        }
    },
}
./strelka-oneshot -l - -f src/python/strelka/tests/fixtures/test_password_encrypted_headers.rar
{
    "rar": {
        "compression_rate": 62.94,
        "elapsed": 0.236674,
        "files": [{
                "compression_rate": 62.94,
                "compression_size": 1488,
                "datetime": "2022-12-12T03:12:55.499569400+00:00",
                "encrypted": true,
                "extracted": true,
                "file_name": "hidden/lorem-hidden.txt",
                "file_size": 4015,
                "mtime": "2022-12-12T03:12:55.499569400+00:00"
            }, {
                "compression_rate": 62.94,
                "compression_size": 1488,
                "datetime": "2022-12-12T03:12:55.499569400+00:00",
                "encrypted": true,
                "extracted": true,
                "file_name": "hidden/lorem-readonly.txt",
                "file_size": 4015,
                "mtime": "2022-12-12T03:12:55.499569400+00:00"
            }, {
                "compression_rate": 62.94,
                "compression_size": 1488,
                "datetime": "2022-12-12T03:12:55.499569400+00:00",
                "encrypted": true,
                "extracted": true,
                "file_name": "lorem.txt",
                "file_size": 4015,
                "mtime": "2022-12-12T03:12:55.499569400+00:00"
            }
        ],
        "flags": [
            "password_protected",
            "encrypted_filenames"
        ],
        "host_os": "RAR_OS_WIN32",
        "total": {
            "extracted": 3,
            "files": 3
        }
    }
}

**Checklist**
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of and tested my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings

@phutelmyer
Copy link
Contributor

FYSA for testing locally on a Mac -

Kept running into:

[Problem when using rarfile in Python: BadRarFile: Failed the read enough data: req=65536 got=0](https://stackoverflow.com/questions/71308687/problem-when-using-rarfile-in-python-badrarfile-failed-the-read-enough-data-r)

This resolved the issue:

brew install carlocab/personal/unrar

@phutelmyer
Copy link
Contributor

phutelmyer commented Mar 7, 2024

Formatting scan_rar.py with Black to pass style test.
Functional tests look good. Thank you for updating these!

@phutelmyer phutelmyer merged commit 7f71bcb into target:master Mar 11, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants