Firmware-level Android Backdoor via libandroid_runtime Zygote Injection

Tip

Apprenez et pratiquez le hacking AWS :HackTricks Training AWS Red Team Expert (ARTE)
Apprenez et pratiquez le hacking GCP : HackTricks Training GCP Red Team Expert (GRTE) Apprenez et pratiquez le hacking Azure : HackTricks Training Azure Red Team Expert (AzRTE)

Soutenir HackTricks

Aperçu

Une manipulation de la chaîne d’approvisionnement de /system/lib[64]/libandroid_runtime.so peut détourner android.util.Log.println_native de sorte que chaque app forkée depuis Zygote exécute du code attaquant. Le backdoor Keenadu ajoute un seul appel à l’intérieur de println_native qui déclenche un native dropper. Parce que tous les processus d’applications exécutent ce code, les limites du sandbox Android et les permissions par application sont effectivement contournées.

Dropper path: native patch → RC4 → DexClassLoader

  • Hooked entry: appel supplémentaire à l’intérieur de println_native vers __log_check_tag_count (injected static lib libVndxUtils.a).
  • Payload storage: blob chiffré RC4 intégré dans le .so, déposé dans /data/dalvik-cache/arm[64]/system@framework@vndx_10x.jar@classes.jar.
  • Load & execute: DexClassLoader charge le jar et invoque com.ak.test.Main.main. Les logs runtime utilisent le tag AK_CPP (artifact de triage).
  • Anti-analysis: aborts dans les system apps Google/Sprint/T-Mobile ou si des fichiers kill-switch existent.
  • Zygote role split:
  • In system_server → instantiate AKServer.
  • In any other app → instantiate AKClient.

Backdoor client/serveur basé sur Binder

  • AKServer (running in system_server) envoie des broadcasts protégés :
  • com.action.SystemOptimizeService → binder interface for clients.
  • com.action.SystemProtectService → binder interface for downloaded modules.
  • AKClient (inside every app) reçoit l’interface via broadcast et effectue une transaction attach, fournissant un wrapper IPC afin que le serveur puisse charger un DEX arbitraire inside the current app process.
  • Opérations privilégiées exposées (via SystemProtectService) : accorder/révoquer n’importe quelle permission pour n’importe quel package, récupérer la géolocalisation, et exfiltrer les infos de l’appareil. Cela centralise le contournement de privilèges tout en exécutant du code dans des apps cibles choisies (Chrome, YouTube, launcher, shopping apps, etc.).

C2 staging, crypto, and gating

  • Host discovery: Base64 → gzip → AES-128-CFB decrypt with key MD5("ota.host.ba60d29da7fd4794b5c5f732916f7d5c"), IV "0102030405060708".
  • Victim registration: collect IMEI/MAC/model/OS, encrypt with key MD5("ota.api.bbf6e0a947a5f41d7f5226affcfd858c"), POST to /ak/api/pts/v4 with params m=MD5(IMEI) and n=w|m (network type). Response data is encrypted identically.
  • Activation delay: C2 serves modules only after ~2.5 months from an “activation time” in the request, frustrating sandbox detonations.
  • Module container (proprietary):
struct KeenaduPayload {
int32_t  version;
uint8_t  padding[0x100];
uint8_t  salt[0x20];
KeenaduChunk config;   // size + data
KeenaduChunk payload;  // size + data
KeenaduChunk signature;// size + data
} __packed;
  • Intégrité : MD5 file check + DSA signature (seul l’opérateur disposant de la clé privée peut émettre des modules).
  • Déchiffrement : AES-128-CFB, key MD5("37d9a33df833c0d6f11f1b8079aaa2dc" + salt), IV "0102030405060708".

Persistance et conseils forensiques

  • Supply chain placement: malicious static lib libVndxUtils.a linked into libandroid_runtime.so during build (e.g., vendor/mediatek/proprietary/external/libutils/arm[64]/libVndxUtils.a).
  • Audit du firmware : firmware images ship as Android Sparse super.img; use lpunpack (or similar) to extract partitions and inspect libandroid_runtime.so for extra calls in println_native.
  • Artefacts sur l’appareil : la présence de /data/dalvik-cache/arm*/system@framework@vndx_10x.jar@classes.jar, logcat tag AK_CPP, ou de broadcasts protégés nommés com.action.SystemOptimizeService/com.action.SystemProtectService indique une compromission.

Références

Tip

Apprenez et pratiquez le hacking AWS :HackTricks Training AWS Red Team Expert (ARTE)
Apprenez et pratiquez le hacking GCP : HackTricks Training GCP Red Team Expert (GRTE) Apprenez et pratiquez le hacking Azure : HackTricks Training Azure Red Team Expert (AzRTE)

Soutenir HackTricks