Andorid:msm8909:ROOT权限的获取

目录

写在前面

本次目的

详细步骤

修改文件

system/extras/su/su.c

system/core/include/private/android_filesystem_config.h

system/core/libcutils/fs_config.c

frameworks/base/core/jni/com_android_internal_os_Zygote.cpp

frameworks/base/cmds/app_process/app_main.cpp

device/qcom/msm8909/BoardConfig.mk

 

重新编译

本次小结

 

写在前面

SOC:Qualcomm msm8909

Core-Board:SC20-CE QA/PJ

Base-Board:xxx

Linux Kernel:xxx

Android:7.1

 

本次目的

为了在应用层App中可以通过调用su来获取root权限,进而执行一些命令。

 

详细步骤

 

修改文件

system/extras/su/su.c

在“main”函数中,注释掉uid的验证条件:


    //uid_t current_uid = getuid();
    //if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed");

 

system/core/include/private/android_filesystem_config.h

有的时候上面文件中会说明要修改的内容搬家了:

 

system/core/libcutils/fs_config.c

修改su程序的权限配置相关的内容:

    /* the following two files are INTENTIONALLY set-uid, but they
     * are NOT included on user builds. */
    { 06755, AID_ROOT,      AID_SHELL,     0, "system/xbin/su" },

 

frameworks/base/core/jni/com_android_internal_os_Zygote.cpp

注释掉如下内容:

static void DropCapabilitiesBoundingSet(JNIEnv* env) {
/*
  for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) {
    int rc = prctl(PR_CAPBSET_DROP, i, 0, 0, 0);
    if (rc == -1) {
      if (errno == EINVAL) {
        ALOGE("prctl(PR_CAPBSET_DROP) failed with EINVAL. Please verify "
              "your kernel is compiled with file capabilities support");
      } else {
        RuntimeAbort(env, __LINE__, "prctl(PR_CAPBSET_DROP) failed");
      }
    }
  }
*/
}

 

frameworks/base/cmds/app_process/app_main.cpp

注释“main”函数中的如下内容:

/*  
    if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) {
        // Older kernels don't understand PR_SET_NO_NEW_PRIVS and return
        // EINVAL. Don't die on such kernels.
        if (errno != EINVAL) {
            LOG_ALWAYS_FATAL("PR_SET_NO_NEW_PRIVS failed: %s", strerror(errno));
            return 12;
        }
    }
*/

 

device/qcom/msm8909/BoardConfig.mk

在启动参数“BOARD_KERNEL_CMDLINE”中加入对SELinux的设置“androidboot.selinux=permissive”,放宽权限:

BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.selinux=permissive androidboot.console=ttyHSL0 androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 androidboot.bootdevice=7824900.sdhci lpm_levels.sleep_disabled=1 earlyprintk

 

重新编译

修改完上述文件后重新编译系统固件,使用新的固件启动系统,尝试相关操作。

 

本次小结

这个人很懒,什么也没有留下!

你可能感兴趣的:(Android,Linux)