目录
第一题:input
代码
php
<meta charset="utf8">
<?php
error_reporting(0);
$file = $_GET["file"];
if(stristr($file,"php://filter") || stristr($file,"zip://") || stristr($file,"phar://") || stristr($file,"data:")){
exit('hacker!');
}
if($file){
if ($file!="http://www.baidu.com") echo "tips:flag在当前目录的某个文件中";
include($file);
}else{
echo '<a href="?file=http://www.baidu.com">click go baidu</a>';
}
?>
解题过程
这里过滤了一些协议,但是没有过滤php://input这样的一个协议
这里就用php://来读取并执行命令
这里用bp抓包,然后修改传参方式后post传入你要执行的php代码
这里是先查看了一下文件路径,发现flag文件

然后读取文件,这里系统是windows使用type来进行读取,成功读出flag

第二题:input
源码
php
<?php
show_source(__FILE__);
include('flag.php');
$a= $_GET["a"];
if(isset($a)&&(file_get_contents($a,'r')) === 'I want flag'){
echo "success\n";
echo $flag;
}
解题过程
这里是要想办法让程序走到if条件语句里面,也就是要读一个a变量并且使用file_get_contents读这个a然后a里面的内容是I want flag
我们使用php://input来传值,抓包传值

第三题:filter
源码
php
<meta charset="utf8">
<?php
error_reporting(0);
$file = $_GET["file"];
if(stristr($file,"php://input") || stristr($file,"zip://") || stristr($file,"phar://") || stristr($file,"data:")){
exit('hacker!');
}
if($file){
include($file);
}else{
echo '<a href="?file=flag.php">tips</a>';
}
?>
解题过程
这里过滤了很多协议,但是没有过滤php://filter所以直接读,由于读出来的是base64编码所以要解码
php
http://127.0.0.1/test/include_file.php?file=php://filter/read=convert.base64-encode/resource=flag.php

第四题:zip
源码
php
//index.php
<meta charset="utf8">
<?php
error_reporting(0);
$file = $_GET["file"];
if (!$file) echo '<a href="?file=upload">upload?</a>';
if(stristr($file,"input")||stristr($file, "filter")||stristr($file,"data")/*||stristr($file,"phar")*/){
echo "hick?";
exit();
}else{
include($file.".php");
}
?>
<!-- flag在当前目录的某个文件中 -->
//upload.php
<meta charset="utf-8">
<form action="upload.php" method="post" enctype="multipart/form-data" >
<input type="file" name="fupload" />
<input type="submit" value="upload!" />
</form>
you can upload jpg,png,zip....<br />
<?php
if( isset( $_FILES['fupload'] ) ) {
$uploaded_name = $_FILES[ 'fupload' ][ 'name' ]; //文件名
$uploaded_ext = substr( $uploaded_name, strrpos( $uploaded_name, '.' ) + 1); //文件后缀
$uploaded_size = $_FILES[ 'fupload' ][ 'size' ]; //文件大小
$uploaded_tmp = $_FILES[ 'fupload' ][ 'tmp_name' ]; // 存储在服务器的文件的临时副本的名称
$target_path = "uploads\\".md5(uniqid(rand())).".".$uploaded_ext;
if( ( strtolower( $uploaded_ext ) == "jpg" || strtolower( $uploaded_ext ) == "jpeg" || strtolower( $uploaded_ext ) == "png" || strtolower( $uploaded_ext ) == "zip" ) &&
( $uploaded_size < 100000 ) ) {
if( !move_uploaded_file( $uploaded_tmp, $target_path ) ) {// No
echo '<pre>upload error</pre>';
}
else {// Yes!
echo "<pre>".dirname(__FILE__)."\\{$target_path} succesfully uploaded!</pre>";
}
}
else {
echo '<pre>you can upload jpg,png,zip....</pre>';
}
}
?>
解题过程
这里过滤了input和filter和data,但是这里有一个上传文件,并且可以上传zip文件。同时这里可以使用zip协议。我们先上传我们的一句话木马

压缩

上传

zip解压,再include包含,成功
