Dynamic Code Injection with Frida – Hooking the InsecureBankv2 App

Search for a command to run...

No comments yet. Be the first to comment.
Let’s build a Secure Personal AI API with Ollama, Nginx, and Cloudflare Tunnel using oracle ubuntu instance Prerequisites and Target Audience ⚠️ Important Notice: This is not a beginner-friendly tutorial. This guide assumes you have practical, hands-...

Introduction Running applications on Oracle Cloud Infrastructure (OCI) requires more than just starting your server—you need a robust setup that ensures your services stay running, restart automatically after crashes, and survive system reboots. This...

Ever found yourself in one of these situations? "Can you check my website?" but your app is running on localhost:3000 Need to test webhooks from external services but they can't reach your local machine Want to show a client your work-in-progress ...

This article walks you through every single file required to get a secure, refresh-token-enabled JWT authentication system in NestJS with Prisma, bcrypt, Passport, and class-validator.Copy / paste the snippets in order and you will have a working pro...

Introduction to Amazon EC2 Compute refers to the processing power needed to run applications, manage data, and perform calculations. In the cloud, this power is available on-demand. You can access it remotely without owning or maintaining physical ha...
Demonstrate how to intercept and manipulate sensitive app functionality using Frida to bypass login checks on the InsecureBankv2 app.
✅ Frida installed on your PC (pip install frida-tools)
✅ Rooted Android emulator/device (Genymotion or similar)
✅ InsecureBankv2 APK installed and running on the device
✅ USB debugging enabled (or virtual ADB over Genymotion)
Frida is a powerful tool used by developers and ethical hackers to inspect, modify, and control apps while they are running. Think of it like a "microscope" that lets you look inside an app and change what it does — without changing the actual app code.
✅ Common Uses:
Debugging mobile apps
Bypassing root detection
Hooking functions to see how they work
Genymotion ADB (Android Debug Bridge) connects your computer to a Genymotion virtual Android device. It works the same way as it does with a real phone.
✅ Why Use It?
Easy to test apps on different Android versions
Run scripts, install apps, and debug smoothly
Great for automation and security testing
ADB Shell lets you open a terminal directly inside the Android device (real or virtual). You can run commands to control the device or inspect files.
✅ What You Can Do:
Access system directories
Modify app files or settings
Run commands like pm list packages, am start, etc.
Now you understand the basic term required for the dynamic code injection. we will then proceed to installing those requirements
If you are a window user then you must need to install virtual box with creating a virtual environment for installation of kali linux on virtual box and perform the operation on linux machine.
Make sure Python and pip are available:
sudo apt update
sudo apt install python3 python3-pip -y
Then install Frida:
pip3 install frida-tools
Check version to confirm:
frida --version
ADB is needed to connect your PC to the Android emulator:
sudo apt install android-tools-adb -y
Download Genymotion from: https://www.genymotion.com/
Install and launch a rooted virtual device directly from Genymotion.
Enable ADB over network in the emulator settings.
Connect to the emulator:
adb connect <your_emulator_ip>:5555
adb devices
Download the APK, then install it on the emulator:
You will get problem to download the apk. so don’t worry here i’ll provide you a direct link.
App Link: https://github.com/dineshshetty/Android-InsecureBankv2/raw/master/InsecureBankv2.apk
adb install InsecureBankv2.apk
Make sure the app runs on the emulator.
On Genymotion, USB debugging is pre-enabled. Just connect using the IP shown in the emulator.
Look your phone is not rooted at this point so i prefer you to use genymotion we talk about earlier. Once you've installed Frida on your Kali Linux or Ubuntu system and set up a rooted Android device/emulator (like Genymotion), it’s time to set up the Frida Server to start hooking into Android apps.
Frida server must match the Frida version installed on your PC and the CPU architecture of your Android device (e.g., arm, arm64, x86, x86_64).
Check your Frida version:
frida --version
Go to: https://github.com/frida/frida/releases
Download the server binary like:
frida-server-<version>-android-x86_64.xz (for Genymotion)
OR
frida-server-<version>-android-arm64.xz (for real phones)
Extract the binary:
tar -xf frida-server-*.xz
Make sure ADB is connected:
adb devices
Push and set permissions:
adb push frida-server /data/local/tmp/
adb shell "chmod 755 /data/local/tmp/frida-server"
Now open an ADB shell and run the server as root step by step one after another:
adb shell
su
cd /data/local/tmp/
./frida-server &
✅ You should now have Frida server running in the background on your device.
List running processes (check if your target app is visible):
frida-ps -U
-U stands for USB device (or connected emulator).
List only apps:
frida-ps -Uai
-a = applications only
-i = include app identifiers (package names)
To attach to an app (e.g., InsecureBankv2), find the package name (like com.android.insecurebankv2) using frida-ps, then:
frida -U -n com.android.insecurebankv2
Sometimes com.android.insecurebankv2 might not work so in that situation
frida -U -p 3990
This attaches Frida to the app’s running process. Here 3990 is pid obtained from “frida-ps -Uai” command line. Then you will enter into frida REPL.
hook-login.jsNow that Frida is running, let's create a custom script to hook into the app's login function.
Create a file called hook-login.js with the following content:
jsCopyEditJava.perform(function () {
var loginClass = Java.use("com.android.insecurebankv2.LoginActivity");
loginClass.performlogin.implementation = function () {
console.log("🔒 performlogin() hooked!");
// Skip original logic
console.log("✅ Login bypassed (fake success)");
};
});
We're telling Frida:
“Hey, whenever the
performlogin()function is called in the app, don’t do the real logic. Just show a fake success.”
This lets us bypass the actual login check — useful for testing how the app handles sessions, authentication logic, or insecure code.
Now use Frida to inject the hook into the running app.
First, find the app’s PID (process ID):
frida-ps -U
Then inject the script:
frida -U -p <PID> -l hook-login.js
Example:
frida -U -p 3990 -l hook-login.js
✅ If successful, Frida will inject your script, and you’ll return to a prompt where you can see logs printed from your hook.
Go back to the app and enter any credentials, even invalid ones.
If the hook works, you’ll see in the Frida console:
scssCopyEdit🔒 performlogin() hooked!
✅ Login bypassed (fake success)