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,794 @@
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 "elf"
29
+ include "common.yara"
30
+
31
+ rule whitecryption_elf : protector
32
+ {
33
+ // https://github.com/rednaga/APKiD/issues/177
34
+ meta:
35
+ description = "WhiteCryption"
36
+ sample = "6821bce73b3d1146ef7ec9a2d91742a7f6fc2f8206ca9354d3d553e1b5d551a7"
37
+ url = "https://www.intertrust.com/products/application-shielding/"
38
+ author = "Tim 'diff' Strazzere"
39
+
40
+ strings:
41
+ // Currently, it injects the init stub into all classes, so this is a reasonable thing
42
+ // to search for
43
+ $init_stub = "scpClassInit"
44
+ $empty_func = "SCP_EmptyFunction"
45
+ $init_proc_stub = {
46
+ // PUSH {R0-R2,R4,R11,LR}
47
+ 17 48 2D E9
48
+ // BL sub_B500
49
+ 58 00 00 EB
50
+ // BX R0
51
+ 10 FF 2F E1
52
+ }
53
+
54
+ condition:
55
+ is_elf and (($init_stub or $empty_func) or $init_proc_stub)
56
+ }
57
+
58
+ rule whitecryption_elf_a : protector
59
+ {
60
+ meta:
61
+ description = "WhiteCryption"
62
+ sample = "a9926158f16d57072940c001a5ef06e4bf600f98d9ca9daeec202f71caa3d7b2"
63
+ url = "https://www.intertrust.com/products/application-shielding/"
64
+ author = "Eduardo Novella"
65
+
66
+ strings:
67
+ $wcskbox = "whiteCryptionSecureKeyBox"
68
+ $jni = "Java_com_whitecryption_skb_"
69
+ $libname = "libSecureKeyBoxJava.so"
70
+
71
+ condition:
72
+ is_elf and 1 of them
73
+ }
74
+
75
+ rule ahnlab_v3_engine : anti_root
76
+ {
77
+ meta:
78
+ description = "Ahnlab V3 Engine"
79
+ sample1 = "638bad9c6336049f43ac88d7db65c743d9703d732f86f2dc094999b195d63aa2"
80
+ sample2 = "87487409f9fb2f8a2c086f3476a5020c12bea4f18356b45e89c09007791c62fb"
81
+ sample3 = "fc48d65f27b3231db4c068ddc4a63c5ca68843c42b2e989dd626ea6aa2f52b66"
82
+ url = "https://www.ahnlab.com/en"
83
+ author = "whoa-mi"
84
+
85
+ strings:
86
+ $entry = "engmgr_startRootCheck"
87
+
88
+ condition:
89
+ is_elf and all of them
90
+ }
91
+
92
+ rule appdome_elf : protector
93
+ {
94
+ // https://github.com/rednaga/APKiD/issues/151
95
+ meta:
96
+ description = "Appdome"
97
+ sample = "1c6496f1cc8c5799539ee24170c371e8a57547e2eb73c9502c98ff78f44c74cf"
98
+ url = "https://www.appdome.com/"
99
+ author = "Tim 'diff' Strazzere"
100
+
101
+ strings:
102
+ // Currently these are exported symbols and work across all abi's
103
+ $ad_start = "__start_adinit"
104
+ $ad_stop = "__stop_adinit"
105
+ $hook_start = "__start_hook"
106
+ $hook_stop = "__stop_hook"
107
+ $ipcent_start = "__start_ipcent"
108
+ $ipcent_stop = "__stop_ipcent"
109
+
110
+ condition:
111
+ is_elf and (
112
+ ($ad_start and $ad_stop) or
113
+ ($hook_start and $hook_stop) or
114
+ ($ipcent_start and $ipcent_stop)
115
+ )
116
+ }
117
+
118
+ rule appdome_elf_a : protector
119
+ {
120
+ meta:
121
+ description = "Appdome"
122
+ sample = "0143ddce30b16890180cfa71c49520bde4cce706762f4da756e8c4d06283a481"
123
+ url = "https://www.appdome.com/"
124
+ author = "Eduardo Novella"
125
+
126
+ condition:
127
+ is_elf and not appdome_elf and
128
+ // Match at least 2 section names from hook,.hookname,adinit,.adi,ipcent,ipcsel
129
+ for 2 i in (0..elf.number_of_sections):
130
+ (elf.sections[i].name matches /^(hook|\.hookname|adinit|\.adi|ipcent|ipcsel|\.rhash|\.imtab)$/)
131
+ }
132
+
133
+ rule metafortress : protector
134
+ {
135
+ meta:
136
+ description = "InsideSecure MetaFortress"
137
+ url = "https://www.insidesecure.com/Products/Application-Protection/Software-Protection/Code-Protection"
138
+ sample = "326632f52eba45609f825ab6746037f2f2b47bfe66fd1aeebd835c8031f4fdb0"
139
+ author = "Eduardo Novella"
140
+
141
+ strings:
142
+ $a = { 00 4d65 7461 466f 7274 7265 7373 3a20 2573 0025 733a 2025 730a 00 } // MetaFortress %s.%s: %s
143
+ $b = { 00 4d65 7461 466f 7274 7265 7373 00 } // MetaFortress
144
+ $c = { 00 4d45 5441 464f 5249 4300 0000 0000 0000 } // "METAFORIC"
145
+ $d = { 00 4a61 7661 5f63 6f6d 5f69 6e73 6964 6573 6563 7572 655f 6863 655f } // Java_com_insidesecure_hce_internal_MatrixHCENativeBridge_
146
+
147
+ condition:
148
+ is_elf and (($a and $b) or $c or $d)
149
+ }
150
+
151
+ rule virbox_elf : protector
152
+ {
153
+ meta:
154
+ description = "Virbox"
155
+ url = "https://shell.virbox.com"
156
+ sample = "dcbe15f9f9e44690e200c04a2aefd15107e5beeafb2eab6d07be85b9f0a42435"
157
+ author = "Eduardo Novella"
158
+
159
+ strings:
160
+ $brand = { 5669 7262 6f78 2050 726f 7465 6374 6f72 0000 } // Virbox Protector
161
+
162
+ condition:
163
+ is_elf and $brand
164
+ }
165
+
166
+ rule vkey_elf : protector
167
+ {
168
+ meta:
169
+ description = "Vkey (V-OS App Protection)"
170
+ url = "https://www.v-key.com/products/v-os-app-protection/"
171
+ author = "Eduardo Novella"
172
+ sample = "00b745b7c8314c395afa3b01aa24db6e7453c15f19175b7f987988c8b27faa15"
173
+
174
+ strings:
175
+ $libname = "libvosWrapperEx.so"
176
+ $detection1 = "***** FRIDA DETECTED *****"
177
+ $detection2 = "Error creating frida tcp file scan thread"
178
+ $detection3 = "GDB detected!"
179
+ $detection4 = "run_frida_port_scan: reseting map"
180
+ $detection5 = "Error creating emulator detection thread"
181
+ $detection6 = "start_debugger_check"
182
+ $detection7 = "startEmulatorCheck"
183
+ $detection8 = "app_integrity_check_jni: "
184
+ $vos1 = "V-OS.debug"
185
+ $vos2 = "********** V-Key %s: V-OS Firmware Version %d.%d.%d.%d *********"
186
+ $vos3 = "********** V-Key %s: V-OS Firmware (%s) Version %d.%d.%d.%d ****"
187
+ $vos4 = "********** V-Key Release SDK: V-OS Processor"
188
+ $jni1 = "Java_vkey_android_vos_VosWrapper_"
189
+ $jni2 = "Java_vkey_android_vos_VosWrapper_initVOSJNI"
190
+ $jni3 = "Java_vkey_android_vos_VosWrapper_getVADefaultPath"
191
+ $jni4 = "Java_vkey_android_vos_VosWrapper_registerCallback"
192
+ $jni5 = "Java_vkey_android_vos_VosWrapper_setVADefaultPath"
193
+
194
+ condition:
195
+ is_elf and $libname and 1 of ($vos*) and 1 of ($detection*) and 1 of ($jni*)
196
+ }
197
+
198
+ rule verimatrix_arm64 : protector
199
+ {
200
+ meta:
201
+ description = "InsideSecure Verimatrix"
202
+ url = "https://www.verimatrix.com/products/app-shield/"
203
+ sample = "88cb73fbc7371a7ef0ef0efc99c0fcaf129d5fc21bfca8bb5c318dff8f227fcc" // Package: com.bcp.bank.bcp v3.0.4
204
+ author = "Eduardo Novella"
205
+
206
+ strings:
207
+ // Potential crash via division by zero
208
+ // Sample contains ~500 break instructions (other sample ~80)
209
+ $brk_0_3e8 = {
210
+ 00 7D 20 D4 // BRK #0x3E8
211
+ }
212
+
213
+ // Inlined syscall with obfuscated _NR_SYSCALL
214
+ // Payment HCE app sample contains 2.6k inlined syscalls (other sample ~150)
215
+ $svc_0 = {
216
+ 01 00 00 D4 // SVC 0
217
+ }
218
+
219
+ condition:
220
+ elf.machine == elf.EM_AARCH64
221
+ and #svc_0 >= 50
222
+ and #brk_0_3e8 >= 50
223
+ and for any i in (0..elf.number_of_segments): (elf.segments[i].type == elf.PT_LOAD)
224
+ and for any i in (0..elf.number_of_segments): (elf.segments[i].type == elf.PT_NULL)
225
+ and not for any i in (0..elf.number_of_sections): (elf.sections[i].name == ".text")
226
+ }
227
+
228
+ rule verimatrix_arm64_a : protector
229
+ {
230
+ meta:
231
+ description = "InsideSecure Verimatrix"
232
+ url = "https://www.verimatrix.com/products/app-shield/"
233
+ sample = "edb939d77adba5ef5c536c352a4bc25a3a5ff2fe15408c5af9f08b5af583224c" // dk.mitid.app.android v2.3.7
234
+ author = "Eduardo Novella"
235
+
236
+ strings:
237
+ /**
238
+ .mfrt:0000000000AFCC98 ; Segment type: Pure data
239
+ .mfrt:0000000000AFCC98 AREA .mfrt, DATA
240
+ .mfrt:0000000000AFCC98 ; ORG 0xAFCC98
241
+ .mfrt:0000000000AFCC98 04 EC 82 5F+ DCQ 0x4BDB66335F82EC04
242
+ .mfrt:0000000000AFCCA0 FA 45 E6 0C DCD 0xCE645FA
243
+ .mfrt:0000000000AFCCA0 ; .mfrt ends
244
+ */
245
+
246
+ // Sample contains 25 inlined syscalls
247
+ $svc_0 = {
248
+ 01 00 00 D4 // SVC 0
249
+ }
250
+
251
+ /**
252
+ do
253
+ {
254
+ __asm { SYS #3, c7, c11, #1, X12 }
255
+ i += c;
256
+ }
257
+ while ( i < len );
258
+ }
259
+ v30 = (unsigned int)(4 << (StatusReg & 0xF));
260
+ v31 = v3 & -v30;
261
+ __dsb(0xBu);
262
+ for ( ; v31 < len; v31 += v30 )
263
+ __asm { SYS #3, c7, c5, #1, X10 }
264
+ __isb(0xFu);
265
+ ret = ((__int64 (__fastcall *)(_QWORD *))v3)(v33);
266
+ linux_eabi_syscall(__NR_munmap, (void *)v3, 0x4000u);
267
+ */
268
+ $asm_sys_dsb_isb = {
269
+ 2C 7B 0B D5 // SYS #3, c7, c11, #1, X12
270
+ [12-64]
271
+ 9F 3B 03 D5 // DSB ISH
272
+ [0-32]
273
+ 2A 75 0B D5 // SYS #3, c7, c5, #1, X10
274
+ [12-64]
275
+ DF 3F 03 D5 // ISB
276
+ }
277
+
278
+ // "libsdfgebg.so"
279
+ $libname = /lib[a-z]{6,14}\.so/
280
+
281
+ condition:
282
+ elf.machine == elf.EM_AARCH64
283
+ and $asm_sys_dsb_isb
284
+ and $libname
285
+ and #svc_0 >= 15
286
+ and for any i in (0..elf.number_of_segments): (elf.segments[i].type == elf.PT_LOAD)
287
+ and for any i in (0..elf.number_of_sections): (elf.sections[i].name matches /\.mfrt/)
288
+ }
289
+
290
+ rule verimatrix_arm64_b : protector
291
+ {
292
+ meta:
293
+ description = "InsideSecure Verimatrix"
294
+ url = "https://www.verimatrix.com/products/app-shield/"
295
+ sample = "e5acdf85e32675bed3cb8aa43fdfbc42117d7bee74f180db86db23e09895db9d" // dk.mitid.app.android
296
+ author = "Eduardo Novella"
297
+
298
+ strings:
299
+ /**
300
+ if ( v14 < v3 + 0x3FFF )
301
+ {
302
+ do
303
+ {
304
+ __asm { DC CVAU, X12 }
305
+ v14 += v12;
306
+ }
307
+ while ( v14 < (unsigned __int64)v13 );
308
+ }
309
+ __dsb(0xBu);
310
+ v19 = (unsigned int)(4 << (StatusReg & 0xF));
311
+ for ( j = v3 & -v19; j < (unsigned __int64)v13; j += v19 )
312
+ __asm { IC IVAU, X10 }
313
+ __dsb(0xBu);
314
+ __isb(0xFu);
315
+ v4 = ((__int64 (__fastcall *)(_QWORD *))v3)(v23);
316
+ v21 = linux_eabi_syscall(__NR_munmap, v5, 0x4000u);
317
+ */
318
+ $asm_dc_dsb_ic_isb = {
319
+ 2C 7B 0B D5 // DC CVAU, X12
320
+ [12-32]
321
+ 9F 3B 03 D5 // DSB ISH
322
+ [12-32]
323
+ 2A 75 0B D5 // IC IVAU, X10
324
+ [12-32]
325
+ DF 3F 03 D5 // ISB
326
+ }
327
+
328
+ /**
329
+ v3 = (unsigned __int64)linux_eabi_syscall(__NR_mmap, 0, 0x4000u, 7, 34, -1, 0);
330
+ */
331
+ $svc_mmap = {
332
+ ?? 03 1F AA // MOV X11, XZR
333
+ ?? 1B 80 52 // MOV W12, #0xDE
334
+ ?? 00 88 52 // MOV W13, #0x4000
335
+ ?? 00 80 52 // MOV W14, #7
336
+ ?? 04 80 52 // MOV W15, #0x22
337
+ [4-32]
338
+ 01 00 00 D4 // SVC 0
339
+ }
340
+ /**
341
+ linux_eabi_syscall(__NR_munmap, v5, 0x4000u);
342
+ */
343
+ $svc_munmap = {
344
+ ?? 1A 80 52 // MOV W11, #0xD7
345
+ ?? 00 88 52 // MOV W12, #0x4000
346
+ [4-32]
347
+ 01 00 00 D4 // SVC 0
348
+ }
349
+
350
+ $s_jnionload = { 004a 4e49 5f4f 6e4c 6f61 6400 } // JNI_OnLoad
351
+
352
+ condition:
353
+ elf.machine == elf.EM_AARCH64 and all of them
354
+ and for any i in (0..elf.number_of_segments): (elf.segments[i].type == elf.PT_LOAD)
355
+ }
356
+
357
+ rule verimatrix_arm64_c : protector
358
+ {
359
+ meta:
360
+ description = "InsideSecure Verimatrix"
361
+ url = "https://www.verimatrix.com/products/app-shield/"
362
+ sample = "41aab8bad66ab3ee47d8133488084e87abd271e2865d5715fb36269d967a2571"
363
+ author = "FrenchYeti"
364
+
365
+ strings:
366
+ // byte sequence from .rodata, used into JNI_OnLoad
367
+ /**
368
+ void sub_AD1468()
369
+ {
370
+ _QWORD v0[2]; // [xsp+40h] [xbp-A1480h] BYREF
371
+ int v1; // [xsp+50h] [xbp-A1470h]
372
+ int v2; // [xsp+54h] [xbp-A146Ch]
373
+ _QWORD v3[2]; // [xsp+60h] [xbp-A1460h] BYREF
374
+ __int64 v4; // [xsp+70h] [xbp-A1450h]
375
+ _QWORD v5[2]; // [xsp+80h] [xbp-A1440h] BYREF
376
+ int v6; // [xsp+90h] [xbp-A1430h]
377
+ int v7; // [xsp+94h] [xbp-A142Ch]
378
+ char v8[660496]; // [xsp+A8h] [xbp-A1418h] BYREF
379
+ __int64 v9; // [xsp+A14B8h] [xbp-8h]
380
+
381
+ v9 = *(_QWORD *)(_ReadStatusReg(ARM64_SYSREG(3, 3, 13, 0, 2)) + 40);
382
+ v5[1] = v5;
383
+ v7 = 0xB8A89888;
384
+ v5[0] = v5;
385
+ v4 = 0xB8A89888BCAC9C8BLL;
386
+ v3[0] = v3;
387
+ v3[1] = v3;
388
+ v0[0] = v3;
389
+ v0[1] = v0;
390
+ v2 = 0xB8A89888;
391
+ v6 = 1;
392
+ v1 = 0;
393
+ sub_ADCB58(v8, 0LL, 0xA1410LL);
394
+ LODWORD(v4) = 1;
395
+ JUMPOUT(0xAD1524LL);
396
+ }
397
+ */
398
+ $rodata_pattern = {
399
+ ?? ?? ?? ?? 88 98 a8 b8
400
+ ?? ?? ?? ?? 94 a4 b4 c4
401
+ ?? ?? ?? ?? 88 98 a8 b8
402
+ ?? ?? ?? ?? 94 a4 b4 c4
403
+ }
404
+
405
+ // common pattern
406
+ $opcodes = {
407
+ ?3 ?? ?? 54 // b.cc ??
408
+ 29 0d ?0 12 // and w9, w9, #0xf
409
+ 49 21 c9 1a // lsl w9, w10, w9
410
+ ea 03 09 cb // neg x10, x9
411
+ ?a 0? ?? 8a // and x10, ??, ??
412
+ 5f 01 ?? eb // cmp x10, ??
413
+ 9f 3b 03 d5 // dsb ISH
414
+ ?2 ?? ?? 54 // b.cs ??
415
+ 2a 75 0b d5 // ic x10
416
+ 4a 01 09 8b // add x10, x10, x9
417
+ 5f 01 ?? eb // cmp x10, ??
418
+ ?3 ?? ?? 54 // b.cc ??
419
+ [0-4]
420
+ df 3f 03 d5 // isb
421
+ }
422
+
423
+ condition:
424
+ elf.machine == elf.EM_AARCH64
425
+ and all of them
426
+ and not verimatrix_arm64_a
427
+ }
428
+
429
+ rule protectt : protector
430
+ {
431
+ meta:
432
+ description = "Protectt"
433
+ sample = "c246d85560599f91e9c3ed7e59df2dd4e21aaf667f3f2965c28c43d9842f5e75" // com.rblbank.mobank
434
+ url = "https://www.protectt.ai"
435
+ author = "Eduardo Novella"
436
+
437
+ strings:
438
+ $lib1 = "libprotectt-native-lib.so"
439
+ $lib2 = "libprotecttai.so"
440
+ $lib3 = "libapp-protectt-native-lib.so"
441
+
442
+ condition:
443
+ is_elf and 1 of them
444
+ }
445
+
446
+ rule googleIntegrityProtection : protector
447
+ {
448
+ meta:
449
+ description = "Google Play Integrity"
450
+ url = "https://developer.android.com/games/playgames/integrity"
451
+ sample = "607e256868c012dda10aaff07fdd24928d86122c715078406fb21aae7a2b8a44"
452
+ author = "Eduardo Novella"
453
+
454
+ strings:
455
+ $export_jnionload = { 004a 4e49 5f4f 6e4c 6f61 6400 } // JNI_OnLoad
456
+ $export_jnionunload = { 004a 4e49 5f4f 6e55 6e6c 6f61 6400 } // JNI_OnUnLoad
457
+ $export_ExecuteProgram = { 00 4578 6563 7574 6550 726f 6772 616d 00 } // ExecuteProgram
458
+ $lib_name = { 00 6c69 6270 6169 7269 7063 6f72 652e 736f 00} // libpairipcore.so
459
+
460
+ condition:
461
+ is_elf and all of them
462
+ }
463
+
464
+ rule ahope_appshield : protector
465
+ {
466
+ meta:
467
+ description = "Ahope AppShield"
468
+ url = "http://www.ahope.net/sub/app-shields"
469
+ sample = "42a4d907caf625ff73d5b6fbbf32b59ba14d6d5a72f28b81bdc76c47db516122"
470
+ author = "dustty0 & Eduardo Novella"
471
+
472
+ strings:
473
+ $lib = {
474
+ 00 6c69 6261 686f 7065 [0-2] 2e73 6f00 // .libahope.so.
475
+ }
476
+
477
+ condition:
478
+ is_elf and any of them
479
+ }
480
+
481
+
482
+ rule appcamo : protector
483
+ {
484
+ meta:
485
+ description = "AppCamo"
486
+ url = "http://appcamo.com/s2/s2_1.php"
487
+ sample = "b8bf8e44eff2f4557f050d19534624dc3df5053f7793eb409b98c18c475d969b"
488
+ author = "dustty0 & Eduardo Novella"
489
+
490
+ strings:
491
+ $log = { 00 6170 7063 616d 6f 00} // .appcamo.
492
+ $lib = { 00 6c69 6261 6c69 622e 736f 00} // .libalib.so.
493
+ $lod = { 00 6461 6c76 696b 2f73 7973 7465 6d2f 4465 7843 6c61 7373 4c6f 6164 6572 00} // dalvik/system/DexClassLoader
494
+
495
+ condition:
496
+ is_elf and 2 of them
497
+ }
498
+
499
+ rule appsealing : protector
500
+ {
501
+ meta:
502
+ description = "Appsealing"
503
+ url = "https://www.appsealing.com/"
504
+ sample = "803b7b1e25fa879438ebb31e7f8bbcc7292ecda9750bdd0266e589fe4469bc10" // com.drishti.academy.app
505
+ author = "Eduardo Novella"
506
+
507
+ strings:
508
+ // .libcovault-appsec.so.
509
+ $str1 = { 00 6c69 6263 6f76 6175 6c74 2d61 7070 7365 632e 736f 00 }
510
+ // .%s/appsealing.dex.
511
+ $str2 = { 00 2573 2f61 7070 7365 616c 696e 672e 6465 7800 }
512
+ // .APPSEALING-CORE-VERSION_
513
+ $str3 = { 00 4150 5053 4541 4c49 4e47 2d43 4f52 452d 5645 5253 494f 4e5f }
514
+ $str4 = { 00 284c 616e 6472 6f69 642f 636f // .(Landroid/co
515
+ 6e74 656e 742f 436f 6e74 6578 743b 4c63 // ntent/Context;Lc
516
+ 6f6d 2f69 6e6b 612f 6170 7073 6561 6c69 // om/inka/appseali
517
+ 6e67 2f41 7070 5365 616c 696e 6741 7070 // ng/AppSealingApp
518
+ 6c69 6361 7469 6f6e 3b4c 6a61 7661 2f6c // lication;Ljava/l
519
+ 616e 672f 436c 6173 734c 6f61 6465 723b // ang/ClassLoader;
520
+ 4c61 6e64 726f 6964 2f63 6f6e 7465 6e74 // Landroid/content
521
+ 2f72 6573 2f41 7373 6574 4d61 6e61 6765 // /res/AssetManage
522
+ 723b 4c6a 6176 612f 6c61 6e67 2f53 7472 // r;Ljava/lang/Str
523
+ 696e 673b 4c6a 6176 612f 6c61 6e67 2f53 // ing;Ljava/lang/S
524
+ 7472 696e 673b 4c6a 6176 612f 6c61 6e67 // tring;Ljava/lang
525
+ 2f53 7472 696e 673b 294c 6a61 7661 2f6c // /String;)Ljava/l
526
+ 616e 672f 5374 7269 6e67 3b00 // ang/String;.
527
+ }
528
+ $str5 = { 00 636f 6d2f 696e 6b61 2f61 7070 // ....com/inka/app
529
+ 7365 616c 696e 672f 4170 7053 6561 6c69 // sealing/AppSeali
530
+ 6e67 4170 706c 6963 6174 696f 6e00 // ngApplication...
531
+ }
532
+ $str6 = { 49 6e69 7469 6174 6520 // .......Initiate
533
+ 4170 7053 6561 6c69 6e67 2053 6563 7572 // AppSealing Secur
534
+ 6974 7920 3a20 4152 4d36 3420 2843 6f72 // ity : ARM64 (Cor
535
+ 6520 5665 7273 696f 6e20 3d20 2573 2900 // e Version = %s).
536
+ }
537
+
538
+ condition:
539
+ is_elf and 2 of them
540
+ }
541
+
542
+ rule zimperium_zdefend : protector
543
+ {
544
+ meta:
545
+ description = "Zimperium (zDefend)"
546
+ url = "https://www.zimperium.com/zdefend/"
547
+ sample = "9512c46d99cdca1914a9f86870aa1c49845701abe1c63365ba2681d658c19941" // com.dbs.dbspaylah.apk v6.2.0
548
+ author = "Eduardo Novella"
549
+
550
+ strings:
551
+ $lib = { 00 6c69 625a 4465 6665 6e64 2e73 6f00 } // .libZDefend.so.
552
+ $zimperium = "zimperium"
553
+
554
+ condition:
555
+ is_elf and $lib and #zimperium > 10
556
+ }
557
+
558
+ rule zimperium_z9 : protector
559
+ {
560
+ meta:
561
+ description = "Zimperium (z9)"
562
+ url = "https://www.zimperium.com/machine-learning-z9-technology"
563
+ sample = "ed2f6935a4420034ec8dade23ec458ef1440c5021402c142e0b020308e0145fc" // com.chase.sig.android v4.484
564
+ author = "Eduardo Novella"
565
+
566
+ strings:
567
+ $lib = { 00 6c69 627a 392e73 6f00 } // .libz9.so.
568
+ $zimperium = "zimperium"
569
+
570
+ condition:
571
+ is_elf and $lib and #zimperium > 10
572
+ }
573
+
574
+ rule zimperium_zcloud : protector
575
+ {
576
+ meta:
577
+ description = "Zimperium (zcloud)"
578
+ url = "https://www.zimperium.com/zdefend"
579
+ sample = "ed2f6935a4420034ec8dade23ec458ef1440c5021402c142e0b020308e0145fc" // com.chase.sig.android v4.484
580
+ author = "Eduardo Novella"
581
+
582
+ strings:
583
+ $lib = { 006c 6962 7a63 6c6f 7564 2e73 6f00 } // .libzcloud.so.
584
+ $zimperium = "zimperium"
585
+
586
+ condition:
587
+ is_elf and $lib and #zimperium > 10
588
+ }
589
+
590
+ rule msa_sdk : protector
591
+ {
592
+ meta:
593
+ description = "MSA SDK"
594
+ url = "http://msa-alliance.cn"
595
+ sample = "fe4afda0c51fa08237859c3b14c2b35bd2c2a65d098a57857454f0ace354ad45" // tv.danmaku.bili
596
+ author = "Abhi"
597
+
598
+ strings:
599
+ $string = "mprotect"
600
+ $libs = { 00 6C 69 62 6D 73 61 6F 61 69 64 (61 75 74 68 | 73 65 63 ) 2E 73 6F 00 } // .libmsaoaidauth.so. || .libmsaoaidsec.so.
601
+
602
+ condition:
603
+ is_elf and all of them
604
+ }
605
+
606
+ rule nhn_appguard : protector
607
+ {
608
+ meta:
609
+ description = "NHN AppGuard"
610
+ url = "https://www.nhncloud.com/kr/service/security/nhn-appguard"
611
+ sample = "bafa2a9acf4af696b92e0a1ddcf7f470d49a7f3bc27b5c1b1e3ecbdf17049285" // jp.pjfb
612
+ author = "Abhi"
613
+
614
+ strings:
615
+ $payload = { (00 ?? | ??) 61 70 70 67 75 61 72 64 5F 68 65 61 64 65
616
+ 72 2D 3E 47 65 74 (45 6E 63 72 79 70 74 65 64 | 4F 72
617
+ 69 67 69 6E 61 6C) 50 61 79 6C 6F 61 64 4C 65 6E 67 74
618
+ 68 28 29 } // appguard_header->Get(Encrypted|Original)PayloadLength()
619
+ $class = /\d{2}ComNhnentAppguardAppguardJavaClass(Impl)?\x00/
620
+ $class2 = /\d{2}AppGuardCallbackJavaClass(Impl)?\x00/
621
+ $str_app = { 00 28 28 61 70 70 67 75 61 72 64 5F 61 70 70 6C 69 63 61 74
622
+ 69 6F 6E 5F 29 29 20 (3D | 21) 3D 20 28 6E 75 6C 6C 70 74 72 29 } // .((appguard_application_)) (=|!)= (nullptr)
623
+ $lib = { 00 6C 69 62 6C 6F 61 64 65 72 2E 73 6F 00 } // .libloader.so.
624
+
625
+ condition:
626
+ is_elf and any of ($class*) and ( $lib or $str_app or $payload )
627
+ }
628
+
629
+ rule easyprotector : protector
630
+ {
631
+ meta:
632
+ description = "EasyProtector"
633
+ url = "https://github.com/lamster2018/EasyProtector"
634
+ sample = "788ebabd9b5464c5e86b3832e4a7b6e7c91cce5603ff17f214429400ba3bb2b9" // net.crigh.cgsport
635
+ author = "Abhi"
636
+
637
+ strings:
638
+ $lib = "\x00libantitrace.so\x00"
639
+ $log = "\x00I was be traced...trace pid:%d\x00"
640
+ $log2 = "\x00ptrace myself...\x00"
641
+
642
+ condition:
643
+ is_elf and all of them
644
+ }
645
+
646
+ rule rootbeer: anti_root
647
+ {
648
+ meta:
649
+ description = "RootBeer"
650
+ url = "https://github.com/scottyab/rootbeer.git"
651
+ sample = "607ec962ba93cc9817129cb693ff0f335f500a297b5a297e71fbb998d0f6849c" // com.scottyab.rootbeer.sample
652
+ author = "Abhi"
653
+
654
+ strings:
655
+ $class = { 00 4A 61 76 61 5F 63 6F 6D 5F [-] 5F 72 6F 6F 74 62 65 65 72
656
+ 5F 52 6F 6F 74 42 65 65 72 4E 61 74 69 76 65 5F 63 68 65 63
657
+ 6B 46 6F 72 52 6F 6F 74 00 } // Java_com_scottyab_rootbeer_RootBeerNative_checkForRoot
658
+ $lib = { 00 6C 69 62 74 6F 6F 6C 43 68 65 63 6B 65 72 2E 73 6F 00 } // libtoolChecker.so
659
+ $name = { 00 52 6F 6F 74 42 65 65 72 00 } // RootBeer
660
+
661
+ condition:
662
+ is_elf and 2 of them
663
+ }
664
+
665
+ rule build38 : protector
666
+ {
667
+ meta:
668
+ description = "Build38"
669
+ url = "https://build38.com"
670
+ sample = "cfbbfca598a9877a381583a7ae2f9e8cde92e7314b21152658bcba5a4e3a0fff" // com.esignus.hashwalletmanager
671
+ author = "Abhi"
672
+
673
+ strings:
674
+ $lib = { 00 6C 69 62 74 61 6B 2E 73 6F 00 } // libtak.so
675
+ $class = { 4C 63 6F 6D 2F 62 75 69 6C 64 33 38 2F 74 61 6B 2F 4E 61 74 69 76 65 52 65 73 70 6F 6E 73 65 3B 00 } // Lcom/build38/tak/NativeResponse;
676
+
677
+ condition:
678
+ is_elf and any of them
679
+ }
680
+
681
+ rule dpt_shell : protector
682
+ {
683
+ meta:
684
+ description = "DPT Shell"
685
+ url = "https://github.com/luoyesiqiu/dpt-shell"
686
+ sample = "0c4341700f4e685cafc9c86c9112098b75057580ba1f7163bc971347af3712ad"
687
+ author = "Abhi"
688
+
689
+ strings:
690
+ $libname = "\x00libdpt.so\x00"
691
+ $bhook = "\x00bytehook_tag\x00"
692
+
693
+ condition:
694
+ is_elf and
695
+ any of them and
696
+ for any i in (0 .. elf.number_of_sections): (
697
+ elf.sections[i].name == ".bitcode"
698
+ )
699
+ }
700
+
701
+ rule free_rasp_dart : protector
702
+ {
703
+ meta:
704
+ description = "FreeRASP"
705
+ url = "https://www.talsec.app/freerasp-in-app-protection-security-talsec"
706
+ sample = "b1f8b110ef85e6a90b000ec625be2a51e6bf7fa8d17859f158f06bfe0078beb4" // net.corepass.app
707
+ author = "Eduardo Novella"
708
+
709
+ strings:
710
+ $s1 = "\x00package:freerasp/src/errors/talsec_exception.dart\x00"
711
+ $s2 = "\x00package:freerasp/src/models/talsec_config.dart\x00"
712
+ $s3 = "\x00package:freerasp/src/talsec.dart\x00"
713
+ $s4 = "\x00talsec-failure\x00"
714
+ $s5 = "\x00TalsecException\x00"
715
+ $s6 = "\x00TalsecController\x00"
716
+
717
+ condition:
718
+ is_dart and any of them
719
+ }
720
+
721
+ rule shield_sdk : protector
722
+ {
723
+ meta:
724
+ description = "Shield SDK"
725
+ url = "https://shield.com/"
726
+ sample = "fb4b7f033658b3898e0448955491b448a2c78e1a2325c65fece6ad64f6f6b6d0" // com.mpl.androidapp
727
+ author = "Abhi"
728
+
729
+ strings:
730
+ $lib = { 00 6C 69 62 63 61 73 68 73 68 69 65 6C 64 61 62
731
+ 63 2D 6E 61 74 69 76 65 2D 6C 69 62 2E 73 6F 00 } // libcashshieldabc-native-lib.so
732
+ $class = { 00 63 6F 6D 2F 73 68 69 65 6C 64 2F 61 6E 64 72
733
+ 6F 69 64 2F 69 6E 74 65 72 6E 61 6C 2F 4E 61 74
734
+ 69 76 65 55 74 69 6C 73 00 } // com/shield/android/internal/NativeUtils
735
+
736
+ condition:
737
+ is_elf and all of them
738
+ }
739
+
740
+ rule bugsmirror : protector
741
+ {
742
+ meta:
743
+ description = "BugsMirror"
744
+ url = "https://www.bugsmirror.com/"
745
+ sample = "c9bbf66ac86bf02663b7bc28a735881d4aeaa8d90e9b8b752e9cf337a26f0bdd"
746
+ author = "Abhi"
747
+
748
+ strings:
749
+ // libdefender.so as dependency of libsettings.so doesn't starts with null-byte
750
+ $name = { 6C 69 62 64 65 66 65 6E 64 65 72 2E 73 6F 00 } // libdefender.so
751
+
752
+ condition:
753
+ is_elf and
754
+ all of them and
755
+ for any i in (0 .. elf.number_of_sections): (
756
+ elf.sections[i].name == ".crypted"
757
+ )
758
+ }
759
+
760
+ rule bshield : protector
761
+ {
762
+ meta:
763
+ description = "BShield"
764
+ url = "https://bshield.io/"
765
+ sample = "f54fa5cfcd9a5d14a947bbd93bc7bb59e8c2b1b23cc5bcc84c66ad0143e55201"
766
+ author = "Abhi"
767
+
768
+ strings:
769
+ $class = { 00 4C 69 6F 2F 62 73 68 69 65 6C 64 2F 63 61 6C
770
+ 6C 62 61 63 6B 2F 53 68 69 65 6C 64 44 61 74 61
771
+ 50 72 6F 74 65 63 74 69 6F 6E 3B 00 } // Lio/bshield/callback/ShieldDataProtection;
772
+ $class2 = { 00 69 6F 2F 62 73 68 69 65 6C 64 2F 63 61 6C 6C
773
+ 62 61 63 6B 2F 53 68 69 65 6C 64 44 61 74 61 50
774
+ 72 6F 74 65 63 74 69 6F 6E 00 } // io/bshield/callback/ShieldDataProtection
775
+
776
+ condition:
777
+ is_elf and any of them
778
+ }
779
+
780
+ rule denuvo_elf : protector
781
+ {
782
+ meta:
783
+ description = "Denuvo"
784
+ url = "https://irdeto.com/denuvo/anti-tamper"
785
+ sample = "f7d1cd97b5d61da16b804daf6cd1199fe822745f9066596988d30a934441f6fc"
786
+ author = "Abhi"
787
+
788
+
789
+ strings:
790
+ $libvmpc = "\x00libvmpc.so\x00"
791
+
792
+ condition:
793
+ is_elf and all of them
794
+ }