Signing the APK
Decompiling, Modifying, and Signing Android Apps
APKTOOL - Decompile
To decompile an APK, you can use the apktool
command:
If you encounter problems, try decompiling with the -r
parameter, which skips the resource files:
If errors persist, consider using alternative decompilers like jadx
or androguard
.
APKTOOL - Compile
After making modifications, you can rebuild the app:
Ensure you provide the directory path and not the APK file when building.
Creating a New Keystore
To sign the APK, you need to create a keystore. Use the following command:
The alias name can be any identifier you choose. It identifies the correct certificate within the keystore, which can hold multiple certificates.
Before signing the APK, align the file using zipalign
to ensure all uncompressed data start with a 4-byte alignment. This reduces the RAM required by the application:
The aligned file outfile.apk
can now be signed.
Signing the App
Sign the APK with the following command:
This creates a new signed application new-debug.apk
, ready for installation.
New Version - Steps
Here is a summary of all commands in the new version of android systems 11,12:
Decompile the APK:
Modify the SMALI content /
AndroidManifest.xml
.Rebuild the APK:
Navigate to the
dist
directory:Align the APK:
Sign the APK:
Install the APK:
Blue Box Key Vulnerability
To exploit the Blue Box key vulnerability:
Add
classez.dex
to the APK.Use a hex editor (like
ghex
) and search forclassez.dex
.Replace
z
withs
.Now the APK will have two
classes.dex
files.If the vulnerability exists, the APK will validate and accept the latest added
classes.dex
from the attacker.
This vulnerability allows attackers to inject malicious code into an APK by adding an additional classes.dex
file and manipulating its name.
Last updated