我最近尝试在Android中读取文件/system/bin/debuggerd
。我可以安装应用或使用adb
命令,但是此错误:
不幸的是我被SELinux拒绝了
[105336.331813] type=1400 audit(8732769.717:226): avc: denied { read } for pid=17773 comm="ServiceHandlerB" name="debuggerd" dev="dm-0" ino=279 scontext
=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:debuggerd_exec:s0 tclass=file permissive=0
我无法通过规则对此设备进行root操作,因此是否可以读取此文件? 这让我困扰了一整天,感谢你的帮助。
答案 0 :(得分:2)
如果你不能“root”设备,那就不是。
详情如下。 debuggerd_exec文件声明为:
type debuggerd_exec, exec_type, file_type;
这意味着尝试读取文件的进程需要类型为debuggerd_exec或属性为exec_type或file_type的读取权限。
在回复时使用AOSP master的当前提示和午餐目标aosp_x86_64-eng,我们可以看到“源域”实际上可以使用以下sesearch命令读取此文件:
$ sesearch -A -t debuggerd_exec -c file -p read $OUT/root/sepolicy
allow debuggerd debuggerd_exec:file { read open getattr entrypoint execute };
allow debuggerd exec_type:file { read lock ioctl open getattr };
allow init debuggerd_exec:file { read getattr open execute };
allow perfprofd exec_type:file { read lock ioctl open getattr };
如果您注意到源域(允许后的第一件事),则它们都不是shell或untrusted_app。在没有漏洞利用的非root用户构建中,只能在untrusted_app或shell域中运行代码(这不完全正确,但细节并不重要)。
此外,即使untrusted_app确实具有访问权限,您也需要注意即使搜索显示您有访问权限,MLS有时也会阻止访问。 Android上的SE Linux使用Type Enforcement(允许规则)和MLS(mls_constrain规则)来提供隔离和沙箱强化。