Android7.1 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

目的:为了在应用层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/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

或者

复制代码
BOARD_KERNEL_CMDLINE := androidboot.selinux=permissive
相关推荐
深盾安全1 小时前
Kotlin Data Classes 快速上手
android
一枚小小程序员哈3 小时前
安卓\android程序开发之基于 Android 的校园报修系统的设计与实现
android
用户2018792831674 小时前
🌟 一场失败的加密舞会:SSL握手失败的奇幻冒险
android
tangweiguo030519875 小时前
面向对象编程三剑客:Dart、Java 和 Kotlin 的核心区别
android·flutter·kotlin
幼稚园的山代王5 小时前
Kotlin数据类型
android·开发语言·kotlin
xixixin_5 小时前
【H5】禁止IOS、安卓端长按的一些默认操作
android·css·ios·h5
zhangphil5 小时前
Android实现Glide/Coil样式图/视频加载框架,Kotlin
android·kotlin
用户2018792831676 小时前
“记忆邮局” (LiveData)
android
叽哥6 小时前
flutter学习第 17 节:项目实战:综合应用开发(下)
android·flutter·ios
小林up6 小时前
HiSmartPerf使用WIFI方式连接Android机显示当前设备0.0.0.0无法ping通!设备和电脑连接同一网络,将设备保持亮屏重新尝试
android·网络·电脑