前言
OverTheWire 是一個專門提供資安挑戰遊戲(Wargames)的平台,而 Bandit 是該平台上最基礎、最適合新手入門的系列。這個遊戲的目標是透過一關一關的挑戰,讓玩家在實戰中學習 Linux 基礎指令與操作技巧。
為什麼選擇 Bandit?
- 零門檻入門:不需要任何資安背景,只要會用終端機就能開始
- 循序漸進:從最簡單的
ls、cat開始,逐步學習進階指令 - 實戰導向:每一關都是真實的 Linux 環境,學到的技能可以直接應用
- 免費開放:完全免費,隨時可以練習
遊戲規則
- 每一關的目標是找到下一關的密碼
- 使用 SSH 連線到遊戲伺服器
- 密碼通常藏在某個檔案中,需要用各種 Linux 指令找出來
- 找到密碼後,用該密碼登入下一關繼續挑戰
適合對象
- 想學習 Linux 指令的初學者
- 對資安/CTF 有興趣但不知從何開始的人
- 想複習 Linux 基礎操作的工程師
🎯 遊戲網址: http://www.overthewire.org/wargames/bandit/
📌 SSH 連線格式:
ssh [email protected] -p 2220
Level 0 – SSH 登入

題目說明
使用 SSH 登入遊戲伺服器。
連線資訊
| 項目 | 內容 |
|---|---|
| Host | bandit.labs.overthewire.org |
| Port | 2220 |
| Username | bandit0 |
| Password | bandit0 |
指令
ssh [email protected] -p 2220
指令介紹
| 指令 | 說明 |
|---|---|
ssh |
Secure Shell,用於遠端安全連線 |
-p |
指定連接埠(預設是 22,這裡用 2220) |
Level 0 → Level 1
題目說明
密碼存在 home 目錄的 readme 檔案中。
解題過程
bandit0@bandit:~ls
readme
bandit0@bandit:~ cat readme

密碼
ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If
指令介紹
| 指令 | 說明 |
|---|---|
ls |
列出目錄內容 |
cat |
顯示檔案內容 |
Level 1 → Level 2

題目說明
密碼存在檔名為 - 的檔案中。
挑戰點
檔名是 -(破折號),而 - 在 Linux 指令中通常代表「從標準輸入讀取」,所以直接 cat - 不會讀取檔案。
解題過程
bandit1@bandit:~ls
-
bandit1@bandit:~ cat ./-

密碼
263JGJPfgU6LtdEvgfWU1XP5yac29mFx
解法說明
| 方法 | 指令 |
|---|---|
| 使用相對路徑 | cat ./- |
| 使用絕對路徑 | cat /home/bandit1/- |
使用 -- 結束選項 |
cat -- - |
指令介紹
| 語法 | 說明 |
|---|---|
./ |
當前目錄的相對路徑 |
-- |
告訴指令「選項結束,後面都是檔案名」 |
Level 2 → Level 3
題目說明
密碼存在檔名含有空格的檔案中。
挑戰點
檔名為 spaces in this filename,包含空格。
解題過程
bandit2@bandit:~ls -al
-rw-r----- 1 bandit3 bandit2 33 Oct 14 09:26 spaces in this filename
bandit2@bandit:~ cat "./spaces in this filename"

密碼
MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx
解法說明
| 方法 | 指令 |
|---|---|
| 使用引號包住 | cat "spaces in this filename" |
| 使用反斜線跳脫 | cat spaces\ in\ this\ filename |
| 使用 Tab 自動補全 | 輸入 cat sp 後按 Tab |
指令介紹
| 語法 | 說明 |
|---|---|
"..." |
雙引號,將內容視為一個字串 |
\ |
反斜線,跳脫特殊字元(如空格) |
Level 3 → Level 4
題目說明
密碼存在 inhere 目錄中的隱藏檔案。
挑戰點
檔案是隱藏檔(檔名以 . 開頭)。
解題過程
bandit3@bandit:~cd inhere/
bandit3@bandit:~/inhere ls -al
-rw-r----- 1 bandit4 bandit3 33 Oct 14 09:26 ...Hiding-From-You
bandit3@bandit:~/inhere$ cat ...Hiding-From-You

密碼
2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ
指令介紹
| 指令 | 說明 |
|---|---|
cd |
切換目錄 |
ls -al |
列出所有檔案(包含隱藏檔)並顯示詳細資訊 |
-a |
顯示隱藏檔案(以 . 開頭的檔案) |
-l |
顯示詳細資訊(權限、擁有者、大小等) |
Level 4 → Level 5
題目說明
密碼存在 inhere 目錄中唯一「human-readable」的檔案。
挑戰點
有 10 個檔案(-file00 ~ -file09),只有一個是可讀文字檔。
解題過程
bandit4@bandit:~cd inhere/
bandit4@bandit:~/inhere ls -al
-rw-r----- 1 bandit5 bandit4 33 Oct 14 09:26 -file00
-rw-r----- 1 bandit5 bandit4 33 Oct 14 09:26 -file01
...
bandit4@bandit:~/inherefile ./-*
./-file00: data
./-file01: data
./-file02: data
./-file03: data
./-file04: data
./-file05: data
./-file06: data
./-file07: ASCII text
./-file08: data
./-file09: data
bandit4@bandit:~/inhere cat ./-file07

密碼
4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw
指令介紹
| 指令 | 說明 |
|---|---|
file |
檢測檔案類型 |
* |
萬用字元,匹配所有檔案 |
./-* |
當前目錄下所有以 - 開頭的檔案 |
ASCII text |
可讀的純文字檔案 |
data |
二進位資料(不可讀) |
Level 5 → Level 6
題目說明
密碼存在 inhere 目錄某處,檔案符合以下條件:
– human-readable(可讀文字)
– 1033 bytes 大小
– not executable(不可執行)
挑戰點
有 20 個子目錄(maybehere00 ~ maybehere19),需要用 find 搜尋。
解題過程
bandit5@bandit:~cd inhere/
bandit5@bandit:~/inhere find . -type f -size 1033c ! -executable
./maybehere07/.file2
bandit5@bandit:~/inhere$ cat ./maybehere07/.file2

密碼
HWasnPhtq9AVKe0dmk45nxy20cvUa6EG
指令介紹
| 指令/選項 | 說明 |
|---|---|
find |
搜尋檔案 |
. |
從當前目錄開始搜尋 |
-type f |
只搜尋檔案(不包含目錄) |
-size 1033c |
檔案大小為 1033 bytes(c = bytes) |
! -executable |
不可執行(! 表示「非」) |
find 大小單位
| 單位 | 說明 |
|---|---|
c |
bytes |
k |
kilobytes |
M |
megabytes |
G |
gigabytes |
Level 6 → Level 7
題目說明
密碼存在伺服器某處,檔案符合以下條件:
– owned by user bandit7
– owned by group bandit6
– 33 bytes in size
挑戰點
需要搜尋整個伺服器,並過濾掉「Permission denied」錯誤訊息。
解題過程
bandit6@bandit:~find / -type f -user bandit7 -group bandit6 -size 33c 2>/dev/null
/var/lib/dpkg/info/bandit7.password
bandit6@bandit:~ cat /var/lib/dpkg/info/bandit7.password

密碼
morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj
指令介紹
| 指令/選項 | 說明 |
|---|---|
find / |
從根目錄開始搜尋整個系統 |
-user bandit7 |
擁有者是 bandit7 |
-group bandit6 |
群組是 bandit6 |
-size 33c |
檔案大小為 33 bytes |
2>/dev/null |
將錯誤訊息(stderr)丟棄 |
重導向說明
| 語法 | 說明 |
|---|---|
> |
將標準輸出(stdout)重導向 |
2> |
將錯誤輸出(stderr)重導向 |
/dev/null |
Linux 的「黑洞」,丟棄所有輸入 |
2>/dev/null |
丟棄所有錯誤訊息 |
密碼總整理
| Level | 密碼 |
|---|---|
| bandit0 | bandit0 |
| bandit1 | ZjLjTmM6FvvyRnrb2rfNWOZOTa6ip5If |
| bandit2 | 263JGJPfgU6LtdEvgfWU1XP5yac29mFx |
| bandit3 | MNk8KNH3Usiio41PRUEoDFPqfxLPlSmx |
| bandit4 | 2WmrDFRmJIq3IPxneAaMGhap0pFhF3NJ |
| bandit5 | 4oQYVPkxZOOEOO5pTW81FB8j8lxXGUQw |
| bandit6 | HWasnPhtq9AVKe0dmk45nxy20cvUa6EG |
| bandit7 | morbNTDkSW6jIlUc0ymOdMaLnOlFVAaj |
常用指令速查表
| 指令 | 用途 | 範例 |
|---|---|---|
ssh |
遠端連線 | ssh user@host -p port |
ls |
列出檔案 | ls -al |
cat |
顯示檔案內容 | cat filename |
cd |
切換目錄 | cd /path/to/dir |
file |
檢測檔案類型 | file filename |
find |
搜尋檔案 | find . -name "*.txt" |
學習重點總結
- 特殊檔名處理: 使用
./或引號處理-開頭或含空格的檔名 - 隱藏檔案: 使用
ls -a查看以.開頭的隱藏檔 - 檔案類型判斷: 使用
file指令判斷檔案是否為可讀文字 - 進階搜尋: 使用
find配合多種條件搜尋檔案 - 錯誤處理: 使用
2>/dev/null過濾錯誤訊息
