π§ APK/JAR Advanced Tool Kits
Advanced utilities for APK and JAR patching.
dynamic_apktoolβ
Dynamically decompiles or recompiles APKs/JARs with enhanced options.
Flag | Description |
---|---|
-decompile (-d) | APK or JAR to decompile |
-recompile (-r) | Folder to recompile |
-framework (-f) FILE | Framework-res.apk to use |
-add (-a) PATH | Folders/files to add to result (multiple allowed) |
-command (-c) OPT | Extra apktool.jar options |
-output (-o) DEST | Full path to results |
-sign (-s) | Sign the result (recompile) |
-zipalign (-z) | Zipalign the result (recompile) |
-preserve-signature (-ps) | Keep original META-INF and AndroidManifest.xml (recompile) |
-no-api | Disable automatic device API specification |
-no-extras | Disable original resource checking/adding (decompile) |
-use-baksmali FILE | Use external baksmali.jar (DEXed) (decompile) |
-use-smali FILE | Use external smali.jar (DEXed) (recompile) |
# Decompile with added folder
dynamic_apktool -decompile "Test.apk" -o "/sdcard/Test" -add "/sdcard/folder"
# Decompile with custom baksmali and no extras
dynamic_apktool -no-extras -use-baksmali "$TMP/custom.jar" -decompile "Test.apk" -o "/sdcard/Test" -add "/sdcard/folder"
# Recompile with additions, signing, and zipalign
dynamic_apktool -recompile "/sdcard/Test" -add "/sdcard/testfolder" -add "/sdcard/Test/original/META-INF" -add "/sdcard/test.txt" -zipalign -sign
note
It does not decompile or recompile resources (res/
) by default, only .dex
(smali). This guarantees errors prevention in most cases.
smali_kitβ
Manipulates smali files for advanced APK editing.
Flag | Description |
---|---|
-dir (-d) FOLDER | Path to find .smali files |
-name (-n) PATTERN | Pattern for .smali file names (Multiple allowed) |
-file (-f) FILE | Specific .smali file to edit |
-method (-m) NAME | Pattern for method name to find |
-replace (-r) CODE | Replace entire method with new code |
-replace-in-method (-rim) OLD NEW | Replace OLD string with NEW in method |
-delete-in-method (-dim) TEXT | Remove TEXT from method |
-remake (-re) CODE | Replace methodβs internal content |
-after-line (-al) LINE TEXT | Add TEXT after LINE in method |
-before-line (-bl) LINE TEXT | Add TEXT before LINE in method |
-limit (-l) N | Limit number of results |
-check (-c) | Report modified files or no changes |
-delete-method (-dm) | Remove entire method |
-print-path (-pp) | Print paths of .smali files found |
REPLACE="
.method public static isTima()Z
.locals 1
const/4 v0, 0x1
return v0
.end method
"
REMAKE="
.locals 1
const/4 v0, 0x4
return v0
"
# Replace in specific file
smali_kit -check -method "isTima" -file "/sdcard/file.smali" -replace "$REPLACE"
# Search for a .smali by NAME
smali_kit -check -method "isTima" -dir "FOLDER" -name "NAME.smali" -replace "$REPLACE"
# Search for a .smali by PARTIAL NAME
# It is not necessary to know the exact name, just a PART
smali_kit -method "isTima" -d "FOLDER" -name "PART*" -replace "$REPLACE"
smali_kit -method "isTima" -d "FOLDER" -name "*PART*" -remake "$REMAKE"
# This may be more accurate
# Although the name is partial, the file extension should be .smali
smali_kit -method "isTima" -d "FOLDER" -name "PART*.smali" -delete-method
# Search for .smali files with multiple possible NAMES or PARTIAL NAMES
smali_kit -method "isTima" -d "FOLDER" -name "NAME.smali" -name "PART*.smali" -name "*PART2*.smali" -delete-method
# Replace string in method
smali_kit -method "isTima" -dir "FOLDER" -name "NAME.smali" -replace-in-method "const/4 v0, 0x1" "const/4 v0, 0x0"
# Remake method content
smali_kit -method "isTima" -d "FOLDER" -name "NAME.smali" -remake "$REMAKE"
# Simply get the paths of the .smali files that contain a valid method
found_paths=$(smali_kit -print-path -method "isTima" -d "FOLDER" -name "NAME.smali")
info
If you don't specify -name
when specifying a directory (-dir
), all files in the directory will be read to search for the method. This is much slower than filtering the search with multiple full or partial file names.
note
Only Search and reconstruction of Smali Code is ensured with basic principles, an analysis of the new code at the syntax level is not carried out.