Skip to content

Lesson 10 of 13 · 12m

Reading the Binary

apktool and jadx turn a release APK into a searchable codebase, smali grep finds the dangerous calls, and a FairPlay-encrypted Mach-O needs a jailbroken dump before Ghidra can read it.

jadx first, always

apktool d app.apk gives you the decoded manifest, resources, and a smali tree. jadx — or jadx-gui — decompiles all classes*.dex into Java-ish source you can search like a codebase. Release apps are obfuscated by R8: classes named a.b.c, dead code stripped. That changes names, never structure. The permission requests still list in the manifest; invoke-static calls still show the API being touched; string constants survive intact. You don't need the source. You need to read.

Smali rewards ten minutes of syntax. .class public Lcom/x/Y; is a class; .method blocks contain instructions over registers v0, v1, p0; invoke-virtual {v0, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V is a call; move-result-object v2 captures the return. Grep the tree for the calls that matter:

rg 'Runtime;->exec|Cipher;->getInstance|addJavascriptInterface|loadUrl|setAllowFileAccess|MODE_WORLD' smali/

That one line is 80% of an insecure-storage/WebView/exec audit.

The toolchain in order

  • aapt dump badging app.apk — package, min/target SDK, permissions, launcher activity.
  • apksigner verify --print-certs — which signature schemes verified and the cert fingerprints.
  • apktool d — manifest, resources, smali.
  • jadx -d out/ app.apk — the Java view; --deobf rewrites single-letter names to stable readable ones.
  • baksmali/smali — disassemble/assemble DEX round-trips when you need to patch a debug build.
  • MobSF — upload the APK; it automates the manifest/permission/string pass and flags the common patterns so you can spend your time on the interesting 20%.

Native libraries — lib/arm64-v8a/*.so — go to Ghidra (free, from the NSA's 2019 release) or IDA/radare2. JNI entry points are named Java_com_x_Y_nativeMethod, which makes them trivially grepable; the interesting crypto and anti-tamper almost always lives there rather than in DEX. React Native apps ship Hermes bytecode in a .hbc bundle (hbcdump reads it); Flutter ships Dart AOT snapshots inside libapp.so, which defeat standard tooling and need reFlutter-class approaches or runtime hooks.

App Bundle targets add one wrinkle: Play ships split APKs, so bundletool build-apks (or adb pull of every base-master/config.arm64_v8a/config.xx split) is required to reconstruct the full artifact — a lone base-master.apk has no resources and confuses jadx.

Two static findings to put on every report: android:debuggable="true" in the manifest — the build flag that turns run-as <pkg> into instant data extraction — and the signing scheme set from apksigner verify. Both are one-line reads that decide whether the rest of the audit is easy or trivial.

The iOS branch

Start at the Mach-O. otool -l (macOS) lists load commands — LC_ENCRYPTION_INFO with cryptid 1 means the binary is FairPlay-encrypted and you'll get nothing until you dump it decrypted on a jailbroken device via frida-ios-dump or Bagbak. otool -L lists linked frameworks; lipo -info shows slices. class-dump extracts Objective-C headers — class names, methods, properties — from __objc_classname/__objc_methname. Swift symbols arrive mangled (_$s...); swift demangle translates them, and Ghidra 10+ handles Mach-O plus Swift's __swift5_* metadata sections. Hopper is the lighter interactive alternative. strings over __cstring still finds the embedded URLs and key strings nobody removed.

The wrong model

"Reverse engineering requires the source" — no; it requires the artifact and patience. The other half of the wrong model: "obfuscation made it safe." R8 is a minifier. Reading an obfuscated app is slower, not prevented — the manifest can't be obfuscated because the OS has to parse it, and neither can the calls into framework APIs, because the framework has to find them.

Practice

Read the manifest before the code — it declares the surface. Grep for the dangerous-call list before reading business logic. Keep the app's R8 mapping.txt nearby if you're the developer auditing your own build; retrace turns obfuscated stack traces back into source line numbers. Verify what the shipped artifact contains, because the artifact — not your git tree — is what the attacker downloads.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.