Skip to main content

Utilities to help injecting libraries and frida in apks.

Project description

APK Injector

Pluginable tool to automate injection of libraries in apks, with support for unpack, repack, and bundles.

Features

  • Insert libraries and load them when an activity starts.
  • Frida support with support to load frida scripts either from disc or codeshare.
  • Bundle support. Apks exported from SAI or XApks downloaded from apkpure.
  • Plugins support. Check plugins/plugins.json and plugin_example.py

Installation

pip3 install apkinjector

Usage

apkinjector [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  apk      Apk utils
  frida    Inject a frida gadget in a target apk.
  inject   Inject a shared library (*.so) in a target apk.
  plugins  Manage plugins

Frida

Usage: python -m apkinjector frida [OPTIONS] APK

  Inject a frida gadget in a target apk.

Options:
  --gadget TEXT     Path to custom gadget.
  --script TEXT     Inject a javascript to be loaded when the gadget starts.
  --codeshare TEXT  Same as --script but uses Frida Codeshare as the source
                    javascript.
  --arch TEXT       Architecture to inject for. If empty --adb or --gadget
                    must be specified.
  --adb             Use adb (if installed) to detect device architecture.
  --activity TEXT   Name of the activity to inject into. If unspecified, the
                    main activity will be injected.
  --output          Custom path where the patched apk should be saved.
  --force           Force delete destination directory.
  --help            Show this message and exit.

Inject

Usage: python -m apkinjector inject [OPTIONS] APK

  Inject a shared library (*.so) in a target apk.

Options:
  --library TEXT   Shared library (*.so) to inject.  [required]
  --include TEXT   Extra files to include in the lib folder. Can be used
                   multiple times to include more files.
  --arch TEXT      Architecture to inject for. If empty --adb or --library
                   must be specified.
  --adb            Use adb (if installed) to detect device architecture.
  --activity TEXT  Name of the activity to inject into. If unspecified, the
                   main activity will be injected.
  --output         Custom path where the patched apk should be saved.
  --force          Force delete destination directory.
  --help           Show this message and exit.

Apk utils

Usage: python -m apkinjector apk [OPTIONS] APK

  Apk utils

Options:
  --activities   Gets all activities
  --permissions  Gets all permissions
  --libraries    Gets all libraries
  --recievers    Gets all receivers
  --help         Show this message and exit.

Plugins

Usage: python -m apkinjector plugins [OPTIONS]

  Manage plugins

Options:
  --list          List all installed and available plugins.
  --install TEXT  Installs a plugin by name.
  --remove TEXT   Removes an installed plugin.
  --help          Show this message and exit.

Using as a module

from apkinjector import LOG


LOG.info("This has been printed using apkinjector logging")


# Also comes with runners for apktool, uber-apk-signer, etc/

from apkinjector.apktool import ApkTool

from apkinjector.uber_apk_signer import UberApkSigner

# Automatically download and setup apktool.
ApkTool.install()

# Decompile apk
ApkTool.decode(...)

# Automatically download and setup uber-apk-signer
UberApkSigner.install()

# Sign apk
UberApkSigner.sign(...)


# Check if a dependency is in path

from apkinjector import DEPENDENCIES_MANAGER

# Add a new dependency
java = DEPENDENCIES_MANAGER.add_dependency('java', required=True) # Return Depedency(name, path, required)

# Check if a dependency is path
# Returns the path to the binary if found, if not returns None
# See apkpatcher/apkpatcher to see how dependencies are automatically handled
in_path = DEPENDENCIES_MANAGER.java

Usage as a plugin

# Can use the same methods as a it would been included in a separate module.

from apkinjector import LOG

# Adding a new command to the `apkinjector` application:

from apkinjector.plugins import main

# Define a new command. It uses click under the hood. See more at https://click.palletsprojects.com/en/8.1.x/
# Check plugins/plugin_example.py for a full example.
@main.command(help='Prints hello world to the console.')
def hello_world():
    LOG.info('Hello World')  # prints info
    LOG.warning("Hello World")  # prints warning
    LOG.error('Hello World')  # prints error and calls sys.exit(1)

# This will be usable with `apkinjector hello_world`
# 
# apkinjector hello-world --help
# Usage: python -m apkinjector hello-world [OPTIONS]

#   Prints hello world to the console.

# Options:
#   --help  Show this message and exit. 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apkinjector-1.1.1.tar.gz (30.6 kB view details)

Uploaded Source

File details

Details for the file apkinjector-1.1.1.tar.gz.

File metadata

  • Download URL: apkinjector-1.1.1.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for apkinjector-1.1.1.tar.gz
Algorithm Hash digest
SHA256 2ff93d2de85e499951f977f09054c0d40e3442d7e1f4d6237a9ae5c4d1b32d2c
MD5 3840c0e3d9119c97084a6d85f57323f0
BLAKE2b-256 c4af9bfc1a74c78b18a4e78f8df3db8596b02d5a6a13529461c02d4fb362a851

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page