Extracting Android Apps for Security Testing

How to extract an Android app's APK files for security testing over adb without root, with split APKs, APKS and AAB files explained and what still needs root.

GuideMobile Security8 min readIntermediate

To extract an Android app for security testing, turn on USB debugging, use adb to find every APK file the app is installed as, and copy them all to your computer. You don’t need root for the APK files. Most Play Store apps arrive as several split APKs, so copying only one gives you an incomplete app.

Every Android security review starts with the same question: what exactly is installed on the phone? Since the move to app bundles, the answer is rarely “one APK file”. Copy only one file of a split app and you’ll analyse an incomplete app without knowing it. You can do the extraction by hand with adb, or in one command with our free tool getAPK.

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

What is inside an APK file?

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, and the code and assets are where secrets, endpoints and weak cryptography turn up.

Split APKs, APKS and AAB files

Split APKs are several APK files that together make up one installed app. Google Play generates them from an Android App Bundle (AAB), and tools pack them into an APKS file so they travel together. Android has supported installing one app from several APKs since Android 5.0, and 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 what you pull from a phone is always a set of APKs. 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, which holds 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, with 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, which is 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.

How to set up adb and USB debugging

To use adb with a phone, turn on USB debugging in Developer options and accept the pairing prompt that appears when you connect. 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 turn on USB debugging:

  1. Open Settings, then 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 are Android apps stored on the phone?

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/. Android tracks every installed app by its package name, such as com.example.app, and 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.

Preinstalled apps are hidden from pm list packages -3, which shows only the apps the user installed.

Why APK files can be copied without root

APK files can be copied without root because they 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 can’t you extract without root?

Without root, you can’t read an app’s private data. 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.

How to extract an APK in one command with getAPK

getAPK extracts an installed Android app in one command, with no root and nothing installed on the phone. By hand, you would list packages, ask pm path, pull each file, check it and zip the splits together.

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.

Under the hood, getAPK:

  • asks the phone for every APK file of the app, with the base first
  • pulls each one and checks it’s a real APK: a zip containing AndroidManifest.xml
  • saves a single-APK app as <package>-<version>.apk, and a split app as <package>-<version>.apks, a zip holding base.apk and every split
  • 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.

How to analyse an extracted Android app

An extracted app is the input for analysis, which works best in this order, from the package itself to the API behind it:

  1. Start with 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 by listing 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 unconfirmed leads for manual review. 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

Can I extract an APK from an Android phone without root?

Yes. The installed APK files are readable by the adb shell user, so you can copy them from any Android 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. A base.apk 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?

Not necessarily. The files on a phone are the split APKs the store delivered to that device, and another phone can hold a different set for the same version 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 own phone?

Whether extracting an app is legal 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.