Always run adb as root on a rooted device

28,947

You can try this method, but be carefully as this allows any app to gain root, can you say, "Security Hole!"

Make your suid binary insecure by typing the following commands.

adb shell
su
mount -o remount,rw /system # or: adb remount
ls -la /system/bin/sh
lrwxr-xr-x root shell 2012-11-10 15:20 sh -> mksh
chmod 4755 /system/bin/sh
ls -la /system/bin/mksh
-rwsr-xr-x root shell 157520 2012-11-10 09:54 mksh # notice the suid bit is set
^D
adb shell
Share:
28,947
pogo2065
Author by

pogo2065

I am a graduate of the Kalamazoo Area Mathematics and Science Center(KAMSC), as well as Gull Lake High School. I am currently employed to design android apps for a small business.

Updated on July 09, 2022

Comments

  • pogo2065
    pogo2065 almost 2 years

    So I have a rooted SGS3 running the lastest CyanogenMod nightly. I am trying to use DDMS while developing but have run into a problem. I do have root access on my phone (evident when I use an adb shell and use the su command), however DDMS does not use adb in root mode, forcing me to manually change permissions of files using the adb shell before being able to copy them. Is there a way to force ddms to use root all the time? I figured this must be some setting somewhere but I cannot find it.

    Any help is gladly appreciated.

  • George Hilliard
    George Hilliard over 9 years
    This works well; really clever workaround! Note that I had to change the settings of mksh instead (didn't work on the symlink).
  • Jordan
    Jordan about 9 years
    Hmm, I think I'm missing something - I'm trying these steps on a rooted Nexus5 w/ 5.0.1 and, within /system/bin (a) sh does not appear to be a symlink and (b) mksh doesn't appear to be there at all.
  • user1501382
    user1501382 about 9 years
    Cool. After following above steps my DDMS runs as root and i need not worry about accessing files.