Mobile resilience

From ShulkwiSEC/bb-huge · View interactive version

Mobile resilience is an AI agent skill from the GitHub repository ShulkwiSEC/bb-huge. Detects weak reverse engineering and tampering protections in mobile apps (Android/iOS). Trigger on: root detection bypass, jailbreak detection bypass, Frida detection, debugger detection, anti-debugging, ptrace, sysctl, emulator detection, code obfuscation absent, debug symbols present, get-task-al

How to use this skill

Skill file

Mobile Resilience Against Reverse Engineering

What Is Broken and Why

Resilience controls protect app logic, keys, and business rules from reverse engineering and tampering. Root/jailbreak detection, anti-debugging, and integrity checks create defense-in-depth. Without them, attackers can attach Frida to patch auth checks, repack APKs with modified logic, or extract keys from memory at leisure. Most basic resilience checks are bypassable individually — the value comes from layered controls that raise the cost of attack. Root detection that relies on a single file check (/system/app/Superuser.apk) is trivially bypassed; multi-vector detection that checks file system, build properties, and system call behavior is significantly harder.

Key Signals

Methodology

Android:

  1. Check android:debuggable in manifest — should be false in release build
  2. Attach debugger: adb shell jdwp | xargs → connect Android Studio debugger → if attaches: no anti-debug
  3. Run on emulator (AVD) — does the app detect and exit?
  4. Root check bypass: run app on Magisk-rooted device, then apply MagiskHide/Shamiko — does app still detect root?
  5. Frida attach: frida -U -f TARGET_PKG — if no crash/exit: no Frida detection
  6. Repack test: apktool b app/ -o repack.apk → sign → install — does app accept repackaged build?
  7. Check obfuscation: jadx decompiled/ — are class/method names meaningful (no obfuscation) or mangled?

iOS:

  1. Check get-task-allow entitlement: codesign -d --entitlements :- App.ipa
  2. Attach lldb: lldb -p TARGET_PID — does app detect and exit?
  3. Jailbreak detection: run on jailbroken device — does app behave normally?
  4. Check for ptrace calls: otool -tV App.app/App | grep ptrace
  5. Frida attach: frida -U TARGET — detection if app calls proc_pidinfo to scan for suspicious process names
  6. Check debug symbols: dsymutil -s App.app/App | head -50 — are symbols present in production?
  7. Integrity check: modify a resource file in IPA → re-sign → install — does app detect modification?

Payloads & Tools

# Android — check debuggable flag
apktool d app.apk && grep "debuggable" app/AndroidManifest.xml

# Android — Frida bypass root detection (generic)
frida -U -f TARGET_PKG --no-pause -l bypass-root-detection.js
# Common scripts: https://github.com/fridayy/frida-scripts

# Android — objection root bypass
objection --gadget TARGET_PKG explore
android root disable

# Android — check obfuscation
jadx app.apk -d jadx-out/
ls jadx-out/sources/  # readable package names = no obfuscation

# iOS — check entitlements
codesign -d --entitlements :- Payload/App.app/App | grep "get-task-allow"

# iOS — Frida jailbreak bypass
frida -U TARGET -l jailbreak-bypass.js
# Liberty Lite, Shadow (Cydia tweaks) for persistent bypass

# checksec — Android native binary
checksec --file=lib/arm64-v8a/libapp.so
// Frida — Android: bypass single root check (file existence)
Java.perform(function() {
  var File = Java.use("java.io.File");
  File.exists.implementation = function() {
    var path = this.getAbsolutePath();
    if (path.indexOf("su") >= 0 || path.indexOf("magisk") >= 0) {
      console.log("[+] Blocked file check:", path);
      return false;
    }
    return this.exists();
  };
});

Bypass Techniques

Exploitation Scenarios

Scenario 1 — Frida Attach to Extract Business Logic

Setup: Fintech app has no Frida detection. Logic for calculating fees is in native method calculateFee(). → Trigger: frida -U TARGET -e "Module.findExportByName(null,'calculateFee')" hooks the method. → Impact: Proprietary fee calculation logic extracted and replicated by competitor.

Scenario 2 — APK Repackage to Remove Feature Flags

Setup: App has premium feature gated by boolean check if (user.isPremium). No integrity verification. → Trigger: Decompile APK, patch smali to always return true, repack and re-sign. → Impact: Free users access all premium features without payment.

Scenario 3 — Debug Build in Production

Setup: App shipped with android:debuggable="true" in release. → Trigger: Attacker runs adb shell run-as TARGET_PKG to access app's private data directory. → Impact: SQLite databases, SharedPreferences, and cached tokens extracted without root.

False Positives

Fix Patterns

// Android — multi-vector root detection (raise attack cost)
fun isDeviceRooted(): Boolean {
    return checkSuBinary() || checkBuildTags() || checkDangerousApps() ||
           checkRWPaths() || checkSafetyNetAttestation()
}
// Use Play Integrity API for cryptographic device attestation (replaces SafetyNet)

// Android — prevent debugging in release
// In build.gradle: ensure debuggable is false
buildTypes { release { debuggable false } }
// iOS — ptrace anti-debug
import Darwin
func denyDebugger() {
    var name = [CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid()]
    var info = kinfo_proc()
    var infoSize = MemoryLayout<kinfo_proc>.size
    sysctl(&name, 4, &info, &infoSize, nil, 0)
    if (info.kp_proc.p_flag & P_TRACED) != 0 { exit(1) }
}

Related Skills

[[mobile-auth-bypass]] via Frida hook is the most common exploit that resilience controls defend against — without debugger detection and Frida detection, biometric bypasses are trivially reproducible. [[mobile-insecure-storage]] extraction requires root or jailbreak access that resilience detection is designed to catch. [[mobile-code-quality]] binary hardening (PIE, stack canaries) complements resilience: hardened native code makes memory corruption exploitation harder even when the attacker has successfully bypassed root/jailbreak detection.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.