主页 > 未分类 > adb shell的root权限(#与$)

adb shell的root权限(#与$)

adb shell的root权限可以通过kitchen工具修改boot.img的default.prop文件中如下部分:

ro.secure=0
ro.allow.mock.location=0
ro.debuggable=1
persist.services.adb.enable=1

这部分内容在adbd的源码中有定义,通过一个宏ALLOW_ADBD_ROOT控制,检测到该宏时,才会对ro.secure做处理,处理如下:

static int should_drop_privileges() {
#ifndef ALLOW_ADBD_ROOT
    return 1;
#else /* ALLOW_ADBD_ROOT */
    int secure = 0;
    char value[PROPERTY_VALUE_MAX];

   /* run adbd in secure mode if ro.secure is set and
    ** we are not in the emulator
    */

    property_get("ro.kernel.qemu", value, "");
    if (strcmp(value, "1") != 0) {
        property_get("ro.secure", value, "1");
        if (strcmp(value, "1") == 0) {
            // don't run as root if ro.secure is set...
            secure = 1;

            // ... except we allow running as root in userdebug builds if the
            // service.adb.root property has been set by the "adb root" command
            property_get("ro.debuggable", value, "");
            if (strcmp(value, "1") == 0) {
                property_get("service.adb.root", value, "");
                if (strcmp(value, "1") == 0) {
                    secure = 0;
                }
            }
        }
    }
    return secure;
#endif /* ALLOW_ADBD_ROOT */
}

所以如果修改ro.secure=0仍不能打开root,则需要重新编译adbd,放入到boot.img中即可

评论:3

  1. 我的名字叫麒 回复
    2013 年 2 月 18 日 于 下午 4:23

    看不懂,友情顶帖!

  2. wking 回复
    2013 年 4 月 5 日 于 下午 11:43

    已经用厨房工具修改default.prop,但root无效。请问如何重新编译abcd?

    • tianyu 回复
      2013 年 4 月 8 日 于 下午 3:15

      在源码里编译,或者找个能用的adbd替换掉

wking进行回复 取消回复

邮箱地址不会被公开。 必填项已用*标注