Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Practice library / Mobile

Lab · Medium · 1.5 hoursFree account

Android Dynamic Analysis

Frida hooking, SSL unpinning, and runtime method tracing on Android.

  • android
  • dynamic-analysis
  • frida
  • ssl-unpinning
On this page 13 sections
  1. ·Prerequisites
  2. ·Lab Setup
  3. ·Build the target
  4. 1Create and start the emulator
  5. 2Install the app and start it
  6. Locked: Read the app log
  7. Locked: Read the app files while it runs
  8. Locked: Intercept the traffic with Burp
  9. Locked: Trace a method with Frida
  10. Locked: Write the findings
  11. Locked: Defence and Detection
  12. Locked: Check Your Work
  13. Locked: Clean-up

A running app shows what a static read cannot. A card number in the log, a password in a world-readable file, a login sent over plain HTTP, a method call that fires on each tap — each one appears only at run time. Build a disposable emulator, install a training app, then watch its log, its private files, its traffic and its method calls with adb, Burp and Frida. Record each finding with a command and its output.

Lab Objectives

  • Start an Android emulator that you control and install a training app with adb
  • Read the app log with adb logcat and find a secret that the app writes to it
  • Read the private files of the app while it runs
  • Send the traffic of the emulator through Burp Suite and read one request
  • Explain why an app can ignore a user certificate and what SSL pinning changes
  • Trace one method of the running app with Frida, without changing it

Static analysis reads the app. Dynamic analysis runs it and watches what it does. Some flaws exist only at run time: a secret in the log, a file with open permissions, a request that sends a password in clear text. This lab shows you three views of a running app: the log, the file system and the network. Then it adds a fourth, the method calls, with Frida.

You work as a defender or a tester with permission. Every step runs on an emulator that you own, against a training app.

Prerequisites

  • Finish the Android Static Analysis lab first. It uses the same app, diva-beta.apk, and the same terms: manifest, activity, APK.
  • Know Burp Suite from the Burp Suite Basics lab: start it, set a listener, read the HTTP history.
  • Read the Android Fundamentals workbook for the app sandbox and the data folders.

Lab Setup

Use your own Kali Linux machine. A virtual machine is fine. You need:

ItemPurpose
Android SDK command-line toolssdkmanager, avdmanager, emulator
adb (Android platform-tools)Talks to the emulator
Burp Suite CommunityIntercepts the traffic
frida-toolsfrida, frida-ps, frida-trace
DIVA (diva-beta.apk)The training app, package jakhar.aseem.diva. Get the APK as the Android Static Analysis lab says

The emulator needs hardware virtualisation (KVM). Check it first.

ls -l /dev/kvm

Example output:

crw-rw---- 1 root kvm 10, 232 Nov 19 08:02 /dev/kvm

Build the target

KaliRange hosts no targets, no virtual machines and no lab files. You run this lab on your own machine. Only Step 5 needs a web server. Use your own DVWA (Damn Vulnerable Web Application, by the DVWA team on GitHub; it runs with docker compose) on a host that you own. In this text its address is 10.0.0.20. Replace it with the address of your own DVWA host.

  • The emulator must reach that host over HTTP.
  • The login page is http://10.0.0.20/dvwa/login.php. If your DVWA serves the login page at another path, change the path in the commands.
  • The account is the default DVWA account admin with the password password. Use your own account if you changed it.

Take a snapshot of the DVWA virtual machine, or note the container state, before Step 1, so that you can go back.

Authorised scope. Run these steps only on your own emulator, with the DIVA training app and your own DVWA host. Never install DIVA on a personal phone. Never send the traffic of a real account through your proxy. Never point Burp or Frida at an app or a server that you do not own or have written permission to test.

Step 1: Create and start the emulator

1

Build an emulator image with root access for adb

An emulator is a virtual phone. Use an image of the type google_apis, not google_apis_playstore. Only the first type lets adb root work, and you need it to read app files in Step 4.

Download a system image and create the device. Version android-33 is an example; any recent API level that has a google_apis image works.

sdkmanager "platform-tools" "emulator" "system-images;android-33;google_apis;x86_64"
avdmanager create avd -n lab33 -k "system-images;android-33;google_apis;x86_64" -d pixel_6
emulator -list-avds

Example output:

lab33

Start Burp now (Step 5 explains the settings). Burp listens on 127.0.0.1:8080 by default. Start the emulator in a second terminal and tell it to use that proxy from the first minute.

emulator -avd lab33 -no-snapshot -http-proxy http://127.0.0.1:8080

Wait about one minute, then check the connection in the first terminal.

adb devices

Example output:

List of devices attached
emulator-5554	device

device means the emulator is ready. offline means it is still starting. Wait and run the command again.

Step 2: Install the app and start it

2

Install DIVA with adb and confirm what runs

adb install copies the APK to the emulator and registers it. Then confirm the package name, the target SDK level and the process.

cd ~/android-static-lab
adb install diva-beta.apk
adb shell pm list packages | grep diva
adb shell dumpsys package jakhar.aseem.diva | grep -E "versionName|targetSdk"

Example output:

Performing Streamed Install
Success
package:jakhar.aseem.diva
    versionName=1.0
    targetSdk=22

Start the app from the command line and read its process ID.

adb shell monkey -p jakhar.aseem.diva -c android.intent.category.LAUNCHER 1
adb shell pidof jakhar.aseem.diva

Example output:

Events injected: 1
4172

Your process ID differs. If monkey reports that no activity was found, open the app by hand on the emulator screen.

Look at targetSdk=22. This old target level matters in Step 5.

Sign in to continue

8 more sections are for signed-in members. It is free: sign in with Google.

Related