Coder Social home page Coder Social logo

ax / apk.sh Goto Github PK

View Code? Open in Web Editor NEW
3.3K 24.0 187.0 63 KB

apk.sh makes reverse engineering Android apps easier, automating some repetitive tasks like pulling, decoding, rebuilding and patching an APK.

License: GNU General Public License v3.0

Shell 100.00%
android apk frida reverse-engineering android-reverse-engineering frida-gadget split-apk objection

apk.sh's Introduction

πŸ•ΉοΈ apk.sh

apk.sh is a Bash script that makes reverse engineering Android apps easier, automating some repetitive tasks like pulling, decoding, rebuilding and patching an APK.

Features

apk.sh basically uses apktool to disassemble, decode and rebuild resources and some bash to automate the frida gadget injection process. It also supports app bundles/split APKs.

  • πŸ„ Patching APKs to load frida-gadget.so on start.
  • πŸ†• Support for app bundles/split APKs.
  • πŸ”§ Disassembling resources to nearly original form with apktool.
  • πŸ”© Rebuilding decoded resources back to binary APK/JAR with apktool.
  • πŸ—οΈ Code signing the apk with apksigner.
  • πŸ–₯️ Multiple arch support (arm, arm64, x86, x86_64).
  • πŸ“΅ No rooted Android device needed.

Getting started

⬅️ Pulling an APK from a device is simple as running ./apk.sh pull <package_name>

πŸ”§ Decoding an APK is simple as running ./apk.sh decode <apk_name>

πŸ”© Rebuilding an APK is simple as running ./apk.sh build <apk_dir>

apk.sh pull

apk.sh pull pull an APK from a device. It supports app bundles/split APKs, which means that split APKs will be joined in a single APK (this is useful for patching). If the package is an app bundle/split APK, apk.sh will combine the APKs into a single APK, fixing all public resource identifiers.

apk.sh patch

apk.sh patch patch an APK to load frida-gadget.so on start.

frida-gadget.so is a Frida's shared library meant to be loaded by programs to be instrumented (when the Injected mode of operation isn’t suitable). By simply loading the library it will allow you to interact with it using existing Frida-based tools like frida-trace. It also supports a fully autonomous approach where it can run scripts off the filesystem without any outside communication.

Patching an APK is simple as running ./apk.sh patch <apk_name> --arch arm.

You can calso specify a Frida gadget configuration in a json ./apk.sh patch <apk_name> --arch arm --gadget-conf <config.json>

If you encounter "already interned" apktool d errors like in #30, you can pass the --only-main-classes flag, which will be passed to apktool when decoding your APK.

πŸ„ Frida's Gadget configurations

In the default interaction, Frida Gadget exposes a frida-server compatible interface, listening on localhost:27042 by default. In order to achieve early instrumentation Frida let Gadget’s constructor function block until you either attach() to the process, or call resume() after going through the usual spawn() -> attach() -> ...apply instrumentation... steps.

If you don’t want this blocking behavior and want to let the program boot right up, or you’d prefer it listening on a different interface or port, you can customize this through a json configuration file.

The default configuration is:

{
  "interaction": {
    "type": "listen",
    "address": "127.0.0.1",
    "port": 27042,
    "on_port_conflict": "fail",
    "on_load": "wait"
  }
}

You can pass the gadget configuration file to apk.sh with the --gadget-conf option.

Script interaction

A typically suggested configuration might be:

{
  "interaction": {
    "type": "script",
    "path": "/data/local/tmp/script.js",
    "on_change":"reload"
  }
}

script.js could be something like:

var android_log_write = new NativeFunction(
    Module.getExportByName(null, '__android_log_write'),
    'int',
    ['int', 'pointer', 'pointer']
);

var tag = Memory.allocUtf8String("[frida-script][ax]");

var work = function() {
    setTimeout(function() {
        android_log_write(3, tag, Memory.allocUtf8String("ping @ " + Date.now()));
        work();
    }, 1000);
}

work();

android_log_write(3, tag, Memory.allocUtf8String(">--(O.o)-<"));

adb push script.js /data/local/tmp

./apk.sh patch <apk_name> --arch arm --gadget-conf <config.json>

adb install file.gadget.apk

Note

Add the following code to print to logcat the console.log output of any script from the frida codeshare when using the Script interaction type.

// print to logcat the console.log output
// see: https://github.com/frida/frida/issues/382
var android_log_write = new NativeFunction(
    Module.getExportByName(null, '__android_log_write'),
    'int',
    ['int', 'pointer', 'pointer']
);
var tag = Memory.allocUtf8String("[frida-script][ax]");
console.log = function(str) {
    android_log_write(3, tag, Memory.allocUtf8String(str));
}

Requirements

  • apktool
  • apksigner
  • unxz
  • zipalign
  • aapt
  • adb

Usage

SYNOPSIS

apk.sh [SUBCOMMAND] [APK FILE|APK DIR|PKG NAME] [FLAGS]
apk.sh pull [PKG NAME] [FLAGS]
apk.sh decode [APK FILE] [FLAGS]
apk.sh build [APK DIR] [FLAGS]
apk.sh patch [APK FILE] [FLAGS]
apk.sh rename [APK FILE] [PKG NAME] [FLAGS]

SUBCOMMANDS

pull	Pull an apk from device/emulator.
decode	Decode an apk.
build	Re-build an apk.
patch	Patch an apk.
rename	Rename the apk package.

FLAGS

-a, --arch <arch> Specify the target architecture, mandatory when patching.

-g, --gadget-conf <json_file> Specify a frida-gadget configuration file, optional when patching.

-n, --net Add a permissive network security config when building, optional. It can be used with patch, pull and rename also.

-s, --safe Do not decode resources when decoding (i.e. apktool -r). Cannot be used when patching.

-d, --no-dis Do not disassemble dex, optional when decoding (i.e. apktool -s). Cannot be used when patching.

πŸ“ƒ Links of Interest

https://frida.re/docs/gadget/

https://lief-project.github.io/doc/latest/tutorials/09_frida_lief.html

https://koz.io/using-frida-on-android-without-root/

https://github.com/sensepost/objection/

https://github.com/NickstaDB/patch-apk/

https://neo-geo2.gitbook.io/adventures-on-security/frida-scripting-guide/frida-scripting-guide

apk.sh's People

Contributors

altayakkus avatar ax avatar gergesh avatar jeromew avatar mainrs avatar netc4ts avatar orhun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apk.sh's Issues

script.js into APK

Request : Integrate script.js into APK without adb push

Details : Hi, thank you for the script,
I am currently using the following commands to patch an APK and run a script:

adb push script.js /data/local/tmp

./apk.sh patch <apk_name> --arch arm --gadget-conf <config.json>

adb install file.gadget.apk

I would like to know if it is possible to integrate script.js directly into the APK without using adb push, and then execute it. According to this link, it seems feasible. Could you please provide(if possible) guidance on how to achieve this using apk.sh?

Thank you!

[BUG] Could not smali file: XYZ already interned

Information

  1. apk.sh version : 1.0.8
  2. Operating System (Mac, Linux, Windows) : Linux, Windows etc.
  3. APK From? (Playstore, ROM, Other) : PlayStore

apk.sh output

I: Smaling smali_assets folder into assets.dex
xyz/smali_assets/audience_network/javax/annotation/concurrent/ThreadSafe.smali
[>] Sorry!
[!] java -jar /home/me/.apk.sh/apktool_2.9.3.jar b -d myapk -o myapk.gagdet.apk --use-aapt2 return errors!
[>] Bye!

Steps to Reproduce

  1. apk.sh patch myfile.apk

APK

Is not needed.

Questions to ask before submission

Are you using the latest apk.sh version? Yes

The thing is that apktool encounters problems with certain APKs, see iBotPeaches/Apktool#2784 .

This can be fixed by using the option --only-main-classes while decoding the .apk, but this feature is not supported by apk.sh.

[BUG] Pull split apk from device lead to missing drawable resource

Information

  1. apk.sh version : 1.0.6
  2. Operating System (Mac, Linux, Windows) : Linux Ubuntu 20.4
  3. APK From? (Playstore, ROM, Other) :
    Downloaded from Playstore

apk.sh output

output is the happy path

Steps to Reproduce

I experience an issue when I pull apk from the device that contains split fule.
I got this exception

Process: com.package, PID: 8459
04-13 14:59:53.979  8459  8459 E AndroidRuntime: 	at com.package.ui.MainActivity.m0(Unknown Source:41)
04-13 14:59:53.979  8459  8459 E AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: Drawable com.package:drawable/APKTOOL_DUMMY_3ed with resource ID #0x7f0803ed

I try a couple of things:

  1. I copy all the drawable from the split file and paste them in the drawable of the base.apk #Does not work
  2. I tried to delete the APKTOOL_DUMMY_3ed from the drawable and properties, but still, the app searched it by ID and didn't work again
    Is there any solution for this, or do I need to search for an alternative to pull APK that has split.

Questions to ask before submission

Are you using the latest apk.sh version?
Yes

Mange to inject πŸ’‰ frida on React native app but app freeze on splash screen.

I managed to insert the frida gadgets to Android React Native app, but when I launched it, it was freeze on the Splash screen.I proxy I only see a firebase request witch fails.
I use

    1.apk.sh decode app.apk
    2.CHANGE export native lib to true
    3.build
    4.patch 

The app statt but freeze on splash screen.
Any hints on how to proceed.I don't want to pin the certificate.
Regards

Failed to extract native library

Hi I'm trying to do the patch for frida. After the success I run:

adb install base.gadget.apk

I get this error message:

Performing Streamed Install
adb: failed to install base.gadget.apk: Failure [INSTALL_FAILED_INVALID_APK: Failed to extract native libraries, res=-2]

The CPU of my device is arm64-v8a. And the base.apk file installs fine. Any ideas what could be going wrong? Here is my full output of the logs

 bash ./apk.sh patch base.apk --arch arm64
[*] apk.sh v1.0.3 
[*] home dir is /Users/me/.apk.sh
[*] apktool v2.7.0 exist in /Users/me/.apk.sh
[*] apksigner v0.9 exist in /Users/me/.apk.sh/sdk_root/build-tools/33.0.1
[*] zipalign exist in /Users/me/.apk.sh/sdk_root/build-tools/33.0.1
[*] aapt exist in /Users/me/.apk.sh/sdk_root/build-tools/33.0.1
[>] Injecting Frida gadget for arm64 in base.apk...
[>] Frida gadget already present in /Users/me/.apk.sh
[>] Using /Users/me/.apk.sh/frida-gadget-15.1.28-android-arm64.so
[>] Decoding base.apk with java -jar /Users/me/.apk.sh/apktool_2.7.0.jar d base.apk
I: Using Apktool 2.7.0 on base.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /Users/me/Library/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Baksmaling classes3.dex...
I: Baksmaling classes4.dex...
I: Baksmaling classes5.dex...
I: Baksmaling classes6.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
I: Copying META-INF/services directory
[>] Done!
[>] Searching for a launchable-activity...
[>] launchable-activity found --> com.sampleapp.MainActivity
[>] Local path should be ./base/smali/com/sampleapp/MainActivity.smali
[!] ./base/smali/com/sampleapp/MainActivity.smali does not exist! Probably a multidex APK...
[?] Looking in ./base/smali_classes2/com/sampleapp/MainActivity.smali...
[!] ./base/smali_classes2/com/sampleapp/MainActivity.smali does not exist! Probably a multidex APK...
[?] Looking in ./base/smali_classes3/com/sampleapp/MainActivity.smali...
[>] ./base/smali_classes3/com/sampleapp/MainActivity.smali found!
[>] Patching smali...
[>>] A constructor is already present --> .method public constructor <init>()V
[>>] Injecting partial load library!
[>>] .locals declaration found!
[>>] Skipping .locals line...
[>>] Update locals count...
[>] Writing the pathced smali back...
[?] Checking if Internet permission is present in the manifest...
[>] Internet permission is there!
[>] Building with java -jar /Users/me/.apk.sh/apktool_2.7.0.jar b -d base -o file.apk --use-aapt2
I: Using Apktool 2.7.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes6 folder into classes6.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes4 folder into classes4.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes5 folder into classes5.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Using aapt2 - setting 'debuggable' attribute to 'true' in AndroidManifest.xml
I: Copying libs... (/lib)
I: Copying libs... (/kotlin)
I: Copying libs... (/META-INF/services)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: file.apk
[>] Built!
[>] Aligning with zipalign -p 4 ....
[>] Done!
[>] A Keystore exist!
[>] Signing file.apk with apksigner...
[>] Done!
[>] base.gadget.apk ready!
[>] Bye!

[BUG] missing 'name' attribute in res/values xml files

Information

  1. apk.sh version : 1.0.8
  2. Operating System (Mac, Linux, Windows) : Linux
  3. APK From? (Playstore, ROM, Other) : Playstore

More Accurate Description

in the affected resource files there is a (seemingly) arbitrary number of xml tags (usually) at the end, within the <resources> with the following structure: <item type=\"\S*\" name=\"\" \/>

some files have none of the empty name tag tags, some have just them, and most have something in between

in public.xml is the tag different, there it is <public type=\"\S*\" name=\"\" id=\"\S*\" \/>

apk.sh output

[>] Building with java -jar /home/my-user/.apk.sh/apktool_2.9.3.jar b -d  com.attidomobile.passwallet_split_apks/base -o file.apk --use-aapt2
I: Using Apktool 2.9.3
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether sources has changed...
I: Checking whether resources has changed...
I: Building resources...
I: Using aapt2 - setting 'debuggable' attribute to 'true' in AndroidManifest.xml
W: /home/my-user/apk.sh/com.attidomobile.passwallet_split_apks/base/res/values/public.xml:6934: error: <public> missing 'name' attribute.
W: /home/my-user/apk.sh/com.attidomobile.passwallet_split_apks/base/res/values/public.xml:6935: error: <public> missing 'name' attribute.
W: /home/my-user/apk.sh/com.attidomobile.passwallet_split_apks/base/res/values/public.xml: error: file failed to compile.
W: /home/my-user/apk.sh/com.attidomobile.passwallet_split_apks/base/res/values/strings.xml:655: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.attidomobile.passwallet_split_apks/base/res/values/strings.xml:656: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.attidomobile.passwallet_split_apks/base/res/values/strings.xml: error: file failed to compile.
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_130762370632719210017057457644154483351.tmp, compile, --dir, /home/my-user/apk.sh/com.attidomobile.passwallet_split_apks/base/res, --legacy, -o, /home/my-user/apk.sh/com.attidomobile.passwallet_split_apks/base/build/resources.zip]
[>] Sorry!
[!] java -jar /home/my-user/.apk.sh/apktool_2.9.3.jar b -d  com.attidomobile.passwallet_split_apks/base -o file.apk --use-aapt2 return errors!
[>] Bye!

or

[>] Building with java -jar /home/my-user/.apk.sh/apktool_2.9.3.jar b -d  com.google.android.apps.walletnfcrel_split_apks/base -o file.single.apk --use-aapt2 
I: Using Apktool 2.9.3
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Using aapt2 - setting 'debuggable' attribute to 'true' in AndroidManifest.xml
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:3: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:4: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:5: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:6: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:7: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:8: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:9: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:10: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:11: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml:12: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/animators.xml: error: file failed to compile.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:3: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:4: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:5: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:6: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:7: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:8: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:9: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:10: error: <item> missing 'name' attribute.
W: /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res/values/anims.xml:11: error: <item> missing 'name' attribute.
brut.androlib.exceptions.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/tmp/brut_util_Jar_22534173162893068579221351672871164782.tmp, compile, --dir, /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/res, --legacy, -o, /home/my-user/apk.sh/com.google.android.apps.walletnfcrel_split_apks/base/build/resources.zip]
[>] Sorry!
[!] java -jar /home/my-user/.apk.sh/apktool_2.9.3.jar b -d  com.google.android.apps.walletnfcrel_split_apks/base -o file.single.apk --use-aapt2  return errors!
[>] Bye!

Steps to Reproduce

  1. pull an affected app
  2. watch apk.sh/apktool die

APK

I had issues with

  • com.google.android.apps.walletnfcrel
  • com.attidomobile.passwallet

Local Fix

Manually remove the affected lines (?) and try to rebuild until no errors pop up anymore
The apps were able to be built, but there were internal issues
(This might also be an issue with apktool --resource-mode dummy, idk for sure)

Is the apk.sh pin the certificate

Hello πŸ‘‹ I am testing the script against react native app (Android).Its appear that when I patch the apk (also I have set the export native in Manifest to true ) I got error on install that state the certificate is missing or similar is equal to null.I suppose that the script does not pin the certificate and I am curious does the default behavior do this or is not part of the apk.sh.Since I can't use pining on this app I need to be more familiar with it.
Regards

substring expression < 0 error on macos zsh when patch

command

./apk.sh patch ./base.apk --arch arm

error

./apk.sh: line 209: -3: substring expression < 0

it's this line if [ ! -f "${FRIDA_SO_XZ::-3}" ]; then in the shell. Not sure how to fix it.

	FRIDA_SO_XZ="$APK_SH_HOME/$GADGET"

	if [ ! -f "${FRIDA_SO_XZ::-3}" ]; then

[BUG] Positional args never used

Information

  1. apk.sh version : v1.0.4
  2. Operating System (Mac, Linux, Windows) : N/A
  3. APK From? (Playstore, ROM, Other) : N/A

apk.sh output

N/A

Steps to Reproduce

  1. Run any command accepting positional args (build, decode, patch)
  2. Theses args are saved but never used

Questions to ask before submission

  • Are you using the latest apk.sh version?

This StackOverflow answer seems to have been a source when this file was created. But some things are missing (the definition of the POSITIONAL_ARGS variable and the restoration of positional parameters)...

[BUG] Cannot merge split APKs together, brut.directory.PathNotExist: apktool.yml

Maybe this tool cannot do it, not sure here

Information

  1. apk.sh version : 1.0.6
  2. Operating System (Mac, Linux, Windows) : Linux
  3. APK From? (Playstore, ROM, Other) : $ split APKS from Playstore

apk.sh output

[=======================================] 100% Unzipping... android-13/renderscrSDK Build-Tools

[>] Done!
[>] apksigner installed!
[*] zipalign exist in /home/***/.apk.sh/sdk_root/build-tools/33.0.1
[*] aapt exist in /home/***/.apk.sh/sdk_root/build-tools/33.0.1
[>] Building with java -jar /home/***/.apk.sh/apktool_2.8.1.jar b -d  /home/all -o file.apk --use-aapt2
I: Using Apktool 2.8.1
brut.directory.PathNotExist: apktool.yml
[>] Sorry!
[!] java -jar /home/***/.apk.sh/apktool_2.8.1.jar b -d  /home/all -o file.apk --use-aapt2 return errors!
[>] Bye!

Steps to Reproduce

I have 4 split APKs which I try to pack together, using command:
./apk.sh build /home/all

Questions to ask before submission

Yes, latest script version

[BUG] cannot pull latest instagram apk

Information

  1. apk.sh version : 1.0.4
  2. Operating System (Mac, Linux, Windows) : MacOS Ventura 13.4
  3. APK From? (Playstore, ROM, Other) : Playstore
  4. Device : Pixel 3a (Android 12)

apk.sh output

❯❯❯ ./apk.sh pull com.instagram.android
[*] apk.sh v1.0.4
[*] home dir is /Users/{username}/.apk.sh
[*] apktool v2.7.0 exist in /Users/{username}/.apk.sh
[*] apksigner v0.9 exist in /Users/{username}/.apk.sh/sdk_root/build-tools/33.0.1
[*] zipalign exist in /Users/{username}/.apk.sh/sdk_root/build-tools/33.0.1
[*] aapt exist in /Users/{username}/.apk.sh/sdk_root/build-tools/33.0.1
[>] Pulling com.instagram.android: Split apks detected!
[>] Pulling 3 apks in ./com.instagram.android_split_apks/
/data/app/~~cj7mY3z04tmehXjM5xUimQ==/com.instagram.android-kudgMUtbD5bmhF...=/base.apk: 1 file pulled, 0 skipped. 6.3 MB/s (53360636 bytes in 8.056s)
/data/app/~~cj7mY3z04tmehXjM5xUimQ==/com.instagram.android-kudgMUtbD5bmhF...mentation.apk: 1 file pulled, 0 skipped. 5.9 MB/s (74291 bytes in 0.012s)
/data/app/~~cj7mY3z04tmehXjM5xUimQ==/com.instagram.android-kudgMUtbD5bmhF...pytorch.apk: 1 file pulled, 0 skipped. 4.7 MB/s (2072985 bytes in 0.416s)
[>] Combining split APKs into a single APK...
[>] Decoding com.instagram.android_split_apks/base.apk with java -jar /Users/{username}/.apk.sh/apktool_2.7.0.jar d com.instagram.android_split_apks/base.apk -o com.instagram.android_split_apks/base 1>/dev/null
[>] Done!
[>] Decoding com.instagram.android_split_apks/split_arservicesforpersonsegmentation.apk with java -jar /Users/{username}/.apk.sh/apktool_2.7.0.jar d com.instagram.android_split_apks/split_arservicesforpersonsegmentation.apk -o com.instagram.android_split_apks/split_arservicesforpersonsegmentation 1>/dev/null
W: Could not decode attr value, using undecoded value instead: ns=dist, name=title, value=0x7f020000
[>] Done!
[>] Decoding com.instagram.android_split_apks/split_pytorch.apk with java -jar /Users/{username}/.apk.sh/apktool_2.7.0.jar d com.instagram.android_split_apks/split_pytorch.apk -o com.instagram.android_split_apks/split_pytorch 1>/dev/null
W: Could not decode attr value, using undecoded value instead: ns=dist, name=title, value=0x7f020000
[>] Done!
[>] Walking extracted APKs dirs and copying files to the base APK...
[>] Fixing APKTOOL_DUMMY public resource identifiers...
[>] Done!
[>] Disabling APK splitting (isSplitRequired=false) if it was set to true...
sed: 1: "com.instagram.android_s ...": command c expects \ followed by text
[>] Done!
[>] Enabling native libraries extraction if it was set to false...
sed: 1: "com.instagram.android_s ...": command c expects \ followed by text
[>] Done!
[>] Building with java -jar /Users/{username}/.apk.sh/apktool_2.7.0.jar b -d  com.instagram.android_split_apks/base -o file.single.apk --use-aapt2
I: Using Apktool 2.7.0
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes10 folder into classes10.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes9 folder into classes9.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes7 folder into classes7.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes6 folder into classes6.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes8 folder into classes8.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes3 folder into classes3.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes4 folder into classes4.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes5 folder into classes5.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether resources has changed...
I: Building resources...
I: Using aapt2 - setting 'debuggable' attribute to 'true' in AndroidManifest.xml
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-h640dp/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-h640dp/layouts.xml: error: file failed to compile.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-land/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-land/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-land/layouts.xml:5: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-land/layouts.xml: error: file failed to compile.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-sw600dp/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-sw600dp/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values-sw600dp/layouts.xml: error: file failed to compile.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:3: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:4: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:5: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:6: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:7: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:8: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:9: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:10: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:11: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:12: error: invalid value for type 'layout'. Expected a reference.
W: /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res/values/layouts.xml:13: error: invalid value for type 'layout'. Expected a reference.
brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [/var/folders/37/c55v40hd2pg0ycf01ryx3jn80000gn/T/brut_util_Jar_114820535807874165421544189346892466900.tmp, compile, --dir, /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/res, --legacy, -o, /Users/{username}/{working_dir}/apk.sh/com.instagram.android_split_apks/base/build/resources.zip]
[>] Sorry!
[!] java -jar /Users/{username}/.apk.sh/apktool_2.7.0.jar b -d  com.instagram.android_split_apks/base -o file.single.apk --use-aapt2  return errors!
[>] Bye!
zsh: exit 1     ./apk.sh pull com.instagram.android

Steps to Reproduce

  1. adb connect android device (target app installed)
  2. ./apk.sh pull com.instagram.android

APK

Instagram v286.0.0.20.69 arm64 v8a (installed from playstore)

Questions to ask before submission

Are you using the latest apk.sh version?
yes

building split apks / single apk

Hello,

I tried to pull a splitted apk and apk.sh built a file.single.apk.
This file.single.apk did not work as expected after installation (android complained about missing components and proposed to re-download the app via the app store)

After some research, I found how to install splitted apks (avoiding the need for the single apk hack)

  1. first you need to push the apks to the device in /data/local/tmp
  2. then you need to execute a sh script in an adb shell
TOTALSIZE=`wc -c /data/local/tmp/*.apk | tail -n 1 | cut -f1 -d " "`
SESSIONID=`pm install-create -S $TOTALSIZE | tr -dc '0-9'`
INDEX=0
for f in /data/local/tmp/*.apk
do
  let SIZE=`wc -c ${f} | cut -f1 -d " "`
  echo streaming ${f}
  pm install-write -S ${SIZE} ${SESSIONID} ${INDEX} ${f}
  let INDEX=${INDEX}+1
done
pm install-commit ${SESSIONID}
rm /data/local/tmp/*.apk

this creates an install session on the devices and then writes the different apks in this session.

Using this the installed app starts correctly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.