APKTool is a powerful reverse-engineering tool for Android apps. Here are the key methods:
Use the following command to extract an APK:
apktool d app.apk -o output_folder
Strings and other values can be edited in the res/values/strings.xml
file.
nano res/values/strings.xml
The AndroidManifest.xml can be modified:
nano AndroidManifest.xml
Search for root detection and debugging checks:
grep -ir "root" smali/
To replace a hardcoded string in the Smali code, use the following command:
sed -i 's/old_string/new_string/g' smali/com/example/app/MainActivity.smali
After making changes, the APK can be rebuilt:
apktool b output_folder -o modified.apk
Before signing an APK, a keystore must be generated:
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
The APK must be signed after modifications:
apksigner sign --ks my-release-key.keystore --out signed_app.apk modified.apk
If needed, the APK can also be signed using Jarsigner:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore modified.apk my-key-alias
A Bash script for automation:
#!/bin/bash
apktool d $1 -o extracted
nano extracted/smali/com/example/app/MainActivity.smali
apktool b extracted -o modified.apk
apksigner sign --ks my-release-key.keystore --out final_app.apk modified.apk