linux suid提权原理,Linux SUID、SGID、sticky提权
S UID SGID SOID 核心就在 “S” ,S就是允許本圈子 用戶有r,w,x ;
例如:1、chmod s+g test.txt 只允許testex.txt所在的組 員可以執(zhí)行r,w,x
2、chmod u+s test.txt2 只允許test.txt2的屬主 執(zhí)行r,w,x
溫馨提示:對SUID只需要有個了解就行了,不要瞎設(shè)置,否則會影響系統(tǒng)的穩(wěn)定運行
1、臨時提權(quán)讓不同的組之間可以相互查看別創(chuàng)建的文件
[root@localhost ~]# chmod u+s /usr/bin/cat 注:把cat放到/usr/bin/才會運行
[root@localhost ~]# ll /usr/bin/cat
-rwsr-xr-x. 1 root root 54080 11月 6 2016 /usr/bin/cat
[root@localhost ~]#
2、將賦予的SUID臨時提權(quán)給去掉
[root@localhost ~]# chmod u-s /usr/bin/cat
[root@localhost ~]# ll /usr/bin/cat
-rwxr-xr-x. 1 root root 54080 11月 6 2016 /usr/bin/cat
[root@localhost ~]#
3、舉個鮮明的例子,passwd天生就具有SUID,能使普通用戶自己可改密碼;
[peng1@localhost ~]$ ll /usr/bin/passwd
-rwsr-xr-x. 1 root root 27832 6月 10 2014 /usr/bin/passwd
[peng1@localhost ~]$
關(guān)于SGID,說白了設(shè)置SGID相當于給hr目錄設(shè)置權(quán)限繼承關(guān)系,
[root@localhost ~]# mkdir /home/hr
[root@localhost ~]# ll /home/hr
總用量 0
[root@localhost ~]# ll -d /home/hr
drwxr-xr-x. 2 root root 6 4月 19 14:00 /home/hr
[root@localhost ~]# chmod g+s /home/hr
[root@localhost ~]# ll -d /home/hr
drwxr-sr-x. 2 root root 6 4月 19 14:00 /home/hr
[root@localhost ~]#
3、stiky:保證在公共環(huán)境里只有自己能del其他用戶不能del
[root@localhost ~]# mkdir /home/hr2
[root@localhost ~]# chmod 777 /home/hr2
[root@localhost ~]# chmod o+t /home/hr2
[root@localhost ~]# ll -d /home/hr2
drwxrwxrwt. 2 root root 6 4月 19 15:23 /home/hr2
[root@localhost ~]#
總結(jié)
以上是生活随笔為你收集整理的linux suid提权原理,Linux SUID、SGID、sticky提权的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android nougat和安卓7.1
- 下一篇: Java实现:月,日,年,周,访问量统计