溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

linux權(quán)限suid

發(fā)布時間:2020-07-31 03:55:25 來源:網(wǎng)絡 閱讀:845 作者:hjun169 欄目:編程語言

1.創(chuàng)建文件1.txt,屬于root用戶,root組,權(quán)限為700
2.創(chuàng)建程序文件
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

#define BUFFSIZE 10

int main()
{
int fd;
char buf[BUFFSIZE];
fd = open("1.txt", O_RDWR);
if(fd < 0)
{
perror("1.txt");
return 1;
}
if(read(fd, buf, 10) < 0)
{
perror("1.txt");
return 1;
}
//打印進程uid,有效uid
printf("%d %d %s\n", getuid(), geteuid(), buf);
exit(1);
}
編譯成a.out二進制文件
3.二進制文件a.out權(quán)限修改為4770,用戶屬于root,組為當前用戶所在組,執(zhí)行./a.out可以執(zhí)行成功,因為進程有效用戶已經(jīng)為root

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI