Skip to content

Commit b3e7e62

Browse files
Copilotcpholguera
andauthored
Add apkeep tool and XAPK conversion technique (#3697)
* Initial plan * Add apkeep tool page (MASTG-TOOL-0148) and xapk conversion technique (MASTG-TECH-0145) Co-authored-by: cpholguera <[email protected]> * Refactor apkeep tool and usage --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: cpholguera <[email protected]> Co-authored-by: Carlos Holguera <[email protected]>
1 parent ad2a6e8 commit b3e7e62

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed

techniques/android/MASTG-TECH-0003.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ One of the easiest options is to download the APK from websites that mirror publ
1414

1515
Beware that you do not have control over these sites, and you cannot guarantee what they will do in the future. Only use them if it's your only option left.
1616

17-
## Using gplaycli
17+
!!! note
18+
Some alternative app stores may provide apps in XAPK format instead of standard APK files. XAPK files are ZIP archives that bundle the APK with additional data files. See @MASTG-TECH-0145 for instructions on how to extract and work with XAPK files.
19+
20+
## Using @MASTG-TOOL-0016
1821

1922
You can use @MASTG-TOOL-0016 to download (`-d`) the selected APK by specifying its AppID (add `-p` to show a progress bar and `-v` for verbosity):
2023

@@ -34,6 +37,28 @@ The `com.google.android.keep.apk` file will be in your current directory. As you
3437
3538
> You may use your own Google Play credentials or token. By default, gplaycli will use [an internally provided token](https://github.com/matlink/gplaycli/blob/3.26/gplaycli/gplaycli.py#L106 "gplaycli Fallback Token").
3639
40+
## Using @MASTG-TOOL-0148
41+
42+
You can use @MASTG-TOOL-0148 to download APKs from Google Play Store. To download the latest version of an app by specifying its package name:
43+
44+
```bash
45+
apkeep -a com.google.android.keep .
46+
```
47+
48+
The APK will be downloaded to the current directory. apkeep can also download specific versions and handle split APKs:
49+
50+
```bash
51+
apkeep -a [email protected] .
52+
```
53+
54+
To download all split APKs for an app bundle:
55+
56+
```bash
57+
apkeep -a com.google.android.keep -d .
58+
```
59+
60+
apkeep is particularly useful for automation and doesn't require authentication for downloading free apps.
61+
3762
## Extracting the App Package from the Device
3863
3964
Obtaining app packages from the device is the recommended method, as we can guarantee the app hasn't been modified by a third party. To obtain applications from a rooted or non-rooted device, you can use the following methods:
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: Working with XAPK Files
3+
platform: android
4+
---
5+
6+
When downloading apps from alternative stores such as APKPure or APKMirror, you may receive XAPK files instead of a single APK. XAPK is not an Android standard format. It is simply a ZIP archive used by third-party stores to bundle one or more APKs together with optional additional data.
7+
8+
## What an XAPK Contains
9+
10+
An XAPK file is a regular ZIP archive that typically includes:
11+
12+
- A base APK
13+
- Optional split APKs generated from an Android App Bundle
14+
- Optional OBB data files
15+
- A manifest.json file describing the package contents
16+
17+
## Extracting an XAPK
18+
19+
Because XAPK is just a ZIP file, it can be extracted using standard tools.
20+
21+
```bash
22+
unzip app.xapk -d app_extracted
23+
```
24+
25+
After extraction you may see a single APK or multiple APK files. For example:
26+
27+
```sh
28+
ls -1 app_extracted
29+
base.apk
30+
config.ar.apk
31+
config.arm64_v8a.apk
32+
...
33+
config.xxxhdpi.apk
34+
icon.png
35+
manifest.json
36+
```
37+
38+
## Installing Apps from an XAPK
39+
40+
### Single APK Case
41+
42+
If the extracted directory contains only one APK, it can be installed normally.
43+
44+
```bash
45+
adb install app_extracted/*.apk
46+
```
47+
48+
### Split APK Case
49+
50+
If multiple APKs are present, the app was built as an Android App Bundle. There is no reliable or supported way to convert these splits into one universal APK. The correct approach is to install the base APK together with the splits that match the target device.
51+
52+
```bash
53+
adb install-multiple -r app_extracted/*.apk
54+
```
55+
56+
### OBB Data
57+
58+
If the XAPK contains OBB files, install the APKs first, then push the OBB directory to the device.
59+
60+
```bash
61+
adb push app_extracted/Android/obb/<package.name> /sdcard/Android/obb/
62+
```
63+
64+
## Reverse Engineering
65+
66+
For reverse engineering and static analysis, you can open the base APK and all relevant split APKs together using @MASTG-TOOL-0018 like this:
67+
68+
```bash
69+
jadx app_extracted/*.apk
70+
```
71+
72+
See @MASTG-TECH-0017 for more details on decompiling Android apps.

tools/android/MASTG-TOOL-0148.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: apkeep
3+
platform: android
4+
source: https://github.com/EFForg/apkeep
5+
hosts: [windows, linux, macOS]
6+
---
7+
8+
[apkeep](https://github.com/EFForg/apkeep) is a command-line tool written in Rust for downloading APK files from various sources including Google Play Store. It's designed to make downloading and archiving Android APKs simple and reliable.
9+
10+
- Supports downloading specific versions of apps
11+
- Can download split APKs and bundle them
12+
- Provides CSV output for automation
13+
- No authentication required for free apps
14+
15+
See the [GitHub repository](https://github.com/EFForg/apkeep) for more information and installation instructions.

0 commit comments

Comments
 (0)