[ASUS ROG Phone 5 / 5s] jenwashere:
I just received my ROG Phone 5 today and rooted it using Magisk. These are my notes. (I like to keep rooting notes for each device in case I ever need to check how I did it or repeat the process.)

If you are already familiar with rooting a device with Magisk, then you will find these notes very familiar. These are based on the generic Magisk method listed here: https://topjohnwu.github.io/Magisk/install.html

Magisk's instructions note that the device should be running a stock ROM. If you are using a brand new device, this should already be true BUT there are reports online that some resellers are selling a locked device that was previously unlocked, flashed with a custom rom, and then re-locked. (The people reporting this issue have devices that say Tencent on the back and come in a rectangular box, but it's also possible that you have a Tencent version that can be unlocked. Asus made a deal with Tencent to release a special Tencent edition of the phone, but Asus is also selling the phone as well. I have not heard any reports of the non-Tencent version coming in a state that cannot be unlocked. I bought one that was more expensive and got sent the pro in the non-rectangular box, without Tencent on the back of the phone.)

I rooted the phone from a machine running Ubuntu. I imagine it would also work from other linux distros or from osx, but I have no idea if it will work from Windows.

1) Turn on Developer Options:

Start phone, go through setup process (skip as much as you can because you will lose all of these settings in the rooting process), go to Settings->System->About Phone->Software Information->click on the build number seven times, enter your pin when/if prompted

2) Enable USB Debugging:

Go to Settings->System->Developer Options

Enable USB Debugging

Connect via USB from the side of the phone to your computer (do not use the usb port on the bottom of the phone)

When prompted on the phone, agree to allow File Transfer and USB Debugging and trust the PC

3) Check whether the bootloader is already unlocked:

Open a terminal on your computer

(install adb and fastboot if you have not previously done so)

$ adb reboot bootloader

Wait for device to reboot, then from the terminal do

$ fastboot oem device-info

(bootloader) Verity mode: true

(bootloader) Device unlocked: false

(bootloader) Device critical unlocked: false

... etc

^^ This is what the output may look like if your device is not already unlocked.

If the bootloader is already unlocked, you can skip step 4.

4) Unlock the phone:

Start up your phone

Download the unlock utility on your computer:

https://dlcdnets.asus.com/pub/ASUS/ZenFone/ZS673KS/AsusUnlock_1.0.0.7_210127_fulldpi.apk

from the terminal do

$ adb install ./AsusUnlock_1.0.0.7_210127_fulldpi.apk

This will install the unlock tool on the phone

Open the newly installed unlock app on the phone

Follow the instructions in the app to unlock your device.

After unlock, you will have to go through the phone setup all over again. Annoying, I know.

From this point on, you can expect a warning about your bootloader being unlocked every time you boot the phone. This is normal.

(If unlock fails, you may have been sold a phone that was unlocked by a reseller, flashed with a custom ROM, and then re-locked. If that's the case, this method of rooting your phone will not work. You can always try to return the phone if it was advertised as being unlocked and isn't.)

5) Install Magisk:

Download the latest Magisk apk onto your PC from https://github.com/topjohnwu/Magisk/releases and rename it to Magisk.apk

Open a terminal on your PC and

$ adb install ./Magisk.apk

This will install the Magisk app on the phone

Open it and verify that it says "Ramdisk Yes" two lines under the blue word Magisk. The ROG Phone 5 *should* say this and if it does not something is wrong, refer to the official Magisk instructions.

6) Download the firmware from ASUS:

Let your phone update if it has not already. Mine was pushed an update after install.

Check the exact version you are currently on after the phone updates.

Go to Settings->System->About Phone->Software Information

You need to know your Extension Rom and your Build Number

Then download the firmware from Asus for your build number by going to the URL corresponding to your build number and extension, such as:

https://dlcdnets.asus.com/pub/ASUS/ZenFone/ZS673KS/UL-ASUS_I005_1-ASUS-18.0840.2103.26-1.1.81-user.zip

Where 18.0840.2103.26 from the link above is my build number and 1.1.81 is my extension ROM. If your build number and extension are different, change those values in the URL.

7) Extract the boot.img from the firmware:

Unzip the downloaded firmware

Install Payload Dumper on your PC: https://github.com/vm03/payload_dumper (instructions for installing payload dumper are on the github)

Copy payload.bin from the extracted firmware into the payload dumper folder

Open a terminal, cd to the folder containing payload dumper and payload.bin and then run

$ python3 payload_dumper.py payload.bin

Note: depending on how python is installed, you may need to type python instead of python3 here.

Once this completes, the boot.img file will be in payload dumper's output folder

$ cd output

$ adb push boot.img /sdcard/boot.img

8) Patch the boot file using Magisk:

Open Magisk

Press the install button to the right of the word Magisk

Press "Select and Patch a File", browse to the boot.img from the file folder (if you put it in SDcard like me, try checking the Rog Phone 5 folder for it)

Magisk will patch the boot.img to make it usable for your phone and place it in a file named magisk_patched_[random_strings].img in the Downloads folder of your phone.

9) Flashing the rooted firmware:

Transfer the patched file to your PC and rename it to ./magisk_patched.img

Reboot into fastboot by opening a terminal and entering

$ adb reboot bootloader

Test the image file prior to flashing:

$ fastboot boot ./magisk_patched.img

If that did not error (the bootloader unlock warning is normal), reboot into flashboot and flash:

$ adb reboot bootloader

$ fastboot flash boot ./magisk_patched.img

$ fastboot reboot

After the warning about the bootloader being unlocked, the phone should boot as normal. Once booted, open Magisk and verify that it is rooted by looking for the version of Magisk that is installed. Under the word Magisk in blue, it should say Installed: version. If it says Installed: N/A then your device is not rooted.

You should be able to further test whether you have root access at this point by doing

$ adb shell

$ su

Then clicking accept on the su request on your phone. If that works, the device is definitely rooted.