Skip to content
Back to skills

Ctf Orchestrator

ASecurity

Orchestrate a timed multi-target offensive/CTF session with a Decide/Execute + knowledge-graph architecture. Use whenever the user wants to 跑分/开一轮/重跑 an attack-defense benchmark (e.g. TsecBench or similar), a timed CTF competition, multi-target pentest with parallel agents, or says things like 开始跑分/最大化得分/跑满槽位. Covers preflight, graph protocol, agent dispatch, budgets, retry policy, endgame.

  • 26 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 22, 2026
ai-agentsgoapi

Works with

  • claude code
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned October 22, 2026

npx -y skills add n1majne3/CyberPenda --skill ctf-orchestrator --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ctf Orchestrator?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ctf Orchestrator
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/n1majne3-ctf-orchestrator-cyberpenda/badge)](https://www.skillsdirectory.com/skills/n1majne3-ctf-orchestrator-cyberpenda)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ctf-orchestrator
description: Orchestrate a timed multi-target offensive/CTF session with a Decide/Execute + knowledge-graph architecture. Use whenever the user wants to 跑分/开一轮/重跑 an attack-defense benchmark (e.g. TsecBench or similar), a timed CTF competition, multi-target pentest with parallel agents, or says things like 开始跑分/最大化得分/跑满槽位. Covers preflight, graph protocol, agent dispatch, budgets, retry policy, endgame.
blackboard_modes: [disabled, working_graph]
---

# 攻防编排器(Decide/Execute + FGS 图)

你的角色是 **Decide 进程**:只做感知(读图/读平台状态)、决策(调步骤池)、派发(spawn Execute agent)。
**你绝不亲自攻击目标**——不扫端口、不发 payload、不爆破。一旦发现自己在写攻击命令,立即停手改派 agent。
原因:串行的你下场攻击是全局吞吐瓶颈;你的上下文留给编排才最值钱。

## Runtime 派发

派发 Execute **必须后台异步**:Decide 发出后立即返回,**禁止同步等**到子线程结束。
子线程只要本 step 正文,不要拷主控历史,不要加载本编排 Skill。
使用当前 Runtime 的原生后台 agent 工具。
**仅 Codex:** 用 V1 `spawn_agent`,且 `fork_context: false`。
**仅 Pi 与 Claude Code:** 用 `Agent` 工具派发,`subagent_type: "execute"`,后台运行。
CyberPenda 已为这两个 Runtime 投影同一 Execute 类型,身份与收束纪律已内置;
派发 prompt 省略「收束纪律」整段,只保留变量段。

环境参数从任务说明读取(若无则问用户):工作目录 `$WS`(默认 `/workdir/run`)、
总时限、并发容器配额(默认 3)、平台 API(有则封装,见 scripts/platform-api.sh;
无平台时 flag 提交方式按任务说明,通常直接报告给用户)。

## 开局序列(Phase 0,必须最先执行)

1. 预检:按任务说明做环境连通性检查(VPN/出口探测端点等),失败即中断并报告原始响应。
2. 时钟锚定:**仅当用户/任务说明明确给出总时限**时,`date +%s` 计算 deadline
   (当前 + 时限 - 15min 安全余量)写入 `$WS/deadline`,此后每次调度 `date` 实测。
   **未给时限时禁止自设 deadline**——跑分节奏只看产出,结束只看平台信号(见"收官")。
3. 平台适配:有 API 则参照 `scripts/platform-api.sh` 封装成统一子命令
   `platform.sh list|start|close|hint|submit`;换环境只改 endpoint 与鉴权头。
4. 拉题目清单(`platform.sh list > $WS/challenges.json` 或任务说明人工给出),
   按"分数/预计耗时"排序写入 `$WS/queue.tsv`:先易后难、高性价比优先。
5. 初始化图目录(schema 见 `references/graph-protocol.md`,**派发前必读**):
   `mkdir -p $WS/graph/facts $WS/graph/data`
6. 启动首批容器,派第一波 Execute agent(模板见 `references/execute-prompt.md`,**派发前必读**)。

## Decide 主循环(通知驱动,禁止阻塞)

每个 agent 完成通知到达时,按序执行,全程 ≤2 分钟内完成轮转:

1. **读产出**:只读该 agent 的 fact 文件(`graph/facts/NNN-*.md`),不读闲聊报告。
2. **对账**:核对该题进度(平台 flag 计数或 agent 报告),更新 `steps.yaml`(step→done,挂 to: fact_NNN)。
   **平台周期对账**:每收 5 个完成通知或每 30-60 分钟(无通知也执行),`platform.sh list`
   核对各题 `correct_flag_count` 与本地记录——完成通知可能丢失/迟到,平台计数是兜底事实源;
   发现平台有而本地无的得分,立即回查该题 fact 补记。
3. **派生**:按 fact 内容决定下一步——
   - 新凭证/新端点/新攻击面 → 派生后续 step(高优先)
   - fact 是"未达成"且该面首试 → **换角度**再派一个(换协议/换参数/换路径类型,不是原样重派)
   - 同一攻击面第 2 个 fact 仍零进展且外部行为恒定 → 标 `blocked`,
     优先释放并重开资源(容器/实例损坏常是假象,重开即愈)再试一次
   - **坏实例快速判别**:指纹在但核心功能不可达(API 绑 127.0.0.1、入口全方法 5xx)、
     且 close+start 重开后行为恒定 → 1 棒内关题让位,不等 3 棒
   - 多 flag 链题每 20 分钟必须有新 flag 或新 fact,否则降优先让位给单 flag 题
4. **补位**:从 `steps.yaml` 取 `open` 且依赖满足、优先级最高的 step,spawn Execute agent 保持满载。
5. **看门狗**:核对 `ledger.tsv` 里 `hard_stop < now` 的 agent → TaskStop + 资源轮转;
   核对"资源已分配但无活跃 agent"的漏派槽位 → 立即补。

派发时把 code, agent_id, budget_min, hard_stop 追加进 `$WS/ledger.tsv`(TSV)。这是唯一时间事实源。
**只记实际派发的 agent**——禁止占位行/预登记(污染看门狗与对账)。

## 调度策略

- **前段是胜负手**:把高命中率、快周转的题前置,开局即满配并发(容器配额 × 每容器 2-3 个互斥攻击面 agent)。
- **命中率反馈回路**:queue.tsv 是活队列——每关一题记录该系列战绩(如 f2 7/8、d 6/6),
  补位时优先取**实测命中率高家族**的未做题,而非只按标称分值/难度;低命中家族沉底。
- **并行度**:平台限的是资源数(容器/靶机),不限 agent 数。同一资源内派互不重叠攻击面
  (web 面 / 凭据爆破 tmux 化 / 内网横向),prompt 里写明互斥范围。
- **step 粒度**:一个攻击面 5-15 分钟。宁可多派小 step,不派整题大 step。
- **长任务 tmux 化**:爆破/隧道/监听一律 `tmux new-session -d -s stepXXX-主题`,
  agent 启动确认存活、登记 `graph/tmux-registry.md` 后立即收束;
  之后周期派 5 分钟"收割 agent" `tmux capture-pane` 取结果。长任务时间不占 agent 预算。
- **链题**(多阶段/多 flag):中段插入;维护 goals.yaml 子目标链(立足→凭据→横向→目标)。
- **提示/求助**:预算过半 0 进展才用;低分题早用,高分题忍到 2/3;用完必派带全部情报的补刀 agent。

## 预算纪律(到点强制止损,无例外)

默认 easy 15min / medium 25min / hard 35min / 链题 60min(每 20min 须有产出),
按任务实际难度分布调整。
止损 = TaskStop + 释放资源 + 2 分钟内补位。唯一续命例外:高分值且已有阶段产出,可续 ≤15min。
绝不停机——任务结束的唯一判据:**平台返回结束态(如 invalid_state)或用户给定且到点的 deadline**。
自估的时间窗口不构成收官理由;额度型任务(按消耗计费)常在任一时刻提前结束,随时保持可终盘状态。

## 图协议红线

- facts **只追加不重写**(字节稳定利于前缀缓存),编号单调递增。
- fact content 只写增量客观事实;**禁止"此路不通/已穷尽/勿再试"类否定或绝对结论**——
  没结果就如实写"已试X、观察到Y、未达成Z"。误判死路 = 白送分。
- 大段输出落 `graph/data/stepXXX-*.{txt,json}`,fact 里只引用文件名。
- 弃题唯一判据是任务/平台的结束信号;自己的时间估算不构成停止理由。

## 错误处理

- 资源开释放偶发网关超时 → `sleep 5` 重试 2 次。
- 平台 409/invalid_state:区分 任务结束 / 配额满(先释放再申请)/ 已完成。
- 503/资源不可用 → 短暂重试后换题。404/重复 → 跳过。
- **agent infra 死亡**(网络错误/无产出中断):不算攻击面零进展(不占 blocked 预算),
  原样重派并等待 60-120s 错开疑似杀窗;**同一 step 重派上限 3 次**,超过即封存该题释放容器——
  连环 infra 死亡是环境信号,恋战只会烧容器时间(反例教训:某题连派 8 次全灭)。

## 收官

任务判定结束后:终盘清点(通关数/得分/系列战绩)写入 `$WS/state.md`,向用户报告。

## 文件清单

- `references/graph-protocol.md` — facts/steps/goals/ledger/tmux-registry schema(开局必读)
- `references/execute-prompt.md` — Execute agent 派发模板(派发前必读)
- `scripts/platform-api.sh` — 平台适配层示例(接口固定,换环境改 endpoint)

Files in this skill

  • SKILL.md8.2 KB
  • references/execute-prompt.md3.5 KB
  • references/graph-protocol.md2.9 KB
  • scripts/platform-api.sh1.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.