Search This Blog

Saturday, October 1, 2022

Motorola One: Rooting model XT1941-4

My latest project was rooting a Motorola One, a phone model released in October 2018. At first I tried Kingoroot but that app did not work.

These are the three steps that you need:

1. Prepping the phone and getting software for the computer

2. Unlocking the bootloader using Fastboot.exe

3. Completing the root and confirming that it worked.


Step 1: Prepping phone and computer

1. You will need a cable from the computer to the phone, which uses USB-C.

2. Download platform-tools_r33.0.3-windows from Android. Extract the files to some easy to access folder on your computer. C:\Temp\ for example. You will be using ADB.exe and Fastboot.exe for this operation. 

3. Download the device's USB drivers to your computer, such as MotorolaDeviceManager_2.5.4.exe


Step 2: Unlocking the bootloader on your smartphone

This erases all your data, voids your guarantee and you have the full responsibility for what happens next. 

To unlock my Motorola One I used the official guide from Motorola themselves. This requires you to create an account on Motorola. The guide leads to a unlocking code that is used to unlocking the OEM (Original Equipment Manufacturer) of the phone. 

At this step you should have Fastboot.exe and your device USB drivers installed.

1. Put your Motorola One in fastboot mode. Turn your phone off. Hold the minus volume button down and start the phone. Then connect your phone to the computer.

2. On your computer: start command prompt as admin (or start PowerShell as admin, then enter CMD). Set your location to the folder where Fastboot.exe is residing.

Enter this command: fastboot oem get_unlock_data and the command prompt should return 4-5 lines of data. Copy and connect all the data together into one long line containing numbers, letters and symbols. Do not include "(bootloader)". This long text string is the device ID.

3. Paste the device ID into the textbox on the Motorola site and you will be emailed an unlock key that is unique to you.

4. Once again, make sure your phone is in fastboot mode, connected to the computer and that your command prompt is targeted at the location of your fastboot.exe. Verify that your device is connected with this command: fastboot devices.

5. Enter the command fastboot oem unlock <unique unlock key>  and you might have to enter it one more time to confirm. Now you are done, restart device and you will be notified that your Motorola One bootloader has been unlocked.

Step 3: Rooting the device

I based this step on a guide for a phone of the same brand, Motorola G9 Power.

First you need stock firmware, it's basically the pure OS from the original manufacturer. It's something you can fall back on when something goes wrong. I had to flash stock firmware to my recovery for my Google Nexus 7 2012 wi-fi today when I was rooting that tablet for example, after having installed a custom kernel that wouldn't go away.

1. The stock firmware I used for my Motorola One was downloaded from this page, after figuring out which software channel (reteu), model (XT1941-4) and build (QPKS30.54-22-13-15) to use. Getting this wrong can cause nasty side effects. 

2. In your Magisk phone app it should say that you have Ramdisk. After downloading the .zip, unzip the folder and copy boot.img to your phone's storage. My phone didn't have a separate vbmeta partition. Here I followed this guide.

3. Open Magisk app, press install and navigate to "select and patch a file". Target your boot.img-file and start. This creates a patched image file. Bring this to your computer using your command prompt with the following commands:

adb pull /storage/path/to/magisk_patched_[random_strings].img

Reboot your phone into fastboot mode and flash the image that you pulled using this command:

fastboot flash boot /path/to/magisk_patched.img

Once completed, do a reboot and you should be done.

Summary: A few last words on the rooting experience

You can now download Root Checker to see if you can grant super user access. Not all apps can ask for this permission. I'm currently experiencing issues managing super user access from the Magisk app, but it does show apps that have been granted access. You don't seem to be able to "add" permission manually.


Sunday, September 18, 2022

PowerShell: Turning scripts into .exe

Let's say you need to make a portable script and bring it to another computer then for your basic scripts this could be the right solution for you. Using this way you can turn your .ps1 into a working .exe which then can be run like an ordinary file.

First of all, finish up your script. Make sure that file references are dynamic and that the right assemblies are loaded into the script. In a script that reads content for me I started the .ps1-file with the following lines:
 
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Speech
$Speaker = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
 
Once you feel like your script is ready, go to your start menu and launch "IExpress" as an administrator.


1. Choose "create new self extraction directive file" and press next. A SED-file is a file with the settings for your .exe file such as what to prompt the user, how to launch and where to fetch the dependencies.

2. Choose "extract files and run an installation command", and press next.

3. Package title is what name the installation dialog boxes will display. Choose a name and continue.

4. Confirmation prompt can be left empty. This basically asks the user if they want to install or not.

5. License agreement can be left empty as well.

6. Packaged files, choose the script and any files that it depends on.

 
 
7. Install program to launch, here you pick the program that will install/run your program.

Write: powershell.exe -executionpolicy bypass -windowstyle hidden -file filename.ps1

Leave the second box empty.

This will allow PowerShell to run without any execution policies blocking the installation. You will also avoid the big PowerShell window in the background by hiding it.

8. Show window should be set to default if you are using a GUI-application using Windows Forms for example.

9. Finished message, no need to set one unless you are running a script in the background.

10. Set the saving location, check both boxes and press next. If you need to run the .exe on Windows 95 then you don't check the second box.

11. Configure restart, select "no restart" and press next.

12. Save the self extraction directive if you want to go back and make changes in the setup of your .exe, if you don't save the file you just need to make the choices again should you want to remake the executable.

Done, now you should try run the exe and also try running it from different locations.