Magisk - System-level "Magic Mask"
Magisk (Magic Mask) is an open-source Android framework developed by topjohnwu. It has become one of the most popular Android system modification tools since its release in 2016. Its core innovation is to achieve root permission acquisition and modular function expansion without modifying the system partition through "systemless" technology.

Core Functions And Advantages
1. Systemless Root
By virtually mounting and overwriting the system partition, root permissions can be obtained without modifying the /system partition, avoiding triggering OTA update failures or security mechanisms (such as Google SafetyNet) detection.
2. Magisk module repository
- System-level function enhancement and customization: Such as interface beautification (custom status bar, font replacement), performance optimization (such as intelligent management of memory usage through the "BlackHog" module).
- Privacy and security protection: Such as ad filtering (install the "AdAway" module to achieve global ad blocking), permission management (finely control application permissions through the "AppOpsX" module, or forge device fingerprints to bypass application risk control detection), and Root hiding (combined with the "Shamiko" module to bypass system security detection).
- Developer debugging and remote management: Such as dynamic analysis (integrating the "Frida-server" module for application reversing and dynamic hooking), remote access module (deploying the "MagiskSSH" module to remotely control the device through the SSH protocol), and compatibility testing (forging device models and Android version numbers to verify the application's performance in different environments).
- Customizable modules: For example, developing modules to install applications in batches, configure network policies, or execute scheduled tasks.
3. Zygisk Dynamic Injection
The Zygisk technology introduced in version v24 enables more efficient module operation and hidden Root detection capabilities by injecting the Android system core process Zygote.
4. Hide Mode
The root status can be hidden for specific applications (such as banking apps and game anti-cheat systems), and more than 90% of root detection mechanisms can be bypassed when used with plug-ins such as "Shamiko".
Magisk Deployment
This time, based on the Firefly RK hardware platform, Magisk Delta (fdac22ba version) was deployed losslessly in the Android in Docker environment without patching the boot partition or modifying the system image.
- Device: ROC-RK3588S-PC
- Firmware: ROC-RK3588S-PC_Ubuntu20.04-Minimal-r2407_240929
- Device system environment: Completed the "Technical Case - Android in Docker" environment construction
Installation Steps
(1) Import magisk.tar, magisk_setup.rc, setup.sh into the host machine.
//If the host machine is connected to the Internet, you can use the SCP
command to import the host machine
scp ./magisk_delta_fdac22ba/magisk.tar root@xxx.xx.xx.xx:/root/
scp ./magisk_delta_fdac22ba/remove.rc root@xxx.xx.xx.xx:/root/
scp ./magisk_delta_fdac22ba/setup.sh root@xxx.xx.xx.xx:/root/
//Or push to the host machine via adb
adb push ./magisk_delta_fdac22ba/magisk.tar /root/
adb push ./magisk_delta_fdac22ba/magisk_setup.rc /root/
-
adb push ./magisk_delta_fdac22ba/setup.sh /root/
(2) Set magisk_setup.rc permissions.
root@firefly:~# chmod 644 /root/magisk_setup.rc
root@firefly:~# ls -l /root/magisk_setup.rc
-rw-r--r-- 1 root root 979 May 13 07:23 /root/magisk_setup.rc
(3) Modify the container/aic.sh startup script in the host
run_cmd "docker run -itd --restart=always --privileged $CONTAINER_NAME $HOST_NAME $DATA_BIND \
$CONFIG_COMMON $CONFIG_PRIVATE \
$CONTAINER_NETWORK $CONTAINER_MAC $CONTAINER_IP $PORT_BIND \
+ -v ~/magisk_setup.rc:/vendor/etc/init/magisk_setup.rc \
+ -v ~/setup.sh:/setup.sh \
+ -v ~/magisk.tar:/magisk.tar \
-
$ANDROID_IMAGE"
(4) Execute at first startup
./aic.sh -i # Initialization for the first time
-
./aic.sh -r <android image.tgz> <number of containers>
Magisk Function Verification And Use
Installation Verification
1. The host machine needs to be connected to the network.
2. View container status
root@firefly:/userdata/container# docker ps -a --format "table {{.ID}}\t{{.Ports}}"
CONTAINER ID PORTS
-
725921edb3a2 0.0.0.0:1100->5555/tcp, :::1100->5555/tcp
3. Check the host IP
root@firefly:/userdata/container# ifconfig eth0
eth0: flags=4163 mtu 1500
inet 172.16.10.211 netmask 255.255.0.0 broadcast 172.16.255.255
inet6 fe80::fa62:d724:f565:ffed prefixlen 64 scopeid 0x20
ether 6a:01:8e:a5:3f:2c txqueuelen 1000 (Ethernet)
RX packets 384418 bytes 118264726 (118.2 MB)
RX errors 0 dropped 38243 overruns 0 frame 0
TX packets 127586 bytes 29265180 (29.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 92
4. PC uses ADB to connect to the container and cast the screen
lwy@DESKTOP-KGTB0I2: adb connect 172.16.10.211:1100
-
lwy@DESKTOP-KGTB0I2: scrcpy.exe -s 172.16.10.211:1100
- For the first startup, you need to enter the APP to complete the initialization restart
- Verification version number: fdac22ba-delta(25210(D))
Magisk Core Function Demonstration
Superuser Authorization
lwy@DESKTOP-KGTB0I2: adb -s 172.16.10.211:1100 shell
13|rk3588_docker:/ $ su
rk3588_docker:/ #
Enter "su" in the terminal, Magisk will pop up a prompt box, click Grant to complete the authorization.
Zygisk Enable
Magisk settings interface -> Enable zygisk -> Restart. after restart, the zygisk bar on the interface shows "yes".
Application Hiding
Magisk Settings -> Hide Magisk -> Select the disguised app, wait until it is completed, and the icon changes to "Settings".
Magisk Module Application Demonstration
Lsposed
//PC directly import LSPosed-v1.9.1-6990-zygisk.zip
adb -s 172.16.10.211:1100 push LSPosed-v1.9.1-6990-zygisk.zip /sdcard/
Load LSPosed-v1.9.1-6990-zygisk.zip in the Magisk module interface -> restart to take effect.
MagiskSSH
Similarly, import SSH_for_Magisk-v0.22_22.zip into the container, and restart after the Magisk module interface is loaded.
PC directly import SSH_for_Magisk-v0.22_22.zip
adb -s 172.16.10.211:1100 push SSH_for_Magisk-v0.22_22.zip /sdcard/
Use the terminal or Termux to enter the command `ssh user@192.xxx.x.xxx` and the login password to log in. For more usage methods, such as password-free login, please refer to the Readme document of SSH_for_Magisk-v0.22_22.zip.
Technical Information Acquisition
Magisk builds an extensible technical foundation for the Android system through the Systemless architecture. Developers can flexibly develop customized functional components based on their modular interface. The platform provides a standardized development framework and supports full-dimensional customization capabilities from permission management to hardware tuning.
The current case demonstrates two modules, Lsposed and MagiskSSH, based on the Firefly hardware platform. Developers can explore more gameplay and system customization development based on this platform. For complete deployment information of Magisk in Android in Docker environment, please contact the Firefly open source team - global@t-firefly.com