Level0
Level Goal
The goal of this level is for you to log into the game using SSH. The host to which you need to connect is bandit.labs.overthewire.org, on port 2220. The username is bandit0 and the password is bandit0. Once logged in, go to the Level 1 page to find out how to beat Level 1.
Commands you may need to solve this level
ssh
putty를 설치한다.
HOST NAME에 bandit.labs.overthewire.org.를 입력하고, 포트 번호에는 2220을 입력한다.
디폴트 설정에 저장해놓고 ssh로 오픈한다.
그렇게 하면 아래와 같은 화면이 뜨고 맨 윗줄의 "Login as: "까지 나온다..
그 상태에서 bandit0를 입력하면 패스워드를 입력하라는 문장까지 또 출력된다.
그러면 다시 bandit0를 입력한다. 이 때, 입력되는 상황은 보이지 않는다.
전부 입력하면 위와 같이 내용이 쭉 출력되는 것을 확인할 수 있다. (아래 무슨 글이 더 써져 있다!)
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.
Commands you may need to solve this level
ls, cd, cat, file, du, find
이 레벨을 풀기 위해 필요한 명령어들에 대해 검색해보았다.
1) ls 명령어 - dos의 "dir"
: ls ; 현재의 디렉토리 목록
: ls /usr/bin ; /usr/bin 의 디렉토리 목록
: ls -a ; 디렉토리 목록(숨김파일 포함)
: ls -l ; 디렉토리 목록 자세히
: ls *.txt ; txt파일 보여줌
: ls -l /usr/bin/a* ; /usr/bin/ 디렉토리에서 앞글자가 a인 목록.
2) cd 명령어 - 디렉토리 이동
: cd ; 사용자의 홈 디렉토리로 이동
: cd ~root ; root사용자의 홈 디렉토리로 이동
: cd .. ; 상위 디렉토리로 이동
: cd /usr/bin ; /usr/bin 디렉토리로 이동(절대경로)
: cd ../usr/bin ; 상대경로로 이동
3) cat - 텍스트 작성 파일 화면에 출력
: cat install.log
4) file - 파일의 종류 표시
: file install.log
: file /bin/gzip
5) find [경로] [옵션] [조건] [action]
[옵션] -name, -user(소유자), -newer(전, 후) -perm(허가권), -size(크기)
[경로] -print(디폴트), -exec(외부명령 실행)
[사용 예]
: find /etc -name "*.conf" ; /etc 에 확장자 conf 파일 검색
: find ~ -perm 644 ; 허가권이 644인 파일 검색
: find /bin -size +10k -size -100k ; 10kb~100kb인 파일 검색
: find ~ -size 0k -exec ls -l { } \;
-> 사용자 홈 디렉토리 하위에 파일 크기가 0인 파일 목록 상세히 출력
: find /home -name "*.swp" -exec rm { } \;
-> /home 홈 디렉토리 하위에 확장자 swp파일 삭제
6) du - Disk Usage를 의미하며, 지정된 디렉토리의 디스크 사용량을 표시하는 명령어.
예시 - du [ 옵션 ] [ 파일 ] [ 디렉토리]
우리는 이중에서 ls와 cat를 이용해서 비밀번호를 알아낼 수 있다.
ls를 입력하면 디렉토리 안에 readme라는 파일이 있다는 것을 알 수 있다.
cat 명령어를 이용해 readme 파일 안의 내용을 읽어온다.
저게 아마도 비밀번호일 것이다.
복사하기를 해놓자.
boJ9jbbUNNfktd78OOpsqOltutMc3MY1
Level1 -> Level2
Level Goal
The password for the next level is stored in a file called - located in the home directory
Commands you may need to solve this level
ls, cd, cat, file, du, find
Helpful Reading Material
login as : bandit1 을 치면 비밀번호를 입력하라고 뜬다.
근데 붙여넣기가 안된다...
그래서 열심히 비밀번호를 쳤다.
위 문제에서, - 란 이름의 파일에 다음 레벨로 가는 비밀번호가 저장되어있다고 하는 것 같다.
이전 레벨처럼 ls를 써보자.
ls를 입력하니 파일 이름은 - 라고 한다.
이전 레벨처럼 cat을 이용해 내용을 보려고 했다.
그랬더니 입력을 해도 입력한 내용을 다시 출력만 한다.
입력을 받아주는 문장도 안뜬다.
다시 비밀번호를 쳐야하나 생각했는데, 신기하게 ctrl + c를 입력하니 탈출이 됐다.
검색해보니, 맨 앞이 특수문자로 된 파일명을 읽으려면 cat과 파일명 사이에 <를 붙이거나 ./를 붙여야한다고 한다.
잘 출력이 되었다^^
아래 이상하게 더 출력된 것은 비밀번호를 복붙하기 위해 노력한 흔적이다.
비밀번호는 CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9 이다.
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
Commands you may need to solve this level
ls, cd, cat, file, du, find
Helpful Reading Material
다음 레벨로 넘어가기 위해 필요한 비밀번호는 '파일 이름 안에 공간이 있는' 파일에 있다고 한다.
필요한 명령어는 대충 비슷하다고 한다.
딱봐도 왠지 ls는 될 것 같은데, cat은 안될 것 같다.
그래도 혹시 몰라서 해봤는데, 역시 안된다.
출력된 내용을 보니 '이러한 파일이 디렉토리에 없다'라고 한다.
근데 저 내용이 각 단어별로 출력이 된다. 그래서 한 단어만 입력해보니 맞는 것 같다.
이 문제는 " "안에 파일이름을 적어줌으로써 해결할 수 있다.
비밀번호는 UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK 이다.
Level3 -> Level4
Level Goal
The password for the next level is stored in a hidden file in the inhere directory.
Commands you may need to solve this level
ls, cd, cat, file, du, find
이번엔 비밀번호가 숨겨진 파일에 있는데, 이 파일이 홈 디렉토리가 아니라 inhere 디렉토리에 있다고 한다.
위에 문제들처럼 ls와 cat를 시도해보자.
ls를 입력하니 이전과 다르게 파란색 글씨로 inhere란 글씨가 출력된다.
ls -a를 입력하면 숨겨진 디렉토리도 볼 수 있다.
그래서 바로 입력해보니 어떤 내용들이 출력되었다. 아마도 홈 디렉토리 안에 있는 목록들이 뜬 것 같다.
우리는 inhere 안의 파일을 봐야하므로, cd란 명령어를 이용해서 inhere로 이동한다.
cd inhere를 입력하면 된다.
그리고 다시 ls -a를 입력하자.
그러면 파일이 나오고, cat으로 비밀번호를 알아낼 수 있다.
비밀번호는 pIwrPrtPN36QITSp3EQaw936yaFoFgAB 이다.
저기 목록을 보면 . 이랑 .. 그리고 .hidden이 떴는데, cd ..을 하게 되면 상위 디렉토리로 가게 된다.
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.
Commands you may need to solve this level
ls, cd, cat, file, du, find
이번 비밀번호는 inhere 디렉토리의 only human-readable 파일에 있다고 한다.
이전과 같이 ls와 cat를 이용하다보면, 파일이 8개나 나온다.
차례대로 해보면 7번 파일에 있다는 것을 알 수 있다.
팁에 reset 명령어를 알려준걸 사용하면 좀 깔끔하게 할 수 있다.
비밀번호는 koReBOKuIDDepwhWk7jZC0RTdopnAYKh 이다.
근데 이런식으로 다 입력하는게 불편해서 찾아보니 파일 형식을 다 출력해주는 명령어가 있다.
file ./*을 입력하면 7번만 ASCII text이고, 나머진 data라는 것을 알 수 있다.
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
Commands you may need to solve this level
ls, cd, cat, file, du, find
이번 비밀번호는 inhere 디렉토리에 있다. 그리고 인간이 읽을 수 있고, 1033 바이트의 사이즈면서 실행불가능?하다.
이전 레벨들처럼 ls와 cat, cd를 써서 해보자.
그 전에 명령어 모음을 검색해보자.
OPTION
-P : 심볼릭 링크를 따라가지 않고, 심볼릭 링크 자체 정보 사용.
-L : 심볼릭 링크에 연결된 파일 정보 사용.
-H : 심볼릭 링크를 따라가지 않으나, Command Line Argument를 처리할 땐 예외.
-D : 디버그 메시지 출력.
EXPRESSION
-name : 지정된 문자열 패턴에 해당하는 파일 검색.
-empty : 빈 디렉토리 또는 크기가 0인 파일 검색.
-delete : 검색된 파일 또는 디렉토리 삭제.
-exec : 검색된 파일에 대해 지정된 명령 실행.
-path : 지정된 문자열 패턴에 해당하는 경로에서 검색.
-print : 검색 결과를 출력. 검색 항목은 newline으로 구분. (기본 값)
-print0 : 검색 결과를 출력. 검색 항목은 null로 구분.
-size : 파일 크기를 사용하여 파일 검색.
-type : 지정된 파일 타입에 해당하는 파일 검색.
-mindepth : 검색을 시작할 하위 디렉토리 최소 깊이 지정.
-maxdepth : 검색할 하위 디렉토리의 최대 깊이 지정.
-atime : 파일 접근(access) 시각을 기준으로 파일 검색.
-ctime : 파일 내용 및 속성 변경(change) 시각을 기준으로 파일 검색.
-mtime : 파일의 데이터 수정(modify) 시각을 기준으로 파일 검색.
근데, find -size 1033만 쓰면 실행이 되지 않는다.
단위를 안썼기 때문이다.
바이트라서 b를 써야할 것 같지만, c를 써야한다.
단위는 b는 블록, c가 바이트, w는 2바이트, k는 Kbytes, M은 Mbytes, G는 Gbytes 이다.
그래서 find -size 1033c를 쓰면 된다.
비밀번호는 DXjZPULLxYr17uwoI01bNLQbtFemEgo7 이다.
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
Commands you may need to solve this level
ls, cd, cat, file, du, find, grep
이번 비밀번호는 서버의 어딘가에 저장되어있다고 한다. 그리고 위와 같은 특징들이 있다고 한다.
find -user [유저이름] 을 사용하면 소유자의 이름이 유저이름인 파일을 찾고, group 인 경우엔 그 파일을 찾는다.
find -user ~~ -group ~~ -size 33c 처럼 이어서 쓸 수 있다.
아래서 4번째 줄에 보면 .password 라고 있다.
비밀번호는 HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs 이다.
Level7 -> Level8
Level Goal
The password for the next level is stored in the file data.txt next to the word millionth
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
비밀번호가 data.txt라는 파일 안에 millionth라는 단어 다음에 있다고 한다.
grep 명령어를 사용해 찾을 수 있다.
grep "[내용]"[파일이름] 을 하면 해당 파일 안에 해당 내용이 포함된 줄을 출력한다.
그냥 cat data.txt 를 하면 무수히 많은 내용이 출력되니 하지 말자....
비밀번호는 cvX2JJa4CFALtqS87jk27qwqGhBM9plV 이다.
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
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
Helpful Reading Material
비밀번호가 data.txt란 파일 안에 있고, 한 줄만 있다고 한다.
이전처럼 ls를 입력하고, cat data.txt 하면 수많은 문장들이 출력된다.
sort를 이용하면 사용자가 지정한 파일 내용을 오름차순으로 정렬한다.
uniq를 이용하면 내부의 문장들 중 연속된 중복 문장 중 하나만 출력되게 한다.
그런데 uniq -u를 쓰면 파일 내부의 문장들 중 연속된 중복 문장은 모두 삭제하고 출력한다.
위 코드에서 |는 파이프로, 이전 명령어를 통해 출력된 결과를 다음 명령어에 보내준다.
그래서 cat data.txt|sort|uniq -u라 하면, 정렬을 한 후에 중복된 문장을 삭제하고 출력한다.
그러므로 비밀번호만 출력된다.
비밀번호는 UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR 이다.
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, beginning with several ‘=’ characters.
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
이번 비밀번호는 data.txt란 파일에 있는데, 인간이 읽을 수 있는 몇개의 문장 중에서 =로 시작한다고 한다.
우선 항상 하던대로 ls와 cat을 이용해보자.
strings 명령어를 이용하면 binary 파일에서 문자열만을 추출할 수 있다.
strings data.txt를 하게되면 많은 문자열들이 출력된다.
근데 그 수가 아직 꽤 많다.
그래서 이전 단계에서 썼던, | 기호와 grep명령어를 사용해서
strings data.txt|grep "="를 하면 된다.
비밀번호는 truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk 이다.
Level10 -> Level11
Level Goal
The password for the next level is stored in the file data.txt, which contains base64 encoded data
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
Helpful Reading Material
비밀번호가 data.txt 파일 안에 있는데, 그 파일은 base64로 인코드 된 데이터를 갖고있다고 한다.
디코드를 하는 명령어는 --decode 이고, 그 앞에 base64를 적어주면 된다.
즉, cat data.txt | base64 --decode를 하면 비밀번호가 나올 것이다.
비밀번호는 IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR 이다.
Level11 -> Level12 (다시 공부)
Level Goal
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
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd
Helpful Reading Material
이번 비밀번호는 마찬가지로 data.txt 파일 안에 있다. 근데 모든 알파벳이 13자리씩 돌았다고 한다.
ls와 cat를 이용해 내용을 출력해보면 내용이 나오긴 하는데 이걸 다시 원래대로 돌려야한다.
그래서 tr 명령어를 사용한다.
$ # Map upper case A-Z to N-ZA-M and lower case a-z to n-za-m
$ tr 'A-Za-z' 'N-ZA-Mn-za-m' <<< "The Quick Brown Fox Jumps Over The Lazy Dog"
Gur Dhvpx Oebja Sbk Whzcf Bire Gur Ynml Qbt
위키피디아에 검색하니 위와 같은 문장을 발견했다.
두번째 줄의 tr 'A-Za-z' 'N-ZA-Mn-za-m' 을 보면, A부터 Z까지와 a부터 z까지를 각각 N부터 Z까지와 A부터 M까지, 그리고 n부터 z까지와 a부터 m까지로 바꾸란 뜻이다.
그래서 cat data.txt|tr 'A-Za-z' 'N-ZA-Mn-za-m' 를 해보면...
비밀번호가 5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu 라는 것을 알 수 있다.
Level12 -> Level13
Level Goal
The password for the next level is stored in the file data.txt, which is a hexdump of a file that has been repeatedly compressed. For this level it may be useful to create a directory under /tmp in which you can work using mkdir. For example: mkdir /tmp/myname123. Then copy the datafile using cp, and rename it using mv (read the manpages!)
Commands you may need to solve this level
grep, sort, uniq, strings, base64, tr, tar, gzip, bzip2, xxd, mkdir, cp, mv, file
Helpful Reading Material
이번 패스워드도 마찬가지로 data.txt 파일 안에 있는데, 이 파일은 반복적으로 압축된? 파일의 hexdump란다.
이 레벨을 위해서는 /tmp 디렉토리 아래에 mkdir을 써서 디렉토리를 만드는게 유용할 것이라고 한다.
예시도 줬다...
mkdir이 뭐고, hexdump가 뭔지 알아보자.
mkdir은 make directory의 약자이다. 위 예시처럼 하면 하위에 디렉토리를 만든다.
일단 ls와 cat를 이용해 파일을 열어보면 16진수로 된 코드가 쭉 출력된다.
우선, 이 문제를 해결하기 위해 필요할 수 있는 명령어 몇개를 알아보자.
tar은 여러 개의 파일을 하나의 파일로 묶거나 풀 때 사용하는 명령입니다. "테이프 아카이버(Tape ARchiver)"의 앞 글자들을 조합하여 "tar"라는 이름으로 명명된다.
tar [OPTION...] [FILE]...
-f : 대상 tar 아카이브 지정. (기본 옵션)
-c : tar 아카이브 생성. 기존 아카이브 덮어 쓰기. (파일 묶을 때 사용)
-x : tar 아카이브에서 파일 추출. (파일 풀 때 사용)
-v : 처리되는 과정(파일 정보)을 자세하게 나열.
-z : gzip 압축 적용 옵션.
-j : bzip2 압축 적용 옵션.
-t : tar 아카이브에 포함된 내용 확인.
-C : 대상 디렉토리 경로 지정.
-A : 지정된 파일을 tar 아카이브에 추가.
-d : tar 아카이브와 파일 시스템 간 차이점 검색.
-r : tar 아카이브의 마지막에 파일들 추가.
-u : tar 아카이브의 마지막에 파일들 추가.
-k : tar 아카이브 추출 시, 기존 파일 유지.
-U : tar 아카이브 추출 전, 기존 파일 삭제.
-w : 모든 진행 과정에 대해 확인 요청. (interactive)
-e : 첫 번째 에러 발생 시 중지.
Level13 -> Level14
Level Goal
The password for the next level is stored in /etc/bandit_pass/bandit14 and can only be read by user bandit14. For this level, you don’t get the next password, but you get a private SSH key that can be used to log into the next level. Note: localhost is a hostname that refers to the machine you are working on
Commands you may need to solve this level
ssh, telnet, nc, openssl, s_client, nmap
Helpful Reading Material
이번 패스워드는 어떤 파일에 들어있고, user bandit14로만 읽을 수 있다는 것 같다.
이 레벨에서는 다음 비밀번호를 얻을 수 없지만, log에 입력해서 다음 레벨로 갈 수 있는 private SSH key를 얻을 수 있는 것 같다.
localhost는 ???이다.
'포너블 스터디' 카테고리의 다른 글
달고나 요약 (~ 33p) (0) | 2020.04.11 |
---|---|
System Exploitation Fundamental (3) (0) | 2020.04.10 |
System Exploitation Fundamental (2) (0) | 2020.04.10 |
System Exploitation Fundamental (1) (0) | 2020.04.10 |