apk.sh

axGPL-3.0更新放缓

用 Shell 脚本把 APK 拉取、解码、重打包和打补丁这些重复活自动化,省去手动折腾,方便对 Android 应用做逆向分析和动态调试。

Makes reverse engineering Android apps easier, automating repetitive tasks like pulling, decoding, rebuilding and patching an APK.

v1.1.3发布于 2026-01-26 18:41 UTC3,861star +1 / 7 天230fork同步于 2026-11-10 17:41 UTC

怎么上手

由 README 提炼,执行前请确认
./apk.sh pull <package_name>
./apk.sh patch <apk_name> --arch arm
硬件要求按 README 说明

README 未说明;无需 root 的安卓设备,通过 adb 连接真机或模拟器操作

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Bash 脚本自动化 APK 拉取、解码、重建与 Frida 注入,简化安卓逆向流程

用 Shell 脚本把 APK 拉取、解码、重打包和打补丁这些重复活自动化,省去手动折腾,方便对 Android 应用做逆向分析和动态调试。

核心能力

  • 用 apktool 反编译资源并重建为二进制 APK/JAR
  • 向 APK 注入 frida-gadget.so 实现启动即加载
  • 支持 app bundle/split APK 合并为单一 APK
  • 支持 arm、arm64、x86、x86_64 多架构
  • 用 apksigner 对生成的 APK 进行签名

容易踩的坑

需预先安装 apktool、apksigner、unxz、zipalign、aapt、adb 等依赖;patch 时必须用 --arch 指定目标架构;遇到 already interned 解码错误可加 --only-main-classes 传给 apktool

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v1.1.3
  1. v1.1.3最新正式版2026-01-26 · 2026-01-26 18:41 UTC
    • Fixed bug when injecting a full class initializer
  2. v1.1.22026-01-23 · 2026-01-23 19:13 UTC
    查看更新说明
    • Make apktool keep dummy resources id for all missing resources when decoding when pulling splits.
  3. v1.1.12026-01-22 · 2026-01-22 18:03 UTC
    查看更新说明
    • Removed use of --use-aapt2 when building since it is used by default in Apktool v2.9.0 and above.
    • Fixed some errors when dealing with split apks, aapt2 linker seems to inject isSplitRequired="true" into the manifest if other split‑related attributes are present.
  4. v1.12025-04-07 · 2025-04-07 22:29 UTC
    查看更新说明

    Supports direct bytecode manipulation, this avoids decompilation/recompilation errors and preserves original obfuscation and optimizations.

  5. v1.0.112025-03-12 · 2025-03-12 22:24 UTC
    查看更新说明

    Fix in gadget injection

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    :joystick: 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.

    • :mushroom: Patching APKs to load frida-gadget.so on start.
    • :new: Support direct bytecode manipulation with no decompilation, this avoids decompilation/recompilation errors.
    • :bento: Support for app bundles/split APKs.
    • :wrench: Disassembling resources to nearly original form with apktool.
    • :nut_and_bolt: Rebuilding decoded resources back to binary APK/JAR with apktool.
    • :old_key: Code signing the apk with apksigner.
    • :desktop_computer: Multiple arch support (arm, arm64, x86, x86_64).
    • :no_mobile_phones: No rooted Android device needed.

    Getting started

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

    :wrench: Decoding an APK is simple as running ./apk.sh decode <apk_name>

    :nut_and_bolt: 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.

    :mushroom: 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.

    -r, --no-res Do not decode resources when decoding (i.e. apktool -r), optional. Can be used when patching.

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

    :page_with_curl: 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

    https://github.com/ax/DEXPatch