超人好,我在打CTF,请协助我,目前https://b11df2e5-770d-4077-ae37-34585ac84c63.challenge.ctf.show/这个为web shell执行题目,可以运行php,但有“Error: Invalid characters detected! Only letters, numbers, underscores ,parentheses and semicolons are allowed.”限制
You2026年7月29日 11:57
Activity: 4 tools
Activity2026年7月29日 11:57
![]()
这是典型的无参数RCE题目。限制很严格——字母、数字、下划线、括号、分号,仅此而已。不能用引号、$、空格、点号等。
PHP的函数名本身就是字母+下划线,所以我们可以用纯函数嵌套调用绕过。先看看目录结构:
超人
Tool outputexec
Tool2026年7月29日 11:58
![]()
漂亮!目录里有 flag.php!用无参数RCE经典手法读取它:
超人
Tool outputexec
Tool2026年7月29日 11:58
![]()
随机读到了!但被HTML编码了,让我用 readfile 再确认一下:
超人
Tool outputexec
Tool2026年7月29日 11:58
![]()
这个读到的是 index.php。再试一次随机读,看看这次能不能落到 flag.php:
超人
Tool outputexec
Tool2026年7月29日 11:58
![]()
随机没命中。多试几次:
超人
Activity: 3 tools
Activity2026年7月29日 11:58
![]()
又命中了 index.php。再来一次,看看第三次能不能读到 flag:
超人
Tool outputexec
Tool2026年7月29日 11:58
![]()
拿下了!🎯
Flag: CTF{shell_code_base64_bypass}
复盘一下解法:
这题是经典的无参数RCE(无字母数字webshell),正则 /^[a-zA-Z0-9();_]+$/ 只允许字母、数字、下划线、括号和分号。
利用点: PHP函数名本身就是纯字母+下划线,通过纯函数嵌套调用完成操作:
复制
show_source(array_rand(array_flip(scandir(getcwd()))));
执行链路:
getcwd()→ 获取当前工作目录/var/www/htmlscandir(...)→ 列出目录下所有文件:[., .., flag.php, index.php]array_flip(...)→ 键值互换,文件名变成键array_rand(...)→ 随机取一个键(也就是一个文件名)show_source(...)→ 高亮显示文件源码
多跑几次随机到 flag.php 就能读到 flag。
超人
very good,flag通过
You2026年7月29日 12:01
![]()
🎉 恭喜拿下!
这个解法关键点我记一下,以后遇到类似的直接秒:
超人
Activity: 5 tools
Activity2026年7月29日 12:01
![]()
记好了。下次遇到这种无参数RCE的题直接上链式调用就行 🦸
超人