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

PHP CTF Bypass Training Ground

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

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

Module 1: preg_replace 双写绕过

📋 GET: code 难度: ⭐⭐ 分类: preg_replace
考点:preg_replace 全局替换为空 + === 全等比较 + 重叠双写绕过
核心逻辑:$clean = preg_replace('/ctf/i', '', $_GET['code']); 然后 $clean === 'ctf'
原理:preg_replace单次扫描,找到所有不重叠的匹配项后一次性替换。如果目标关键字被嵌入到重叠位置(如 ctctff),正则只能匹配到其中一组,移除后残余部分恰好形成目标字符串。
提示:思考 ctctff 这样的结构 — 正则匹配到中间的 ctf(位置 2-4),移除后剩余 ct + f = ctf