seandroid机制总结

Android 应用(1)——安全策略sepolicy https://blog.youkuaiyun.com/weixin_38148680/article/details/80257685 http://www.voidcn.com/article/p-stzeacwv-xe.html https://blog.youkuaiyun.com/keheinash/article/details/101108686 https://blog.youkuaiyun.com/rikeyone/article/details/84337115 https://blog.youkuaiyun.com/u0112164 阅读详情

在这里插入图片描述
大概解释下吧,网上各种文章都写炸了,
1.首先安装的时候通过签名在表Mac_premissions.xml中查询确定要创建的各种文件夹和文件的权限属性。
2.之后启动的时候通过上一步查询的seinfo确定启动进程的上下文属性类型。
3.最后就是根据进程上下文属性访问各种资源和属性。

app文件上下文属性有
seapp_context大概长这样:

# Input selectors: 
#   isSystemServer (boolean)
#   user (string)
#   seinfo (string)
#   name (string)
#   sebool (string)
# isSystemServer=true can only be used once.
# An unspecified isSystemServer defaults to false.
# An unspecified string selector will match any value.
# A user string selector that ends in * will perform a prefix match.
# user=_app will match any regular app UID.
# user=_isolated will match any isolated service UID.
# All specified input selectors in an entry must match (i.e. logical AND).
# Matching is case-insensitive.
# Precedence rules:
#     (1) isSystemServer=true before isSystemServer=false.
#     (2) Specified user= string before unspecified user= string.
#     (3) Fixed user= string before user= prefix (i.e. ending in *).
#     (4) Longer user= prefix before shorter user= prefix. 
#     (5) Specified seinfo= string before unspecified seinfo= string.
#     (6) Specified name= string before unspecified name= string.
#     (7) Specified sebool= string before unspecified sebool= string.
#
# Outputs:
#   domain (string)
#   type (string)
#   levelFrom (string; one of none, all, app, or user)
#   level (string)
# Only entries that specify domain= will be used for app process labeling.
# Only entries that specify type= will be used for app directory labeling.
# levelFrom=user is only supported for _app or _isolated UIDs.
# levelFrom=app or levelFrom=all is only supported for _app UIDs.
# level may be used to specify a fixed level for any UID. 
#
isSystemServer=true domain=system
user=system domain=system_app type=system_data_file
user=bluetooth domain=bluetooth type=bluetooth_data_file
user=nfc domain=nfc type=nfc_data_file
user=radio domain=radio type=radio_data_file
user=_app domain=untrusted_app type=app_data_file levelFrom=none
user=_app seinfo=platform domain=platform_app type=platform_app_data_file
user=_app seinfo=shared domain=shared_app type=platform_app_data_file
user=_app seinfo=media domain=media_app type=platform_app_data_file
user=_app seinfo=release domain=release_app type=platform_app_data_file

可以看到 domain被定义了很多种,通过seinfo我们查找到对应的domain并且创建进程。

接下来解释通过domain设置能过访问的资源,通过策略实现
external/sepolicy/*.te =>sepolicy
这些te文件通过几层设置,最终会有类似

app.te文件

#
# Apps signed with the platform key.
#
type platform_app, domain;
permissive platform_app;
app_domain(platform_app)
platform_app_domain(platform_app)
# Access the network.
net_domain(platform_app)
# Access bluetooth.
bluetooth_domain(platform_app)
unconfined_domain(platform_app)

文件unconfined.te定义了unconfineddomain这个Type所具有的权限,如下所示:

allow unconfineddomain self:capability_class_set *;
allow unconfineddomain kernel:security *;
allow unconfineddomain kernel:system *;
allow unconfineddomain self:memprotect *;
allow unconfineddomain domain:process *;
allow unconfineddomain domain:fd *;
allow unconfineddomain domain:dir r_dir_perms;
allow unconfineddomain domain:lnk_file r_file_perms;
allow unconfineddomain domain:{ fifo_file file } rw_file_perms;
allow unconfineddomain domain:socket_class_set *;
allow unconfineddomain domain:ipc_class_set *;
allow unconfineddomain domain:key *;
allow unconfineddomain fs_type:filesystem *;
allow unconfineddomain {fs_type dev_type file_type}:{ dir blk_file lnk_file sock_file fifo_file } *;
allow unconfineddomain {fs_type dev_type file_type}:{ chr_file file } ~entrypoint;
allow unconfineddomain node_type:node *;
allow unconfineddomain node_type:{ tcp_socket udp_socket rawip_socket } node_bind;
allow unconfineddomain netif_type:netif *;
allow unconfineddomain port_type:socket_class_set name_bind;
allow unconfineddomain port_type:{ tcp_socket dccp_socket } name_connect;
allow unconfineddomain domain:peer recv;
allow unconfineddomain domain:binder { call transfer set_context_mgr };

allow unconfineddomain property_type:property_service set;

这里基本可以看到普通app可以拥有的权限,和系统app在seandroid权限上没有区别。

根据这里可以知道app进程可以访问的资源类型。

我们再看file_context中的内容‘

###########################################
# Root
/           u:object_r:rootfs:s0
 
# Data files
/adb_keys       u:object_r:rootfs:s0
/default.prop       u:object_r:rootfs:s0
/fstab\..*      u:object_r:rootfs:s0
/init\..*       u:object_r:rootfs:s0
/res(/.*)?      u:object_r:rootfs:s0
/ueventd\..*        u:object_r:rootfs:s0
 
# Executables
/charger        u:object_r:rootfs:s0
/init           u:object_r:rootfs:s0
/sbin(/.*)?     u:object_r:rootfs:s0
 
#############################
# System files
#
/system(/.*)?       u:object_r:system_file:s0
/system/bin/ash     u:object_r:shell_exec:s0
/system/bin/mksh    u:object_r:shell_exec:s0

也就是说根据unconfined.te和 file_context,我们基本能确定普通app可以访问的文件,如果要增加相应的访问,也可以通过更改这里,当然在启动的系统中,这几个文件肯定没有写权限的。这个是后话。

SeAndroid 安全策略机制 在Android系统中,应用有时需要访问或修改特定的系统属性。为了限制哪些应用可以访问或修改这些属性,我们可以使用seAndroid的策略来控制。 阅读详情

相关推荐

浅谈SEAndroid安全机制及应用方法

浅谈SEAndroid安全机制及应用方法 内容提纲: ➢SEAndroid/SELinux简介 ➢SEAndroid/SELinux框架 ➢SELinux Policy介绍 ➢安全策略文件(TE文件) ➢SELinux安全问题分析 ​ ➢SELinux设备文件权限解决办法 ​ ➢SELinux服务权限解决办法 ​ ➢SELinux可执行权限解决办法 ➢补充 ​ ➢客体类型添加 一.SEAn...

阿路 1309

Android 4.4.2 SELinux 与系统关系详解三:根据Seinfo 为Package 设置安全上下文标签

在对Android 操作系统进行定制开发过程中,优势仅仅需要编译修改过的部分并烧写到设备上进行验证,下面是重新编译打包boot.img,并自动烧写到设备的脚本文件。 [code=Python] echo on out/host/linux-x86/bin/mkbootfs out/target/product/hammerhead/root | out/host/linux-x86/bin/

万能的终端和网络 2562

测试丢包_电信IPRAN承载LTE业务丢包故障处理案例

银川 景旭阳电信IPRAN承载LTE业务丢包故障处理案例一.故障现象某地市IPRAN网络承载LTE基站业务,客户反馈近期丢包严重,基站侧ping侧核心网EPC丢包达到10%左右;且基站数量在10个左右,并分布在同一地区,需要IPRAN网络协助排查;随后查看了IPRAN网络;发现这些业务所在基站的PW-BFD历史告警存在频繁的UP/DOWN告警;综上信息展开故障处理,初步判断由于BFD频繁...

weixin_29740921的博客 1912

Selinux-篇4 标签 android版本

如何新增一个app的防护规则。 1、seapp_contexts: #新增 一个app user=_app seinfo=bd_testname=com.baidu.testappdomain=testapp_app type=test_app_data_file levelFrom=user user=_app seinfo=bd_testname=com.baidu.test:* domain=test_app type=test_app_data_file levelFrom=u...

xieyinsen的专栏 2087

Sparse4Dv3 代码复现

打包数据集的元信息和标签,并生成所需的.pkl文件。最后还输出了很多跟踪相关的东西...然后通过K-means生成锚点。编译可变形聚合CUDA算子。安装motmetrics。

m0_60857098的博客 4487

Android汽车服务篇(一) CarService

本文主要说明了CarService这一系统服务的启动流程,以及一些关键成员的创建和初始化流程.同时简单介绍了一下客户端是如何获取和使用CarService对象, 如上文介绍的, CarService对象只是获取各个Manager的媒介,它本身并不承担管理传感器.空调等具体的任务.如果要获取车辆的相关信息,如车速, 车内空调温度,诊断信息, 或对车辆进行相关的控制,如升高和降低空调温度,控制座椅和车窗, 调节音量等,就要通过具体的Manager中的API和对应的服务来实现了.

u012514113的专栏 8147

app属性seinfo 应用selinux上下文

seinfo用zygote创建app进程时创建selinux上下文使用。不同签名会创建对应的selinux上下文。platform,system,untrusted等。 frameworks/base/services/core/java/com/android/server/pm/SELinuxMMAC.java中 getSeInfo()函数获取对应安装时分配的值。特殊修改上下文看以针对此函数改动。 ...

LEAD_SOLO的专栏 691

Windows 10下Carla 0.9.15安装避坑指南:从下载到运行的全流程解析

本文详细解析了在Windows 10系统上安装和运行Carla 0.9.15自动驾驶仿真平台的全流程。内容涵盖从系统环境准备、资源下载、Python依赖安装,到首次启动验证及常见错误(如DLL缺失、显卡驱动问题)的深度解决方案,旨在帮助用户快速搭建稳定的开发环境,并运行第一个自动驾驶Python脚本。

alice7model的博客 546

Android系统SELinux详解

SELinux是一种加强文件安全的一种策略,可以更好地保护我们的Android系统, 比如限制系统服务的访问权限、控制应用对数据和系统日志的访问等措施,这样就降低了恶意软件的影响,并且可以防止因代码存在的缺陷而产生的对系统安全的影响。从系统安全方面考虑,SELinux是保护神,但是从软件开发方面,SELinux就是一道牵绊,这是一把双刃剑。SELinux默认开启,即使获得了该系统的root权限,也只能向相关策略中指定的设备写入数据,从而更好地保护和限制系统服务,保障系统和数据的安全。......

star_nwe的博客 2215

白话详细解读(七)----- CBAM:Convolutional Block Attention Module

一、CBAM简介 论文链接:https://x.sci-hub.org.cn/scholar?hl=zh-TW&as_sdt=0%2C5&q=CBAM%3A+Convolutional+Block+Attention+Module&btnG=&oq=CB CBAM这篇论文是在2018年提出的,自提出之后,已经被引用上千次,可见其影响力。CBAM是一种专门为了卷积神经网络而设计的注意力模块,传统的卷积存在只关注局部信息,而往往忽略全局信息的弊端,以3*3卷积为例,滤波器有9个

奋斗の博客 1万+

Drools vs URule:5个真实项目场景告诉你如何选择开源规则引擎

本文通过电商风控、物流计费、会员体系、保险定价和物联网告警五个真实项目场景,深度对比了Drools与URule两款开源规则引擎。分析了两者在规则复杂度、性能表现、开发运维及适用场景上的核心差异,为技术选型提供基于实战的决策指南。

k6l7m8n9的博客 944

SEAndroid安全机制框架分析

我们知道,Android系统基于Linux实现。针对传统Linux系统,NSA开发了一套安全机制SELinux,用来加强安全性。然而,由于Android系统有着独特的用户空间运行时,因此SELinux不能完全适用于Android系统。为此,NSA针对Android系统,在SELinux基础上开发了SEAndroid。本文就对SEAndroid安全机制框架进行分析,以便后面可以更好地分析其实现细节。

老罗的Android之旅 9万+

基于FPGA的相控阵雷达波束控制系统设计(2)

也就是在计算波控码时0,按2.8125递增,取遍-90

qq_43416206的博客 1812

SEAndroid安全机制简要介绍和学习计划

与iOS相比,Android最被人诟病的是其流畅性和安全性。然而,从4.0开始,Android不遗余力地改善其流畅性。特别是在即将发布的L版本中,用ART替换了Dalvik,相信会越来越流畅。至于安全性,Android也没有遗忘。从4.3开始,Android引入了一套基于SELinux的安全机制,称为SEAndroid,来加强系统安全性。接下来我们就对SEAndroid进行简要介绍和制定学习计划。

老罗的Android之旅 5万+

uniapp中使用canvas生成海报,并下载保存到手机相册

如下图,是在H5中,canvas生成后的效果,首先说明,H5不支持返回图片的临时路径,不能用于保存,APP端生成成功后,会返回图片的临时路径用来保存到相册。本地测试,用的网络图片,没有出现跨域的问题,APP端也正常显示。 完整代码:可以将整个代码复制到你得uniapp项目中直接运行。代码中做了详细的注册,关于API的用法,这里只标注的简单的提示,具体还是参考 官方链接uniapp-canvas吧 <template> <view class="demo"> <c.

sunluyi的博客 3万+

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

SEAndroid安全机制对Binder IPC的保护分析

在SEAndroid安全机制中,除了文件和属性,还有Binder IPC需要保护。Binder IPC是Android系统的灵魂,使用得相当广泛又频繁。例如,应用程序都是Binder IPC请求访问系统服务和资源。因此,SEAndroid安全机制必须要为Binder IPC保驾护航,阻止一个进程非法访问其它进程的服务和资源。本文就详细分析SEAndroid安全机制对Binder IPC提供的支持。

老罗的Android之旅 2万+

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

上一篇: mave仓库管理
下一篇: qemu 搭建linux内核调试
inquisiter
博客等级 码龄10年 374粉丝 228原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值