# Ctf Ops

> CTF 运维指南 — 回连验证、nuclei 模板使用、共享状态协议。 自动注入所有 CTF worker 的 system prompt。

- Skill: `chainreactors/ctf-ops` (Agent Skill)
- Install (CLI): `npx skillmds@latest add chainreactors/ctf-ops`
- Raw SKILL.md: https://api.skillmd.com/api/skills/chainreactors/ctf-ops/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: chainreactors (https://skillmd.com/u/chainreactors)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/chainreactors/ctf-ops

---


# CTF 运维指南

## 一、网络与外带策略

回连地址必须由当前授权环境提供，不要依赖固定公网 IP。

推荐约定：
- `AIDE_CALLBACK_HOST`：外带接收主机或域名。
- `AIDE_CALLBACK_PORT`：默认外带端口。
- `AIDE_CALLBACK_URL`：完整回连 URL，优先级最高。

首次需要回连前，先探测并写入共享状态：

```python
fs.shell(command="CALLBACK_HOST=${AIDE_CALLBACK_HOST:-$(hostname -I | awk '{print $1}')} && CALLBACK_URL=${AIDE_CALLBACK_URL:-http://$CALLBACK_HOST:${AIDE_CALLBACK_PORT:-9999}} && echo CALLBACK_URL=$CALLBACK_URL")
fs.shell(command="timeout 3 bash -c 'nc -lvnp ${AIDE_CALLBACK_PORT:-9999} >/tmp/callback-test.log 2>&1 &'")
memory_write("network:callback", "<实际验证通过的 URL 或 host:port> [1.0]")
```

如果目标没有出站能力，立即切换到无需回连的方案，不要反复尝试反弹 shell。

### 无回连替代方案

| 优先级 | 方案 | 适用场景 |
|--------|------|----------|
| 1 | 直接回显 | SSTI、表达式注入、UNION SELECT、命令执行回显 |
| 2 | 写文件后读取 | RCE + webroot 可写、LFI、日志读取 |
| 3 | 利用题目自身存储 | 数据库、用户资料、工单、构建日志、文件上传 |
| 4 | DNS 外带 | 有 DNS 出站但无 TCP |
| 5 | 时间/布尔盲注 | 完全无出站 |
| 6 | SSRF 中转 | 目标能访问内部服务且响应可回显 |

## 二、POC 与模板

### 搜索方法

```python
# 搜索 nuclei 模板
nuclei_templates.search("<产品名或CVE>")
nuclei_templates.read("<模板路径>")

# 如果 MCP 工具不可用，回退到 shell
fs.shell(command="rg -li '<关键词>' /root/nuclei-templates ~/.aide-corpora/nuclei-templates 2>/dev/null")

# 直接执行模板
fs.shell(command="nuclei -u <target> -t <template_path> -timeout 30 -nc")
```

识别出具体产品/中间件后，先查 nuclei 模板再盲打：

```python
nuclei_templates.search("<产品名>")
```

## 三、运行前检查

```python
# ripgrep 是 nuclei 模板搜索的基础依赖
fs.shell(command="which rg && rg --version")

# 模板目录
fs.shell(command="ls /root/nuclei-templates/http 2>/dev/null || ls ~/.aide-corpora/nuclei-templates/http 2>/dev/null || true")

# 常用安全工具
fs.shell(command="which nmap sqlmap gobuster ffuf nuclei hydra curl whatweb")
```

## 四、共享状态协议

所有 worker 通过 memory 共享事实，使用统一 key 前缀：

```text
target:*     目标信息
port:*       开放端口和服务
surface:*    暴露面和高价值端点
vuln:*       已确认漏洞
cred:*       发现的凭据
access:*     已获取的访问层级
constraint:* 环境限制、WAF、网络隔离
dead:*       已证实死路
flag:*       已捕获 flag
technique:*  已验证有效技术
bypass:*     已验证绕过方法
blocker:*    当前阻塞点
network:*    网络拓扑和回连测试结果
```

权重约定：
- `[1.0]` 已确认事实
- `[0.5]` 待验证推测
- `[0.0]` 或 `[dead]` 死路

## 五、工具速查

```python
fs.shell(command="nmap -sV -sC -p- --min-rate 3000 <target>")
fs.shell(command="sqlmap -u '<url>?id=1' --batch --level 3")
fs.shell(command="gobuster dir -u <target> -w /usr/share/seclists/Discovery/Web-Content/common.txt -k")
fs.shell(command="ffuf -u <target>/FUZZ -w /usr/share/seclists/Discovery/Web-Content/common.txt")
fs.shell(command="nuclei -u <target> -t <template_path> -timeout 30 -nc")
fs.shell(command="whatweb -a 3 <target>")
```

找到 flag 后立即提交，不要等到 session 结束：

```python
submit_flag(code="<challenge_code>", flag="flag{...}")
memory_write("flag:<name>", "flag{...} — submitted, correct [1.0]")
```

