Android APK Reverse Engineering — A Practical Guide

Full walkthrough from APK extraction to patching, including integrity check bypass and Frida-based permanent patching

androidreverse-engineeringsecurityfrida

Tools

Guide

Preparing the App

Using AntiSplit-M:

  1. Download and install AntiSplit-M from GitHub
  2. Click ‘Select from Installed Apps’
  3. Select the app from the list
  4. Save to default location (/sdcard)
  5. Connect device to adb
  6. Run:
Bash Bash

Direct from Android package manager:

  1. List packages:

    Bash Bash
  2. Identify the package name

  3. Get path:

    Bash Bash
  4. Pull APKs:

    Bash Bash
  5. If split APK, merge with AntiSplit-M

Downloading from the internet:

  1. Search for the APK
  2. Choose reliable source (APKMirror, APKPure, F-Droid)
  3. Download APK/APKS/XAPK
  4. If split, merge with AntiSplit-M

Bypassing Integrity Protections

After installing the unmodified but merged APK, the app crashed quickly due to signature changing. Logcat showed an error from native function verifyNativeIntegrity called from function x1.

Using JADX: search for the function definition, find the class, look for System.LoadLibrary to identify which native library to investigate.

Extract the library from libs folder in JADX, open in Ghidra or IDA. Look for functions beginning with Java_ (JNI callable methods). In this case, verifyNativeIntegrity returns a boolean — patching means forcing return value to true.

Two approaches: patching the library with Ghidra, or patching with Frida.

Frida approach:

Create frida-gadget.config:

frida-gadget.config
JSON JSON

Create frida.js to patch the native function:

frida.js
JavaScript JavaScript

Patch the APK:

Bash Bash

Then run:

Bash Bash

The app still closed but with “System.exit called” — more integrity checks. Search for System.exit in JADX — it’s called in 5 places. Hook it with Frida:

integrity3.png
integrity4.png
integrity5.png
JavaScript JavaScript

This reveals the calling function. Navigate to it in JADX.

checkPNAndAdIdWrapper renamed in JADX

Note: checkPNAndAdIdWrapper has been renamed in JADX to make decompilation easier. It is good practice to do similar if you can work out the purpose of any methods.

The function checkPNAndAdIdWrapper calls several integrity checks — signature checking, package name checks, etc.

Integrity checks in JADX

Since these all go through K1, patch K1:

JavaScript JavaScript

Killing RootBeerFresh (Root Detection)

JADX shows com.kimchangyoun.rootbeerFresh package.

RootBeerFresh package

RootBeerFresh details

RootBeer methods called in a single function that returns false if no triggers hit. Patch it:

JavaScript JavaScript

Permanently Patching the App

Once all patches work, make the Frida script run automatically. Edit frida-gadget.config:

frida-gadget.config
JSON JSON

Rebuild and patch with Objection:

Bash Bash