GuideMobile Security8 min readIntermediate

Extracting Android Apps for Security Testing

How to get an installed Android app off a phone for analysis: APKs, split APKs, APKS and AAB files, adb and USB debugging, and what you can't reach without root.

Every Android security review starts with the same question: what exactly is installed on the phone? The answer is rarely “one APK file”. Since the move to app bundles, most apps from the Play Store arrive as a small collection of files, and if you copy only one of them you’ll analyse an incomplete app without knowing it.

This guide explains how Android packages apps, where they live on the phone, what you can copy without root and what you can’t. Then it shows the practical method we use, our free tool getAPK, and where to go next with what you’ve pulled.

Only extract apps from devices you own or are authorised to test.

What an APK contains

An APK (Android package) is a zip file with a fixed layout. Unzip one and you’ll typically find:

  • AndroidManifest.xml: the app’s identity, permissions, components and settings, stored in a compiled binary XML format
  • classes.dex (and classes2.dex and so on): the app’s Java and Kotlin code, compiled to Dalvik bytecode
  • resources.arsc and res/: compiled resources such as strings, layouts and images
  • assets/: files shipped as they are, which is where you’ll often find JavaScript bundles, configuration files and certificates
  • lib/: native libraries, one folder per CPU architecture (for example arm64-v8a)
  • Signature data: Android requires every APK to be signed, and an app can only be updated by an APK signed with the same key

For a tester, the manifest and the code are the main targets. The manifest maps the app’s attack surface. The code and assets are where secrets, endpoints and weak cryptography turn up.

Split APKs, APKS and AAB

Android has supported installing one app from several APKs since Android 5.0. Developers rarely build split APKs by hand. They usually come from the store.

Android App Bundles

An Android App Bundle (.aab) is a publishing format. A developer uploads the bundle to Google Play, and Play generates optimised APKs from it for each kind of device. Google Play has required new apps to be published as bundles since August 2021.

A phone never installs an AAB. So when you pull an app from a phone, you get APKs, not a bundle. If the developer gives you an AAB directly, you can analyse the bundle itself, or turn it into installable APKs with Google’s bundletool.

Split APKs on the phone

What Play delivers for a bundle-built app is a set of split APKs:

  • base.apk: the manifest, the main code and the shared resources
  • Configuration splits: one for the phone’s CPU architecture (native libraries), one or more for languages, and one for screen density. They have names like split_config.arm64_v8a.apk or split_config.en.apk.
  • Feature splits, if the app uses on-demand feature modules

The phone only receives the splits it needs. A phone with an arm64 CPU, set to English, gets the arm64 split and the English split, not every split the bundle could produce. That has two consequences:

  1. base.apk alone is incomplete. It may have no native libraries at all, and it won’t install on its own. Code that lives in a native library, such as a cryptography routine or a root check, is invisible if you analyse only the base.
  2. Two phones can hold different files for the same app version. That’s normal. Record what you pulled so your notes match the build you analysed.

APKS and other bundle files

Because a split app is several files, tools pack them into one archive so they travel together. APKS is the common name for this: a zip that holds a set of split APKs. bundletool produces its own form of .apks file, and you’ll also see similar formats such as XAPK from third-party app stores.

To reinstall a set of split APKs on a test phone, unzip them and install them together with adb install-multiple. Android checks that they all belong to the same app and are signed with the same key.

adb and USB debugging

adb (Android Debug Bridge) is the command-line tool in Google’s Android platform-tools. It talks to the adb service on the phone over USB, or over Wi-Fi with wireless debugging on Android 11 and later.

To use it, turn on USB debugging:

  1. Open Settings → About phone and tap Build number seven times. This unlocks Developer options.
  2. In Developer options, switch on USB debugging.
  3. Connect the phone. A prompt asks whether to allow USB debugging from this computer, and shows the computer’s key fingerprint. Accept it.

Until you accept that prompt, adb devices lists the phone as unauthorized and won’t run commands on it. That pairing is a security control: a phone that’s locked, or whose owner declines the prompt, doesn’t talk to a stranger’s computer.

USB debugging gives a lot of access to whoever holds the paired computer. On a phone you also use day to day, turn it off when you’re finished.

Where apps live on the phone

Android tracks every installed app by its package name, such as com.example.app. Two commands, run through adb, tell you what’s installed and where:

adb shell pm list packages -3        # apps the user installed
adb shell pm path com.example.app    # where each of its APK files is

pm path prints one package: line per APK file. For a split app you’ll see several:

package:/data/app/~~Xy12==/com.example.app-Ab3==/base.apk
package:/data/app/~~Xy12==/com.example.app-Ab3==/split_config.arm64_v8a.apk
package:/data/app/~~Xy12==/com.example.app-Ab3==/split_config.en.apk
package:/data/app/~~Xy12==/com.example.app-Ab3==/split_config.xxhdpi.apk

Example output.

User-installed apps live under /data/app/, in folders with randomised names. Preinstalled apps live on the system partitions, in places such as /system/app/ and /system/priv-app/, and they’re hidden from pm list packages -3.

Why you can copy them without root

The APK files themselves aren’t secret. Android keeps them readable so the system and other apps can load resources from them, and the adb shell user is allowed to read them. That’s why adb pull works on an unrooted phone, as long as you know the full path of every file.

What you can’t get without root

The installed APKs are only half of an app. While it runs, the app writes private data to its own folder under /data/data/<package>/ (also reachable as /data/user/0/<package>/):

  • SQLite databases
  • shared_prefs/ XML files, where many apps keep settings and, too often, tokens
  • caches, downloaded files and WebView storage

That folder belongs to the app’s own Linux user, and the Android sandbox stops other apps and the adb shell from reading it. Without root you have limited options:

  • run-as lets the adb shell act as the app, but only for apps built as debuggable. Release builds from a store aren’t.
  • adb backup is deprecated, and apps that target Android 12 or higher have their data excluded unless they’re debuggable.
  • Shared storage such as /sdcard/Android/data/<package>/ is more restricted since Android 11 and doesn’t hold an app’s private folder.

So data-at-rest testing, such as checking whether an app stores tokens or personal data in plain text, needs a rooted test device or emulator, or a debuggable build from the developer. That’s a deliberate limit of the platform, and it’s a good thing for users. For how testers approach that part of the work, see part 4 of our AppSleuth series, which covers pulling and auditing an app’s data container on a device you control.

The practical method: getAPK

You can do all of the above by hand: list packages, ask pm path, pull each file, check it, zip the splits together. getAPK does it in one command, with no root and nothing installed on the phone.

pipx install getapk
getapk --list
getapk com.example.app -o ./apps

It needs Python 3.9 or newer and adb on your PATH, and runs on macOS, Linux and Windows. --list shows each user-installed app with its version and the app that installed it. Pulling an app gives you one file and its hash:

[+] com.example.app 2.4.1 -> ./apps/com.example.app-2.4.1.apks  (4 splits, 4.9 MB)
    sha256 1151750e38fe4bbbd568818e3ac9dfbfc37f65359a7fcb909cfc1b6bf966e77d

Example output.

What happens under the hood:

  • It asks the phone for every APK file of the app, with the base first.
  • It pulls each one and checks it’s a real APK: a zip containing AndroidManifest.xml.
  • A single-APK app is saved as <package>-<version>.apk. A split app is saved as <package>-<version>.apks, a zip holding base.apk and every split.
  • It prints the SHA-256 of the file it wrote, so you can tie your findings to an exact build.

It also treats the phone as untrusted. Package names, serials and every path the phone reports are checked before use, output names are cleaned, and nothing is written to the output folder until it’s complete.

Other options cover the common cases: --all to pull every user-installed app, --include-system for preinstalled apps, -m to filter by text, -s to pick a phone when several are connected, and --format apks to always produce a bundle. The getAPK blog post walks through them.

Analyse what you pulled

An extracted app is the input to analysis, not a finding in itself. A sensible order:

  1. Static triage. Our free tool AppSleuth reads .apk, .apks, .xapk and .aab files directly, so you can scan getAPK’s output as it is:

    appsleuth scan apps/com.example.app-2.4.1.apks
    appsleuth info apps/com.example.app-2.4.1.apks

    scan looks for hardcoded secrets, network security configuration, exported components, weak cryptography and hardening issues. info gives a one-screen summary of identity, signing, permissions and exported components. The AppSleuth series explains how to read the results, and our guide to mobile app static analysis with AppSleuth covers the method end to end.

  2. Map the attack surface. List the hosts, deep links and cloud backends the app references. Part 2 of the series covers this.

  3. Test the running app and its data. On a rooted test device, check what the app stores and how it behaves at runtime.

  4. Test the API. The app is usually a client for a backend, and most serious issues are on the server side. Our API security testing guide covers that part.

Static findings are leads for manual review, not confirmed vulnerabilities. The OWASP Mobile Application Security project, with its verification standard and testing guide, is a good reference for what a full assessment covers.

Summary

  • Most Android apps are installed as split APKs. Copy every file, or you’re analysing part of an app.
  • AAB is a publishing format, so phones never hold one. APKS and similar archives keep split APKs together.
  • With USB debugging and adb you can copy any installed app without root. You can’t read its private data without root or a debuggable build.
  • getAPK automates the extraction and records a hash for each app. AppSleuth takes it from there.

If you’d like experienced testers to look at your Android app and the API behind it, see our mobile app penetration testing service, and read our mobile app penetration testing guide for how a full engagement works.

Frequently asked questions

Do I need a rooted phone to extract an Android app?

No. The installed APK files are readable by the adb shell user, so you can copy them from any phone with USB debugging turned on. You only need root, or a debuggable build, to read the app's private data such as its databases and preferences.

What is the difference between an APK, an APKS and an AAB?

An APK is an installable Android package. An APKS file is a zip that holds a set of split APKs for one app, so they stay together. An AAB, or Android App Bundle, is the format developers upload to the store, which then generates split APKs for each device. Phones install APKs, never AABs.

Why won't the base.apk I pulled install on another phone?

The app was probably installed as split APKs. The base needs its matching splits, for example the native libraries for the phone's CPU, and Android won't install it alone. Pull every split, then install them together with adb install-multiple.

Is the APK on my phone the same as the one the developer built?

It's the set of files the store delivered to your phone, which can differ from another phone's set because splits are chosen per device. Record the version and a SHA-256 hash of what you pulled so your findings are tied to an exact build.

Is it legal to extract an app from my phone?

That depends on where you are and on the app's licence terms. Only extract apps you own or are authorised to test, and use the copy for security analysis, not redistribution. This is general guidance, not legal advice.

Need a pentest for an audit, a customer, or peace of mind?

Tell us what you need tested. You’ll get a fixed-fee proposal with tester-days and timeline stated, usually within a few days of the scoping call.