zoukankan      html  css  js  c++  java
  • linux基础学习-12.7-特殊权限-suid-粘滞位

    1、suid

    4(SUID) 设置SUID的文件,无论谁执行此文件,他都有文件所有者的权限

    -rws

    SUID 权限仅对二进制程序(binary program)有效

    执行者对于该程序需要具有x的可执行权限;

    本权限仅在执行该程序的过程中有效 (run-time);

    执行者将具有该程序拥有者 (owner) 的权限。

    2、查看系统有suid权限的命令:

    find / -type f -perm 4755 |xargs ls -l

    Linux系统基本优化,取消无用的suid命令

    文件有执行权限,不一定可以执行,还有内核控制

    [root@oldboy ~]# ll /usr/bin/passwd

    -rwsr-xr-x. 1 root root 30768 2月 22 2012 /usr/bin/passwd

    用户删除本来无权限的文件:(三个,满足一个即可)

    a、 sudo 给 用户授权rm

    b、给rm命令设置suid

    c、设置上级目录w权限

    [root@oldboy test]# chmod u+s a.sh

    [root@oldboy test]# ll

    total 0

    -rwSr--r-- 1 root root 0 Sep 6 01:22 a.sh

    [root@oldboy test]# chmod u+x a.sh

    [root@oldboy test]# ll

    total 0

    -rwsr--r-- 1 root root 0 Sep 6 01:22 a.sh

    3、sgid

    2(SGID) 设置SGID的目录,无论谁来此目录,他都有目录所属组的权限

    [root@oldboy ~]# ll `which locate`

    -rwx--s--x. 1 root slocate 38464 3月 12 2015 /usr/bin/locate

    SGID 可以针对目录来设置,目录设置sgid后,普通用户放到这个目录下的文件的用户组跟这个目录走 {#sgid-可以针对目录来设置,目录设置sgid后,普通用户放到这个目录下的文件的用户组跟这个目录走}
    SGID 对二进制程序有用 {#sgid-对二进制程序有用}
    程序执行者对于该程序来说,需具备 x的权限 {#程序执行者对于该程序来说,需具备-x的权限}
    执行者在执行的过程中将会获得该程序群组的支持 {#执行者在执行的过程中将会获得该程序群组的支持}

    [root@oldboy test]# ll

    total 0

    -rw-r--r-- 1 root root 0 Sep 6 01:22 a.sh

    [root@oldboy test]# chmod g+s a.sh

    [root@oldboy test]# ll

    total 0

    -rw-r-Sr-- 1 root root 0 Sep 6 01:22 a.sh

    [root@oldboy test]# chmod g+x a.sh

    [root@oldboy test]# ll

    total 0

    -rw-r-sr-- 1 root root 0 Sep 6 01:22 a.sh

    4、sticky(粘滞位)

    存放在该目录的文件只允许属主操作 {#存放在该目录的文件只允许属主操作}

    rwt t代表设置了粘滞位

    tmp经典的粘滞位目录案例,特点,谁都有写权限,因此安全成问题,常常是木马第一手的跳板地点

    linux高级优化,tmp目录常常是木马第一手跳板地点

    [root@oldboy ~]# ll -d /tmp

    drwxrwxrwt. 3 root root 10829824 Sep 6 00:41 /tmp

    [root@oldboy ~]# chmod o-t /tmp

    [root@oldboy ~]# ll -d /tmp

    drwxrwxrwx. 3 root root 10829824 Sep 6 00:41 /tmp

    [root@oldboy ~]# chmod o+t /tmp

    [root@oldboy ~]# ll -d /tmp

    drwxrwxrwt. 3 root root 10829824 Sep 6 00:41 /tmp

    [root@oldboy ~]# chmod o-x /tmp

    [root@oldboy ~]# ll -d /tmp

    drwxrwxrwT. 3 root root 10829824 Sep 6 00:41 /tmp

    5、设置特殊权限位

    chmod 4755 filename

    chmod u+s filename

    chmod g+s filename

    chmod +t /tmp

    练习题:

    1、特殊权限的设置

    2、粘滞位的标识及如何设置

  • 相关阅读:
    DOS命令大全 1 attrib,delete等 外部 内部 命令都有
    css图像映射
    简单的css样式控制分页效果
    (转)AjaxPro实现机制探讨——Ajax是如何调用服务器端C#方法?
    学习笔记ADO.Net方面
    一个挺好用的数据库操作类
    .net开发人员应该知道(二)
    js与C#之间相互调用的一些方法
    JS 事件大全
    .net开发人员应该知道(一)
  • 原文地址:https://www.cnblogs.com/Klanti/p/9143421.html
Copyright © 2011-2022 走看看