查看: 16066|回复: 1

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

[复制链接]

404

主题

246

回帖

2万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
20408
发表于 2021-6-4 18:26:29 | 显示全部楼层 |阅读模式
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};  

风火轮微信公众号
回复

使用道具 举报

0

主题

2

回帖

8

积分

新手上路

Rank: 1

积分
8
发表于 2021-6-11 16:00:36 | 显示全部楼层
请问su文件的位置具体是在哪呢
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|风火轮WIKI|手机版|小黑屋|深圳风火轮团队 ( 粤ICP备17095099号 )

GMT+8, 2024-4-20 10:20 , Processed in 0.046706 second(s), 19 queries .

快速回复 返回顶部 返回列表
 
【客服1】 商务合作 15289193
【客服2】 业务洽谈 13257599
【客服3】 售前咨询 510313198
【邮箱】
smartfire@smartfire.cn