0. OverTheWire Bandit
리눅스 연습!
각 단계에서 얻은 password로 다음 레벨의 아이디(e.g.
bandit1)에 접속할 수 있다.
1. level 0
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를 이용해서 bandit0 유저로bandit.labs.overthewire.org:2220에 접속하면 된다.
ssh bandit.labs.overthewire.org -p 2220 -l bandit0
ssh bandit10@bandit.labs.overthewire.org -p 2220 ## host 앞에 user@를 붙이는 것도 가능하다home directory에 있는 readme라는 파일을 읽어 bandit1의 password를 찾아낸다. 찾아낸 password는 로컬 머신에 복사해둬야 한다.
cat ~/readme2. level 1
The password for the next level is stored in a file called - located in the home directory
home directory의 - 파일(dashed file)을 읽어야 한다.
(ls -al로 home directory의 파일들을 확인)
-라는 이름의 파일은 cat -로 바로 읽게 되면 아무 반응이 없는데, -가 표준 입력 stdin을 의미해서 입력을 기다리는 상태가 되기 때문이다.
bandit1@bandit:~$ cat -
hello
hello아래와 같이 읽을 수 있다.
cat < - ## dashed file을 읽어 stdin으로 연결
cat ./- ## dashed file의 위치를 지정하여 읽음3. level 2
The password for the next level is stored in a file called --spaces in this filename-- located in the home directory
파일명에 공백이 있는 파일을 읽어야 한다. 공백 앞에 \를 붙여야 읽을 수 있다.
cat ./--spaces\ in\ this\ filename--4. level 3
The password for the next level is stored in a hidden file in the inhere directory.
~/inhere 디렉토리의 숨은 파일을 읽어야 한다. ls는 숨은 파일은 알려주지 않으므로 ls -a를 사용해야 한다.
ls -al ## a: all l: long-listing
cat ./...Hiding-From-You주로 ls -al을 사용하는데, l 옵션은 권한, 소유자, 그룹, 크기, 시간 등을 한 줄씩 출력해줘서 읽기 편한듯,,
5. level 4
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.
human-readable 파일을 읽어야 한다.
file 커맨드로 파일의 MIME 타입 등의 정보를 알 수 있다.
cd ~/inhere
file -i ./*파일 하나만 ASCII text으로 사람이 읽을 수 있다.
6. level 5
The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:
inhere 디렉토리에서 아래 조건을 만족하는 파일을 찾아서 읽어야 한다.
- human-readable
- 1033 bytes in size
- not executablefind .는 현재 디렉토리 하위의 모든 파일과 디렉토리들을 보여준다.
find . -type f -size 1033c ! -executable-type: 검색할 타입을 지정한다.
| type | 의미 |
|---|---|
f | 일반 파일 |
d | 디렉토리 |
l | 심볼릭 링크 |
c | 문자 디바이스 |
b | 블록 디바이스 |
p | 파이프(FIFO) |
s | 소켓 |
-size: 사이즈로 검색한다.
| size | 의미 |
|---|---|
c | bytes |
b | 512-byte blocks |
k | kilobytes (1024B) |
M | megabytes |
G | gigabytes |
-executable: 실행 가능한 것을 의미하며 앞에 !을 붙여 부정으로 바꿀 수 있다.
7. level 6
The password for the next level is stored somewhere on the server and has all of the following properties:
server 내의 어딘가에 있는 파일 중 아래 조건을 만족하는 파일을 읽어야 한다.
owned by user bandit7
owned by group bandit6
33 bytes in sizefind / -type f -size 33c -user bandit7 -group bandit6 2>/dev/null-user, -group로 owner 검색이 가능하다.
2>/dev/null를 쓰지 않으면 find 커맨드 실행 중 권한이 없는 디렉토리/파일을 만날 때 에러 메시지 Permission Denied를 stderr(FD 2)로 출력한다.
2>/dev/null은 sderr 2를 /dev/null로 리다이렉션(>)하여 에러 출력이 버려지도록 한다.
8. level 7
The password for the next level is stored in the file data.txt next to the word millionth
겁나 큰 용량의 data.txt 파일 내에서 millionth라는 단어의 옆에 써있는 password를 읽어야 한다.
ls -lh ## h: human 옵션으로 용량 값을 읽기 쉽도록 바꿔준다.
cat data.txt | grep millionth9. level 8
The password for the next level is stored in the file data.txt and is the only line of text that occurs only once
data.txt 에서 유일한 line을 찾아야 한다.
sort data.txt | uniq -iusort로 파일의 line들을 정렬한다. 여러 옵션을 추가로 사용할 수 있다.
uniq 커맨드는 중복되는 line을 제거하고 출력해준다. -d는 중복된 내용만 출력, -u는 고유한 내용만 출력, -i는 대소문자 구분 무시 옵션이다.
10. level 9
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.
data.txt에서 읽을 수 있는, =가 앞에 있는 문자열만을 출력해야 한다.
file data.txt ## data.txt: data
strings data.txt | grep '='strings는 파일에 포함된 string을 뽑아낼 수 있다.
11. level 10
The password for the next level is stored in the file data.txt, which contains base64 encoded data
base64 인코딩된 문자열이 data.txt에 들어있다.
cat data.txt | base64 -dbase64 -d 커맨드로 문자열을 디코딩하여 원래 바이너리를 출력한다.
12. level 11
The password for the next level is stored in the file data.txt, where all lowercase (a-z) and uppercase (A-Z) letters have been rotated by 13 positions
시저 암호가 적용된 data.txt 파일을 해석해야 한다. Rot13이므로 A → N Z→ M으로 치환한다.
정규식은 아니라고 한다.. (tr에서 쓰인 규칙일 뿐)
cat data.txt | tr '[A-Za-z]' '[N-ZA-Mn-za-m]'