> ## Documentation Index
> Fetch the complete documentation index at: https://docs.panguard.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 即時防護

> 設定 Guard 持續監控系統、了解 7 天學習期怎麼運作、設定自動威脅回應。

# 即時防護

Guard 24/7 跑在你的系統上，監控 process、網路連線、檔案和日誌。它用四個 AI agent 組成的管線即時偵測、分析、回應、報告安全威脅。

<Info>
  安裝前的安全檢查，請看 [Skill Auditor](/products/overview) -- 建議在跑任何 AI agent skill
  之前先審計。
</Info>

***

## 快速開始

<Steps>
  <Step title="啟動 Guard">
    ```bash theme={null}
    panguard guard start
    ```

    Guard 會進入**學習模式**，前 7 天觀察你系統的正常行為。
  </Step>

  <Step title="查看狀態">
    ```bash theme={null}
    panguard guard status
    ```

    ```
      -- Guard Status -----------------------

      Status:     Running
      Mode:       Learning (Day 3/7)
      PID:        12345
      Uptime:     3d 14h 22m
      Events:     12,847 observed
      Baseline:   42% complete
    ```
  </Step>

  <Step title="等待進入防護模式">
    7 天後 Guard 自動切換到**防護模式**，開始主動偵測和回應威脅。
  </Step>
</Steps>

***

## 學習模式（第 1-7 天）

學習期間 Guard 靜靜觀察並記錄：

* **Process** -- 哪些程式正常在跑、啟動時間、資源用量
* **網路** -- 正常連線模式、常用 port、流量特徵
* **檔案** -- 關鍵目錄的異動模式
* **使用者** -- 登入時間、來源 IP、操作模式

<Info>
  學習模式期間 Guard
  不會發警報。這是為了避免大多數安全工具都會遇到的誤報轟炸。你會收到每日學習進度摘要。
</Info>

***

## 防護模式（第 8 天起）

基線建好之後，Guard 啟動完整防護：

* 偏離基線的事件會觸發警報
* 三層 AI 漏斗分析可疑事件
* 根據信心度自動或手動回應
* 透過你設定的通知頻道即時通知

### 依信心度回應

| 信心度    | 動作        | 範例                    |
| ------ | --------- | --------------------- |
| > 90%  | 自動執行，事後通知 | 已知惡意 IP 自動封鎖          |
| 70-90% | 發通知請你確認   | 可疑 process -- 問你要不要砍掉 |
| \< 70% | 只通知       | 輕微異常 -- 告知你留意         |

***

## 四 Agent 管線

每個安全事件都經過四個專門的 agent：

```
  Event -> [Detect] -> [Analyze] -> [Respond] -> [Report]
```

| Agent            | 職責                                   |
| ---------------- | ------------------------------------ |
| **DetectAgent**  | ATR 規則匹配、威脅情報查詢、事件關聯                 |
| **AnalyzeAgent** | 蒐集證據、加權信心度評分、三層漏斗 AI 推理              |
| **RespondAgent** | 執行動作（封鎖 IP、砍 process、隔離檔案）、安全檢查、升級處理 |
| **ReportAgent**  | 事件紀錄、更新基線、匿名化資料送 Threat Cloud        |

***

## 回應動作

Guard 可以自動執行以下回應：

| 動作             | 說明                                   | 平台支援                                           |
| -------------- | ------------------------------------ | ---------------------------------------------- |
| **IP 封鎖**      | 封鎖惡意 IP                              | macOS (pfctl)、Linux (iptables)、Windows (netsh) |
| **檔案隔離**       | 隔離可疑檔案並記錄 SHA-256 hash               | 全平台                                            |
| **Process 終止** | 砍掉惡意 process（先 SIGTERM，5 秒後 SIGKILL） | 全平台                                            |

### 安全防護機制

Guard 內建安全規則，避免誤傷：

* **白名單 IP：** `127.0.0.1`、`::1`、`localhost`、`0.0.0.0`（加上你自訂的）
* **受保護 process：** `sshd`、`systemd`、`init`、`launchd`、`node`、`panguard-guard`
* **受保護帳號：** `root`、`Administrator`、`SYSTEM`
* **網路隔離**需信心度 >= 95%
* **不會砍自己的 process**

***

## 整合威脅情報

Guard 自動查詢 5 個威脅情報來源：

* **ThreatFox** -- IoC 資料庫（IP、domain、URL、檔案 hash）
* **URLhaus** -- 惡意軟體散布 URL
* **Feodo Tracker** -- C2 伺服器追蹤
* **GreyNoise** -- IP 信譽（針對性 vs. 大規模掃描）
* **AbuseIPDB** -- 社群回報的惡意 IP

每小時更新，搭配本地 cache 避免重複查詢。

***

## 規則引擎

### ATR 規則

Guard 內建 768 條 ATR 規則，你也可以加自訂規則：

```yaml theme={null}
# 自訂規則：偵測透過 Agent 的 SSH 暴力破解
id: ATR-CUSTOM-001
name: SSH Brute Force via Agent
severity: high
detection:
  patterns:
    - event_type: login_failed
      service: ssh
  context: system_event
action: alert
```

把 `.yml` 檔放進 Guard 的規則目錄就好。Guard 支援 hot reload，自動載入新規則。

***

## 管理 Guard

```bash theme={null}
# 啟動 Guard
panguard guard start

# 查看狀態
panguard guard status

# 停止 Guard
panguard guard stop

# 看目前 config
panguard guard config

# 裝成系統服務（開機自動跑）
panguard guard install
```

<Tip>
  正式環境建議把 Guard
  裝成系統服務，開機自動啟動、掛掉自動重啟。詳見[系統服務指南](/guides/system-service)。
</Tip>

***

## CLI 參考

```
panguard guard <command> [options]

Commands:
  start              啟動 Guard 引擎
  stop               停止 Guard 引擎
  status             顯示狀態
  install            安裝為系統服務
  uninstall          移除系統服務
  config             顯示目前 config

Options:
  --data-dir <path>  資料目錄（預設：~/.panguard-guard）
```

***

## 相關文件

<CardGroup cols={2}>
  <Card title="學習模式" icon="graduation-cap" href="/concepts/learning-mode">
    深入了解 7 天學習期和基線建立機制。
  </Card>

  <Card title="三層式 AI 漏斗" icon="brain-circuit" href="/concepts/three-layer-ai">
    規則、本地 AI、雲端 AI 怎麼協同運作。
  </Card>

  <Card title="系統服務" icon="gear" href="/guides/system-service">
    把 Guard 裝成 systemd/launchd 服務。
  </Card>

  <Card title="通知設定" icon="bell" href="/guides/notifications-setup">
    設定 Guard 怎麼通知你威脅事件。
  </Card>
</CardGroup>
