adb_root icon indicating copy to clipboard operation
adb_root copied to clipboard

USB Debugging does not work when installed

Open duraki opened this issue 5 years ago • 15 comments

@evdenis USB Debugging does not work once this module is installed and enabled in Magisk.

duraki avatar Jun 26 '20 15:06 duraki

This means that adbd is not starting. Reasons could be different. What android version? What phone, firmware? Does it work if you switch selinux to permissive mode?

evdenis avatar Jun 26 '20 20:06 evdenis

Phone: Samsung SM-G900F Flashed+rooted, running ViperOS 6.7 Android Version: 9

I'll try setting SELinux to permissive and let you know.

duraki avatar Jun 27 '20 09:06 duraki

Nop. Same. Setenforce is set to 0 (Permissible). Restarted the device (SELinux persist the state Permissible).

root@kali:~# adb root
restarting adbd as root

Device gets disconnected. Reattaching the cable does not work.

root@kali:~# adb shell
error: no devices/emulators found

Can I execute the module with debug (stdout/err) info from the console (I can ssh into the phone)?

duraki avatar Jun 27 '20 10:06 duraki

Ok, found the hotfix:

Init

$ ssh root@android -p2222
(android) $ whoami
root
(android) $ adbd

Confirmation

root@kali:~# adb root
restarting adbd as root

root@kali:~# adb shell
(android) $ whoami
root

Now I'm wondering what is the issue that kills adbd on my phone. :/

duraki avatar Jun 27 '20 11:06 duraki

same issue on samsung j2core (j260gu) 8.1.0 oreo.

kmanjunathk41 avatar Jul 03 '20 10:07 kmanjunathk41

Same issue on Oneplus 7T Pro Oxygen OS 10.0.12

oxillix avatar Aug 14 '20 20:08 oxillix

Any error messages in dmesg? I wonder if something like https://github.com/frida/frida/issues/877#issuecomment-549636944 would work.

Manouchehri avatar Aug 17 '20 17:08 Manouchehri

I wonder if something like frida/frida#877 (comment) would work.

No, it won't work. SELinux (most probably) kills adb root because this policy https://github.com/evdenis/adb_root/blob/master/sepolicy.rule is not enough on Samsung SM-G900F, samsung j2core, Oneplus 7T Pro devices.

I don't have these devices and can't debug and test the module on them.

The simplest and universal way to solve the issue on these devices is to switch SELinux to permissive mode during boot process.

evdenis avatar Aug 21 '20 22:08 evdenis

The simplest and universal way to solve the issue on these devices is to switch SELinux to permissive mode during boot process.

@evdenis that does not work, see this; https://github.com/evdenis/adb_root/issues/2#issuecomment-650542332

duraki avatar Aug 23 '20 13:08 duraki

That's why I wrote "(most probably)". I don't know the exact reason on your phone and obviously can't debug it. I only know that SELinux can kill the process or the kernel itself (on samsung devices it's true because of this code https://github.com/CruelKernel/samsung-exynos9820/blob/1039ba0bf7e89464e0b233b78f31277c6da5bdd0/fs/exec.c#L1837, https://github.com/CruelKernel/samsung-exynos9820/blob/1039ba0bf7e89464e0b233b78f31277c6da5bdd0/security/samsung/defex_lsm/defex_rules.c#L85). Maybe selinux in your case starts in enforcing mode during boot and switches to permissive too late. You can check kernel log or /proc/avc_msg file for strings like 'avc' or 'denied' or 'adb'.

evdenis avatar Aug 23 '20 14:08 evdenis

The way you fixed your problem with starting adbd manually is another "indirect evidence" for me that you struggle with SELinux, because I also faced the exactly the same behaviour while writing the module. SELinux killed adbd on my phone and it was possible to start adbd manually from termux with root privileges. I solved the case by writing additional policy https://github.com/evdenis/adb_root/blob/master/sepolicy.rule that magisk injects to selinux during the boot process. This policy is enough on OnePlus 5T, Samsung S10 and these are the only devices I can test the module on.

evdenis avatar Aug 23 '20 14:08 evdenis

Just in case, if you use LineageOS you don't need this module since it's possible to switch adbd root in settings.

evdenis avatar Aug 23 '20 14:08 evdenis

@duraki ssh root@android -p2222 gives me ssh: connect to host android port 2222: Connection refused

So basically I connect the mobile to computer through USB. Now how do I know what port to connect to?

leovarmak avatar Jan 27 '21 13:01 leovarmak

@leovarmak you need simplesshd on your mobile device or connect via adb shell.

duraki avatar Jan 27 '21 13:01 duraki

@duraki Thank you so much!!! I am a QA, so incase if you ever want feedback about whatever you work now, I am here 😁

leovarmak avatar Jan 28 '21 18:01 leovarmak