Skip to content

Commit 3e93707

Browse files
authored
Merge pull request #1868 from HackTricks-wiki/update_clsdumper___Android_Dynamic_Class_Dumper__dump_all_20260206_185400
clsdumper — Android Dynamic Class Dumper (dump all DEX files...
2 parents 0fd529e + b0ab783 commit 3e93707

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

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

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ If the APK is debuggable (android:debuggable="true"), you can attach over JDWP a
114114
- Repo: https://github.com/frankheat/frida-jdwp-loader
115115
- Requirements: ADB, Python 3, USB/Wireless debugging. App must be debuggable (emulator with `ro.debuggable=1`, rooted device with `resetprop`, or rebuild manifest).
116116

117-
Quick start
117+
Quick start:
118118
```bash
119119
git clone https://github.com/frankheat/frida-jdwp-loader.git
120120
cd frida-jdwp-loader
@@ -285,6 +285,49 @@ Java.perform(function () {
285285

286286
Run the script with `frida -U -f <package> -l disable-flag-secure.js --no-pause`, interact with the UI, and screenshots/recordings will work again. Because everything happens on the UI thread there is no flicker, and you can still combine the hook with HTTP Toolkit/Burp to capture the traffic that revealed the `/channel` PIN leak.
287287

288+
## Dynamic DEX dumping / unpacking with clsdumper (Frida)
289+
290+
`clsdumper` is a Frida-based dynamic **DEX/class dumper** that survives hardened apps by combining an anti-Frida pre-stage with native and Java discovery strategies (works even if `Java.perform()` dies). Requirements: Python 3.10+, rooted device with `frida-server` running, USB or `--host` TCP connection.
291+
292+
**Install & quick use**
293+
```bash
294+
pip install clsdumper
295+
# Attach to a running app
296+
clsdumper com.example.app
297+
# Spawn first (hooks before early loaders)
298+
clsdumper com.example.app --spawn
299+
# Select strategies
300+
clsdumper com.example.app --strategies fart_dump,oat_extract
301+
```
302+
303+
**CLI options (most useful)**
304+
- `target`: package name or PID.
305+
- `--spawn`: spawn instead of attach.
306+
- `--host <ip>`: connect to remote frida-server.
307+
- `--strategies <comma>`: limit/choose extractors; default is all except `mmap_hook` (expensive).
308+
- `--no-scan` / `--deep-scan`: disable or slow deep memory scan (adds CDEX scanning).
309+
- `--extract-classes`: post-process dumps into `.smali` via androguard.
310+
- `--no-anti-frida`: skip the pre-hook bypass stage.
311+
- `--list` / `--list-apps`: enumerate running processes or installed packages.
312+
313+
**Anti-instrumentation bypass (phase 0)**
314+
- Hooks `sigaction`/`signal` to block registration of crash/anti-debug handlers.
315+
- Serves a filtered `/proc/self/maps` via `memfd_create` to hide Frida regions.
316+
- Monitors `pthread_create` to catch/neutralize watchdog threads hunting Frida.
317+
318+
**DEX discovery (phases 1–2)** — multiple complementary strategies with per-hit metadata + deduplication (agent-side djb2, host-side SHA-256):
319+
- Native (no Java bridge needed): `art_walk` (walk ART Runtime→ClassLinker→DexFile), `open_common_hook` (hook `DexFile::OpenCommon`), `memory_scan` (DEX magic in readable maps), `oat_extract` (parse mapped .vdex/.oat), `fart_dump` (hook `DefineClass` + walk `class_table_`), `dexfile_constructor` (hook `OatDexFile` constructors), `mmap_hook` (watch `mmap/mmap64`, off by default for perf).
320+
- Java (when available): `cookie` (read `mCookie` from ClassLoaders), `classloader_hook` (monitor `loadClass`, `DexClassLoader`, `InMemoryDexClassLoader`).
321+
322+
**Output layout**
323+
```
324+
dump_<target>/
325+
dex/classes_001.dex ...
326+
classes/ # only when --extract-classes
327+
metadata.json # strategy per hit + hashes
328+
```
329+
330+
Tip: protected apps often load code from several sources (in-memory payload, vdex/oat, custom loaders). Running with the default multi-strategy set plus `--spawn` maximizes coverage; enable `--deep-scan` only when needed to avoid performance hits.
288331

289332
## Tutorials
290333

@@ -479,5 +522,6 @@ Java.choose("com.example.a11x256.frida_test.my_activity", {
479522
- ["Super secure" MAGA-themed messaging app leaks everyone’s phone number](https://ericdaigle.ca/posts/super-secure-maga-messaging-app-leaks-everyones-phone-number/)
480523
- [Android Frida Hooking: Disabling FLAG_SECURE](https://www.securify.nl/en/blog/android-frida-hooking-disabling-flagsecure/)
481524
- [frida-ui](https://github.com/adityatelange/frida-ui)
525+
- [clsdumper — Android Dynamic Class Dumper](https://github.com/TheQmaks/clsdumper)
482526

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

0 commit comments

Comments
 (0)