Android修改源码实现root

简介: Android修改源码实现root

userdebug 和 user 版本

1. 关闭 selinux

system/core

diff -- git a / init / selinux . cpp b / init / selinux . cpp
 
index 5 a0255acd .. 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 1 a1ab6bf .. 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 ();
 
- if ( current_uid != AID_ROOT && current_uid != AID_SHELL ) error ( 1 , 0 , "not
allowed" );
 
+ //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. 给 su 文件默认授予 root 权限


system/core/libcutils/fs_config.cpp
 
diff -- git a / libcutils / fs_config . cpp b / libcutils / fs_config . cpp
 
index 5805 a4d19 .. 92e93 e76f 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 , 0 , "system/bin" },
 
{ 00755 , AID_ROOT , AID_ROOT , 0 , "system/etc/ppp" },
 
{ 00755 , AID_ROOT , AID_SHELL , 0 , "system/vendor" },
 
- { 00750 , AID_ROOT , AID_SHELL , 0 , "system/xbin" }, + { 00755 , AID_ROOT , AID_SHELL , 0 , "system/xbin" },
 
{ 00751 , AID_ROOT , AID_SHELL , 0 , "system/apex/*/bin" },
 
{ 00751 , AID_ROOT , AID_SHELL , 0 , "system_ext/bin" },
 
{ 00751 , AID_ROOT , AID_SHELL , 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 , 0 , "system/xbin/procmem" },
 
- { 04750 , AID_ROOT , AID_SHELL , 0 , "system/xbin/su" },
 
+ { 06755 , AID_ROOT , AID_SHELL , 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 9 eede83e21e5 .. 694 eec2a40ac 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 .. 19124 dd6239a1 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/make/target/product/base_system.mk 
 
build/core
 
diff -- git a / target / product / base_system . mk b / target / product / base_system . mk
 
index 4569 bceff9 .. 5 c8eaaa87c 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 \


目录
相关文章
|
Android开发
安卓虚拟摄像头替换摄像头, 微信虚拟相机替换拍照,安卓免root虚拟摄像头
虚拟摄像头系统包含多个组件:主摄像头类、预览面板、驱动接口、DirectShow实现和管理类
|
Ubuntu 开发工具 Android开发
Repo下载AOSP源码:基于ubuntu22.04 环境配置,android-12.0.0_r32
本文介绍了在基于Ubuntu 22.04的环境下配置Python 3.9、安装repo工具、下载和同步AOSP源码包以及处理repo同步错误的详细步骤。
1935 0
Repo下载AOSP源码:基于ubuntu22.04 环境配置,android-12.0.0_r32
|
Java Android开发
安卓虚拟摄像头过人脸,免root虚拟hook相机,虚拟相机hook版【jar】
两种Hook Android相机的方法:Xposed模块和Frida脚本。Xposed模块需要安装在已root的设备
|
安全 Shell 测试技术
安卓硬改一键新机,一键新机改串软件,免ROOT网卡串号Imei/sn码
本内容提供移动安全研究相关资料与方法,包括通过Android Studio官方工具和模拟器进行设备测试、ADB调试命令学习
|
XML 搜索推荐 Android开发
Android改变进度条控件progressbar的样式(根据源码修改)
本文介绍了如何基于Android源码自定义ProgressBar样式。首先分析了系统源码中ProgressBar样式的定义,发现其依赖一张旋转图片实现动画效果。接着分两步指导开发者实现自定义:1) 模仿源码创建一个旋转动画XML文件(放置在drawable文件夹),修改图片为自定义样式;2) 在UI控件中通过`indeterminateDrawable`属性应用该动画。最终实现简单且个性化的ProgressBar效果,附带效果图展示。
786 2
|
网络协议 Android开发 数据安全/隐私保护
三色过人脸虚拟摄像头,安卓免root虚拟摄像头, 安卓虚拟摄像头过人脸
这个实现包含三个主要部分:虚拟摄像头核心服务、安卓环境配置脚本和客户端测试程序
|
NoSQL 应用服务中间件 PHP
布谷一对一直播源码android版环境配置流程及功能明细
部署需基于 CentOS 7.9 系统,硬盘不低于 40G,使用宝塔面板安装环境,包括 PHP 7.3(含 Redis、Fileinfo 扩展)、Nginx、MySQL 5.6、Redis 和最新 Composer。Swoole 扩展需按步骤配置。2021.08.05 后部署需将站点目录设为 public 并用 ThinkPHP 伪静态。开发环境建议 Windows 操作系统与最新 Android Studio,基础配置涉及 APP 名称修改、接口域名更换、包名调整及第三方登录分享(如 QQ、微信)的配置,同时需完成阿里云与腾讯云相关设置。
|
开发工具 git 索引
repo sync 更新源码 android-12.0.0_r34, fatal: 不能重置索引文件至版本 ‘v2.27^0‘。
本文描述了在更新AOSP 12源码时遇到的repo同步错误,并提供了通过手动git pull更新repo工具来解决这一问题的方法。
1035 1
|
开发工具 uml git
AOSP源码下载方法,解决repo sync错误:android-13.0.0_r82
本文分享了下载AOSP源码的方法,包括如何使用repo工具和处理常见的repo sync错误,以及配置Python环境以确保顺利同步特定版本的AOSP代码。
3917 0
AOSP源码下载方法,解决repo sync错误:android-13.0.0_r82
|
Java Android开发 芯片
使用Android Studio导入Android源码:基于全志H713 AOSP,方便解决编译、编码问题
本文介绍了如何将基于全志H713芯片的AOSP Android源码导入Android Studio以解决编译和编码问题,通过操作步骤的详细说明,展示了在Android Studio中利用代码提示和补全功能快速定位并修复编译错误的方法。
1879 0
使用Android Studio导入Android源码:基于全志H713 AOSP,方便解决编译、编码问题

热门文章

最新文章