우선 overthewire 페이지를 해석 해보겠습니다.
"inhere 폴더안에 사람이 읽을수 있고 파일의 크기가 1033bytes인 파일안에 비번이 있어" 라고 말하고 있습니다.
첫번째로, 진짜 bandit5안에 inhere 폴더가 있는지 ls명령어로 확인해 보겠습니다.
bandit5@bandit:~$ ls
inhere
이런식으로 inhere 폴더가 있습니다.
두번째로 cd명령어로 inhere 폴더로 들어가고, inhere 폴더안에 어떤 파일이 있는지 확인해 보겠습니다.
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 폴더안에는 19개의 폴더가 있습니다. 그중 maybehere00으로 한번들어가 보겠습니다.
bandit5@bandit:~/inhere$ cd maybehere00
bandit5@bandit:~/inhere/maybehere00$ ls
-file1 -file2 -file3 spaces file1 spaces file2 spaces file3
이런식으로, 이 bandit5의 구조를 설명하면 inhere 폴더안에는 19개의 폴더가 있고, 그안에 또 파일이 있습니다.
근데 저희 한테는 고맙게도 주어진 조건이 있죠? 사람이 읽을수 있는 파일을 찾는거랑 크기가 1033byte 인 파일을 찾는것,
그중 저는 크기가 1033byte 인 파일찾는 방법으로 찾겠습니다.
그 크기가 1033byte 인 파일을 찾으려면 find 명령어를 알아야 합니다.
find는 파일 시스템에서 파일과 폴더를 찾을 때 사용됩니다.
이 find 명령어를 쓰는 구조는 배웠던거랑은 조금 다른데...
find [경로] [옵션] [조건] 이런식으로 쓰입니다.
find 경로,옵션,조건 설명 :
본론으로 돌아가겠습니다.
그럼 find를 이용해서 옵션은 -size 이고, 크기는 1033byte 이니까 리눅스 사용법에 따라
find -size 1033c 이런식으로 하겠습니다. (이 c는 나중에 설명하겠습니다.)
bandit5@bandit:~/inhere$ find -size 1033c
./maybehere07/.file2
이런식으로 뜨네요 그럼 cat을 통해 읽겠습니다.
bandit5@bandit:~/inhere$ cat ./maybehere07/.file2
P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU
잘 되네요. 비번은 P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU 입니다.
쓴 코드 :
bandit5@bandit:~$ ls
inhere
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
bandit5@bandit:~/inhere$ cd maybehere00
bandit5@bandit:~/inhere/maybehere00$ ls
-file1 -file2 -file3 spaces file1 spaces file2 spaces file3
bandit5@bandit:~/inhere/maybehere00$ cd ../
bandit5@bandit:~/inhere$ find -size 1033c
./maybehere07/.file2
bandit5@bandit:~/inhere$ cat ./maybehere07/.file2
P4L4vucdmLnm8I7Vl7jG1ApGSfjYKqJU
find 명령어는 파일이나 폴더를 찾을때 쓰인다.
| [bandit] bandit6 -> bandit7 (0) | 2023.04.27 |
|---|---|
| [Bandit] bandit0 -> bandit1(ls,cat) (0) | 2023.04.24 |
| [bandit] bandit4 -> bandit5 (0) | 2023.04.22 |
| [bandit] bandit3 -> bandit4 (0) | 2023.04.22 |
| [bandit] bandit2 -> bandit3 (0) | 2023.04.21 |