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.
- package/LICENSE +21 -0
- package/README.md +249 -0
- package/anais.sh +669 -0
- package/analysis_tools/__pycache__/apk_basic_info.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/apk_basic_info.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/check_zip_encryption.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/check_zip_encryption.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/detect_obfuscation.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/detect_obfuscation.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/dex_payload_hunter.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/entropy_analyzer.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/error_logger.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/error_logger.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/find_encrypted_payload.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/fix_apk_headers.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/fix_apk_headers.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/manifest_analyzer.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/manifest_analyzer.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/network_analyzer.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/network_analyzer.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/report_generator.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/report_generator.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/report_generator_modular.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/sast_scanner.cpython-313.pyc +0 -0
- package/analysis_tools/__pycache__/sast_scanner.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/so_string_analyzer.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/yara_enhanced_analyzer.cpython-314.pyc +0 -0
- package/analysis_tools/__pycache__/yara_results_processor.cpython-314.pyc +0 -0
- package/analysis_tools/apk_basic_info.py +85 -0
- package/analysis_tools/check_zip_encryption.py +142 -0
- package/analysis_tools/detect_obfuscation.py +650 -0
- package/analysis_tools/dex_payload_hunter.py +734 -0
- package/analysis_tools/entropy_analyzer.py +335 -0
- package/analysis_tools/error_logger.py +75 -0
- package/analysis_tools/find_encrypted_payload.py +485 -0
- package/analysis_tools/fix_apk_headers.py +154 -0
- package/analysis_tools/manifest_analyzer.py +214 -0
- package/analysis_tools/network_analyzer.py +287 -0
- package/analysis_tools/report_generator.py +506 -0
- package/analysis_tools/report_generator_modular.py +885 -0
- package/analysis_tools/sast_scanner.py +412 -0
- package/analysis_tools/so_string_analyzer.py +406 -0
- package/analysis_tools/yara_enhanced_analyzer.py +330 -0
- package/analysis_tools/yara_results_processor.py +368 -0
- package/analyzer_config.json +113 -0
- package/apkid/__init__.py +32 -0
- package/apkid/__pycache__/__init__.cpython-313.pyc +0 -0
- package/apkid/__pycache__/__init__.cpython-314.pyc +0 -0
- package/apkid/__pycache__/apkid.cpython-313.pyc +0 -0
- package/apkid/__pycache__/apkid.cpython-314.pyc +0 -0
- package/apkid/__pycache__/main.cpython-313.pyc +0 -0
- package/apkid/__pycache__/main.cpython-314.pyc +0 -0
- package/apkid/__pycache__/output.cpython-313.pyc +0 -0
- package/apkid/__pycache__/rules.cpython-313.pyc +0 -0
- package/apkid/apkid.py +266 -0
- package/apkid/main.py +98 -0
- package/apkid/output.py +177 -0
- package/apkid/rules/apk/common.yara +68 -0
- package/apkid/rules/apk/obfuscators.yara +118 -0
- package/apkid/rules/apk/packers.yara +1197 -0
- package/apkid/rules/apk/protectors.yara +301 -0
- package/apkid/rules/dex/abnormal.yara +104 -0
- package/apkid/rules/dex/anti-vm.yara +568 -0
- package/apkid/rules/dex/common.yara +60 -0
- package/apkid/rules/dex/compilers.yara +434 -0
- package/apkid/rules/dex/obfuscators.yara +602 -0
- package/apkid/rules/dex/packers.yara +761 -0
- package/apkid/rules/dex/protectors.yara +520 -0
- package/apkid/rules/dll/common.yara +38 -0
- package/apkid/rules/dll/obfuscators.yara +43 -0
- package/apkid/rules/elf/anti-vm.yara +43 -0
- package/apkid/rules/elf/common.yara +54 -0
- package/apkid/rules/elf/obfuscators.yara +991 -0
- package/apkid/rules/elf/packers.yara +1128 -0
- package/apkid/rules/elf/protectors.yara +794 -0
- package/apkid/rules/res/common.yara +43 -0
- package/apkid/rules/res/obfuscators.yara +46 -0
- package/apkid/rules/res/protectors.yara +46 -0
- package/apkid/rules.py +77 -0
- package/bin/anais +3 -0
- package/dist/cli.js +82 -0
- package/dist/index.js +123 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/output.js +44 -0
- package/dist/utils/paths.js +107 -0
- package/docs/ARCHITECTURE.txt +353 -0
- package/docs/Workflow and Reference.md +445 -0
- package/package.json +70 -0
- package/rules/yara_general_rules.yar +323 -0
- package/scripts/dynamic_analysis_helper.sh +334 -0
- package/scripts/frida/dpt_dex_dumper.js +145 -0
- package/scripts/frida/frida_dex_dump.js +145 -0
- package/scripts/frida/frida_hooks.js +437 -0
- package/scripts/frida/frida_websocket_extractor.js +154 -0
- package/scripts/setup.sh +206 -0
- package/scripts/validate_framework.sh +224 -0
- package/src/cli.ts +91 -0
- package/src/index.ts +123 -0
- package/src/types/index.ts +44 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/output.ts +50 -0
- package/src/utils/paths.ts +72 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,568 @@
|
|
|
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
|
+
import "dex"
|
|
29
|
+
include "common.yara"
|
|
30
|
+
|
|
31
|
+
private rule uses_build_class : internal
|
|
32
|
+
{
|
|
33
|
+
meta:
|
|
34
|
+
description = "References android.os.Build class"
|
|
35
|
+
|
|
36
|
+
strings:
|
|
37
|
+
// Landroid/os/Build;
|
|
38
|
+
$a = {00 12 4C 61 6E 64 72 6F 69 64 2F 6F 73 2F 42 75 69 6C 64 3B 00}
|
|
39
|
+
condition:
|
|
40
|
+
is_dex
|
|
41
|
+
and $a
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private rule uses_debug_class : internal
|
|
45
|
+
{
|
|
46
|
+
meta:
|
|
47
|
+
description = "References android.os.Debug class"
|
|
48
|
+
|
|
49
|
+
strings:
|
|
50
|
+
// Landroid/os/Debug;
|
|
51
|
+
$a = {00 12 4C 61 6E 64 72 6F 69 64 2F 6F 73 2F 44 65 62 75 67 3B 00}
|
|
52
|
+
condition:
|
|
53
|
+
is_dex
|
|
54
|
+
and $a
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private rule uses_telephony_class : internal
|
|
58
|
+
{
|
|
59
|
+
meta:
|
|
60
|
+
description = "References android.telephony.TelephonyManager class"
|
|
61
|
+
|
|
62
|
+
strings:
|
|
63
|
+
// Landroid/telephony/TelephonyManager;
|
|
64
|
+
$a = {00 24 4C 61 6E 64 72 6F 69 64 2F 74 65 6C 65 70 68 6F 6E 79 2F 54
|
|
65
|
+
65 6C 65 70 68 6F 6E 79 4D 61 6E 61 67 65 72 3B 00}
|
|
66
|
+
condition:
|
|
67
|
+
is_dex
|
|
68
|
+
and $a
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
rule checks_build_fingerprint : anti_vm
|
|
72
|
+
{
|
|
73
|
+
meta:
|
|
74
|
+
description = "Build.FINGERPRINT check"
|
|
75
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
76
|
+
|
|
77
|
+
strings:
|
|
78
|
+
// FINGERPRINT
|
|
79
|
+
$prop = {00 0B 46 49 4E 47 45 52 50 52 49 4E 54 00}
|
|
80
|
+
// generic
|
|
81
|
+
$str_1 = {00 07 67 65 6E 65 72 69 63 00 0A}
|
|
82
|
+
// unknown
|
|
83
|
+
$str_2 = {00 07 75 6E 6B 6E 6F 77 6E 00}
|
|
84
|
+
$str_3 = "generic/sdk/generic"
|
|
85
|
+
$str_4 = "generic/generic/generic"
|
|
86
|
+
$str_5 = "generic/google_sdk/generic"
|
|
87
|
+
$str_6 = "generic_x86/sdk_x86/generic_x86"
|
|
88
|
+
$str_7 = "Android/full_x86/generic_x86"
|
|
89
|
+
$str_8 = "generic/vbox86p/vbox86p"
|
|
90
|
+
|
|
91
|
+
condition:
|
|
92
|
+
uses_build_class
|
|
93
|
+
and $prop
|
|
94
|
+
and 1 of ($str_*)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
rule checks_debugger_present : anti_debug
|
|
98
|
+
{
|
|
99
|
+
meta:
|
|
100
|
+
description = "Debug.isDebuggerConnected() check"
|
|
101
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
102
|
+
|
|
103
|
+
strings:
|
|
104
|
+
$debug = "Debug"
|
|
105
|
+
$debugger_connected = "isDebuggerConnected"
|
|
106
|
+
|
|
107
|
+
condition:
|
|
108
|
+
uses_debug_class
|
|
109
|
+
and $debug and $debugger_connected
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
rule checks_build_model : anti_vm
|
|
113
|
+
{
|
|
114
|
+
meta:
|
|
115
|
+
description = "Build.MODEL check"
|
|
116
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
117
|
+
|
|
118
|
+
strings:
|
|
119
|
+
// MODEL
|
|
120
|
+
$prop = {00 05 4D 4F 44 45 4C 00}
|
|
121
|
+
// google_sdk
|
|
122
|
+
$str_1 = {00 0A 67 6F 6F 67 6C 65 5F 73 64 6B 00}
|
|
123
|
+
// sdk
|
|
124
|
+
$str_2 = {00 03 73 64 6B 00}
|
|
125
|
+
// Emulator
|
|
126
|
+
$str_3 = {00 08 45 6D 75 6C 61 74 6F 72 00}
|
|
127
|
+
// Android SDK built for x86
|
|
128
|
+
$str_4 = "Android SDK built for x86"
|
|
129
|
+
$str_5 = "Full Android on x86"
|
|
130
|
+
|
|
131
|
+
condition:
|
|
132
|
+
uses_build_class
|
|
133
|
+
and $prop
|
|
134
|
+
and 1 of ($str_*)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
rule checks_build_manufacturer : anti_vm
|
|
138
|
+
{
|
|
139
|
+
meta:
|
|
140
|
+
description = "Build.MANUFACTURER check"
|
|
141
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
142
|
+
|
|
143
|
+
strings:
|
|
144
|
+
// MANUFACTURER
|
|
145
|
+
$prop = {00 0C 4D 41 4E 55 46 41 43 54 55 52 45 52 00}
|
|
146
|
+
// Genymotion
|
|
147
|
+
$str_1 = {00 0A 47 65 6E 79 6D 6F 74 69 6F 6E 00}
|
|
148
|
+
// unknown
|
|
149
|
+
$str_2 = {00 07 75 6E 6B 6E 6F 77 6E 00}
|
|
150
|
+
|
|
151
|
+
condition:
|
|
152
|
+
uses_build_class
|
|
153
|
+
and $prop
|
|
154
|
+
and 1 of ($str_*)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
rule checks_build_brand : anti_vm
|
|
158
|
+
{
|
|
159
|
+
meta:
|
|
160
|
+
description = "Build.BRAND check"
|
|
161
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
162
|
+
|
|
163
|
+
strings:
|
|
164
|
+
// BRAND
|
|
165
|
+
$prop = {00 05 42 52 41 4E 44 00}
|
|
166
|
+
// generic
|
|
167
|
+
$str_1 = {00 07 67 65 6E 65 72 69 63 00 0A}
|
|
168
|
+
|
|
169
|
+
condition:
|
|
170
|
+
uses_build_class
|
|
171
|
+
and $prop
|
|
172
|
+
and $str_1
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
rule checks_build_device : anti_vm
|
|
176
|
+
{
|
|
177
|
+
meta:
|
|
178
|
+
description = "Build.DEVICE check"
|
|
179
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
180
|
+
|
|
181
|
+
strings:
|
|
182
|
+
// DEVICE
|
|
183
|
+
$prop = {00 06 44 45 56 49 43 45 00}
|
|
184
|
+
// generic
|
|
185
|
+
$str_1 = {00 07 67 65 6E 65 72 69 63 00 0A}
|
|
186
|
+
|
|
187
|
+
condition:
|
|
188
|
+
uses_build_class
|
|
189
|
+
and $prop
|
|
190
|
+
and $str_1
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
rule checks_build_product : anti_vm
|
|
194
|
+
{
|
|
195
|
+
meta:
|
|
196
|
+
description = "Build.PRODUCT check"
|
|
197
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
198
|
+
|
|
199
|
+
strings:
|
|
200
|
+
// PRODUCT
|
|
201
|
+
$prop = {00 07 50 52 4F 44 55 43 54 00}
|
|
202
|
+
// google_sdk
|
|
203
|
+
$str_1 = {00 0A 67 6F 6F 67 6C 65 5F 73 64 6B 00}
|
|
204
|
+
// sdk
|
|
205
|
+
$str_2 = {00 03 73 64 6B 00}
|
|
206
|
+
|
|
207
|
+
condition:
|
|
208
|
+
uses_build_class
|
|
209
|
+
and $prop
|
|
210
|
+
and 1 of ($str_*)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
rule checks_build_hardware : anti_vm
|
|
214
|
+
{
|
|
215
|
+
meta:
|
|
216
|
+
description = "Build.HARDWARE check"
|
|
217
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
218
|
+
|
|
219
|
+
strings:
|
|
220
|
+
// HARDWARE
|
|
221
|
+
$prop = {00 08 48 41 52 44 57 41 52 45 00}
|
|
222
|
+
// goldfish
|
|
223
|
+
$str_1 = {00 08 67 6F 6C 64 66 69 73 68 00}
|
|
224
|
+
// ranchu
|
|
225
|
+
$str_2 = {00 06 72 61 6E 63 68 75 00}
|
|
226
|
+
$str_4 = "vbox86"
|
|
227
|
+
|
|
228
|
+
condition:
|
|
229
|
+
uses_build_class
|
|
230
|
+
and $prop
|
|
231
|
+
and 1 of ($str_*)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
rule checks_build_board : anti_vm
|
|
235
|
+
{
|
|
236
|
+
meta:
|
|
237
|
+
description = "Build.BOARD check"
|
|
238
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
239
|
+
|
|
240
|
+
strings:
|
|
241
|
+
// BOARD
|
|
242
|
+
$prop = {00 05 42 4F 41 52 44 00}
|
|
243
|
+
// unknown
|
|
244
|
+
$str_1 = {00 07 75 6E 6B 6E 6F 77 6E 00}
|
|
245
|
+
|
|
246
|
+
condition:
|
|
247
|
+
uses_build_class
|
|
248
|
+
and $prop
|
|
249
|
+
and $str_1
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
rule checks_build_id : anti_vm
|
|
253
|
+
{
|
|
254
|
+
meta:
|
|
255
|
+
description = "Build.ID check"
|
|
256
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
257
|
+
|
|
258
|
+
strings:
|
|
259
|
+
// ID
|
|
260
|
+
$prop = {00 02 49 44 00}
|
|
261
|
+
// FRF91
|
|
262
|
+
$str_1 = {00 05 46 52 46 39 31 00}
|
|
263
|
+
|
|
264
|
+
condition:
|
|
265
|
+
uses_build_class
|
|
266
|
+
and $prop
|
|
267
|
+
and $str_1
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
rule possible_build_serial_check : anti_vm
|
|
271
|
+
{
|
|
272
|
+
meta:
|
|
273
|
+
description = "possible Build.SERIAL check"
|
|
274
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
275
|
+
|
|
276
|
+
strings:
|
|
277
|
+
// SERIAL
|
|
278
|
+
$prop = {00 06 53 45 52 49 41 4C 00}
|
|
279
|
+
// Serial is checked for null / 0x0, so no literal
|
|
280
|
+
|
|
281
|
+
condition:
|
|
282
|
+
uses_build_class
|
|
283
|
+
and $prop
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
rule checks_build_tags : anti_vm
|
|
287
|
+
{
|
|
288
|
+
meta:
|
|
289
|
+
description = "Build.TAGS check"
|
|
290
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
291
|
+
|
|
292
|
+
strings:
|
|
293
|
+
// TAGS
|
|
294
|
+
$prop = {00 04 54 41 47 53 00}
|
|
295
|
+
// test-keys
|
|
296
|
+
$str_1 = {00 09 74 65 73 74 2D 6B 65 79 73 00}
|
|
297
|
+
|
|
298
|
+
condition:
|
|
299
|
+
uses_build_class
|
|
300
|
+
and $prop
|
|
301
|
+
and $str_1
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
rule checks_build_user : anti_vm
|
|
305
|
+
{
|
|
306
|
+
meta:
|
|
307
|
+
description = "Build.USER check"
|
|
308
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
309
|
+
|
|
310
|
+
strings:
|
|
311
|
+
// TAGS
|
|
312
|
+
$prop = {00 04 54 41 47 53 00}
|
|
313
|
+
// android-build
|
|
314
|
+
$str_1 = {00 0D 61 6E 64 72 6F 69 64 2D 62 75 69 6C 64 00}
|
|
315
|
+
|
|
316
|
+
condition:
|
|
317
|
+
uses_build_class
|
|
318
|
+
and $prop
|
|
319
|
+
and $str_1
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
rule checks_sim_operator : anti_vm
|
|
323
|
+
{
|
|
324
|
+
meta:
|
|
325
|
+
description = "SIM operator check"
|
|
326
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
327
|
+
|
|
328
|
+
strings:
|
|
329
|
+
// getSimOperator
|
|
330
|
+
$a = {00 0E 67 65 74 53 69 6D 4F 70 65 72 61 74 6F 72 00}
|
|
331
|
+
// Android
|
|
332
|
+
$b = {00 07 41 6E 64 72 6F 69 64 00}
|
|
333
|
+
|
|
334
|
+
condition:
|
|
335
|
+
uses_telephony_class
|
|
336
|
+
and all of them
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
rule checks_network_operator : anti_vm
|
|
340
|
+
{
|
|
341
|
+
meta:
|
|
342
|
+
description = "network operator name check"
|
|
343
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
344
|
+
|
|
345
|
+
strings:
|
|
346
|
+
// getNetworkOperatorName
|
|
347
|
+
$a = {00 16 67 65 74 4E 65 74 77 6F 72 6B 4F 70 65 72 61 74 6F 72 4E 61 6D 65 00}
|
|
348
|
+
// Android
|
|
349
|
+
$b = {00 07 41 6E 64 72 6F 69 64 00}
|
|
350
|
+
|
|
351
|
+
condition:
|
|
352
|
+
uses_telephony_class
|
|
353
|
+
and all of them
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
rule checks_device_id : anti_vm
|
|
357
|
+
{
|
|
358
|
+
meta:
|
|
359
|
+
description = "device ID check"
|
|
360
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
361
|
+
|
|
362
|
+
strings:
|
|
363
|
+
// getDeviceId
|
|
364
|
+
$a = {00 0B 67 65 74 44 65 76 69 63 65 49 64 00}
|
|
365
|
+
// 000000000000000
|
|
366
|
+
$b = {00 0F 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 00}
|
|
367
|
+
|
|
368
|
+
condition:
|
|
369
|
+
uses_telephony_class
|
|
370
|
+
and all of them
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
rule checks_line1_number : anti_vm
|
|
374
|
+
{
|
|
375
|
+
meta:
|
|
376
|
+
description = "line 1 number check"
|
|
377
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
378
|
+
|
|
379
|
+
strings:
|
|
380
|
+
// getLine1Number
|
|
381
|
+
$a = {00 0E 67 65 74 4C 69 6E 65 31 4E 75 6D 62 65 72 00}
|
|
382
|
+
// 155552155
|
|
383
|
+
$b = {00 09 31 35 35 35 35 32 31 35 35 00}
|
|
384
|
+
|
|
385
|
+
condition:
|
|
386
|
+
uses_telephony_class
|
|
387
|
+
and all of them
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
rule checks_voicemail_number : anti_vm
|
|
391
|
+
{
|
|
392
|
+
meta:
|
|
393
|
+
description = "voice mail number check"
|
|
394
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
395
|
+
|
|
396
|
+
strings:
|
|
397
|
+
// getVoiceMailNumber
|
|
398
|
+
$a = {00 12 67 65 74 56 6F 69 63 65 4D 61 69 6C 4E 75 6D 62 65 72 00}
|
|
399
|
+
// 15552175049
|
|
400
|
+
$b = {00 0B 31 35 35 35 32 31 37 35 30 34 39 00}
|
|
401
|
+
|
|
402
|
+
condition:
|
|
403
|
+
uses_telephony_class
|
|
404
|
+
and all of them
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
rule checks_subscriber_id: anti_vm
|
|
408
|
+
{
|
|
409
|
+
meta:
|
|
410
|
+
description = "subscriber ID check"
|
|
411
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
412
|
+
|
|
413
|
+
strings:
|
|
414
|
+
// getSubscriberId
|
|
415
|
+
$a = {00 0F 67 65 74 53 75 62 73 63 72 69 62 65 72 49 64 00}
|
|
416
|
+
$b = "0000000000"
|
|
417
|
+
|
|
418
|
+
condition:
|
|
419
|
+
uses_telephony_class
|
|
420
|
+
and all of them
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
rule checks_network_interface_names: anti_vm
|
|
424
|
+
{
|
|
425
|
+
meta:
|
|
426
|
+
description = "network interface name check"
|
|
427
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
428
|
+
|
|
429
|
+
strings:
|
|
430
|
+
// Ljava/net/NetworkInterface;
|
|
431
|
+
$a = {00 1B 4C 6A 61 76 61 2F 6E 65 74 2F 4E 65 74 77 6F 72 6B 49 6E 74 65 72 66 61 63 65 3B 00}
|
|
432
|
+
// getName
|
|
433
|
+
$b = {00 07 67 65 74 4E 61 6D 65 00 0F}
|
|
434
|
+
// eth0
|
|
435
|
+
$c = {00 04 65 74 68 30 00}
|
|
436
|
+
|
|
437
|
+
condition:
|
|
438
|
+
is_dex
|
|
439
|
+
and all of them
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
rule checks_cpuinfo : anti_vm
|
|
443
|
+
{
|
|
444
|
+
meta:
|
|
445
|
+
description = "/proc/cpuinfo check"
|
|
446
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
447
|
+
|
|
448
|
+
strings:
|
|
449
|
+
$a = "/proc/cpuinfo"
|
|
450
|
+
$b = "Goldfish"
|
|
451
|
+
|
|
452
|
+
condition:
|
|
453
|
+
is_dex
|
|
454
|
+
and all of them
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
rule checks_build_type : anti_vm
|
|
458
|
+
{
|
|
459
|
+
meta:
|
|
460
|
+
description = "ro.build.type check"
|
|
461
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
462
|
+
|
|
463
|
+
strings:
|
|
464
|
+
$a = "ro.build.type"
|
|
465
|
+
$b = "user"
|
|
466
|
+
|
|
467
|
+
condition:
|
|
468
|
+
is_dex
|
|
469
|
+
and all of them
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
rule checks_hardware : anti_vm
|
|
473
|
+
{
|
|
474
|
+
meta:
|
|
475
|
+
description = "ro.hardware check"
|
|
476
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
477
|
+
|
|
478
|
+
strings:
|
|
479
|
+
$a = "ro.hardware"
|
|
480
|
+
$str_1 = "goldfish"
|
|
481
|
+
$str_2 = "ranchu"
|
|
482
|
+
|
|
483
|
+
condition:
|
|
484
|
+
is_dex
|
|
485
|
+
and $a
|
|
486
|
+
and 2 of ($str_*)
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
rule checks_product_device : anti_vm
|
|
490
|
+
{
|
|
491
|
+
meta:
|
|
492
|
+
description = "ro.product.device check"
|
|
493
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
494
|
+
|
|
495
|
+
strings:
|
|
496
|
+
$a = "ro.product.device"
|
|
497
|
+
$b = "generic"
|
|
498
|
+
|
|
499
|
+
condition:
|
|
500
|
+
is_dex
|
|
501
|
+
and all of them
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
rule checks_kernel_qemu : anti_vm
|
|
505
|
+
{
|
|
506
|
+
meta:
|
|
507
|
+
description = "ro.kernel.qemu check"
|
|
508
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
509
|
+
|
|
510
|
+
strings:
|
|
511
|
+
$a = "ro.kernel.qemu"
|
|
512
|
+
|
|
513
|
+
condition:
|
|
514
|
+
is_dex
|
|
515
|
+
and all of them
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
rule possible_ro_secure_check : anti_vm
|
|
519
|
+
{
|
|
520
|
+
meta:
|
|
521
|
+
description = "possible ro.secure check"
|
|
522
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
523
|
+
|
|
524
|
+
strings:
|
|
525
|
+
$a = "ro.secure"
|
|
526
|
+
|
|
527
|
+
condition:
|
|
528
|
+
is_dex
|
|
529
|
+
and all of them
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
rule checks_qemu_file : anti_vm
|
|
533
|
+
{
|
|
534
|
+
meta:
|
|
535
|
+
description = "emulator file check"
|
|
536
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
537
|
+
|
|
538
|
+
strings:
|
|
539
|
+
$a = "/init.goldfish.rc"
|
|
540
|
+
$b = "/sys/qemu_trace"
|
|
541
|
+
$c = "/system/bin/qemud"
|
|
542
|
+
$d = "/system/bin/qemu-props"
|
|
543
|
+
$e = "/system/lib/libc_malloc_debug_qemu.so"
|
|
544
|
+
$f = "/dev/qemu_pipe"
|
|
545
|
+
$g = "/dev/socket/qemud"
|
|
546
|
+
|
|
547
|
+
// Geny detections
|
|
548
|
+
$h = "/dev/socket/genyd"
|
|
549
|
+
$i = "/dev/socket/baseband_genyd"
|
|
550
|
+
|
|
551
|
+
condition:
|
|
552
|
+
is_dex
|
|
553
|
+
and 1 of them
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
rule possible_vm_check : anti_vm
|
|
557
|
+
{
|
|
558
|
+
meta:
|
|
559
|
+
description = "possible VM check"
|
|
560
|
+
sample = "9c6b6392fc30959874eef440b6a83a9f5ef8cc95533037a6f86d0d3d18245224"
|
|
561
|
+
|
|
562
|
+
strings:
|
|
563
|
+
$a = "isEmulator"
|
|
564
|
+
|
|
565
|
+
condition:
|
|
566
|
+
is_dex
|
|
567
|
+
and all of them
|
|
568
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
import "dex"
|
|
29
|
+
|
|
30
|
+
rule is_dex : file_type
|
|
31
|
+
{
|
|
32
|
+
meta:
|
|
33
|
+
description = "DEX"
|
|
34
|
+
|
|
35
|
+
strings:
|
|
36
|
+
$dex = { 64 65 78 0A 30 33 ?? 00 }
|
|
37
|
+
$odex = { 64 65 79 0A 30 33 ?? 00 }
|
|
38
|
+
|
|
39
|
+
condition:
|
|
40
|
+
$dex at 0 or
|
|
41
|
+
$odex at 0
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private rule yara_detected_dex : internal {
|
|
45
|
+
meta:
|
|
46
|
+
description = "magic bytes look like a dex but yara disagrees"
|
|
47
|
+
|
|
48
|
+
condition:
|
|
49
|
+
is_dex
|
|
50
|
+
and dex.header.header_size > 0
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
rule yara_undetected_dex : yara_issue {
|
|
54
|
+
meta:
|
|
55
|
+
description = "yara issue - dex file recognized by apkid but not yara module"
|
|
56
|
+
|
|
57
|
+
condition:
|
|
58
|
+
is_dex
|
|
59
|
+
and not yara_detected_dex
|
|
60
|
+
}
|