7 system("/bin/cat /tmp/shadow");
8 return 0;
9 }
gcc setuid.c -o setuid
切换到root用户,更改setuid程序为CAP_SETUID
su - root
setcap cap_setuid=eip /tmp/setuid
切换到test用户,运行/tmp/setuid程序,如下:
su - test
/tmp/setuid
root:$1$S9AmPHY8$ZIdORp6aLnYleb5EORxw8/:14479:0:99999:7:::
daemon:*:14479:0:99999:7:::
bin:*:14479:0:99999:7:::
sys:*:14479:0:99999:7:::
sync:*:14479:0:99999:7:::
games:*:14479:0:99999:7:::
man:*:14479:0:99999:7:::
lp:*:14479:0:99999:7:::
我们看到普通用户可以查看/tmp/shadow文件,而取消CAP_SETUID则使程序不能拥有setuid的权限,如下:
setcap -r /tmp/setuid
su - test
/tmp/setuid
/bin/cat: /tmp/shadow: Permission denied
十三)CAP_SETPCAP 8 (允许向其它进程转移能力以及删除其它进程的任意能力)
事实上只有init进程可以设定其它进程的能力,而其它程序无权对进程授权,root用户也不能对其它进程的能力进行修改,只能对当前进程通过cap_set_proc等函数进行修改,而子进程也会继承这种能力.
所以即使使用了CAP_SETPCAP能力,也不会起到真正的作用.
十四)CAP_LINUX_IMMUTABLE 9 (允许修改文件的不可修改(IMMUTABLE)和只添加(APPEND-ONLY)属性)
普通用户不能通过chattr对文件设置IMMUTABLE(chattr +i)和APPEND-ONLY(chattr +a)权限,而通过CAP_LINUX_IMMUTABLE可以使普通用户通过自己增减(immutable/append-only)权限.
普通用户通过chattr给文件增加immutable权限,如下:
touch /tmp/test
chattr +i /tmp/test
chattr: Operation not permitted while setting flags on /tmp/test
我们看到授权失败了,而如果我们对chattr增加了LINUX_IMMUTABLE权限,则可以成功,如下:
此时切换到root用户:
su -
linux/binfmts.h 146 include/linux/capability.h 147 include/linux/elf.h ...旋转锁将在第 10 章进行深入介绍。 如果你对 flags 在传送给 spin_lock_...
linux/binfmts.h 146 include/linux/capability.h 147 include/linux/elf.h ...内核体系结构的深入了解 442 3.4 Linux 内核的类型 444 3.5 设计和实现的...
下面,在具体深入 linux 内核分析研究之前,需要 对内核中进程相关的几个概念做...具体的实现:Processors typically provide this capability with a mode bit in ...
(HHARM9-EDU实验6中断、 14GPIO/key、AD/DA、I2C等) 进一步深入学习其它的...<linux/major.h> #include <linux/blkdev.h> #include <linux/capability.h...
capability of Linux.Based on the SMP support of Linux,the kernel of Linux...随着对中间件研究的深入,相关的技 术会越来越多,所设计的中间件产品性能会更好...
.c 功能:initializes some of the processor’s interrupt handling capability. ...2005-12-30 28 内容 Linux启动函数分析 X86下的Linux启动分析 ARM下的Linux...
amongallthemethodsofimprovingLinuxrealtimecapability,theprimarywayincludesthinning...本课题针对Linux实时调度策略单一性限帛lJLinux实时应用的情况,深入研 究和分析...
Linux下的Capabilities安全机制分析_IT/计算机_专业资料。Linux下的Capabilities...即将 r00t的特权分割成不同的capabIlIty(本文译为权能),每种 权能代表一定的...
(2008)03—0109—04 ResearchofReaI—TimeCapabilityofEmbeddedLinux0SZHANGZi—qiang...开发难度等方面对两者进行一些深入 的对比,以及分析:3.1实时性能 合前面提到的...
capability.h 147 /linux/elf.h 150 /linux/elfcore.h 156 /linux/errupt.h...(spin-lock)来控制对控制台访问旋转锁将在第10章进行深入介绍 如果你对 flags...
热门文档