This post covers a full reverse-engineering and dynamic instrumentation assessment of Hamrah Bank’s Mehr Android app (com.ada.mbank.mehr), confirming a two-layer anti-tampering chain — signature verification, root/debugger/Frida detection, and SSL pinning in both SplashActivity and AbstractActivity. It shows how all of it is bypassed with one consolidated Frida script, and how three hardcoded secrets — an API key and an AES key/IV pair — were extracted from the native library.
- Target: Mehr (Hamrah Bank mobile banking app)
- Package:
com.ada.mbank.mehr - Version tested: 9.6.2753
Tester: Admiral
1. Executive Summary
This report documents a full reverse-engineering and dynamic instrumentation
exercise against an Iranian mobile banking application. The app implements a
multi-layered anti-tampering and anti-analysis defense, including APK
signature verification, root detection, debugger detection, Frida/Xposed
tooling detection, and SSL certificate pinning, enforced redundantly at two
separate points in the application lifecycle (SplashActivity and a base
AbstractActivity class inherited by every screen).
All layers were identified through static analysis (JADX for Java/Kotlin, Ghidra for the native ARM64 library) and bypassed dynamically using a single consolidated Frida script. Full HTTPS traffic interception was subsequently achieved via Burp Suite. Three hardcoded secrets (an API key and an AES key/IV pair) were extracted directly from the native library’s data segment.
2. Static Analysis Findings
2.1 AndroidManifest.xml
| |
- Cleartext HTTP is disabled app-wide; a custom Network Security Config is
used, strongly suggesting certificate pinning via NSC
<pin-set>and/or OkHttpCertificatePinner. allowBackup="false"rules outadb backupas a data-extraction vector.
The <queries> block enumerates the exact set of packages the app actively
probes for via PackageManager, which doubles as a readable threat model of
what the developers consider a hostile environment:
| Category | Packages |
|---|---|
| Root managers | com.noshufou.android.su(.elite), eu.chainfire.supersu, com.koushikdutta.superuser, com.thirdparty.superuser, com.yellowes.su |
| Root cloaking | com.devadvance.rootcloak(plus), com.amphoras.hidemyroot(adfree), com.formyhm.hideroot(Premium) |
| Patchers | com.dimonvideo.luckypatcher, com.chelpus.lackypatch |
| Temp-root / quarantine | com.zachspong.temprootremovejb, com.ramdroid.appquarantine(pro) |
| Dynamic instrumentation | asvid.github.io.fridaapp, com.github.nowsecure.objection, io.frida.server, com.example.frida |
| Xposed / Substrate | de.robv.android.xposed.installer, de.robv.android.xposed.XposedBridge, com.saurik.substrate |
| Other tooling | com.android.SSLTrustKiller, com.mwr.dz (Drozer), com.introspy.config, com.introspy.core |
A flutterEmbedding=2 / flutterProjectType=module meta-data pair confirms
the app is a hybrid native + Flutter module — some screens are rendered
by a FlutterActivity and are not visible to JADX; a Dart-level tool (e.g.
blutter) would be required to analyze those flows, which was out of scope
for this engagement.
2.2 Security Call Chain — SplashActivity
Full flow reconstructed from decompiled Kotlin:
onCreate()
├── g1() → emulator check [com.ada.mbank.component.b$b.c()] → toast only, non-blocking
└── background thread → E1()
├── component.a$C0026a.a() → [SIGNATURE CHECK] → false ⇒ j1() ⇒ System.exit(0)
└── i1()
└── lz3.d() → e1()
├── (debuggable flag | Debug.isDebuggerConnected()) → warning dialog
├── iu3.x() → [TOOL / FRIDA / XPOSED DETECTION] → warning dialog
├── lz3.c() → [SIGNATURE CHECK, 2nd site] → j1() ⇒ System.exit(0)
└── f1()
└── iu3.u() → [ROOT CHECK] → dialog, or kill if
`restrict_rooted_devices=true`
Signature check (fully decompiled): component.a$C0026a.a() reads the
APK’s signing certificate via PackageManager.GET_SIGNATURES, computes
signature.toCharsString().hashCode(), and compares it against 14
hardcoded integer constants in a switch statement. Any signature outside
that whitelist (including a self-resigned APK) returns false.
2.3 Second Enforcement Layer — AbstractActivity
Critically, root/tamper enforcement is not confined to SplashActivity.
Every activity in the app extends AbstractActivity, whose onCreate()
independently re-checks device state and, on failure, calls:
AbstractActivity.onCreate():4 → Activity.finish()
AbstractActivity.onCreate():5 → Process.killProcess(pid)
This was discovered empirically: bypassing all SplashActivity checks still
resulted in the process being killed immediately upon RegisterActivity
launching, confirmed via Frida stack-trace interception (§4.4).
2.4 Native Library — libnative-lib.so
Architecture: AARCH64, 45 functions, 3 JNI exports:
Java_com_ada_mbank_network_BaseModel_BaseRequest_getAPIKey
Java_com_ada_mbank_util_PasswordUtil_getPasswordKey
Java_com_ada_mbank_util_PasswordUtil_getPasswordKey2
Each function follows an identical pattern: build a base64 string from
a data-segment literal → base64_decode() → return via
NewStringUTF (JNIEnv+0x538). The base64 literals were read directly from
the binary’s .rodata segment via Ghidra’s memory inspector, at offsets
0x101500–0x101560.
Decoded secrets:
| Native function | Base64 (in binary) | Decoded value | Purpose |
|---|---|---|---|
getAPIKey | c2VjcmV0S2V5MTIzNDU2Nw== | secretKey1234567 | API auth key, sent on every request |
getPasswordKey | JmFzcjI0KyFAIzczOTElXg== | &asr24+!@#7391%^ | AES-128 key |
getPasswordKey2 | bWJhbmsqJl4lMTkzN1pYQw== | mbank*&^%1937ZXC | AES-128 IV (CBC mode) |
Both JNI functions are named getPasswordKey/getPasswordKey2, which —
combined with the 16-byte length of both values — strongly indicates
AES-128-CBC is used to encrypt the password field client-side before
submission, with the first value as key and the second as IV.
3. Server-Side Observation — Device Fingerprint Headers
Once traffic was intercepted in Burp, every request was found to carry a
full device-fingerprint header block, populated from SharedPreferences
values written by the client-side security checks above:
| |
Finding: Is_device_rooted: true is derived from the client-side root
check (iu3.u()) and sent in plaintext to the server as a trust signal.
Because the determination happens entirely on-device with no server-side
corroboration (e.g. SafetyNet / Play Integrity attestation), this header is
fully attacker-controlled and can be rewritten in transit — demonstrated
in §4.6. Any backend risk/fraud logic that trusts this header as a hard
signal is bypassable by any client capable of intercepting its own traffic.
Additional attack-surface notes from the observed register endpoint:
national_code(Iranian national ID, 10 digits) andmobileare accepted with no apparent format validation in this sample request ("test"accepted for both) — recommend fuzzing for format-string, injection, and enumeration behavior server-side.deviceis a static, client-generated fingerprint reused across sessions with no apparent binding to a hardware attestation value.
4. Dynamic Instrumentation — Bypass Methodology
4.1 Iteration Log (what failed and why)
| Attempt | Result | Root cause |
|---|---|---|
v1: Java.registerClass custom TrustManager | SecurityException: Writable dex file not allowed | Java.registerClass writes a dex file at runtime; blocked on this Android 10+ emulator image |
v1: hook defpackage.iu3 directly | ClassNotFoundException | Obfuscated class name differs between JADX’s static view and the runtime-loaded name/location |
v2: hook SplashActivity.e1/f1/i1 directly | Progressed past Splash, but process still killed | Second enforcement layer in AbstractActivity.onCreate(), independent of SplashActivity |
v2: generic Activity.finish() hook (single overload) | has more than one overload error | finish() has finish() and finish(int) overloads; must specify .overload() |
v3: AbstractActivity.onCreate → call AppCompatActivity.onCreate directly | Double-execution / vtable re-dispatch | Calling the superclass implementation via Frida re-enters the overridden method through ART’s vtable |
v4 (final): intercept Process.killProcess + conditionally block Activity.finish() | Stable | Blocking the effects (kill/finish) rather than trying to re-route control flow avoids all vtable/dispatch issues |
Lesson: when a security check is enforced redundantly across multiple
classes/layers, it is more robust to hook the terminal side-effects
(System.exit, Process.killProcess, Activity.finish) than to try to
patch every individual check site — especially when some of those sites
resolve to obfuscated/unstable class names at runtime.
4.2 Bypass Coverage Achieved
| Check | Mechanism | Bypass method |
|---|---|---|
| APK signature whitelist | component.a$C0026a.a() hashCode switch | Force return true |
| Anti-debug | Debug.isDebuggerConnected() | Force return false |
| Root detection (Splash) | iu3.u() / SplashActivity.f1() | Short-circuit to normal flow |
| Root/tamper (AbstractActivity, 2nd layer) | Process.killProcess / Activity.finish in base class | Intercept and suppress the call itself |
| Tool/Frida/Xposed detection | PackageManager.getPackageInfo() | Throw NameNotFoundException for the 28 known tool packages |
| su binary presence | File.exists() | Return false for all known su paths |
| SSL pinning (Conscrypt) | TrustManagerImpl.verifyChain() | Return chain unverified |
| SSL pinning (OkHttp internal) | X509TrustManagerExtensions.checkServerTrusted() | Return chain as-is |
SSL pinning (OkHttp3 CertificatePinner) | .check() (both overloads) | No-op |
| SSL pinning (SSLContext) | SSLContext.init() | Null the TrustManager[] |
| Traffic not reaching proxy | OkHttp hardcoded Proxy.NO_PROXY | Hook OkHttpClient.Builder.proxy() to force Burp’s address |
Is_device_rooted header leak | Request.Builder.addHeader/header() | Rewrite value to false in transit; also normalizes Device_model/Device_brand to a real device profile |
4.3 Final Consolidated Frida Script
| |
4.4 Diagnostic Pattern Used to Find the 2nd Enforcement Layer
When the app continued dying after all SplashActivity checks were
neutralized, the following diagnostic hooks were added to capture the exact
call site via stack trace rather than guessing:
| |
This immediately surfaced:
java.lang.Exception: kill
at android.os.Process.killProcess(Native Method)
at com.ada.mbank.component.AbstractActivity.onCreate(AbstractActivity.java:5)
at com.ada.mbank.component.BaseActivity.onCreate(BaseActivity.java:1)
at com.ada.mbank.component.RegisterActivity.onCreate(RegisterActivity.java:1)
...
— confirming the second, independent enforcement point and exactly which line triggers it, without needing to resolve the obfuscated class names involved in the actual boolean check itself.
4.5 Network Interception Setup
| |
4.6 Result Confirmation
[+] Conscrypt.verifyChain bypassed: hamrahbank.qmb.ir
[+] X509TrustManagerExtensions.checkServerTrusted bypassed: hamrahbank.qmb.ir
Both independent SSL-validation code paths were observed firing and being
suppressed for the production host hamrahbank.qmb.ir, after which full
plaintext HTTP history became visible in Burp, including the register
request reproduced in §3.
5. Static Alternative — Smali Patching (Documented, Not Executed)
For completeness, the equivalent static (no-Frida) bypass path was documented for future use, since this target’s own signature check complicates it:
| |
Caveat specific to this app: because component.a$C0026a.a() verifies
the APK’s own signing certificate, the signature-check smali patch above is
a prerequisite for any resign — without it, re-signing with any key other
than the original developer key still fails the check and the app
self-terminates at first launch, regardless of what else is patched.
6. Summary of Findings & Recommendations
| # | Finding | Impact | Recommendation |
|---|---|---|---|
| 1 | Root/tamper trust signal (Is_device_rooted) is purely client-asserted | Medium | Corroborate with server-side attestation (Play Integrity API) before trusting this header for fraud/risk decisions |
| 2 | Hardcoded API key and AES key/IV in native library, trivially extractable via static binary analysis | High | Move to a backend-issued, short-lived token model; do not rely on a static shared secret embedded in the client for API authentication |
| 3 | Static AES key/IV pair used for password encryption — identical for every install of the app | High | Use per-session ephemeral keys (e.g. negotiated via TLS-bound key exchange) rather than a hardcoded symmetric key, which, once extracted once, decrypts every client’s traffic |
| 4 | No input validation observed on national_code / mobile in the sampled register request | Medium (needs further testing) | Validate format and existence server-side; rate-limit and monitor for enumeration |
| 5 | Redundant but ultimately bypassable client-side integrity controls (signature check, root detection, SSL pinning) | Informational | Client-side controls meaningfully raise the bar against unsophisticated tampering but cannot be treated as a security boundary; sensitive business logic (fraud scoring, transaction authorization) must not depend on these checks holding |
7. Appendix — Methodology Notes for Future Engagements
- When a kill/exit is observed but its source cannot be located via static
analysis of the expected class, hook
System.exit,Process.killProcess, andActivity.finishglobally with stack-trace logging before attempting any targeted bypass — this collapses “where is it killing me” from a search problem into a one-shot diagnostic. - Prefer hooking terminal side effects over re-routing control flow when a security check is enforced at multiple, possibly redundant, sites — re-invoking a superclass method manually through Frida can trigger ART vtable re-dispatch and re-execute the very code being bypassed.
Java.registerClassis unreliable on modern (Android 10+) emulator/device images due to writable-dex restrictions; prefer direct method implementation overrides wherever an equivalent exists (e.g. nullingSSLContext’sTrustManager[]instead of supplying a custom one).- A hardcoded
Proxy.NO_PROXYinside an app’s HTTP client is a distinct failure mode from SSL pinning and requires its own bypass (hooking the client builder’s.proxy()method) even after all pinning is defeated. - Static analysis (JADX class/method tracing, Ghidra memory inspection of
native
.sodata segments) should always precede Frida work: every hook written above was only possible because the corresponding check, class, or secret location had first been identified statically.