1673482012.FILE5_44-16-gb29519e7.detect-android-apk-files-fc-stegerman.patch 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. Subject: Detect Android APK files (FC Stegerman)
  2. Origin: FILE5_44-16-gb29519e7 <https://github.com/file/file/commit/FILE5_44-16-gb29519e7>
  3. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  4. Date: Thu Jan 12 00:06:52 2023 +0000
  5. --- a/magic/Magdir/archive
  6. +++ b/magic/Magdir/archive
  7. @@ -1505,6 +1505,65 @@
  8. !:mime application/zip
  9. !:ext zip/cbz
  10. +# Android APK file (Zip archive)
  11. +0 string PK\003\004
  12. +!:strength +1
  13. +# Starts with AndroidManifest.xml (file name length = 19)
  14. +>26 uleshort 19
  15. +>>30 string AndroidManifest.xml Android package (APK), with AndroidManifest.xml
  16. +>>>-22 string PK\005\006
  17. +>>>>(-6.l-16) string APK\x20Sig\x20Block\x2042 \b, with APK Signing Block
  18. +!:mime application/vnd.android.package-archive
  19. +!:ext apk
  20. +# Starts with META-INF/com/android/build/gradle/app-metadata.properties
  21. +>26 uleshort 57
  22. +>>30 string META-INF/com/android/build/gradle/
  23. +>>>&0 string app-metadata.properties Android package (APK), with gradle app-metadata.properties
  24. +>>>>-22 string PK\005\006
  25. +>>>>>(-6.l-16) string APK\x20Sig\x20Block\x2042 \b, with APK Signing Block
  26. +!:mime application/vnd.android.package-archive
  27. +!:ext apk
  28. +# Starts with classes.dex (file name length = 11)
  29. +>26 uleshort 11
  30. +>>30 string classes.dex Android package (APK), with classes.dex
  31. +>>>-22 string PK\005\006
  32. +>>>>(-6.l-16) string APK\x20Sig\x20Block\x2042 \b, with APK Signing Block
  33. +!:mime application/vnd.android.package-archive
  34. +!:ext apk
  35. +# Starts with META-INF/MANIFEST.MF (file name length = 20)
  36. +# NB: checks for resources.arsc or drawables as well to avoid matching JAR files
  37. +>26 uleshort 20
  38. +>>30 string META-INF/MANIFEST.MF
  39. +# Contains resources.arsc (near the end, in the central directory)
  40. +>>>-512 search resources.arsc Android package (APK), with MANIFEST.MF and resources.arsc
  41. +>>>>-22 string PK\005\006
  42. +>>>>>(-6.l-16) string APK\x20Sig\x20Block\x2042 \b, with APK Signing Block
  43. +!:mime application/vnd.android.package-archive
  44. +!:ext apk
  45. +>>>-512 default x
  46. +# Contains drawables (near the end, in the central directory)
  47. +>>>>-512 search res/drawable Android package (APK), with MANIFEST.MF and drawables
  48. +>>>>>-22 string PK\005\006
  49. +>>>>>>(-6.l-16) string APK\x20Sig\x20Block\x2042 \b, with APK Signing Block
  50. +!:mime application/vnd.android.package-archive
  51. +!:ext apk
  52. +# Starts with zipflinger virtual entry (28 + 104 = 132 bytes)
  53. +# See https://github.com/obfusk/apksigcopier/blob/666f5b7/apksigcopier/__init__.py#L230
  54. +>4 string \x00\x00\x00\x00\x00\x00
  55. +>>&0 string \x21\x08\x21\x02
  56. +>>>&0 string \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
  57. +>>>>&0 string \x00\x00 Android package (APK), with zipflinger virtual entry
  58. +>>>>>-22 string PK\005\006
  59. +>>>>>>(-6.l-16) string APK\x20Sig\x20Block\x2042 \b, with APK Signing Block
  60. +!:mime application/vnd.android.package-archive
  61. +!:ext apk
  62. +# APK Signing Block
  63. +>0 default x
  64. +>>-22 string PK\005\006
  65. +>>>(-6.l-16) string APK\x20Sig\x20Block\x2042 Android package (APK), with APK Signing Block
  66. +!:mime application/vnd.android.package-archive
  67. +!:ext apk
  68. +
  69. # Zip archives (Greg Roelofs, c/o zip-bugs@wkuvx1.wku.edu)
  70. 0 string PK\005\006 Zip archive data (empty)
  71. !:mime application/zip