╚═════╝   ╚═╝   ╚═╝         ╚═════╝    ╚═╝   ╚═════╝ ╚═╝  ╚═╝╚══════╝╚══════╝

PHP CTF Bypass Training Ground

preg_replace 替换绕过 · file_get_contents / include 文件包含 · PHP 弱类型 专项训练

🏁 通关进度:0 / 8 剩余 8 关
1 2 3 4 5 6 7 8

Module 7: 终极综合大题

📋 GET: code, file, page + POST body 难度: ⭐⭐⭐⭐⭐ 分类: mixed
考点:preg_replace 双层过滤 + strpos 拦截 + 伪协议 + 文件包含路径绕过

Part 1 (GET: code):
· strpos 拦截明文 'hacker''bypass'(区分大小写)
· 第一层 preg_replace('/hacker/i') → 第二层 preg_replace('/bypass/i')
· 最终结果须 === 'pass'

Part 2 (GET: file, page + POST body):
· preg_match('/http|data|file/i', $file) → 拦截 http/data/file 协议
· strpos($file, 'pass') → 拦截明文 'pass'
· file_get_contents($file) 读取内容须等于 'pass'
· preg_match('/^flag/i', $page) → 拦截以 flag 开头的路径
· include($page) 包含文件获取 flag
两关须同时通过才能拿到最终 Flag。
⚠️ 注意:Part 2 需要 POST 原始数据(raw body = pass),建议用 curl 一次性提交:
💡 curl 完整解题命令: curl "http://localhost:8080/index.php?module=7&code=[Part1答案]&file=php://input&page=./flag.php" -d "pass"
[Part 1] ⏳ 待解 — 需提供 GET 参数 code