Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?

Root OnePlus5 without unlocking the bootloader

Gain adb root.

$ adb shell am start -n --es "code" "angela"

Download Magisk-v14.0 and extract it somewhere. Download MagiskManager.

Now, open a shell (adb shell).

OnePlus5:/ # mkdir /data/magisk
OnePlus5:/ #

Push the required file to the device:

adb push {arm64/*,common/*} /data/magisk/
arm64/magisk: 1 file pushed. 6.7 MB/s (192736 bytes in 0.027s)
arm64/magiskboot: 1 file pushed. 20.2 MB/s (316536 bytes in 0.015s)
common/ 1 file pushed. 3.1 MB/s (7732 bytes in 0.002s)
common/init.magisk.rc: 1 file pushed. 0.3 MB/s (675 bytes in 0.003s)
common/magisk.apk: 1 file pushed. 21.6 MB/s (3311368 bytes in 0.147s)
common/ 1 file pushed. 2.5 MB/s (6688 bytes in 0.003s)
6 files pushed. 17.9 MB/s (3835735 bytes in 0.205s)

Download busybox for arm. Extract it and push it to the device:

adb push busybox-armv6l/system/xbin/busybox /data/magisk/

Install MagiskManager:

adb install ../MagiskManager-v5.4.0.apk

Back on the ADB shell (adb shell):

OnePlus5:/ # cd /data/magisk/
OnePlus5:/data/magisk # ls busybox init.magisk.rc magisk magisk.apk magiskboot
OnePlus5:/data/magisk # ./magisk --createimg magisk.img 64
Creating filesystem with parameters:
    Size: 67108864
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 4096
    Inode size: 256
    Journal blocks: 1024
    Blocks: 16384
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/4096 inodes and 1294/16384 blocks
OnePlus5:/data/magisk # mv magisk.img ..
OnePlus5:/data/magisk # ./magisk --createimg xbin.img 64
Creating filesystem with parameters:
    Size: 67108864
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 4096
    Inode size: 256
    Journal blocks: 1024
    Blocks: 16384
    Block groups: 1
    Reserved block group size: 7
Created filesystem with 11/4096 inodes and 1294/16384 blocks
OnePlus5:/data/magisk # ./magisk --mountimg xbin.img xbin
OnePlus5:/data/magisk # cp /system/xbin/* xbin/
OnePlus5:/data/magisk # cp magisk xbin
OnePlus5:/data/magisk # umount xbin
OnePlus5:/data/magisk # rmdir xbin
OnePlus5:/data/magisk # ./magisk --mountimg xbin.img /system/xbin
OnePlus5:/data/magisk # magisk --post-fs
OnePlus5:/data/magisk # magisk --post-fs-data
OnePlus5:/data/magisk # magisk  --service

That's it, your phone is now rooted and Magisk modules should work too. After a reboot you'll need to repeat the last steps:

$ adb shell
OnePlus5:/ # cd /data/magisk/
OnePlus5:/data/magisk # ./magisk --mountimg xbin.img /system/xbin
OnePlus5:/data/magisk # magisk --post-fs
OnePlus5:/data/magisk # magisk --post-fs-data
OnePlus5:/data/magisk # magisk  --service

aldur commented Nov 14, 2017

Credits for the initial exploit to the amazing Elliot Alderson (@fs0c131y):

Roguyt commented Nov 14, 2017

Is it required to apply the last step after every reboot ? Or just once for the installation ?

Seems like you forgot to mention having to chmod +x magisk, other than that it seems to be working perfectly

MagiskManager also seems to report "Not Rooted"


aldur commented Nov 14, 2017

@Roguyt: you need the last steps after any reboot.
@martmists: it was already executable in my case, are you using Windows by any chance?

Arch Linux here, might just be linux preventing you from getting already executable files from a zip/download

@aldur su doesn't seem to be working however, any clue?

Same here. Had to chmod, and it said magisk installed, no root. Now it says magisk not installed, no root. Any ideas?

Roguyt commented Nov 14, 2017

@aldur No way to auto execute those lines ?
Either ways everything is working as expected 👌

@Roguyt I might be able to make a bash script for Linux users, will report back once done.


aldur commented Nov 14, 2017

@Roguyt: Yeah it's the next thing I'll work on, my plan is to do it without requiring a computer.

Roguyt commented Nov 14, 2017

@aldur Good luck, i'm still trying to install Xposed through Magisk but it seems to doesn't want to install.
Still a good way to root but not really reliable for everything


aldur commented Nov 14, 2017

To those of you having troubles, double check that magisk_daemon is running:

OnePlus5:/ # ps | grep magisk
root      4911  0     1     35204  3752  __skb_recv 7fa055b49c S magisk_daemon
u0_a149   6308  902   831   1800832 51952 SyS_epoll_ 7fa8df04fc S com.topjohnwu.magisk

If it is running and MagiskManager is not detecting root, kill it (kill 6308 in my case) and start it again.


aldur commented Nov 14, 2017

@Roguyt: yeah I didn't try Xposed yet, but it probably requires something more. Check where the update_script is failing and start debugging from there.

@aldur Yep, working now. Thank you.

Roguyt commented Nov 14, 2017

@aldur Apparently it failed just from copying zip to /system /vendor, etc so i guess rip
Anyway i think yeah it needs some changes and that this root is a POC of Qualcomm and manufacturers mistakes

when i put this comand :

adb push {arm64/,common/} /data/magisk/

got this :

1|OnePlus3T:/ # adb push {arm64/,common/} /data/magisk/
adb push {arm64/,common/} /data/magisk/
/system/bin/sh: adb: not found

what i do.


aldur commented Nov 14, 2017

@Roguyt yeah our whole thing here does not touch system, if Xposed wants to modify anything there it won't work, we have dm-verity enabled and that forbids the bootloader from booting the system if any partition is modified.
@jrekiri85 you need to run that command from your PC.

Roguyt commented Nov 14, 2017

@aldur Yep that's what i was thinking and kinda confirmed by knowledge. Still a great POC :p

@aldur I've been thinking... Since magisk has this magisk_merge.img that integrates with /system, would it be possible to make something that can flash to /system using that image file?

@aldur im running the comand on the pc, not on the mobile

xaviex commented Nov 14, 2017

@aldur Any word on if this is going to trip safety net?

Lopry02 commented Nov 14, 2017

Adoperando questo metodo, il dispositivo avrà sempre la spunta su Safetynet?

In order to push the required files to your device, you need to do this:
OnePlus5:/ # exit
Then you can use adb to push those files without the errors. After that and installing Magisk Manager, you can return to the adb shell.
As @martmists stated earlier, run this command:
chmod +x magisk
Otherwise, you get the "Permission denied" error when running the main Magisk program.
I hope that clears up a lot of things when doing this on your devices.

SpasilliumNexus commented Nov 15, 2017

I haven't tried rooting my OnePlus 3T this way (yet), but by the looks of it, couldn't you use a Terminal app to apply those last four commands after every reboot, or do you need to be root to apply them?

If root is not needed, and you can run them in Terminal, using Tasker to run the task at every boot would be much simpler for those who use it. You can even have the task show a notification when it completes.

YUDHPK commented Nov 15, 2017

Do we pass safety net or not?

Will i able to het OTA update after this?

@SpasilliumNexus you will need to run them from ADB, as you do not have root until those commands are entered, and root is needed to run those magisk commands.

in oneplus3 i do it follow you write
magisk say Magiskv14.0 has install but not root.....

@tangsilian Make sure the magisk daemon is running

joedu12 commented Nov 15, 2017

I've rebooted then the disappeared, how can this be possible ? :o

@aldur few reboots later, experiencing same issue as others. Daemon undetected, even when restarted.

Update: magisk su works, su does NOT

The daemon also only seems to run while ADB is connected


aldur commented Nov 15, 2017

@martmists, are you sure about the daemon? I am currently running with all the developer options disabled, without issues.


aldur commented Nov 15, 2017

@YUDHPK: Yes you'll pass safetynet and you'll receive OTA.

@aldur Weird, could this have been caused by windows vs linux? I'll try windows in a few minutes to check.

Managed to get it working on Windows and Magisk 14.0 (On Linux I used 14.3), however root was lost after disconnecting from ADB

can some one make a video with a step by step guide.

Lopry02 commented Nov 15, 2017

@xaviex I'm from Italy and I thought I could ask my question in Italian to aldur because he's from Italy. I asked if this root method can pass Safetynet or not


aldur commented Nov 15, 2017

@Lopry02 it will pass safetynet, by the way.

@ITsMu1zz I'll see if I can make one later

@aldur How did you get the daemon process to persist after disconnecting from ADB? To me it seems like the daemon was bound to the ADB session.

OnePlus3T:/ $ su
Starting daemon requires root: Connection refused
1|OnePlus3T:/ $ magisk su
Starting daemon requires root: Connection refused
1|OnePlus3T:/ $

@Roguyt I made an attempt, though this code is untested and I have limited Linux experience.
Check the files out here

xaviex commented Nov 15, 2017

@martmists IS this a test of a zero reboot code required?

You sadly will have to run code at reboot. As of right now I'm trying to work on making modules that mount /system work using a dummy file and merge img

YUDHPK commented Nov 15, 2017

Magisk su working perfectly on my one plus 3t with open beta 17
successfully passed safety net test.
next task i will try is to use adaway systemless to block ads and then reboot
Thanks @aldur

Hi! Can you make the same with the OnePlus 2 please?

@Wipperland what type of processor is it, and does it have the EngineeringMode app installed?

andQlimax commented Nov 15, 2017

@YUDHPK on your oneplus 3T with Oreo beta it working fine right? Did you only followed instruction or did something different?

YUDHPK commented Nov 15, 2017

i followed the instructions @andQlimax (read everything even comments before starting)

guys i have a question . currently i am using android oreo open beta 17 on my 3T with stock recovery and locked bootloader .
what will happen if i change system by mistakely?
also my device is encrypted by default.

It will not allow to change system because dm-verity is still enabled, I tried it.

Is there a way to unlock bootloader state with root, without trigger the factory reset?

xaviex commented Nov 15, 2017

@aldur How would one go about removing magisk, is this functionality already built inm?

@xaviex to remove magisk, simply reboot (or use umount /system/xbin) and delete /data/magisk.img and /data/magisk/

@andQlimax I'm looking for a way to edit boot.img without triggering dm-verity, but it seems near-impossible to pull off... unless of course you unlock your bootloader

@sirmordred I'll see about making a custom script to use for SuperSU

ThatGuyWhoUsesLinux commented Nov 15, 2017

Uh, Probably doing this wrong. I enter the first command: adb shell am start -n --es "code" "angela"
and get the error:
Starting: Intent { }
Error type 3
Error: Activity class {} does not exist.

@ThatGuyWhoUsesLinux are you sure you have the EngineeringMode app? It doesn't seem like it, and it's the core of this exploit.

Any way to unroot O.o

Lopry02 commented Nov 15, 2017

Thanks a lot @aldur

ThatGuyWhoUsesLinux commented Nov 16, 2017

@martmists Yes, I checked before attempting this exploit.

@aldur @martmists nevermind, its working good :) (confirmed on OnePlus3T)
TO ALL i made an app that automates all the process and install SuperSU here you go

chuckfecht commented Nov 16, 2017

On OnePlus 3t with Android Oreo open beta, I'm getting the error "Please use BootBridge from @AdrianDC to flash Magisk" while running
sh busybox init.magisk.rc magisk magisk.apk magiskboot (I modified the command from above slightly because as it was it refused to work)

xaviex commented Nov 16, 2017

So what are the chances of finding a way to run magisk, untethered, in such a way that doesn't trip safetynet

YUDHPK commented Nov 16, 2017

divide this command
adb push {arm64/,common/} /data/magisk/
into two separate commands like

  1. adb push arm64/ /data/magisk/
  2. adb push common/ /data/magisk/
also while executing the commands you should be inside extracted magisk folder in the terminal

osm0sis commented Nov 16, 2017

You could just use your adb root to dd dump the boot.img and then use Magisk Manager to patch it, and then dd flash the rooted boot.img back. Full root that persists through reboot.

YUDHPK commented Nov 16, 2017

i have the rom zip file from which i can extract the boot.img
then i can patch boot.img file using Magisk manager will it work ?
i flashed the boot.img using magisk manager
it didnt work.

After root do we have to update full size ota or the one we recieve in system updates?

martmists commented Nov 16, 2017

@rootxharsh to remove magisk, simply reboot (or use umount /system/xbin) and delete /data/magisk.img and /data/magisk/
@chuckfecht Don't run that, it's just the result of ls. We cannot patch the boot image yet sadly :P
@xaviex Currently magisk does not trip safetynet
@osm0sis Feel free to make a guide and test it! I've been thinking about adding that, but I'm worried about dm-verity screwing us over.
@prakashgd As long as the OTA doesn't remove persist.sys.adbroot it's perfectly fine to update using system updates

Guddu4 commented Nov 16, 2017

Will this apk install magisk too??

@Guddu4 It can easily be modified to install Magisk, but no, as of now it does NOT.

@martmists feel free to contribute it brah, adding Magisk support shouldnt be hard as you said (it needs third script and needs magisk files in asset) any contributions are welcome

Update: using Flashify to flash magisk's patched boot WILL cause a bootloop.

YUDHPK commented Nov 16, 2017

can we flash recovery like twrp after obtaining root?

@YUDHPK You can try, but you will risk bootlooping. You can use either dd or any flashing app that uses root to flash. If you get it to work, let me know and I'll see if I can reproduce it

Guddu4 commented Nov 16, 2017

After getting root what's the procedure to install magisk..
I am noob at this...
Can some one make guide for it...

YUDHPK commented Nov 16, 2017

@martmists i can't risk of getting a bootloop.
also i prepared a script package just like you but it works with just 2 scripts (for user)
1 required for installing
1 for reinitializing after reboot

last but not the least to uninstall.

tested on my oneplus 3 open beta 18

Also friends substratum is also working with root(just like old times . i didnt make it happen)

YUDHPK commented Nov 16, 2017

@Guddu4 this will work for you (even i have average linux knowlegde)
installation proof

reinitilaization proof

@martmists sorry for using the same repo name as yours BackDoorRootScripts and some files which gives warning as i am not a good writer

Guddu4 commented Nov 16, 2017

Thanks @YUDHPK

The Angela back door still working with today oneplus 3t open beta update?

andQlimax commented Nov 16, 2017

@YUDHPK thanks. Downloading the new open beta OTA. It detected root, so it is downloading the full OTA. Even if I removed magisk.
Probably because the adb shell root is still active

FYI: probably OP should be updated with new Magisk 14.4 and new apk?

YUDHPK commented Nov 16, 2017

@andQlimax don't worry nothing will happen .
you just need to install again.

also here we are testing some new concept so its better to use stable v14.0 version instead of beta

For anyone having trouble with Magisk detecting your root, try launching the EngineerMode app again and clicking "Privilege Recover."
According to this guy, quote, "root from the Qualcomm App and root from Magisk can't cohabit".
This fixed Magisk not detecting root for me (I'm on OP2)

@YUDHPK Tried flashing twrp with the locked bootloader via the backdoor, soft bricked my phone. Have to reflash original boot.img to fix

Can confirm the above for flashing a patched boot.img, though a system reset had to be done as I got locked out of my device

@martmists I was locked out as well. All I had to do was boot the boot.img in fastboot (fastboot boot [location]/boot.img)

I'm trying to get Unified Hosts Adblock on magisk working but no luck. I install the module and restart manually(restart in app does not work). After restarting I execute the final few commands. The final 3 commands I execute twice as first time magisk will say it's not rooted. After that I try su && hosts but hosts cannot be found...Systemless hosts also is toggled off again after restart.

Why can't we disable the DM Verity thing, which we do when we change the recovery.

@TurtleSandals this is because magisk doesn't run on boot and is unable to mount /system before it becomes a busy partition.

@apurvakumar01 I believe DM-Verity is part of the boot partition which is hard to edit out. Magisk supposedly is able to patch this but I've had no luck so far.

Raboo commented Nov 18, 2017

Is there no way to make the root persistent across reboots?

Not until we can patch boot.img @Raboo

Hi everyone...sorry for out of topic bcoz i'm using diffrent phone brand and model..l'm looking everywhere to root my device Lenovo PB1 750M
6.0.1 mushmallow...already tried all kinds of roots app about 12 i think...please give me any suggestion...
Can i using root plus one ?....please show me or teach me...
Thank you all...

Raboo commented Nov 19, 2017

@martmists ok, thanks for the info.

OOS5 is apparently rolling out for those in Canada; can anybody report on whether the update removes the backdoor?

I used it on my OP3T before the update and you retain adb root after the update at least. I do not know if they have already patched out the command to get it. Reapplying magisk root worked without a hitch after upgrading.

Blubster commented Nov 20, 2017

It seems the backdoor is no longer there in OOS 5.0 on my OP3T. I tried this morning to launch the intent, it opens on my screen but i do not get any root adb with this.
On my screen there are four options :
Engineer Mode Toggle
Full port switch
Rndis,diag switch
None of these options enable a root ADB :

adb shell id
uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc) context=u:r🐚s0

We can say they were pretty quick to remove this backdoor! ^^

nlsantos commented Nov 22, 2017

Has anybody experienced the magisk binary disappearing after running magisk --post-fs-data. Immediately after mounting xbin.img, running which magisk will output /system/xbin/magisk, but after magisk --post-fs-data, which returns 1?

I can remount xbin.img onto /system/xbin, but I've noticed that root disappears after a while, and I can't run any other terminal apps (within Termux). Or I can use the magisk binary inside /data/magisk, to run magisk --service, but then MagiskManager can't detect root.

EDIT: I think this is due to my installing Busybox via Magisk Manager. It looks like when Magisk binds the binaries into /system/xbin, the setup gets clobbered.

Pileot commented Nov 22, 2017

Two questions hopefully you can help me with

On the OnePlus 3 how can I use this to move an app to /system/app in 7.1.1?
Every method I've tried so far fails. LuckyPatcher fails. manually moving the folders fails. I downloaded "App Systemizer" with Magisk, manually installed the APK, rebooted, tried to move the app that way, still failed. Suggestions?

How can we remove root after using this method? For instance, OTA still detects root even after a reboot. Id really rather not reinstall.


YUDHPK commented Nov 23, 2017

@aldur there are many changes for magisk 14.5 .
please update the instructions
or specify atleast what should be used in both cases (case 1: 14.0 & 5.4.0) (case 2: 14.5 & 5.4.2)

Does it work with Magisk 14.5?

YUDHPK commented Nov 25, 2017

@max23468 not yet

@Pileot simply reboot and it should be unrooted.

@YUDHPK what all changed? I might need to edit my repo too

YUDHPK commented Nov 25, 2017

@martmists see the changelog for magisk v14.5 here

Also magisk manager 5.4.3 and 5.4.2 crashes with magisk v14.0

Pileot commented Nov 26, 2017

@martmists when I reboot and select the OTA update it still detects root. If I finally DO find a way to move an app to system and do a full OTA it will delete the system app - something I am trying to avoid.

It is still working on today new OOS open beta?

@andQlimax it still works

Lopry02 commented Dec 2, 2017

I cancelled the two .sh files by wrong. How can I get them again?

Lopry02 commented Dec 2, 2017

I updated to Oreo Open Beta and I tried to root my device again, but I cancelled that files.

Lopry02 commented Dec 2, 2017

Please, can you add the angelaroot folder into a zip to share me it?

Adb push was failing for me:

# adb push {arm64/*,common/*} /data/magisk/
failed to copy 'arm64/magisk' to 'arm64/magiskboot': secure_mkdirs failed: No such file or directory

So I've used this instead:

# for file in {arm64/*,common/*}; do adb push -p $file /data/magisk/; done
Transferring: 192736/192736 (100%)
2214 KB/s (192736 bytes in 0.084s)
Transferring: 316536/316536 (100%)
3163 KB/s (316536 bytes in 0.097s)
Transferring: 7732/7732 (100%)
164 KB/s (7732 bytes in 0.045s)
Transferring: 675/675 (100%)
13 KB/s (675 bytes in 0.049s)
Transferring: 3311368/3311368 (100%)
6545 KB/s (3311368 bytes in 0.494s)
Transferring: 6688/6688 (100%)
145 KB/s (6688 bytes in 0.044s)

aoprea75 commented Dec 5, 2017

How can we delete some apps (directory) from system/app or system/priv-app ??? (debloating)

i falow the guide and obtained root .. but system is read-only and cannot delete anything
i tried mount -o rw,remount /system but phone is restarted

sow .. it's possible to debloat system folder ?


Just to let you all know I just received the OnePlus 5T Monday and it has EngineerMode on it. Do you all believe this will still work with it?

@RBuenemann most likely, yes

@aoprea75 some devices do not allow remounting /system

@shark0der make sure the correct directories have been made

@andQlimax It works on my device

@aldur Here's an idea for persistant root:


@martmists isn't there any way to change bootloader status without trigger factory reset?

martmists commented Dec 19, 2017

@andQlimax what do you mean? It's not possible to unlock the bootloader without doing that...

lu-zero commented Dec 19, 2017

I tried with a oneplus5t and looks like they plugged the su side-effect =/

SelaO commented Dec 21, 2017

Can I do this with the latest OS update on the op5?

I'm getting this:

It seems OnePlus removed the EngineeringMode app on the OP5 and OP5T devices in an OTA, so it is no longer possible until you install the app manually.

YUDHPK commented Dec 22, 2017

Guys magisk manager v5.5.0 is working great on open beta 19 of op3T

It's work with OnePlus2 ?

YUDHPK commented Dec 26, 2017

@aldur can you guide us for magisk 15.0 and manager 5.5.1

@fabien91 if you have an EngineeringMode app, yes
@YUDHPK procedure should be the same, shouldn't it?

@martmists no the file names have changed, further if you already had magisk installed on previous version then you can run the command and you get root. If not you need to go back to older version and update Magisk sustains.

I tried doing it but since the file names and files have changed did not succeed, your help is needed, please. @martmists

Stay with using Magisk 14.0, I don't actually know how to do it with 15.0 either

Currently I'm trying to get a modified boot image to be flashed using EDL, but I'm getting an md5 mismatch

Raboo commented Jan 1, 2018

I might have fucked up. I used the magisk built in auto update. And now my OP3T doesn't recognize my pin when I rebooted the Phone.
What are my options?

Raboo commented Jan 1, 2018

I was able to recover using recovery and adb sideload to put in the original ROM. And all my settings remained :-)

doegox commented Jan 3, 2018

There is a 15.2 release fixing issues for oneplus5:
Any idea how to install it?

YUDHPK commented Jan 4, 2018

@doegox nope not yet

guys for latest open beta on oneplus 3t you should run this command
adb shell am start -n com.oneplus.factorymode/.qualcomm.DiagEnabled --es "code" "angela"

dotternetta commented Jan 11, 2018

adb noob here :-( this is killing me! When I enter the first push command I get this:

C:\Android>adb shell
root@OnePlus2:/ # adb push {arm64/,common/} /data/magisk/
adb push {arm64/,common/} /data/magisk/
/system/bin/sh: adb: not found

Please help. I download Download Magisk-v14.0 and extracted it in the c:/android/ folder from where I run adb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment