πŸ“± Mobile Application Security β€” Deep Dive: Android Pentesting, iOS Security, OWASP MASVS, Reverse Engineering APK/IPA

Panduan komprehensif keamanan aplikasi mobile β€” dari Android (APK reversing, Smali patching, Frida hooking, Drozer, ADB forensics) sampai iOS (IPA decryption, class-dump, Frida/objection, Keychain, iOS app sandbox). Mencakup OWASP Mobile Application Security Verification Standard (MASVS) Level 1-3, mobile app reverse engineering (Jadx, Ghidra, Hopper), runtime instrumentation (Frida, Xposed, Cycript), network interception (mitmproxy, Burp Suite untuk mobile), mobile malware analysis, dan platform-specific attack surface (Android Intents, iOS URL Scheme, WebView, Deep Link). Vault udah punya web-hacking-exploitation (web) dan browser-security-exploitation-deepdive (browser) β€” catatan ini melengkapi dari sisi mobile app.

Posisi di Vault

Nota ini melengkapi web-hacking-exploitation (web app pentesting) dan browser-security-exploitation-deepdive (browser security) dengan mobile-specific attack surface. Juga terkait dengan mobile-forensics (data forensik device β€” beda scope), api-security-deep-dive (mobile API security β€” sebagian besar mobile app backend-nya API), identity-and-access-management (mobile auth β€” OAuth, JWT), cryptography-biometrics (mobile crypto β€” Keychain, Keystore, Secure Enclave), dan endpoint-detection-playbook (mobile endpoint β€” EDR untuk mobile).


Daftar Isi


OWASP MASVS β€” Mobile App Security Standard

Tingkatan MASVS

LevelNamaTujuanCocok Untuk
L1Standard SecurityVerifikasi dasar β€” semua app wajibApp biasa, internal app
L2Defense-in-DepthPertahanan berlapis β€” anti-tamper, anti-debug, jailbreak detectionFintech, health, enterprise
L3Resiliency Against Reverse EngineeringReverse engineering sangat sulit β€” obfuscation, white-box crypto, integrity checkDRM, payment, high-value IP

MASVS Categories (8 Group)

  1. MSTG-ARCH β€” Architecture, design, threat modeling
  2. MSTG-STORAGE β€” Data storage & privacy (Keychain, Keystore, NSUserDefaults)
  3. MSTG-CRYPTO β€” Cryptography (mobile-specific: Keychain, TEE, Secure Enclave)
  4. MSTG-AUTH β€” Authentication & session management (biometric, OAuth)
  5. MSTG-NETWORK β€” Network communication (TLS pinning, certificate validation)
  6. MSTG-PLATFORM β€” Platform interaction (Intents, URL Scheme, WebView, Deep Links)
  7. MSTG-CODE β€” Code quality & anti-tampering (obfuscation, jailbreak detection)
  8. MSTG-RESILIENCE β€” Resilience against reverse engineering (Frida detection, anti-debug)

Android Security Model

Android Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        Applications            β”‚ ← Sandboxed per-user ID
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        Android Framework       β”‚ ← Permissions, Content Providers, Intents
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        Android Runtime (ART)   β”‚ ← AOT + JIT compilation
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        Hardware Abstraction    β”‚ ← HAL, Keystore, TEE
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚        Linux Kernel            β”‚ ← SELinux, namespaces, DAC
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Android Attack Surface

SurfaceKerentanan UmumImpact
APKReverse engineering (Jadx, APKTool)Source code leak, hardcoded secret
IntentIntent spoofing, intent redirectionPrivilege escalation, data leak
Content ProviderSQL injection, path traversalDatabase access, file read
WebViewXSS via JavaScript bridge, file:// accessRCE (JavaScript→Java bridge)
SharedPreferencesUnencrypted local storageCredential leak
Deep LinkURL scheme hijackingSession hijack, phishing
BackupADB backup tanpa passwordFull app data extraction
LoggingLogcat β€” sensitive info di logInformation disclosure

Android Permission Model

  • Normal β€” auto-grant (INTERNET, ACCESS_NETWORK_STATE)
  • Dangerous β€” user grant runtime (CAMERA, LOCATION, READ_CONTACTS)
  • Signature β€” same signature only (vendor-specific)
  • SignatureOrSystem β€” system app only

Android Pentesting

Setup Lab

Device: rooted Pixel / Emulator with root
Tools: ADB, Frida, objection, APKTool, Jadx, Burp Suite, Drozer, Magisk

Step-by-Step Pentest

1. APK Extraction & Analysis

# Extract APK from installed app
adb shell pm list packages | grep com.target
adb shell pm path com.target.app
adb pull /data/app/.../base.apk target.apk
 
# Decompile
apktool d target.apk -o target_extracted/
jadx-gui target.apk  # Java source code

2. Static Analysis Checklist

  • Hardcoded API keys, tokens, secrets di strings.xml atau Java code
  • Root/jailbreak detection β€” dimana? Bisa bypass?
  • Certificate pinning implementation β€” TrustManager custom?
  • WebView JavaScript interface β€” ada @JavascriptInterface ekspos?
  • Backup flag β€” android:allowBackup="true"?
  • Deep link verification β€” android:autoVerify="true"?
  • Intent filter exposure β€” komponen yang tidak di-export tapi bisa diakses?

3. Dynamic Analysis (Runtime)

# Frida β€” bypass root detection
frida -U -l bypass_root.js com.target.app
 
# objection β€” mobile exploration
objection -g com.target.app explore
# Dalam objection shell:
# android root disable
# android sslpinning disable
# android hooking list classes
 
# Drozer β€” Android security audit
drozer console connect
dz> run app.activity.info -a com.target.app
dz> run app.provider.info -a com.target.app
dz> run scanner.provider.finduris -a com.target.app

4. Network Interception

# Burp Suite setup
adb shell settings put global http_proxy 192.168.1.100:8080
 
# Install Burp CA di system trust store (rooted device)
adb push burp-ca.der /sdcard/
adb shell
su
mount -o rw,remount /system
cp /sdcard/burp-ca.der /etc/security/cacerts/9a5ba575.0
chmod 644 /etc/security/cacerts/9a5ba575.0
 
# Jika ada certificate pinning β†’ Frida bypass
frida -U -l ssl_pinning_bypass.js com.target.app

5. Local Storage Extraction

# ADB backup (tanpa password β€” insecure)
adb backup -f app_backup.ab com.target.app
(echo 00; dd if=app_backup.ab bs=24 skip=1) | openssl zlib -d > backup.tar
 
# Direct database access (rooted device)
adb shell
su
cat /data/data/com.target.app/databases/app.db
sqlite3 /data/data/com.target.app/databases/app.db .dump
 
# SharedPreferences & internal storage
cat /data/data/com.target.app/shared_prefs/*.xml
cat /data/data/com.target.app/files/*.json

iOS Security Model

iOS Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        Applications            β”‚ ← Sandbox, code signing mandatory
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚      Cocoa Touch (UIKit)       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚       Media / Core Services    β”‚ ← Keychain, iCloud, Push
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚      Core OS / Kernel (XNU)    β”‚ ← Mach, BSD, sandbox (Seatbelt)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    Secure Enclave + SEP        β”‚ ← Biometric, crypto, hardware key
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

iOS vs Android Security

AspekAndroidiOS
App DistributionMultiple stores, sideloading allowedApp Store only (wajib review)
Code SigningOptional (APK sign)Mandatory β€” semua app harus signed
SandboxPer-user ID (Linux)Seatbelt + sandbox profile
EncryptionFile-based (since Android 7)Hardware-backed (Secure Enclave)
JailbreakRoot (easy)Jailbreak (difficult β€” need exploit)
PermissionRuntime (since 6.0)Runtime (since iOS 10)
App reviewNo official reviewApp Store review
Third-party keyboardYesYes (since iOS 8)
App CloningNative supportNot allowed

iOS Pentesting

Setup Lab

Device: jailbroken iPhone/iPad
Tools: frida-ios-dump, class-dump, Hopper, objection, Frida, Keychain-Dumper, needle

1. IPA Extraction & Decryption

# Dump decrypted IPA dari jailbroken device
frida-ios-dump -u -o target.ipa com.target.app
 
# Class information
class-dump -H target.ipa extracted_headers/
 
# Or with objection
objection explore
objection> ios info binary

2. iOS Static Analysis

# Binary analysis with Hopper/Ghidra
# Check: hardcoded keys, pinning, encryption
 
# Info.plist analysis
plutil -p extracted_app/Payload/App.app/Info.plist
 
# Check:
# - NSAppTransportSecurity (ATS) β€” di-disable?
# - Exported URL Schemes
# - Background modes
# - Keychain access groups

3. iOS Runtime Analysis

# Frida β€” hook Objective-C methods
frida -U com.target.app -l ios_hook.js
 
# objection β€” iOS exploration
objection -g com.target.app explore
objection> ios jailbreak disable
objection> ios sslpinning disable
objection> ios hooking list classes
objection> ios keychain dump
 
# Keychain extraction
objection> ios keychain dump
frida -U --codeshare mrmacete/find-and-bypass-ios-ssl-pinning

4. iOS Data Storage

# App sandbox access (jailbroken)
/var/mobile/Containers/Data/Application/<UUID>/
# Check:
# - Documents/ β€” user data
# - Library/Preferences/ β€” NSUserDefaults (plist)
# - Library/Caches/ β€” cached data (maybe sensitive)
# - tmp/ β€” temporary files
 
# Keychain Dumper
./Keychain-Dumper -a  # Dump all keychain items

5. iOS Reversing

# Hopper: decompile ObjC β†’ pseudo-code
# Frida codeshare: banyak script siap pakai
 
# Trace ObjC method calls
frida -U com.target.app -l ios_trace.js
 
# Dump NSUserDefaults
frida -U com.target.app -e "NSUserDefaults.alloc().initWithSuiteName_('com.target.app').dictionaryRepresentation()"

Mobile API Security

Mobile apps mostly communicate via REST/GraphQL API. Pastikan:

CheckKenapaTools
API Key hardcoded?String di APK bisa dibacaJadx, strings, Ghidra
No certificate pinningMITM via proxyBurp Suite, mitmproxy
Rate limiting missingAccount takeover via brute forceCustom Frida, DroidBot
Weak OAuth flowAuthorization code interceptionBurp OAuth scanner
GraphQL introspection enabledFull schema exposedGraphiQL, introspection query
JWT weak secretToken forgeryjwt_tool, John

Runtime Instrumentation

Frida β€” Universal Tool

# Android
frida -U com.target.app -l script.js
 
# iOS
frida -U com.target.app -l script.js
 
# Key Frida use cases:
# 1. Bypass SSL pinning
# 2. Bypass root/jailbreak detection
# 3. Hook function β†’ change return value
# 4. Dump method arguments
# 5. Trace method calls

Objection β€” Mobile Exploration Platform

objection -g com.target.app explore
# Commands:
# android hooking list classes
# android hooking watch class com.target.login
# ios hooking list classes
# ios jailbreak disable
# ios sslpinning disable
# android sslpinning disable
# android root disable

Xposed (Android only)

  • Permanent module-based hooking
  • Module: SSLUnpinning, XposedInstaller, RootCloak
  • Kelemahan: require reboot setiap ganti module, gak work di Android 10+

Frida vs Xposed

AspekFridaXposed
PermanenceSession-basedModule (permanent)
Android versionAll (5+)Android 4-9 (deprecated 10+)
iOS supportβœ…βŒ
SetupNo rebootNeed reboot
DetectionMudah dideteksi (port 27042)Moderate (check /system)
FlexibilitySangat tinggi (JavaScript)Medium (Java modules)

Mobile Malware

Android Malware Types

TypeBehaviorExample
Banking TrojanOverlay phishing, SMS interceptCerberus, Anubis, TeaBot
SpywareCall recording, location trackingPegasus (iOS), Triout
RansomwareLock screen, file encryptionSimplocker, Koler
AdwareAggressive ads, background installJudy, HummingBad
DropperDownload & install second-stage payloadHiddad, Moqhao

Detection Techniques

  • Static β€” signature-based (YARA rules)
  • Dynamic β€” behavior analysis (sandbox, network monitoring)
  • ML-based β€” permission anomalies, API call patterns

Toolchain Perbandingan

ToolAndroidiOSFungsiHarga
Jadxβœ…βŒAPK to Java decompilerFree
APKToolβœ…βŒAPK decode, rebuildFree
Fridaβœ…βœ…Runtime instrumentationFree
objectionβœ…βœ…Mobile explorationFree
Drozerβœ…βŒAndroid security auditFree
class-dumpβŒβœ…iOS ObjC header extractionFree
HopperβŒβœ…iOS binary disassembler$
Ghidraβœ…βœ…Binary reverse engineeringFree
Burp Suiteβœ…βœ…Proxy, scannerFree/Pro
NeedleβŒβœ…iOS security testingFree
MobSFβœ…βœ…Automated mobile security scanFree
MVTβœ…βœ…Mobile Verification Toolkit (forensics)Free

Koneksi ke Vault