[overthewire] Leviathan level4

mj·2023년 1월 16일
0
post-thumbnail

접속

ssh -p 2223 leviathan4@leviathan.labs.overthewire.org
pw: vuH0coox6m

주어진 정보 확인

현재 디렉터리에서 정보를 확인한다.

leviathan4@leviathan:~$ ls -al
total 24
drwxr-xr-x  3 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
-rw-r--r--  1 root root        675 May 15  2017 .profile
dr-xr-x---  2 root leviathan4 4096 Aug 26  2019 .trash
leviathan4@leviathan:~$ ls -al .trash
total 16
dr-xr-x--- 2 root       leviathan4 4096 Aug 26  2019 .
drwxr-xr-x 3 root       root       4096 Aug 26  2019 ..
-r-sr-x--- 1 leviathan5 leviathan4 7352 Aug 26  2019 bin
leviathan4@leviathan:~$ file ./.trash/bin
./.trash/bin: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=00ce1aa55b0e691470f61baff0ee59a6c33fcb50, not stripped
leviathan4@leviathan:~$ 

현재 디렉터리를 확인해보니 .trash 디렉터리가 있고, 그 디렉터리안에는 bin이라는 이름의 바이너리 파일이 들어있다.

해당 바이너리 파일을 실행시켜보자

leviathan4@leviathan:~$ .trash/bin
01010100 01101001 01110100 01101000 00110100 01100011 01101111 01101011 01100101 01101001 00001010 
leviathan4@leviathan:~$ 

해당 바이너리 파일을 실행시키니까 2진수처럼 보이는 숫자들이 출력됐다.

스크립트를 작성하여 해당 2진수를 문자로 변환해보자

  1 binary = open('bin', 'r').read().strip()
  2 bin_list = binary.split(' ')
  3               
  4 result = ''      
  5 for bin in bin_list:
  6     num = int(bin, 2)
  7     num = chr(num)
  8     result += num
  9               
 10 print(result)        
leviathan4@leviathan:/tmp/leviathan4$ python payload.py 
Tith4cokei

leviathan4@leviathan:/tmp/leviathan4$ 

password를 획득했다.

id: leviathan5
pw: Tith4cokei

profile
사는게 쉽지가 않네요

0개의 댓글