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

1
2
3
android:usesCleartextTraffic="false"
android:networkSecurityConfig="@xml/network_security_config"
android:allowBackup="false"
  • Cleartext HTTP is disabled app-wide; a custom Network Security Config is used, strongly suggesting certificate pinning via NSC <pin-set> and/or OkHttp CertificatePinner.
  • allowBackup="false" rules out adb backup as 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:

CategoryPackages
Root managerscom.noshufou.android.su(.elite), eu.chainfire.supersu, com.koushikdutta.superuser, com.thirdparty.superuser, com.yellowes.su
Root cloakingcom.devadvance.rootcloak(plus), com.amphoras.hidemyroot(adfree), com.formyhm.hideroot(Premium)
Patcherscom.dimonvideo.luckypatcher, com.chelpus.lackypatch
Temp-root / quarantinecom.zachspong.temprootremovejb, com.ramdroid.appquarantine(pro)
Dynamic instrumentationasvid.github.io.fridaapp, com.github.nowsecure.objection, io.frida.server, com.example.frida
Xposed / Substratede.robv.android.xposed.installer, de.robv.android.xposed.XposedBridge, com.saurik.substrate
Other toolingcom.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 functionBase64 (in binary)Decoded valuePurpose
getAPIKeyc2VjcmV0S2V5MTIzNDU2Nw==secretKey1234567API auth key, sent on every request
getPasswordKeyJmFzcjI0KyFAIzczOTElXg==&asr24+!@#7391%^AES-128 key
getPasswordKey2bWJhbmsqJl4lMTkzN1pYQw==mbank*&^%1937ZXCAES-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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
POST /gw/banking/v2/user/register HTTP/1.1
Host: hamrahbank.qmb.ir
Is_device_rooted: true
Device_id: 5e677fe3b9835daf
App_version: 9.6.2753
Device_model: sdk_gphone64_x86_64
Net_type: 3G
Os_version: 14
Ip_address: 10.0.2.15
Platform: net
App_name: com.ada.mbank.mehr
Device_brand: Google
Os_name: ANDROID
Content-Type: application/json; charset=UTF-8

{"device":"5e677fe3b9835daf","mobile":"test","national_code":"test"}

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) and mobile are 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.
  • device is 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)

AttemptResultRoot cause
v1: Java.registerClass custom TrustManagerSecurityException: Writable dex file not allowedJava.registerClass writes a dex file at runtime; blocked on this Android 10+ emulator image
v1: hook defpackage.iu3 directlyClassNotFoundExceptionObfuscated class name differs between JADX’s static view and the runtime-loaded name/location
v2: hook SplashActivity.e1/f1/i1 directlyProgressed past Splash, but process still killedSecond enforcement layer in AbstractActivity.onCreate(), independent of SplashActivity
v2: generic Activity.finish() hook (single overload)has more than one overload errorfinish() has finish() and finish(int) overloads; must specify .overload()
v3: AbstractActivity.onCreate → call AppCompatActivity.onCreate directlyDouble-execution / vtable re-dispatchCalling the superclass implementation via Frida re-enters the overridden method through ART’s vtable
v4 (final): intercept Process.killProcess + conditionally block Activity.finish()StableBlocking 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

CheckMechanismBypass method
APK signature whitelistcomponent.a$C0026a.a() hashCode switchForce return true
Anti-debugDebug.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 classIntercept and suppress the call itself
Tool/Frida/Xposed detectionPackageManager.getPackageInfo()Throw NameNotFoundException for the 28 known tool packages
su binary presenceFile.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 proxyOkHttp hardcoded Proxy.NO_PROXYHook OkHttpClient.Builder.proxy() to force Burp’s address
Is_device_rooted header leakRequest.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

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
/*
 * mbank-bypass-v2.js
 * Target: com.ada.mbank.mehr (Hamrah Bank "Mehr", v9.6.2753)
 * Consolidated bypass: signature check, anti-debug, root detection
 * (both enforcement layers), tool/Frida/Xposed detection, SSL pinning
 * (Conscrypt + OkHttp, multi-layer), Burp proxy injection, and
 * device-fingerprint header rewriting.
 *
 * Usage:
 *   frida -U -f com.ada.mbank.mehr -l mbank-bypass-v2.js --no-pause
 */

Java.perform(function () {

    // ══════════════════════════════════════════════
    // 1. SIGNATURE CHECK — component.a$C0026a.a()
    //    Hard kill via j1()/System.exit(0) if this returns false.
    // ══════════════════════════════════════════════
    try {
        var SignChecker = Java.use('com.ada.mbank.component.a$C0026a');
        SignChecker.a.implementation = function () {
            console.log('[+] SignChecker.a() -> true');
            return true;
        };
    } catch (e) {
        try {
            var SignCheckerAlt = Java.use('com.ada.mbank.component.a$a');
            SignCheckerAlt.a.implementation = function () {
                console.log('[+] SignChecker$a.a() -> true');
                return true;
            };
        } catch (e2) { console.log('[-] SignChecker: ' + e2); }
    }
    try {
        var SignOuter = Java.use('com.ada.mbank.component.a');
        SignOuter.a.overload().implementation = function () {
            console.log('[+] SignChecker outer.a() -> true');
            return true;
        };
    } catch (e) { console.log('[-] SignChecker outer: ' + e); }

    // ══════════════════════════════════════════════
    // 2. ANTI-DEBUG
    // ══════════════════════════════════════════════
    var Debug = Java.use('android.os.Debug');
    Debug.isDebuggerConnected.implementation = function () {
        return false;
    };

    // ══════════════════════════════════════════════
    // 3. SPLASHACTIVITY — short-circuit the entire
    //    tool/root/signature gate chain (i1 -> e1 -> f1 -> B1)
    // ══════════════════════════════════════════════
    try {
        var Splash = Java.use('com.ada.mbank.component.SplashActivity');

        Splash.i1.implementation = function () {
            console.log('[+] SplashActivity.i1() -- skipping lz3.d() gate');
            this.e1();
        };
        Splash.e1.implementation = function () {
            console.log('[+] SplashActivity.e1() bypassed -> calling f1()');
            this.f1();
        };
        Splash.f1.implementation = function () {
            console.log('[+] SplashActivity.f1() (root check) bypassed -> B1()');
            this.J1(true);
            this.B1();
        };
        console.log('[+] SplashActivity hooks active');
    } catch (e) { console.log('[-] SplashActivity hooks: ' + e); }

    // ══════════════════════════════════════════════
    // 4. PACKAGEMANAGER — block queries for every
    //    root/Frida/Xposed/tool package from the manifest
    // ══════════════════════════════════════════════
    var BLOCKED = [
        'com.noshufou.android.su', 'com.noshufou.android.su.elite',
        'eu.chainfire.supersu', 'com.koushikdutta.superuser',
        'com.thirdparty.superuser', 'com.yellowes.su',
        'com.zachspong.temprootremovejb', 'com.ramdroid.appquarantine',
        'com.ramdroid.appquarantinepro', 'com.devadvance.rootcloak',
        'com.devadvance.rootcloakplus', 'com.amphoras.hidemyroot',
        'com.amphoras.hidemyrootadfree', 'com.formyhm.hiderootPremium',
        'com.formyhm.hideroot', 'com.dimonvideo.luckypatcher',
        'com.chelpus.lackypatch', 'com.koushikdutta.rommanager',
        'com.koushikdutta.rommanager.license',
        'asvid.github.io.fridaapp', 'com.github.nowsecure.objection',
        'io.frida.server', 'com.example.frida',
        'de.robv.android.xposed.installer', 'de.robv.android.xposed.XposedBridge',
        'com.saurik.substrate', 'com.android.SSLTrustKiller',
        'com.mwr.dz', 'com.introspy.config', 'com.introspy.core',
    ];
    var PM = Java.use('android.app.ApplicationPackageManager');
    var NNFE = Java.use('android.content.pm.PackageManager$NameNotFoundException');
    PM.getPackageInfo.overload('java.lang.String', 'int').implementation = function (pkg, flags) {
        if (BLOCKED.indexOf(pkg) !== -1) {
            console.log('[+] PM blocked: ' + pkg);
            throw NNFE.$new(pkg);
        }
        return this.getPackageInfo(pkg, flags);
    };

    // ══════════════════════════════════════════════
    // 5. FILE SYSTEM — hide su binaries
    // ══════════════════════════════════════════════
    var File = Java.use('java.io.File');
    var SU_PATHS = [
        '/system/bin/su', '/system/xbin/su', '/sbin/su', '/su/bin/su',
        '/data/local/su', '/data/local/bin/su', '/data/local/xbin/su',
        '/system/sd/xbin/su', '/system/bin/failsafe/su',
    ];
    File.exists.implementation = function () {
        var path = this.getAbsolutePath();
        if (SU_PATHS.indexOf(path) !== -1) {
            console.log('[+] File.exists() hiding: ' + path);
            return false;
        }
        return this.exists();
    };

    // ══════════════════════════════════════════════
    // 6. SSL PINNING — multi-layer bypass
    //    (no Java.registerClass — avoids SecurityException
    //    on Android 10+ emulator images)
    // ══════════════════════════════════════════════
    try {
        var ConscryptTM = Java.use('com.android.org.conscrypt.TrustManagerImpl');
        ConscryptTM.verifyChain.implementation = function (a, b, host, c, d, e) {
            console.log('[+] Conscrypt.verifyChain bypassed: ' + host);
            return a;
        };
    } catch (e) { console.log('[-] Conscrypt: ' + e); }

    try {
        var CP = Java.use('okhttp3.CertificatePinner');
        CP.check.overload('java.lang.String', 'java.util.List').implementation = function (h, c) {
            console.log('[+] OkHttp CertPinner.check() bypassed: ' + h);
        };
    } catch (e) { console.log('[-] OkHttp CP list: ' + e); }
    try {
        var CP2 = Java.use('okhttp3.CertificatePinner');
        CP2.check.overload('java.lang.String', 'kotlin.jvm.functions.Function0').implementation = function (h, f) {
            console.log('[+] OkHttp CertPinner.check() kotlin bypassed: ' + h);
        };
    } catch (e) {}

    try {
        var TrustManagerExt = Java.use('android.net.http.X509TrustManagerExtensions');
        TrustManagerExt.checkServerTrusted.implementation = function (chain, authType, host) {
            console.log('[+] X509TrustManagerExtensions.checkServerTrusted bypassed: ' + host);
            return Java.use('java.util.Arrays').asList(chain);
        };
    } catch (e) { console.log('[-] X509TrustManagerExt: ' + e); }

    try {
        var SSLCtx = Java.use('javax.net.ssl.SSLContext');
        SSLCtx.init.implementation = function (km, tm, sr) {
            console.log('[+] SSLContext.init -> tm nulled');
            this.init(km, null, sr);
        };
    } catch (e) { console.log('[-] SSLCtx: ' + e); }

    try {
        var HttpsURLConn = Java.use('javax.net.ssl.HttpsURLConnection');
        HttpsURLConn.setDefaultHostnameVerifier.implementation = function (v) {
            console.log('[+] HttpsURLConnection hostname verifier suppressed');
        };
    } catch (e) {}

    try {
        var Builder = Java.use('okhttp3.OkHttpClient$Builder');
        Builder.certificatePinner.implementation = function (pinner) {
            console.log('[+] OkHttpClient.Builder.certificatePinner() -> noop');
            return this;
        };
        Builder.hostnameVerifier.implementation = function (verifier) {
            console.log('[+] OkHttpClient.Builder.hostnameVerifier() -> noop');
            return this;
        };
        Builder.sslSocketFactory.overload(
            'javax.net.ssl.SSLSocketFactory',
            'javax.net.ssl.X509TrustManager'
        ).implementation = function (sf, tm) {
            console.log('[+] OkHttpClient.Builder.sslSocketFactory() -> noop');
            return this;
        };

        // Force OkHttp through Burp even if the app hardcodes Proxy.NO_PROXY
        try {
            var ProxyClass   = Java.use('java.net.Proxy');
            var ProxyType    = Java.use('java.net.Proxy$Type');
            var InetSockAddr = Java.use('java.net.InetSocketAddress');
            var burpAddr     = InetSockAddr.createUnresolved('10.0.2.2', 8080); // emulator -> host
            var burpProxy    = ProxyClass.$new(ProxyType.HTTP.value, burpAddr);

            Builder.proxy.implementation = function (p) {
                console.log('[+] OkHttpClient.Builder.proxy() -> Burp forced');
                return this.proxy(burpProxy);
            };
        } catch (ep) { console.log('[-] OkHttp proxy inject: ' + ep); }
    } catch (e) { console.log('[-] OkHttpClient.Builder hooks: ' + e); }

    // ══════════════════════════════════════════════
    // 7. EMULATOR TOAST — cosmetic only, silence it
    // ══════════════════════════════════════════════
    try {
        var Toast = Java.use('android.widget.Toast');
        Toast.show.implementation = function () { /* suppressed */ };
    } catch (e) {}

    // ══════════════════════════════════════════════
    // 8. KILL INTERCEPTORS
    //    Second enforcement layer (AbstractActivity.onCreate)
    //    cannot be bypassed by patching SplashActivity alone.
    //    Intercept the terminal effects directly instead.
    // ══════════════════════════════════════════════

    // Activity.finish() -- allow SplashActivity's own normal
    // Splash->Register transition, block every other mbank finish()
    try {
        var Activity = Java.use('android.app.Activity');
        Activity.finish.overload().implementation = function () {
            var name = this.getClass().getName();
            if (name.indexOf('mbank') === -1) {
                this.finish.overload().call(this);
                return;
            }
            if (name.indexOf('SplashActivity') !== -1) {
                console.log('[+] SplashActivity.finish() allowed (normal flow)');
                this.finish.overload().call(this);
                return;
            }
            var Exception = Java.use('java.lang.Exception');
            var Log = Java.use('android.util.Log');
            console.log('[!] Activity.finish() blocked on: ' + name);
            console.log(Log.getStackTraceString(Exception.$new('finish')));
            // suppressed -- activity stays alive
        };
    } catch (e) { console.log('[-] Activity.finish hook: ' + e); }

    // System.exit -- diagnostic + suppression
    try {
        var SystemCls = Java.use('java.lang.System');
        SystemCls.exit.implementation = function (code) {
            var Exception = Java.use('java.lang.Exception');
            var Log = Java.use('android.util.Log');
            console.log('[!] System.exit(' + code + ') intercepted -- stack:');
            console.log(Log.getStackTraceString(Exception.$new('exit')));
        };
    } catch (e) { console.log('[-] System.exit hook: ' + e); }

    // Process.killProcess -- the AbstractActivity 2nd-layer kill
    try {
        var OsProcess = Java.use('android.os.Process');
        OsProcess.killProcess.implementation = function (pid) {
            var Exception = Java.use('java.lang.Exception');
            var Log = Java.use('android.util.Log');
            console.log('[!] Process.killProcess(' + pid + ') intercepted -- stack:');
            console.log(Log.getStackTraceString(Exception.$new('kill')));
        };
    } catch (e) { console.log('[-] Process.killProcess hook: ' + e); }

    console.log('[+] AbstractActivity kills handled via killProcess+finish intercepts');

    // ══════════════════════════════════════════════
    // 9. HEADER MANIPULATION
    //    Rewrite device-fingerprint headers before they
    //    leave the device, catching both Request.Builder
    //    entry points OkHttp exposes.
    // ══════════════════════════════════════════════
    try {
        var RequestBuilder = Java.use('okhttp3.Request$Builder');

        function rewriteHeader(name, value) {
            var n = name.toLowerCase();
            if (n === 'is_device_rooted') return 'false';
            if (n === 'device_model')     return 'SM-G991B';
            if (n === 'device_brand')     return 'samsung';
            return value;
        }

        RequestBuilder.addHeader.implementation = function (name, value) {
            var v = rewriteHeader(name, value);
            if (v !== value) console.log('[+] Header rewrite: ' + name + ' -> ' + v);
            return this.addHeader(name, v);
        };
        RequestBuilder.header.implementation = function (name, value) {
            var v = rewriteHeader(name, value);
            if (v !== value) console.log('[+] Header rewrite: ' + name + ' -> ' + v);
            return this.header(name, v);
        };

        console.log('[+] Header manipulation hooks active');
    } catch (e) { console.log('[-] Header hooks: ' + e); }

    console.log('[*] mbank bypass v2 loaded -- all layers active');
});

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Java.perform(function () {
    var SystemCls = Java.use('java.lang.System');
    SystemCls.exit.implementation = function (code) {
        var Exception = Java.use('java.lang.Exception');
        var Log = Java.use('android.util.Log');
        console.log('[!] System.exit(' + code + ') intercepted -- stack:');
        console.log(Log.getStackTraceString(Exception.$new('exit')));
    };

    var OsProcess = Java.use('android.os.Process');
    OsProcess.killProcess.implementation = function (pid) {
        var Exception = Java.use('java.lang.Exception');
        var Log = Java.use('android.util.Log');
        console.log('[!] Process.killProcess(' + pid + ') intercepted -- stack:');
        console.log(Log.getStackTraceString(Exception.$new('kill')));
    };
});

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Route emulator traffic through Burp on the host
adb shell settings put global http_proxy 10.0.2.2:8080

# Burp Suite config required:
#   Proxy -> Options -> Listener binding: All interfaces (not Loopback only)
#   Proxy -> Intercept: OFF (otherwise requests queue silently)

# Install Burp's CA into the system trust store (Android 7+ requires this
# for any store trusting system/ or for apps that don't honor user certs)
adb root && adb remount
openssl x509 -inform DER -in burp.cer -out burp.pem
HASH=$(openssl x509 -inform PEM -subject_hash_old -in burp.pem | head -1)
cp burp.pem ${HASH}.0
adb push ${HASH}.0 /system/etc/security/cacerts/
adb shell chmod 644 /system/etc/security/cacerts/${HASH}.0
adb reboot

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:

1
2
3
4
5
6
7
8
9
apktool d mehr_product_website_release_9.6.2753.apk -o mbank_decoded
# locate + patch:
#   smali*/com/ada/mbank/component/a$C0026a.smali   -> force a()Z to return 1
#   smali*/com/ada/mbank/component/AbstractActivity.smali -> remove/guard the
#       finish()/killProcess() calls in onCreate()
#   res/xml/network_security_config.xml -> add <certificates src="user"/>
apktool b mbank_decoded -o mbank_patched.apk
apksigner sign --ks pentest.keystore --ks-key-alias pentest mbank_patched.apk
adb install -r mbank_patched.apk

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

#FindingImpactRecommendation
1Root/tamper trust signal (Is_device_rooted) is purely client-assertedMediumCorroborate with server-side attestation (Play Integrity API) before trusting this header for fraud/risk decisions
2Hardcoded API key and AES key/IV in native library, trivially extractable via static binary analysisHighMove to a backend-issued, short-lived token model; do not rely on a static shared secret embedded in the client for API authentication
3Static AES key/IV pair used for password encryption — identical for every install of the appHighUse 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
4No input validation observed on national_code / mobile in the sampled register requestMedium (needs further testing)Validate format and existence server-side; rate-limit and monitor for enumeration
5Redundant but ultimately bypassable client-side integrity controls (signature check, root detection, SSL pinning)InformationalClient-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, and Activity.finish globally 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.registerClass is unreliable on modern (Android 10+) emulator/device images due to writable-dex restrictions; prefer direct method implementation overrides wherever an equivalent exists (e.g. nulling SSLContext’s TrustManager[] instead of supplying a custom one).
  • A hardcoded Proxy.NO_PROXY inside 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 .so data 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.