Magisk-Modules-Alt-Repo / BuiltIn-BusyBox

Systemless Magisk module that installs and symlinks BusyBox with its applets to the Magisk built-in busybox binary
GNU General Public License v2.0
187 stars 12 forks source link

Copy busybox to /system/(x)bin #10

Closed HuskyDG closed 1 year ago

HuskyDG commented 1 year ago

Do not create symlink pointing to /data/adb/magisk/busybox, it will not accessible by non-root process or restricted root process (process with root access but limited capabilities such as zygote, adb root, ...). Instead copying busybox to $MODPATH/system/bin and create symlink pointing to ./busybox instead. The context of busybox also must be u:object_r:system_file:s0 not u:object_r:adb_data_file:s0.

zgfg commented 1 year ago

I can copy but the context is currently correct for me, as follows

ls -lZ $(which busybox)

lrwxrwxrwx 1 root root u:object_r:system_file:s0 24 1971-07-14 21:49 /system/xbin/busybox -> /data/adb/magisk/busybox

Also for the applets like:

ls -Z $(which setfattr)

u:object_r:system_file:s0 /system/xbin/setfattr

Screenshot_2023-06-17-09-34-26-804_com offsec nhterm

HuskyDG commented 1 year ago

Non-root process cannot access anything in /data/adb, and busybox is a symlink to /data/adb/magisk/busybox

zgfg commented 1 year ago

Generally, non-root apps should not see eg BB because it opens a door for root detection

Btw, I've recently seen a post on XDA with a screenshot, a 'banking' app reporting that system is read-write because the guy had installed OverlayFS?!

Anyway, attached is the BB module v1.06a that copies the BB binary:

ls -lZ $(which busybox)

-rwxr-xr-x 1 root root u:object_r:system_file:s0 2115816 1971-07-16 03:22 /system/xbin/busybox

BuiltIn-BusyBox_v1.0.6a.zip

zgfg commented 1 year ago

Screenshot_2023-06-17-15-28-58-285_com offsec nhterm

HuskyDG commented 1 year ago

Generally, non-root apps should not see eg BB because it opens a door for root detection

[ -e /system/bin/busybox ] && echo "Found" without root access then you will know

HuskyDG commented 1 year ago

Btw, I've recently seen a post on XDA with a screenshot, a 'banking' app reporting that system is read-write because the guy had installed OverlayFS?!

That guy forget to remount system back to Read-only after remounting to Read-write to modify system files, that is the reason

HuskyDG commented 1 year ago

Generally, non-root apps should not see eg BB because it opens a door for root detection

[ -e /system/bin/busybox ] && echo "Found" without root access then you will know

After unmounting modules, it should not be visible. However, there are some cases we want to use busybox without root access. Example, in Terminal Emulator or Termux, you want to run scripts or test something, it might require busybox. Since /system/bin/busybox is a symlink to /data/adb/magisk/busybox, and access /system/bin/busybox is actually /data/adb/magisk/busybox (/data/adb can only be accessible for root process that has permission to read adb_data_file), not a mounted files, so it is inaccessible

zgfg commented 1 year ago

Sorry, I was on the dark side of Moon over the extended weekend

First I bricked my daily driver Xiaomi by stupidly going over the edge with making changes by using your OverlayFS

Suddenly, phone rebooted and after that only boot-looped to recovery (OrangeFox). Android reported that it cannot decrypt storage - but OrangeFox still happily decrypted and I was able to copy my photos etc to the PC and to upload the ROM OTA and to flash from OF

I couldn't unbrick even with putting uninstall file to the module's folder neither by booting with stock boot IMG (and in the Android safe mode). Android remembered something and it didn't care that stock was returned

Then I said, ok, I will take the case and clean flash the new Xiaomi.eu ROM, upgrading from A12 to A13.

But upon reboot, it complained that the phone is bound to my previous MiCloud account (all as expected) and I had to enter it's pass

But I forgot that pass and since I changed the PC over the years, wasn't able to find it

Next day, after sleeping I solved the problems and activated the phone but (actually, unnecessarily) by asking Xiaomi to unrelated my MiCloud acc from the phone

That way I lost all apps and settings backups I had on MiCloud and (since it was Factory reset) had to re-install and configure everything from the scratch

zgfg commented 1 year ago

Btw, there was an opposite request time ago (to mount instead of copying): https://github.com/zgfg/BuiltIn-BusyBox/issues/1

zgfg commented 1 year ago

Off the topic but for you Husky:

With Xiaomi.eu ROMs (previously A12, now I upgraded to A13), without any custom Kernel, your OverlayFS installs and worls flawlessly, it mounts my read-only /system, /system-ext, /vendor and /product as read-write, I tested by copying and adding files from MiXplorer and Terminal emulator

Previously I had your Delta 25210, now after upgrading the phone Canary 25106 and it works again. Btw, are you planning to update Delta? Screenshot_2023-06-21-07-59-40-542_com android settings-edit Screenshot_2023-06-21-07-58-48-810_com topjohnwu magisk-edit Screenshot_2023-06-21-07-59-10-290_com topjohnwu magisk-edit Screenshot_2023-06-21-08-04-28-781_com mixplorer-edit Screenshot_2023-06-21-08-07-16-793_com offsec nhterm-edit

HankAviator commented 10 months ago

I'm using @HuskyDG 's Magisk Delta and I'm seeing the same problem within Termux. v1.0.6a works.

zgfg commented 10 months ago

I'm using @HuskyDG 's Magisk Delta and I'm seeing the same problem within Termux. v1.0.6a works.

What exact problem?

Termux has its own PATH and if not properly configured it will not see /system/bin or /system/xbin

I don't provide customer support for Termux

Install a simple Terminal emulator, make sure that it has both /system/bin and /system/xbin in the PATH and test

Hint for Termux - Add /system/bin and /system/xbin to the PATH

HankAviator commented 10 months ago

Simply put, checked with solid explorer /system/xbin doesn't include the symlinked applets for v1.0.7. this is a miscall...

I do have both /system/bin and /system/xbin in PATH. v1.0.6a works but v1.0.7 doesn't. Validated with busybox command.

HankAviator commented 10 months ago

I'm curious though why other applets are under /data/adb/modules/BuiltIn-BusyBox/system/xbin but under /system/xbin only busybox seems added

zgfg commented 9 months ago

I'm curious though why other applets are under /data/adb/modules/BuiltIn-BusyBox/system/xbin but under /system/xbin only busybox seems added

This module works fine with the official Magisk, and Magisk Canary versions incl. the latest Magisk Canary v26404

This module also works with the previous versions of Magisk Delta - namely with Delta 26401 (I didn't test with v26402 but I used Delta v26401 for two months and this module worked fine)

So the problem is in Kitsune v26403

Even more, try instead BusyBox NDK module from Osm0sis: https://github.com/Magisk-Modules-Repo/busybox-ndk Download link: https://xdaforums.com/attachments/update-busybox-installer-v1-36-1-all-signed-zip.6000117/

BB NDK will also not work on Kitsune v26403, you will only have busybox binary in /system/(x)bin, but there will be no BB applets (except those that are common to ToyBox and come pre-installed to /system/bin but as part of ToyBox in the ROM)

Ie, BB NDK will similarly create symlinks for the BB applets in its folder: /data/adb/modules/busybox-ndk/system/(x)bin

but Kitsune will fail to mount them to /system/(x)bin

So:

HankAviator commented 9 months ago

Thank you for the time for detailed diagnosis and reply! Didn't know it's a bug of Kitsune. I'll report this to Kitsune developer.

HuskyDG commented 9 months ago

Fixed https://github.com/HuskyDG/magisk-files/releases