Skip to main content
Apktool scripts automate the complete APK analysis workflow from decompilation to installation. These scripts handle local and remote execution, APK rebuilding, signing with certificates, and device installation.

Overview

Tool Version

Apktool: v2.4.0 (from install scripts) Download: https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.4.0.jar

APK Analysis Workflow

1

Decode APK

Decompile the APK to extract resources, manifest, and smali code.Choose local or remote execution based on your environment.
2

Analyze & Modify

Review the decompiled code, AndroidManifest.xml, and resources.Make necessary modifications for security testing or research.
3

Rebuild APK

Recompile the modified source back into an APK file.The build process creates a new APK in the dist/ subdirectory.
4

Sign APK

Sign the rebuilt APK with a certificate for installation.Uses uber-apk-signer for automatic signing and alignment.
5

Install APK

Install the signed APK to an Android device or emulator.Uses ADB to push and install the application.

apktool_decode_local.bat

Decodes an APK file locally using Apktool, extracting all resources and code.

Parameters

Script Implementation

Output Structure

Usage Example

apktool_decode_remote.bat

Decodes an APK file on a remote Linux server via SSH, useful for distributed analysis.

Parameters

Workflow

1

Upload APK

Transfers APK to /tmp/ on remote server using pscp.exe.
2

Execute Apktool

Runs Apktool on remote server with Java runtime.
3

Archive Results

Creates tar.gz archive of APK and decoded directory.
4

Download Report

Transfers archive back to local machine.
5

Cleanup

Removes temporary files from remote server.

Script Implementation

Usage Example

apktool_build_local.bat

Rebuilds an APK from decoded source code, with optional signing step.

Parameters

Build Process

The script:
  1. Extracts the directory name from the path
  2. Builds the APK using Apktool
  3. Creates output in dist/ subdirectory
  4. Prompts for optional signing
  5. Calls apk_sign_local.bat if user confirms

Script Implementation

Output Location

Built APK is created at:
Example:

Usage Example

apk_sign_local.bat

Signs an APK file using uber-apk-signer for installation compatibility.

Parameters

Signing Tool

Uber APK Signer: v1.0.0 Download: https://github.com/patrickfav/uber-apk-signer/releases/download/v1.0.0/uber-apk-signer-1.0.0.jar The tool automatically:
  • Creates debug keystore if needed
  • Signs the APK
  • Aligns the APK with zipalign
  • Overwrites the original file

Script Implementation

Manual Signing (Alternative)

The script includes commented examples for manual signing:

Usage Example

apk_install_local.bat

Installs a signed APK to an Android device or emulator using ADB.

Parameters

Installation Process

1

Kill ADB Server

Stops any running ADB server instances.
2

Start ADB Server

Starts fresh ADB server and detects connected devices.
3

Install APK

Pushes and installs APK to connected Android device.

Script Implementation

Prerequisites

  • Android device connected via USB with USB debugging enabled
  • ADB drivers installed on Windows
  • Device authorized for debugging (accept RSA key fingerprint)

Usage Example

Troubleshooting

Device not found:
Installation failed:

Complete Workflow Example

Here’s a complete example of analyzing and modifying an APK:
  • ADB (Android Debug Bridge): Platform tools for device communication
  • JD-GUI: Java decompiler for viewing DEX bytecode
  • Enjarify: Convert Dalvik bytecode to Java bytecode