当前位置: 首页 > news >正文

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

http://www.lryc.cn/news/166369.html

相关文章:

  • 几个好用的数据标注软件labelme、CVAT及LabelImage
  • VSCode学习笔记一:添加代码模板
  • Linux下修改jar包中的配置文件application.conf
  • 【python绘图—colorbar操作学习】
  • Python+Appium自动化测试-编写自动化脚本
  • AMEYA360|ROHM罗姆首次推出硅电容器BTD1RVFL系列
  • Linux发散小知识
  • GTS 中testPeakPssOfAllApps fail 详解
  • linux查看远程仓库的分支
  • 【Linux常用命令】
  • QString类与整型,浮点数互转
  • 基于STM32F407ZET6的环境温湿度监控系统(粤嵌GEC-M4)
  • 2023年五一杯数学建模A题无人机定点投放问题求解全过程论文及程序
  • Redis 7 第九讲 微服务集成Redis 应用篇
  • c++day7
  • C++学习概述
  • 关系型数据库和非关系型数据库
  • 基于SSM的快餐店点餐服务系统设计与实现
  • 使用vcpkg配置CGAL+visual studio 2022
  • 【Spring面试】三、Bean的配置、线程安全、自动装配
  • flink连接kafka报:org.apache.kafka.common.errors.TimeoutException
  • sql order by 排序 null值放最后,怎么写
  • HDMI字符显示实验
  • Spring Cloud 框架搭建
  • 20个非常有用的单行Python代码片段
  • 【LangChain系列 9】Prompt模版——MessagePromptTemplate
  • ROS2的学习路径
  • Maintaining leader role through timed lease mechanism
  • Mysql InnoDB引擎 的hash索引
  • 23年PMP考试如何备考?