OverTheWire : Bandit Level 5 → Level 6

heuniy·2023년 9월 24일

bandit_write up

목록 보기
7/10

문제

https://overthewire.org/wargames/bandit/bandit6.html

Bandit Level 5 → Level 6
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

inhere 디렉토리 어딘가에 있는 파일에 password 가 있다.

조건은 human-readable 1033 bytes in size not executable 이다.


풀이

bandit5@bandit:~$ cd inhere
bandit5@bandit:~/inhere$ ls
maybehere00 maybehere04 maybehere08 maybehere12 maybehere16
maybehere01 maybehere05 maybehere09 maybehere13 maybehere17
maybehere02 maybehere06 maybehere10 maybehere14 maybehere18
maybehere03 maybehere07 maybehere11 maybehere15 maybehere19

inhere 디텍토리 목록을 출력하니 되게..많이 뜬다.


bandit5@bandit:~/inhere$ cd maybehere00
bandit5@bandit:~/inhere/maybehere00$ ls
-file1 -file2 -file3 spaces file1 spaces file2 spaces file3

maybehere00 으로 이동해서 목록을 확인하니 또 .. 많다. 다 확인하긴 무리일 것 같다.

따라서 주어진 조건에 따라서 찾아보는게 좋을 듯 하다 !!


조건 중 1033 bytes in size 을 만족하는 파일을 찾기 위해 find 명령어를 사용한다.

find : 특정 파일 / 디렉토리 찾기

bandit5@bandit:~/inhere$ find ./* -size 1033c
./maybehere07/.file2

파일 크기로 찾을 때는 size 표현식을 사용하고 bytes 는 뒤에 c 가 붙는다.


bandit5@bandit:~/inhere$ file ./maybehere07/.file2
./maybehere07/.file2: ASCII text, with very long lines (1000)

파일 종류를 확인하니 매우 긴 ASCII 타입이므로 human-readable 조건을 충족한다.


bandit5@bandit:~/inhere$ cat ./maybehere07/.file2
P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU

passwordP4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU 이다.


기타

리눅스 명령어 정리 (누적)

pwd : 현재 작업중인 디렉토리 정보(경로) 출력

ls : 디렉토리 목록 확인

  • ls -a : 모든 파일(숨겨진 파일 혹은 디렉토리)을 출력

cat [파일명] : [파일명] 내용 출력

  • cat ./[파일명] : 현재 디렉토리에 있는 [파일명] 내용을 출력
  • cat '[파 일 명]' : space가 있는 [파일명] 내용 출력
  • cat [파\ 일\ 명] : space가 있는 [파일명] 내용 출력

file [파일명] : [파일명] 종류(타입) 확인

find [옵션][경로][표현식] : 특정 파일 / 디렉토리 찾기

  • find ./* -size [bytes]c : 현재 디텍토리에서 [bytes]파일 찾기
profile
고양이 귀여워

0개의 댓글