Level 4 -> Level 5
<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 "reset" command
Approach
inhere ๋๋ ํ ๋ฆฌ์ ์ฌ๋๋ง ์ฝ์ ์ ํ์ผ์ password๊ฐ ์๋ค๊ณ ํ๋ค.
์์๋๋ก ํ์ผ ์ด๋ฆ๋ค์ด ์ ์์ ์ด์ง๋ ์๋ค. -๋ก ์์ํ๋ ๋ฆฌ๋๋ ์ ์ผ๋ก ํด์๋ ํ๋ฅ ์ด ์ปค๋ณด์ธ๋ค.
bandit4@bandit:~/inhere$ ls
-file00 -file01 -file02 -file03 -file04 -file05 -file06 -file07 -file08 -file09
๊ทธ๋์ ํ์ผ๋ช ์ผ๋ก ํด์ํ๋ more ๋ช ๋ น์ด๋ฅผ ์จ๋ดค๋ค. ํ์ง๋ง error ๋ฉ์์ง๊ฐ ๋ฌ๊ณ , ๋ด์ฉ์ ๋ณด๋ ๋ฆฌ๋๋ ์ ์ด๋ ์ต์ ์ผ๋ก ํด์๋ ๊ฒ์ด ๋ฌธ์ ์ธ ๋ฏ ํ๋ค.
bandit4@bandit:~/inhere$ more -file00
more: invalid option -- 'i'
Try 'more --help' for more information.
๊ทธ๋์ ๋ฆฌ๋๋ ์ ๊ธฐํธ <๋ฅผ ์ฌ์ฉํด์ ํ์ผ ๋ด์ฉ์ ํ์ค ์ ๋ ฅ์ผ๋ก ์ ๋ฌํด๋ดค๋ค. -file00์ด ๋ช ๋ น์ด ์ต์ ์ด ์๋๋ผ ํ์ผ ์ด๋ฆ์ด๋ผ๋ ๊ฒ์ ์กฐ๊ธ ๋ ๋ช ํํ ํ๊ธฐ ์ํด์์ด๋ค. ๊ทธ๋ฌ๋๋ ๋ญ๊ฐ ์ด์ํ ๋ฌธ์์ด์ด ์ถ๋ ฅ๋์๋ค.
bandit4@bandit:~/inhere$ more < -file00
๏ฟฝp๏ฟฝ๏ฟฝ&๏ฟฝy๏ฟฝ,๏ฟฝ(jo๏ฟฝ.at๏ฟฝ:uf๏ฟฝ^๏ฟฝ๏ฟฝ๏ฟฝ@
๊ทธ๋์ ๋ชจ๋ ํ์ผ์ ๋ด์ฉ์ ์ฝ์ด๋ณด๊ธฐ๋ก ํ๋ค. ์์ผ๋์นด๋๋ฅผ ์ฌ์ฉํด ๋ชจ๋ ํ์ผ์ ์ฝ์ผ๋ ค ํ์ผ๋ ๋ช ํํ์ง ์์ ๋ฆฌ๋๋ ์ ์ด๋ผ๋ ์๋ฌ๊ฐ ๋ฌ๋ค.
bandit4@bandit:~/inhere$ more < -file*
-bash: -file*: ambiguous redirect
๊ทธ๋์ ๊ทธ๋ฅ ํ์ผ ํ๋ํ๋ ๋ชจ๋ ์ฝ์ด๋ณด๊ธฐ๋ก ํ๋ค. ๊ทธ ์ ์ ์ถ๋ ฅ๋ ์ด์ํ ๋ฌธ์์ด์ ์์คํค์ฝ๋ ๋ณํ, 16์ง์ ๋ณํํด์ ์๋ฏธ์๋ ๋ฌธ์์ด์ ์ฐพ์๋ด๊ณ ์ ํ๋ค(file*์ ๋ชจ๋ ๋ฌธ์ฅ์ ํฉ์ณ์ผ ๋ต์ด ๋์ฌ ๊ฒ์ด๋ผ๊ณ ์๊ฐํด์). ํ์ง๋ง ์ ์๋ฏธํ ๊ฒฐ๊ณผ๊ฐ์ด ๋์ค์ง ์์, Level Goal์ ์๋ human readable file์ ๋ํด ๊ฒ์ํด๋ดค๋ค. ๊ทธ๋ฆฌ๊ณ find ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํด ์ฝ์ ์ ์๋ ํ์ผ์ ์ฐพ์๋ณด๋ผ๋ ํํธ๋ฅผ ์ป์๋ค.
Solve
file ๋ช ๋ น์ด๋, ์ง์ ๋ ํ์ผ์ ์ข ๋ฅ(ํ์ )์ ํ์ธํ๋ ๋ช ๋ น์ด์ด๋ค. ํ์ฌ ํ์ผ ์ด๋ฆ์ด -๋ก ์์ํ๊ธฐ ๋๋ฌธ์ ์๋ชป ํด์๋ ์ฌ์ง๊ฐ ์๋ค. ๊ทธ๋์ ./๋ก ํ์ฌ ๋๋ ํ ๋ฆฌ์ ํ์ผ์ด๋ผ๋ ๊ฒ์ ๋ช ์ํ๊ณ ์์ผ๋ ์นด๋๋ฅผ ์ฌ์ฉํด inhere ๋๋ ํ ๋ฆฌ์ ๋ชจ๋ ํ์ผ๋ค์ ์ข ๋ฅ๋ฅผ ํ์ธํ๋ค.
bandit4@bandit:~/inhere$ file ./*
./-file00: data
./-file01: data
./-file02: data
./-file03: data
./-file04: data
./-file05: data
./-file06: data
./-file07: ASCII text
./-file08: data
./-file09: data
-file07์ด ์์คํค ํ ์คํธ๋ก ์ ํ์๋ค๋ ๊ฒ์ ์๊ฒ ๋์๊ณ , ํด๋น ํ์ผ์ ์ด์ด๋ณด๋ password๊ฐ ์์๋ค. level 4๋ ํด๋ฆฌ์ด๋ค!
-> ์ธ๊ฐ์ด ์ฝ์ ์ ์๋ ํ์ผ์ ASCII text๋ก ์ ํ ํ์ผ์ธ๊ฐ๋ณด๋ค.
bandit4@bandit:~/inhere$ more < -file07
4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw
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
Approach
๋ณต์กํด๋ณด์ด์ง๋ง ์๊ฐ๋ณด๋ค ๊ฐ๋จํ๋ค. inhere ๋๋ ํ ๋ฆฌ ์๋์ ์ ๋ง ๋ง์ ํ์ ๋๋ ํ ๋ฆฌ๊ฐ ์กด์ฌํ๋๋ฐ, ์ด ํ์ ๋๋ ํ ๋ฆฌ ์์ ๋ ํ์ผ๋ค์ด ๋ค์ด์๋ค. inhere ๋๋ ๋๋ฆฌ ํ์์ ์กด์ฌํ๋ ๋ชจ๋ ํ์ผ๋ค ์ค human-readable(ASCII text) + 1033 bytes + ์คํ ๊ฐ๋ฅํ์ง ์์? ์ด ์กฐ๊ฑด์ ๋ง์กฑํ๋ ๊ณณ์ password๊ฐ ์กด์ฌํ๋ค๊ณ ํ๋ค.
์๋์ ๊ฐ์ ๊ตฌ์กฐ๋ก ๋์ด์์ผ๋ฉฐ, maybehere[0*] ๋๋ ํ ๋ฆฌ๋ฅผ ๋ชจ๋ ๊ฒ์ํด๋ณด๋ฉด ๋ต์ด ๋์ฌ ๊ฒ ๊ฐ๊ธด ํ๋ค.
bandit5@bandit:~/inhere$ ls
maybehere00 maybehere03 maybehere06 maybehere09 maybehere12 maybehere15 maybehere18
maybehere01 maybehere04 maybehere07 maybehere10 maybehere13 maybehere16 maybehere19
maybehere02 maybehere05 maybehere08 maybehere11 maybehere14 maybehere17
bandit5@bandit:~/inhere$ cd maybehere00
bandit5@bandit:~/inhere/maybehere00$ ls
-file1 -file2 -file3 spaces file1 spaces file2 spaces file3
bandit5@bandit:~/inhere/maybehere00$ file ./*
./-file1: ASCII text, with very long lines (1038)
./-file2: ASCII text, with very long lines (9387)
./-file3: OpenPGP Secret Key
./spaces file1: ASCII text, with very long lines (6117)
./spaces file2: ASCII text, with very long lines (6849)
./spaces file3: data
ํ์ง๋ง ls ๋ช ๋ น์ด ์ต์ -R(์์นํ ๋๋ ํ ๋ฆฌ ํ๋ถ ๋๋ ํ ๋ฆฌ์ ํ์ผ๊น์ง ๋ชจ๋ ์ถ๋ ฅ)์ด ๋ ์ฌ๋๊ณ , file ๋ช ๋ น์ด ๋๋ find ๋ช ๋ น์ด์๋ ์ด๋ฐ ์ต์ ์ด ์์ ๊ฒ ๊ฐ๋ค๋ ์๊ฐ์ด ๋ค์๋ค. ์ด๋ฐ ์ต์ ์ด ์กด์ฌํ๋ค๋ฉด inhere ํ์์ ๋ชจ๋ ๋๋ ํ ๋ฆฌ์ ํ์ผ์ด ์ถ๋ ฅ๋๋ฏ๋ก ํ๋ํ๋ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ์ง ์์๋ ๋๋ค.
->ํ์ผ ํ์ ๊ณผ ํ์ผ ์ฌ์ด์ฆ๊ฐ ์ฃผ์ด์ก์ผ๋ ์ด๊ฒ์ ์ด์ฉํด์ ํํฐ๋ง ํ๋ฉด ๋์ง ์์๊น?
Solve
์ผ๋จ find ๋ช ๋ น์ด๋ฅผ ์ด์ฉํด size๊ฐ 1033 bytes์ธ ํ์ผ์ ์ฐพ๋๊ฒ์ ์ฑ๊ณตํ๋ค. find ๊ฒฝ๋ก๋ฅผ inhere ๋๋ ํ ๋ฆฌ ํ์์ maybehere* ํ์์ ํ์ผ๊ณผ ๋๋ ํ ๋ฆฌ๋ก ์ค์ ํ๋ค. ๊ทธ๋ฆฌ๊ณ 1033 ๋ค์ c๋ byte ๋จ์์ธ ๊ฒ์ ๋ช ์ํด์ฃผ๋ ๊ฒ์ด๋ค.
๊ทธ๋ฐ๋ฐ .file2? ์จ๊ฒจ์ง ํ์ผ์ด๋ค.
bandit5@bandit:~/inhere$ find ./maybehere* -size 1033c
./maybehere07/.file2
๊ทธ๋์ maybehere07 ๋๋ ํ ๋ฆฌ์ ๋ชจ๋ ํ์ผ, ๋๋ ํ ๋ฆฌ๋ฅผ ์ถ๋ ฅํด๋ดค๋ค. ์ ์จ๊ฒจ์ง ํ์ผ์ด ์๋ค.
andit5@bandit:~/inhere/maybehere07$ ls -a
. -file1 -file2 -file3 spaces file1 spaces file3
.. .file1 .file2 .file3 spaces file2
file ๋ช ๋ น์ด์์๋ ์จ๊ฒจ์ง ํ์ผ์ ๋ํ ์ ๋ณด๋ ์ถ๋ ฅ๋์ง ์๋๋ค. ์ง์ง ํ๋ํ๋ ์ฐพ์๋ค๋ฉด ๋ต์ ๋ชป ์ฐพ์์ ๊ฒ ๊ฐ๋ค.
bandit5@bandit:~/inhere/maybehere07$ file ./*
./-file1: ASCII text, with very long lines (3662)
./-file2: ASCII text, with very long lines (2487)
./-file3: data
./spaces file1: ASCII text, with very long lines (4129)
./spaces file2: ASCII text, with very long lines (9063)
./spaces file3: data
์จ๊ฒจ์ง ํ์ผ์ธ .file2๋ฅผ cat ๋ช ๋ น์ด๋ก ์ฝ์ด๋ณด๋ฉด password๊ฐ ๋์จ๋ค. level 5 ํด๋ฆฌ์ด๋ค!
bandit5@bandit:~/inhere/maybehere07$ cat .file2
HWasnPhtq9AVKe0dmk45nxy20cvUa6EG
More
01. not execytable?
password๊ฐ ๋ค์ด์๋ ํ์ผ์ ์กฐ๊ฑด ์ค 'not executable' ์ด๋ฐ๊ฒ ์์๋ค. ์ด๊ฑด ๋ฌด์จ ์๋ฏธ์ธ์ง ์์๋ดค๋ค.
ls -l ๋ช ๋ น์ด๋ ์จ๊ฒจ์ง ํ์ผ์ ๋ํ ์ ๋ณด๋ ์ถ๋ ฅํ์ง ์์ผ๋ ls -al ๋ช ๋ น์ด๋ฅผ ํตํด ํ์ผ๋ค์ ์ดํด๋ณด์๋ค. .file2๋ฅผ ์ดํด๋ณด๋ฉด ์ฝ๊ธฐ ๊ถํ r๊ณผ ์ฐ๊ธฐ ๊ถํ w๋ง ์๋ ์ํ์ด๋ค. 'not executable'์ x ๊ถํ์ด ์๋ ๊ฒ์ ์๋ฏธํ์ง ์์๋...? ์ถ๋ค.
bandit5@bandit:~/inhere/maybehere07$ ls -al
total 56
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 3663 Sep 19 07:08 -file1
-rwxr-x--- 1 root bandit5 3065 Sep 19 07:08 .file1
-rw-r----- 1 root bandit5 2488 Sep 19 07:08 -file2
-rw-r----- 1 root bandit5 1033 Sep 19 07:08 .file2
-rwxr-x--- 1 root bandit5 3362 Sep 19 07:08 -file3
-rwxr-x--- 1 root bandit5 1997 Sep 19 07:08 .file3
-rwxr-x--- 1 root bandit5 4130 Sep 19 07:08 spaces file1
-rw-r----- 1 root bandit5 9064 Sep 19 07:08 spaces file2
-rwxr-x--- 1 root bandit5 1022 Sep 19 07:08 spaces file3
02. find์ ์ง์ ๋ ๊ฒฝ๋ก ๋ฒ์
(find ๋ช ๋ น์ด ์ ๋ฆฌ๋ ์ฌ์ดํธ: https://coding-factory.tistory.com/804)
<find ๋ช ๋ น์ด์ ๋์ ์๋ฆฌ>
1) ./maybehere*๋ก ์ง์ ๋ ๊ฒฝ๋ก๊ฐ ๋๋ ํ ๋ฆฌ์ด๋ฉด, ๊ทธ ๋๋ ํ ๋ฆฌ์ ๋ชจ๋ ํ์ ํ์ผ๊ณผ ํ์ ๋๋ ํ ๋ฆฌ๊น์ง ํฌํจํ์ฌ ํ์ํ๋ค.
2) ./maybehere*๋ก ์ง์ ๋ ๊ฒฝ๋ก๊ฐ ํ์ผ์ด๋ฉด, ํด๋น ํ์ผ๋ง ํ์ธํ๋ค.
์์ ๊ฐ์ ์ด์ ๋ก ./maybehere*๊ณผ ./์ ์ถ๋ ฅ ๊ฒฐ๊ณผ๊ฐ ๋์ผํ๋ค. ์ง์ ๋ ๊ฒฝ๋ก์ ๋ชจ๋ ํ์ ๋๋ ํ ๋ฆฌ์ ํ์ ํ์ผ์ ํฌํจํ์ฌ ๊ฒ์ํ๊ธฐ ๋๋ฌธ์ด๋ค.
andit5@bandit:~/inhere$ find ./maybehere* -size 1033c
./maybehere07/.file2
bandit5@bandit:~/inhere$ find ./ -size 1033c
./maybehere07/.file2
'๐ฆ Private > bandit' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Level 2 -> Level 4 (1) | 2024.12.27 |
---|---|
Level 0 -> Level 2 (0) | 2024.12.26 |
Level 0-SSH (2) | 2024.12.25 |