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 디렉토리 어딘가에 3가지 조건을 가지고 존재하네요.
사람이 읽을 수 있을 것, 1033 바이트의 파일, 실행할 수 없는 파일 입니다.
inhere 디렉토리로 이동한 다음 ls -la 명령어를 확인하여 살펴보겠습니다.
bandit5@bandit:~/inhere$ ls -la
total 88
drwxr-x--- 22 root bandit5 4096 Sep 19 07:08 .
drwxr-xr-x 3 root root 4096 Sep 19 07:08 ..
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere00
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere01
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere02
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere03
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere04
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere05
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere06
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere07
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere08
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere09
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere10
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere11
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere12
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere13
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere14
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere15
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere16
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere17
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere18
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 maybehere19
maybehere00부터 maybehere19까지 20개의 디렉토리가 있네요!
maybehere00 디렉토리로 이동하여 어떤 파일들이 존재하는지 보겠습니다.
bandit5@bandit:~/inhere/maybehere00$ ls -la
total 72
drwxr-x--- 2 root bandit5 4096 Sep 19 07:08 .
drwxr-x--- 22 root bandit5 4096 Sep 19 07:08 ..
-rwxr-x--- 1 root bandit5 1039 Sep 19 07:08 -file1
-rwxr-x--- 1 root bandit5 551 Sep 19 07:08 .file1
-rw-r----- 1 root bandit5 9388 Sep 19 07:08 -file2
-rw-r----- 1 root bandit5 7836 Sep 19 07:08 .file2
-rwxr-x--- 1 root bandit5 7378 Sep 19 07:08 -file3
-rwxr-x--- 1 root bandit5 4802 Sep 19 07:08 .file3
-rwxr-x--- 1 root bandit5 6118 Sep 19 07:08 spaces file1
-rw-r----- 1 root bandit5 6850 Sep 19 07:08 spaces file2
-rwxr-x--- 1 root bandit5 1915 Sep 19 07:08 spaces file3
이거 하나하나 살펴보기에는 시간이 너무 오래 걸릴 것 같네요.
리눅스의 명령어에는 find가 있습니다.
파일과 디렉토리를 검색할 때 사용하는 것이지요!
- find inhere를 실행하면 inhere 디렉토리에서 파일과 디렉토리를 검색합니다.
- find . 을 실행하면 현재 디렉토리 내에서 검색을 수행합니다.
- find -type f는 디렉토리를 제외하고 파일만 찾아줍니다.
-> 디렉토리, 심볼릭 링크, 소켓 무시- 파일 크기를 조건에 추가하려면 -size 하시면 됩니다.
-> -size 1033c를 넣어주면 되겠군요(c는 바이트를 의미)- -executable은 실행 가능한 파일을 의미하고 앞에 ! 붙여주면 실행 불가능한 파일입니다.
위의 팁을 참고하여 명령어를 작성하면 find inhere -type f -size 1033c ! -executable이 되겠군요!
터미널에서 실행해보죠.
bandit5@bandit:~$ find inhere -size 1033c ! -executable -type f
inhere/maybehere07/.file2
오! 해당 조건을 만족하는 파일의 경로가 나타났습니다.
이 파일은 사람이 읽을 수 있는 파일일까요? file 명령어를 사용해보겠습니다.
bandit5@bandit:~$ file inhere/maybehere07/.file2
inhere/maybehere07/.file2: ASCII text, with very long lines (1000)
ASCII text인 것을 보니 읽을 수 있겠네요!
위 경로에 있는 파일을 cat 명령어를 사용하여 출력해보겠습니다.
bandit5@bandit:~$ cat inhere/maybehere07/.file2
HWasnPhtq9AVKe0dmk45nxy20cvUa6EG
비밀번호 출력 완성 :)
어려워 보이는데 진짜 멋집니다 👍🏻