Level 0 -> Level 1
<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
Slove
ํ ๋๋ ํ ๋ฆฌ์ readme ํ์ผ์ password๊ฐ ์๋ค๊ณ ํ๋, cat ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํด์ readme ํ์ผ์ ๋ด์ฉ์ ์ฝ์ผ๋ฉด ๋๋ค.
-> ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If ์ด๊ฒ ํจ์ค์๋์ธ ๊ฒ ๊ฐ๋ค.
bandit0@bandit:~$ ls
readme
bandit0@bandit:~$ cat readme
Congratulations on your first steps into the bandit game!!
Please make sure you have read the rules at https://overthewire.org/rules/
If you are following a course, workshop, walkthrough or other educational activity,
please inform the instructor about the rules as well and encourage them to
contribute to the OverTheWire community so we can keep these games free!
The password you are looking for is: ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If
์ด์ username์ bandit1๋ก ๋ฐ๊พธ๊ณ SSH ์ ์์ ํ๋ค. password ๋ถ๋ถ์ ์์์ ์ป์ ๊ฐ์ ๋ฃ์ผ๋ฉด bandit1๋ก ๋ก๊ทธ์ธ๋๋ค. level 1 ํด๋ฆฌ์ด๋ค!
โโโ(kaliใฟkali)-[~/.ssh]
โโ$ ssh -p 2220 bandit1@bandit.labs.overthewire.org
_ _ _ _
| |__ __ _ _ __ __| (_) |_
| '_ \ / _` | '_ \ / _` | | __|
| |_) | (_| | | | | (_| | | |_
|_.__/ \__,_|_| |_|\__,_|_|\__|
This is an OverTheWire game server.
More information on http://www.overthewire.org/wargames
bandit1@bandit.labs.overthewire.org's password:
...
bandit1@bandit:~$
Level 1 -> Level 2
<Level Goal>
The password for the next level is stored in a file called - located in the home directory
Slove
ํ ๋๋ ํ ๋ฆฌ์ ์๋ -๋ผ๋ ์ด๋ฆ์ ํ์ผ์ password๊ฐ ์๋ค๊ณ ํ๋ค. ํ์ผ ์ด๋ฆ์ด ํน์ดํ๋ค. ๋ง์ฐฌ๊ฐ์ง๋ก cat ๋ช ๋ น์ด๋ฅผ ํตํด -ํ์ผ ๋ด์ฉ์ ์ฝ์ผ๋ฉด ๋ ๊ฒ ๊ฐ๋ค. ๊ทธ๋ฐ๋ฐ cat - ๋ฅผ ์ ๋ ฅํ๋ฉด ๋ฐฐ์ ์์ด ํ์ค ์ ๋ ฅ ๋๊ธฐ ์ํ๊ฐ ๋๋ค.
๊ทธ๋์ ls -l ๋ช ๋ น์ด๋ก - ํ์ผ ์ ๋ณด๋ฅผ ์ดํด๋ดค๋ค. ํน์ด์ ์ ์๋ ๊ฒ ๊ฐ๋ค. ์คํ ๊ถํ์ด x๊ฐ ์์ด๋, ์ฝ๊ธฐ ๊ถํ์ธ r์ด ์์ผ๋ cat ๋ช ๋ น์ด๋ ์๋ํด์ผ ํ๋๊ฒ ๋ง๋ค.
bandit1@bandit:~$ ls -l
total 4
-rw-r----- 1 bandit2 bandit1 33 Sep 19 07:08 -
ํ์ผ ์ ํ์ ํ์ธํ๋ file ๋ช ๋ น์ด๋ ๋จนํ์ง ์์์ ํํธ๋ฅผ ์ฐธ๊ณ ํ๋ค. dashed filename์ ๋ํด ์ดํด๋ณด๋ผ๊ณ ํ๋ค.
'-' ์ด๋ฌํ ์ ํ์ ์ ๊ทผ ๋ฐฉ์์ -๋ฅผ ์ธ์๋ก ์ฌ์ฉํ์ฌ stdin/stdout์ ์ฐธ์กฐํ๊ธฐ ๋๋ฌธ์ ํ๋ก๊ทธ๋จ์ ์คํด๋ฅผ ๋ถ๋ฌ์ฌ ์ ์๋ค๊ณ ํ๋ค. ๋ฐ๋ผ์ ์ผ๋ฐ์ ์ธ ๋ช ๋ น์ผ๋ก๋ -๋ก ๊ตฌ๋ถ๋ ํ์ผ ์ด๋ฆ์ ์ด ์ ์์ ์๋ ์๋ค.
๋จผ์ ./์ ๊ฐ์ด ํ์ฌ ๋๋ ํ ๋ฆฌ์ ์๋ ํ์ผ์์ ๋ช ์ํจ์ผ๋ก์จ cat ๋ช ๋ น์ด๋ฅผ ์๋์ํฌ ์ ์๋ค.
# ./์ ์ด์ฉํ ๋ฐฉ๋ฒ
bandit1@bandit:~$ cat ./-
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
๋ฆฌ๋๋ ์ ๊ธฐํธ๋ฅผ ์ฌ์ฉํด ํ์ผ์ ์ฝ์ ์๋ ์๋ค.
# <์ ์ด์ฉํ ๋ฐฉ๋ฒ
bandit1@bandit:~$ cat < -
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
๊ธด ํ์ผ ๋ด์ฉ์ ํ ํ์ด์ง์ฉ ๋ณด์ฌ์ฃผ๋ ๋ช ๋ น์ด more์ ์ฌ์ฉํด์ - ํ์ผ์ ๋ด์ฉ์ ์ฝ์ ์๋ ์๋ค.
# more ๋ช
๋ น์ด๋ฅผ ์ด์ฉํ ๋ฐฉ๋ฒ
bandit1@bandit:~$ more -
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
Question
์ cat ๋ช ๋ น์ด๋ก๋ - ํ์ผ์ ์ฝ์ ์ ์๊ณ , more ๋ช ๋ น์ด๋ก๋ ์ฝ์ ์ ์์๊น?
์ด๋ ๋ช ๋ น์ด์ ์ค๊ณ ๋ชฉ์ ์ ์๊ฒ๋๋ฉด ์ดํด๋๋ ๋ฌธ์ ์ด๋ค. ๋ฆฌ๋ ์ค์์ -๋ ์ผ๋ฐ์ ์ผ๋ก stdin์ด๋ stdout์ ๋ํ๋ธ๋ค.
cat ๋ช ๋ ์ด๋ ๋ฆฌ๋๋ ์ ๊ณผ ํ์ดํ์์ ์์ฃผ ์ฌ์ฉ๋๋ฏ๋ก, -๋ฅผ ํ์ค ์ ๋ ฅ์ผ๋ก ์ฒ๋ฆฌํ๋๋ก ์ค๊ณ๋์ด์๋ค. ๋ฐ๋ผ์ cat ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ๋ฉด -๋ฅผ ํ์ผ ์ด๋ฆ์ด ์๋ ํ์ค ์ ๋ ฅ์ผ๋ก ์ดํดํ๊ธฐ ๋๋ฌธ์ cat - ๋ ์ฌ์ฉ์๊ฐ ์ ๋ ฅํ ๋ด์ฉ์ ๊ธฐ๋ค๋ฆฌ๋ ํ์ค ์ ๋ ฅ ๋๊ธฐ ์ํ๊ฐ ๋๋ค.
๋ฐ๋ฉด more์ ์ฃผ๋ก ํ์ผ ๋ด์ฉ์ ํ์ด์ง ๋จ์๋ก ํ์ํ๊ธฐ ์ํด ์ฌ์ฉ๋๋ ๋ช ๋ น์ด์ด๋ค. ๋ฐ๋ผ์ -๋ฅผ ํ์ผ ์ด๋ฆ์ผ๋ก ์ดํดํ์ฌ -์ ๋ด์ฉ์ด ์ถ๋ ฅ๋๋ ๊ฒ์ด๋ค.
๊ทธ๋ ๋ค๋ฉด more๊ณผ ๋น์ทํ ๊ธฐ๋ฅ์ ๊ฐ์ง๋ less ๋ช ๋ น์ด๋ก๋ - ํ์ผ์ ์ฝ์ ์ ์์๊น?
๊ฒฐ๋ก ๋ถํฐ ๋งํ์๋ฉด ์๋๋ค. less๋ more๊ณผ ๋น์ทํ ๊ธฐ๋ฅ์ด๋ผ ๊ฐ๋ฅํ ๊ฒ ๊ฐ์ด ๋ณด์ด์ง๋ง less ๋ํ cat์ฒ๋ผ -๋ฅผ ํ์ค ์ ๋ ฅ์ผ๋ก ์ฒ๋ฆฌํ๋ค.
01. ์ ธ(Shell)
์ ธ์ด๋, ํค๋ณด๋์ ๋ช ๋ น์ ๋ฐ์ ์ด์์ฒด์ ์ ์ ๋ฌํ์ฌ ์คํํ๋ ํ๋ก๊ทธ๋จ์ด๋ค. ๋๋ถ๋ถ์ linux ๋ฐฐํฌํ์ bash ์ ธ ํ๋ก๊ทธ๋จ์ ์ ๊ณตํ๋ค.
02. ํฐ๋ฏธ๋ ์๋ฎฌ๋ ์ดํฐ(Terminal Emulators)
GUI๋ฅผ ์ฌ์ฉํ ๊ฒฝ์ฐ, ์ ธ๊ณผ ์ํธ์์ฉ ํ๊ธฐ ์ํด์๋ ํฐ๋ฏธ๋ ์๋ฎฌ๋ ์ดํฐ๋ผ๋ ํ๋ก๊ทธ๋จ์ด ํ์ํ๋ค.
03. ์ ธ ํ๋กฌํํธ(Shell prompt)
์ ธ ํ๋กฌํํธ๋ ์ ธ์ด ์ ๋ ฅ์ ์๋ฝํ ์ค๋น๊ฐ ๋๋ฉด ๋ํ๋๋ค. ๋ฐฐํฌํ์ ๋ฐ๋ผ ๋ชจ์์ด ๋ค์ ๋ค๋ฅผ ์ ์์ง๋ง ์ผ๋ฐ์ ์ผ๋ก [username]@[machinename] [ํ์ฌ ์์ ๋๋ ํ ๋ฆฌ] $ ํํ๋ก ๋์ด์๋ค.
ํ๋กฌํํธ์ ๋ง์ง๋ง ๋ฌธ์๊ฐ $๊ฐ ์๋ #์ธ ๊ฒฝ์ฐ๋ root ์ฌ์ฉ์๋ก ๋ก๊ทธ์ธ ํ๊ฑฐ๋ ์ํผ์ ์ (๊ด๋ฆฌ์) ๊ถํ์ ์ ๊ณตํ๋ ํฐ๋ฏธ๋ ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์ ํํ์์ ์๋ฏธํ๋ค.
0.4. I/O ๋ฆฌ๋๋ ์ (redirection), ํ์ผ ๋์คํฌ๋ฆฝํฐ
๋ฆฌ๋๋ ์ ์ด๋, linux/unix์์ ๋ช ๋ น์ด์ ์ ๋ ฅ๊ณ ์ถ๋ ฅ์ ๊ธฐ๋ณธ๊ฐ(ํฐ๋ฏธ๋) ๋์ , ํ์ผ์ด๋ ๋ค๋ฅธ ๋ช ๋ น์ด๋ก ๋ณ๊ฒฝํ๋ ๊ธฐ๋ฅ์ ์๋ฏธํ๋ค. ์ด๋ ๋ช ๋ น์ด ์คํ ์ ๋ฐ์ดํฐ๋ฅผ ์ฝ๊ฑฐ๋ ์ฐ๋ ๋ฐฉ์์ ์ ์ฐ๊ฒ ์กฐ์ ํ ์ ์๊ฒ ํด์ค๋ค.
I/O๋ input/output์ ์๋ฏธํ๋ฉฐ, ์ด ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ฉด ๋ช ๋ น์ ์ ์ถ๋ ฅ์ ํ์ผ๋ก ๋ฆฌ๋ค์ด๋ ์ ํ ์ ์๊ณ , ์ฌ๋ฌ ๋ช ๋ น์ pipeline์ผ๋ก ์ฐ๊ฒฐํ ์๋ ์๋ค.
๋ฆฌ๋ ์ค์์ ๋ชจ๋ ํ๋ก์ธ์ค๋ stdin, stdout, stderr ์ด ์ธ ๊ฐ์ง์ ๋ฐ์ดํฐ ์คํธ๋ฆผ์ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ, ๊ฐ๊ฐ 0, 1, 2๋ก ํํ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์ด๋ฅผ ํ์ผ ๋์คํฌ๋ฆฝํฐ(descripter) ๋ผ๊ณ ๋ถ๋ฅธ๋ค.
ํ์ผ ๋์คํฌ๋ฆฝํฐ ๋ฒํธ | ์ด๋ฆ | |
0 | stdin(ํ์ค ์ ๋ ฅ) | ํค๋ณด๋ ์ ๋ ฅ ๋๋ ๋ฆฌ๋ค์ด๋ ์ ๋ ์ ๋ ฅ(<) |
1 | stdout(ํ์ค ์ถ๋ ฅ) | ํ๋ก๊ทธ๋จ์ ์ผ๋ฐ(์ ์) ์ถ๋ ฅ |
2 | stderr(ํ์ค ์ค๋ฅ) | ์๋ฌ ๋ฉ์์ง ์ถ๋ ฅ |
05. Linux Redirection
ํ์ผ ๋์คํฌ๋ฆฝํฐ(0,1,2)์ redirection ๊ธฐํธ(>, >>, <, <<)๋ฅผ ์ฌ์ฉํ์ฌ ์ ์ถ๋ ฅ ๋์์ ์์ ๋กญ๊ฒ ๋ณ๊ฒฝํ์ฌ ์ฌ์ฉํ ์ ์๋ค.
> | ๊ฒฐ๊ณผ๋ฅผ ํ์ผ๋ก ์ ์ฅ(๋ฎ์ด์ฐ๊ธฐ) |
>> | ๊ฒฐ๊ณผ๋ฅผ ํ์ผ๋ก ์ ์ฅ(๋ฎ์ด์ฐ์ง ์๊ณ ๊ธฐ์กด ํ์ผ์ ์ถ๊ฐ) |
< | ์ ๋ ฅ์ ๋ช ๋ น์ด์ ์คํ(๋ฎ์ด์ฐ๊ธฐ) |
<< | ์ ๋ ฅ์ ๋ช ๋ น์ด์ ์คํ(๋ฎ์ด์ฐ์ง ์๊ณ ๊ธฐ์กด ํ์ผ์ ์ถ๊ฐ) |
06. /์ ./
/๋ ๋ฃจํธ ๋๋ ํ ๋ฆฌ๋ฅผ ์๋ฏธํ๋ค. /a.sh๋ ๋ฃจํธ ๋๋ ํ ๋ฆฌ์ ์๋ a.sh ํ์ผ์ ์คํํ๋ผ๋ ์๋ฏธ๊ฐ ๋๋ค.
./๋ ํ์ฌ ๋๋ ํ ๋ฆฌ๋ฅผ ๋ํ๋ธ๋ค. ./a.sh๋ ํ์ฌ ๋๋ ํ ๋ฆฌ์ ์๋ a.sh ํ์ผ์ ์คํํ๋ผ๋ ์๋ฏธ๊ฐ ๋๋ค.
07. ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ(/home, ~)
โโโ(kaliใฟkali)-[~]
โโ$ cd /
โโโ(kaliใฟkali)-[/]
โโ$ ls
bin home lib32 mnt run swing usr
boot initrd.img lib64 opt sbin swing32 var
dev initrd.img.old lost+found proc srv sys vmlinuz
etc lib media root swapfile tmp vmlinuz.old
โโโ(kaliใฟkali)-[/]
โโ$ cd home
~์์ cd/๋ฅผ ํตํด root ๋๋ ํ ๋ฆฌ๋ก ์ด๋ํ๋ ๊ฒ์ ๋ณด๊ณ ์๋ฌธ์ ์ด ์๊ธฐ๊ธฐ ์์ํ๋ค.
Q1) ~(ํ ๋๋ ํ ๋ฆฌ)๊ฐ root ๋๋ ํ ๋ฆฌ๋ณด๋ค ์์ ๋๋ ํ ๋ฆฌ์ธ๊ฐ?
-> ์๋๋ค. root๊ฐ ์ต์์ ๋๋ ํ ๋ฆฌ์ด๋ค.
Q2) ~๋ ํ ๋๋ ํ ๋ฆฌ์ธ๋ฐ, ๊ทธ๋ผ / ์๋์ ์๋ home ๋๋ ํ ๋ฆฌ๋ ๋ญ์ง?
-> ~ ๋๋ ํ ๋ฆฌ๋ /์ ํ์ ๋๋ ํ ๋ฆฌ ์ค ํ๋์ธ /home/[์ฌ์ฉ์] ๋๋ ํ ๋ฆฌ์ด๋ค.
์ ๋ฆฌํ์๋ฉด /home์ ๋ชจ๋ ์ฌ์ฉ์์ ํ ๋๋ ํ ๋ฆฌ๋ฅผ ํฌํจํ๋ ๋๋ ํ ๋ฆฌ, ~(/home/[์ฌ์ฉ์ ๋ช ])์ ํน์ ์ฌ์ฉ์์ ํ ๋๋ ํ ๋ฆฌ์ด๋ค.
์ฌ์ฉ์ ๋ช | ~ ๋๋ ํ ๋ฆฌ |
user1 | /home/user1 |
root | /root |
'๐ฆ Private > bandit' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Level 4 -> Level 6 (1) | 2024.12.27 |
---|---|
Level 2 -> Level 4 (1) | 2024.12.27 |
Level 0-SSH (0) | 2024.12.25 |