Toybrick

ANDROID 第三方 APK 获取 SU 权限说明

395876134

版主

积分
1059
楼主
发表于 2019-8-9 17:53:28    查看: 10816|回复: 0 | [复制链接]    打印 | 只看该作者
本帖最后由 395876134 于 2019-8-12 10:24 编辑

1. 修改 system\extras\su\目录 su.cpp 文件
在 main 函数里面屏蔽
//uid_t current_uid = getuid();
//if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed");

2. 修改 system\core\libcutils\目录 fs_config.cpp 文件
把{ 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },
修改为{ 06755, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },


3. 修 改 \frameworks\base\core\jni\ 目 录
com_android_internal_os_Zygote.cpp 文件
屏蔽 DropCapabilitiesBoundingSet(JNIEnv* env)函数如下:
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 {
            ALOGE("prctl(PR_CAPBSET_DROP, %d) failed: %s", i, strerror(errno));
            RuntimeAbort(env, __LINE__, "prctl(PR_CAPBSET_DROP) failed");
       }
    }
}
*/
}


4. 修改 system\sepolicy\public\目录 domain.te 文件
neverallow { domain userdebug_or_eng(`-dumpstate -shell -su') } su_exec:file no_x_file_perms;
修 改 为 : #neverallow { domain userdebug_or_eng(`-dumpstate -shell -su') } su_exec:file
no_x_file_perms;


5. 修 改 device\rockchip\common\sepolicy\ 目 录
untrusted_app.te 文件
在最后添加 allow untrusted_app su_exec:file { execute read open getattr ioctl execute_no_trans};  




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

产品中心 购买渠道 开源社区 Wiki教程 资料下载 关于Toybrick


快速回复 返回顶部 返回列表