# 自主滲透測試

> 什麼是自主滲透測試、PentAGI 如何從目標執行測試至產生 report，以及人員如何保持控制。

在自主滲透測試中，AI 系統會自行規劃並執行測試步驟。它會根據迄今為止的發現來決定下一步要檢視的內容、執行工具、檢查結果，並撰寫所學到的內容。掃描器每次都會執行相同的檢查；而自主 [agent](https://pentagi.com/zh-tw/docs/glossary/#agent) 則會在測試進行過程中調整其計畫。

## [PentAGI 如何執行測試](https://pentagi.com/zh-tw/docs/concepts/autonomous-pentesting/#how-pentagi-runs-a-test)

您以自然語言描述目標與目的：要評估什麼、範圍包含什麼，以及什麼才算完成。從此處開始，[flow](https://pentagi.com/zh-tw/docs/getting-started/first-flow/) 會自動執行：

1. 您的訊息會成為一個 [task](https://pentagi.com/zh-tw/docs/glossary/#task)，而 generator 會將其拆分為最多 15 個 [subtask](https://pentagi.com/zh-tw/docs/glossary/#subtask)。
2. 針對每個 subtask，primary agent 會將工作交給專家 — searcher、pentester、coder 或 installer — 他們會透過各自的 [tool](https://pentagi.com/zh-tw/docs/glossary/#tool) 來執行動作。
3. 這些 tool 會在該 [flow](https://pentagi.com/zh-tw/docs/glossary/#flow) 專屬的 [sandbox](https://pentagi.com/zh-tw/docs/glossary/#sandbox) 容器中執行，該容器是根據為該目的挑選的映像檔建構而成，並非在 PentAGI 內部執行；[worker node](https://pentagi.com/zh-tw/docs/deployment/worker-node/) 會讓它們完全脫離 PentAGI 主機執行。
4. 在每個 subtask 之後，refiner 會檢視剩餘的計畫，並在結果需要時進行變更。
5. 當 task 完成時，reporter 會撰寫其結果，而該 flow 的 [report](https://pentagi.com/zh-tw/docs/glossary/#report) 則會彙整其所有 task 的結果。

指令、其輸出與結果都會保留在該 flow 的 [memory](https://pentagi.com/zh-tw/docs/concepts/memory/) 中，因此後續的 subtask 會建立在先前的基礎上；agents 儲存在其中的指南、答案與程式碼也可供後續的 flows 使用。

## [您如何保持控制權](https://pentagi.com/zh-tw/docs/concepts/autonomous-pentesting/#where-you-stay-in-control)

* **範圍。** agents 會遵循 task：將目標、邊界以及任何參與規則寫入其中。PentAGI 本身不會限制目標，因此請在網路層級強制執行硬性邊界，例如在 [worker node](https://pentagi.com/zh-tw/docs/glossary/#worker-node) 上使用防火牆規則。
* **互動模式。** 在 **Assistant** 模式中，您可以與 agent 逐步完成測試，而不是讓它自行執行。
* **引導。** 執行中 flow 的 **Assistant** 檢視畫面可讓您檢查其狀態、停止目前的 task、發送後續指示或變更規劃的 subtasks — 請參閱 [引導執行中的 flow](https://pentagi.com/zh-tw/docs/getting-started/first-flow/#steer-a-running-flow)。
* **提問。** 啟用 `ASK_USER=true` 後，primary agent 可以暫停 flow 並向您請求輸入。此功能預設為關閉。
* **限制。** [tool call](https://pentagi.com/zh-tw/docs/glossary/#tool-call) 限制與重複偵測會阻止陷入循環的 agent，而 reflector 則會喚回停止呼叫 tool 的 agent — 請參閱 [防護措施](https://pentagi.com/zh-tw/docs/concepts/agents/#safeguards)。

## [適用時機](https://pentagi.com/zh-tw/docs/concepts/autonomous-pentesting/#when-it-fits)

自主測試適合對您自己的系統、實驗室與訓練目標進行重複評估，以及 [engagement](https://pentagi.com/zh-tw/docs/glossary/#engagement) 的初步階段：繪製攻擊面、檢查已知弱點並撰寫發現內容。它無法取代測試人員對於範圍、影響與風險的判斷，且同一 task 的兩次執行結果可能會有所不同，因此請將其 [findings](https://pentagi.com/zh-tw/docs/glossary/#finding) 視為需要確認的線索。

> [!WARNING]
> 僅測試您擁有或已獲得明確授權評估的系統。使用 PentAGI 須遵守 [EULA](https://github.com/vxcontrol/pentagi/blob/main/EULA.md)。