redballoonsecurity / ofrak

OFRAK: unpack, modify, and repack binaries.
https://ofrak.com
Other
1.82k stars 128 forks source link

Support `application/vnd.android.package-archive` mime type for APKs #470

Closed ANogin closed 1 month ago

ANogin commented 1 month ago

One sentence summary of this PR (This should go in the CHANGELOG!) Support application/vnd.android.package-archive mime type for APKs, which is returned by newer versions of libmagic

Link to Related Issue(s) N/A

Please describe the changes in your request. In Debian 12 Bookworm with libmagic 5.44-3, ofrak_core/test_ofrak/components/test_apk.py currently fails, as the ApkIdentifier does not recognize the test apk file as such. The issue is that currently ApkIdentifier expects apks to be recognized by libmime as application/java-archive or application/zip but in fact it is recognized as application/vnd.android.package-archive. This change adds application/vnd.android.package-archive to ApkIdentifier - for that mime type, the Apk tag is immediately added without checking the archive contents.

Note that for newer libmagic the old code is not actually needed (and would only cause the identifier to take too long to reject the non-APK zip archives), but I kept it as we obviously want to support older versions of libmagic as well for time being.

Anyone you think should look at this, specifically? Not sure.