android 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #------------------------------------------------------------
  2. # $File: android,v 1.12 2019/04/19 00:42:27 christos Exp $
  3. # Various android related magic entries
  4. #------------------------------------------------------------
  5. # Dalvik .dex format. http://retrodev.com/android/dexformat.html
  6. # From <mkf@google.com> "Mike Fleming"
  7. # Fixed to avoid regexec 17 errors on some dex files
  8. # From <diff@lookout.com> "Tim Strazzere"
  9. 0 string dex\n
  10. >0 regex dex\n[0-9]{2}\0 Dalvik dex file
  11. >4 string >000 version %s
  12. 0 string dey\n
  13. >0 regex dey\n[0-9]{2}\0 Dalvik dex file (optimized for host)
  14. >4 string >000 version %s
  15. # Android bootimg format
  16. # From https://android.googlesource.com/\
  17. # platform/system/core/+/master/mkbootimg/bootimg.h
  18. 0 string ANDROID! Android bootimg
  19. >1024 string LOKI\01 \b, LOKI'd
  20. >8 lelong >0 \b, kernel
  21. >>12 lelong >0 \b (0x%x)
  22. >16 lelong >0 \b, ramdisk
  23. >>20 lelong >0 \b (0x%x)
  24. >24 lelong >0 \b, second stage
  25. >>28 lelong >0 \b (0x%x)
  26. >36 lelong >0 \b, page size: %d
  27. >38 string >0 \b, name: %s
  28. >64 string >0 \b, cmdline (%s)
  29. # Android Backup archive
  30. # From: Ariel Shkedi
  31. # Update: Joerg Jenderek
  32. # URL: https://github.com/android/platform_frameworks_base/blob/\
  33. # 0bacfd2ba68d21a68a3df345b830bc2a1e515b5a/services/java/com/\
  34. # android/server/BackupManagerService.java#L2367
  35. # Reference: https://sourceforge.net/projects/adbextractor/
  36. # android-backup-extractor/perl/backupencrypt.pl
  37. # Note: only unix line feeds "\n" found
  38. # After the header comes a tar file
  39. # If compressed, the entire tar file is compressed with JAVA deflate
  40. #
  41. # Include the version number hardcoded with the magic string to avoid
  42. # false positives
  43. 0 string/b ANDROID\ BACKUP\n Android Backup
  44. # maybe look for some more characteristics like linefeed '\n' or version
  45. #>16 string \n
  46. # No mime-type defined offically
  47. !:mime application/x-google-ab
  48. !:ext ab
  49. # on 2nd line version (often 1, 2 on kitkat 4.4.3+, 4 on 7.1.2)
  50. >15 string >\0 \b, version %s
  51. # "1" on 3rd line means compressed
  52. >17 string 0\n \b, Not-Compressed
  53. >17 string 1\n \b, Compressed
  54. # The 4th line is encryption "none" or "AES-256"
  55. # any string as long as it's not the word none (which is matched below)
  56. >19 string none\n \b, Not-Encrypted
  57. # look for backup content after line with encryption info
  58. #>>19 search/7 \n
  59. # data part after header for not encrypted Android Backup
  60. #>>>&0 ubequad x \b, content 0x%16.16llx...
  61. # look for zlib compressed by ./compress after message with 1 space at end
  62. #>>>&0 indirect x \b; contains
  63. # look for tar archive block by ./archive for package name manifest
  64. >>288 string ustar \b; contains
  65. >>>31 use tar-file
  66. # look for zip/jar archive by ./archive ./zip after message with 1 space at end
  67. #>>2079 search/1025/s PK\003\004 \b; contains
  68. #>>>&0 indirect x
  69. >19 string !none
  70. >>19 regex/1l \^([^n\n]|n[^o]|no[^n]|non[^e]|none.+).* \b, Encrypted (%s)
  71. # Commented out because they don't seem useful to print
  72. # (but they are part of the header - the tar file comes after them):
  73. # The 5th line is User Password Salt (128 Hex)
  74. # string length too high with standard src configuration
  75. #>>>&1 string >\0 \b, PASSWORD salt: "%-128.128s"
  76. #>>>&1 regex/1l .* \b, Password salt: %s
  77. # The 6th line is Master Key Checksum Salt (128 Hex)
  78. #>>>>&1 regex/1l .* \b, Master salt: %s
  79. # The 7th line is Number of PBDKF2 Rounds (10000)
  80. #>>>>>&1 regex/1l .* \b, PBKDF2 rounds: %s
  81. # The 8th line is User key Initialization Vector (IV) (32 Hex)
  82. #>>>>>>&1 regex/1l .* \b, IV: %s
  83. #>>>>>>&1 regex/1l .* \b, IV: %s
  84. # The 9th line is Master IV+Key+Checksum (192 Hex)
  85. #>>>>>>>&1 regex/1l .* \b, Key: %s
  86. # look for new line separator char after line number 9
  87. #>>>0x204 ubyte 0x0a NL found
  88. #>>>>&1 ubequad x \b, Content magic %16.16llx
  89. # *.pit files by Joerg Jenderek
  90. # https://forum.xda-developers.com/showthread.php?p=9122369
  91. # https://forum.xda-developers.com/showthread.php?t=816449
  92. # Partition Information Table for Samsung's smartphone with Android
  93. # used by flash software Odin
  94. 0 ulelong 0x12349876
  95. # 1st pit entry marker
  96. >0x01C ulequad&0xFFFFFFFCFFFFFFFC =0x0000000000000000
  97. # minimal 13 and maximal 18 PIT entries found
  98. >>4 ulelong <128 Partition Information Table for Samsung smartphone
  99. >>>4 ulelong x \b, %d entries
  100. # 1. pit entry
  101. >>>4 ulelong >0 \b; #1
  102. >>>0x01C use PIT-entry
  103. >>>4 ulelong >1 \b; #2
  104. >>>0x0A0 use PIT-entry
  105. >>>4 ulelong >2 \b; #3
  106. >>>0x124 use PIT-entry
  107. >>>4 ulelong >3 \b; #4
  108. >>>0x1A8 use PIT-entry
  109. >>>4 ulelong >4 \b; #5
  110. >>>0x22C use PIT-entry
  111. >>>4 ulelong >5 \b; #6
  112. >>>0x2B0 use PIT-entry
  113. >>>4 ulelong >6 \b; #7
  114. >>>0x334 use PIT-entry
  115. >>>4 ulelong >7 \b; #8
  116. >>>0x3B8 use PIT-entry
  117. >>>4 ulelong >8 \b; #9
  118. >>>0x43C use PIT-entry
  119. >>>4 ulelong >9 \b; #10
  120. >>>0x4C0 use PIT-entry
  121. >>>4 ulelong >10 \b; #11
  122. >>>0x544 use PIT-entry
  123. >>>4 ulelong >11 \b; #12
  124. >>>0x5C8 use PIT-entry
  125. >>>4 ulelong >12 \b; #13
  126. >>>>0x64C use PIT-entry
  127. # 14. pit entry
  128. >>>4 ulelong >13 \b; #14
  129. >>>>0x6D0 use PIT-entry
  130. >>>4 ulelong >14 \b; #15
  131. >>>0x754 use PIT-entry
  132. >>>4 ulelong >15 \b; #16
  133. >>>0x7D8 use PIT-entry
  134. >>>4 ulelong >16 \b; #17
  135. >>>0x85C use PIT-entry
  136. # 18. pit entry
  137. >>>4 ulelong >17 \b; #18
  138. >>>0x8E0 use PIT-entry
  139. 0 name PIT-entry
  140. # garbage value implies end of pit entries
  141. >0x00 ulequad&0xFFFFFFFCFFFFFFFC =0x0000000000000000
  142. # skip empty partition name
  143. >>0x24 ubyte !0
  144. # partition name
  145. >>>0x24 string >\0 %-.32s
  146. # flags
  147. >>>0x0C ulelong&0x00000002 2 \b+RW
  148. # partition ID:
  149. # 0~IPL,MOVINAND,GANG;1~PIT,GPT;2~HIDDEN;3~SBL,HIDDEN;4~SBL2,HIDDEN;5~BOOT;6~KENREl,RECOVER,misc;7~RECOVER
  150. # ;11~MODEM;20~efs;21~PARAM;22~FACTORY,SYSTEM;23~DBDATAFS,USERDATA;24~CACHE;80~BOOTLOADER;81~TZSW
  151. >>>0x08 ulelong x (0x%x)
  152. # filename
  153. >>>0x44 string >\0 "%-.64s"
  154. #>>>0x18 ulelong >0
  155. # blocksize in 512 byte units ?
  156. #>>>>0x18 ulelong x \b, %db
  157. # partition size in blocks ?
  158. #>>>>0x22 ulelong x \b*%d
  159. # Android sparse img format
  160. # From https://android.googlesource.com/\
  161. # platform/system/core/+/master/libsparse/sparse_format.h
  162. 0 lelong 0xed26ff3a Android sparse image
  163. >4 leshort x \b, version: %d
  164. >6 leshort x \b.%d
  165. >16 lelong x \b, Total of %d
  166. >12 lelong x \b %d-byte output blocks in
  167. >20 lelong x \b %d input chunks.
  168. # Android binary XML magic
  169. # In include/androidfw/ResourceTypes.h:
  170. # RES_XML_TYPE = 0x0003 followed by the size of the header (ResXMLTree_header),
  171. # which is 8 bytes (2 bytes type + 2 bytes header size + 4 bytes size).
  172. 0 lelong 0x00080003 Android binary XML