# 自主渗透测试

> 什么是自主渗透测试，PentAGI 如何从目标到报告执行测试，以及人员如何保持控制。

在自主渗透测试中，AI 系统自行规划并执行测试步骤。它根据迄今的发现决定下一步检查什么，运行工具，检查结果，并撰写所学内容。扫描器每次运行相同的检查；而自主 [agent](https://pentagi.com/zh-cn/docs/glossary/#agent) 会在测试过程中调整其计划。

## [PentAGI 如何运行测试](https://pentagi.com/zh-cn/docs/concepts/autonomous-pentesting/#how-pentagi-runs-a-test)

您用自然语言描述目标和目的：要评估什么、范围是什么以及怎样才算完成。从此处开始，一个 [flow](https://pentagi.com/zh-cn/docs/getting-started/first-flow/) 会自动运行：

1. 您的消息变为一个 [task](https://pentagi.com/zh-cn/docs/glossary/#task)，generator 将其拆分为最多 15 个 [subtask](https://pentagi.com/zh-cn/docs/glossary/#subtask)。
2. 对于每个 subtask，primary agent 将工作交给专家——searcher、pentester、coder 或 installer——他们通过各自的 [tool](https://pentagi.com/zh-cn/docs/glossary/#tool) 执行操作。
3. Tool 在 [flow](https://pentagi.com/zh-cn/docs/glossary/#flow) 专属的 [sandbox](https://pentagi.com/zh-cn/docs/glossary/#sandbox) 容器中运行，该容器根据目标选择的镜像构建，而非在 PentAGI 内部运行；[worker node](https://pentagi.com/zh-cn/docs/deployment/worker-node/) 使它们完全脱离 PentAGI 主机。
4. 每个 subtask 结束后，refiner 会审查剩余计划，并在结果需要时进行调整。
5. 当 task 完成后，reporter 会撰写其结果，flow 的 [report](https://pentagi.com/zh-cn/docs/glossary/#report) 会收集其所有 task 的结果。

命令、其输出和结果都保留在 flow 的 [memory](https://pentagi.com/zh-cn/docs/concepts/memory/) 中，因此后续的 subtask 可以建立在之前的基础上；agent 保存其中的指南、答案和代码也可供后续 flow 使用。

## [您保持控制的地方](https://pentagi.com/zh-cn/docs/concepts/autonomous-pentesting/#where-you-stay-in-control)

* **范围。** Agent 遵循 task：将目标、边界和任何交战规则写入其中。PentAGI 不会自行限制目标，因此请在网络层面强制执行硬性边界，例如在 [worker node](https://pentagi.com/zh-cn/docs/glossary/#worker-node) 上使用防火墙规则。
* **交互模式。** 在 **Assistant** 模式下，您与 agent 逐步完成测试，而不是让其自行运行。
* **引导。** 正在运行的 flow 的 **Assistant** 视图允许您检查其状态、停止当前 task、发送后续指令或更改计划的 subtask——请参阅 [Steer a running flow](https://pentagi.com/zh-cn/docs/getting-started/first-flow/#steer-a-running-flow)。
* **提问。** 使用 `ASK_USER=true`，primary agent 可以暂停 flow 并向您征求输入。默认情况下此功能处于关闭状态。
* **限制。** [Tool call](https://pentagi.com/zh-cn/docs/glossary/#tool-call) 限制和重复检测可以阻止陷入循环的 agent，而 reflector 可以恢复停止调用 tool 的 agent——请参阅 [Safeguards](https://pentagi.com/zh-cn/docs/concepts/agents/#safeguards)。

## [适用场景](https://pentagi.com/zh-cn/docs/concepts/autonomous-pentesting/#when-it-fits)

自主测试适用于对您自有系统、实验室和培训目标的重复评估，以及 [engagement](https://pentagi.com/zh-cn/docs/glossary/#engagement) 的初步阶段：映射攻击面、检查已知弱点并撰写发现内容。它不能替代测试人员在范围、影响和风险方面的判断，并且同一 task 的两次运行结果可能不同，因此应将其 [finding](https://pentagi.com/zh-cn/docs/glossary/#finding) 视为需要确认的线索。

> [!WARNING]
> 仅测试您拥有或已明确授权评估的系统。使用 PentAGI 需遵守 [EULA](https://github.com/vxcontrol/pentagi/blob/main/EULA.md)。