anais-apk-forensic 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +249 -0
  3. package/anais.sh +669 -0
  4. package/analysis_tools/__pycache__/apk_basic_info.cpython-313.pyc +0 -0
  5. package/analysis_tools/__pycache__/apk_basic_info.cpython-314.pyc +0 -0
  6. package/analysis_tools/__pycache__/check_zip_encryption.cpython-313.pyc +0 -0
  7. package/analysis_tools/__pycache__/check_zip_encryption.cpython-314.pyc +0 -0
  8. package/analysis_tools/__pycache__/detect_obfuscation.cpython-313.pyc +0 -0
  9. package/analysis_tools/__pycache__/detect_obfuscation.cpython-314.pyc +0 -0
  10. package/analysis_tools/__pycache__/dex_payload_hunter.cpython-314.pyc +0 -0
  11. package/analysis_tools/__pycache__/entropy_analyzer.cpython-314.pyc +0 -0
  12. package/analysis_tools/__pycache__/error_logger.cpython-313.pyc +0 -0
  13. package/analysis_tools/__pycache__/error_logger.cpython-314.pyc +0 -0
  14. package/analysis_tools/__pycache__/find_encrypted_payload.cpython-314.pyc +0 -0
  15. package/analysis_tools/__pycache__/fix_apk_headers.cpython-313.pyc +0 -0
  16. package/analysis_tools/__pycache__/fix_apk_headers.cpython-314.pyc +0 -0
  17. package/analysis_tools/__pycache__/manifest_analyzer.cpython-313.pyc +0 -0
  18. package/analysis_tools/__pycache__/manifest_analyzer.cpython-314.pyc +0 -0
  19. package/analysis_tools/__pycache__/network_analyzer.cpython-313.pyc +0 -0
  20. package/analysis_tools/__pycache__/network_analyzer.cpython-314.pyc +0 -0
  21. package/analysis_tools/__pycache__/report_generator.cpython-313.pyc +0 -0
  22. package/analysis_tools/__pycache__/report_generator.cpython-314.pyc +0 -0
  23. package/analysis_tools/__pycache__/report_generator_modular.cpython-314.pyc +0 -0
  24. package/analysis_tools/__pycache__/sast_scanner.cpython-313.pyc +0 -0
  25. package/analysis_tools/__pycache__/sast_scanner.cpython-314.pyc +0 -0
  26. package/analysis_tools/__pycache__/so_string_analyzer.cpython-314.pyc +0 -0
  27. package/analysis_tools/__pycache__/yara_enhanced_analyzer.cpython-314.pyc +0 -0
  28. package/analysis_tools/__pycache__/yara_results_processor.cpython-314.pyc +0 -0
  29. package/analysis_tools/apk_basic_info.py +85 -0
  30. package/analysis_tools/check_zip_encryption.py +142 -0
  31. package/analysis_tools/detect_obfuscation.py +650 -0
  32. package/analysis_tools/dex_payload_hunter.py +734 -0
  33. package/analysis_tools/entropy_analyzer.py +335 -0
  34. package/analysis_tools/error_logger.py +75 -0
  35. package/analysis_tools/find_encrypted_payload.py +485 -0
  36. package/analysis_tools/fix_apk_headers.py +154 -0
  37. package/analysis_tools/manifest_analyzer.py +214 -0
  38. package/analysis_tools/network_analyzer.py +287 -0
  39. package/analysis_tools/report_generator.py +506 -0
  40. package/analysis_tools/report_generator_modular.py +885 -0
  41. package/analysis_tools/sast_scanner.py +412 -0
  42. package/analysis_tools/so_string_analyzer.py +406 -0
  43. package/analysis_tools/yara_enhanced_analyzer.py +330 -0
  44. package/analysis_tools/yara_results_processor.py +368 -0
  45. package/analyzer_config.json +113 -0
  46. package/apkid/__init__.py +32 -0
  47. package/apkid/__pycache__/__init__.cpython-313.pyc +0 -0
  48. package/apkid/__pycache__/__init__.cpython-314.pyc +0 -0
  49. package/apkid/__pycache__/apkid.cpython-313.pyc +0 -0
  50. package/apkid/__pycache__/apkid.cpython-314.pyc +0 -0
  51. package/apkid/__pycache__/main.cpython-313.pyc +0 -0
  52. package/apkid/__pycache__/main.cpython-314.pyc +0 -0
  53. package/apkid/__pycache__/output.cpython-313.pyc +0 -0
  54. package/apkid/__pycache__/rules.cpython-313.pyc +0 -0
  55. package/apkid/apkid.py +266 -0
  56. package/apkid/main.py +98 -0
  57. package/apkid/output.py +177 -0
  58. package/apkid/rules/apk/common.yara +68 -0
  59. package/apkid/rules/apk/obfuscators.yara +118 -0
  60. package/apkid/rules/apk/packers.yara +1197 -0
  61. package/apkid/rules/apk/protectors.yara +301 -0
  62. package/apkid/rules/dex/abnormal.yara +104 -0
  63. package/apkid/rules/dex/anti-vm.yara +568 -0
  64. package/apkid/rules/dex/common.yara +60 -0
  65. package/apkid/rules/dex/compilers.yara +434 -0
  66. package/apkid/rules/dex/obfuscators.yara +602 -0
  67. package/apkid/rules/dex/packers.yara +761 -0
  68. package/apkid/rules/dex/protectors.yara +520 -0
  69. package/apkid/rules/dll/common.yara +38 -0
  70. package/apkid/rules/dll/obfuscators.yara +43 -0
  71. package/apkid/rules/elf/anti-vm.yara +43 -0
  72. package/apkid/rules/elf/common.yara +54 -0
  73. package/apkid/rules/elf/obfuscators.yara +991 -0
  74. package/apkid/rules/elf/packers.yara +1128 -0
  75. package/apkid/rules/elf/protectors.yara +794 -0
  76. package/apkid/rules/res/common.yara +43 -0
  77. package/apkid/rules/res/obfuscators.yara +46 -0
  78. package/apkid/rules/res/protectors.yara +46 -0
  79. package/apkid/rules.py +77 -0
  80. package/bin/anais +3 -0
  81. package/dist/cli.js +82 -0
  82. package/dist/index.js +123 -0
  83. package/dist/types/index.js +2 -0
  84. package/dist/utils/index.js +21 -0
  85. package/dist/utils/output.js +44 -0
  86. package/dist/utils/paths.js +107 -0
  87. package/docs/ARCHITECTURE.txt +353 -0
  88. package/docs/Workflow and Reference.md +445 -0
  89. package/package.json +70 -0
  90. package/rules/yara_general_rules.yar +323 -0
  91. package/scripts/dynamic_analysis_helper.sh +334 -0
  92. package/scripts/frida/dpt_dex_dumper.js +145 -0
  93. package/scripts/frida/frida_dex_dump.js +145 -0
  94. package/scripts/frida/frida_hooks.js +437 -0
  95. package/scripts/frida/frida_websocket_extractor.js +154 -0
  96. package/scripts/setup.sh +206 -0
  97. package/scripts/validate_framework.sh +224 -0
  98. package/src/cli.ts +91 -0
  99. package/src/index.ts +123 -0
  100. package/src/types/index.ts +44 -0
  101. package/src/utils/index.ts +6 -0
  102. package/src/utils/output.ts +50 -0
  103. package/src/utils/paths.ts +72 -0
  104. package/tsconfig.json +14 -0
@@ -0,0 +1,761 @@
1
+ /*
2
+ * Copyright (C) 2023 RedNaga. https://rednaga.io
3
+ * All rights reserved. Contact: rednaga@protonmail.com
4
+ *
5
+ *
6
+ * This file is part of APKiD
7
+ *
8
+ *
9
+ * Commercial License Usage
10
+ * ------------------------
11
+ * Licensees holding valid commercial APKiD licenses may use this file
12
+ * in accordance with the commercial license agreement provided with the
13
+ * Software or, alternatively, in accordance with the terms contained in
14
+ * a written agreement between you and RedNaga.
15
+ *
16
+ *
17
+ * GNU General Public License Usage
18
+ * --------------------------------
19
+ * Alternatively, this file may be used under the terms of the GNU General
20
+ * Public License version 3.0 as published by the Free Software Foundation
21
+ * and appearing in the file LICENSE.GPL included in the packaging of this
22
+ * file. Please visit http://www.gnu.org/copyleft/gpl.html and review the
23
+ * information to ensure the GNU General Public License version 3.0
24
+ * requirements will be met.
25
+ *
26
+ **/
27
+
28
+ include "common.yara"
29
+
30
+ rule pangxie_dex : packer
31
+ {
32
+ meta:
33
+ description = "PangXie"
34
+ sample = "ea70a5b3f7996e9bfea2d5d99693195fdb9ce86385b7116fd08be84032d43d2c"
35
+
36
+ strings:
37
+ // Lcom/merry/wapper/WapperApplication;
38
+ $wrapper = {
39
+ 00 24 4C 63 6F 6D 2F 6D 65 72 72 79 2F 77 61 70
40
+ 70 65 72 2F 57 61 70 70 65 72 41 70 70 6C 69 63
41
+ 61 74 69 6F 6E 3B 00
42
+ }
43
+
44
+ condition:
45
+ is_dex and
46
+ $wrapper
47
+ }
48
+
49
+ rule medusah_dex : packer
50
+ {
51
+ meta:
52
+ description = "Medusah"
53
+ sample = "b92c0090038f3185908f2fb3b7e927da734040b9332332fc09542e20c615e083"
54
+
55
+ strings:
56
+ $wrapper = "Lcom/seworks/medusah"
57
+
58
+ condition:
59
+ is_dex and $wrapper
60
+ }
61
+
62
+ rule medusah_appsolid_dex : packer
63
+ {
64
+ meta:
65
+ description = "Medusah (AppSolid)"
66
+
67
+ strings:
68
+ $loader = "Lweb/apache/sax/app;"
69
+ $main_activity = "Lweb/apache/sax/MainActivity;"
70
+
71
+ condition:
72
+ is_dex and $loader and $main_activity
73
+ }
74
+
75
+ rule apkguard_dex : packer
76
+ {
77
+ meta:
78
+ description = "APKGuard"
79
+ url = "http://apkguard.io/"
80
+ sample = "d9c98fff427646883ecb457fc2e9d2a8914ba7a9ee194735e0a18f56baa26cca"
81
+
82
+ strings:
83
+ $attachBaseContextOpcodes = {
84
+ 120b // const/4 v11, #int 0 // #0
85
+ 6f20 0100 fe00 // invoke-super {v14, v15}, Landroid/app/Application;.attachBaseContext:(Landroid/content/Context;)V // method@0001
86
+ 2206 ??00 // new-instance v6, Ljava/io/File; // type@0006
87
+ 6e10 ??00 0e00 // invoke-virtual {v14}, Lyxlhycuqv/weudayy;.getFilesDir:()Ljava/io/File; // method@0019
88
+ 0c09 // move-result-object v9
89
+ 1a0a (2f|30) 00 // const-string v10, "lllllllllllllllllllllllllllllllllllllllll.zip" // string@002f
90
+ 7030 ??00 960a // invoke-direct {v6, v9, v10}, Ljava/io/File;.<init>:(Ljava/io/File;Ljava/lang/String;)V // method@000a
91
+ 1a09 1900 // const-string v9, BASE64_ENCODED_ZIP_FILE
92
+ 7120 ??00 b900 // invoke-static {v9, v11}, Landroid/util/Base64;.decode:(Ljava/lang/String;I)[B // method@0003
93
+ 0c02 // move-result-object v2
94
+ 2205 ??00 // new-instance v5, Ljava/io/FileOutputStream; // type@0007
95
+ 7020 ??00 6500 // invoke-direct {v5, v6}, Ljava/io/FileOutputStream;.<init>:(Ljava/io/File;)V // method@000c
96
+ 2201 ??00 // new-instance v1, Ljava/io/BufferedOutputStream; // type@0005
97
+ 7020 ??00 5100 // invoke-direct {v1, v5}, Ljava/io/BufferedOutputStream;.<init>:(Ljava/io/OutputStream;)V // method@0006
98
+ 6e20 ??00 2100 // invoke-virtual {v1, v2}, Ljava/io/BufferedOutputStream;.write:([B)V // method@0009
99
+ 6e10 ??00 0100 // invoke-virtual {v1}, Ljava/io/BufferedOutputStream;.flush:()V // method@0008
100
+ 6e10 ??00 0100 // invoke-virtual {v1}, Ljava/io/BufferedOutputStream;.close:()V // method@0007
101
+ 6e10 ??00 0600 // invoke-virtual {v6}, Ljava/io/File;.getAbsolutePath:()Ljava/lang/String; // method@000b
102
+ 0c03 // move-result-object v3
103
+ 6e10 ??00 0e00 // invoke-virtual {v14}, Lyxlhycuqv/weudayy;.getFilesDir:()Ljava/io/File; // method@0019
104
+ 0c09 // move-result-object v9
105
+ 6e10 ??00 0900 // invoke-virtual {v9}, Ljava/io/File;.getAbsolutePath:()Ljava/lang/String; // method@000b
106
+ 0c07 // move-result-object v7
107
+ 6e10 ??00 0e00 // invoke-virtual {v14}, Lyxlhycuqv/weudayy;.getClassLoader:()Ljava/lang/ClassLoader; // method@0018
108
+ 0c00 // move-result-object v0
109
+ 2204 ??00 // new-instance v4, Ldalvik/system/DexClassLoader; // type@0004
110
+ 1209 // const/4 v9, #int 0 // #0
111
+ 7050 ??00 3497 // invoke-direct {v4, v3, v7, v9, v0}, Ldalvik/system/DexClassLoader;.<init>:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)V // method@0004
112
+ 1a09 ??00 // const-string v9, "yabno/blkngwigpd" // string@003d
113
+ 6e20 ??00 9400 // invoke-virtual {v4, v9}, Ldalvik/system/DexClassLoader;.loadClass:(Ljava/lang/String;)Ljava/lang/Class; // method@0005
114
+ 0c09 // move-result-object v9
115
+ 120a // const/4 v10, #int 0 // #0
116
+ 23aa ??00 // new-array v10, v10, [Ljava/lang/Class; // type@0016
117
+ 6e20 ??00 a900 // invoke-virtual {v9, v10}, Ljava/lang/Class;.getConstructor:([Ljava/lang/Class;)Ljava/lang/reflect/Constructor; // method@000d
118
+ 0c09 // move-result-object v9
119
+ 120a // const/4 v10, #int 0 // #0
120
+ 23aa ??00 // new-array v10, v10, [Ljava/lang/Object; // type@0017
121
+ 6e20 ??00 a900 // invoke-virtual {v9, v10}, Ljava/lang/reflect/Constructor;.newInstance:([Ljava/lang/Object;)Ljava/lang/Object; // method@0013
122
+ 0c09 // move-result-object v9
123
+ 5be9 0000 // iput-object v9, v14, Lyxlhycuqv/weudayy;.aaa:Ljava/lang/Object; // field@0000
124
+ 54e9 0000 // iget-object v9, v14, Lyxlhycuqv/weudayy;.aaa:Ljava/lang/Object; // field@0000
125
+ 6e10 ??00 0900 // invoke-virtual {v9}, Ljava/lang/Object;.getClass:()Ljava/lang/Class; // method@0012
126
+ 0c09 // move-result-object v9
127
+ 1a0a ??00 // const-string v10, "attachBaseContext" // string@0022
128
+ 121b // const/4 v11, #int 1 // #1
129
+ 23bb ??00 // new-array v11, v11, [Ljava/lang/Class; // type@0016
130
+ 120c // const/4 v12, #int 0 // #0
131
+ 1c0d ??00 // const-class v13, Landroid/content/Context; // type@0002
132
+ 4d0d 0b0c // aput-object v13, v11, v12
133
+ 6e30 ??00 a90b // invoke-virtual {v9, v10, v11}, Ljava/lang/Class;.getDeclaredMethod:(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method; // method@000e
134
+ 0c09 // move-result-object v9
135
+ 54ea 0000 // iget-object v10, v14, Lyxlhycuqv/weudayy;.aaa:Ljava/lang/Object; // field@0000
136
+ 121b // const/4 v11, #int 1 // #1
137
+ 23bb ??00 // new-array v11, v11, [Ljava/lang/Object; // type@0017
138
+ 120c // const/4 v12, #int 0 // #0
139
+ 4d0e 0b0c // aput-object v14, v11, v12
140
+ 6e30 ??00 a90b // invoke-virtual {v9, v10, v11}, Ljava/lang/reflect/Method;.invoke:(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; // method@0015
141
+ 0e00 // return-void
142
+ 0d08 // move-exception v8
143
+ 6e10 ??00 0800 // invoke-virtual {v8}, Ljava/lang/Exception;.printStackTrace:()V // method@000f
144
+ 28fb // goto 0073 // -0005
145
+ }
146
+
147
+ condition:
148
+ is_dex and $attachBaseContextOpcodes
149
+ }
150
+
151
+ rule cryptoshell_dex : packer
152
+ {
153
+ meta:
154
+ description = "CryptoShell"
155
+ url = "http://cryptoshell.io"
156
+ sample = "d6745c1533b440c93f7bdfbb106470043b23aafdf91506c52332ed192d7b7003"
157
+
158
+ strings:
159
+ $attachBaseContextOpcodes = {
160
+ 120b // const/4 v11, 0
161
+ 6f20 0100 fe00 // invoke-super {v14, v15}, Landroid/app/Application.attachBaseContext(Landroid/content/Context;)V ; 0x1
162
+ 2206 ??00 // new-instance v6, Ljava/io/File; ; 0x180
163
+ 6e10 ??00 0e00 // invoke-virtual {v14}, Llctavku/ngbdjdfqf.getFilesDir()Ljava/io/File; ; 0x19
164
+ 0c09 // move-result-object v9
165
+ 1a0a ??00 // const-string v10, str.mtuECIoALWpjXcVYbOOKBHNTMligrjLQpGFKT.zip ; 0x239c
166
+ 7030 ???? 960a // invoke-direct {v6, v9, v10}, Ljava/io/File.<init>(Ljava/io/File;Ljava/lang/String;)V ; 0xa
167
+ 1a09 ??00 // const-string v9, str.UEsDBBQAAAAIAAMAi0tT_4a5ihQAAGArAAALABwAY2xhc3Nlcy5kZXhVVAkAA1Wg....
168
+ 7120 ??00 b900 // invoke-static {v9, v11}, Landroid/util/Base64;.decode:(Ljava/lang/String;I)[B // method@0003
169
+ 0c02 // move-result-object v2
170
+ 2205 ??00 // new-instance v5, Ljava/io/FileOutputStream; // type@0007
171
+ 7020 ??00 6500 // invoke-direct {v5, v6}, Ljava/io/FileOutputStream;.<init>:(Ljava/io/File;)V // method@000c
172
+ 2201 ??00 // new-instance v1, Ljava/io/BufferedOutputStream; // type@0005
173
+ 7020 ??00 5100 // invoke-direct {v1, v5}, Ljava/io/BufferedOutputStream;.<init>:(Ljava/io/OutputStream;)V // method@0006
174
+ 6e20 ??00 2100 // invoke-virtual {v1, v2}, Ljava/io/BufferedOutputStream;.write:([B)V // method@0009
175
+ 6e10 ??00 0100 // invoke-virtual {v1}, Ljava/io/BufferedOutputStream;.flush:()V // method@0008
176
+ 6e10 ??00 0100 // invoke-virtual {v1}, Ljava/io/BufferedOutputStream;.close:()V // method@0007
177
+ 6e10 ??00 0600 // invoke-virtual {v6}, Ljava/io/File;.getAbsolutePath:()Ljava/lang/String; // method@000b
178
+ 0c03 // move-result-object v3
179
+ 6e10 ??00 0e00 // invoke-virtual {v14}, Lyxlhycuqv/weudayy;.getFilesDir:()Ljava/io/File; // method@0019
180
+ 0c09 // move-result-object v9
181
+ 6e10 ??00 0900 // invoke-virtual {v9}, Ljava/io/File;.getAbsolutePath:()Ljava/lang/String; // method@000b
182
+ 0c07 // move-result-object v7
183
+ 6e10 ??00 0e00 // invoke-virtual {v14}, Lyxlhycuqv/weudayy;.getClassLoader:()Ljava/lang/ClassLoader; // method@0018
184
+ 0c00 // move-result-object v0
185
+ 2204 ??00 // new-instance v4, Ldalvik/system/DexClassLoader; // type@0004
186
+ 1209 // const/4 v9, #int 0 // #0
187
+ 7050 ??00 3497 // invoke-direct {v4, v3, v7, v9, v0}, Ldalvik/system/DexClassLoader;.<init>:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/ClassLoader;)V // method@0004
188
+ 1a09 ??00 // const-string v9, "yabno/blkngwigpd" // string@003d
189
+ 6e20 ??00 9400 // invoke-virtual {v4, v9}, Ldalvik/system/DexClassLoader;.loadClass:(Ljava/lang/String;)Ljava/lang/Class; // method@0005
190
+ 0c09 // move-result-object v9
191
+ 120a // const/4 v10, #int 0 // #0
192
+ 23aa ??00 // new-array v10, v10, [Ljava/lang/Class; // type@0016
193
+ 6e20 ??00 a900 // invoke-virtual {v9, v10}, Ljava/lang/Class;.getConstructor:([Ljava/lang/Class;)Ljava/lang/reflect/Constructor; // method@000d
194
+ 0c09 // move-result-object v9
195
+ 120a // const/4 v10, #int 0 // #0
196
+ 23aa ??00 // new-array v10, v10, [Ljava/lang/Object; // type@0017
197
+ 6e20 ??00 a900 // invoke-virtual {v9, v10}, Ljava/lang/reflect/Constructor;.newInstance:([Ljava/lang/Object;)Ljava/lang/Object; // method@0013
198
+ 0c09 // move-result-object v9
199
+ 5be9 0000 // iput-object v9, v14, Lyxlhycuqv/weudayy;.aaa:Ljava/lang/Object; // field@0000
200
+ 54e9 0000 // iget-object v9, v14, Lyxlhycuqv/weudayy;.aaa:Ljava/lang/Object; // field@0000
201
+ 6e10 ??00 0900 // invoke-virtual {v9}, Ljava/lang/Object;.getClass:()Ljava/lang/Class; // method@0012
202
+ 0c09 // move-result-object v9
203
+ 1a0a ??00 // const-string v10, "attachBaseContext" // string@0022
204
+ 121b // const/4 v11, #int 1 // #1
205
+ 23bb ??00 // new-array v11, v11, [Ljava/lang/Class; // type@0016
206
+ 120c // const/4 v12, #int 0 // #0
207
+ 1c0d ??00 // const-class v13, Landroid/content/Context; // type@0002
208
+ 4d0d 0b0c // aput-object v13, v11, v12
209
+ 6e30 ??00 a90b // invoke-virtual {v9, v10, v11}, Ljava/lang/Class;.getDeclaredMethod:(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method; // method@000e
210
+ 0c09 // move-result-object v9
211
+ 54ea 0000 // iget-object v10, v14, Lyxlhycuqv/weudayy;.aaa:Ljava/lang/Object; // field@0000
212
+ 121b // const/4 v11, #int 1 // #1
213
+ 23bb ??00 // new-array v11, v11, [Ljava/lang/Object; // type@0017
214
+ 120c // const/4 v12, #int 0 // #0
215
+ 4d0e 0b0c // aput-object v14, v11, v12
216
+ 6e30 ??00 a90b // invoke-virtual {v9, v10, v11}, Ljava/lang/reflect/Method;.invoke:(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; // method@0015
217
+ 0e00 // return-void
218
+ 0d08 // move-exception v8
219
+ 6e10 ??00 0800 // invoke-virtual {v8}, Ljava/lang/Exception;.printStackTrace:()V // method@000f
220
+ 28fb // goto 0073 // -0005
221
+ }
222
+
223
+ condition:
224
+ is_dex and
225
+ $attachBaseContextOpcodes and
226
+ not apkguard_dex
227
+ }
228
+
229
+
230
+ rule jar_pack01 : packer
231
+ {
232
+ meta:
233
+ // Official name unknown
234
+ description = "jar_pack01"
235
+ sample = "faf1e85f878ea52a3b3fbb67126132b527f509586706f242f39b8c1fdb4a2065"
236
+
237
+ strings:
238
+ $pre_jar = { 00 6F 6E 43 72 65 61 74 65 00 28 29 56 00 63 6F 6D 2F 76 } // .onCreate.()V.com/v
239
+ $jar_data = { 2E 6A 61 72 00 2F 64 61 74 61 2F 64 61 74 61 2F 00 2F } // .jar./data/data
240
+ $post_jar = { 2E 6A 61 72 00 77 00 6A 61 76 61 2F 75 74 69 6C 2F 4D 61 70 00 67 65 74 49 6E 74 00 } // .jar.w.java/util/Map.getInt.
241
+
242
+ condition:
243
+ is_dex and
244
+ ($pre_jar and $jar_data and $post_jar)
245
+ }
246
+
247
+ rule gaoxor : packer
248
+ {
249
+ meta:
250
+ description = "GaoXor"
251
+ url = "https://github.com/rednaga/APKiD/issues/71"
252
+ sample = "673b3ab2e06f830e7ece1e3106a6a8c5f4bacd31393998fa73f6096b89f2df47"
253
+ author = "Eduardo Novella"
254
+
255
+ strings:
256
+ $str_0 = { 11 61 74 74 61 63 68 42 61 73 65 43 6F 6E 74 65 78 74 00 } // "attachBaseContext"
257
+ $str_1 = { 04 2F 6C 69 62 00 } // "/lib"
258
+ $str_2 = { 17 4C 6A 61 76 61 2F 6C 61 6E 67 2F 43 6C 61 73 73 4C 6F 61 64 65 72 3B 00 } // Ljava/lang/ClassLoader;
259
+ $str_3 = { 77 72 69 74 65 64 44 65 78 46 69 6C 65 00 } // writedDexFile
260
+
261
+ /**
262
+ public void attachBaseContext(Context base) {
263
+ super.attachBaseContext(base);
264
+ try {
265
+ getClass().getDeclaredMethod(GaoAoxCoJpRm("MS4zNiguNyIBJCQ9HAU="), new Class[0]).invoke(this, new Object[0]);
266
+ } catch (Exception e) {
267
+ }
268
+ }
269
+ */
270
+ $attachBaseContextOpcodes = {
271
+ // method.public.Lpykqdxlnyt_iytDlJSoOg.Lpykqdxlnyt_iytDlJSoOg.method.attachBaseContext_Landroid_content_Context__V:
272
+ 6f20??004300 // invoke-super {v3, v4}, Landroid/app/Application.attachBaseContext(Landroid/content/Context;)V
273
+ 6e10??000300 // invoke-virtual {v3}, Ljava/lang/Object.getClass()Ljava/lang/Class;
274
+ 0c00 // move-result-object v0
275
+ 1a01??00 // const-string v1, str.MS4zNiguNyIBJCQ9HAU ; 0xdfd
276
+ 6e20??001300 // invoke-virtual {v3, v1}, Lpykqdxlnyt/iytDlJSoOg.GaoAoxCoJpRm(Ljava/lang/String;)Ljava/lang/String;
277
+ 0c01 // move-result-object v1
278
+ 1202 // const/4 v2, 0 ; Protect.java:79
279
+ 2322??00 // new-array v2, v2, [Ljava/lang/Class; ; 0x3b8
280
+ 6e30??001002 // invoke-virtual {v0, v1, v2}, Ljava/lang/Class.getDeclaredMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
281
+ 0c00 // move-result-object v0
282
+ 1201 // const/4 v1, 0
283
+ 2311??00 // new-array v1, v1, [Ljava/lang/Object; ; 0x3bc
284
+ 6e30??003001 // invoke-virtual {v0, v3, v1}, Ljava/lang/reflect/Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
285
+ 0e00 // return-void
286
+ 0d00 // move-exception v0
287
+ 28fe // goto 0x00002984
288
+ }
289
+
290
+ /**
291
+ private byte[] mMuKJXDuYr(byte[] a, byte[] key) {
292
+ byte[] out = new byte[a.length];
293
+ for (int i = 0; i < a.length; i++) {
294
+ out[i] = (byte) (a[i] ^ key[i % key.length]);
295
+ }
296
+ return out;
297
+ }
298
+ */
299
+ $xor_key = {
300
+ 21 ?2 // array-length v2, p1
301
+ 23 21 17 00 // new-array v1, v2, [B
302
+ 12 00 // const/4 v0, 0
303
+ 21 ?2 // array-length v2, p1
304
+ 35 20 10 00 // if-ge v0, v2, :2A
305
+ 48 02 0? 00 // aget-byte v2, p1, v0
306
+ 21 ?3 // array-length v3, p2
307
+ 94 03 00 03 // rem-int v3, v0, v3
308
+ 48 03 0? 03 // aget-byte v3, p2, v3
309
+ B7 32 // xor-int/2addr v2, v3
310
+ 8D 22 // int-to-byte v2, v2
311
+ 4F 02 01 00 // aput-byte v2, v1, v0
312
+ D8 00 00 01 // add-int/lit8 v0, v0, 1
313
+ 28 F0 // goto :8
314
+ 11 01 // return-object v1
315
+ }
316
+
317
+ condition:
318
+ $attachBaseContextOpcodes and $xor_key and is_dex and 3 of ($str_*)
319
+ }
320
+
321
+ rule appsealing_loader_1_2_2 : packer
322
+ {
323
+ meta:
324
+ // Commercial packer
325
+ description = "AppSealing Loader v1.2.2"
326
+ url = "https://www.appsealing.com/"
327
+ sample = "61a983b032aee2e56159e682ad1588ad30fa8c3957bf849d1afe6f10e1d9645d"
328
+ author = "zeroload"
329
+
330
+ strings:
331
+ $loader_ver = /AppSealingLoader [.]+ v1.2.2/
332
+ $class = "Lcom/inka/appsealing/AppSealingApplication;"
333
+
334
+ condition:
335
+ is_dex and all of them
336
+ }
337
+
338
+ rule tencent : packer
339
+ {
340
+ meta:
341
+ description = "Mobile Tencent Protect"
342
+ url = "https://intl.cloud.tencent.com/product/mtp"
343
+ sample = "7c6024abc61b184ddcc9fa49f9fac1a7e5568d1eab09ee748f8c4987844a3f81"
344
+
345
+ strings:
346
+ $libshell_a = { 00 0C 6C 69 62 73 68 65 6C 6C 61 2E 73 6F 00 } // libshella.so
347
+ $libshell_b = { 00 0C 6C 69 62 73 68 65 6C 6C 62 2E 73 6F 00 } // libshellb.so
348
+ $libshell_c = { 00 0C 6C 69 62 73 68 65 6C 6C 63 2E 73 6F 00 } // libshellc.so
349
+ // Lcom/tencent/StubShell/TxAppEntry;
350
+ $class_app_entry = {
351
+ 00 22 4C 63 6F 6D 2F 74 65 6E 63 65 6E 74 2F 53 74 75 62 53 68 65
352
+ 6C 6C 2F 54 78 41 70 70 45 6E 74 72 79 3B 00
353
+ }
354
+ // Lcom/tencent/StubShell/a
355
+ $class_stubshell = {
356
+ 00 19 4C 63 6F 6D 2F 74 65 6E 63 65 6E 74 2F 53 74 75 62 53 68 65
357
+ 6C 6C 2F 61 3B 00
358
+ }
359
+
360
+ condition:
361
+ is_dex
362
+ and 2 of ($libshell_*)
363
+ or 1 of ($class_*)
364
+ }
365
+
366
+ rule crazy_dog_wrapper : packer
367
+ {
368
+ meta:
369
+ description = "Crazy Dog Wrapper"
370
+ url = "https://github.com/rednaga/APKiD/issues/31"
371
+ sample = "b1f0143c22a588aea89d3a9c0a53fa6d8cea07dd64dec1f82d905f5599acea94"
372
+
373
+ strings:
374
+ // libhdog-x86.so
375
+ $lib1 = { 00 0E 6C 69 62 68 64 6F 67 2D 78 38 36 2E 73 6F 00 }
376
+ // libhdog.so
377
+ $lib2 = { 00 0A 6C 69 62 68 64 6F 67 2E 73 6F 00 }
378
+ // Lcom/vdog/VDogApplication;
379
+ $class1 = { 00 1A 4C 63 6F 6D 2F 76 64 6F 67 2F 56 44 6F 67 41 70 70 6C 69 63 61 74 69 6F 6E 3B 00 }
380
+ // Lcom/vdog/VLibrary;
381
+ $class2 = { 00 13 4C 63 6F 6D 2F 76 64 6F 67 2F 56 4C 69 62 72 61 72 79 3B 00 }
382
+ // /.cache/libvdog.so
383
+ $str1 = { 00 12 2F 2E 63 61 63 68 65 2F 6C 69 62 76 64 6F 67 2E 73 6F 00 }
384
+
385
+ condition:
386
+ is_dex
387
+ and 2 of them
388
+ }
389
+
390
+ rule jsonpacker : packer
391
+ {
392
+ meta:
393
+ description = "JsonPacker"
394
+ sample = "e23f0a124fdaba30c07a3c40011dd99240af081cec4cdfcb990c811126867e59"
395
+ author = "Axelle Apvrille"
396
+
397
+ strings:
398
+ /* typical XOR algo with junk operations */
399
+ $algo = {
400
+ b0 9b // add-int/2addr v11, v9
401
+ da 0? 0? 00 // mul-int/lit8 v12, v11, 0
402
+ b3 9c // div-int/2addr v12, v9
403
+ b0 1c // add-int/2addr v12, v1
404
+ b0 5c // add-int/2addr v12, v5
405
+ 93 0? 0? 0? // div-int v5, v6, v6
406
+ d8 0? 0? ff // add-int/lit8 v5, v5, -1
407
+ b0 5c // add-int/2addr v12, v5
408
+ b4 66 // rem-int/2addr v6, v6
409
+ b0 6c // add-int/2addr v12, v6
410
+ 97 05 0c 0a // xor-int v5, v12, v10
411
+ }
412
+ $algo2 = {
413
+ b0 ?? // add-int/2addr v4, v12
414
+ da 0? 0? 00 // mul-int/lit8 v4, v4, 0
415
+ b0 ?? // add-int/2addr v4, v9
416
+ 93 0? 0? 0? // div-int v9, v12, v12
417
+ (b3 69 | db 04 04 01) // div-int/2addr v9, v6
418
+ // or: div-int/lit8 v4, v4, 0x1
419
+ (b7 69 | df 04 04 01) // xor-int/2addr v9, v6
420
+ // or: xor-int/lit8 v4, v4, 0x1
421
+ b0 ?? // add-int/2addr v4, v9
422
+ 94 0? 0? 0? // rem-int v9, v12, v12
423
+ b0 ?? // add-int/2addr v4, v9
424
+ (b7 b4 | 97 04 07 09 ) // xor-int/2addr v4, v11
425
+ // or: xor-int v4, v7, v9
426
+ }
427
+ $algo3 = {
428
+ b0 36
429
+ dc 07 05 02 // add-int/2addr v6, v3
430
+ 48 07 02 07 // rem-int/lit8 v7, v5, 0x2
431
+ d8 08 06 e5 // aget-byte v7, v2, v7
432
+ d8 08 08 26 // add-int/lit8 v8, v6, -27
433
+ 91 03 08 03 // sub-int v3, v8, v3
434
+ b7 74 // xor-int/2addr v4, v7
435
+ }
436
+ $dexclass = {
437
+ 6e 20 ?? ?? 10 00 // invoke-virtual {v0, v1}, Ljava/lang/reflect/Constructor;->newInstance([Ljava/lang/Object;)Ljava/lang/Object;
438
+ 0c ?? // move-result-object p1
439
+ 1f 0? // check-cast p1, Ldalvik/system/DexClassLoader;
440
+ }
441
+
442
+ condition:
443
+ is_dex
444
+ and ($algo or $algo2 or $algo3)
445
+ and $dexclass
446
+ }
447
+
448
+ rule multidexpacker : packer
449
+ {
450
+ meta:
451
+ description = "MultidexPacker"
452
+ sample = "49d167f8f7427f0340297ae1c89ce4a216a8e64c55294f8e422f1f972732bae7"
453
+ author = "Axelle Apvrille"
454
+ url = "https://cryptax.medium.com/multidex-trick-to-unpack-android-bianlian-ed52eb791e56"
455
+
456
+ strings:
457
+ /* the strings for the implementation of MultiDex are de-obfuscated */
458
+ $multidex_deobfuscation = {
459
+ 13 00 58 01 // const/16 v0, 344
460
+ 71 10 ?? ?? 00 00 // invoke-static b->a(I)String, v0 # DECRYPTED_STRING: "multidex.version"
461
+ 0C 00 // move-result-object v0
462
+ 69 00 ?? ?? // sput-object v0, b->e:String
463
+ 13 00 67 01 // const/16 v0, 359
464
+ 71 10 ?? ?? 00 00 // invoke-static b->a(I)String, v0 # DECRYPTED_STRING: "timestamp" (0x1)
465
+ 0C 00 // move-result-object v0
466
+ 69 00 ?? ?? // sput-object v0, b->f:String
467
+ 13 00 76 01 // const/16 v0, 374
468
+ 71 10 ?? ?? 00 00 // invoke-static b->a(I)String, v0 # DECRYPTED_STRING: "crc" (0x1)
469
+ }
470
+
471
+ /* decrypting the DEX and writing it in classes.dex */
472
+ $decrypt_dex = {
473
+ 70 20 ?? ?? 40 00 // invoke-direct ZipEntry-><init>(String)V, v0, v4
474
+ 6E 10 ?? ?? 0? 00 // invoke-virtual ZipEntry->getTime()J, p1
475
+ 0B 0? // move-result-wide v4
476
+ 6E 30 ?? ?? 40 05 // invoke-virtual ZipEntry->setTime(J)V, v0, v4, v5
477
+ 6E 20 ?? ?? 03 00 // invoke-virtual ZipOutputStream->putNextEntry(ZipEntry)V, v3, v0
478
+ 62 00 ?? ?? // sget-object v0, b->decryption_key:String
479
+ 22 04 ?? ?? // new-instance v4, InflaterInputStream
480
+ 70 20 ?? ?? 14 00 // invoke-direct InflaterInputStream-><init>(InputStream)V, v4, v1
481
+ 22 05 ?? ?? // new-instance v5, InflaterOutputStream
482
+ 70 20 ?? ?? 35 00 // invoke-direct InflaterOutputStream-><init>(OutputStream)V, v5, v3
483
+ 71 30 ?? ?? 40 05 // invoke-static k->decrypt(String, InputStream, OutputStream)V, v0, v4, v5
484
+ }
485
+
486
+ condition:
487
+ is_dex
488
+ and $multidex_deobfuscation
489
+ and $decrypt_dex
490
+ }
491
+
492
+ rule appguard_dex : packer
493
+ {
494
+ meta:
495
+ description = "AppGuard"
496
+ url = "http://appguard.nprotect.com/en/index.html"
497
+ sample = "23cd2af10d46459065ea65b2d40fb706fd4847a1f8ef195cbebf1c6d8d54a48a"
498
+ author = "Eduardo Novella"
499
+
500
+ strings:
501
+ $class1 = { 00?? 4c63 6f6d 2f69 6e63 612f 7365 6375 7269 7479 2f
502
+ (49|69) (49|69) (49|69) (49|69) (49|69) (49|69) (49|69)
503
+ [0-10] 3b 00} // Lcom/inca/security/IIIiiiiIii;
504
+ $class2 = { 00 254c 636f 6d2f 696e 6361 2f73 6563
505
+ 7572 6974 792f 5072 6f78 792f 4a4e 4953
506
+ 6f78 5072 6f78 793b 00} // .%Lcom/inca/security/Proxy/JNISoxProxy;.
507
+ $class3 = { 00 2b4c 636f 6d2f 696e 6361 2f73 6563
508
+ 7572 6974 792f 5365 7276 6963 652f 4170
509
+ 7047 7561 7264 5365 7276 6963 653b 00} // .+Lcom/inca/security/Service/AppGuardService;.
510
+
511
+ condition:
512
+ is_dex and any of them
513
+ }
514
+
515
+ rule custom_multidex : packer
516
+ {
517
+ meta:
518
+ description = "Custom Multidex"
519
+ sample1 = "b8f8948187846371eb32b2d7ef4f537c94997329e08d762b9ac6b3bfcbc86993"
520
+ sample2 = "fdf5b6930d38da33ec117d7c0f83f142db1c33013d020f0ab4801d1fd781f552"
521
+ author = "ReBensk"
522
+
523
+ strings:
524
+ $cipher = {
525
+ 1a00 ???? // const-string v0, // string@00c9
526
+ 7110 ???? 0000 // invoke-static {v0}, Ljava/nio/charset/Charset;.forName:(Ljava/lang/String;)Ljava/nio/charset/Charset; // method@0067
527
+ 0c00 // move-result-object v0
528
+ 6900 ???? // sput-object v0, Lᵔˎʻᐧـˏ/יﹳﹶˆˆ/ˊ゙ᵔٴʼי/ᴵˆᵔᵎˑʾ/ʼˈˏ゙ˎˉ;.defaultCharset:Ljava/nio/charset/Charset; // field@0069
529
+ 1a00 ???? // const-string v0, "゙ﹳ゙ـⁱᐧʿـʿʿⁱᵎﹶʽʾ゙ʽٴיᵎﹶʼʼʽˑˉᵎʼٴי// ˋᵎʼـʿʿʼˈʽᵔ" // string@01a2
530
+ 7110 ???? 0000 // invoke-static {v0}, Lᵔˎʻᐧـˏ/יﹳﹶˆˆ/ˊ゙ᵔٴʼי/ᴵˆᵔᵎˑʾ/ʼˈˏ゙ˎˉ;.encodePass:(Ljava/lang/String;)Ljava/lang/String; // method@0082
531
+ 0c00 // move-result-object v0
532
+ 6900 ???? // sput-object v0 Lᵔˎʻᐧـˏ/יﹳﹶˆˆ/ˊ゙ᵔٴʼי/ᴵˆᵔᵎˑʾ/ʼˈˏ゙ˎˉ;.globalPass:Ljava/lang/String; // field@006a
533
+ 0e00 // return-void
534
+ }
535
+ $cipher2 = {
536
+ 1201 // const/4 v1, #int 0 // #0
537
+ 2203 ???? // new-instance v3, Ljavax/crypto/spec/SecretKeySpec; // type@006a
538
+ 6e10 ???? 0700 // invoke-virtual {v7}, Ljava/lang/String;.getBytes:()[B // method@004f
539
+ 0c04 // move-result-object v4
540
+ 1a05 ???? // const-string v5, "AES" // string@001e
541
+ 7030 ???? 4305 // invoke-direct {v3, v4, v5}, Ljavax/crypto/spec/SecretKeySpec;.<init>:([BLjava/lang/String;)V // method@0072
542
+ 1a04 ???? // const-string v4, "AES" // string@001e
543
+ 7110 ???? 0400 // invoke-static {v4}, Ljavax/crypto/Cipher;.getInstance:(Ljava/lang/String;)Ljavax/crypto/Cipher; // method@0070
544
+ 0c00 // move-result-object v0
545
+ 1224 // const/4 v4, #int 2 // #2
546
+ 6e30 ???? 4003 // invoke-virtual {v0, v4, v3}, Ljavax/crypto/Cipher;.init:(ILjava/security/Key;)V // method@0071
547
+ 6e20 ???? 6000 // invoke-virtual {v0, v6}, Ljavax/crypto/Cipher;.doFinal:([B)[B // method@006f
548
+ 0c01 // move-result-object v1
549
+ 1101 // return-object v1
550
+ 0d02 // move-exception v2
551
+ 6e10 ???? 0200 // invoke-virtual {v2}, Ljava/lang/Exception;.printStackTrace:()V // method@0043
552
+ 28fb // goto 001a // -0005
553
+ }
554
+ $cipher3 = {
555
+ 7110 ???? 0100 // invoke-static {v1}, Lᵔˎʻᐧـˏ/יﹳﹶˆˆ/ˊ゙ᵔٴʼי/ᴵˆᵔᵎˑʾ/ʼˈˏ゙ˎˉ;.encodeToMD516:(Ljava/lang/String;)Ljava/lang/String; // method@0085
556
+ 0c00 // move-result-object v0
557
+ 6e10 ???? 0000 // invoke-virtual {v0}, Ljava/lang/String;.toLowerCase:()Ljava/lang/String; // method@0056
558
+ 0c00 // move-result-object v0
559
+ 1100 // return-object v0
560
+ }
561
+
562
+ condition:
563
+ is_dex and all of them
564
+ }
565
+
566
+ rule custom_flutter : packer
567
+ {
568
+ meta:
569
+ description = "Custom Flutter"
570
+ sample1 = "d91a793d7a63ca6279da81ea5986ba51663f0762399ce122d85b09a020521a0c"
571
+ sample2 = "130f9d4c200f8c45df48e49360eb422710db8999f3dc571f10cfb04b139ed0d0"
572
+ author = "ReBensk"
573
+
574
+ strings:
575
+ $attachBaseContextOpcodes = {
576
+ 6f20 0100 ba00 // invoke-super {v10, v11}, Landroid/app/Application;.attachBaseContext:(Landroid/content/Context;)V // method@0001
577
+ 1a0b ???? // const-string v11, "AppasyOlsoNaMdq_XoCdqeMx" // string@0005
578
+ 7110 ???? 0b00 // invoke-static {v11}, Lcom/zzWrgZUeZn;.reewRNuvCn:(Ljava/lang/String;)Ljava/lang/String; // method@0012
579
+ 0c0b // move-result-object v11
580
+ 1203 // const/4 v3, #int 0 // #0
581
+ 6e30 ???? ba03 // invoke-virtual {v10, v11, v3}, Lcom/zzWrgZUeZn;.getDir:(Ljava/lang/String;I)Ljava/io/File; // method@000e
582
+ 0c0b // move-result-object v11
583
+ 1a04 ???? // const-string v4, "ipwaIyIlxoxajdm_VdNeDx" // string@00f3
584
+ 7110 ???? 0400 // invoke-static {v4}, Lcom/zzWrgZUeZn;.reewRNuvCn:(Ljava/lang/String;)Ljava/lang/String; // method@0012
585
+ 0c04 // move-result-object v4
586
+ 6e30 ???? 4a03 // invoke-virtual {v10, v4, v3}, Lcom/zzWrgZUeZn;.getDir:(Ljava/lang/String;I)Ljava/io/File; // method@000e
587
+ 0c04 // move-result-object v4
588
+ 6e10 ???? 0400 // invoke-virtual {v4}, Ljava/io/File;.listFiles:()[Ljava/io/File; // method@0020
589
+ 0c05 // move-result-object v5
590
+ 2155 // array-length v5, v5
591
+ 3905 0d00 // if-nez v5, 0030 // +000d
592
+ }
593
+ $cipher = {
594
+ 1a00 ???? // const-string v0, "WATEPSY/cEDCnBZ/jPdKNCNSL5GPjawdmdkiWnzg" // string@00b2 // AES/ECB/PKCS5Padding
595
+ 7110 ???? 0000 // invoke-static {v0}, Lcom/zzWrgZUeZn;.reewRNuvCn:(Ljava/lang/String;)Ljava/lang/String; // method@0012
596
+ 0c00 // move-result-object v0
597
+ 1a01 ???? // const-string v1, "3662583155221358" // string@0001
598
+ 1a02 ???? // const-string v2, "7243279461549821" // string@0002
599
+ 7140 ???? 2140 // invoke-static {v1, v2, v0, v4}, Lcom/zzWrgZUeZn;.DgQYvfuzRk:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[B)[B // method@0006
600
+ 0c04 // move-result-object v4
601
+ 1104 // return-object v4
602
+ }
603
+
604
+ condition:
605
+ is_dex and all of them
606
+ }
607
+
608
+ rule jiagu_k : packer
609
+ {
610
+ meta:
611
+ description = "Jiagu K"
612
+ sample1 = "aa666b75ffb3588dd41c8e546d53e353cda67cf278b167c7737b1169262856bb"
613
+ sample2 = "d9baf66e7ac116a8c68599ef16fae5397ac4fd0847e2fcfe3ee2c155ecf4f850"
614
+ author = "ReBensk"
615
+
616
+ strings:
617
+ $classNameString = { 00 10 4C 76 69 72 62 6F 78 2F 53 74 75 62 41 70 70 3B 00 } // Lvirbox/StubApp;
618
+
619
+ condition:
620
+ is_dex and all of them and (dex.header.data_size + dex.header.data_offset) < dex.header.file_size
621
+ }
622
+
623
+ rule nesun_dex : packer
624
+ {
625
+ meta:
626
+ description = "Nesun"
627
+ url = "http://nesun.cn"
628
+ sample = "13735b73994231e25393a1847e1111c9741cc112315b3f0d4f775a62ab58ae5d"
629
+ author = "Abhi"
630
+
631
+ strings:
632
+ $versionString = { 00 08 7a 56 65 72 73 69 6f 6e 00 } // ..zVersion.
633
+ $libString = { 00 08 7A 70 72 6F 74 65 63 74 00 } // ..zprotect.
634
+ $class = { 00 14 4c 63 6f 6d 2f 6e 65 73 75 6e 2f 73 74 75 62 2f 5a 41 50 3b 00 } // Lcom/nesun/stub/ZAP;
635
+
636
+ condition:
637
+ is_dex and all of them
638
+ }
639
+
640
+ rule gpresto_dex : packer
641
+ {
642
+ meta:
643
+ description = "G-Presto (anti-cheat)"
644
+ url = "https://www.largosoft.co.kr/"
645
+ sample = "44558c6c758b1ecf42ecda9981240d50c32f42e0d2be4693e37e39f8eb3a3488"
646
+ author = "Abhi"
647
+
648
+ strings:
649
+ $class = { 00 22 4C 63 6F 6D 2F 62 69 73 68 6F 70 73 6F 66 74 2F 50 72 65 73 74 6F 2F 53 44 4B 2F 50 72 65 73 74 6F 3B 00 } // ."Lcom/bishopsoft/Presto/SDK/Presto;.
650
+
651
+ // code segment of the injected methods plus junk opcodes
652
+ $code_segment = {
653
+ 02 00 01 00 00 00 00 00 ?? ?? ?? ?? 11 00 00 00 00 (1? | 2? | 3? | 4? | 5? | 6? | 7? | 8? | 9? | a? | b? | c0 | c1 | c2 | c3 | c4 | c5 | c6 | c7)
654
+ }
655
+
656
+ condition:
657
+ is_dex and all of them
658
+ }
659
+
660
+ rule dingxiang_dex : packer
661
+ {
662
+ meta:
663
+ description = "DingXiang"
664
+ url = "https://www.dingxiang-inc.com/business/android"
665
+ sample = "788ebabd9b5464c5e86b3832e4a7b6e7c91cce5603ff17f214429400ba3bb2b9" // net.crigh.cgsport
666
+ author = "Abhi"
667
+
668
+ strings:
669
+ $class = { 00 50 4C [32] 2F 63 6F 6D 2F 64 69
670
+ 6E 67 78 69 61 6E 67 2F 6D 6F 62 69
671
+ 6C 65 2F 72 65 73 65 6E 2F 53 74 72
672
+ 69 6E 67 45 6E 63 72 79 70 74 55 74
673
+ 69 6C 73 3B 00 } // L[32]/com/dingxiang/mobile/resen/StringEncryptUtils;
674
+ $class2 = { 00 1E 4C 63 6F 6D 2F 73 65 63 75 72
675
+ 69 74 79 2F 69 6E 6E 65 72 2F 73 74
676
+ 75 62 30 30 30 2F [1] 3B 00 } // Lcom/security/inner/stub000/x;
677
+ $class3 = { 00 20 4C 70 6E 66 2F 74 68 69 73 2F
678
+ 6F 62 6A 65 63 74 2F 64 6F 65 73 2F
679
+ 6E 6F 74 2F 45 78 69 73 74 3B 00 } // Lcom/pnf/this/object/does/not/Exist;
680
+
681
+ /* Older versions starts with hash + class name
682
+ E.g.: L377f1c444f7bd22614205e1a99a24ee1/com/mobile/streng/BuildConfig; */
683
+ $hash_code = { 00 40 4C [32] 2F 63 6F 6D 2F 6D 6F 62 69 6C 65 2F 73 74
684
+ 72 65 6E 63 2F 42 75 69 6C 64 43 6F 6E 66 69 67 3B 00 }
685
+
686
+ /* Newer Versions check for hash directly
687
+ E.g.: String trim = ("5404f0525edfb68c1abc06e6f6d468f3" == 0 ? "" : "5404f0525edfb68c1abc06e6f6d468f3").trim(); */
688
+ $hash_code2 = {
689
+ 71 00 ?? 01 00 00 // invoke-static {}, Lpnf/this/object/does/not/Exist;->started()V
690
+ 63 00 4? 00 // sget-boolean v0, Lpnf/this/object/does/not/Exist;->enabled:Z
691
+ 67 00 4? 00 // sput v0, Lpnf/this/object/does/not/Exist;->started:I
692
+ 1A 00 ?? ?? // const-string v0, "hash"
693
+ 39 00 ?? ?? // if-nez v0, :cond_x
694
+ 1A 00 ?? ?? // const-string v0, ""
695
+ 6E 10 ?? ?? 00 00 // invoke-virtual {v0}, Ljava/lang/String;->trim()Ljava/lang/String;
696
+ 0C 00 // move-result-object v0
697
+ }
698
+
699
+ /* File file2 = new File(file, String.format("libdsn_hold_%s.jar", "56cc9cd75dfe4dff177b9b4de6908cba".trim())); */
700
+ $hash_code3 = {
701
+ 22 ?? 40 00 // new-instance v1, Ljava/io/File;
702
+ 1A 00 ?? ?? // const-string v0, "hash"
703
+ 6E 10 ?? ?? 00 00 // invoke-virtual {v0}, Ljava/lang/String;->trim()Ljava/lang/String;
704
+ 0C 00 // move-result-object v0
705
+ 23 ?? 7A 00 // new-array v2, v10, [Ljava/lang/Object;
706
+ 4D 00 ?? ?? // aput-object v0, v2, v9
707
+ 1A 00 ?? ?? // const-string v0, "libdsn_hold_%s.jar" | "libdsn_%s.jar"
708
+ 71 ?? 0F ?? ?? ?? // invoke-static {v0, v2}, Ljava/lang/String.format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
709
+ 0C 00 // move-result-object v0
710
+ }
711
+
712
+ $string = { 00 04 64 73 6E 30 00 } // dsn0
713
+ $string2 = { 00 07 73 74 75 62 30 30 30 00 } // stub000
714
+ $string3 = { 00 0D 6C 69 62 73 74 75 62 30 30 30 2E 73 6F 00 } // libstub000.so
715
+ $string4 = { 00 0F 63 6F 64 65 5F 63 61 63 68 65 2F 64 73 6E 30 00 } // code_cache/dsn0
716
+
717
+ condition:
718
+ is_dex
719
+ and any of ($hash_code*)
720
+ and any of ($string*)
721
+ or 2 of ($class*)
722
+ }
723
+
724
+ rule kiwisec_dex : packer
725
+ {
726
+ meta:
727
+ description = "KiwiSec"
728
+ url = "https://en.kiwisec.com/"
729
+ sample = "d108652bd1b685765e3ada2b7376e3c3ff67f8162afcf8bad91e0aef79b7b08a"
730
+ author = "Abhi"
731
+
732
+ strings:
733
+ $class = { 00 1E 4C 63 6F 6D 2F 6B 69 77 69 73 65 63
734
+ 2F 63 72 61 73 68 2F 43 72 61 73 68 55 74
735
+ 69 6C 73 3B 00 } // Lcom/kiwisec/crash/CrashUtils;
736
+ $class2 = { 00 25 4C 63 6F 6D 2F 6B 69 77 69 76 6D 2F
737
+ 73 65 63 75 72 69 74 79 2F 53 74 75 62 41
738
+ 70 70 6C 69 63 61 74 69 6F 6E 3B 00 } // Lcom/kiwivm/security/StubApplication;
739
+
740
+ condition:
741
+ is_dex and any of them
742
+ }
743
+
744
+ rule manxi_sec : packer
745
+ {
746
+ meta:
747
+ description = "Manxi Security"
748
+ url = "https://www.manxi-inc.com/en/"
749
+ sample = "9803121e89d5609215dc736b11cf5cf0a7d56ddfe5ac9ab71eb2b2883f427ac2" // cn.dict.android.pro (6.1.37)
750
+ author = "Abhi"
751
+
752
+ strings:
753
+ $class = { 00 18 4C 63 6F 6D 2F 6D 61 6E 78 69 2F 73
754
+ 68 65 6C 6C 2F 48 65 6C 70 65 72 3B 00 } // Lcom/manxi/shell/Helper;
755
+ $class2 = { 00 1F 4C 63 6F 6D 2F 6D 61 6E 78 69 2F 73
756
+ 68 65 6C 6C 2F 4D 58 41 70 70 6C 69 63 61
757
+ 74 69 6F 6E 3B 00 } // Lcom/manxi/shell/MXApplication;
758
+
759
+ condition:
760
+ is_dex and any of them
761
+ }