嵌入式爱好者

android-3568-Android系统获取root权限

2022-12-22 09:41| 发布者: PaperLove| 查看: 236| 评论: 0|来自: 原创

类目: RK3568系列产品  >  Android     文档编号: 849

1. 需要编译userdebug版本

2. 关闭selinux,修改源码/OK3568-android11-source/device/rockchip/common/BoardConfig.mk

BOARD_SELINUX_ENFORCING ?= true 

改为:

BOARD_SELINUX_ENFORCING ?= false 

3. 修改/OK3568-android11-source/system/extras/su/su.cpp,注释用户组权限检测

int main(int argc, char** argv) {

//uid_t current_uid = getuid();

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

allowed");

// Handle -h and --help.

++argv;

4. 修改/OK3568-android11-source/system/core/libcutils/fs_config.cpp给 su 文件默认授予 root权限。 

 { 04750, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },

改为:

{ 06755, AID_ROOT, AID_SHELL, 0, "system/xbin/su" },

 

5. 修改/OK3568-android11-source/frameworks/base/core/jni/com_android_internal_os_Zygote.cpp

注释代码。 

static void DropCapabilitiesBoundingSet(fail_fn_t fail_fn) {

/* 

for (int i = 0; prctl(PR_CAPBSET_READ, i, 0, 0, 0) >= 0; i++) {;

if (prctl(PR_CAPBSET_DROP, i, 0, 0, 0) == -1) {

if (errno == EINVAL) {

@@ -666,6 +667,7 @@ static void DropCapabilitiesBoundingSet(fail_fn_t fail_fn) {

}

}

}

*/ 

}

6. 修改/OK3568-android11-source/kernel/security/commoncap.c,注释代码。

static int cap_prctl_drop(unsigned long cap)

{

struct cred *new;

/*

if (!ns_capable(current_user_ns(), CAP_SETPCAP))

return -EPERM;

if (!cap_valid(cap))

return -EINVAL;

*/

7. 修改完以上内容,重新编译源码。

forlinx@ubuntu: ~/3568/OK3568-android11-source $ source build/envsetup.sh

forlinx@ubuntu: ~/3568/OK3568-android11-source $ lunch ok3568_r-userdebug

forlinx@ubuntu: ~/3568/OK3568-android11-source $ ./build.sh -UKAup

8. 使用瑞芯微提供的/OK3568-android11-source/RKDocs/android/patches/root/RootChecker工具测试,是否root成功。

点击测试按钮显示:Root check failed.表示root失败。

点击测试按钮显示:Root check pass.表示root成功。


已解决

未解决

只是看看

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-9-19 09:10

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部