Skip to content

Latest commit

 

History

History
120 lines (85 loc) · 4.7 KB

211016.md

File metadata and controls

120 lines (85 loc) · 4.7 KB

Day 15

man <command> : 설명, 나올때는 q, ctrl d는 다음으로

OverTheWire WriteUp

level0 -> level1

Level Goal

The password for the next level is stored in a file called readme located in the home directory. Use this password to log into bandit1 using SSH. Whenever you find a password for a level, use SSH (on port 2220) to log into that level and continue the game.

ssh -p [포트번호] [username]@[host]

Level1 -> Level2

Level Goal

The password for the next level is stored in a file called - located in the home directory

파일명이 '-'인 파일 열기

리눅스 시스템에서는 '-'를 명령어의 인자로 본다

'-'로 된 파일을 열려면 상대경로나 절대경로로 경로로 표현하여 파일임을 인식시켜준다.

Level2 -> Level3

Level Goal

The password for the next level is stored in a file called spaces in this filename located in the home directory

파일명에 공백이 있는 파일 읽기

방법1 : '' 사용
방법2 : 공백 옆에 \사용
방법3 : 와일드카드 사용

Level3 -> Level4

Level Goal

The password for the next level is stored in a hidden file in the inhere directory.

숨김파일 찾아서 읽기
ls -al로 inhere이라는 숨김폴더 찾음
cd로 이동해서 ls -al로 .hidden이라는 숨김 파일을 찾고 cat으로 출력

Level4 -> Level5

Level Goal

The password for the next level is stored in the only human-readable file in the inhere directory. Tip: if your terminal is messed up, try the “reset” command.

cd로 inhere 디렉토리로 이동
ls -al로 확인결과 -file00, -file01, ... -file09까지 있었다.
file ./*을 하면 디렉토리안의 모든 파일에대하여 file 명령을 처리한다.
이 중에서 -file07 하나만 ASCII text였다

Level5 -> Level6

Level Goal

The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:

  • human-readable
  • 1033 bytes in size
  • not executable

password는 inhere 디렉토리 아래에 사람이 읽을 수 있고, 1033 바이트의 크기를 가지고, 실행이 불가능하다는 특징을 가지고 있다.
find 명령어 사용

  • -size n : 파일 크기로 찾음
    • b : Block
    • c : Byte
    • w : Word (2 Byte)
  • path 쪽에 .으로 주면 하위 디렉토리 전체 확인, /는 루트부터 전체

find . -size 1033c로 확인하니 파일 하나 나옴

Level6 -> Level7

Level Goal

The password for the next level is stored somewhere on the server and has all of the following properties:

  • owned by user bandit7
  • owned by group bandit6
  • 33 bytes in size

서버내에 어딘가에 user 권한은 bandit7, group 권한은 bandit6이고, 크기는 33바이트인 파일이 존재한다.

find / -user bandit7 -group bandit6 -size 33c 2>/dev/null 사용

2>/dev/null은 에러를 화면에 출력하지 않게 해줌

Level7 -> Level8

Level Goal

The password for the next level is stored in the file data.txt next to the word millionth

data.txt파일에 millionth 단어 다음에 password가 존재한다

grep 명령어와 |를 이용한다
cat data.txt | grep millionth
data.txt를 cat으로 출력한 것을 grep에게 주어 millionth라는 문자열을 찾아냈다.

Level8 -> Level9

Level Goal

The password for the next level is stored in the file data.txt and is the only line of text that occurs only once

password는 data.txt 파일에서 단 한번만 나타난 문자열이다.

sort : 지정한 파일의 내용을 정렬하거나, 정렬된 파일의 내용을 병합할 때 사용

uniq : 중복된 내용의 행이 연속으로 있으면 하나만 남기고 삭제, 분산되어 있으면 찾아내지 못하여 주로 sort와 같이 쓰인다.

-u 옵션을 사용하면 중복 라인이 없는 것만 보여준다.

sort data.txt | uniq -u 명령어를 실행하여 data.txt를 정렬시키고, uniq -u로 중복된 행이 없는 것만 출력 시켰다.

Level9 -> Level10

Level Goal

The password for the next level is stored in the file data.txt in one of the few human-readable strings, preceded by several ‘=’ characters.

password는 data.txt에 존재하며 몇개의 '=' 문자로 시작되며 읽을 수 있는 몇 안되는 문장 중 하나이다.

리눅스 명령어 중 strings라는 명령어가 있는데 얘는 ASCII 문자를 찾아 출력해준다.
grep을 사용해서 =을 찾으면 더 보기 편해질 것이다.
strings data.txt | grep =

Level10 -> Level11

Level Goal

The password for the next level is stored in the file data.txt, which contains base64 encoded data

password는 data.txt에 base64로 encoding되어 있다.

base64 명령어로 -d옵션을 주면 디코딩을 해준다
base64 -d data.txt