Rooting Emulator and Installing Magisk

Karthikeyan
System Weakness
Published in
3 min readNov 21, 2023

--

In this blog, we’ll dive into the intricacies of rooting Android Studio AVD. Given the challenges of obtaining physical devices for testing and the risks they present, leveraging emulators emerges as a practical choice for pentesting and more. In this we will explore how to root the emulator, unlocking its potential for various testing needs and beyond.

Prerequisites:
1. Install Android Studio and after installation declare the variables and path as directed in the below steps.
2. Add the “platform-tools” to the path in the environment variable to use ADB.
3. Declare the SDK folder of the Android Studio to the variable “ANDROID_HOME” in the “Environment Variable”.

Steps:
Create an emulator of any configuration with Android release “S”(API 31).

Android Version

Later download rootAVD and run rootAVD.bat ListAllAVDs in the CLI to list out the system images available then copy the path of the ramdisk.img for the API 31 the Android version that we opted to install on the emulator.

Then run the bat file along with the ramdisk.img path to root the emulator CMD: rootAVD.bat system-images\android-31\google_apis_playstore\x86_64\ramdisk.img

Note: The Emulator should be in the active state.

While rooting the AVD it will ask for which version of “Magisk” to install choose the stable version. Once the process is completed the emulator will power off automatically, if not turn it off manually. Later turn ON the emulator, where it can be seen that the machine has been rooted and Magisk has been successfully installed.

I tried to root and install Magisk on various Android releases but this particular version “S” works well. If the playstore is not in the emulator go to the config.ini file present in the .android file and change the value of PlayStore.enabled=true and image path: image.sysdir.1=system-images\android-31\google_apis_playstore\x86_64\.

So I hope this blog will help root AVD, and will be back with another interesting blog.

--

--