[Android Software/Hacking General [Developers Only]] BlassGO:
SMALI PATCH with MAGISK

SUPPORT: TELEGRAM CHANNEL - TELEGRAM GROUP

ABOUT THIS:
​

This guide will teach you how to patch the classes.dex of APKs and JARs in a Magisk Module, using the Dynamic Installer

What can you do?

Find and Edit smali .methods in directory without breaking their structure

You can also specify some conditions such as a pattern in the name of the .smali files that can be edited or the full name of the .smali file that can be edited

Get a report of modified files in real time (Edited or Not)

You can replace the entire .method, replace something within that .method, remove something within the .method, just replace all internal content of the .method, add something after or before a specific line of the .method

​

Requirements

​

You need download the last Dynamic Installer template​

Knowledge of how to manipulate .smali on Android​

Basic knowledge of shell script​

PRE-INTRODUCTION

$MODPATH = It is a variable that contains the working path of your magisk module

$TMP = It is a variable that contains the path of Temp directory

customize.sh = It is the script that runs when they install your magisk module

module.prop = It is the information of your magisk module

smali_kit = It is a Dynamic Installer utility focused on editing .smali files (More info here)

How to decompile JAR / APK

To decompile .JAR in $TMP directory

apktool -f d "JAR File" -o "$TMP/FOLDER"

Example:

apktool -f d "/system/framework/services.jar" -o "$TMP/my_decompile"

To decompile .APK in $TMP directory (Only .DEX)

apktool --no-res -f d "APK File" -o "$TMP/FOLDER"

Example:

apktool --no-res -f d "/system/priv-app/SystemUI/SystemUI.apk" -o "$TMP/my_decompile"

How to recompile JAR / APK

To recompile .JAR in $MODPATH (Apply MOD)

mkdir -p "$MODPATH/ORIGINAL FILE PATH"

apktool --copy-original -f b "$TMP/FOLDER to RECOMPILE" -o "$MODPATH/FULL ORIGINAL FILE PATH"

Example:

mkdir -p "$MODPATH/system/framework"

apktool --copy-original -f b "$TMP/my_decompile" -o "$MODPATH/system/framework/services.jar"

To recompile .APK in $MODPATH (Apply MOD)

mkdir -p "$MODPATH/ORIGINAL FILE PATH"

apktool --copy-original -f b "$TMP/FOLDER to RECOMPILE" -o "$TMP/Test.apk"

#APKs need zipalign

zipalign -f -v 4 "$TMP/Test.apk" "$MODPATH/ORIGINAL FILE PATH"

Example:

mkdir -p "$MODPATH/system/framework"

apktool --copy-original -f b "$TMP/my_decompile" -o "$TMP/Test.apk"

#APKs need zipalign

zipalign -f -v 4 "$TMP/Test.apk" "$MODPATH/system/priv-app/SystemUI/SystemUI.apk"

smali_kit USAGE

To find a .method ( Example: ".method isSecureLocked" )

smali_kit -method "Method to Find" -dir "Directory"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile"

To find a .method BUT Only in files with a similar name pattern

smali_kit -method "Method to Find" -dir "Directory" -name "Pattern Name"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile" -name "WindowManager"

To find a .method BUT Only in ONE file with the exact name

smali_kit -method "Method to Find" -dir "Directory" -static-name "Exactly Name"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile" -static-name "WindowManagerService.smali"

To replace ALL .method found

smali_kit -method "Method to Find" -dir "Directory" -replace "New .method"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile" -replace "lmao"

To replace something within that .method

smali_kit -method "Method to Find" -dir "Directory" -replace-in-method "Original Text" "New Text"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile" -replace-in-method "const/4 v0, 0x1" "LMAO"

To remove something within that .method

smali_kit -method "Method to Find" -dir "Directory" -delete-in-method "Text to remove"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile" -delete-in-method "const/4 v0, 0x1"

To just replace all internal content of the .method

smali_kit -method "Method to Find" -dir "Directory" -remake "New internal content"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile" -remake "LMAO"

To add something after a specific line of the .method

smali_kit -method "Method to Find" -dir "Directory" -after-line "Line" "Content to add after"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile" -after-line "const/4 v0, 0x1" "LMAO"

To add something before a specific line of the .method

smali_kit -method "Method to Find" -dir "Directory" -before-line "Line" "Content to add before"

smali_kit -method "isSecureLocked" -dir "$TMP/my_decompile" -before-line "const/4 v0, 0x1" "LMAO"

To check changes in found .smali files

Use -check flag with smali_kit

smali_kit -check -method "isSecureLocked" -dir "$TMP/my_decompile" -before-line "const/4 v0, 0x1" "LMAO"

FINALLY, HOW TO PACK YOUR MAGISK MODULE

Unzip Dynamic Installer template

Go to META-INF/com/google/android/magisk

Open customize.sh

In this file you can design the magisk module as you like

EXAMPLES

SystemDialogError Disabler (Magisk Module)

General Samsung Patcher (Magisk Module)