1 / 12

setuid, setgid, sticky bit 권한

setuid, setgid, sticky bit 권한. 그 외의 권한들. 1. setuid. 1). Setuid 권한. Setuid 란 ?. setuid 권한을 가진 file 을 일반 user 가 실행하게 되면 그 순간 잠시 root 권한을 빌려 오는 것이라 생각하면 편리하다 . Program 실행 시 process 가 가지는 권한은 program 을 실행한 사용자의 권한이 아닌 program 소유자의 권한을 가지는 것을 setuid 의 개념이라고 생각하면 된다 .

Download Presentation

setuid, setgid, sticky bit 권한

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. setuid, setgid, sticky bit 권한

  2. 그 외의 권한들 1. setuid 1). Setuid 권한 Setuid란? setuid 권한을 가진 file을 일반 user가 실행하게 되면 그 순간 잠시 root 권한을 빌려 오는 것이라 생각하면 편리하다. Program 실행 시 process가 가지는 권한은 program을 실행한 사용자의 권한이 아닌 program 소유자의 권한을 가지는 것을 setuid의 개념이라고 생각하면 된다. $ ls -l /bin/passwd -r-sr-sr-x 3 root sys 101744 Jan 6 2000 /bin/passwd (passwd 명령어는 setuid와 setgid가 설정되어 있으므로 일반유저에서 파일소유자의 권한으로 실행이 가능하다.)

  3. 그 외의 권한들 1. setuid 2). Setuid 실행 예제 Setuid 예제 $ cat /etc/shadow  (cat의 실행자는 일반유저이므로 파일을 읽을 수 없다.) cat: cannot open /etc/shadow $ su - ; root로 사용자 이동 # ls -l /etc/shadow  (root 권한으로만 읽기가 가능하다.) -r--------   1 root     sys          339 Feb 18 18:41 /etc/shadow # ls -l /bin/cat  (파일소유자는 root이다.) -r-xr-xr-x   1 root     bin        10092 Jul 10  2000 /bin/cat # chmod 4455 /bin/cat # ls -l /bin/cat -r-Sr-xr-x   1 root     bin        10092 Jul 10  2000 /bin/cat (파일에 setuid권한이 있으나 실행 권한이 없을 경우는 소문자 s가 아니라 대문자 S 기호가 나타난다.)

  4. 그 외의 권한들 1. setuid 2). Setuid 실행 예제 Setuid란? # chmod 4555 /bin/cat  (실행자의 권한이 아닌 파일소유자의 권한을 부여한다.) # ls -l /bin/cat -r-sr-xr-x   1 root     bin        10092 Jul 10  2000 /bin/cat # su ysw100 $ cat /etc/shadow (cat의 실행자가 아닌 파일소유자의 권한으로 읽는다.) root:L89niy4Uo6HtM:6445::::::

  5. 그 외의 권한들 2. setgid 1). Setgid 권한 Setgid란? setuid와 유사하다. setuid는 실행 파일을 소유한 사용자의 권한을 가지지만, setgid는 실행 파일을 소유한 그룹 소유주의 권한을 가진다. 즉 process가 명령어를 실행한 소유자가 속한 기본 그룹의 권한을 가지지 않고 명령어의 그룹 소유주 권한을 가지게 된다. setgid 권한을 명시할 때는 기호 방법만을 사용한다. setgid 권한이 명시된 directory 밑에 새로 생성되는 모든 하위 directory나 file도 setgid 권한을 가진다.

  6. 그 외의 권한들 2. setgid 2). Setgid 실행 예제 Setgid 예제 $ id -a uid=107(blackbat) gid=2002(users) groups=2002(users) $ mkdir sgid $ ls -ld sgid drwxr-xr-x   2 blackbat users        512 Feb 20 17:18 sgid $ cd sgid $ mkdir dir1 $ touch file1 $ su # id -a uid=0(root)gid=1(other)groups=1(other),0(root),2(bin),3(sys),4(adm),5(uucp),6(mail),7(tty),8(lp),9(nuucp),12(daemon) # chmod g+s sgid

  7. 그 외의 권한들 2. setgid 2). Setgid 실행 예제 Setgid 예제 # ls -ld sgid drwxr-sr-x   3 blackbat users        512 Feb 20 17:20 sgid # mkdir dir2 # touch file2 # ls -l total 4 drwxr-xr-x   2 blackbat users        512 Feb 20 17:20 dir1 drwxr-sr-x   2 root      users        512 Feb 20 17:21 dir2 -rw-r--r--   1 blackbat users          0 Feb 20 17:20 file1 -rw-r--r--   1 root     users          0 Feb 20 17:21 file2 (어떤 사용자든지 새로 파일이나 디렉토리를 만들어도 setgid 권한이 명시된 상위그룹과 동일한 그룹 소유자를 가진다.)

  8. 그 외의 권한들 3. Sticky bit 1). Sticky bit란? Sticky bit 란? 일반적으로 모든 사용자에게 변경 권한이 부여된 directory 이다. system에 존재하는 어떠한 사용자라도 해당 directory 밑에 file이나 하위 directory 를 생성할 수 있고, 삭제가 가능하다. 하지만 삭제는 file이나 directory의 소유자나 root 사용자 또는 변경권한이 허락하는 경우에만 가능하다.) Sticky bit의 사용 목적의 대부분은 공용 directory로 사용하기 위한 것이다.  즉, sticky-bit로 설정된 directory는 모든 사용자가 write가능하며 write된 파일은 그 사용자의 소유가 된다. 물론 삭제할 수 있는 권한 또한 root와 해당 사용자만이 가능하다. # mkdir sticky # chmod 1777 sticky drwxrwxrwt   2 root     other        512 Feb 20 17:33 sticky

  9. 그 외의 권한들 4. 권한변경 1). 권한 변경 방법 각각의 권한 변경 방법 setuid, setgid, skicky bit로 권한을 변경할 때는 다음과 같이 변환한다. sun02[/aaa]#touch test1 test2 test3 sun02[/aaa]#ls -l 총 0 -rw-r--r-- 1 root other 0 3월 19일 02:45 test1 -rw-r--r-- 1 root other 0 3월 19일 02:45 test2 -rw-r--r-- 1 root other 0 3월 19일 02:45 test3 sun02[/aaa]#chmod 4644 test1 ;test1 file에 setuid 권한 부여 sun02[/aaa]#chmod 2644 test2 ;test2 file에 setgid 권한 부여 sun02[/aaa]#chmod 1644 test3 ;test3 file에 sticky bit 권한 부여 sun02[/aaa]#ls -l -rwSr--r-- 1 root other 0 3월 19일 02:45 test1 -rw-r-lr-- 1 root other 0 3월 19일 02:45 test2 -rw-r--r-T 1 root other 0 3월 19일 02:45 test3

  10. Find 명령어 5. Find 명령어 1). Find 명령어 사용방법 Find 명령어 사용예제 sun02[/]# find / -name host* -print ; / directory를 시작점으로 host로 시작하는 모든 file을 찾아서 화면에 출력해라. sun02[/]# find /var –size +1024k –print (리눅스 형식) ; /var directory를 시작점으로 1MB 이상 되는 file을 찾아서 화면에 출력해라. sun02[/]# find / -perm -4000 –print > sample1 ; / directory를 시작점으로 setuid가 걸린 file을 찾아서 sample1이라는 file에 저장해라. sun02[/] # find / -perm -2000 –print > sample2 ; / directory를 시작점으로 setgid가 걸린 file을 찾아서 sample2라는 file에 저장해라. sun02[/] # find / -perm -1000 –print > sample3 ; / directory를 시작점으로 sticky bit가 걸린 file을 찾아서 sample3이라는 file에 저장해라.

  11. Find 명령어 1. Find 명령어 1). Find 명령어 사용방법 Find 명령어 사용예제 sun02[/]# find / -name core –exec rm {} \; ; / directory를 시작점으로 core file을 찾아내어 모두 삭제한다. (core file을 삭제하는 전형적인 예문이므로 꼭 외워두도록 한다.) sun02[/]# find /etc–mtime -7 –print > modi1 ; /etc directory를 시작점으로 7일 동안 수정된 file을 찾아서 modi1 file에 저장. sun02[/]# find /etc–atime -3 –print > modi2 ; /etc directory를 시작점으로 3일 동안 access된 file을 찾아서 modi2 file에 저장. sun02[/]# find /–inum6574 –print ; / directory를 시작점으로 inode number가 6574인 file을 찾아서 화면에 출력.

  12. File 실행 순서 1. File이 실행되는 순서에 대해 1). File 실행 순서 File이 실행되는 우선순위와 절차 1. $PATH에서 찾음 2. 찾은 후에 실행 권한 check 3. 권한이 있다면 실행시킨 사용자의 UID로 실행 4. setuid bit가 있는가를 확인 5. setuid bit가 있다면 명령어 소유주의 UID로 실행

More Related