Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

mi_nobl_magisk

Magisk v30.7 on locked bootloader via two vulnerabilities affecting Qualcomm + MIUI/HyperOS devices.

Made with Claude AI and a lot of fixing on my own

Vulnerabilities exploited

  1. Qualcomm fastboot oem set-gpu-preemption and oem set-hw-fence-value — commands allowing inject of arbitrary kernel cmdline parameters, used here to set androidboot.selinux=permissive

  2. miui.mqsas.IMQSNative binder service — MIUI/HyperOS service running as root that accepts arbitrary shell command execution. Combined with echo u:r:su:s0 > /proc/self/attr/current gives full root with correct SELinux context.

Why Magisk instead of KernelSU

KernelSU requires a .ko matched to the exact kernel version. For kernel 6.6.x / Android 16 there are no prebuilt releases (or at least i didn't find them), and building the whole kernel is annoying. Magisk is purely userspace — no kernel module, works on any kernel version.

How it works

fastboot oem set-gpu-preemption 0 androidboot.selinux=permissive or fastboot oem set-hw-fence-value 0 androidboot.selinux=permissive
  └─ kernel boots with SELinux permissive
      └─ service call miui.mqsas.IMQSNative 21 ... runcon u:r:su:s0
          └─ setup: deploy binaries to /data/adb/magisk/
          └─ start: mount tmpfs MAGISKTMP, load sepolicy, start magiskd

Requirements

  • MIUI or HyperOS device with vulnerable fastboot interface (Qualcomm)
  • MQSas service present on your HyperOS build and device vulnerable
  • adb + fastboot on host

Usage

# plug in device, then:
chmod +x host_magisk.sh
./host_magisk.sh

The script will:

  1. Reboot to fastboot
  2. Inject permissive SELinux via cmdline
  3. Continue boot and wait for Android
  4. Push binaries and scripts
  5. Run setup via MQSas (deploys to /data/adb/magisk/)
  6. Run start via MQSas (mounts tmpfs, starts magiskd)
  7. Downloads and installs Magisk Manager APK
  8. Provide scripts to auth apps to use root (because magisk prompt might be broken so we directly query the apps into magisk.db and auth them)

Re-running after reboot

Since this is a temp root you must re-run host_magisk.sh every reboot. The setup stage if magisk has already been deployed previously will be skipped on subsequent boots.

Notes

Seems modules work, just flash them, reboot and re-run the temp root. The device will soft boot and modules will be loaded. Also for some reason com.android.shell at least on my device fails to grant, it's a minor issue but we can stay without it using root, shizuku works instead. Another thing to know is that is not necessary to enable security settings of adb, just normal usb debug is enough, the script uses privileges of MQSas when adb can't do stuff.

Porting to other devices

  • If MQSas transactions don't respond, enumerate nearby transactions (20, 22, 23...)
  • If echo u:r:su:s0 > /proc/self/attr/current is blocked, try runcon u:r:su:s0 or try other contexts (MQSas runs as root anyway, just without the ideal context)

Credits

关于 About

magisk on locked bootloader for mi devices

语言 Languages

Shell100.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
24
Total Commits
峰值: 17次/周
Less
More

核心贡献者 Contributors