Overview
| Script | Purpose | Environment |
|---|---|---|
apktool_decode_local.bat | Decode APK locally | Windows |
apktool_decode_remote.bat | Decode APK on remote server | Windows (SSH) |
apktool_build_local.bat | Rebuild APK from source | Windows |
apk_sign_local.bat | Sign APK with certificate | Windows |
apk_install_local.bat | Install APK to Android device | Windows |
Tool Version
Apktool: v2.4.0 (from install scripts) Download:https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.4.0.jar
APK Analysis Workflow
Decode APK
Decompile the APK to extract resources, manifest, and smali code.Choose local or remote execution based on your environment.
Analyze & Modify
Review the decompiled code, AndroidManifest.xml, and resources.Make necessary modifications for security testing or research.
Rebuild APK
Recompile the modified source back into an APK file.The build process creates a new APK in the
dist/ subdirectory.Sign APK
Sign the rebuilt APK with a certificate for installation.Uses uber-apk-signer for automatic signing and alignment.
apktool_decode_local.bat
Decodes an APK file locally using Apktool, extracting all resources and code.Parameters
| Parameter | Description | Example |
|---|---|---|
AppExe | Path to apktool.jar | C:\tools\apktool\apktool.jar |
PathAPK | Full path to APK file | C:\apps\sample.apk |
FileApk | APK filename (no extension) | sample |
Timestamp | Unique timestamp identifier | 20230615_143022 |
Documentacion | Output directory path | C:\reports |
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
| Parameter | Description | Example |
|---|---|---|
PathAPK | Local path to APK file | C:\samples\app.apk |
FileApk | APK filename (no extension) | app |
Timestamp | Unique timestamp identifier | 20230615_143022 |
Documentacion | Local output directory | C:\reports |
AppExe | Remote path to apktool.jar | /root/apktool/apktool.jar |
Server | SSH server hostname/IP | 192.168.1.100 |
Username | SSH username | root |
Password | SSH password | password123 |
Workflow
Script Implementation
Usage Example
apktool_build_local.bat
Rebuilds an APK from decoded source code, with optional signing step.Parameters
| Parameter | Description | Example |
|---|---|---|
AppExe | Path to apktool.jar | C:\tools\apktool\apktool.jar |
PathDirAPK | Decoded APK directory | C:\reports\app_20230615_143022 |
AppExeSign | Path to uber-apk-signer.jar | C:\tools\uber-apk-signer.jar |
Build Process
The script:- Extracts the directory name from the path
- Builds the APK using Apktool
- Creates output in
dist/subdirectory - Prompts for optional signing
- Calls
apk_sign_local.batif user confirms
Script Implementation
Output Location
Built APK is created at:Usage Example
apk_sign_local.bat
Signs an APK file using uber-apk-signer for installation compatibility.Parameters
| Parameter | Description | Example |
|---|---|---|
AppExe | Path to uber-apk-signer.jar | C:\tools\uber-apk-signer.jar |
PathAPK | Path to APK file to sign | C:\apps\modified.apk |
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
| Parameter | Description | Example |
|---|---|---|
PathAPK | Path to signed APK file | C:\apps\signed.apk |
FileAPK | APK filename | signed.apk |
Timestamp | Unique timestamp identifier | 20230615_143022 |
Documentacion | Log output directory | C:\reports |
Installation Process
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:Complete Workflow Example
Here’s a complete example of analyzing and modifying an APK:Related Tools
- ADB (Android Debug Bridge): Platform tools for device communication
- JD-GUI: Java decompiler for viewing DEX bytecode
- Enjarify: Convert Dalvik bytecode to Java bytecode