Skip to content

hypnguyen1209/offensive-claude / skills/mobile-pentest

mobile-pentest

Unverified

Use when pentesting an Android/iOS app — Frida 17 instrumentation, SSL-pinning & root/jailbreak bypass, Android 14/15 CA injection, exported-component/content-provider abuse, deep-link/WebView chains, biometric bypass, Flutter/React-Native RE

references/ios-offensive.md

View on GitHub
# iOS Offensive Workflow

> **ATT&CK (Mobile):** T1635 (Install Insecure/Malicious Config / JB-detection bypass), T1409 (Stored Application Data / IPA decrypt) · **CWE:** CWE-693, CWE-200

Jailbreak tooling and version matrix, jailbreak-detection bypass, IPA decryption, binary
analysis (class-dump / Swift), entitlements & URL-scheme review, and the Frida-version gotchas
that bite iOS dynamic analysis in 2025-2026.

---

## 1. Jailbreak Tooling Matrix (2025-2026)

| Tool | Mechanism | Chips | iOS support | Notes |
|------|-----------|-------|-------------|-------|
| **palera1n** | checkm8 bootrom (tethered/semi-tethered) | A8–A11, T2 | iOS/iPadOS 15.0–18.7.x | Rootful or rootless; iPadOS 17/18 rootless-only. Hardware-limited to ≤A11. |
| **Dopamine** | semi-untethered (kfd-family) | A8–A16, M1–M2 | iOS 15.0–16.6.1 | Use **2.5b4** for 15.8.7–15.8.8 / 16.7-RC / 16.7–18.7.1 sideloads; signed at jailbreaks.app. RootHide variant adds VarClean. |
| **checkra1n** | checkm8 (legacy) | A7–A11 | up to iOS 14.x | Predecessor to palera1n; mostly superseded. |

**Reality for A12+ on iOS 17/18**: no public userland jailbreak. If you must test such a device,
provision it on the **lowest available firmware** before the engagement, or fall back to **on-device
binary patching** (Ghidra/IDA) and a **frida-gadget**-repacked IPA on a non-JB device (resign with a dev
cert / TrollStore where applicable).

Connectivity once jailbroken:

```bash
brew install libimobiledevice            # provides iproxy
iproxy 2222 22 &
ssh -p 2222 root@127.0.0.1               # default password: alpine  (CHANGE IT)
# install frida-server from the palera1n/Dopamine Sileo/Cydia repo, or via SSH:
#   apt update && apt install re.frida.server   (from https://build.frida.re repo)
```

---

## 2. Jailbreak-Detection Bypass

JB detection commonly checks: existence of `/Applications/Cydia.app`, `/private/var/lib/apt`,
`/bin/bash`, `/etc/apt`, the `cydia://`/`sileo://` URL schemes, whether `/private/...` is writable, and
the presence of `frida`/`MobileSubstrate` in `dyld` images or `/proc`-style `sysctl` process lists.

### 2a. Frida hooks (in `scripts/ios_bypass_suite.js`)

```js
// Lie about file existence to stat/lstat/fopen/access
['stat','lstat','fopen','access','open'].forEach(fn => {
  const p = Module.findExportByName(null, fn); if (!p) return;
  Interceptor.attach(p, { onEnter(args) {
    try {
      const path = args[0].readUtf8String();
      if (/Cydia|Sileo|substrate|MobileSubstrate|frida|\/bin\/(ba)?sh|apt|jailbreak|\/etc\/apt/i.test(path))
        args[0] = Memory.allocUtf8String('/nonexistent_' + Math.random());
    } catch (e) {}
  }});
});
// dlopen of the substrate/frida dylibs
const dlopen = Module.findExportByName(null, 'dlopen');
Interceptor.attach(dlopen, { onEnter(a) {
  try { const s = a[0].readUtf8String(); if (/Substrate|frida|cycript/i.test(s)) this.block = true; } catch(e){}
}, onLeave(r) { if (this.block) r.replace(ptr(0)); }});
// canOpenURL for cydia://, sileo://
const UIApp = ObjC.classes.UIApplication;
if (UIApp) {
  const m = UIApp['- canOpenURL:'];
  Interceptor.attach(m.implementation, { onEnter(a) {
    const u = new ObjC.Object(a[2]).toString();
    if (/cydia|sileo|zbra|filza|undecimus/i.test(u)) this.fake = true;
  }, onLeave(r) { if (this.fake) r.replace(ptr(0)); }});
}
```

### 2b. Dopamine **HideJailbreak** (when Frida scripts fail)

A 2025 workflow that works when `evaluatePolicy`/stat hooks don't: in **Dopamine → Settings →
Hide Jailbreak**. Catch: HideJailbreak can break Frida attachment. Sequence that preserves both:

1. Fully close the target app.
2. Enable **Hide Jailbreak** (if still detected → **Reboot Userspace**).
3. Launch app, keep it backgrounded.
4. Return to Dopamine → **Unhide Jailbreak**, go back to app → popup gone **and** Frida can attach.

Fallbacks: **Shadow** tweak, **A-Bypass**, CodeShare scripts, or static binary patch in Ghidra (flip the
detection branch / `ret 0`).

### 2c. Frida version gotcha

iOS dynamic analysis is sensitive to Frida version. A documented 2025 case: **Frida 16.6.6 crashed** the
target, requiring downgrade to **16.4.3** for stability under Dopamine. Always pin host `frida-tools` to
the on-device `frida-server` version and be ready to step a couple of patch releases back on iOS.

---

## 3. IPA Decryption & Pull

App Store binaries are FairPlay-encrypted; decrypt on a jailbroken device:

```bash
# frida-ios-dump — pulls + decrypts a running/installed app
frida-ios-dump -o app.ipa com.target.app
# bagbak — alternative, handles app extensions & frameworks well
bagbak com.target.app -o ./out
unzip app.ipa -d extracted
```

---

## 4. Binary & Metadata Analysis

```bash
APP=extracted/Payload/Target.app/Target

# Objective-C class/method surface
class-dump-dyld -H "$APP" -o headers/         # or `class-dump` for older binaries
# Swift: names are mangled; use Hopper/IDA, or swift-demangle:
nm "$APP" | xcrun swift-demangle

# Strings — endpoints / keys / secrets
strings -a "$APP" | grep -iE 'https?://|secret|api[_-]?key|token|AKIA|AIza'

# Mach-O hardening checks
otool -hv "$APP"                 # PIE flag
otool -Iv "$APP" | grep -i stack_chk      # stack canary
codesign -d --entitlements :- "$APP"      # entitlements: keychain-access-groups, associated-domains, etc.

# Info.plist attack surface
plutil -p extracted/Payload/Target.app/Info.plist
# inspect: CFBundleURLTypes (custom schemes), NSAppTransportSecurity exceptions (cleartext),
#          associated-domains entitlement (Universal Links), UIFileSharingEnabled, LSApplicationQueriesSchemes
```

URL-scheme / Universal-Link exploitation continues in `webview-deeplink-exploitation.md`;
Keychain/biometric in `insecure-storage-crypto.md`.

---

## 5. objection iOS quick-reference

```bash
objection -g com.target.app explore
ios sslpinning disable
ios jailbreak disable
ios ui biometrics_bypass
ios keychain dump
ios nsuserdefaults get
ios cookies get
memory dump all app_mem.bin      # then `strings app_mem.bin | grep ...`  (fridump-style scrape)
```

---

## Detection

- **JB-detection bypass**: an app with robust detection cross-checks multiple signals and may detect the
  hook itself (e.g. integrity check on `stat`'s prologue, or `dyld` image enumeration that spots
  `FridaGadget`). Server-side **DeviceCheck / App Attest** attestation is unaffected by local hooking —
  note client- vs server-side enforcement.
- **Frida on iOS**: app scanning loaded dylibs for `FridaGadget`/`frida-agent`, probing port 27042, or
  checking for the `gum-js-loop` thread. Renamed gadget + custom port reduce IOCs.
- **IPA decryption**: not network-visible, but the decrypted binary differs (no `LC_ENCRYPTION_INFO`
  `cryptid=1`); irrelevant to live detection.
- App-side hardening to recommend: ATS without exceptions, no `UIFileSharingEnabled`, Keychain ACLs with
  `.biometryCurrentSet`, jailbreak detection as defense-in-depth only (not a security control), and
  App Attest for server-trust.

## OPSEC

- Change the default `alpine` SSH password immediately on a fresh JB device; a JB device with open SSH
  on USB+Wi-Fi is itself an exposure.
- Dopamine HideJailbreak / Reboot-Userspace cycles disrupt running hooks — script your Frida re-attach.
- Decrypted IPAs contain client IP/build secrets; treat as engagement data, store in the case folder, do
  not upload to public scanners.

## References

- palera1n — official repo & supported devices — https://github.com/palera1n/palera1n
- ios.cfw.guide — Installing Dopamine (version/sign matrix) — https://ios.cfw.guide/installing-dopamine/
- Medium (A. Barbieri) — Bypassing Jailbreak detection using Dopamine HideJailbreak — https://medium.com/@Bug_Fucker/bypassing-jailbreak-detection-using-dopamine-hidejailbreak-f53f02d11994
- Medium (F. Faisal) — Mastering iOS Pentesting Part 1: Dopamine & palera1n — https://medium.com/@frsfaisall/mastering-ios-pentesting-part-1-jailbreaking-your-devices-dopamine-palera1n-200ae1dc7542
- Frida CodeShare — iOS jailbreak detection bypass (palera1n) — https://codeshare.frida.re/@DevTraleski/ios-jailbreak-detection-bypass-palera1n/
- OWASP MASTG — iOS reverse engineering / Local Authentication — https://mas.owasp.org/MASTG/
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall