This post covers a security assessment of Gardeshgari Bank’s Android app (mob.banking.android.gardesh), using static analysis and live Frida and Burp testing on a rooted Android 14 emulator. It confirms and bypasses root/debug detection, a hand-rolled single-CA SSL pinning scheme, and a silent anti-tamper watchdog, and traces how login credentials are encrypted and how a device-trust token can skip two-factor authentication. Signature/tamper self-verification and the replayability of that device-trust token remain open questions for follow-up testing.
- Target: Gardeshgari Bank (Iran)
- Package:
mob.banking.android.gardesh - Version tested: v12.6.0 (versionCode 260)
- Testing window: static analysis 2026-07-25; full dynamic re-verification (live Frida instrumentation, static-to-runtime cross-check, extended 60+ second stability test on an Android Studio AVD) 2026-08-07
Tester: Admiral
Version evidence: confirmed three independent ways — apktool.yml/manifest agree, adb shell dumpsys package mob.banking.android.gardesh on the live install reports versionName=12.6.0 versionCode=260, and the in-app splash screen renders نسخه: ۱۲.۶.۰ (only one build of this app has been provided; there is no older version to cross-check against).
1. Root and debug detection (confirmed)
Confirmed via both static analysis and a live bypass test. Custom, in-house implementation — no RootBeer or other known library (searched, zero matches). The app requests android.permission.QUERY_ALL_PACKAGES (device-wide enumeration) rather than a fixed manifest <queries> allowlist, consistent with a homegrown scanner rather than a library.
The decision point. mobile.banking.activity.StartActivity.A() is the single method that gates all of this. It calls mobile.banking.util.RootUtil.isDeviceRootedNative(Context)Z — a native/JNI-backed method — and stores the boolean result. Depending on a build-flavor switch (a lookup table on the ordinal of Lp6/a;->m:Lmobile/banking/enums/d4;), A() either routes on that result directly, or additionally requires two more predicates before accepting the device as safe:
mobile.banking.activity.ac.V0(Context)Zmobile.banking.activity.ac.a1(Context)Z
Both V0() and a1() must return true, in addition to the root check being negative, for the flow to reach mobile.banking.enums.b0.SafeOrAccepted. a1() itself reads Settings.Secure.getInt(cr, "adb_enabled", 0) (note: Secure, not Global — an easy hook to reach for and miss) unless a SharedPreferences flag usbDebuggerAlertAccepted is already set from a previous “I Agree” tap — meaning on a real device, a user who dismisses the warning once will not see it again on that install.
Three distinct outcomes route to three distinct activities:
mobile.banking.activity.AlertRootActivity— root detected, dismissible warningmobile.banking.activity.DenyRootedDeviceActivity— hard block (reached directly fromA()’s stricter branch when the native check is positive)mobile.banking.activity.AlertUsbDebuggerAndPinActivity— USB-debugging warning, dismissible, persisted viausbDebuggerAlertAccepted
There is also a continuous background check: mobile.banking.activity.ya (a Thread subclass, started from StartActivity.B() right after the startup gate passes) polls android.os.Debug.isDebuggerConnected() on an ongoing basis, independent of the one-time startup gate.
Live bypass, confirmed 2026-08-07. Hooking RootUtil.isDeviceRootedNative alone was not sufficient — on the rooted, adb-attached test emulator, the app still routed to AlertUsbDebuggerAndPinActivity because a1()’s adb_enabled check is independent of the root signal and true in that environment. Adding direct hooks on ac.V0 and ac.a1 (both forced true) reached the real login screen (نام کاربری / رمز عبور / ورود) cleanly, with no block or warning screen at all. Confirmed via screenshot. Debug.isDebuggerConnected was also hooked defensively for the background watchdog thread; it was not observed firing during the login-screen test window but the app was also not exercised beyond the login screen.
2. Signature verification (not confirmed)
Unchanged from the prior pass: GET_SIGNATURES / getSignatures returns zero matches across all 32,616 smali files. Not investigated further this round — this app either skips signature self-verification, relies on server-side attestation, or implements the check through a non-obvious path. Needs a dedicated pass (JADX or targeted native/reflection search) before it can be marked either way.
3. SSL/TLS pinning (confirmed)
Confirmed via both static analysis and live testing, superseding the July static-only finding entirely. The July finding that grepping for okhttp3.CertificatePinner/OkHttpClient returned zero matches was correct, but the conclusion drawn from it (that OkHttp isn’t the app’s networking stack) was incomplete — and, as it turns out, ultimately beside the point. OkHttp classes are genuinely present in this APK: R8 renamed most of them to short synthetic package names (o50, p50, g50, l50, k50, n50, r50, w90), which is exactly why the original keyword grep for the real class names found nothing. The one OkHttp class that survives renaming intact is okhttp3.internal.publicsuffix.PublicSuffixDatabase — it can’t safely be renamed because it loads a resource file by class-relative path, and it was the thread that led back to the rest. Corroborating evidence in the renamed classes: the string literal "CustomTrustRootIndex(trustManager=" (a real, distinctive OkHttp internal string), android.net.http.X509TrustManagerExtensions usage matching OkHttp’s Android platform trust-manager path, and a reflective lookup of .OpenSSLSocketFactoryImpl (OkHttp’s Android-Conscrypt-detection idiom).
None of that matters for this app’s own traffic, though. OkHttp is a transitive dependency (most likely pulled in by Firebase Messaging, which StartActivity.B() calls directly via FirebaseMessaging.getInstance().getToken()) — not the library the app uses for its own banking API calls. The bank’s actual REST client is hand-rolled:
mobile.banking.rest.service.h(abstract base class) has a methode()Ljavax/net/ssl/SSLSocketFactory;that: decodes a single hardcoded X.509 certificate embedded as a base64 string directly in the smali (via a helperLt90/a;->a(Ljava/lang/String;)[B), loads it into a fresh, single-entryBKSKeyStore(setCertificateEntry("ca", cert)), builds aTrustManagerFactoryinitialized with only that keystore, and returns anSSLSocketFactoryfrom anSSLContextof type"TLS"initialized with those trust managers. This is certificate pinning implemented by hand: trust exactly one embedded CA, nothing else.mobile.banking.rest.service.f(extendsl0.h, which is this app’s renamed copy of Volley’sHurlStack) overridesg2(URL)Ljava/net/HttpURLConnection;— Volley’s connection-creation hook — casts the connection toHttpsURLConnection, and callssetSSLSocketFactory()with the factory fromh.e(), plussetHostnameVerifier()with an instance of:mobile.banking.rest.service.g— aHostnameVerifierwhoseverify(String, SSLSession)unconditionally returnstrue. No hostname checking happens at all on this path; the entire scheme’s security reduces to secrecy of the one embedded certificate (and, transitively, its private key never being used to sign anything else).
Live bypass, confirmed 2026-08-07. Rather than hook h.e() or f.g2() directly, a generic platform hook on javax.net.ssl.SSLContext.init(KeyManager[], TrustManager[], SecureRandom) (nulling the TrustManager[] argument so the system trust store — which trusts the installed Burp CA — wins) intercepts the exact overload h.e() calls into, without needing to reference any app-specific class. Confirmed firing 4-5 times during a single cold start (config/branch data fetch, Firebase, and the REST client all initializing their own SSLContexts). A second, direct observability hook on h.e() itself confirmed the method is live and actually called on this exact build (not dead code from an older version). The device’s proxy is pointed at the same Burp instance used for the other two apps in this engagement (192.168.1.169:8080); no SSLHandshakeException, CertPathValidatorException, or connection-level exception appeared in logcat during the test window, and the app reached its real login screen normally.
Practical, no-Frida alternative (not tested this round, noted for completeness): since there’s no signature self-check found so far (§2), patching the embedded certificate blob directly in h.smali (or patching g.smali’s verify() to keep returning true, which it already does) and rebuilding/resigning would be a durable, Frida-free bypass — the same “patch, don’t hook” option already documented for the other apps in this series, adapted to a hardcoded-cert target instead of a network_security_config.xml target.
4. Anti-tamper watchdog (confirmed)
Confirmed, root-caused, and bypassed live. The first live-test pass on this app (same day) reported “no crash, no early exit, no detection observed” — that was true only because the test window was a few seconds long. Left running longer, the app reproducibly self-terminated 15–30 seconds after reaching the login screen, every time, with no Java exception in logcat and no fresh tombstone in /data/tombstones/ (ruling out both a normal crash and a native-level SIGSEGV/SIGABRT). That silence is itself the signature of a deliberate, silent kill rather than a bug.
Root cause: mobile.banking.activity.ya is an R8 lambda-merged class (Thread subclass reused for ~9 unrelated callback purposes via a packed-switch on a constructor int — most of its run() method is unrelated UI-adapter code from other lambdas that happened to get merged into the same class by the compiler; this is normal R8 behavior, not evasion). Instantiated with the discriminant value that skips the packed-switch table entirely (from StartActivity.B(), via new-instance ya; const/16 v1, 0x9; invoke-direct ...ya;-><init>(Ljava/lang/Object;I)V; ...Thread;->start()V), it becomes a watchdog loop:
loop:
sleep(random 15000-29999 ms)
if Debug.isDebuggerConnected() -> kill
if (app's own ApplicationInfo.flags & FLAG_DEBUGGABLE) != 0 -> kill
if SecurityUtil.a() -> kill
else -> loop
kill:
Process.killProcess(Process.myPid())
System.exit(1)
Three independent trip conditions feeding one silent kill, checked forever on a randomized interval (the randomization itself is worth noting: it makes correlating “why did the app just close” to any specific user action meaningfully harder than a fixed timer would).
mobile.banking.util.SecurityUtil.a() is a textbook emulator-fingerprint check, notable for how its strings are stored: as byte arrays decoded to String at runtime via new String(byte[], "UTF-8"), not plaintext constants, so a keyword grep across the smali tree won’t find them. Decoded, they are: generic, unknown, google_sdk, Emulator, Android SDK built for x86, Genymotion, goldfish, ranchu, sdk_google, sdk, sdk_x86, vbox86p, emulator (plus a few — simulator, QC_Reference_Phone, Xiaomi, Build — that are decoded but not obviously used in the visible boolean chain, possibly dead code from a refactor). The check is Build.BRAND/DEVICE/FINGERPRINT/HARDWARE/MODEL/MANUFACTURER/PRODUCT against these substrings; Build.HARDWARE == "ranchu" (the standard QEMU2 backend on essentially every modern Android Studio AVD, x86 and arm64 alike) is the most likely single trigger on the current test device.
Live-verified, 2026-08-07, on the Android Studio AVD (emulator-5554, sdk_gphone64_arm64): with Debug.isDebuggerConnected, SecurityUtil.a(), and a blanket Process.killProcess/System.exit safety net all hooked, the app was left running past the login screen for 60+ seconds and survived five full watchdog cycles, each one logged and suppressed cleanly (Process.killProcess(<pid>) -- suppressed / System.exit(1) -- suppressed), same pid throughout, no restart, no visible behavior change. Notably, SecurityUtil.a()’s hook never actually fired in any of the five cycles — the kill was reached via the FLAG_DEBUGGABLE branch every time instead, meaning this specific AVD’s system image is reporting the app as debuggable at runtime even though it wasn’t built that way (a property of the emulator’s own build, not of the APK). This wasn’t independently confirmed by reading ApplicationInfo.flags directly, it’s inferred from process of elimination (the isDebuggerConnected hook is confirmed working via its own log line firing every cycle; SecurityUtil.a()’s hook is confirmed correctly attached but never invoked; the only remaining branch in the traced logic is FLAG_DEBUGGABLE) — good enough to explain the behavior, not yet a directly-read value. Worth a two-minute follow-up (Java.use('android.app.ActivityThread').currentApplication().getApplicationInfo().flags.value or similar) if it matters for the writeup or future testing on a different AVD image.
Practical implication either way: the blanket killProcess/System.exit hook makes which specific branch fired moot for bypass purposes. It would matter if the goal were to characterize the check precisely for a remediation writeup, which is why it’s flagged rather than left silently unresolved.
5. Two networking stacks (confirmed)
Live-captured traffic through Burp shows the app actually splits its own API surface across two independent HTTP clients, not one:
mobilebank.tourismbank.ir:4555(note:mobilebank, notmbanking, and a non-default port) — utility/reference-data calls (getATMsconfirmed).User-Agent: Dalvik/2.1.0 (Linux; U; Android 14; sdk_gphone64_arm64 Build/UE1A.230829.050), the raw OS-generated default fromHttpURLConnection/http.agent, meaning this endpoint gets the actualBuild.MODEL/Build.IDstring on every request. This is the custom Volley-HurlStack+ hardcoded-CA client documented in §3.mbanking.tourismbank.ir:443(default HTTPS port) — session/auth calls (account/loginconfirmed, real request captured and forwarded through Burp successfully after the §3 fix).User-Agent: okhttp/4.12.0, OkHttp’s own unmodified default, which does not leak any device info.
So the earlier “OkHttp is present but belongs to a bundled SDK, not the app’s own traffic” framing in §3 was too broad: OkHttp is a bundled dependency and it genuinely handles at least the login/session portion of this app’s own API surface. The custom hand-rolled client is not the whole story, it’s one of two parallel stacks, split by endpoint. Both ultimately funneled through the same platform-level SSLContext.init/NetworkSecurityTrustManager hooks in §3’s fix, which is why one fix covered both once the NetworkSecurityTrustManager layer was added, this app has no explicit okhttp3.CertificatePinner configured on its OkHttp client either (confirmed absent by the original July grep), so both stacks were ultimately relying on the same Android platform-level trust enforcement rather than their own pinning logic.
Finding: device-model leak via User-Agent on the mobilebank.tourismbank.ir:4555 endpoints. Every request through the custom client sends the exact Build.MODEL/Build.ID string in plaintext in the User-Agent header, server-visible on every call, independent of anything the client does locally. On a test device this reads sdk_gphone64_arm64, an immediate, server-observable “this is an emulator” signal, entirely separate from the local SecurityUtil.a() emulator-fingerprint check in §4. A real device would leak its actual model/build instead, which is lower-severity but still an unnecessary and easily-fixed information disclosure (Volley’s HurlStack can have a fixed or randomized UA set explicitly instead of falling through to the OS default).
6. Login credential encryption (confirmed)
Algorithm confirmed, and live plaintext capture confirmed working — this is RSA, not practically “crackable” after the fact. account/login sends encryptedUsername and encryptedPassword as separate base64 blobs, each decoding to ~256 bytes regardless of input length, the exact fixed output size of RSA-2048. Static analysis confirms RSA/ECB/PKCS1Padding is available via the bundled BouncyCastle provider (w80/c, l6/a, and three separate references inside the ac god-class); the exact call site wiring a specific public key to the login-request builder (u7/a, the LoginRequestApiEntity data class) wasn’t traced line-by-line, the fixed-length ciphertext pattern plus the confirmed algorithm availability is enough to call this RSA with high confidence without spending more time on it.
This is not practically reversible from captured ciphertext. RSA is asymmetric by design specifically so that a client holding only the public key (or nothing at all, if the key is server-fetched per-session) cannot decrypt what it just encrypted, only the server’s private key can. Barring an implementation flaw (key reuse, a weak/small modulus, a predictable key-generation bug, none of which were checked for this round), there is no “recover the plaintext from the ciphertext” technique available here, and none should be implied in anything published from this engagement.
The correct, standard technique, and the one actually deployed: hook javax.crypto.Cipher app-wide and log input going in, which captures the plaintext going in, before encryption happens, rather than attempting anything against the ciphertext after the fact. This is standard methodology for assessing client-side crypto (confirm what’s actually being protected and how, without needing to break the primitive itself) and should not be read as, or written up as, “cracking” anything.
Live-confirmed working, 2026-08-07. The first version of this hook (Cipher.doFinal(byte[]), one overload only) got zero hits across two real login attempts, despite the process being confirmed hooked and logging normally on every other check in the same window — the login flow simply calls a different Cipher overload than the one hooked, not something that avoids JCE’s Cipher class entirely as first assumed. Widening the hook to every doFinal/update overload on the class (hook #9 in the appendix) caught it on the very next attempt: both encryptedUsername and encryptedPassword plaintext were recovered in full and confirmed correct against the test account used throughout this engagement.
Actual credential values are deliberately not recorded in this document. This section documents that the capture technique works and exactly how, not the account’s live credentials.
A second, deeper hook on java.math.BigInteger.modPow (hook #10 — the modular exponentiation every RSA implementation on a JVM eventually calls regardless of library, and a core JDK class R8 cannot rename) was added as a renaming-proof fallback and left attached. It did not fire on this app; the actual RSA operation here routes through Android’s native crypto provider rather than pure-Java math. Hook #9 is what actually caught the credentials. Worth keeping #10 in the script anyway, it costs nothing and may be the one that matters on a different app or build that does route RSA through BigInteger.
7. Second-factor device-trust token (partially confirmed)
The mechanism by which a second factor can be skipped on a recognized device, via a persisted authorizeKey token, is confirmed via both static analysis and live testing; replayability and device-binding have not yet been tested. Two live login attempts, same account, same Deviceid header (dbda015753b4168c), the same testing session. The first attempt’s request body had no authorizeKey field; the response came back with "isAuthorizeNeeded":true and a short opaque accessToken (96 hex characters, not a JWT) — a pre-auth token pending OTP, as expected. The second attempt’s request body included a new field, "authorizeKey":"c8467a49b33074006ee2acf21ff91b0909cc4000e6b4698a420107a00901799f", and the response came back with "isAuthorizeNeeded":false and a full RS256 JWT access token (claims include "amr":["ServerKey"] — no OTP/password AMR value present, confirming this session was authorized without a fresh second factor).
Static analysis confirms where authorizeKey comes from and where it goes:
- Issued on successful OTP verification.
mobile.core.model.account.login.otp.VerifyCoreOTPResponseDomainEntityandmobile.core.model.account.login.otp.VerifyShahkarOTPResponseDomainEntity(Shahkar = Iran’s national mobile-number/national-ID registry, used for SIM-ownership verification) both define anauthorizeKeyfield. Both are response models for OTP-verification endpoints specifically — the server hands this value back only after a code has actually been checked and accepted, not merely when a code is issued. - Persisted locally.
dv/i.smali,a6/a.smali,b7/c.smali, ando7/c.smaliall reference the literal string"authorizeKey_"as a storage-key prefix (SharedPreferences pattern;dv/i.smaliline 722 also references"authorizeKey_null", consistent with a null-check/no-stored-key sentinel). - Re-sent on subsequent requests.
t7/a(LoginRequestApiEntity),u7/a(ForceChangePasswordRequestApiEntity), andw7/f/w7/h(additional OTP-flow request entities) all declare anauthorizeKeyJSON field via their serialization annotations — a real wire field the app sends back, not just something logged internally.
This is consistent with an intended “remember this device” feature: prove phone-number possession once via OTP, get a token back, skip re-challenging on that same device for some period. That’s standard, reasonable UX for a banking app and not inherently a flaw.
What wasn’t tested, and is the actual open question: whether authorizeKey is a bare bearer secret the app blindly replays, or whether it’s bound to the device in some way that survives extraction. If it’s the former, extracting it (rooted-device SharedPreferences read, unencrypted backup, or any other local-storage access) and replaying it from a different device or emulator, alongside only the username and password, would skip the OTP step entirely — a real second-factor bypass, not a UX nicety. If it’s tied to hardware-backed attestation, a short validity window, or server-side device-fingerprint cross-checking, it’s fine as designed. Confirming this requires: (1) pulling the stored value directly (SharedPreferences XML path not yet enumerated), (2) attempting a replay from a wiped app-data state or a different Deviceid, and (3) checking whether the key has any observable expiry. None of this was done this round — flagged here rather than assumed either way.
Summary of confirmed findings
Root/debug detection: fully confirmed, exact decision points identified (RootUtil.isDeviceRootedNative, ac.V0, ac.a1), live-bypassed to a real login screen. Notably a two-signal design — root state and USB-debugging state are checked independently, not derived from one another, and a naive bypass of only the root check is insufficient (confirmed the hard way, live). SSL/TLS: fully confirmed, and materially different from what was assumed in July — no library-provided pinning framework is involved at all; it’s a hand-rolled single-CA trust store paired with a hostname verifier that accepts everything, wired through a renamed Volley HurlStack, plus a platform-level trust layer (NetworkSecurityTrustManager/NetworkSecurityConfig) that turned out to require its own hooks independent of the app’s own code (§3, §5). Anti-tamper watchdog: fully confirmed and root-caused — a continuously-looping background thread (three independent trip conditions: debugger-attached, app-flagged-debuggable, and a byte-array-obfuscated emulator fingerprint check) silently kills the process on a randomized 15-30s interval with no exception and no tombstone, which is why it wasn’t caught in the first, shorter test pass. Live-verified surviving 60+ seconds and five full check cycles once hooked. Login credential encryption: confirmed RSA-2048/PKCS1Padding, not reversible from captured ciphertext, live plaintext-capture technique confirmed working with actual values deliberately excluded from this document (§6). Second-factor device-trust token (§7): mechanism fully traced and live-confirmed, but whether authorizeKey is safely device-bound or a replayable bearer secret is now an open item alongside signature verification (§2).
Recommended remediation priority
- Hostname verification —
mobile.banking.rest.service.gaccepts any hostname unconditionally. Even with the CA-pinning design intact, this removes a real layer of defense-in-depth; a certificate issued by the embedded CA for any name would be accepted. Fix: implement real hostname verification, or remove the custom verifier and let the default apply. - Verify the
authorizeKeydevice-trust token (§7) is actually device-bound before relying on it. If it’s a bare bearer secret, anyone who extracts it plus the account’s username/password can skip OTP entirely from a different device. This needs a replay test, not an assumption, and given it sits directly on the second factor it should be prioritized ahead of lower-severity items below. - The silent kill in §4 gives the security team zero visibility.
Process.killProcess/System.exitwith no logging, no server-side beacon, and no user-facing message means a real attacker’s instrumented session ends exactly like a random app hiccup would look to anyone watching analytics — there’s no signal that a tamper attempt happened at all. If this watchdog is meant to be a security control rather than just an inconvenience, it should report before it kills. - Root/debug detection is client-side and known-bypassable (as demonstrated) — pair with server-side attestation (Play Integrity or equivalent) rather than relying on these checks, or the watchdog in §4, as primary controls.
- The two-signal root/debug design and the three-condition watchdog are genuine (minor) positives — layering independent checks costs an attacker more effort than any single check would, which is measurable and worth keeping even while adding server-side attestation.
- Once §2 is completed: standard recommendations apply (avoid static secrets in the client — the embedded CA certificate is one — and consolidate redundant checks only after confirming none of them are silently load-bearing).
What needs to happen before this ships anywhere else
- Dedicated pass for §2 (signature/tamper self-verification) — JADX or targeted reflection/native search, not yet done.
- Replay test for §7’s
authorizeKey— extract the stored value, attempt reuse from a wiped app-data state or a differentDeviceid, confirm whether it’s device-bound or a bare replayable secret. This is the highest-value remaining test in this report. - Confirm directly (not just by elimination) whether this test AVD’s
ApplicationInfo.flagsreally hasFLAG_DEBUGGABLEset, and if so whether that’s specific to this system image or reproducible elsewhere — relevant if future testing moves to a different emulator or a physical device. - If the “patch, don’t hook” alternative in §3 is wanted for a longer unattended capture session, it hasn’t been tested — only the live Frida hook path has been verified. The same applies to §4’s watchdog: a static smali patch (replacing the
Process.killProcess/System.exitcalls, or short-circuitingya’s run() before the check chain) would be the Frida-free equivalent, not yet tried.
Appendix: the complete bypass script (gardeshgari_bypass_v1.js)
| |
Note on hooks #9/#10’s console output: these hooks log real captured plaintext to the local Frida driver’s terminal by design, that’s the point of the technique. The actual values captured during this engagement’s testing are deliberately not transcribed anywhere in this document (see §6) or elsewhere.
Driver: spawn-gated (frida.get_device('emulator-5554'), spawn + hook + resume, spawn gate registered for future relaunches), same pattern as the other two apps in this engagement. Live-verified stable for 60+ seconds and five full watchdog cycles on the Android Studio AVD (sdk_gphone64_arm64) that surfaced this finding.