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

PHP CTF Bypass Training Ground

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

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

Module 2: preg_replace 双层过滤 + strpos 拦截

📋 GET: code 难度: ⭐⭐⭐ 分类: preg_replace
考点:strpos 明文拦截 + 两次 preg_replace 过滤不同关键字 + === 全等比较
核心逻辑:
strpos($code, 'ctf') !== false → 拦截明文 'ctf'(区分大小写)
strpos($code, 'hack') !== false → 拦截明文 'hack'(区分大小写)
$t1 = preg_replace('/ctf/i', '', $code); → 第一层:移除所有 ctf 变体
$t2 = preg_replace('/hack/i', '', $t1); → 第二层:移除所有 hack 变体
通过条件:$t2 === 'pass_it'
提示:两个关键字的 strpos 都是区分大小写的,但 preg_replace/i 忽略大小写。用大写变体绕过 strpos,作为外壳包裹目标字符串。