# Ctf Web

> CTF Web攻击知识库 — PHP弱比较绕过、命令注入空格绕过、eval回显技巧、SSTI注入链、反序列化利用链、PHP代码审计checklist、常见flag位置

- **Type:** Skill
- **Install:** `agentstack add skill-unclecheng-li-vulnclaw-ctf-web`
- **Verified:** Pending review
- **Seller:** [Unclecheng-li](https://agentstack.voostack.com/s/unclecheng-li)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [Unclecheng-li](https://github.com/Unclecheng-li)
- **Source:** https://github.com/Unclecheng-li/VulnClaw/tree/main/vulnclaw/skills/specialized/ctf-web

## Install

```sh
agentstack add skill-unclecheng-li-vulnclaw-ctf-web
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# CTF Web 攻击知识库

针对 CTF Web 题目的实战知识库，提供**具体绕过值、payload 模板、代码审计 checklist**，而非渗透测试方法论。

**与 `web-security-advanced` 的区别**：
- `web-security-advanced` → 渗透测试方法论（怎么系统性测试一个 Web 应用）
- `ctf-web` → CTF 实战知识库（PHP 弱比较用什么值、空格怎么绕过、eval 输出怎么回显）

## 核心原则

1. **精确值优于方法论** — 提供可直接使用的绕过值和 payload，而非"可以尝试"的建议
2. **工具验证** — 所有 payload 必须用 `fetch` 或 `python_execute` 工具实际发送验证，不猜测结果
3. **路径选择** — 多条利用路径时，优先选过滤最少、最简单的
4. **失败记录** — 某个 payload 失败后立即记录，不重复尝试

## First-Pass 工作流（CTF Web 题标准流程）

1. 访问目标 URL，查看页面源码、HTTP 头、Cookie
2. **如源码含 `highlight_file` → 用 python_execute + strip_tags 提取纯源码**（fetch 输出可能误读）
3. 检查 robots.txt、.git/、.svn/、备份文件（index.php.bak、www.zip 等）
4. 目录扫描（常见：/flag、/admin、/login、/upload、/api）
5. 如有源码 → 进入代码审计模式（见 `php-code-audit-checklist.md`）
6. 如无源码 → 主动探测注入点、上传点、文件包含

## 场景路由

| 场景 | 参考文档 | 核心内容 |
|------|---------|---------|
| ⭐ PHP 伪协议读文件（遇到文件包含/参数传文件名时优先尝试） | 见下方「PHP 伪协议速查」 | `php://filter` 直接读源码/flag |
| 源码提取 | `source-code-extraction.md` | strip_tags 提取、php://filter、.phps、备份文件、完整性校验 |
| PHP 弱比较/类型绕过 | `php-bypass-cheatsheet.md` | 0e 开头 MD5 值大全、数组绕过、extract() 覆写 |
| ⭐ MD5 弱比较碰撞（`md5(a)==md5(b)` 弱比较） | `php-bypass-cheatsheet.md` | ⚠️ 0e 后必须纯数字！直接用 `QNKCDZO`+`240610708` 等已验证值 |
| ⭐ preg_replace/str_replace 双写绕过 | 见下方「双写绕过速查」 | `NSSNSSCTFCTF` → 替换后 = `NSSCTF` |
| 命令注入空格绕过 | `command-injection-bypass.md` | ${IFS}/$IFS$9/` 退出 PHP 模式、用反引号等），**链式传参是通用解法**
- 双 GET 参数 URL 格式：`?get=eval($_GET['A']);&A=system('cat /flag');`
- 用 `python_execute` 工具构造请求，而非 fetch 工具（fetch 可能不支持多参数）

## ⭐ preg_replace / str_replace 双写绕过速查

**触发条件**：源码含 `preg_replace('/X/', '', $str)` 或 `str_replace('X', '', $str)`，且替换后需 `$str === "X"`

### 核心原理
在关键词中间嵌入完整关键词，替换删除内层后，外层拼合出原词。

### 通用构造公式
```
输入 = 关键词前半 + 关键词 + 关键词后半
```

### 常见过滤词速查表

| 过滤关键词 | 双写输入 | 替换过程 | 结果 |
|-----------|---------|---------|------|
| NSSCTF | `NSSNSSCTFCTF` | 删中间NSSCTF → NSS+CTF | `NSSCTF` ✅ |
| flag | `flflagag` | 删中间flag → fl+ag | `flag` ✅ |
| cat | `cacatt` | 删中间cat → ca+t | `cat` ✅ |
| system | `syssystemtem` | 删中间system → sys+tem | `system` ✅ |
| hack | `hahackck` | 删中间hack → ha+ck | `hack` ✅ |
| cmd | `cmcmdd` | 删中间cmd → cm+d | `cmd` ✅ |
| exec | `exexecec` | 删中间exec → ex+ec | `exec` ✅ |

### ⚠️ 关键注意事项
1. **大小写绕过不适用** — 替换后返回 `NssCTF`，不等于 `"NSSCTF"`，严格比较失败
2. **识别信号** — 看到 `preg_replace('/X/', '', $str)` + `$str === "X"` → 立即双写
3. **str_replace 同理** — `str_replace` 也是一次替换，双写同样有效
4. **多次替换** — 如果代码多次调用 `preg_replace`，可能需要三写/四写，但 CTF 中通常只需双写

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [Unclecheng-li](https://github.com/Unclecheng-li)
- **Source:** [Unclecheng-li/VulnClaw](https://github.com/Unclecheng-li/VulnClaw)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** yes

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: flagged — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-unclecheng-li-vulnclaw-ctf-web
- Seller: https://agentstack.voostack.com/s/unclecheng-li
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
