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

Android su

1. userdebug和user版本

2. 关闭selinux

system/core

diff --git a/init/selinux.cpp b/init/selinux.cpp index 5a0255acd..787917274 100644--- a/init/selinux.cpp +++ b/init/selinux.cpp

@@ -104,6 +104,8 @@ EnforcingStatus StatusFromCmdline() { } bool IsEnforcing() {

+     + return false; if (ALLOW_PERMISSIVE_SELINUX) { return StatusFromCmdline() == SELINUX_ENFORCING; }

3. 修改su.cpp,注释用户组权限检测

system/extras/su/su.cpp

diff --git a/su/su.cpp b/su/su.cpp index 1a1ab6bf..af3d2a68 100644--- a/su/su.cpp

+++ b/su/su.cpp @@ -80,8 +80,8 @@ void extract_uidgids(const char* uidgids, uid_t* uid, gid_t* gid, gid_t* gids, i } int main(int argc, char** argv) {-    -     +     uid_t current_uid = getuid(); //uid_t current_uid = getuid(); if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed"); +     //if (current_uid != AID_ROOT && current_uid != AID_SHELL) error(1, 0, "not allowed"); // Handle -h and --help. ++argv; 4. 给 su 文件默认授予 root 权限 system/core/libcutils/fs_config.cpp diff --git a/libcutils/fs_config.cpp b/libcutils/fs_config.cpp index 5805a4d19..92e93e76f 100644--- a/libcutils/fs_config.cpp +++ b/libcutils/fs_config.cpp @@ -86,7 +86,7 @@ static const struct fs_path_config android_dirs[] = { { 00751, AID_ROOT,         AID_SHELL,         { 00755, AID_ROOT,         { 00755, AID_ROOT,         -   { 00750, AID_ROOT,         AID_ROOT,         AID_SHELL,         AID_SHELL,         0, "system/bin" }, 0, "system/etc/ppp" }, 0, "system/vendor" }, 0, "system/xbin" }, +   -   +   { 00755, AID_ROOT,         { 00751, AID_ROOT,         { 00751, AID_ROOT,         { 00751, AID_ROOT,         AID_SHELL,         AID_SHELL,         0, "system/xbin" }, 0, "system/apex/*/bin" }, AID_SHELL,         AID_SHELL,         0, "system_ext/bin" }, 0, "system_ext/apex/*/bin" }, @@ -190,7 +190,7 @@ static const struct fs_path_config android_files[] = { // the following two files are INTENTIONALLY set-uid, but they // are NOT included on user builds. { 06755, AID_ROOT,       AID_ROOT,       { 04750, AID_ROOT,       { 06755, AID_ROOT,       AID_SHELL,     AID_SHELL,     0, "system/xbin/procmem" }, 0, "system/xbin/su" }, 0, "system/xbin/su" }, frameworks/base/core/jni/com_android_internal_os_Zygote.cpp diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 9eede83e21e5..694eec2a40ac 100644--- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -656,6 +656,7 @@ static void EnableKeepCapabilities(fail_fn_t fail_fn) { } 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) { } } } + */ } kernel/security/commoncap.c diff --git a/security/commoncap.c b/security/commoncap.c index f86557a8e43f6..19124dd6239a1 100644--- a/security/commoncap.c +++ b/security/commoncap.c @@ -1147,12 +1147,12 @@ int cap_task_setnice(struct task_struct *p, int nice) 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; +*/ new = prepare_creds(); if (!new) return -ENOMEM; 5. user版本需要把su编进系统 build/core diff --git a/target/product/base_system.mk b/target/product/base_system.mk index 4569bceff9..5c8eaaa87c 100644--- a/target/product/base_system.mk +++ b/target/product/base_system.mk @@ -273,6 +273,7 @@ PRODUCT_PACKAGES += \ wificond \ wifi.rc \ wm \ +     su \ # VINTF data for system image PRODUCT_PACKAGES += \ @@ -378,7 +379,6 @@ PRODUCT_PACKAGES_DEBUG := \ ss \ start_with_lockagent \ strace \-     su \ sanitizer-status \ tracepath \ tracepath6

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

相关文章:

  • 微信小程序真机调试异常cmdId 1006, errCode-50011-已解决
  • 36.SpringMVC视图
  • LeetCode 热题 100(四):48. 旋转图像、240. 搜索二维矩阵 II、234. 回文链表
  • Qt 编译使用Bit7z库接口调用7z.dll、7-Zip.dll解压压缩常用Zip、ISO9660、Wim、Esd、7z等格式文件(二)
  • 224、仿真-基于51单片机音乐播放器流水灯控制Proteus仿真设计(程序+Proteus仿真+原理图+程序流程图+元器件清单+配套资料等)
  • 虹科展会 | 自动驾驶展品:上海汽车测试展精彩回顾
  • Unity自定义脚本的 初始模版
  • vue3中使用第三方插件mitt实现任意组件通讯
  • (五)、深度学习框架源码编译
  • 迈向通用听觉人工智能!清华电子系、火山语音携手推出认知导向的听觉大语言模型SALMONN
  • NOIP 2015 扫雷(mine)
  • elaticsearch(3)
  • DevOps系列文章 之 Gitlab+Docker自动部署SpringBoot
  • React Native 列表组件基础知识
  • 操作系统的体系结构、内核、虚拟机
  • 【C++】vector的基本用法
  • SSM——用户、角色、权限操作
  • UI界面设置
  • 论文学习——PixelSNAIL:An Improved Autoregressive Geenrative Model
  • mySQL 视图 VIEW
  • 「UG/NX」Block UI 曲线收集器CurveCollector
  • 微信小程序:函数节流与函数防抖
  • Mathematica(42)-计算N个数值的和
  • 安装和配置 Ansible
  • 电脑系统重装日记
  • 通讯协议044——全网独有的OPC HDA知识一之聚合(十二)持续坏值时间
  • Docker:Windows container和Linux container
  • excel提示更新外部引用文件 这个提示能手动禁用
  • 2023 最新 小丫软件库app开源源码 PHP后端
  • Selenium 测试用例编写