3

BlueStacks is a popular Android emulator for Windows and macOS for gamers. It is popular, because the emulator ships with Google Play Store pre-installed and installing any games is easy. Unfortunately, the emulator file system is not rooted by default. How to root it?

6

These instructions require that you understand the UNIX command line basics. The instructions work on OSX, Linux and Windows. No Microsoft Windows or BlueStacks Tweaker needed.

The emulator is internally using VirtualBox and runs Android x64 binaries (64 bit). It ships with two VirtualBox VDI disk images, Prebundled.bdi and Root.vdi. Luckily BlueStacks has left a primitive su binary on the disk image, so we do not need to add this binary to the image ourselves. We still need to change VirtualBox settings, though.

adb command can be obtained from Android Studio SDK by Google or it is also found in /Applications/BlueStacks.app/Contents/MacOS/adb.

Make sure that the emulator is off and turn all disks in VirtualBox configuration file to read-write. On macOS, the file can be found ~/Library/BlueStacks/Android/Android.vbox. Make sure the emulator is not running when you edit this file.

enter image description here

Start the emulator.

Enable ADB bridge in the emulator settings.

enter image description here

Download SuperSU zip file on your local computer.

Start your ADB hacking session.

# This is the default port exposed by BlueStacks
adb connect localhost:5555

Push the zip file to the /mnt/sdcard of the emulated device.

adb push SuperSU-v2.82-201705271822.zip /mnt/sdcard

Then work inside the emulator shell:

# Start shell session in the emulator VM
adb shell
# Use the provided BlueStacks binary to switch to root  
system/xbin/bstk/su

# Disable SELinux
setenforce 0

# Remount all filesystems
mount -o rw,remount,rw /
mount -o rw,remount,rw /system
mount -o rw,remount,exec,rw /storage/emulated

# Unzip SuperSU zip
cd /mnt/sdcard
mkdir supersu
cd supersu
unzip ../SuperSU-v2.82-201705271822.zip

# Extract su command and run its post-install
cp x64/su /system/xbin/su 
chmod a+rwx /system/xbin/su 
/system/xbin/su --install

# Start su daemon mode
/system/xbin/su --daemon

Now run the installer for Superuser.apk in the emulator through Media Manager.

enter image description here

enter image description here

When su --daemon is running SuperSU Android UI should detect the root when started:

enter image description here

The emulator needs to be restarted after this as it hangs. After the restart, when opening SuperSU you see it is enabled.

enter image description here

6
  • I got this error cp: /system/xbin/su: Read-only file system when I ran cp x64/su /system/xbin/su. i followed all of the steps up to that point. How can I fix this?
    – Tabulate
    Jul 25 '20 at 1:00
  • Some of the earlier steps have failed and Virtualbox did not mount the disk in write mode. Jul 27 '20 at 7:25
  • 1
    Something's wrong with the SuperSu zip. It doesn't extract and VirusTotal doesn't like it for some kind of ad aware library. I'd recommend checking on that and ensuring a safe binary is used instead. Oct 1 '20 at 5:10
  • 1
    I just found out in latest build they removed su access. now I get permission denied for su. I did kind of work around. Mounted Root.vdi under Library/Bluestacks/android into ubuntu vm via virtualbox. Added the files manually. changed their permission to 1000:1000 and tried 2000:2000 but did not got it to work. only position independent executables on super su. also tried busybox's su but no luck yet. I copied bstk su to other location. It works but gives output 1 and gives back shell user again. :( Feb 14 '21 at 9:22
  • 1
    may also (instead?) need to change a "ReadOnly" from true to false in bluestacks's HypervVm.json
    – amgg
    Jan 20 at 21:10
1

Mikko Ohtamaa's answer already covered the main question. However, if there are some difficulties while following it, here are some additional tips that may help:

a) If adb connect localhost:5555 doesn't work, try adb kill-server and then adb start-server

b) Usually the .zip file SuperUser..... is a directory, if so, I suggest avoiding these steps

mkdir supers
cd supersu
unzip ../SuperSU-v2.82-201705271822.zip*

c) Try to find the SuperUser.apk on the internet. Then run

Exit from adb and begin from the first step

All steps are similar but

adb push <SuperUser.apk just got from internet> /mnt/sdcard

Avoid these steps

#1. Unzip SuperSU zip

cd /mnt/sdcard
mkdir supersu
cd supersu
unzip ../SuperSU-v2.82-201705271822.zip

#2. Extract su command and run its post-install

cp x64/su /system/xbin/su
chmod a+rwx /system/xbin/su
/system/xbin/su --install

#Continue with the next steps

Then run the SuperUser.apk you got from the internet from the step where says run SuperUser.apk from MediaCenter.

Not the answer you're looking for? Browse other questions tagged or ask your own question.