This tool allows you to patch APK files for Frida instrumentation using the Frida gadget. It injects the required libraries and smali code into the APK, re-signs it, and ensures the APK is ready to use with Frida for reverse engineering or penetration testing.
- Disassembles APK files using
apktool
- Adds
INTERNET
permission and customnetwork_security_config.xml
if not already present - Injects Frida gadget libraries into the APK
- Modifies the APK's smali code to load the Frida gadget
- Rebuilds, aligns, and signs the APK for use
- Compatible with Android versions that support APK Signature Schemes v1 and v2
Before using this tool, ensure the following tools are installed on your system:
aapt
(Android Asset Packaging Tool)apktool
zipalign
apksigner
- Python 3.x
- Java Development Kit (JDK) for APK signing
git clone https://github.com/sperixlabs/frida-apk-patcher.git
cd frida-apk-patcher
Place the APK you want to patch in a known directory. Note the absolute path to the APK, as it will be needed during execution.
Run getlibs.sh
to fetch the latest Frida Gadgets
bash getlibs.sh
Run the script with the path to the APK you want to patch. Here's the command:
python apk_builder.py --apk /path/to/your.apk
python apk_builder.py --apk /home/user/downloads/sample.apk
After the tool finishes running, it will output the patched APK file as your-apk-appmon.apk
in the same directory where the original APK was located.
--apk
: Absolute path to the APK you want to patch.
- The patched APK file will be created in the current working directory as
app_name-appmon.apk
.
- Over USB
frida -U Gadget -l [frida_script]
- Specific Device
frida Gadget -l [frida_script] -D [device_name]
-
Signing Errors: Ensure you have the correct Java Development Kit (JDK) installed and set up. The signing process uses
apksigner
, which requires the keystore and password (appmon.keystore
andpass:appmon
in this case) to sign the APK. -
Zipalign Issues: Ensure
zipalign
is correctly installed and available in your PATH environment variable. If you're using Android SDK, this tool is located in thebuild-tools
directory.
Feel free to open issues or submit pull requests if you find any bugs or want to contribute to improving this tool. Your contributions are welcome!